diff --git a/tools/native/paragraph-formatting.ps1 b/tools/native/paragraph-formatting.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..93ee9beea196c50f82271116a38124d9ac44350a --- /dev/null +++ b/tools/native/paragraph-formatting.ps1 @@ -0,0 +1,39 @@ +param([Parameter(Mandatory=$true)][string]$Root, [Parameter(Mandatory=$true)][string]$CloneHost) +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' +& "$PSScriptRoot\cold-current.ps1" -Root $Root -CloneHost $CloneHost +$app = New-Object -ComObject OneNote.Application +$notebook = '' +try { + $app.OpenHierarchy((Join-Path $Root 'notebook'), '', [ref]$notebook, 0) + $section = '' + $app.OpenHierarchy('synthetic.one', $notebook, [ref]$section, 0) + $page = '' + $app.CreateNewPage($section, [ref]$page, 0) + $cases = @( + @{ name = 'Default'; attributes = '' }, + @{ name = 'Explicit zero'; attributes = ' alignment="left" RTL="false" spaceBefore="0" spaceAfter="0" spaceBetween="0"' }, + @{ name = 'Center spaced'; attributes = ' alignment="center" spaceBefore="12" spaceAfter="6" spaceBetween="20"' }, + @{ name = 'Right RTL'; attributes = ' alignment="right" RTL="true" spaceBefore="3" spaceAfter="9" spaceBetween="18"' }, + @{ name = 'Style inherited'; attributes = ' quickStyleIndex="1"' }, + @{ name = 'Style overridden'; attributes = ' quickStyleIndex="1" alignment="center" spaceBefore="0" spaceAfter="2" spaceBetween="16"' } + ) + $body = '' + $body += 'Paragraph formatting' + foreach ($case in $cases) { + $body += 'bold italic plain]]>' + } + $body += '' + $xml = '' + $body + '' + $inputs = Join-Path $Root 'inputs' + New-Item -ItemType Directory -Path $inputs | Out-Null + [IO.File]::WriteAllText((Join-Path $inputs 'paragraph-formatting.xml'), $xml, [Text.Encoding]::UTF8) + $app.UpdatePageContent($xml, [DateTime]::MinValue, 1, $true) + $app.SyncHierarchy($notebook) +} finally { + if ($notebook) { $app.CloseNotebook($notebook, $false) } + [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($app) + $app = $null + [GC]::Collect() + [GC]::WaitForPendingFinalizers() +}