summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-02-16 17:37:13 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-02-16 17:45:37 +0100
commitc7c761455fbdece36c4fb7cfb9bdd4495e80ddba (patch)
treeadef0791755c3bad9c06b880fcd18667085207d1 /oox
parent6357031a3269ea191965469a8fe6867e7335e292 (diff)
drawingML export: make WritePolyPolygon robuster
Make sure a:cubicBezTo conatins three a:pt elements. escherex: It seems a cubic bezier curve last point has a POLY_NORMAL flag and not POLY_CONTROL. Change-Id: Id6dc2160c7ae171a720e4a1aa9161cef2b3b9413
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx55
1 files changed, 22 insertions, 33 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index d03a0d87c007..c4e79a4af781 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1793,7 +1793,6 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon )
const Polygon& rPoly = rPolyPolygon[ i ];
Rectangle aRect( rPoly.GetBoundRect() );
- sal_Bool bBezier = sal_False;
mpFS->startElementNS( XML_a, XML_path,
XML_w, I64S( aRect.GetWidth() ),
@@ -1812,46 +1811,36 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon )
mpFS->endElementNS( XML_a, XML_moveTo );
}
- sal_Int32 nCounter = 0 ;
for( sal_uInt16 j = 1; j < rPoly.GetSize(); j ++ )
{
enum PolyFlags flags = rPoly.GetFlags(j);
- if( flags == POLY_CONTROL && !bBezier )
+ if( flags == POLY_CONTROL )
{
- mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND );
- bBezier = sal_True;
- }
- else if( flags == POLY_NORMAL && !bBezier )
- {
- mpFS->startElementNS( XML_a, XML_lnTo, FSEND );
- ++nCounter ;
- }
+ // a:cubicBezTo can only contain 3 a:pt elements, so we need to make sure of this
+ if( j+2 < rPoly.GetSize() && rPoly.GetFlags(j+1) == POLY_CONTROL && rPoly.GetFlags(j+2) != POLY_CONTROL )
+ {
- mpFS->singleElementNS( XML_a, XML_pt,
- XML_x, I64S( rPoly[j].X() - aRect.Left() ),
- XML_y, I64S( rPoly[j].Y() - aRect.Top() ),
- FSEND );
+ mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND );
+ for( sal_uInt8 k = 0; k <= 2; ++k )
+ {
+ mpFS->singleElementNS( XML_a, XML_pt,
+ XML_x, I64S( rPoly[j+k].X() - aRect.Left() ),
+ XML_y, I64S( rPoly[j+k].Y() - aRect.Top() ),
+ FSEND );
- if( ( flags == POLY_NORMAL || flags == POLY_SYMMTR || j == rPoly.GetSize() - 1) && bBezier )
- {
- mpFS->endElementNS( XML_a, XML_cubicBezTo );
- bBezier = sal_False;
+ }
+ mpFS->endElementNS( XML_a, XML_cubicBezTo );
+ j += 2;
+ }
}
- else if( flags == POLY_NORMAL && !bBezier )
- mpFS->endElementNS( XML_a, XML_lnTo );
-
- /* ( j % 3 == 0 ) will fail to address the iterations
- that have been dedicated to XML_lnTo in case if the
- flag is POLY_NORMAL.
- Similarly the sequence would go wrong if we do not
- make the flag bBezier as false after ending the element.
- */
- else if( bBezier && ( ( j - nCounter ) % 3 ) == 0 )
+ else if( flags == POLY_NORMAL )
{
- // //a:cubicBezTo can only contain 3 //a:pt elements, so we
- // need to break things up...
- mpFS->endElementNS( XML_a, XML_cubicBezTo );
- bBezier = sal_False;
+ mpFS->startElementNS( XML_a, XML_lnTo, FSEND );
+ mpFS->singleElementNS( XML_a, XML_pt,
+ XML_x, I64S( rPoly[j].X() - aRect.Left() ),
+ XML_y, I64S( rPoly[j].Y() - aRect.Top() ),
+ FSEND );
+ mpFS->endElementNS( XML_a, XML_lnTo );
}
}