writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx | 19 ++++++++++ writerfilter/qa/cppunittests/dmapper/data/tdf143455_SmartArtPosition.docx |binary writerfilter/source/dmapper/GraphicImport.cxx | 14 +++++-- 3 files changed, 29 insertions(+), 4 deletions(-)
New commits: commit 17cfd3d3e2e6f807eb1faf07436c7e96e15157a7 Author: Regina Henschel <rb.hensc...@t-online.de> AuthorDate: Wed Jul 21 20:43:53 2021 +0200 Commit: Regina Henschel <rb.hensc...@t-online.de> CommitDate: Fri Jul 23 18:05:01 2021 +0200 tdf#143455 exclude diagram from pos and margin adaptions The current implementation of diagram (SmartArt) uses a SdrGroupObj, but it is actually not a group of the diagram parts. Currently the group's object list contains only one, dummy object. Therefore it works not well with the code parts used for groups. Because we will have (hopefully) the tender 'Dynamic Diagram feature' I have done nothing on diagrams, but as workaround only excluded diagrams from these code parts. That way the rendering is same as in LO 7.1. This part of code needs to be touched again, when diagrams are implemented in a different way. Change-Id: Ife4bb495c96fb1dd57663f28409dc2bb456282ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119344 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx index ffd14a4f2082..edd6e02ff8ea 100644 --- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx +++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx @@ -57,6 +57,25 @@ void Test::tearDown() constexpr OUStringLiteral DATA_DIRECTORY = u"/writerfilter/qa/cppunittests/dmapper/data/"; +CPPUNIT_TEST_FIXTURE(Test, testTdf143455SmartArtPosition) +{ + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf143455_SmartArtPosition.docx"; + getComponent() = loadFromDesktop(aURL); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + // Without fix in place the group, which represents the SmartArt, was placed at the initializing + // position 0|0. + sal_Int32 nHoriPosition = 0; + xShape->getPropertyValue("HoriOrientPosition") >>= nHoriPosition; + // The test would have failed with Expected: 2858, Actual: 0 + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2858), nHoriPosition); + sal_Int32 nVertPosition = 0; + xShape->getPropertyValue("VertOrientPosition") >>= nVertPosition; + // The test would have failed with Expected: 1588, Actual: 0 + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1588), nVertPosition); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf143208wrapTight) { OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf143208_wrapTight.docx"; diff --git a/writerfilter/qa/cppunittests/dmapper/data/tdf143455_SmartArtPosition.docx b/writerfilter/qa/cppunittests/dmapper/data/tdf143455_SmartArtPosition.docx new file mode 100644 index 000000000000..1b1881b1e9ef Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/tdf143455_SmartArtPosition.docx differ diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index fde309061940..80ffbcaff85c 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -79,6 +79,7 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <o3tl/unit_conversion.hxx> +#include <oox/export/drawingml.hxx> using namespace css; @@ -879,7 +880,12 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) comphelper::SequenceAsHashMap aInteropGrabBag(xShapeProps->getPropertyValue("InteropGrabBag")); sal_Int32 nOOXAngle(0); aInteropGrabBag.getValue("mso-rotation-angle") >>= nOOXAngle; // 1/60000 deg - const bool bIsGroupOrLine = xServiceInfo->supportsService("com.sun.star.drawing.GroupShape") + // tdf#143455: A diagram is imported as group, but has no valid object list + // and contour wrap is different to Word. As workaround diagramms are excluded + // here in various places. + const bool bIsDiagram = oox::drawingml::DrawingML::IsDiagram(m_xShape); + const bool bIsGroupOrLine = (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape") + && !bIsDiagram) || xServiceInfo->supportsService("com.sun.star.drawing.LineShape"); SdrObject* pShape = GetSdrObjectFromXShape(m_xShape); if ((bIsGroupOrLine && !lcl_bHasGroupSlantedChild(pShape) && nOOXAngle == 0) @@ -1012,7 +1018,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) || m_pImpl->nWrap == text::WrapTextMode_LEFT || m_pImpl->nWrap == text::WrapTextMode_RIGHT || m_pImpl->nWrap == text::WrapTextMode_NONE) - && !(m_pImpl->mpWrapPolygon)) + && !(m_pImpl->mpWrapPolygon) && !bIsDiagram) { // For wrap "Square" an area is defined around which the text wraps. MSO // describes the area by a base rectangle and effectExtent. LO uses the @@ -1046,7 +1052,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) m_pImpl->nBottomMargin += aMSOBaseLeftTop.Y + aMSOBaseSize.Height - (aLOBoundRect.Y + aLOBoundRect.Height); } - else if (m_pImpl->mpWrapPolygon) // with contour + else if (m_pImpl->mpWrapPolygon && !bIsDiagram) { // Word uses a wrap polygon, LibreOffice has no explicit wrap polygon // but creates the wrap contour based on the shape geometry, without @@ -1136,7 +1142,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) if (m_pImpl->nRightMargin < 0) m_pImpl->nRightMargin = 0; } - else // text::WrapTextMode_THROUGH + else if (!bIsDiagram) // text::WrapTextMode_THROUGH { // Word writes and evaluates the effectExtent in case of position // type 'Alignment' (UI). We move these values to margin to approximate _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits