summaryrefslogtreecommitdiff
path: root/basegfx/source/polygon
diff options
context:
space:
mode:
authorthb <thb@openoffice.org>2009-10-16 00:59:42 +0200
committerthb <thb@openoffice.org>2009-10-16 00:59:42 +0200
commitd3356548cf6aa4c53cb4c17395df82e8bbdea88f (patch)
tree147c0f2baf5ba699c07afe71f273fb5f8d0f3338 /basegfx/source/polygon
parent7bae8837395d6f4ab80d01ee9525820ced425a51 (diff)
#i105939# Side-tracked by extensive unit test slowness - fixed
by properly using strbuf in svg exporter
Diffstat (limited to 'basegfx/source/polygon')
-rw-r--r--basegfx/source/polygon/b2dsvgpolypolygon.cxx51
1 files changed, 27 insertions, 24 deletions
diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
index 2247c237d90f..c18e6d5e5af8 100644
--- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
@@ -67,10 +67,8 @@ namespace basegfx
}
}
- inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true)
+ inline bool lcl_isOnNumberChar(const sal_Unicode aChar, bool bSignAllowed = true)
{
- const sal_Unicode aChar(rStr[nPos]);
-
const bool bPredicate( (sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
|| (bSignAllowed && sal_Unicode('+') == aChar)
|| (bSignAllowed && sal_Unicode('-') == aChar) );
@@ -78,6 +76,12 @@ namespace basegfx
return bPredicate;
}
+ inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true)
+ {
+ return lcl_isOnNumberChar(rStr[nPos],
+ bSignAllowed);
+ }
+
bool lcl_getDoubleChar(double& o_fRetval,
sal_Int32& io_rPos,
const ::rtl::OUString& rStr,
@@ -233,16 +237,16 @@ namespace basegfx
lcl_skipSpacesAndCommas(io_rPos, rStr, nLen);
}
- void lcl_putNumberChar( ::rtl::OUString& rStr,
- double fValue )
+ void lcl_putNumberChar( ::rtl::OUStringBuffer& rStr,
+ double fValue )
{
- rStr += ::rtl::OUString::valueOf( fValue );
+ rStr.append( fValue );
}
- void lcl_putNumberCharWithSpace( ::rtl::OUString& rStr,
- double fValue,
- double fOldValue,
- bool bUseRelativeCoordinates )
+ void lcl_putNumberCharWithSpace( ::rtl::OUStringBuffer& rStr,
+ double fValue,
+ double fOldValue,
+ bool bUseRelativeCoordinates )
{
if( bUseRelativeCoordinates )
fValue -= fOldValue;
@@ -250,11 +254,10 @@ namespace basegfx
const sal_Int32 aLen( rStr.getLength() );
if(aLen)
{
- if( lcl_isOnNumberChar(rStr, aLen - 1, false) &&
+ if( lcl_isOnNumberChar(rStr.charAt(aLen - 1), false) &&
fValue >= 0.0 )
{
- rStr += ::rtl::OUString::valueOf(
- sal_Unicode(' ') );
+ rStr.append( sal_Unicode(' ') );
}
}
@@ -879,7 +882,7 @@ namespace basegfx
bool bDetectQuadraticBeziers)
{
const sal_uInt32 nCount(rPolyPolygon.count());
- ::rtl::OUString aResult;
+ ::rtl::OUStringBuffer aResult;
B2DPoint aCurrentSVGPosition(0.0, 0.0); // SVG assumes (0,0) as the initial current point
for(sal_uInt32 i(0); i < nCount; i++)
@@ -896,7 +899,7 @@ namespace basegfx
// handle polygon start point
B2DPoint aEdgeStart(aPolygon.getB2DPoint(0));
- aResult += ::rtl::OUString::valueOf(lcl_getCommand('M', 'm', bUseRelativeCoordinates));
+ aResult.append(lcl_getCommand('M', 'm', bUseRelativeCoordinates));
lcl_putNumberCharWithSpace(aResult, aEdgeStart.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
lcl_putNumberCharWithSpace(aResult, aEdgeStart.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
aLastSVGCommand = lcl_getCommand('L', 'l', bUseRelativeCoordinates);
@@ -957,7 +960,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -972,7 +975,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -993,7 +996,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1010,7 +1013,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1049,7 +1052,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1063,7 +1066,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1077,7 +1080,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1095,12 +1098,12 @@ namespace basegfx
// close path if closed poly (Z and z are equivalent here, but looks nicer when case is matched)
if(aPolygon.isClosed())
{
- aResult += ::rtl::OUString::valueOf(lcl_getCommand('Z', 'z', bUseRelativeCoordinates));
+ aResult.append(lcl_getCommand('Z', 'z', bUseRelativeCoordinates));
}
}
}
- return aResult;
+ return aResult.makeStringAndClear();
}
}
}