diff --git a/PlotDirector.NativeCompanion/DeveloperVersion.props b/PlotDirector.NativeCompanion/DeveloperVersion.props
index 5635d912..4144e814 100644
--- a/PlotDirector.NativeCompanion/DeveloperVersion.props
+++ b/PlotDirector.NativeCompanion/DeveloperVersion.props
@@ -1 +1 @@
-1.0.0.46
+1.0.0.47
diff --git a/PlotDirector.NativeCompanion/Vsto/NativeRibbon.cs b/PlotDirector.NativeCompanion/Vsto/NativeRibbon.cs
index fa0cb71e..8eedce46 100644
--- a/PlotDirector.NativeCompanion/Vsto/NativeRibbon.cs
+++ b/PlotDirector.NativeCompanion/Vsto/NativeRibbon.cs
@@ -69,9 +69,10 @@ namespace PlotDirector.WordAddIn
}
public bool GetFocusHeld(Office.IRibbonControl control)=>adapter()?.WindowFocusHeld(control?.Context)==true;
- public string GetFocusAction(Office.IRibbonControl control)=>GetFocusHeld(control)?"Release Hold":"Hold";
+ public string GetFocusAction(Office.IRibbonControl control)=>CanHoldFocus(control)&&GetFocusHeld(control)?"Resume":"Hold";
+ public object GetFocusIcon(Office.IRibbonControl control)=>GetPlaybackIcon(CanHoldFocus(control)&&GetFocusHeld(control)?"PlotDirectorAudioPlay":"PlotDirectorAudioPause");
public bool CanHoldFocus(Office.IRibbonControl control)=>adapter()?.CanHoldFocus==true;
- public string GetFocusTip(Office.IRibbonControl control)=>!CanHoldFocus(control)?"Connect Companion and select a linked Word manuscript.":GetFocusHeld(control)?"Release Hold: catch up to shared manuscript focus. Content synchronisation stays active.":"Hold this Word window at its local position. Other windows and content synchronisation continue.";
+ public string GetFocusTip(Office.IRibbonControl control)=>!CanHoldFocus(control)?"Connect Companion and select a linked Word manuscript.":GetFocusHeld(control)?"Resume: catch up to shared manuscript focus. Content synchronisation stays active.":"Hold this Word window at its local position. Other windows and content synchronisation continue.";
public void ToggleFocusHold(Office.IRibbonControl control,bool pressed){adapter()?.SetFocusHeld(pressed);Invalidate();}
public bool CanOpenBook(Office.IRibbonControl control) => adapter()?.HasRibbonBook == true;
public string GetBookTip(Office.IRibbonControl control) => adapter()?.RibbonBook ?? "No linked book";
@@ -93,9 +94,11 @@ namespace PlotDirector.WordAddIn
public void AudioBack(Office.IRibbonControl control) => adapter()?.RequestAudio("back15");
public void AudioForward(Office.IRibbonControl control) => adapter()?.RequestAudio("forward15");
- public object GetPlaybackIcon(Office.IRibbonControl control)
+ public object GetPlaybackIcon(Office.IRibbonControl control)=>GetPlaybackIcon(control.Id);
+
+ private object GetPlaybackIcon(string id)
{
- if (playbackIcons.TryGetValue(control.Id, out var icon)) return icon;
+ if (playbackIcons.TryGetValue(id, out var icon)) return icon;
using (var bitmap = new Bitmap(32, 32))
using (var graphics = Graphics.FromImage(bitmap))
@@ -104,7 +107,7 @@ namespace PlotDirector.WordAddIn
using (var shape = new GraphicsPath())
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
- switch (control.Id)
+ switch (id)
{
case "PlotDirectorAudioPlay":
shape.AddPolygon(new[] { new Point(8, 4), new Point(27, 16), new Point(8, 28) });
@@ -117,7 +120,7 @@ namespace PlotDirector.WordAddIn
case "PlotDirectorAudioForward":
shape.AddPolygon(new[] { new Point(3, 7), new Point(15, 16), new Point(3, 25) });
shape.AddPolygon(new[] { new Point(16, 7), new Point(28, 16), new Point(16, 25) });
- if (control.Id == "PlotDirectorAudioBack")
+ if (id == "PlotDirectorAudioBack")
{
graphics.TranslateTransform(31, 0);
graphics.ScaleTransform(-1, 1);
@@ -130,7 +133,7 @@ namespace PlotDirector.WordAddIn
graphics.DrawPath(outline, shape);
icon = RibbonPicture.FromImage(bitmap);
}
- playbackIcons.Add(control.Id, icon);
+ playbackIcons.Add(id, icon);
return icon;
}
diff --git a/PlotDirector.NativeCompanion/Vsto/Properties/AssemblyInfo.cs b/PlotDirector.NativeCompanion/Vsto/Properties/AssemblyInfo.cs
index 9afcd3b4..cae4aae1 100644
--- a/PlotDirector.NativeCompanion/Vsto/Properties/AssemblyInfo.cs
+++ b/PlotDirector.NativeCompanion/Vsto/Properties/AssemblyInfo.cs
@@ -3,6 +3,6 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("PlotDirector Word Companion — Native development")]
[assembly: AssemblyCompany("Nick Beckley")]
[assembly: AssemblyProduct("PlotDirector")]
-[assembly: AssemblyVersion("1.0.0.46")]
-[assembly: AssemblyFileVersion("1.0.0.46")]
+[assembly: AssemblyVersion("1.0.0.47")]
+[assembly: AssemblyFileVersion("1.0.0.47")]
[assembly: ComVisible(false)]
diff --git a/PlotDirector.NativeCompanion/Vsto/Ribbon.xml b/PlotDirector.NativeCompanion/Vsto/Ribbon.xml
index 54d96ed7..07659bd1 100644
--- a/PlotDirector.NativeCompanion/Vsto/Ribbon.xml
+++ b/PlotDirector.NativeCompanion/Vsto/Ribbon.xml
@@ -7,7 +7,7 @@
-
+
diff --git a/PlotDirector.NativeCompanion/WindowsValidation/Setup/Release.json b/PlotDirector.NativeCompanion/WindowsValidation/Setup/Release.json
index 596473e8..e78ec96c 100644
--- a/PlotDirector.NativeCompanion/WindowsValidation/Setup/Release.json
+++ b/PlotDirector.NativeCompanion/WindowsValidation/Setup/Release.json
@@ -1,7 +1,7 @@
{
- "version": "1.0.0.46",
- "msiVersion": "1.0.46",
- "productCode": "{BEEA290D-63A3-48EF-A8C9-753B9FBA92DA}",
+ "version": "1.0.0.47",
+ "msiVersion": "1.0.47",
+ "productCode": "{34A55804-99FD-48F1-9855-13BFC88F9625}",
"upgradeCode": "{641A087B-9779-458C-B290-BCBBAD49319A}",
"atlasBaseline": "9fed339879887964d526cff00772ffc4dc522c5d",
"baselineProductCode": "{98F46939-764D-407F-BD1F-1D88315D010A}",
diff --git a/PlotDirector.NativeCompanion/WindowsValidation/Test-WordFocusRibbon.ps1 b/PlotDirector.NativeCompanion/WindowsValidation/Test-WordFocusRibbon.ps1
new file mode 100644
index 00000000..3efc54b8
--- /dev/null
+++ b/PlotDirector.NativeCompanion/WindowsValidation/Test-WordFocusRibbon.ps1
@@ -0,0 +1,39 @@
+[CmdletBinding()]
+param([Parameter(Mandatory)][string]$PackagePath)
+$ErrorActionPreference='Stop'
+# Run under Windows PowerShell/.NET Framework. Loads signed build bytes in this
+# short-lived process; never starts Office, registers VSTO or changes installation.
+if($env:OS -ne 'Windows_NT' -or $PSVersionTable.PSEdition -ne 'Desktop'){throw 'Use Windows PowerShell for the .NET Framework VSTO ribbon check.'}
+. (Join-Path $PSScriptRoot 'DeveloperPackage.ps1')
+$package=Test-DeveloperPackage $PackagePath
+$script:passed=0
+function Check([bool]$condition,[string]$message){if(!$condition){throw $message};$script:passed++;Write-Output "PASS $message"}
+$assembly=[Reflection.Assembly]::LoadFrom((Join-Path $PackagePath 'PlotDirector.WordAddIn.dll'))
+Check ($assembly.GetName().Version.ToString() -eq $package.version) 'Loaded ribbon assembly matches the qualified package version'
+$adapterType=$assembly.GetType('PlotDirector.WordAddIn.WordAdapter',$true)
+$ribbonType=$assembly.GetType('PlotDirector.WordAddIn.NativeRibbon',$true)
+$factoryType=[Func``1].MakeGenericType($adapterType)
+$factoryMethod=[Reflection.Emit.DynamicMethod]::new('NoWordAdapter',$adapterType,[Type[]]@())
+$il=$factoryMethod.GetILGenerator();$il.Emit([Reflection.Emit.OpCodes]::Ldnull);$il.Emit([Reflection.Emit.OpCodes]::Ret)
+$factory=$factoryMethod.CreateDelegate($factoryType)
+$ribbon=[Activator]::CreateInstance($ribbonType,[object[]]@($factory))
+function Callback([string]$name){$ribbonType.GetMethod($name,[Reflection.BindingFlags]'Public,Instance').Invoke($ribbon,[object[]]@($null))}
+$xml=[xml](Callback 'GetCustomUI')
+$ns=New-Object Xml.XmlNamespaceManager($xml.NameTable);$ns.AddNamespace('r','http://schemas.microsoft.com/office/2009/07/customui')
+$hold=$xml.SelectSingleNode('//r:toggleButton[@id="PlotDirectorHold"]',$ns)
+Check ($hold -and $hold.size -eq 'large' -and $hold.ParentNode.id -eq 'PlotDirectorSharedFocus') 'Large focus toggle remains in the Manuscript focus group'
+Check ($hold.getLabel -eq 'GetFocusAction' -and $hold.getImage -eq 'GetFocusIcon' -and $hold.getPressed -eq 'GetFocusHeld' -and $hold.getEnabled -eq 'CanHoldFocus' -and $hold.onAction -eq 'ToggleFocusHold') 'Dynamic label, image, enabled, pressed and existing action bindings are present'
+Check (!$hold.HasAttribute('imageMso')) 'Static Lock icon cannot override the dynamic Pause/Play image'
+Check (!$xml.SelectSingleNode('//*[@id="PlotDirectorFocusState"]') -and !$xml.SelectSingleNode('//*[@id="PlotDirectorIntent"]')) 'Redundant State and retired Intent controls are absent'
+foreach($control in @('PlotDirectorBook','PlotDirectorChapter','PlotDirectorScene','PlotDirectorContext','PlotDirectorWeb','PlotDirectorOpen','PlotDirectorAudioReview','PlotDirectorSynchronise','PlotDirectorTools')){
+ Check ($null -ne $xml.SelectSingleNode("//*[@id='$control']")) "Preserved ribbon control $control"
+}
+Check ((Callback 'GetFocusAction') -eq 'Hold' -and !(Callback 'CanHoldFocus') -and !(Callback 'GetFocusHeld')) 'Unavailable callback state is Hold, disabled and unpressed'
+Check ((Callback 'GetFocusTip') -match 'Connect Companion') 'Unavailable tooltip explains how to recover'
+$pause=Callback 'GetFocusIcon';$again=Callback 'GetFocusIcon'
+Check ($null -ne $pause -and [object]::ReferenceEquals($pause,$again)) 'Unavailable Pause icon is rendered and cached without ribbon churn'
+$imageMethod=$ribbonType.GetMethod('GetPlaybackIcon',[Reflection.BindingFlags]'NonPublic,Instance',$null,[Type[]]@([string]),$null)
+$play=$imageMethod.Invoke($ribbon,[object[]]@('PlotDirectorAudioPlay'))
+$cachedPause=$imageMethod.Invoke($ribbon,[object[]]@('PlotDirectorAudioPause'))
+Check ($null -ne $play -and ![object]::ReferenceEquals($play,$pause) -and [object]::ReferenceEquals($cachedPause,$pause)) 'Play and Pause reuse the established distinct Audio Review image cache'
+Write-Output "PASS Windows compiled ribbon qualification: $script:passed assertions; Word and the installer were not executed."