diff options
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx | 19 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/tdf143455_SmartArtPosition.docx | bin | 0 -> 24753 bytes | |||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 14 |
3 files changed, 29 insertions, 4 deletions
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 Binary files differnew file mode 100644 index 000000000000..1b1881b1e9ef --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/data/tdf143455_SmartArtPosition.docx 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 |