Kaydet (Commit) cf4e5e49 authored tarafından umeshkadam's avatar umeshkadam Kaydeden (comit) Miklos Vajna

FDO#74774 : issue with number of child nodes of tag CubicBezierTo.

Issue :
 - Number of child nodes required by cubicBexTo should be 3 of type "pt".
   While exporting, sometimes the child nodes are less than 3.
   The sequence of writing these tags was getting messed up.

Implementation :
 - corrected the logic for writing the sequence of cubicBexTo tag.

Change-Id: Ic26db72b2c516276c2e6452a21b4106d6a0a1a80
Reviewed-on: https://gerrit.libreoffice.org/7990Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 0ff99add
...@@ -1812,6 +1812,7 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon ) ...@@ -1812,6 +1812,7 @@ 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);
...@@ -1821,7 +1822,10 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon ) ...@@ -1821,7 +1822,10 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon )
bBezier = sal_True; bBezier = sal_True;
} }
else if( flags == POLY_NORMAL && !bBezier ) else if( flags == POLY_NORMAL && !bBezier )
{
mpFS->startElementNS( XML_a, XML_lnTo, FSEND ); mpFS->startElementNS( XML_a, XML_lnTo, FSEND );
++nCounter ;
}
mpFS->singleElementNS( XML_a, XML_pt, mpFS->singleElementNS( XML_a, XML_pt,
XML_x, I64S( rPoly[j].X() - aRect.Left() ), XML_x, I64S( rPoly[j].X() - aRect.Left() ),
...@@ -1835,12 +1839,19 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon ) ...@@ -1835,12 +1839,19 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon )
} }
else if( flags == POLY_NORMAL && !bBezier ) else if( flags == POLY_NORMAL && !bBezier )
mpFS->endElementNS( XML_a, XML_lnTo ); mpFS->endElementNS( XML_a, XML_lnTo );
else if( bBezier && ( j % 3 ) == 0 )
/* ( 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 // //a:cubicBezTo can only contain 3 //a:pt elements, so we
// need to break things up... // need to break things up...
mpFS->endElementNS( XML_a, XML_cubicBezTo ); mpFS->endElementNS( XML_a, XML_cubicBezTo );
mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND ); bBezier = sal_False;
} }
} }
......
...@@ -3200,6 +3200,21 @@ DECLARE_OOXMLEXPORT_TEST(testExtentValue, "fdo74605.docx") ...@@ -3200,6 +3200,21 @@ DECLARE_OOXMLEXPORT_TEST(testExtentValue, "fdo74605.docx")
#endif #endif
DECLARE_OOXMLEXPORT_TEST( testChildNodesOfCubicBezierTo, "FDO74774.docx")
{
/* Number of children required by cubicBexTo is 3 of type "pt".
While exporting, sometimes the child nodes are less than 3.
The test case ensures that there are 3 child nodes of type "pt"
for cubicBexTo
*/
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
assertXPath( pXmlDoc,
"/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent[1]/mc:Choice/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wpg:wgp[1]/wps:wsp[3]/wps:spPr[1]/a:custGeom[1]/a:pathLst[1]/a:path[1]/a:cubicBezTo[2]/a:pt[3]");
}
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment