sw/qa/extras/ooxmlexport/data/tdf128646.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 14 ++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 30 ++++++++++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-)
New commits: commit 2be656908e9f30d0b0f795cc67096f0d673a3a21 Author: László Németh <nem...@numbertext.org> AuthorDate: Fri Mar 13 17:08:34 2020 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Mar 16 22:23:32 2020 +0100 tdf#128646 DOCX import: don't hide shape of hidden paragraph if the shape is not hidden, but it's anchored to an empty table cell paragraph. Change-Id: I97e42431d083d3c70ff67981676e322ca8e7f89d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90568 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf128646.docx b/sw/qa/extras/ooxmlexport/data/tdf128646.docx new file mode 100644 index 000000000000..9648df35a2f3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf128646.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 470e47714940..cc4cc8f33bfa 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -641,6 +641,20 @@ DECLARE_OOXMLEXPORT_TEST(testTdf95033, "tdf95033.docx") assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[9]/w:tc[2]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'nil']", 0); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128646, "tdf128646.docx") +{ + // The problem was that not hidden shapes anchored to empty hidden paragraphs were imported as hidden. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:pPr/w:rPr/w:vanish", 1); + if (!mbExported) + // originally no <w:vanish> (the same as <w:vanish val="false">) + assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:r/w:rPr/w:vanish", 0); + else + // This was hidden (<w:vanish/>) + assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:r/w:rPr/w:vanish", "val", "false"); +} + DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFdo77129, "fdo77129.docx") { // The problem was that text after TOC field was missing if footer reference comes in field. diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 3e87fcb0a2b5..cc4311d0aaff 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1751,10 +1751,11 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con css::uno::Reference<css::beans::XPropertySet> xParaProps(xTextRange, uno::UNO_QUERY); - // table style has got bigger precedence than docDefault style - // collect these pending paragraph properties to process in endTable() + // table style precedence and not hidden shapes anchored to hidden empty table paragraphs if (xParaProps && m_nTableDepth > 0) { + // table style has got bigger precedence than docDefault style + // collect these pending paragraph properties to process in endTable() uno::Reference<text::XTextCursor> xCur = xTextRange->getText( )->createTextCursor( ); xCur->gotoEnd(false); xCur->goLeft(1, false); @@ -1763,6 +1764,31 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con xParaCursor->gotoStartOfParagraph(false); TableParagraph aPending{xParaCursor, xCur, pParaContext, xParaProps}; m_aParagraphsToEndTable.push_back(aPending); + + // hidden empty paragraph with a not hidden shape, set as not hidden + o3tl::optional<PropertyMap::Property> pHidden; + if ( !m_aAnchoredObjectAnchors.empty() && (pHidden = pParaContext->getProperty(PROP_CHAR_HIDDEN)) ) + { + bool bIsHidden; + pHidden->second >>= bIsHidden; + if (bIsHidden) + { + bIsHidden = false; + pHidden = GetTopContext()->getProperty(PROP_CHAR_HIDDEN); + if (pHidden) + pHidden->second >>= bIsHidden; + if (!bIsHidden) + { + uno::Reference<text::XTextCursor> xCur3 = xTextRange->getText()->createTextCursorByRange(xParaCursor); + xCur3->goRight(1, true); + if (xCur3->getString() == SAL_NEWLINE_STRING) + { + uno::Reference< beans::XPropertySet > xProp( xCur3, uno::UNO_QUERY ); + xProp->setPropertyValue(getPropertyName(PROP_CHAR_HIDDEN), uno::makeAny(false)); + } + } + } + } } // tdf#118521 set paragraph top or bottom margin based on the paragraph style _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits