diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx index 1f044bc2f309..8c11e3db22c7 100644 --- a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx @@ -114,6 +114,25 @@ CPPUNIT_TEST_FIXTURE(Test, testFloatingTablesOuterNonsplitInner) // i.e. the inner floating table was not floating. CPPUNIT_ASSERT_EQUAL(static_cast(4), xFrames->getCount()); } + +CPPUNIT_TEST_FIXTURE(Test, testDOCXFloatingTableHiddenAnchor) +{ + // Given a document with a floating table, anchored in a paragraph that is hidden: + loadFromURL(u"floattable-hidden-anchor.docx"); + + // When checking the visibility of the the anchor paragraph: + uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference xText(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference xParagraphs = xText->createEnumeration(); + uno::Reference xAnchor(xParagraphs->nextElement(), uno::UNO_QUERY); + + // Then make sure the anchor (and thus the table) is visible: + bool bCharHidden{}; + CPPUNIT_ASSERT(xAnchor->getPropertyValue("CharHidden") >>= bCharHidden); + // Without the accompanying fix in place, this test would have failed, the paragraph + table was + // hidden. + CPPUNIT_ASSERT(!bCharHidden); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/qa/cppunittests/dmapper/data/floattable-hidden-anchor.docx b/writerfilter/qa/cppunittests/dmapper/data/floattable-hidden-anchor.docx new file mode 100644 index 000000000000..08816aacc47e Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/floattable-hidden-anchor.docx differ diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 370a89c0442f..5b0971eee20f 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1643,6 +1643,24 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab } } + if (xContent.is()) + { + // By the time the frame is created, the anchor's paragraph marker character + // properties are already imported. Check if we need to disable "vanish", that + // would lead to a hidden floating table in Writer, but it does not in Word. + uno::Reference xParagraph(xContent->getAnchor(), + uno::UNO_QUERY); + if (xParagraph.is()) + { + bool bCharHidden{}; + xParagraph->getPropertyValue("CharHidden") >>= bCharHidden; + if (bCharHidden) + { + xParagraph->setPropertyValue("CharHidden", uno::Any(false)); + } + } + } + AfterConvertToTextFrame(m_rDMapper_Impl, aFramedRedlines, redPos, redLen, redCell, redTable); }