1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #include <sal/types.h>
14 #include <basegfx/point/b2dpoint.hxx>
15 #include <drawingml/customshapeproperties.hxx>
16 #include <oox/drawingml/shape.hxx>
17 #include <oox/drawingml/drawingmltypes.hxx>
18 #include <rtl/ustring.hxx>
19 #include <com/sun/star/uno/Reference.hxx>
21 #include <com/sun/star/beans/XPropertySet.hpp>
25 namespace ConnectorHelper
28 * Some preset shapes use the default connector site but in order right, bottom, left, top.
29 * The function detects this.
31 * @param rShapeType The shape type identifier as it is used in the prst attribute in OOXML.
32 * @return true if this shape type has the right, bottom, left, top order of connection site.
34 bool hasClockwiseCxn(const OUString
& rShapeType
);
37 * Calculates the handle positions based on the definition in presetShapeDefinitions.xml and the
38 * actual size of the connector shape. It transforms the handles positions to the actual used
39 * connector layout. It transforms the handle coordinates to Hmm.
40 * The vector rHandlePositions is cleared and then filled with the actual handle positions. It is
41 * empty if the geometry does not use handles, e.g. "bentConnector2" and "curvedConnector2".
42 * This method works both for bentConnector and curvedConnector.
44 * @pre pConnector is not empty and points to a ooxml::drawing::Shape that represents a connector
47 * @param [in] pConnector pointer to a connector shape
48 * @param [in, out] rHandlePositions contains the calculated handle positions.
50 void getOOXHandlePositionsHmm(const oox::drawingml::ShapePtr
& pConnector
,
51 std::vector
<basegfx::B2DPoint
>& rHandlePositions
);
54 * OOXML defines the connector shapes so, that the start point is top-left and the leaving
55 * direction is horizontal. Other layout is done by flipV, flipH and 90deg, 180deg or 270deg
56 * rotation of the connector shape. This method collects these transformations into a
59 * @param [in] pConnector is pointer to a oox::drawing::Shape that represents a connector shape.
60 * @return a newly created B2DHomMatrix. It might be the unit matrix.
62 basegfx::B2DHomMatrix
getConnectorTransformMatrix(const oox::drawingml::ShapePtr
& pConnector
);
65 * Calculates the handle positions of a connector of type ConnectorType_STANDARD. Such connector
66 * corresponds to the OOXML bentConnector shapes, aka "ElbowConnector". The calculation is based on
67 * the actual polygon of the connector. The coordinates are always returned in Hmm, even for shapes
68 * on a text document draw page.
69 * The vector rHandlePositions is cleaned and then filled with the actual handle positions. It
70 * is empty if the geometry does not use handles.
72 * @param [in] pConnector is pointer to a oox::drawing::Shape that represents a connector shape.
73 * @param [in,out] rHandlePositions contains the calculated handle positions.
75 void getLOBentHandlePositionsHmm(const oox::drawingml::ShapePtr
& pConnector
,
76 std::vector
<basegfx::B2DPoint
>& rHandlePositions
);
79 * Calculates the handle positions of a connector of type ConnectorType_CURVE for which OOXML
80 * compatible routing is enabled. Such connector corresponds to the OOXML curvedConnector shapes. The
81 * calculation is based on the actual polygon of the connector. The coordinates are always returned
82 * in Hmm, even for shapes on a text document draw page.
83 * The vector rHandlePositions is cleaned and then filled with the actual handle positions. It
84 * is empty if the geometry does not use handles.
86 * @param [in] pConnector is pointer to a oox::drawing::Shape that represents a connector shape.
87 * @param [in,out] rHandlePositions contains the calculated handle positions.
89 void getLOCurvedHandlePositionsHmm(const oox::drawingml::ShapePtr
& pConnector
,
90 std::vector
<basegfx::B2DPoint
>& rHandlePositions
);
93 * Sets the properties "StartShape", "EndShape", "StartGluePointIndex" and "EndGluePointIndex". Thus
94 * it actually connects the shapes. Connecting generates the default connector path.
96 * @param pConnector is pointer to a oox::drawing::Shape that represents a connector shape.
97 * @param [in] A flat map of target shape candidates, indexed by their msId.
99 void applyConnections(oox::drawingml::ShapePtr
& pConnector
, oox::drawingml::ShapeIdMap
& rShapeMap
);
102 * Calculates the difference between handle positions in OOXML and the default handle positions in
103 * LibreOffice. The difference is written to "EdgeLine1Delta", "EdgeLine2Delta" and "EdgeLine3Delta"
104 * properties. It uses the connector polygon.
106 * @pre The referenced connector has type ConnectorType_STANDARD and has the default connector path.
108 * @param pConnector refers to the shape whose handles are adapted.
110 void applyBentHandleAdjustments(oox::drawingml::ShapePtr pConnector
);
113 * Calculates the difference between handle positions in OOXML and the default handle positions in
114 * LibreOffice. The difference is written to "EdgeLine1Delta", "EdgeLine2Delta" and "EdgeLine3Delta"
115 * properties. It uses the connector polygon.
117 * @pre The referenced connector has type ConnectorType_CURVE, OOXML compatible routing is enabled,
118 and the connector has the default connector path.
119 * @param pConnector refers to the shape whose handles are adapted.
121 void applyCurvedHandleAdjustments(oox::drawingml::ShapePtr pConnector
);
123 } // end namespace ConnectorHelper
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */