sw/qa/extras/ooxmlexport/data/embedded_chart.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 26 +++++++++++++++++++++++ sw/source/core/layout/atrfrm.cxx | 9 +++++++ 3 files changed, 34 insertions(+), 1 deletion(-)
New commits: commit 57db9a4fdbee6db24b381f3ea48b3df089c555fc Author: Tünde Tóth <toth.tu...@nisz.hu> AuthorDate: Wed Nov 30 14:56:25 2022 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Dec 5 13:14:19 2022 +0000 tdf#126477 DOCX export: fix lost charts in embedded documents The charts of the embedded documents were not exported. Follow-up to commit a41cf57c1eb4cabe5afc1a45d6fe535dbb935217 "tdf#134987 convert DOCX to ODT: fix lost charts". Change-Id: I20f1cdfa68687043d0822c4bbf59793a208e83d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143495 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/ooxmlexport/data/embedded_chart.odt b/sw/qa/extras/ooxmlexport/data/embedded_chart.odt new file mode 100644 index 000000000000..820e9a3b2e76 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/embedded_chart.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index 79ea4323274d..5d6576a0d619 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -12,6 +12,7 @@ #include <queue> #include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/text/GraphicCrop.hpp> @@ -212,6 +213,31 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf152200) assertXPath(pXmlDoc, "//w:fldChar", 3); // no field characters elsewhere } +CPPUNIT_TEST_FIXTURE(Test, testTdf126477) +{ + loadAndReload("embedded_chart.odt"); + + uno::Reference<text::XTextEmbeddedObjectsSupplier> xTEOSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xAccess(xTEOSupplier->getEmbeddedObjects()); + uno::Sequence<OUString> aSeq(xAccess->getElementNames()); + + // Check number of embedded objects. + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeq.getLength()); + + uno::Reference<document::XEmbeddedObjectSupplier> xEOSupplier(xAccess->getByName(aSeq[0]), + uno::UNO_QUERY); + uno::Reference<lang::XComponent> xObj(xEOSupplier->getEmbeddedObject()); + uno::Reference<text::XTextEmbeddedObjectsSupplier> xTEOSupplier2(xObj, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xAccess2(xTEOSupplier2->getEmbeddedObjects()); + uno::Sequence<OUString> aSeq2(xAccess2->getElementNames()); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // i.e. the chart lost in the embedded document. + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeq2.getLength()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index dac5a59e2ccb..ff0763aed532 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2800,7 +2800,14 @@ SdrObject* SwFrameFormat::FindRealSdrObject() std::pair<Point, bool> const tmp(aNullPt, false); SwFlyFrame* pFly = static_cast<SwFlyFrame*>(::GetFrameOfModify( nullptr, *this, SwFrameType::Fly, nullptr, &tmp)); - return pFly ? pFly->GetVirtDrawObj() : nullptr; + if( pFly ) + return pFly->GetVirtDrawObj(); + + if( !GetDoc() || !GetDoc()->GetDocShell() || + GetDoc()->GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) + return nullptr; + + // tdf#126477 fix lost charts in embedded documents } return FindSdrObject(); }