mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-12 00:44:57 +03:00
feat(skd): v8ui:Font в appearance + use=false в conditionalAppearance
Font хранится как объект {@type:Font, ref, faceName, height, bold, italic,
underline, strikeout, kind, scale} — все исходные атрибуты сохраняются для
bit-perfect round-trip.
Заодно Get-SettingsAppearance теперь читает dcscor:use на conditionalAppearance
items (раньше игнорировал — терялся use=false на appearance value).
sample30: −315 строк (3637 → 3322).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.65 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.66 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -2200,9 +2200,30 @@ function Emit-AppearanceValue {
|
||||
if ($useWrapper) { X "$indent`t<dcscor:use>false</dcscor:use>" }
|
||||
X "$indent`t<dcscor:parameter>$(Esc-Xml $key)</dcscor:parameter>"
|
||||
|
||||
# Multilang dict ({"ru": "...", "en": "..."}) → LocalStringType независимо от ключа.
|
||||
$isMultilang = ($innerVal -is [hashtable]) -or ($innerVal -is [System.Collections.IDictionary]) -or ($innerVal -is [PSCustomObject])
|
||||
if ($isMultilang) {
|
||||
# Font dict ({@type: "Font", ref, faceName, height, bold, ...}) → <dcscor:value xsi:type="v8ui:Font" .../>
|
||||
$isFontDict = $false
|
||||
if ($innerVal -is [PSCustomObject]) {
|
||||
$tProp = $innerVal.PSObject.Properties['@type']
|
||||
if ($tProp -and "$($tProp.Value)" -eq 'Font') { $isFontDict = $true }
|
||||
} elseif ($innerVal -is [System.Collections.IDictionary]) {
|
||||
if ($innerVal.Contains('@type') -and "$($innerVal['@type'])" -eq 'Font') { $isFontDict = $true }
|
||||
}
|
||||
$isDict = ($innerVal -is [hashtable]) -or ($innerVal -is [System.Collections.IDictionary]) -or ($innerVal -is [PSCustomObject])
|
||||
if ($isFontDict) {
|
||||
$attrParts = @()
|
||||
foreach ($attrName in @('ref','faceName','height','bold','italic','underline','strikeout','kind','scale')) {
|
||||
$av = $null
|
||||
if ($innerVal -is [PSCustomObject]) {
|
||||
$ap = $innerVal.PSObject.Properties[$attrName]
|
||||
if ($ap) { $av = $ap.Value }
|
||||
} else {
|
||||
if ($innerVal.Contains($attrName)) { $av = $innerVal[$attrName] }
|
||||
}
|
||||
if ($null -ne $av) { $attrParts += "$attrName=`"$(Esc-Xml "$av")`"" }
|
||||
}
|
||||
X "$indent`t<dcscor:value xsi:type=`"v8ui:Font`" $($attrParts -join ' ')/>"
|
||||
} elseif ($isDict) {
|
||||
# Multilang dict ({"ru": "...", "en": "..."}) → LocalStringType независимо от ключа.
|
||||
Emit-MLText -tag "dcscor:value" -text $innerVal -indent "$indent`t"
|
||||
} else {
|
||||
$actualVal = "$innerVal"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.65 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.66 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -1835,8 +1835,14 @@ def emit_appearance_value(lines, key, val, indent):
|
||||
lines.append(f'{indent}\t<dcscor:use>false</dcscor:use>')
|
||||
lines.append(f'{indent}\t<dcscor:parameter>{esc_xml(key)}</dcscor:parameter>')
|
||||
|
||||
# Multilang dict ({"ru": "...", "en": "..."}) \u2192 LocalStringType \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043a\u043b\u044e\u0447\u0430.
|
||||
if isinstance(inner_val, dict):
|
||||
# Font dict ({@type: "Font", ref, faceName, height, bold, ...}) \u2192 <dcscor:value xsi:type="v8ui:Font" .../>
|
||||
if isinstance(inner_val, dict) and inner_val.get('@type') == 'Font':
|
||||
attr_parts = []
|
||||
for attr_name in ('ref', 'faceName', 'height', 'bold', 'italic', 'underline', 'strikeout', 'kind', 'scale'):
|
||||
if attr_name in inner_val:
|
||||
attr_parts.append(f'{attr_name}="{esc_xml(str(inner_val[attr_name]))}"')
|
||||
lines.append(f'{indent}\t<dcscor:value xsi:type="v8ui:Font" {" ".join(attr_parts)}/>')
|
||||
elif isinstance(inner_val, dict):
|
||||
emit_mltext(lines, f'{indent}\t', 'dcscor:value', inner_val)
|
||||
else:
|
||||
actual_val = str(inner_val) if inner_val is not None else ''
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-decompile v0.49 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# skd-decompile v0.50 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -431,6 +431,18 @@ function Get-RestrictionTokens {
|
||||
}
|
||||
|
||||
# <appearance> → hashtable {param: value}
|
||||
function Get-FontValue {
|
||||
param($valNode)
|
||||
# Шрифт: <dcscor:value xsi:type="v8ui:Font" ref=... faceName=... height=... bold=... .../>
|
||||
# Сохраняем все атрибуты как объект {@type:Font, ...}, чтобы compile мог восстановить bit-perfect.
|
||||
$f = [ordered]@{ '@type' = 'Font' }
|
||||
foreach ($attrName in @('ref','faceName','height','bold','italic','underline','strikeout','kind','scale')) {
|
||||
$a = $valNode.Attributes[$attrName]
|
||||
if ($null -ne $a) { $f[$attrName] = $a.Value }
|
||||
}
|
||||
return $f
|
||||
}
|
||||
|
||||
function Get-AppearanceDict {
|
||||
param($appNode)
|
||||
if (-not $appNode) { return $null }
|
||||
@@ -440,10 +452,12 @@ function Get-AppearanceDict {
|
||||
$p = Get-Text $it "dcscor:parameter"
|
||||
$valNode = $it.SelectSingleNode("dcscor:value", $ns)
|
||||
if (-not $p -or -not $valNode) { continue }
|
||||
# Value can be xs:string, v8ui:HorizontalAlign, v8:LocalStringType, etc.
|
||||
# Value can be xs:string, v8ui:HorizontalAlign, v8:LocalStringType, v8ui:Font, etc.
|
||||
$valType = Get-LocalXsiType $valNode
|
||||
if ($valType -eq 'LocalStringType') {
|
||||
$rawVal = Get-MLText $valNode
|
||||
} elseif ($valType -eq 'Font') {
|
||||
$rawVal = Get-FontValue $valNode
|
||||
} else {
|
||||
$rawVal = $valNode.InnerText
|
||||
}
|
||||
@@ -1570,9 +1584,18 @@ function Get-SettingsAppearance {
|
||||
if (-not $pName -or -not $val) { continue }
|
||||
$valType = Get-LocalXsiType $val
|
||||
if ($valType -eq 'LocalStringType') {
|
||||
$dict[$pName] = Get-MLText $val
|
||||
$rawVal = Get-MLText $val
|
||||
} elseif ($valType -eq 'Font') {
|
||||
$rawVal = Get-FontValue $val
|
||||
} else {
|
||||
$dict[$pName] = $val.InnerText
|
||||
$rawVal = $val.InnerText
|
||||
}
|
||||
# wrapper {use:false, value} как в Get-AppearanceDict
|
||||
$useV = Get-Text $it "dcscor:use"
|
||||
if ($useV -eq 'false') {
|
||||
$dict[$pName] = [ordered]@{ value = $rawVal; use = $false }
|
||||
} else {
|
||||
$dict[$pName] = $rawVal
|
||||
}
|
||||
}
|
||||
return $dict
|
||||
|
||||
Reference in New Issue
Block a user