mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-11 08:24:57 +03:00
feat(skd): различать 3 namespace цветов (style/web/win)
Раньше decompile Normalize-Color сворачивал любой dN: префикс в style: независимо от URI. Compile Emit-ColorValue знал только style: → один xmlns (http://v8.1c.ru/8.1/data/ui/style). Цвета web:GhostWhite и win:Highlight терялись/искажались. URI mapping: - http://v8.1c.ru/8.1/data/ui/style → style: - http://v8.1c.ru/8.1/data/ui/colors/web → web: - http://v8.1c.ru/8.1/data/ui/colors/windows → win: decompile: резолвим prefix через GetNamespaceOfPrefix. compile (PS+Py): Emit-ColorValue для template cells — long form с локальным xmlns. Emit-AppearanceValue (внутри settings) — short form, т.к. <dcsset:settings> уже объявляет xmlns:style/web/win/sys на корне. См. upload/erf/ЦветаВМакете — образец с 4 формами цвета.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.101 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.102 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -1651,12 +1651,21 @@ foreach ($stylesFile in $searchPaths) {
|
||||
|
||||
function Emit-ColorValue {
|
||||
param([string]$color, [string]$indent)
|
||||
if ($color.StartsWith('style:')) {
|
||||
$styleName = $color.Substring(6)
|
||||
X "$indent<dcscor:value xmlns:d8p1=`"http://v8.1c.ru/8.1/data/ui/style`" xsi:type=`"v8ui:Color`">d8p1:$styleName</dcscor:value>"
|
||||
} else {
|
||||
X "$indent<dcscor:value xsi:type=`"v8ui:Color`">$(Esc-Xml $color)</dcscor:value>"
|
||||
# Префиксы style:/web:/win: → соответствующий xmlns + dN:Name
|
||||
$colorPrefixToUri = @{
|
||||
'style:' = 'http://v8.1c.ru/8.1/data/ui/style'
|
||||
'web:' = 'http://v8.1c.ru/8.1/data/ui/colors/web'
|
||||
'win:' = 'http://v8.1c.ru/8.1/data/ui/colors/windows'
|
||||
}
|
||||
foreach ($pfx in $colorPrefixToUri.Keys) {
|
||||
if ($color.StartsWith($pfx)) {
|
||||
$name = $color.Substring($pfx.Length)
|
||||
$uri = $colorPrefixToUri[$pfx]
|
||||
X "$indent<dcscor:value xmlns:d8p1=`"$uri`" xsi:type=`"v8ui:Color`">d8p1:$name</dcscor:value>"
|
||||
return
|
||||
}
|
||||
}
|
||||
X "$indent<dcscor:value xsi:type=`"v8ui:Color`">$(Esc-Xml $color)</dcscor:value>"
|
||||
}
|
||||
|
||||
function Emit-CellAppearance {
|
||||
@@ -2438,6 +2447,8 @@ function Emit-AppearanceValue {
|
||||
if ($keyType) {
|
||||
X "$indent`t<dcscor:value xsi:type=`"$keyType`">$(Esc-Xml $actualVal)</dcscor:value>"
|
||||
} elseif ($actualVal -match '^(style|web|win):') {
|
||||
# Внутри <dcsset:settings> префиксы style:/web:/win:/sys: уже объявлены на корне,
|
||||
# локальный xmlns не нужен — эмитим short form.
|
||||
X "$indent`t<dcscor:value xsi:type=`"v8ui:Color`">$(Esc-Xml $actualVal)</dcscor:value>"
|
||||
} elseif ($actualVal -eq "true" -or $actualVal -eq "false") {
|
||||
X "$indent`t<dcscor:value xsi:type=`"xs:boolean`">$actualVal</dcscor:value>"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.101 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.102 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -1346,11 +1346,18 @@ def load_user_styles(base_dir, output_path=None):
|
||||
|
||||
|
||||
def _emit_color_value(lines, color, indent):
|
||||
if color.startswith('style:'):
|
||||
style_name = color[6:]
|
||||
lines.append(f'{indent}<dcscor:value xmlns:d8p1="http://v8.1c.ru/8.1/data/ui/style" xsi:type="v8ui:Color">d8p1:{style_name}</dcscor:value>')
|
||||
else:
|
||||
lines.append(f'{indent}<dcscor:value xsi:type="v8ui:Color">{esc_xml(color)}</dcscor:value>')
|
||||
# Префиксы style:/web:/win: → соответствующий xmlns + dN:Name
|
||||
color_prefix_to_uri = {
|
||||
'style:': 'http://v8.1c.ru/8.1/data/ui/style',
|
||||
'web:': 'http://v8.1c.ru/8.1/data/ui/colors/web',
|
||||
'win:': 'http://v8.1c.ru/8.1/data/ui/colors/windows',
|
||||
}
|
||||
for pfx, uri in color_prefix_to_uri.items():
|
||||
if color.startswith(pfx):
|
||||
name = color[len(pfx):]
|
||||
lines.append(f'{indent}<dcscor:value xmlns:d8p1="{uri}" xsi:type="v8ui:Color">d8p1:{name}</dcscor:value>')
|
||||
return
|
||||
lines.append(f'{indent}<dcscor:value xsi:type="v8ui:Color">{esc_xml(color)}</dcscor:value>')
|
||||
|
||||
|
||||
def _emit_cell_appearance(lines, style, width=0, v_merge=False, h_merge=False, min_height=0, extra_items=None):
|
||||
@@ -1992,6 +1999,8 @@ def emit_appearance_value(lines, key, val, indent):
|
||||
if key_type:
|
||||
lines.append(f'{indent}\t<dcscor:value xsi:type="{key_type}">{esc_xml(actual_val)}</dcscor:value>')
|
||||
elif re.match(r'^(style|web|win):', actual_val):
|
||||
# Внутри <dcsset:settings> префиксы style:/web:/win:/sys: уже объявлены на корне,
|
||||
# локальный xmlns не нужен — эмитим short form.
|
||||
lines.append(f'{indent}\t<dcscor:value xsi:type="v8ui:Color">{esc_xml(actual_val)}</dcscor:value>')
|
||||
elif actual_val == 'true' or actual_val == 'false':
|
||||
lines.append(f'{indent}\t<dcscor:value xsi:type="xs:boolean">{actual_val}</dcscor:value>')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-decompile v0.85 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# skd-decompile v0.86 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -1036,7 +1036,17 @@ function Normalize-Color {
|
||||
param($valNode)
|
||||
if (-not $valNode) { return $null }
|
||||
$txt = $valNode.InnerText
|
||||
if ($txt -match '^d\d+p\d+:(.+)$') { return 'style:' + $matches[1] }
|
||||
# Префикс xsi:type или value — резолвим в URI и выбираем DSL-префикс.
|
||||
if ($txt -match '^([^:]+):(.+)$') {
|
||||
$pfx = $matches[1]
|
||||
$name = $matches[2]
|
||||
$uri = $valNode.GetNamespaceOfPrefix($pfx)
|
||||
switch ($uri) {
|
||||
'http://v8.1c.ru/8.1/data/ui/style' { return 'style:' + $name }
|
||||
'http://v8.1c.ru/8.1/data/ui/colors/web' { return 'web:' + $name }
|
||||
'http://v8.1c.ru/8.1/data/ui/colors/windows' { return 'win:' + $name }
|
||||
}
|
||||
}
|
||||
return $txt
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user