summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2021-07-21 20:43:53 +0200
committerRegina Henschel <rb.henschel@t-online.de>2021-07-23 18:05:01 +0200
commit17cfd3d3e2e6f807eb1faf07436c7e96e15157a7 (patch)
tree8c55447bc5752c5d56318a647418c026e2d99d25
parent9b09e862558caf1aa6c71b11c8f4b7f873c12b7a (diff)
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.henschel@t-online.de>
-rw-r--r--writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx19
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/tdf143455_SmartArtPosition.docxbin0 -> 24753 bytes
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx14
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
new file mode 100644
index 000000000000..1b1881b1e9ef
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/tdf143455_SmartArtPosition.docx
Binary files 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