| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | param([Parameter(Mandatory=$true)][string]$Root, [Parameter(Mandatory=$true)][string]$CloneHost) |
| 2 | Set-StrictMode -Version Latest |
| 3 | $ErrorActionPreference = 'Stop' |
| 4 | & "$PSScriptRoot\cold-current.ps1" -Root $Root -CloneHost $CloneHost |
| 5 | $app = New-Object -ComObject OneNote.Application |
| 6 | $notebook = '' |
| 7 | try { |
| 8 | $app.OpenHierarchy((Join-Path $Root 'notebook'), '', [ref]$notebook, 0) |
| 9 | $section = '' |
| 10 | $app.OpenHierarchy('synthetic.one', $notebook, [ref]$section, 0) |
| 11 | $page = '' |
| 12 | $app.CreateNewPage($section, [ref]$page, 0) |
| 13 | $cases = @( |
| 14 | @{ name = 'Default'; attributes = '' }, |
| 15 | @{ name = 'Explicit zero'; attributes = ' alignment="left" RTL="false" spaceBefore="0" spaceAfter="0" spaceBetween="0"' }, |
| 16 | @{ name = 'Center spaced'; attributes = ' alignment="center" spaceBefore="12" spaceAfter="6" spaceBetween="20"' }, |
| 17 | @{ name = 'Right RTL'; attributes = ' alignment="right" RTL="true" spaceBefore="3" spaceAfter="9" spaceBetween="18"' }, |
| 18 | @{ name = 'Style inherited'; attributes = ' quickStyleIndex="1"' }, |
| 19 | @{ name = 'Style overridden'; attributes = ' quickStyleIndex="1" alignment="center" spaceBefore="0" spaceAfter="2" spaceBetween="16"' } |
| 20 | ) |
| 21 | $body = '<one:QuickStyleDef index="0" name="p" font="Calibri" fontSize="11" fontColor="automatic" highlightColor="automatic"/><one:QuickStyleDef index="1" name="h1" font="Georgia" fontSize="18" bold="true" fontColor="#123456" highlightColor="automatic" spaceBefore="8" spaceAfter="4"/>' |
| 22 | $body += '<one:Title><one:OE><one:T>Paragraph formatting</one:T></one:OE></one:Title><one:Outline><one:Position x="72" y="108"/><one:OEChildren>' |
| 23 | foreach ($case in $cases) { |
| 24 | $body += '<one:OE' + $case.attributes + '><one:T><![CDATA[' + $case.name + ': <b>bold</b> <i>italic</i> plain]]></one:T></one:OE>' |
| 25 | } |
| 26 | $body += '</one:OEChildren></one:Outline>' |
| 27 | $xml = '<one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/2010/onenote" ID="' + $page + '">' + $body + '</one:Page>' |
| 28 | $inputs = Join-Path $Root 'inputs' |
| 29 | New-Item -ItemType Directory -Path $inputs | Out-Null |
| 30 | [IO.File]::WriteAllText((Join-Path $inputs 'paragraph-formatting.xml'), $xml, [Text.Encoding]::UTF8) |
| 31 | $app.UpdatePageContent($xml, [DateTime]::MinValue, 1, $true) |
| 32 | $app.SyncHierarchy($notebook) |
| 33 | } finally { |
| 34 | if ($notebook) { $app.CloseNotebook($notebook, $false) } |
| 35 | [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($app) |
| 36 | $app = $null |
| 37 | [GC]::Collect() |
| 38 | [GC]::WaitForPendingFinalizers() |
| 39 | } |