summaryrefslogtreecommitdiff
path: root/oox/qa
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2023-11-19 00:26:16 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-12-01 08:44:01 +0100
commit44ee19c99bfb3bf0f550d9656e87bca3e20e5ca0 (patch)
tree3c937a4c86ec15400a12fb1e69ae893fc8541d39 /oox/qa
parenta83088b05f177fb938c2e4ffb06cd19362a5a1ca (diff)
[API CHANGE] Add OOXML way of curved connector routing
The paths generated for curved connectors are basically incompatible between LibreOffice and OOXML. Thus it was not possible to render curved connectors the same way as MS Office. The patch adds an OOXML compatible method for calculating the path. The new method results in a different svg:d attribute when saved in ODF, but needs no change to ODF. The patch introduces the boolean connector property 'EdgeOOXMLCurve' to switch between the two methods. The property value is determined from the svg:d attribute in case of import from ODF. In case of missing svg:d attribute the property value is set to 'true', because Word currently does not write a svg:d attribute when it exports to ODF. The property value is set to 'true' for import of connectors on a drawing canvas in docx. Default value for new connectors is 'false'. The new property has no UI, but can be used via macro. Currently the new method is used for import of curved connectors on drawing canvas in docx documents. Change-Id: I53d99f44febe4d74c2b611f5fdb9de86628c4519 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159708 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox/qa')
-rw-r--r--oox/qa/unit/data/WPC_CurvedConnector2.docxbin0 -> 20635 bytes
-rw-r--r--oox/qa/unit/data/WPC_CurvedConnector5.docxbin0 -> 21262 bytes
-rw-r--r--oox/qa/unit/wpc_drawing_canvas.cxx32
3 files changed, 31 insertions, 1 deletions
diff --git a/oox/qa/unit/data/WPC_CurvedConnector2.docx b/oox/qa/unit/data/WPC_CurvedConnector2.docx
new file mode 100644
index 000000000000..3f914fdf5cb0
--- /dev/null
+++ b/oox/qa/unit/data/WPC_CurvedConnector2.docx
Binary files differ
diff --git a/oox/qa/unit/data/WPC_CurvedConnector5.docx b/oox/qa/unit/data/WPC_CurvedConnector5.docx
new file mode 100644
index 000000000000..e92f9ecc21ac
--- /dev/null
+++ b/oox/qa/unit/data/WPC_CurvedConnector5.docx
Binary files differ
diff --git a/oox/qa/unit/wpc_drawing_canvas.cxx b/oox/qa/unit/wpc_drawing_canvas.cxx
index d1fde534034c..ba347925d317 100644
--- a/oox/qa/unit/wpc_drawing_canvas.cxx
+++ b/oox/qa/unit/wpc_drawing_canvas.cxx
@@ -17,6 +17,7 @@
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/ConnectorType.hpp>
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -26,7 +27,6 @@
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
#include <com/sun/star/util/XComplexColor.hpp>
-
using namespace ::com::sun::star;
namespace
@@ -306,6 +306,36 @@ CPPUNIT_TEST_FIXTURE(TestWPC, WPC_tdf158348_shape_text_in_table_cell)
// The string had started with "Inside shape" without fix.
CPPUNIT_ASSERT(xCellA1->getString().startsWith("Inside table"));
}
+
+CPPUNIT_TEST_FIXTURE(TestWPC, WPC_CurvedConnector2)
+{
+ // The document has two shapes connected with a curvedConnector2 on a drawing canvas.
+ // This connector is a single Bezier segment without handles.
+ loadFromURL(u"WPC_CurvedConnector2.docx");
+
+ // LO and OOXML differ in the position of the control points. LibreOffice uses 2/3 but OOXML
+ // uses 1/2 of width or height. The path by LO looks more round.
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+ uno::Reference<drawing::XShapes> xGroup(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<lang::XServiceInfo> xInfo(xGroup->getByIndex(3), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xInfo->supportsService("com.sun.star.drawing.ConnectorShape"));
+
+ uno::Reference<beans::XPropertySet> xShapeProps(xGroup->getByIndex(3), uno::UNO_QUERY);
+ com::sun::star::drawing::ConnectorType eEdgeKind;
+ xShapeProps->getPropertyValue(UNO_NAME_EDGEKIND) >>= eEdgeKind;
+ CPPUNIT_ASSERT_EQUAL(drawing::ConnectorType::ConnectorType_CURVE, eEdgeKind);
+
+ // Make sure the path is OOXML compatible
+ drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords;
+ xShapeProps->getPropertyValue("PolyPolygonBezier") >>= aPolyPolygonBezierCoords;
+ drawing::PointSequence aPolygon = aPolyPolygonBezierCoords.Coordinates[0];
+ // First control point. LO routing would generate point (4372|5584).
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5149), aPolygon[1].Y);
+ // Second control point. LO routing would generate point (5887|6458).
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(6645), aPolygon[2].X);
+}
}
CPPUNIT_PLUGIN_IMPLEMENT();