basegfx2d.cxx (09dbbe93) basegfx2d.cxx (1f882ec4)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 136 unchanged lines hidden (view full) ---

145 }
146
147 void impex()
148 {
149 B2DPolyPolygon aPoly;
150 ::rtl::OUString aExport;
151
152 CPPUNIT_ASSERT_MESSAGE("importing simple rectangle from SVG-D",
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 136 unchanged lines hidden (view full) ---

145 }
146
147 void impex()
148 {
149 B2DPolyPolygon aPoly;
150 ::rtl::OUString aExport;
151
152 CPPUNIT_ASSERT_MESSAGE("importing simple rectangle from SVG-D",
153 tools::importFromSvgD( aPoly,
154 aPath0 ));
155 aExport = tools::exportToSvgD( aPoly );
153 tools::importFromSvgD( aPoly, aPath0, false, 0 ));
154 aExport = tools::exportToSvgD( aPoly, true, true, false );
156 const char* sExportString = "m10 10h-20v-20h20z";
157 CPPUNIT_ASSERT_MESSAGE("exporting rectangle to SVG-D",
158 !aExport.compareToAscii(sExportString) );
159 CPPUNIT_ASSERT_MESSAGE("importing simple rectangle from SVG-D (round-trip",
155 const char* sExportString = "m10 10h-20v-20h20z";
156 CPPUNIT_ASSERT_MESSAGE("exporting rectangle to SVG-D",
157 !aExport.compareToAscii(sExportString) );
158 CPPUNIT_ASSERT_MESSAGE("importing simple rectangle from SVG-D (round-trip",
160 tools::importFromSvgD( aPoly,
161 aExport ));
162 aExport = tools::exportToSvgD( aPoly );
159 tools::importFromSvgD( aPoly, aExport, false, 0 ));
160 aExport = tools::exportToSvgD( aPoly, true, true, false );
163 CPPUNIT_ASSERT_MESSAGE("exporting rectangle to SVG-D (round-trip)",
164 !aExport.compareToAscii(sExportString));
165
166 CPPUNIT_ASSERT_MESSAGE("importing simple bezier polygon from SVG-D",
161 CPPUNIT_ASSERT_MESSAGE("exporting rectangle to SVG-D (round-trip)",
162 !aExport.compareToAscii(sExportString));
163
164 CPPUNIT_ASSERT_MESSAGE("importing simple bezier polygon from SVG-D",
167 tools::importFromSvgD( aPoly,
168 aPath1 ));
169 aExport = tools::exportToSvgD( aPoly );
165 tools::importFromSvgD( aPoly, aPath1, false, 0 ));
166 aExport = tools::exportToSvgD( aPoly, true, true, false );
170
171 // Adaptions for B2DPolygon bezier change (see #i77162#):
172 //
173 // The import/export of aPath1 does not reproduce aExport again. This is
174 // correct since aPath1 contains a segment with non-used control points
175 // which gets exported now correctly as 'l' and also a point (#4, index 3)
176 // with C2 continuity which produces a 's' staement now.
177 //

--- 10 unchanged lines hidden (view full) ---

188 "s-3810-11430-3810-11430z";
189 CPPUNIT_ASSERT_MESSAGE("exporting bezier polygon to SVG-D", !aExport.compareToAscii(sExportStringSimpleBezier));
190
191 // Adaptions for B2DPolygon bezier change (see #i77162#):
192 //
193 // a 2nd good test is that re-importing of aExport has to create the same
194 // B2DPolPolygon again:
195 B2DPolyPolygon aReImport;
167
168 // Adaptions for B2DPolygon bezier change (see #i77162#):
169 //
170 // The import/export of aPath1 does not reproduce aExport again. This is
171 // correct since aPath1 contains a segment with non-used control points
172 // which gets exported now correctly as 'l' and also a point (#4, index 3)
173 // with C2 continuity which produces a 's' staement now.
174 //

--- 10 unchanged lines hidden (view full) ---

185 "s-3810-11430-3810-11430z";
186 CPPUNIT_ASSERT_MESSAGE("exporting bezier polygon to SVG-D", !aExport.compareToAscii(sExportStringSimpleBezier));
187
188 // Adaptions for B2DPolygon bezier change (see #i77162#):
189 //
190 // a 2nd good test is that re-importing of aExport has to create the same
191 // B2DPolPolygon again:
192 B2DPolyPolygon aReImport;
196 CPPUNIT_ASSERT_MESSAGE("importing simple bezier polygon from SVG-D", tools::importFromSvgD( aReImport, aExport));
193 CPPUNIT_ASSERT_MESSAGE("importing simple bezier polygon from SVG-D", tools::importFromSvgD( aReImport, aExport, false, 0));
197 CPPUNIT_ASSERT_MESSAGE("re-imported polygon needs to be identical", aReImport == aPoly);
198
194 CPPUNIT_ASSERT_MESSAGE("re-imported polygon needs to be identical", aReImport == aPoly);
195
199 CPPUNIT_ASSERT_MESSAGE("importing '@' from SVG-D", tools::importFromSvgD( aPoly, aPath2 ));
200 aExport = tools::exportToSvgD( aPoly );
196 CPPUNIT_ASSERT_MESSAGE("importing '@' from SVG-D", tools::importFromSvgD( aPoly, aPath2, , false, 0));
197 aExport = tools::exportToSvgD( aPoly, true, true, false );
201
202 // Adaptions for B2DPolygon bezier change (see #i77162#):
203 //
204 // same here, the corrected export with the corrected B2DPolygon is simply more efficient,
205 // so i needed to change the compare string. Also adding the re-import comparison below.
206 const char* sExportString1 =
207 "m1917 1114c-89-189-233-284-430-284-167 0-306 91-419 273s-170 370-17"
208 "0 564c0 145 33 259 98 342 65 84 150 126 257 126q115.5 0 231-57s147-97 210-176 99-143 109-190c38-199 76-398 114"
209 "-598zm840 1646c-133 73-312 139-537 197-225 57-440 86-644 87-483-1-866-132-1150-392-284-261-426-619-426-1076 0-"
210 "292 67-560 200-803s321-433 562-569 514-204 821-204c405 0 739 125 1003 374 264 250 396 550 396 899 0 313-88 576"
211 "-265 787q-265.5 318-627 318c-191 0-308-94-352-281-133 187-315 281-546 281-172 0-315-67-428-200s-170-301-170-50"
212 "5c0-277 90-527 271-751 181-223 394-335 640-335 196 0 353 83 470 250 13-68 26-136 41-204q144 0 288 0c-74 376-14"
213 "8 752-224 1128-21 101-31 183-31 245 0 39 9 70 26 93 17 24 39 36 67 36 145 0 279-80 400-240s182-365 182-615c0-2"
214 "88-107-533-322-734s-487-301-816-301c-395 0-715 124-960 373s-368 569-368 958q0 577.5 357 900c237 216 557 324 95"
215 "8 325 189-1 389-27 600-77 211-52 378-110 503-174q40.5 105 81 210z";
198
199 // Adaptions for B2DPolygon bezier change (see #i77162#):
200 //
201 // same here, the corrected export with the corrected B2DPolygon is simply more efficient,
202 // so i needed to change the compare string. Also adding the re-import comparison below.
203 const char* sExportString1 =
204 "m1917 1114c-89-189-233-284-430-284-167 0-306 91-419 273s-170 370-17"
205 "0 564c0 145 33 259 98 342 65 84 150 126 257 126q115.5 0 231-57s147-97 210-176 99-143 109-190c38-199 76-398 114"
206 "-598zm840 1646c-133 73-312 139-537 197-225 57-440 86-644 87-483-1-866-132-1150-392-284-261-426-619-426-1076 0-"
207 "292 67-560 200-803s321-433 562-569 514-204 821-204c405 0 739 125 1003 374 264 250 396 550 396 899 0 313-88 576"
208 "-265 787q-265.5 318-627 318c-191 0-308-94-352-281-133 187-315 281-546 281-172 0-315-67-428-200s-170-301-170-50"
209 "5c0-277 90-527 271-751 181-223 394-335 640-335 196 0 353 83 470 250 13-68 26-136 41-204q144 0 288 0c-74 376-14"
210 "8 752-224 1128-21 101-31 183-31 245 0 39 9 70 26 93 17 24 39 36 67 36 145 0 279-80 400-240s182-365 182-615c0-2"
211 "88-107-533-322-734s-487-301-816-301c-395 0-715 124-960 373s-368 569-368 958q0 577.5 357 900c237 216 557 324 95"
212 "8 325 189-1 389-27 600-77 211-52 378-110 503-174q40.5 105 81 210z";
216 CPPUNIT_ASSERT_MESSAGE("re-importing '@' from SVG-D", tools::importFromSvgD( aReImport, aExport));
213 CPPUNIT_ASSERT_MESSAGE("re-importing '@' from SVG-D", tools::importFromSvgD( aReImport, aExport, false, 0));
217 CPPUNIT_ASSERT_MESSAGE("re-imported '@' needs to be identical", aReImport == aPoly);
218
219 CPPUNIT_ASSERT_MESSAGE("exporting '@' to SVG-D", !aExport.compareToAscii(sExportString1));
220 CPPUNIT_ASSERT_MESSAGE("importing '@' from SVG-D (round-trip",
214 CPPUNIT_ASSERT_MESSAGE("re-imported '@' needs to be identical", aReImport == aPoly);
215
216 CPPUNIT_ASSERT_MESSAGE("exporting '@' to SVG-D", !aExport.compareToAscii(sExportString1));
217 CPPUNIT_ASSERT_MESSAGE("importing '@' from SVG-D (round-trip",
221 tools::importFromSvgD( aPoly,
222 aExport ));
223 aExport = tools::exportToSvgD( aPoly );
218 tools::importFromSvgD( aPoly, aExport, false, 0 ));
219 aExport = tools::exportToSvgD( aPoly, true, true, false );
224 CPPUNIT_ASSERT_MESSAGE("exporting '@' to SVG-D (round-trip)",
225 !aExport.compareToAscii(sExportString1));
226
227
228 CPPUNIT_ASSERT_MESSAGE("importing complex polygon from SVG-D",
220 CPPUNIT_ASSERT_MESSAGE("exporting '@' to SVG-D (round-trip)",
221 !aExport.compareToAscii(sExportString1));
222
223
224 CPPUNIT_ASSERT_MESSAGE("importing complex polygon from SVG-D",
229 tools::importFromSvgD( aPoly,
230 aPath3 ));
231 aExport = tools::exportToSvgD( aPoly );
225 tools::importFromSvgD( aPoly, aPath3, false, 0 ));
226 aExport = tools::exportToSvgD( aPoly, true, true, false );
232 const char* sExportString2 =
233 "m1598 125h306v2334h-306v-1105h-1293v1105h-305v-2334h305v973h1293"
234 "zm2159 1015 78-44 85 235-91 47-91 40-90 34-90 29-89 21-88 16-88 10-88 3-102-4-97"
235 "-12-91-19-85-26-40-16-39-18-38-20-36-22-34-24-33-26-32-27-30-30-29-31-27-33-25-3"
236 "3-23-36-21-36-19-38-18-40-16-40-26-86-18-91-11-97-4-103 3-98 11-94 17-89 24-84 3"
237 "1-79 37-75 22-35 23-34 24-33 27-32 28-30 29-28 31-27 31-24 33-22 34-21 35-18 37-"
238 "17 38-14 38-13 41-11 41-8 86-12 91-4 82 4 78 10 37 9 37 9 36 12 35 14 33 15 33 1"
239 "7 32 19 31 21 30 22 30 25 55 54 26 29 24 31 22 32 21 33 19 34 18 36 30 74 23 80 "

--- 8 unchanged lines hidden (view full) ---

248 " 74-21 35-23 35-25 32-26 32-28 30-29 28-30 26-31 24-33 22-34 21-35 18-36 17-38 1"
249 "4-39 13-39 10-42 9-85 12-91 4-91-4-86-12-41-9-40-10-39-13-37-14-36-17-35-18-34-2"
250 "1-33-22-31-24-30-26-29-28-28-30-26-32-25-32-23-35-21-35-38-74-30-80-24-85-17-89-"
251 "11-95-3-100 3-101 11-95 17-90 24-85 30-79 38-75 21-35 23-35 25-32 26-32 28-30 29"
252 "-28 30-26 31-24 33-22 34-20 35-18 36-16 37-15 39-12 40-11z";
253 CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D",
254 !aExport.compareToAscii(sExportString2));
255 CPPUNIT_ASSERT_MESSAGE("importing complex polygon from SVG-D (round-trip",
227 const char* sExportString2 =
228 "m1598 125h306v2334h-306v-1105h-1293v1105h-305v-2334h305v973h1293"
229 "zm2159 1015 78-44 85 235-91 47-91 40-90 34-90 29-89 21-88 16-88 10-88 3-102-4-97"
230 "-12-91-19-85-26-40-16-39-18-38-20-36-22-34-24-33-26-32-27-30-30-29-31-27-33-25-3"
231 "3-23-36-21-36-19-38-18-40-16-40-26-86-18-91-11-97-4-103 3-98 11-94 17-89 24-84 3"
232 "1-79 37-75 22-35 23-34 24-33 27-32 28-30 29-28 31-27 31-24 33-22 34-21 35-18 37-"
233 "17 38-14 38-13 41-11 41-8 86-12 91-4 82 4 78 10 37 9 37 9 36 12 35 14 33 15 33 1"
234 "7 32 19 31 21 30 22 30 25 55 54 26 29 24 31 22 32 21 33 19 34 18 36 30 74 23 80 "

--- 8 unchanged lines hidden (view full) ---

243 " 74-21 35-23 35-25 32-26 32-28 30-29 28-30 26-31 24-33 22-34 21-35 18-36 17-38 1"
244 "4-39 13-39 10-42 9-85 12-91 4-91-4-86-12-41-9-40-10-39-13-37-14-36-17-35-18-34-2"
245 "1-33-22-31-24-30-26-29-28-28-30-26-32-25-32-23-35-21-35-38-74-30-80-24-85-17-89-"
246 "11-95-3-100 3-101 11-95 17-90 24-85 30-79 38-75 21-35 23-35 25-32 26-32 28-30 29"
247 "-28 30-26 31-24 33-22 34-20 35-18 36-16 37-15 39-12 40-11z";
248 CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D",
249 !aExport.compareToAscii(sExportString2));
250 CPPUNIT_ASSERT_MESSAGE("importing complex polygon from SVG-D (round-trip",
256 tools::importFromSvgD( aPoly,
257 aExport ));
258 aExport = tools::exportToSvgD( aPoly );
251 tools::importFromSvgD( aPoly, aExport, false, 0 ));
252 aExport = tools::exportToSvgD( aPoly, true, true, false );
259 CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D (round-trip)",
260 !aExport.compareToAscii(sExportString2));
261
262 const B2DPolygon aRect(
263 tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) ));
253 CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D (round-trip)",
254 !aExport.compareToAscii(sExportString2));
255
256 const B2DPolygon aRect(
257 tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) ));
264 aExport = tools::exportToSvgD( B2DPolyPolygon(aRect), false, false);
258 aExport = tools::exportToSvgD( B2DPolyPolygon(aRect), false, false, false );
265
266 const char* sExportStringRect = "M0 0H4000V4000H0Z";
267 CPPUNIT_ASSERT_MESSAGE("exporting to rectangle svg-d string",
268 !aExport.compareToAscii(sExportStringRect));
269 }
270
271 // Change the following lines only, if you add, remove or rename
272 // member functions of the current class,

--- 1187 unchanged lines hidden ---
259
260 const char* sExportStringRect = "M0 0H4000V4000H0Z";
261 CPPUNIT_ASSERT_MESSAGE("exporting to rectangle svg-d string",
262 !aExport.compareToAscii(sExportStringRect));
263 }
264
265 // Change the following lines only, if you add, remove or rename
266 // member functions of the current class,

--- 1187 unchanged lines hidden ---