merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0598-basegfx-svgpolygon-speedup.diff
blob50b4e2ab5fa7c80183c94686c7a0113c123436e0
1 Use stringbuf for concatenating the svg:d string
3 From: Thorsten Behrens <thb@openoffice.org>
6 ---
8 basegfx/source/polygon/b2dsvgpolypolygon.cxx | 51 ++++++++++++++------------
9 1 files changed, 27 insertions(+), 24 deletions(-)
12 diff --git basegfx/source/polygon/b2dsvgpolypolygon.cxx basegfx/source/polygon/b2dsvgpolypolygon.cxx
13 index 0f9d770..2d993a4 100644
14 --- basegfx/source/polygon/b2dsvgpolypolygon.cxx
15 +++ basegfx/source/polygon/b2dsvgpolypolygon.cxx
16 @@ -67,10 +67,8 @@ namespace basegfx
20 - inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true)
21 + inline bool lcl_isOnNumberChar(const sal_Unicode aChar, bool bSignAllowed = true)
23 - const sal_Unicode aChar(rStr[nPos]);
25 const bool bPredicate( (sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
26 || (bSignAllowed && sal_Unicode('+') == aChar)
27 || (bSignAllowed && sal_Unicode('-') == aChar) );
28 @@ -78,6 +76,12 @@ namespace basegfx
29 return bPredicate;
32 + inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true)
33 + {
34 + return lcl_isOnNumberChar(rStr[nPos],
35 + bSignAllowed);
36 + }
38 bool lcl_getDoubleChar(double& o_fRetval,
39 sal_Int32& io_rPos,
40 const ::rtl::OUString& rStr,
41 @@ -233,16 +237,16 @@ namespace basegfx
42 lcl_skipSpacesAndCommas(io_rPos, rStr, nLen);
45 - void lcl_putNumberChar( ::rtl::OUString& rStr,
46 - double fValue )
47 + void lcl_putNumberChar( ::rtl::OUStringBuffer& rStr,
48 + double fValue )
50 - rStr += ::rtl::OUString::valueOf( fValue );
51 + rStr.append( fValue );
54 - void lcl_putNumberCharWithSpace( ::rtl::OUString& rStr,
55 - double fValue,
56 - double fOldValue,
57 - bool bUseRelativeCoordinates )
58 + void lcl_putNumberCharWithSpace( ::rtl::OUStringBuffer& rStr,
59 + double fValue,
60 + double fOldValue,
61 + bool bUseRelativeCoordinates )
63 if( bUseRelativeCoordinates )
64 fValue -= fOldValue;
65 @@ -250,11 +254,10 @@ namespace basegfx
66 const sal_Int32 aLen( rStr.getLength() );
67 if(aLen)
69 - if( lcl_isOnNumberChar(rStr, aLen - 1, false) &&
70 + if( lcl_isOnNumberChar(rStr.charAt(aLen - 1), false) &&
71 fValue >= 0.0 )
73 - rStr += ::rtl::OUString::valueOf(
74 - sal_Unicode(' ') );
75 + rStr.append( sal_Unicode(' ') );
79 @@ -879,7 +882,7 @@ namespace basegfx
80 bool bDetectQuadraticBeziers)
82 const sal_uInt32 nCount(rPolyPolygon.count());
83 - ::rtl::OUString aResult;
84 + ::rtl::OUStringBuffer aResult;
85 B2DPoint aCurrentSVGPosition(0.0, 0.0); // SVG assumes (0,0) as the initial current point
87 for(sal_uInt32 i(0); i < nCount; i++)
88 @@ -896,7 +899,7 @@ namespace basegfx
90 // handle polygon start point
91 B2DPoint aEdgeStart(aPolygon.getB2DPoint(0));
92 - aResult += ::rtl::OUString::valueOf(lcl_getCommand('M', 'm', bUseRelativeCoordinates));
93 + aResult.append(lcl_getCommand('M', 'm', bUseRelativeCoordinates));
94 lcl_putNumberCharWithSpace(aResult, aEdgeStart.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
95 lcl_putNumberCharWithSpace(aResult, aEdgeStart.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
96 aLastSVGCommand = lcl_getCommand('L', 'l', bUseRelativeCoordinates);
97 @@ -957,7 +960,7 @@ namespace basegfx
99 if(aLastSVGCommand != aCommand)
101 - aResult += ::rtl::OUString::valueOf(aCommand);
102 + aResult.append(aCommand);
103 aLastSVGCommand = aCommand;
106 @@ -972,7 +975,7 @@ namespace basegfx
108 if(aLastSVGCommand != aCommand)
110 - aResult += ::rtl::OUString::valueOf(aCommand);
111 + aResult.append(aCommand);
112 aLastSVGCommand = aCommand;
115 @@ -993,7 +996,7 @@ namespace basegfx
117 if(aLastSVGCommand != aCommand)
119 - aResult += ::rtl::OUString::valueOf(aCommand);
120 + aResult.append(aCommand);
121 aLastSVGCommand = aCommand;
124 @@ -1010,7 +1013,7 @@ namespace basegfx
126 if(aLastSVGCommand != aCommand)
128 - aResult += ::rtl::OUString::valueOf(aCommand);
129 + aResult.append(aCommand);
130 aLastSVGCommand = aCommand;
133 @@ -1049,7 +1052,7 @@ namespace basegfx
135 if(aLastSVGCommand != aCommand)
137 - aResult += ::rtl::OUString::valueOf(aCommand);
138 + aResult.append(aCommand);
139 aLastSVGCommand = aCommand;
142 @@ -1063,7 +1066,7 @@ namespace basegfx
144 if(aLastSVGCommand != aCommand)
146 - aResult += ::rtl::OUString::valueOf(aCommand);
147 + aResult.append(aCommand);
148 aLastSVGCommand = aCommand;
151 @@ -1077,7 +1080,7 @@ namespace basegfx
153 if(aLastSVGCommand != aCommand)
155 - aResult += ::rtl::OUString::valueOf(aCommand);
156 + aResult.append(aCommand);
157 aLastSVGCommand = aCommand;
160 @@ -1095,12 +1098,12 @@ namespace basegfx
161 // close path if closed poly (Z and z are equivalent here, but looks nicer when case is matched)
162 if(aPolygon.isClosed())
164 - aResult += ::rtl::OUString::valueOf(lcl_getCommand('Z', 'z', bUseRelativeCoordinates));
165 + aResult.append(lcl_getCommand('Z', 'z', bUseRelativeCoordinates));
170 - return aResult;
171 + return aResult.makeStringAndClear();