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
This commit is contained in:
@@ -1969,7 +1969,7 @@ PolyPolygon EscherPropertyContainer::GetPolyPolygon( const ::com::sun::star::uno
|
|||||||
{
|
{
|
||||||
aPolygon.SetFlags( nPointIndex, POLY_CONTROL);
|
aPolygon.SetFlags( nPointIndex, POLY_CONTROL);
|
||||||
aPolygon.SetFlags( nPointIndex+1, POLY_CONTROL);
|
aPolygon.SetFlags( nPointIndex+1, POLY_CONTROL);
|
||||||
aPolygon.SetFlags( nPointIndex+2, POLY_CONTROL);
|
aPolygon.SetFlags( nPointIndex+2, POLY_NORMAL);
|
||||||
nPointIndex += 3;
|
nPointIndex += 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -1793,7 +1793,6 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon )
|
|||||||
|
|
||||||
const Polygon& rPoly = rPolyPolygon[ i ];
|
const Polygon& rPoly = rPolyPolygon[ i ];
|
||||||
Rectangle aRect( rPoly.GetBoundRect() );
|
Rectangle aRect( rPoly.GetBoundRect() );
|
||||||
sal_Bool bBezier = sal_False;
|
|
||||||
|
|
||||||
mpFS->startElementNS( XML_a, XML_path,
|
mpFS->startElementNS( XML_a, XML_path,
|
||||||
XML_w, I64S( aRect.GetWidth() ),
|
XML_w, I64S( aRect.GetWidth() ),
|
||||||
@@ -1812,46 +1811,36 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon )
|
|||||||
mpFS->endElementNS( XML_a, XML_moveTo );
|
mpFS->endElementNS( XML_a, XML_moveTo );
|
||||||
}
|
}
|
||||||
|
|
||||||
sal_Int32 nCounter = 0 ;
|
|
||||||
for( sal_uInt16 j = 1; j < rPoly.GetSize(); j ++ )
|
for( sal_uInt16 j = 1; j < rPoly.GetSize(); j ++ )
|
||||||
{
|
{
|
||||||
enum PolyFlags flags = rPoly.GetFlags(j);
|
enum PolyFlags flags = rPoly.GetFlags(j);
|
||||||
if( flags == POLY_CONTROL && !bBezier )
|
if( flags == POLY_CONTROL )
|
||||||
{
|
{
|
||||||
mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND );
|
// a:cubicBezTo can only contain 3 a:pt elements, so we need to make sure of this
|
||||||
bBezier = sal_True;
|
if( j+2 < rPoly.GetSize() && rPoly.GetFlags(j+1) == POLY_CONTROL && rPoly.GetFlags(j+2) != POLY_CONTROL )
|
||||||
|
{
|
||||||
|
|
||||||
|
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 );
|
||||||
|
|
||||||
|
}
|
||||||
|
mpFS->endElementNS( XML_a, XML_cubicBezTo );
|
||||||
|
j += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( flags == POLY_NORMAL && !bBezier )
|
else if( flags == POLY_NORMAL )
|
||||||
{
|
{
|
||||||
mpFS->startElementNS( XML_a, XML_lnTo, FSEND );
|
mpFS->startElementNS( XML_a, XML_lnTo, FSEND );
|
||||||
++nCounter ;
|
mpFS->singleElementNS( XML_a, XML_pt,
|
||||||
}
|
XML_x, I64S( rPoly[j].X() - aRect.Left() ),
|
||||||
|
XML_y, I64S( rPoly[j].Y() - aRect.Top() ),
|
||||||
mpFS->singleElementNS( XML_a, XML_pt,
|
FSEND );
|
||||||
XML_x, I64S( rPoly[j].X() - aRect.Left() ),
|
|
||||||
XML_y, I64S( rPoly[j].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;
|
|
||||||
}
|
|
||||||
else if( flags == POLY_NORMAL && !bBezier )
|
|
||||||
mpFS->endElementNS( XML_a, XML_lnTo );
|
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 )
|
|
||||||
{
|
|
||||||
// //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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user