summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-09-08 16:41:46 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-09-08 17:46:05 +0200
commit3ec224dcb15e0e663ba85077b8ea0e632f8f03f8 (patch)
treec48bb91a9a4d8b94893095b48436c403a98f60a5 /writerfilter
parent845fa950ac635ea57dd860fb96fadcfb75e97f2b (diff)
DOCX import: avoid duplicated bookmarks in copied header/footer text
In case a DOCX document has 2 sections and the 2nd section has a linked header, writerfilter/ copies the header text from the 1st page style to the 2nd page style. This leads to duplicated bookmarks in the doc model, which causes an unexpected increase in bookmark count on export. This went wrong with 8885bdf2f564bb7b56181c50baf39ff99d551ec9 (tdf#128106 sw: copy bookmarks at start if whole node is copied, 2021-08-27), previously at least bookmarks at the start of the header were not duplicated, though that was also inconsistent, since other bookmarks were still duplicated. Interestingly the DOC import doesn't have this problem, because it first copies header text and only later imports the bookmarks. Fix the problem by introducing a new SwCopyFlags::SkipBookmarks flag, add UNO API to set this from writerfilter/ code and skip copying bookmarks (but not other marks) in sw::CopyBookmarks() accordingly. Copying other marks is still needed, because e.g. fieldmarks have a mark and a field, and it would be inconsistent to copy the field, but not the mark. Note that the text is still duplicated in header/footer, linked header/footer is a missing feature on the Writer side. Change-Id: I40e18f231ef2c0d91ae9582621684ef5b6284904 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139697 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index eec9b678a209..e848a5780ebf 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -874,7 +874,18 @@ void SectionPropertyMap::CopyHeaderFooterTextProperty( const uno::Reference< bea
if ( xPrevStyle.is() )
xPrevTxt.set( xPrevStyle->getPropertyValue( sName ), uno::UNO_QUERY_THROW );
+ uno::Reference<beans::XPropertySet> xTxtProps(xTxt, uno::UNO_QUERY);
+ if (xTxtProps.is())
+ {
+ // Skip copying bookmarks, so the number of bookmarks in the source document and in the
+ // resulting doc model match.
+ xTxtProps->setPropertyValue("CopySkipsBookmarks", uno::Any(true));
+ }
xTxt->copyText( xPrevTxt );
+ if (xTxtProps.is())
+ {
+ xTxtProps->setPropertyValue("CopySkipsBookmarks", uno::Any(false));
+ }
}
catch ( const uno::Exception& )
{