Fix error in handling 'z' for svg:d string parsing
Previously 'z' did not update the current point to the start point of the subpath, as required by http://www.w3.org/TR/SVG/paths.html#PathDataClosePathCommand. Fixed now, and adapted all the unit tests.
This commit is contained in:
@@ -123,8 +123,7 @@ namespace basegfx
|
|||||||
/** Read poly-polygon from SVG.
|
/** Read poly-polygon from SVG.
|
||||||
|
|
||||||
This function imports a poly-polygon from an SVG-D
|
This function imports a poly-polygon from an SVG-D
|
||||||
attribute. Currently, elliptical arc elements are not yet
|
attribute.
|
||||||
supported (and ignored during parsing).
|
|
||||||
|
|
||||||
@param o_rPolyPoly
|
@param o_rPolyPoly
|
||||||
The output poly-polygon
|
The output poly-polygon
|
||||||
|
@@ -239,6 +239,14 @@ namespace basegfx
|
|||||||
|
|
||||||
// remember closed state of current polygon
|
// remember closed state of current polygon
|
||||||
bIsClosed = true;
|
bIsClosed = true;
|
||||||
|
|
||||||
|
// update current point - we're back at the start
|
||||||
|
if( aCurrPoly.count() )
|
||||||
|
{
|
||||||
|
const B2DPoint aFirst( aCurrPoly.getB2DPoint(0) );
|
||||||
|
nLastX = aFirst.getX();
|
||||||
|
nLastY = aFirst.getY();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1033,6 +1041,8 @@ namespace basegfx
|
|||||||
if(aPolygon.isClosed())
|
if(aPolygon.isClosed())
|
||||||
{
|
{
|
||||||
aResult.append(lcl_getCommand('Z', 'z', bUseRelativeCoordinates));
|
aResult.append(lcl_getCommand('Z', 'z', bUseRelativeCoordinates));
|
||||||
|
// return to first point
|
||||||
|
aCurrentSVGPosition = aPolygon.getB2DPoint(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -136,8 +136,9 @@ public:
|
|||||||
void verifySimpleRange()
|
void verifySimpleRange()
|
||||||
{
|
{
|
||||||
const char* unionSvg="m100 10v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z";
|
const char* unionSvg="m100 10v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z";
|
||||||
const char* intersectSvg="m-100 10v-20h10v20zm80 90v-10h20v10zm-20-190v-10h20v10zm80 100v-20h10v20z";
|
const char* intersectSvg="m-100 10v-20h10v20zm90 90v-10h20v10zm0-190v-10h20v10zm100 100v-20h10v20z";
|
||||||
const char* xorSvg="m-100 10h10v-20h-10zm90 110h20v-10h-20zm0-180h20v-10h-20zm100 110h10v-20h-10zm10 20v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z";
|
const char* xorSvg="m-100 10h10v-20h-10zm90 90h20v-10h-20zm0-190h20v-10h-20zm100 100h10v-20h-10z"
|
||||||
|
"m10 0v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z";
|
||||||
const char* subtractSvg="m-90 10v-20h-10v-90h90v10h20v-10h90v90h-10v20h10v90h-90v-10h-20v10h-90v-90z";
|
const char* subtractSvg="m-90 10v-20h-10v-90h90v10h20v-10h90v90h-10v20h10v90h-90v-10h-20v10h-90v-90z";
|
||||||
|
|
||||||
CPPUNIT_ASSERT_MESSAGE("cleared clip stays empty under union operation",
|
CPPUNIT_ASSERT_MESSAGE("cleared clip stays empty under union operation",
|
||||||
@@ -164,7 +165,7 @@ public:
|
|||||||
aMixedClip.subtractRange(B2DRange(-150,-20,0,20));
|
aMixedClip.subtractRange(B2DRange(-150,-20,0,20));
|
||||||
aMixedClip.xorRange(B2DRange(-150,-150,150,150));
|
aMixedClip.xorRange(B2DRange(-150,-150,150,150));
|
||||||
|
|
||||||
const char* mixedClipSvg="m0 0v20h-100v80h90v10h20v-10h90v-90h10v-20h-10v-90h-80v100zm-40-20v-80h-80v80zm-50 170v-300h300v300z";
|
const char* mixedClipSvg="m0 0v20h-100v80h90v10h20v-10h90v-90h10v-20h-10v-90h-80v100zm-20-20v-80h-80v80zm-130 170v-300h300v300z";
|
||||||
verifyPoly("mixed clip", mixedClipSvg, aMixedClip);
|
verifyPoly("mixed clip", mixedClipSvg, aMixedClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -121,13 +121,13 @@ public:
|
|||||||
|
|
||||||
void validateOr()
|
void validateOr()
|
||||||
{
|
{
|
||||||
const char* pValid="m0 0h100v150h-75v-50h-5v50h-20v-50-10zm75 10v-50h-50v50z";
|
const char* pValid="m0 0h100v150h-75v-50h-5v50h-20v-50-10zm75 100v-50h-50v50z";
|
||||||
validate("validateOr", pValid, &tools::solvePolygonOperationOr);
|
validate("validateOr", pValid, &tools::solvePolygonOperationOr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateXor()
|
void validateXor()
|
||||||
{
|
{
|
||||||
const char* pValid="m0 0h100v150h-75v-50h-5v50h-20v-50-10zm0 10h20v-10h-20zm75 10v-50h-50v50z";
|
const char* pValid="m0 0h100v150h-75v-50h-5v50h-20v-50-10zm0 100h20v-10h-20zm75 0v-50h-50v50z";
|
||||||
validate("validateXor", pValid, &tools::solvePolygonOperationXor);
|
validate("validateXor", pValid, &tools::solvePolygonOperationXor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,10 +139,23 @@ public:
|
|||||||
|
|
||||||
void validateDiff()
|
void validateDiff()
|
||||||
{
|
{
|
||||||
const char* pValid="m0 90v-90h100v150h-75v-50h-5v-10zm55 10v-50h-50v50z";
|
const char* pValid="m0 90v-90h100v150h-75v-50h-5v-10zm75 10v-50h-50v50z";
|
||||||
validate("validateDiff", pValid, &tools::solvePolygonOperationDiff);
|
validate("validateDiff", pValid, &tools::solvePolygonOperationDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkCrossoverSolver()
|
||||||
|
{
|
||||||
|
B2DPolyPolygon aPoly;
|
||||||
|
tools::importFromSvgD(
|
||||||
|
aPoly,
|
||||||
|
::rtl::OUString(
|
||||||
|
RTL_CONSTASCII_USTRINGPARAM(
|
||||||
|
"m0 0 v 5 h 3 h 1 h 1 h 1 v -2 v -3 z"
|
||||||
|
"m3 7 v -2 h 1 h 1 h 1 v -2 h 1 v 3 z")));
|
||||||
|
|
||||||
|
tools::solveCrossovers(aPoly);
|
||||||
|
}
|
||||||
|
|
||||||
// Change the following lines only, if you add, remove or rename
|
// Change the following lines only, if you add, remove or rename
|
||||||
// member functions of the current class,
|
// member functions of the current class,
|
||||||
// because these macros are need by auto register mechanism.
|
// because these macros are need by auto register mechanism.
|
||||||
@@ -152,6 +165,7 @@ public:
|
|||||||
CPPUNIT_TEST(validateXor);
|
CPPUNIT_TEST(validateXor);
|
||||||
CPPUNIT_TEST(validateAnd);
|
CPPUNIT_TEST(validateAnd);
|
||||||
CPPUNIT_TEST(validateDiff);
|
CPPUNIT_TEST(validateDiff);
|
||||||
|
CPPUNIT_TEST(checkCrossoverSolver);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user