mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-10 16:14:54 +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
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -2356,30 +2356,72 @@ function Emit-OutputParameters {
|
||||
foreach ($prop in $params.PSObject.Properties) {
|
||||
$key = $prop.Name
|
||||
$rawVal = $prop.Value
|
||||
# Распознаём wrapper {use: false, value: ...} (отличаем от multilang dict)
|
||||
$useWrapper = $false
|
||||
if ($rawVal -is [PSCustomObject] -and $rawVal.PSObject.Properties['use'] -and $rawVal.use -eq $false -and $rawVal.PSObject.Properties['value']) {
|
||||
$useWrapper = $true
|
||||
# Распознаём wrapper {value, use?, viewMode?, userSettingID?, userSettingPresentation?}
|
||||
# отличая от multilang dict ({ru, en, ...}). Wrapper всегда имеет ключ 'value'.
|
||||
$useFalse = $false
|
||||
$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
|
||||
} elseif (($rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary]) -and $rawVal.Contains('use') -and $rawVal['use'] -eq $false -and $rawVal.Contains('value')) {
|
||||
$useWrapper = $true
|
||||
} elseif (($rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary]) -and $rawVal.Contains('value')) {
|
||||
$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']
|
||||
}
|
||||
# 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]
|
||||
if (-not $ptype) { $ptype = "xs:string" }
|
||||
# Auto-promote to mltext if value is a multilang dict ({ru, en, ...})
|
||||
if ($rawVal -is [System.Management.Automation.PSCustomObject] -or $rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary]) {
|
||||
# Auto-promote to mltext if value is a multilang dict (но не Font/wrapper)
|
||||
if (-not $isFontDict -and ($rawVal -is [System.Management.Automation.PSCustomObject] -or $rawVal -is [hashtable] -or $rawVal -is [System.Collections.IDictionary])) {
|
||||
$ptype = "mltext"
|
||||
}
|
||||
|
||||
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>"
|
||||
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"
|
||||
} else {
|
||||
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>"
|
||||
}
|
||||
if ($null -ne $blockViewMode) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/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
|
||||
import argparse
|
||||
import json
|
||||
@@ -1948,24 +1948,44 @@ def emit_output_parameters(lines, params, indent):
|
||||
|
||||
lines.append(f'{indent}<dcsset:outputParameters>')
|
||||
for key, val in params.items():
|
||||
# Распознаём wrapper {use: false, value: ...} — отличаем от multilang dict
|
||||
use_wrapper = False
|
||||
if isinstance(val, dict) and val.get('use') is False and 'value' in val:
|
||||
use_wrapper = True
|
||||
# wrapper {value, use?, viewMode?, userSettingID?, userSettingPresentation?}
|
||||
use_false = False
|
||||
wrap_vm = None
|
||||
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']
|
||||
is_font_dict = isinstance(val, dict) and val.get('@type') == 'Font'
|
||||
ptype = OUTPUT_PARAM_TYPES.get(key, 'xs:string')
|
||||
# Auto-promote to mltext if value is a multilang dict ({ru, en, ...})
|
||||
if isinstance(val, dict):
|
||||
# Auto-promote to mltext if value is a multilang dict (but not Font)
|
||||
if not is_font_dict and isinstance(val, dict):
|
||||
ptype = 'mltext'
|
||||
|
||||
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: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)
|
||||
else:
|
||||
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}</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
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -1672,11 +1672,21 @@ function Build-OutputParameters {
|
||||
if (-not $pName -or -not $val) { continue }
|
||||
$vType = Get-LocalXsiType $val
|
||||
if ($vType -eq 'LocalStringType') { $rawVal = Get-MLText $val }
|
||||
elseif ($vType -eq 'Font') { $rawVal = Get-FontValue $val }
|
||||
else { $rawVal = $val.InnerText }
|
||||
# <dcscor:use>false</...> → wrapper {value, use: false}
|
||||
# Extras (use=false / viewMode / userSettingID / userSettingPresentation) → wrapper.
|
||||
$useV = Get-Text $it "dcscor:use"
|
||||
if ($useV -eq 'false') {
|
||||
$d[$pName] = [ordered]@{ value = $rawVal; use = $false }
|
||||
$vmN = $it.SelectSingleNode("dcsset:viewMode", $ns)
|
||||
$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 {
|
||||
$d[$pName] = $rawVal
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user