[Libreoffice-commits] .: Branch 'libreoffice-3-5' - basegfx/source
Michael Stahl
mst at kemper.freedesktop.org
Wed Feb 15 03:02:47 PST 2012
basegfx/source/tools/unotools.cxx | 113 +++++++++++++++++++-------------------
1 file changed, 58 insertions(+), 55 deletions(-)
New commits:
commit 3c65e1fef5a4b4e41b4b3846712d7e76e94a34e8
Author: Thorsten Behrens <tbehrens at suse.com>
Date: Wed Feb 15 11:25:57 2012 +0100
Fix fdo#45779 - accessing empty polygon.
Guard access to first polygon point.
(cherry picked from commit d37abad97d72bae0fd0269de12e94c7a7d3fd7e1)
Signed-off-by: Michael Stahl <mstahl at redhat.com>
diff --git a/basegfx/source/tools/unotools.cxx b/basegfx/source/tools/unotools.cxx
index 63b0f4e..6febfd3 100644
--- a/basegfx/source/tools/unotools.cxx
+++ b/basegfx/source/tools/unotools.cxx
@@ -187,70 +187,73 @@ namespace unotools
std::vector<awt::Point> aPoints; aPoints.reserve(nLoopCount);
std::vector<drawing::PolygonFlags> aFlags; aFlags.reserve(nLoopCount);
- // prepare insert index and current point
- basegfx::B2DCubicBezier aBezier;
- aBezier.setStartPoint(rPoly.getB2DPoint(0));
-
- for(sal_uInt32 b(0L); b<nLoopCount; b++)
+ if( nCount )
{
- // add current point (always) and remember StartPointIndex for evtl. later corrections
- const awt::Point aStartPoint(fround(aBezier.getStartPoint().getX()),
- fround(aBezier.getStartPoint().getY()));
- const sal_uInt32 nStartPointIndex(aPoints.size());
- aPoints.push_back(aStartPoint);
- aFlags.push_back(drawing::PolygonFlags_NORMAL);
-
- // prepare next segment
- const sal_uInt32 nNextIndex((b + 1) % nCount);
- aBezier.setEndPoint(rPoly.getB2DPoint(nNextIndex));
- aBezier.setControlPointA(rPoly.getNextControlPoint(b));
- aBezier.setControlPointB(rPoly.getPrevControlPoint(nNextIndex));
-
- if(aBezier.isBezier())
- {
- // if one is used, add always two control points due to the old schema
- aPoints.push_back( awt::Point(fround(aBezier.getControlPointA().getX()),
- fround(aBezier.getControlPointA().getY())) );
- aFlags.push_back(drawing::PolygonFlags_CONTROL);
-
- aPoints.push_back( awt::Point(fround(aBezier.getControlPointB().getX()),
- fround(aBezier.getControlPointB().getY())) );
- aFlags.push_back(drawing::PolygonFlags_CONTROL);
- }
+ // prepare insert index and current point
+ basegfx::B2DCubicBezier aBezier;
+ aBezier.setStartPoint(rPoly.getB2DPoint(0));
- // test continuity with previous control point to set flag value
- if(aBezier.getControlPointA() != aBezier.getStartPoint() && (bClosed || b))
+ for(sal_uInt32 b(0L); b<nLoopCount; b++)
{
- const basegfx::B2VectorContinuity eCont(rPoly.getContinuityInPoint(b));
-
- if(basegfx::CONTINUITY_C1 == eCont)
+ // add current point (always) and remember StartPointIndex for evtl. later corrections
+ const awt::Point aStartPoint(fround(aBezier.getStartPoint().getX()),
+ fround(aBezier.getStartPoint().getY()));
+ const sal_uInt32 nStartPointIndex(aPoints.size());
+ aPoints.push_back(aStartPoint);
+ aFlags.push_back(drawing::PolygonFlags_NORMAL);
+
+ // prepare next segment
+ const sal_uInt32 nNextIndex((b + 1) % nCount);
+ aBezier.setEndPoint(rPoly.getB2DPoint(nNextIndex));
+ aBezier.setControlPointA(rPoly.getNextControlPoint(b));
+ aBezier.setControlPointB(rPoly.getPrevControlPoint(nNextIndex));
+
+ if(aBezier.isBezier())
{
- aFlags[nStartPointIndex] = drawing::PolygonFlags_SMOOTH;
+ // if one is used, add always two control points due to the old schema
+ aPoints.push_back( awt::Point(fround(aBezier.getControlPointA().getX()),
+ fround(aBezier.getControlPointA().getY())) );
+ aFlags.push_back(drawing::PolygonFlags_CONTROL);
+
+ aPoints.push_back( awt::Point(fround(aBezier.getControlPointB().getX()),
+ fround(aBezier.getControlPointB().getY())) );
+ aFlags.push_back(drawing::PolygonFlags_CONTROL);
}
- else if(basegfx::CONTINUITY_C2 == eCont)
+
+ // test continuity with previous control point to set flag value
+ if(aBezier.getControlPointA() != aBezier.getStartPoint() && (bClosed || b))
{
- aFlags[nStartPointIndex] = drawing::PolygonFlags_SYMMETRIC;
+ const basegfx::B2VectorContinuity eCont(rPoly.getContinuityInPoint(b));
+
+ if(basegfx::CONTINUITY_C1 == eCont)
+ {
+ aFlags[nStartPointIndex] = drawing::PolygonFlags_SMOOTH;
+ }
+ else if(basegfx::CONTINUITY_C2 == eCont)
+ {
+ aFlags[nStartPointIndex] = drawing::PolygonFlags_SYMMETRIC;
+ }
}
- }
- // prepare next polygon step
- aBezier.setStartPoint(aBezier.getEndPoint());
- }
+ // prepare next polygon step
+ aBezier.setStartPoint(aBezier.getEndPoint());
+ }
- if(bClosed)
- {
- // add first point again as closing point due to old definition
- aPoints.push_back( aPoints[0] );
- aFlags.push_back(drawing::PolygonFlags_NORMAL);
- }
- else
- {
- // add last point as closing point
- const basegfx::B2DPoint aClosingPoint(rPoly.getB2DPoint(nCount - 1L));
- const awt::Point aEnd(fround(aClosingPoint.getX()),
- fround(aClosingPoint.getY()));
- aPoints.push_back(aEnd);
- aFlags.push_back(drawing::PolygonFlags_NORMAL);
+ if(bClosed)
+ {
+ // add first point again as closing point due to old definition
+ aPoints.push_back( aPoints[0] );
+ aFlags.push_back(drawing::PolygonFlags_NORMAL);
+ }
+ else
+ {
+ // add last point as closing point
+ const basegfx::B2DPoint aClosingPoint(rPoly.getB2DPoint(nCount - 1L));
+ const awt::Point aEnd(fround(aClosingPoint.getX()),
+ fround(aClosingPoint.getY()));
+ aPoints.push_back(aEnd);
+ aFlags.push_back(drawing::PolygonFlags_NORMAL);
+ }
}
*pOuterSequence++ = comphelper::containerToSequence(aPoints);
More information about the Libreoffice-commits
mailing list