diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2024-02-17 11:25:37 -0500 |
---|---|---|
committer | Ashod Nakashian <ash@collabora.com> | 2024-02-20 12:00:32 +0100 |
commit | 4e3fc95767048b6813519efd6c5d7a97484c37ed (patch) | |
tree | 3cc8622c2696300f862928942e0d8b508f3375a8 /sw | |
parent | 1d1a321a02f307b5639dd54f199f50b028cfc368 (diff) |
docx import: correct redline content-controls
When inserting and deleting content-controls
with change-tracking enabled, we hit a few
corner-cases that we need to handle more
smartly.
First, we shouldn't redline the controls
themselves, just the placeholder text.
Second, we have to take special care
to create valid XML structure with
the redline tags.
Includes unit-test that reproduces the
issues and verifies that both saving
and loading work as expected.
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: I6af4d0d2c3f0661e7990d5414cc93effc96f0469
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163555
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Ashod Nakashian <ash@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 28 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 8 |
2 files changed, 31 insertions, 5 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 394d4a715e1a..1ae2a8ae6071 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1919,7 +1919,22 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In } // if there is some redlining in the document, output it - StartRedline( m_pRedlineData, bLastRun ); + bool bSkipRedline = false; + if (nLen == 1) + { + // Don't redline content-controls--Word doesn't do them. + SwTextAttr* pAttr + = pNode->GetTextAttrAt(nPos, RES_TXTATR_CONTENTCONTROL, sw::GetTextAttrMode::Default); + if (pAttr && pAttr->GetStart() == nPos) + { + bSkipRedline = true; + } + } + + if (!bSkipRedline) + { + StartRedline(m_pRedlineData, bLastRun); + } // XML_r node should be surrounded with bookmark-begin and bookmark-end nodes if it has bookmarks. // The same is applied for permission ranges. @@ -1992,6 +2007,13 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In // append the actual run end m_pSerializer->endElementNS( XML_w, XML_r ); + // if there is some redlining in the document, output it + // (except in the case of fields with multiple runs) + if (!bSkipRedline) + { + EndRedline(m_pRedlineData, bLastRun); + } + if (nLen != -1) { sal_Int32 nEnd = nPos + nLen; @@ -2002,10 +2024,6 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In } } - // if there is some redlining in the document, output it - // (except in the case of fields with multiple runs) - EndRedline( m_pRedlineData, bLastRun ); - // enclose in a sdt block, if necessary: if one is already started, then don't do it for now // (so on export sdt blocks are never nested ATM) if ( !m_bAnchorLinkedToNode && !m_aRunSdt.m_bStartedSdt) diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index c8d972a432eb..deb7f06b6b6d 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2369,6 +2369,14 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) bool bStartedPostponedRunProperties = false; OUString aSavedSnippet ; + // Don't redline content-controls--Word doesn't do them. + SwTextAttr* pAttr = rNode.GetTextAttrAt(nCurrentPos, RES_TXTATR_CONTENTCONTROL, + sw::GetTextAttrMode::Default); + if (pAttr && pAttr->GetStart() == nCurrentPos) + { + pRedlineData = nullptr; + } + sal_Int32 nNextAttr = GetNextPos( &aAttrIter, rNode, nCurrentPos ); // Skip un-exportable attributes. |