From afe2550dbd5607645a668ed58a1fe735c857c77d Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Fri, 27 Mar 2026 13:34:46 -0400 Subject: [PATCH] tdf#171527 docx export: allow flies inside framePr Normally, MS Word does not allow a fly to be anchored inside of a fly. But framePr is different. It is a paragraph property, not a container. So remove the restriction that forced inline flies. It looks like a copy/paste during the original implementation in tdf#78590. make CppunitTest_sw_ooxmlexport13 CPPUNIT_TEST_NAME=testFlyInFly Change-Id: Ie3c52f905dd709ce79a8fb5abd9476b475d82bdd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202890 Reviewed-by: Justin Luth Tested-by: Jenkins --- sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 12 +++++++++--- sw/source/filter/ww8/docxsdrexport.cxx | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 53686f34aeca..3197fedea659 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -35,19 +36,24 @@ public: Test() : SwModelTestBase(u"/sw/qa/extras/ooxmlexport/data/"_ustr) {} }; -// TODO: the re-import doesn't work just yet, but that isn't a regression... CPPUNIT_TEST_FIXTURE(Test, testFlyInFly) { createSwDoc("ooo39250-1-min.rtf"); - save(TestFilter::DOCX); + saveAndReload(TestFilter::DOCX); // check that anchor of text frame is in other text frame uno::Reference const xAnchored(getShape(3), uno::UNO_QUERY); CPPUNIT_ASSERT(xAnchored.is()); - CPPUNIT_ASSERT_EQUAL(u"Frame1"_ustr/*generated name*/, uno::Reference(xAnchored, uno::UNO_QUERY_THROW)->getName()); + // generated name + OUString sName = uno::Reference(xAnchored, uno::UNO_QUERY_THROW)->getName(); + CPPUNIT_ASSERT(sName == u"Frame1" || sName == u"Frame 1"); uno::Reference const xAnchorText(xAnchored->getAnchor()->getText()); uno::Reference const xAnchorFrame(xAnchorText, uno::UNO_QUERY); CPPUNIT_ASSERT(xAnchorFrame.is()); CPPUNIT_ASSERT_EQUAL(u"Frame3"_ustr, uno::Reference(xAnchorFrame, uno::UNO_QUERY_THROW)->getName()); + + // All frames are floating frames - not inline + for (auto& pSpz : *getSwDoc()->GetSpzFrameFormats()) + CPPUNIT_ASSERT(RndStdIds::FLY_AS_CHAR != pSpz->GetAnchor().GetAnchorId()); } DECLARE_OOXMLEXPORT_TEST(testTdf125778_lostPageBreakTOX, "tdf125778_lostPageBreakTOX.docx") diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 4142adf80371..005655c04e20 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -1742,7 +1742,6 @@ void DocxSdrExport::writeOnlyTextOfFrame(ww8::Frame const* pParentFrame) ExportDataSaveRestore aDataGuard(m_pImpl->getExport(), nStt, nEnd, pParentFrame); m_pImpl->setBodyPrAttrList(sax_fastparser::FastSerializerHelper::createAttrList().get()); - ::comphelper::FlagRestorationGuard const g(m_pImpl->m_bFlyFrameGraphic, true); comphelper::ValueRestorationGuard vg(m_pImpl->getExport().m_nTextTyp, TXT_TXTBOX); m_pImpl->getExport().WriteText(); }