mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-26 22:51:03 +03:00
feat(skd): viewMode/userSettingID/userSettingPresentation на outputParameters items
Wrapper {value, ...} расширен: помимо use=false поддерживает viewMode,
userSettingID, userSettingPresentation на каждом item внутри
<dcsset:outputParameters>. Также value=Font dict теперь работает в wrapper.
sample30: −92 строки (3322 → 3230).
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# skd-compile v1.66 — Compile 1C DCS from JSON
|
# skd-compile v1.67 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[string]$DefinitionFile,
|
[string]$DefinitionFile,
|
||||||
@@ -2356,30 +2356,72 @@ function Emit-OutputParameters {
|
|||||||
foreach ($prop in $params.PSObject.Properties) {
|
foreach ($prop in $params.PSObject.Properties) {
|
||||||
$key = $prop.Name
|
$key = $prop.Name
|
||||||
$rawVal = $prop.Value
|
$rawVal = $prop.Value
|
||||||
# Распознаём wrapper {use: false, value: ...} (отличаем от multilang dict)
|
# Распознаём wrapper {value, use?, viewMode?, userSettingID?, userSettingPresentation?}
|
||||||
$useWrapper = $false
|
# отличая от multilang dict ({ru, en, ...}). Wrapper всегда имеет ключ 'value'.
|
||||||
if ($rawVal -is [PSCustomObject] -and $rawVal.PSObject.Properties['use'] -and $rawVal.use -eq $false -and $rawVal.PSObject.Properties['value']) {
|
$useFalse = $false
|
||||||
$useWrapper = $true
|
$wrapVM = $null
|
||||||
|
$wrapUSID = $null
|
||||||
|
$wrapUSP = $null
|
||||||
|
$hasValueKey = $false
|
||||||
|
if ($rawVal -is [PSCustomObject] -and $rawVal.PSObject.Properties['value']) {
|
||||||
|
$hasValueKey = $true
|
||||||
|
if ($rawVal.PSObject.Properties['use'] -and $rawVal.use -eq $false) { $useFalse = $true }
|
||||||
|
if ($rawVal.PSObject.Properties['viewMode']) { $wrapVM = "$($rawVal.viewMode)" }
|
||||||
|
if ($rawVal.PSObject.Properties['userSettingID']) { $wrapUSID = "$($rawVal.userSettingID)" }
|
||||||
|
if ($rawVal.PSObject.Properties['userSettingPresentation']) { $wrapUSP = $rawVal.userSettingPresentation }
|
||||||
$rawVal = $rawVal.value
|
$rawVal = $rawVal.value
|
||||||
} elseif (($rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary]) -and $rawVal.Contains('use') -and $rawVal['use'] -eq $false -and $rawVal.Contains('value')) {
|
} elseif (($rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary]) -and $rawVal.Contains('value')) {
|
||||||
$useWrapper = $true
|
$hasValueKey = $true
|
||||||
|
if ($rawVal.Contains('use') -and $rawVal['use'] -eq $false) { $useFalse = $true }
|
||||||
|
if ($rawVal.Contains('viewMode')) { $wrapVM = "$($rawVal['viewMode'])" }
|
||||||
|
if ($rawVal.Contains('userSettingID')) { $wrapUSID = "$($rawVal['userSettingID'])" }
|
||||||
|
if ($rawVal.Contains('userSettingPresentation')) { $wrapUSP = $rawVal['userSettingPresentation'] }
|
||||||
$rawVal = $rawVal['value']
|
$rawVal = $rawVal['value']
|
||||||
}
|
}
|
||||||
|
# Font dict внутри значения
|
||||||
|
$isFontDict = $false
|
||||||
|
if ($rawVal -is [PSCustomObject]) {
|
||||||
|
$tProp = $rawVal.PSObject.Properties['@type']
|
||||||
|
if ($tProp -and "$($tProp.Value)" -eq 'Font') { $isFontDict = $true }
|
||||||
|
} elseif ($rawVal -is [System.Collections.IDictionary]) {
|
||||||
|
if ($rawVal.Contains('@type') -and "$($rawVal['@type'])" -eq 'Font') { $isFontDict = $true }
|
||||||
|
}
|
||||||
$ptype = $script:outputParamTypes[$key]
|
$ptype = $script:outputParamTypes[$key]
|
||||||
if (-not $ptype) { $ptype = "xs:string" }
|
if (-not $ptype) { $ptype = "xs:string" }
|
||||||
# Auto-promote to mltext if value is a multilang dict ({ru, en, ...})
|
# Auto-promote to mltext if value is a multilang dict (но не Font/wrapper)
|
||||||
if ($rawVal -is [System.Management.Automation.PSCustomObject] -or $rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary]) {
|
if (-not $isFontDict -and ($rawVal -is [System.Management.Automation.PSCustomObject] -or $rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary])) {
|
||||||
$ptype = "mltext"
|
$ptype = "mltext"
|
||||||
}
|
}
|
||||||
|
|
||||||
X "$indent`t<dcscor:item xsi:type=`"dcsset:SettingsParameterValue`">"
|
X "$indent`t<dcscor:item xsi:type=`"dcsset:SettingsParameterValue`">"
|
||||||
if ($useWrapper) { X "$indent`t`t<dcscor:use>false</dcscor:use>" }
|
if ($useFalse) { X "$indent`t`t<dcscor:use>false</dcscor:use>" }
|
||||||
X "$indent`t`t<dcscor:parameter>$(Esc-Xml $key)</dcscor:parameter>"
|
X "$indent`t`t<dcscor:parameter>$(Esc-Xml $key)</dcscor:parameter>"
|
||||||
if ($ptype -eq "mltext") {
|
if ($isFontDict) {
|
||||||
|
$attrParts = @()
|
||||||
|
foreach ($attrName in @('ref','faceName','height','bold','italic','underline','strikeout','kind','scale')) {
|
||||||
|
$av = $null
|
||||||
|
if ($rawVal -is [PSCustomObject]) {
|
||||||
|
$ap = $rawVal.PSObject.Properties[$attrName]
|
||||||
|
if ($ap) { $av = $ap.Value }
|
||||||
|
} else {
|
||||||
|
if ($rawVal.Contains($attrName)) { $av = $rawVal[$attrName] }
|
||||||
|
}
|
||||||
|
if ($null -ne $av) { $attrParts += "$attrName=`"$(Esc-Xml "$av")`"" }
|
||||||
|
}
|
||||||
|
X "$indent`t`t<dcscor:value xsi:type=`"v8ui:Font`" $($attrParts -join ' ')/>"
|
||||||
|
} elseif ($ptype -eq "mltext") {
|
||||||
Emit-MLText -tag "dcscor:value" -text $rawVal -indent "$indent`t`t"
|
Emit-MLText -tag "dcscor:value" -text $rawVal -indent "$indent`t`t"
|
||||||
} else {
|
} else {
|
||||||
X "$indent`t`t<dcscor:value xsi:type=`"$ptype`">$(Esc-Xml "$rawVal")</dcscor:value>"
|
X "$indent`t`t<dcscor:value xsi:type=`"$ptype`">$(Esc-Xml "$rawVal")</dcscor:value>"
|
||||||
}
|
}
|
||||||
|
if ($wrapVM) { X "$indent`t`t<dcsset:viewMode>$(Esc-Xml $wrapVM)</dcsset:viewMode>" }
|
||||||
|
if ($wrapUSID) {
|
||||||
|
$uid = if ("$wrapUSID" -eq 'auto') { New-Guid-String } else { "$wrapUSID" }
|
||||||
|
X "$indent`t`t<dcsset:userSettingID>$(Esc-Xml $uid)</dcsset:userSettingID>"
|
||||||
|
}
|
||||||
|
if ($wrapUSP) {
|
||||||
|
Emit-MLText -tag "dcsset:userSettingPresentation" -text $wrapUSP -indent "$indent`t`t"
|
||||||
|
}
|
||||||
X "$indent`t</dcscor:item>"
|
X "$indent`t</dcscor:item>"
|
||||||
}
|
}
|
||||||
if ($null -ne $blockViewMode) {
|
if ($null -ne $blockViewMode) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# skd-compile v1.66 — Compile 1C DCS from JSON
|
# skd-compile v1.67 — Compile 1C DCS from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
@@ -1948,24 +1948,44 @@ def emit_output_parameters(lines, params, indent):
|
|||||||
|
|
||||||
lines.append(f'{indent}<dcsset:outputParameters>')
|
lines.append(f'{indent}<dcsset:outputParameters>')
|
||||||
for key, val in params.items():
|
for key, val in params.items():
|
||||||
# Распознаём wrapper {use: false, value: ...} — отличаем от multilang dict
|
# wrapper {value, use?, viewMode?, userSettingID?, userSettingPresentation?}
|
||||||
use_wrapper = False
|
use_false = False
|
||||||
if isinstance(val, dict) and val.get('use') is False and 'value' in val:
|
wrap_vm = None
|
||||||
use_wrapper = True
|
wrap_usid = None
|
||||||
|
wrap_usp = None
|
||||||
|
if isinstance(val, dict) and 'value' in val:
|
||||||
|
if val.get('use') is False: use_false = True
|
||||||
|
wrap_vm = val.get('viewMode')
|
||||||
|
wrap_usid = val.get('userSettingID')
|
||||||
|
wrap_usp = val.get('userSettingPresentation')
|
||||||
val = val['value']
|
val = val['value']
|
||||||
|
is_font_dict = isinstance(val, dict) and val.get('@type') == 'Font'
|
||||||
ptype = OUTPUT_PARAM_TYPES.get(key, 'xs:string')
|
ptype = OUTPUT_PARAM_TYPES.get(key, 'xs:string')
|
||||||
# Auto-promote to mltext if value is a multilang dict ({ru, en, ...})
|
# Auto-promote to mltext if value is a multilang dict (but not Font)
|
||||||
if isinstance(val, dict):
|
if not is_font_dict and isinstance(val, dict):
|
||||||
ptype = 'mltext'
|
ptype = 'mltext'
|
||||||
|
|
||||||
lines.append(f'{indent}\t<dcscor:item xsi:type="dcsset:SettingsParameterValue">')
|
lines.append(f'{indent}\t<dcscor:item xsi:type="dcsset:SettingsParameterValue">')
|
||||||
if use_wrapper:
|
if use_false:
|
||||||
lines.append(f'{indent}\t\t<dcscor:use>false</dcscor:use>')
|
lines.append(f'{indent}\t\t<dcscor:use>false</dcscor:use>')
|
||||||
lines.append(f'{indent}\t\t<dcscor:parameter>{esc_xml(key)}</dcscor:parameter>')
|
lines.append(f'{indent}\t\t<dcscor:parameter>{esc_xml(key)}</dcscor:parameter>')
|
||||||
if ptype == 'mltext':
|
if is_font_dict:
|
||||||
|
attr_parts = []
|
||||||
|
for attr_name in ('ref', 'faceName', 'height', 'bold', 'italic', 'underline', 'strikeout', 'kind', 'scale'):
|
||||||
|
if attr_name in val:
|
||||||
|
attr_parts.append(f'{attr_name}="{esc_xml(str(val[attr_name]))}"')
|
||||||
|
lines.append(f'{indent}\t\t<dcscor:value xsi:type="v8ui:Font" {" ".join(attr_parts)}/>')
|
||||||
|
elif ptype == 'mltext':
|
||||||
emit_mltext(lines, f'{indent}\t\t', 'dcscor:value', val)
|
emit_mltext(lines, f'{indent}\t\t', 'dcscor:value', val)
|
||||||
else:
|
else:
|
||||||
lines.append(f'{indent}\t\t<dcscor:value xsi:type="{ptype}">{esc_xml(str(val))}</dcscor:value>')
|
lines.append(f'{indent}\t\t<dcscor:value xsi:type="{ptype}">{esc_xml(str(val))}</dcscor:value>')
|
||||||
|
if wrap_vm:
|
||||||
|
lines.append(f'{indent}\t\t<dcsset:viewMode>{esc_xml(str(wrap_vm))}</dcsset:viewMode>')
|
||||||
|
if wrap_usid:
|
||||||
|
uid = new_uuid() if str(wrap_usid) == 'auto' else str(wrap_usid)
|
||||||
|
lines.append(f'{indent}\t\t<dcsset:userSettingID>{esc_xml(uid)}</dcsset:userSettingID>')
|
||||||
|
if wrap_usp:
|
||||||
|
emit_mltext(lines, f'{indent}\t\t', 'dcsset:userSettingPresentation', wrap_usp)
|
||||||
lines.append(f'{indent}\t</dcscor:item>')
|
lines.append(f'{indent}\t</dcscor:item>')
|
||||||
lines.append(f'{indent}</dcsset:outputParameters>')
|
lines.append(f'{indent}</dcsset:outputParameters>')
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# skd-decompile v0.50 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
# skd-decompile v0.51 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -1672,11 +1672,21 @@ function Build-OutputParameters {
|
|||||||
if (-not $pName -or -not $val) { continue }
|
if (-not $pName -or -not $val) { continue }
|
||||||
$vType = Get-LocalXsiType $val
|
$vType = Get-LocalXsiType $val
|
||||||
if ($vType -eq 'LocalStringType') { $rawVal = Get-MLText $val }
|
if ($vType -eq 'LocalStringType') { $rawVal = Get-MLText $val }
|
||||||
|
elseif ($vType -eq 'Font') { $rawVal = Get-FontValue $val }
|
||||||
else { $rawVal = $val.InnerText }
|
else { $rawVal = $val.InnerText }
|
||||||
# <dcscor:use>false</...> → wrapper {value, use: false}
|
# Extras (use=false / viewMode / userSettingID / userSettingPresentation) → wrapper.
|
||||||
$useV = Get-Text $it "dcscor:use"
|
$useV = Get-Text $it "dcscor:use"
|
||||||
if ($useV -eq 'false') {
|
$vmN = $it.SelectSingleNode("dcsset:viewMode", $ns)
|
||||||
$d[$pName] = [ordered]@{ value = $rawVal; use = $false }
|
$usidV = Get-Text $it "dcsset:userSettingID"
|
||||||
|
$uspN = $it.SelectSingleNode("dcsset:userSettingPresentation", $ns)
|
||||||
|
$hasExtras = ($useV -eq 'false') -or $vmN -or $usidV -or $uspN
|
||||||
|
if ($hasExtras) {
|
||||||
|
$wrap = [ordered]@{ value = $rawVal }
|
||||||
|
if ($useV -eq 'false') { $wrap['use'] = $false }
|
||||||
|
if ($vmN) { $wrap['viewMode'] = $vmN.InnerText }
|
||||||
|
if ($usidV) { $wrap['userSettingID'] = 'auto' }
|
||||||
|
if ($uspN) { $wrap['userSettingPresentation'] = Get-MLText $uspN }
|
||||||
|
$d[$pName] = $wrap
|
||||||
} else {
|
} else {
|
||||||
$d[$pName] = $rawVal
|
$d[$pName] = $rawVal
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user