summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2016-07-01 14:30:00 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-07-07 16:46:34 +0200
commit45c5e527cce0f73db3b554f655cb8df4d8432683 (patch)
tree4d597ccff1c62a9a8194d9c9c609fd349e4b7077
parente98353c56efd45762a95d93e968685c10ec313a6 (diff)
tdf#83360 avoid inconsistent connector path data
When loading/importing connectors from ODF format, use the available path data _only_ if the redundant data of start and end point coordinates of path start/end and connector start/end is equal. This is to avoid using errorneous or inconsistent path data at import of foreign formats. LibO itself always writes out a consistent data set. Not using it when there is inconsistency is okay since the path data is completely redundant, just to avoid recalculation of the connector's layout at load time, no real information would be lost. A 'connected' end has prio to direct coordinate data in Start/EndPosition to the path data. Change-Id: Id5aff0889e1e61112b6185f2384b7922f90a16a9
-rw-r--r--xmloff/source/draw/ximpshap.cxx50
1 files changed, 50 insertions, 0 deletions
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 316b37912a00..5067e686e784 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -2081,6 +2081,56 @@ void SdXMLConnectorShapeContext::StartElement(const uno::Reference< xml::sax::XA
if ( bApplySVGD )
{
+ // tdf#83360 use path data only when redundant data of start and end point coordinates of
+ // path start/end and connector start/end is equal. This is to avoid using erraneous
+ // or inconsistent path data at import of foreign formats. Office itself always
+ // writes out a consistent data set. Not using it when there is inconsistency
+ // is okay since the path data is redundant, buffered data just to avoid recalculation
+ // of the connector's layout at load time, no real information would be lost.
+ // A 'connected' end has prio to direct coordinate data in Start/EndPosition
+ // to the path data (which should have the start/end redundant in the path)
+ const drawing::PolyPolygonBezierCoords* pSource = static_cast< const drawing::PolyPolygonBezierCoords* >(maPath.getValue());
+ const sal_uInt32 nSequenceCount(pSource->Coordinates.getLength());
+ bool bStartEqual(false);
+ bool bEndEqual(false);
+
+ if(nSequenceCount)
+ {
+ const drawing::PointSequence& rStartSeq = pSource->Coordinates[0];
+ const sal_uInt32 nStartCount = rStartSeq.getLength();
+
+ if(nStartCount)
+ {
+ const awt::Point& rStartPoint = rStartSeq.getConstArray()[0];
+
+ if(rStartPoint.X == maStart.X && rStartPoint.Y == maStart.Y)
+ {
+ bStartEqual = true;
+ }
+ }
+
+ const drawing::PointSequence& rEndSeq = pSource->Coordinates[nSequenceCount - 1];
+ const sal_uInt32 nEndCount = rEndSeq.getLength();
+
+ if(nEndCount)
+ {
+ const awt::Point& rEndPoint = rEndSeq.getConstArray()[nEndCount - 1];
+
+ if(rEndPoint.X == maEnd.X && rEndPoint.Y == maEnd.Y)
+ {
+ bEndEqual = true;
+ }
+ }
+ }
+
+ if(!bStartEqual || !bEndEqual)
+ {
+ bApplySVGD = false;
+ }
+ }
+
+ if ( bApplySVGD )
+ {
assert(maPath.getValueType() == cppu::UnoType<drawing::PolyPolygonBezierCoords>::get());
xProps->setPropertyValue("PolyPolygonBezier", maPath);
}