mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-30 00:16:56 +03:00
fix(cfe-borrow): generate minimal Form.xml without ChildItems for borrowed forms
Configurator generates borrowed forms with only properties + AutoCommandBar + empty Attributes — no ChildItems. ChildItems appear only when modifications are added via form-edit. Copying full ChildItems caused XDTO errors on complex forms due to unresolvable references (CommonPicture, StyleItem, xr: namespace elements). Changes: - Remove ChildItems extraction and output from Borrow-Form - Strip ChildItems from AutoCommandBar (keep only Autofill property) - Both main and BaseForm sections now contain only properties + minimal AutoCommandBar Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
c72f2210b5
commit
cf5eae6428
@@ -476,9 +476,8 @@ function Borrow-Form {
|
|||||||
$formVersion = $srcFormEl.GetAttribute("version")
|
$formVersion = $srcFormEl.GetAttribute("version")
|
||||||
if (-not $formVersion) { $formVersion = "2.17" }
|
if (-not $formVersion) { $formVersion = "2.17" }
|
||||||
|
|
||||||
# Find direct children: form properties, AutoCommandBar, ChildItems
|
# Find direct children: form properties and AutoCommandBar
|
||||||
$srcAutoCmd = $null
|
$srcAutoCmd = $null
|
||||||
$srcChildItems = $null
|
|
||||||
$formProps = @()
|
$formProps = @()
|
||||||
$reachedVisual = $false
|
$reachedVisual = $false
|
||||||
foreach ($fc in $srcFormEl.ChildNodes) {
|
foreach ($fc in $srcFormEl.ChildNodes) {
|
||||||
@@ -486,8 +485,8 @@ function Borrow-Form {
|
|||||||
if ($fc.LocalName -eq 'AutoCommandBar' -and -not $srcAutoCmd) {
|
if ($fc.LocalName -eq 'AutoCommandBar' -and -not $srcAutoCmd) {
|
||||||
$reachedVisual = $true; $srcAutoCmd = $fc; continue
|
$reachedVisual = $true; $srcAutoCmd = $fc; continue
|
||||||
}
|
}
|
||||||
if ($fc.LocalName -eq 'ChildItems' -and -not $srcChildItems) {
|
if ($fc.LocalName -eq 'ChildItems' -or $fc.LocalName -eq 'Events' -or $fc.LocalName -eq 'Attributes' -or $fc.LocalName -eq 'Commands' -or $fc.LocalName -eq 'Parameters') {
|
||||||
$reachedVisual = $true; $srcChildItems = $fc; continue
|
$reachedVisual = $true; continue
|
||||||
}
|
}
|
||||||
if (-not $reachedVisual) {
|
if (-not $reachedVisual) {
|
||||||
# Form-level properties before AutoCommandBar (WindowOpeningMode, AutoFillCheck, etc.)
|
# Form-level properties before AutoCommandBar (WindowOpeningMode, AutoFillCheck, etc.)
|
||||||
@@ -498,31 +497,15 @@ function Borrow-Form {
|
|||||||
# Get OuterXml and strip redundant namespace redeclarations (they're on root <Form>)
|
# Get OuterXml and strip redundant namespace redeclarations (they're on root <Form>)
|
||||||
$nsStripPattern = '\s+xmlns(?::\w+)?="[^"]*"'
|
$nsStripPattern = '\s+xmlns(?::\w+)?="[^"]*"'
|
||||||
|
|
||||||
|
# AutoCommandBar: copy only properties (Autofill etc.), strip ChildItems
|
||||||
$autoCmdXml = ""
|
$autoCmdXml = ""
|
||||||
if ($srcAutoCmd) {
|
if ($srcAutoCmd) {
|
||||||
$autoCmdXml = $srcAutoCmd.OuterXml
|
$autoCmdXml = $srcAutoCmd.OuterXml
|
||||||
$autoCmdXml = [regex]::Replace($autoCmdXml, $nsStripPattern, '')
|
$autoCmdXml = [regex]::Replace($autoCmdXml, $nsStripPattern, '')
|
||||||
# Replace all CommandName values with 0 (base form buttons lose command refs)
|
# Strip ChildItems from AutoCommandBar (buttons will appear from base form at runtime)
|
||||||
$autoCmdXml = [regex]::Replace($autoCmdXml, '<CommandName>[^<]*</CommandName>', '<CommandName>0</CommandName>')
|
$autoCmdXml = [regex]::Replace($autoCmdXml, '(?s)\s*<ChildItems>.*?</ChildItems>', '')
|
||||||
# Replace Autofill true → false
|
# Replace Autofill true → false
|
||||||
$autoCmdXml = $autoCmdXml -replace '<Autofill>true</Autofill>', '<Autofill>false</Autofill>'
|
$autoCmdXml = $autoCmdXml -replace '<Autofill>true</Autofill>', '<Autofill>false</Autofill>'
|
||||||
# Strip DataPath (references base form attributes not present in extension)
|
|
||||||
$autoCmdXml = [regex]::Replace($autoCmdXml, '\s*<DataPath>[^<]*</DataPath>', '')
|
|
||||||
# Strip element-level Events (base form event handlers not present in extension)
|
|
||||||
$autoCmdXml = [regex]::Replace($autoCmdXml, '(?s)\s*<Events>.*?</Events>', '')
|
|
||||||
}
|
|
||||||
|
|
||||||
$childItemsXml = ""
|
|
||||||
if ($srcChildItems) {
|
|
||||||
$childItemsXml = $srcChildItems.OuterXml
|
|
||||||
$childItemsXml = [regex]::Replace($childItemsXml, $nsStripPattern, '')
|
|
||||||
# Replace all CommandName values with 0 in ChildItems too
|
|
||||||
$childItemsXml = [regex]::Replace($childItemsXml, '<CommandName>[^<]*</CommandName>', '<CommandName>0</CommandName>')
|
|
||||||
# Strip DataPath and element-level Events
|
|
||||||
$childItemsXml = [regex]::Replace($childItemsXml, '\s*<DataPath>[^<]*</DataPath>', '')
|
|
||||||
$childItemsXml = [regex]::Replace($childItemsXml, '(?s)\s*<Events>.*?</Events>', '')
|
|
||||||
} else {
|
|
||||||
$childItemsXml = "<ChildItems/>"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Extract the <Form ...> opening tag from source text (preserves namespace declarations)
|
# Extract the <Form ...> opening tag from source text (preserves namespace declarations)
|
||||||
@@ -538,7 +521,7 @@ function Borrow-Form {
|
|||||||
$formXmlSb.Append($formTag) | Out-Null
|
$formXmlSb.Append($formTag) | Out-Null
|
||||||
$formXmlSb.Append("`r`n") | Out-Null
|
$formXmlSb.Append("`r`n") | Out-Null
|
||||||
|
|
||||||
# Part 1: form properties + visual elements
|
# Part 1: form properties + AutoCommandBar (no ChildItems — they come from base form at runtime)
|
||||||
foreach ($propXml in $formProps) {
|
foreach ($propXml in $formProps) {
|
||||||
$propXml = [regex]::Replace($propXml, $nsStripPattern, '')
|
$propXml = [regex]::Replace($propXml, $nsStripPattern, '')
|
||||||
$formXmlSb.Append("`t$propXml`r`n") | Out-Null
|
$formXmlSb.Append("`t$propXml`r`n") | Out-Null
|
||||||
@@ -547,12 +530,10 @@ function Borrow-Form {
|
|||||||
$formXmlSb.Append("`t$autoCmdXml") | Out-Null
|
$formXmlSb.Append("`t$autoCmdXml") | Out-Null
|
||||||
$formXmlSb.Append("`r`n") | Out-Null
|
$formXmlSb.Append("`r`n") | Out-Null
|
||||||
}
|
}
|
||||||
$formXmlSb.Append("`t$childItemsXml") | Out-Null
|
|
||||||
$formXmlSb.Append("`r`n") | Out-Null
|
|
||||||
$formXmlSb.Append("`t<Attributes/>") | Out-Null
|
$formXmlSb.Append("`t<Attributes/>") | Out-Null
|
||||||
$formXmlSb.Append("`r`n") | Out-Null
|
$formXmlSb.Append("`r`n") | Out-Null
|
||||||
|
|
||||||
# BaseForm: form properties + same visual elements, indented one more level
|
# BaseForm: same properties + AutoCommandBar (no ChildItems)
|
||||||
$formXmlSb.Append("`t<BaseForm version=`"${formVersion}`">") | Out-Null
|
$formXmlSb.Append("`t<BaseForm version=`"${formVersion}`">") | Out-Null
|
||||||
$formXmlSb.Append("`r`n") | Out-Null
|
$formXmlSb.Append("`r`n") | Out-Null
|
||||||
|
|
||||||
@@ -570,13 +551,6 @@ function Borrow-Form {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ciLines = $childItemsXml -split "`r?`n"
|
|
||||||
for ($li = 0; $li -lt $ciLines.Count; $li++) {
|
|
||||||
if ($li -eq 0) { $formXmlSb.Append("`t`t$($ciLines[$li])") | Out-Null }
|
|
||||||
else { $formXmlSb.Append("`t$($ciLines[$li])") | Out-Null }
|
|
||||||
$formXmlSb.Append("`r`n") | Out-Null
|
|
||||||
}
|
|
||||||
|
|
||||||
$formXmlSb.Append("`t`t<Attributes/>") | Out-Null
|
$formXmlSb.Append("`t`t<Attributes/>") | Out-Null
|
||||||
$formXmlSb.Append("`r`n") | Out-Null
|
$formXmlSb.Append("`r`n") | Out-Null
|
||||||
$formXmlSb.Append("`t</BaseForm>") | Out-Null
|
$formXmlSb.Append("`t</BaseForm>") | Out-Null
|
||||||
|
|||||||
Reference in New Issue
Block a user