1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include <sal/config.h>
13 #include <string_view>
15 #include <osl/endian.h>
16 #include <test/bootstrapfixture.hxx>
17 #include <test/xmltesttools.hxx>
18 #include <vcl/gdimtf.hxx>
19 #include <vcl/gradient.hxx>
20 #include <vcl/hatch.hxx>
21 #include <vcl/lineinfo.hxx>
22 #include <vcl/virdev.hxx>
23 #include <vcl/filter/PngImageWriter.hxx>
24 #include <tools/fract.hxx>
25 #include <vcl/metaact.hxx>
26 #include <vcl/filter/SvmReader.hxx>
27 #include <vcl/filter/SvmWriter.hxx>
28 #include <salhelper/simplereferenceobject.hxx>
29 #include <sal/log.hxx>
31 #include <vcl/BitmapWriteAccess.hxx>
33 #include <basegfx/polygon/b2dpolypolygon.hxx>
35 #include <config_features.h>
36 #include <config_cairo_rgba.h>
37 #include <config_fonts.h>
38 #include <vcl/skia/SkiaHelper.hxx>
42 class SvmTest
: public test::BootstrapFixture
, public XmlTestTools
46 OUString
getFullUrl(std::u16string_view sFileName
)
48 return m_directories
.getURLFromSrc(maDataUrl
) + sFileName
;
51 void checkRendering(ScopedVclPtrInstance
<VirtualDevice
> const & pVirtualDev
, const GDIMetaFile
& rMetaFile
, const char * where
);
53 // write GDI Metafile to a file in data directory
54 // only use this for new tests to create the svm file
55 void writeToFile(GDIMetaFile
& rMetaFile
, std::u16string_view rName
);
57 GDIMetaFile
writeAndReadStream(
58 GDIMetaFile
& rMetaFile
, std::u16string_view rName
= std::u16string_view());
60 GDIMetaFile
readFile(std::u16string_view sName
);
62 xmlDocUniquePtr
dumpMeta(const GDIMetaFile
& rMetaFile
);
64 void checkVirtualDevice(const xmlDocUniquePtr
& pDoc
);
65 void checkErase(const xmlDocUniquePtr
& pDoc
);
67 void checkPixel(const GDIMetaFile
& rMetaFile
);
70 void checkPoint(const GDIMetaFile
& rMetaFile
);
73 void checkLine(const GDIMetaFile
& rMetaFile
);
76 void checkRect(const GDIMetaFile
& rMetaFile
);
79 void checkRoundRect(const GDIMetaFile
& rMetaFile
);
82 void checkEllipse(const GDIMetaFile
& rMetaFile
);
85 void checkArc(const GDIMetaFile
& rMetaFile
);
88 void checkPie(const GDIMetaFile
& rMetaFile
);
91 void checkChord(const GDIMetaFile
& rMetaFile
);
94 void checkPolyLine(const GDIMetaFile
& rMetaFile
);
97 void checkPolygon(const GDIMetaFile
& rMetaFile
);
100 void checkPolyPolygon(const GDIMetaFile
& rMetaFile
);
101 void testPolyPolygon();
103 void checkText(const GDIMetaFile
& rMetaFile
);
106 void checkTextArray(const GDIMetaFile
& rMetaFile
);
107 void testTextArray();
109 void checkTextArrayWithContext(const GDIMetaFile
& rMetaFile
);
110 void testTextArrayWithContext();
112 void checkstretchText(const GDIMetaFile
& rMetaFile
);
113 void teststretchText();
115 void checkTextRect(const GDIMetaFile
& rMetaFile
);
118 void checkTextLine(const GDIMetaFile
& rMetaFile
);
121 void checkBitmaps(const GDIMetaFile
& rMetaFile
);
124 void checkBitmapExs(const GDIMetaFile
& rMetaFile
, bool bIsSvmFile
);
125 void testBitmapExs();
127 void checkMasks(const GDIMetaFile
& rMetaFile
);
130 void checkGradient(const GDIMetaFile
& rMetaFile
);
133 void checkGradientEx(const GDIMetaFile
& rMetaFile
);
134 void testGradientEx();
136 void checkHatch(const GDIMetaFile
& rMetaFile
);
139 void checkWallpaper(const GDIMetaFile
& rMetaFile
);
140 void testWallpaper();
142 void checkClipRegion(const GDIMetaFile
& rMetaFile
);
143 void testClipRegion();
145 void checkIntersectRectClipRegion(const GDIMetaFile
& rMetaFile
);
146 void testIntersectRectClipRegion();
148 void checkIntersectRegionClipRegion(const GDIMetaFile
& rMetaFile
);
149 void testIntersectRegionClipRegion();
151 void checkMoveClipRegion(const GDIMetaFile
& rMetaFile
);
152 void testMoveClipRegion();
154 void checkLineColor(const GDIMetaFile
& rMetaFile
);
155 void testLineColor();
157 void checkFillColor(const GDIMetaFile
& rMetaFile
);
158 void testFillColor();
160 void checkTextColor(const GDIMetaFile
& rMetaFile
);
161 void testTextColor();
163 void checkTextFillColor(const GDIMetaFile
& rMetaFile
);
164 void testTextFillColor();
166 void checkTextLineColor(const GDIMetaFile
& rMetaFile
);
167 void testTextLineColor();
169 void checkOverLineColor(const GDIMetaFile
& rMetaFile
);
170 void testOverLineColor();
172 void checkTextAlign(const GDIMetaFile
& rMetaFile
);
173 void testTextAlign();
175 void checkMapMode(const GDIMetaFile
& rMetaFile
);
178 #if HAVE_MORE_FONTS && !defined(_WIN32)
179 void checkFont(const GDIMetaFile
& rMetaFile
);
183 void checkPushPop(const GDIMetaFile
& rMetaFile
);
186 void checkRasterOp(const GDIMetaFile
& rMetaFile
);
189 void checkTransparent(const GDIMetaFile
& rMetaFile
);
190 void testTransparent();
192 void checkFloatTransparent(const GDIMetaFile
& rMetaFile
);
193 void testFloatTransparent();
195 void checkEPS(const GDIMetaFile
& rMetaFile
);
198 void checkRefPoint(const GDIMetaFile
& rMetaFile
);
201 void checkComment(const GDIMetaFile
& rMetaFile
);
204 void checkLayoutMode(const GDIMetaFile
& rMetaFile
);
205 void testLayoutMode();
207 void checkTextLanguage(const GDIMetaFile
& rMetaFile
);
208 void testTextLanguage();
212 : BootstrapFixture(true, false)
213 , maDataUrl(u
"/vcl/qa/cppunit/svm/data/"_ustr
)
216 CPPUNIT_TEST_SUITE(SvmTest
);
217 CPPUNIT_TEST(testPixel
);
218 CPPUNIT_TEST(testPoint
);
219 CPPUNIT_TEST(testLine
);
220 CPPUNIT_TEST(testRect
);
221 CPPUNIT_TEST(testRoundRect
);
222 CPPUNIT_TEST(testEllipse
);
223 CPPUNIT_TEST(testArc
);
224 CPPUNIT_TEST(testPie
);
225 CPPUNIT_TEST(testChord
);
226 CPPUNIT_TEST(testPolyLine
);
227 CPPUNIT_TEST(testPolygon
);
228 CPPUNIT_TEST(testPolyPolygon
);
229 CPPUNIT_TEST(testText
);
230 CPPUNIT_TEST(testTextArray
);
231 CPPUNIT_TEST(testTextArrayWithContext
);
232 CPPUNIT_TEST(teststretchText
);
233 CPPUNIT_TEST(testTextRect
);
234 CPPUNIT_TEST(testTextLine
);
235 CPPUNIT_TEST(testBitmaps
); // BMP, BMPSCALE, BMPSCALEPART
236 CPPUNIT_TEST(testBitmapExs
); // BMPEX, BMPEXSCALE, BMPEXSCALEPART
237 CPPUNIT_TEST(testMasks
); // MASK, MASKSCALE, MASKSCALEPART
238 CPPUNIT_TEST(testGradient
);
239 CPPUNIT_TEST(testGradientEx
);
240 CPPUNIT_TEST(testHatch
);
241 CPPUNIT_TEST(testWallpaper
);
242 CPPUNIT_TEST(testClipRegion
);
243 CPPUNIT_TEST(testIntersectRectClipRegion
);
244 CPPUNIT_TEST(testIntersectRegionClipRegion
);
245 CPPUNIT_TEST(testMoveClipRegion
);
246 CPPUNIT_TEST(testLineColor
);
247 CPPUNIT_TEST(testFillColor
);
248 CPPUNIT_TEST(testTextColor
);
249 CPPUNIT_TEST(testTextFillColor
);
250 CPPUNIT_TEST(testTextLineColor
);
251 CPPUNIT_TEST(testOverLineColor
);
252 CPPUNIT_TEST(testTextAlign
);
253 CPPUNIT_TEST(testMapMode
);
254 CPPUNIT_TEST(testFont
);
255 CPPUNIT_TEST(testPushPop
);
256 CPPUNIT_TEST(testRasterOp
);
257 CPPUNIT_TEST(testTransparent
);
258 CPPUNIT_TEST(testFloatTransparent
);
259 CPPUNIT_TEST(testEPS
);
260 CPPUNIT_TEST(testRefPoint
);
261 CPPUNIT_TEST(testComment
);
262 CPPUNIT_TEST(testLayoutMode
);
263 CPPUNIT_TEST(testTextLanguage
);
265 CPPUNIT_TEST_SUITE_END();
268 static void setupBaseVirtualDevice(VirtualDevice
& rDevice
, GDIMetaFile
& rMeta
)
270 rDevice
.SetConnectMetaFile(&rMeta
);
271 Size
aVDSize(10, 10);
272 rDevice
.SetOutputSizePixel(aVDSize
);
273 rDevice
.SetBackground(Wallpaper(COL_LIGHTRED
));
277 void SvmTest::checkRendering(ScopedVclPtrInstance
<VirtualDevice
> const & pVirtualDev
, const GDIMetaFile
& rMetaFile
, const char * where
)
279 BitmapEx aSourceBitmapEx
= pVirtualDev
->GetBitmapEx(Point(), Size(10, 10));
280 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDevResult
;
281 pVirtualDevResult
->SetOutputSizePixel(Size(10, 10));
282 const_cast<GDIMetaFile
&>(rMetaFile
).Play(*pVirtualDevResult
);
283 BitmapEx aResultBitmapEx
= pVirtualDevResult
->GetBitmapEx(Point(), Size(10, 10));
285 const bool bWriteCompareBitmap
= false;
287 if (bWriteCompareBitmap
)
289 utl::TempFileNamed aTempFile
;
290 aTempFile
.EnableKillingFile();
293 SvFileStream
aStream(aTempFile
.GetURL() + ".source.png", StreamMode::WRITE
| StreamMode::TRUNC
);
294 vcl::PngImageWriter
aPNGWriter(aStream
);
295 aPNGWriter
.write(aSourceBitmapEx
);
298 SvFileStream
aStream(aTempFile
.GetURL() + ".result.png", StreamMode::WRITE
| StreamMode::TRUNC
);
299 vcl::PngImageWriter
aPNGWriter(aStream
);
300 aPNGWriter
.write(aResultBitmapEx
);
303 CPPUNIT_ASSERT_EQUAL_MESSAGE(where
, aSourceBitmapEx
.GetChecksum(), aResultBitmapEx
.GetChecksum());
306 static GDIMetaFile
readMetafile(const OUString
& rUrl
)
308 GDIMetaFile aResultMetafile
;
309 SvFileStream
aFileStream(rUrl
, StreamMode::READ
);
310 aFileStream
.Seek(STREAM_SEEK_TO_BEGIN
);
311 SvmReader
aReader(aFileStream
);
312 aReader
.Read(aResultMetafile
);
313 return aResultMetafile
;
316 static void writeMetaFile(GDIMetaFile
& rInputMetafile
, const OUString
& rUrl
)
318 SvFileStream
aFileStream(rUrl
, StreamMode::WRITE
);
319 aFileStream
.Seek(STREAM_SEEK_TO_BEGIN
);
320 SvmWriter
aWriter(aFileStream
);
321 aWriter
.Write(rInputMetafile
);
325 void SvmTest::writeToFile(GDIMetaFile
& rMetaFile
, std::u16string_view rName
)
329 OUString sFilePath
= getFullUrl(rName
);
330 writeMetaFile(rMetaFile
, sFilePath
);
333 GDIMetaFile
SvmTest::writeAndReadStream(GDIMetaFile
& rMetaFile
, std::u16string_view rName
)
336 writeToFile(rMetaFile
, rName
);
338 SvMemoryStream aStream
;
339 SvmWriter
aWriter(aStream
);
340 aWriter
.Write(rMetaFile
);
341 aStream
.Seek(STREAM_SEEK_TO_BEGIN
);
343 GDIMetaFile aResultMetafile
;
344 SvmReader
aReader(aStream
);
345 aResultMetafile
.Clear();
346 aReader
.Read(aResultMetafile
);
347 return aResultMetafile
;
350 GDIMetaFile
SvmTest::readFile(std::u16string_view sName
)
352 OUString sFilePath
= getFullUrl(sName
);
353 return readMetafile(sFilePath
);
356 xmlDocUniquePtr
SvmTest::dumpMeta(const GDIMetaFile
& rMetaFile
)
358 MetafileXmlDump dumper
;
359 xmlDocUniquePtr pDoc
= dumpAndParse(dumper
, rMetaFile
);
360 CPPUNIT_ASSERT (pDoc
);
362 checkVirtualDevice(pDoc
);
368 void SvmTest::checkVirtualDevice(const xmlDocUniquePtr
& pDoc
)
370 assertXPath(pDoc
, "/metafile/linecolor[1]", "color", u
"#000000");
371 assertXPath(pDoc
, "/metafile/fillcolor[1]", "color", u
"#ffffff");
373 assertXPathAttrs(pDoc
, "/metafile/rect[1]", {
374 {"left", u
"0"}, {"top", u
"0"},
375 {"right", u
"9"}, {"bottom", u
"9"}
378 assertXPath(pDoc
, "/metafile/linecolor[2]", "color", u
"#000000");
379 assertXPath(pDoc
, "/metafile/fillcolor[2]", "color", u
"#ffffff");
382 void SvmTest::checkErase(const xmlDocUniquePtr
& pDoc
)
384 assertXPath(pDoc
, "/metafile/linecolor[3]", "color", u
"#000000");
385 assertXPath(pDoc
, "/metafile/fillcolor[3]", "color", u
"#ff0000");
387 assertXPathAttrs(pDoc
, "/metafile/rect[2]", {
388 {"left", u
"0"}, {"top", u
"0"},
389 {"right", u
"9"}, {"bottom", u
"9"}
393 void SvmTest::checkPixel(const GDIMetaFile
& rMetaFile
)
395 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
397 assertXPathAttrs(pDoc
, "/metafile/pixel[1]", {
398 {"x", u
"8"}, {"y", u
"1"}, {"color", u
"#008000"},
401 assertXPathAttrs(pDoc
, "/metafile/pixel[2]", {
402 {"x", u
"1"}, {"y", u
"8"}, {"color", u
"#000080"},
406 void SvmTest::testPixel()
408 GDIMetaFile aGDIMetaFile
;
409 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
410 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
412 pVirtualDev
->DrawPixel(Point(8, 1), COL_GREEN
);
413 pVirtualDev
->DrawPixel(Point(1, 8), COL_BLUE
);
415 checkPixel(writeAndReadStream(aGDIMetaFile
));
416 checkPixel(readFile(u
"pixel.svm"));
419 void SvmTest::checkPoint(const GDIMetaFile
& rMetaFile
)
421 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
423 assertXPathAttrs(pDoc
, "/metafile/point[1]", {
424 {"x", u
"4"}, {"y", u
"4"}
428 void SvmTest::testPoint()
430 GDIMetaFile aGDIMetaFile
;
431 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
432 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
434 pVirtualDev
->DrawPixel(Point(4, 4));
436 checkPoint(writeAndReadStream(aGDIMetaFile
));
437 checkPoint(readFile(u
"point.svm"));
440 void SvmTest::checkLine(const GDIMetaFile
& rMetaFile
)
442 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
444 assertXPathAttrs(pDoc
, "/metafile/line[1]", {
445 {"startx", u
"1"}, {"starty", u
"1"},
446 {"endx", u
"8"}, {"endy", u
"8"},
449 assertXPathAttrs(pDoc
, "/metafile/line[1]", {
450 {"style", u
"solid"}, {"width", u
"0"},
451 {"dashlen", u
"0"}, {"dashcount", u
"0"},
452 {"dotlen", u
"0"}, {"dotcount", u
"0"},
454 {"join", u
"round"}, {"cap", u
"butt"}
457 assertXPathAttrs(pDoc
, "/metafile/line[2]", {
458 {"startx", u
"1"}, {"starty", u
"8"},
459 {"endx", u
"8"}, {"endy", u
"1"},
462 assertXPathAttrs(pDoc
, "/metafile/line[2]", {
463 {"style", u
"dash"}, {"width", u
"7"},
464 {"dashlen", u
"5"}, {"dashcount", u
"4"},
465 {"dotlen", u
"3"}, {"dotcount", u
"2"},
467 {"join", u
"miter"}, {"cap", u
"round"}
471 void SvmTest::testLine()
473 GDIMetaFile aGDIMetaFile
;
474 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
475 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
477 pVirtualDev
->DrawLine(Point(1, 1), Point(8, 8));
478 LineInfo
aLineInfo(LineStyle::Dash
, 7);
479 aLineInfo
.SetDashLen(5);
480 aLineInfo
.SetDashCount(4);
481 aLineInfo
.SetDotLen(3);
482 aLineInfo
.SetDotCount(2);
483 aLineInfo
.SetDistance(1);
484 aLineInfo
.SetLineJoin(basegfx::B2DLineJoin::Miter
);
485 aLineInfo
.SetLineCap(css::drawing::LineCap_ROUND
);
486 pVirtualDev
->DrawLine(Point(1, 8), Point(8, 1), aLineInfo
);
488 checkLine(writeAndReadStream(aGDIMetaFile
));
489 checkLine(readFile(u
"line.svm"));
492 void SvmTest::checkRect(const GDIMetaFile
& rMetaFile
)
495 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
497 assertXPath(pDoc
, "/metafile/linecolor[5]", "color", u
"#123456");
498 assertXPath(pDoc
, "/metafile/fillcolor[5]", "color", u
"#654321");
500 assertXPathAttrs(pDoc
, "/metafile/rect[3]", {
501 {"left", u
"1"}, {"top", u
"2"},
502 {"right", u
"4"}, {"bottom", u
"5"},
506 void SvmTest::testRect()
508 GDIMetaFile aGDIMetaFile
;
509 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
510 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
512 pVirtualDev
->SetLineColor(Color(0x123456));
513 pVirtualDev
->SetFillColor(Color(0x654321));
515 pVirtualDev
->DrawRect(tools::Rectangle(Point(1, 2), Size(4, 4)));
517 checkRect(writeAndReadStream(aGDIMetaFile
));
518 checkRect(readFile(u
"rect.svm"));
521 void SvmTest::checkRoundRect(const GDIMetaFile
& rMetaFile
)
523 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
525 assertXPath(pDoc
, "/metafile/linecolor[5]", "color", u
"#123456");
526 assertXPath(pDoc
, "/metafile/fillcolor[5]", "color", u
"#654321");
528 assertXPathAttrs(pDoc
, "/metafile/roundrect[1]", {
529 {"left", u
"1"}, {"top", u
"2"},
530 {"right", u
"4"}, {"bottom", u
"5"},
531 {"horizontalround", u
"1"}, {"verticalround", u
"2"}
535 void SvmTest::testRoundRect()
537 GDIMetaFile aGDIMetaFile
;
538 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
539 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
541 pVirtualDev
->SetLineColor(Color(0x123456));
542 pVirtualDev
->SetFillColor(Color(0x654321));
544 pVirtualDev
->DrawRect(tools::Rectangle(Point(1, 2), Size(4, 4)), 1, 2);
546 checkRoundRect(writeAndReadStream(aGDIMetaFile
));
547 checkRoundRect(readFile(u
"roundrect.svm"));
550 void SvmTest::checkEllipse(const GDIMetaFile
& rMetaFile
)
552 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
554 assertXPath(pDoc
, "/metafile/linecolor[5]", "color", u
"#123456");
555 assertXPath(pDoc
, "/metafile/fillcolor[5]", "color", u
"#654321");
557 assertXPathAttrs(pDoc
, "/metafile/ellipse[1]", {
558 {"left", u
"1"}, {"top", u
"2"},
559 {"right", u
"4"}, {"bottom", u
"5"},
563 void SvmTest::testEllipse()
565 GDIMetaFile aGDIMetaFile
;
566 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
567 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
569 pVirtualDev
->SetLineColor(Color(0x123456));
570 pVirtualDev
->SetFillColor(Color(0x654321));
572 pVirtualDev
->DrawEllipse(tools::Rectangle(Point(1, 2), Size(4, 4)));
574 checkEllipse(writeAndReadStream(aGDIMetaFile
));
575 checkEllipse(readFile(u
"ellipse.svm"));
578 void SvmTest::checkArc(const GDIMetaFile
& rMetaFile
)
580 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
582 assertXPath(pDoc
, "/metafile/linecolor[5]", "color", u
"#123456");
583 assertXPath(pDoc
, "/metafile/fillcolor[5]", "color", u
"#654321");
585 assertXPathAttrs(pDoc
, "/metafile/arc[1]", {
586 {"left", u
"1"}, {"top", u
"2"},
587 {"right", u
"4"}, {"bottom", u
"5"},
589 {"startx", u
"10"}, {"starty", u
"11"},
590 {"endx", u
"12"}, {"endy", u
"13"},
594 void SvmTest::testArc()
596 GDIMetaFile aGDIMetaFile
;
597 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
598 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
600 pVirtualDev
->SetLineColor(Color(0x123456));
601 pVirtualDev
->SetFillColor(Color(0x654321));
603 pVirtualDev
->DrawArc(tools::Rectangle(Point(1, 2), Size(4, 4)), Point(10, 11), Point(12, 13));
605 checkArc(writeAndReadStream(aGDIMetaFile
));
606 checkArc(readFile(u
"arc.svm"));
609 void SvmTest::checkPie(const GDIMetaFile
& rMetaFile
)
611 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
613 assertXPath(pDoc
, "/metafile/linecolor[5]", "color", u
"#123456");
614 assertXPath(pDoc
, "/metafile/fillcolor[5]", "color", u
"#654321");
616 assertXPathAttrs(pDoc
, "/metafile/pie[1]", {
617 {"left", u
"11"}, {"top", u
"12"},
618 {"right", u
"14"}, {"bottom", u
"15"},
620 {"startx", u
"20"}, {"starty", u
"21"},
621 {"endx", u
"22"}, {"endy", u
"23"},
625 void SvmTest::testPie()
627 GDIMetaFile aGDIMetaFile
;
628 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
629 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
631 pVirtualDev
->SetLineColor(Color(0x123456));
632 pVirtualDev
->SetFillColor(Color(0x654321));
634 pVirtualDev
->DrawPie(tools::Rectangle(Point(11, 12), Size(4, 4)), Point(20, 21), Point(22, 23));
636 checkPie(writeAndReadStream(aGDIMetaFile
));
637 checkPie(readFile(u
"pie.svm"));
640 void SvmTest::checkChord(const GDIMetaFile
& rMetaFile
)
642 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
644 assertXPath(pDoc
, "/metafile/linecolor[5]", "color", u
"#123456");
645 assertXPath(pDoc
, "/metafile/fillcolor[5]", "color", u
"#654321");
647 assertXPathAttrs(pDoc
, "/metafile/chord[1]", {
648 {"left", u
"21"}, {"top", u
"22"},
649 {"right", u
"24"}, {"bottom", u
"25"},
651 {"startx", u
"30"}, {"starty", u
"31"},
652 {"endx", u
"32"}, {"endy", u
"33"},
656 void SvmTest::testChord()
658 GDIMetaFile aGDIMetaFile
;
659 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
660 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
662 pVirtualDev
->SetLineColor(Color(0x123456));
663 pVirtualDev
->SetFillColor(Color(0x654321));
665 pVirtualDev
->DrawChord(tools::Rectangle(Point(21, 22), Size(4, 4)), Point(30, 31), Point(32, 33));
667 checkChord(writeAndReadStream(aGDIMetaFile
));
668 checkChord(readFile(u
"chord.svm"));
671 void SvmTest::checkPolyLine(const GDIMetaFile
& rMetaFile
)
673 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
675 assertXPathAttrs(pDoc
, "/metafile/polyline[1]", {
676 {"style", u
"solid"}, {"width", u
"0"},
677 {"dashlen", u
"0"}, {"dashcount", u
"0"},
678 {"dotlen", u
"0"}, {"dotcount", u
"0"},
680 {"join", u
"round"}, {"cap", u
"butt"}
683 assertXPathAttrs(pDoc
, "/metafile/polyline[1]/point[1]", {{"x", u
"1"}, {"y", u
"8"}});
684 assertXPathAttrs(pDoc
, "/metafile/polyline[1]/point[2]", {{"x", u
"2"}, {"y", u
"7"}});
685 assertXPathAttrs(pDoc
, "/metafile/polyline[1]/point[3]", {{"x", u
"3"}, {"y", u
"6"}});
687 assertXPathAttrs(pDoc
, "/metafile/polyline[2]", {
688 {"style", u
"dash"}, {"width", u
"7"},
689 {"dashlen", u
"5"}, {"dashcount", u
"4"},
690 {"dotlen", u
"3"}, {"dotcount", u
"2"},
692 {"join", u
"miter"}, {"cap", u
"round"}
694 assertXPathAttrs(pDoc
, "/metafile/polyline[2]/point[1]", {{"x", u
"8"}, {"y", u
"1"}, {"flags", u
"normal"}});
695 assertXPathAttrs(pDoc
, "/metafile/polyline[2]/point[2]", {{"x", u
"7"}, {"y", u
"2"}, {"flags", u
"control"}});
696 assertXPathAttrs(pDoc
, "/metafile/polyline[2]/point[3]", {{"x", u
"6"}, {"y", u
"3"}, {"flags", u
"smooth"}});
697 assertXPathAttrs(pDoc
, "/metafile/polyline[2]/point[4]", {{"x", u
"5"}, {"y", u
"4"}, {"flags", u
"symmetric"}});
700 void SvmTest::testPolyLine()
702 GDIMetaFile aGDIMetaFile
;
703 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
704 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
706 tools::Polygon
aPolygon(3);
707 aPolygon
.SetPoint(Point(1, 8), 0);
708 aPolygon
.SetPoint(Point(2, 7), 1);
709 aPolygon
.SetPoint(Point(3, 6), 2);
711 pVirtualDev
->DrawPolyLine(aPolygon
);
713 tools::Polygon
aPolygonWithControl(4);
714 aPolygonWithControl
.SetPoint(Point(8, 1), 0);
715 aPolygonWithControl
.SetPoint(Point(7, 2), 1);
716 aPolygonWithControl
.SetPoint(Point(6, 3), 2);
717 aPolygonWithControl
.SetPoint(Point(5, 4), 3);
719 aPolygonWithControl
.SetFlags(0, PolyFlags::Normal
);
720 aPolygonWithControl
.SetFlags(1, PolyFlags::Control
);
721 aPolygonWithControl
.SetFlags(2, PolyFlags::Smooth
);
722 aPolygonWithControl
.SetFlags(3, PolyFlags::Symmetric
);
724 LineInfo
aLineInfo(LineStyle::Dash
, 7);
725 aLineInfo
.SetDashLen(5);
726 aLineInfo
.SetDashCount(4);
727 aLineInfo
.SetDotLen(3);
728 aLineInfo
.SetDotCount(2);
729 aLineInfo
.SetDistance(1);
730 aLineInfo
.SetLineJoin(basegfx::B2DLineJoin::Miter
);
731 aLineInfo
.SetLineCap(css::drawing::LineCap_ROUND
);
733 pVirtualDev
->DrawPolyLine(aPolygonWithControl
, aLineInfo
);
735 checkPolyLine(writeAndReadStream(aGDIMetaFile
));
736 checkPolyLine(readFile(u
"polyline.svm"));
739 void SvmTest::checkPolygon(const GDIMetaFile
& rMetaFile
)
741 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
743 assertXPathAttrs(pDoc
, "/metafile/polygon[1]/point[1]", {{"x", u
"1"}, {"y", u
"8"}});
744 assertXPathAttrs(pDoc
, "/metafile/polygon[1]/point[2]", {{"x", u
"2"}, {"y", u
"7"}});
745 assertXPathAttrs(pDoc
, "/metafile/polygon[1]/point[3]", {{"x", u
"3"}, {"y", u
"6"}});
747 assertXPathAttrs(pDoc
, "/metafile/polygon[2]/point[1]", {{"x", u
"8"}, {"y", u
"1"}, {"flags", u
"normal"}});
748 assertXPathAttrs(pDoc
, "/metafile/polygon[2]/point[2]", {{"x", u
"7"}, {"y", u
"2"}, {"flags", u
"control"}});
749 assertXPathAttrs(pDoc
, "/metafile/polygon[2]/point[3]", {{"x", u
"6"}, {"y", u
"3"}, {"flags", u
"smooth"}});
750 assertXPathAttrs(pDoc
, "/metafile/polygon[2]/point[4]", {{"x", u
"5"}, {"y", u
"4"}, {"flags", u
"symmetric"}});
753 void SvmTest::testPolygon()
755 GDIMetaFile aGDIMetaFile
;
756 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
757 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
759 tools::Polygon
aPolygon(3);
760 aPolygon
.SetPoint(Point(1, 8), 0);
761 aPolygon
.SetPoint(Point(2, 7), 1);
762 aPolygon
.SetPoint(Point(3, 6), 2);
764 pVirtualDev
->DrawPolygon(aPolygon
);
766 tools::Polygon
aPolygonWithControl(4);
767 aPolygonWithControl
.SetPoint(Point(8, 1), 0);
768 aPolygonWithControl
.SetPoint(Point(7, 2), 1);
769 aPolygonWithControl
.SetPoint(Point(6, 3), 2);
770 aPolygonWithControl
.SetPoint(Point(5, 4), 3);
772 aPolygonWithControl
.SetFlags(0, PolyFlags::Normal
);
773 aPolygonWithControl
.SetFlags(1, PolyFlags::Control
);
774 aPolygonWithControl
.SetFlags(2, PolyFlags::Smooth
);
775 aPolygonWithControl
.SetFlags(3, PolyFlags::Symmetric
);
777 pVirtualDev
->DrawPolygon(aPolygonWithControl
);
779 checkPolygon(writeAndReadStream(aGDIMetaFile
));
780 checkPolygon(readFile(u
"polygon.svm"));
783 void SvmTest::checkPolyPolygon(const GDIMetaFile
& rMetaFile
)
785 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
787 assertXPathAttrs(pDoc
, "/metafile/polypolygon[1]/polygon[1]/point[1]", {{"x", u
"1"}, {"y", u
"8"}});
788 assertXPathAttrs(pDoc
, "/metafile/polypolygon[1]/polygon[1]/point[2]", {{"x", u
"2"}, {"y", u
"7"}});
789 assertXPathAttrs(pDoc
, "/metafile/polypolygon[1]/polygon[1]/point[3]", {{"x", u
"3"}, {"y", u
"6"}});
791 assertXPathAttrs(pDoc
, "/metafile/polypolygon[1]/polygon[2]/point[1]", {{"x", u
"8"}, {"y", u
"1"}, {"flags", u
"normal"}});
792 assertXPathAttrs(pDoc
, "/metafile/polypolygon[1]/polygon[2]/point[2]", {{"x", u
"7"}, {"y", u
"2"}, {"flags", u
"control"}});
793 assertXPathAttrs(pDoc
, "/metafile/polypolygon[1]/polygon[2]/point[3]", {{"x", u
"6"}, {"y", u
"3"}, {"flags", u
"smooth"}});
794 assertXPathAttrs(pDoc
, "/metafile/polypolygon[1]/polygon[2]/point[4]", {{"x", u
"5"}, {"y", u
"4"}, {"flags", u
"symmetric"}});
797 void SvmTest::testPolyPolygon()
799 GDIMetaFile aGDIMetaFile
;
800 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
801 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
803 tools::Polygon
aPolygon(3);
804 aPolygon
.SetPoint(Point(1, 8), 0);
805 aPolygon
.SetPoint(Point(2, 7), 1);
806 aPolygon
.SetPoint(Point(3, 6), 2);
808 tools::Polygon
aPolygonWithControl(4);
809 aPolygonWithControl
.SetPoint(Point(8, 1), 0);
810 aPolygonWithControl
.SetPoint(Point(7, 2), 1);
811 aPolygonWithControl
.SetPoint(Point(6, 3), 2);
812 aPolygonWithControl
.SetPoint(Point(5, 4), 3);
814 aPolygonWithControl
.SetFlags(0, PolyFlags::Normal
);
815 aPolygonWithControl
.SetFlags(1, PolyFlags::Control
);
816 aPolygonWithControl
.SetFlags(2, PolyFlags::Smooth
);
817 aPolygonWithControl
.SetFlags(3, PolyFlags::Symmetric
);
819 tools::PolyPolygon
aPolyPolygon(2);
820 aPolyPolygon
.Insert(aPolygon
);
821 aPolyPolygon
.Insert(aPolygonWithControl
);
823 pVirtualDev
->DrawPolyPolygon(aPolyPolygon
);
825 checkPolyPolygon(writeAndReadStream(aGDIMetaFile
));
826 checkPolyPolygon(readFile(u
"polypolygon.svm"));
829 void SvmTest::checkText(const GDIMetaFile
& rMetaFile
)
831 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
833 assertXPathAttrs(pDoc
, "/metafile/text[1]", {
834 {"x", u
"4"}, {"y", u
"6"}, {"index", u
"1"}, {"length", u
"2"},
837 assertXPathContent(pDoc
, "/metafile/text[1]/textcontent", u
"xABC");
840 void SvmTest::testText()
842 GDIMetaFile aGDIMetaFile
;
843 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
844 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
846 pVirtualDev
->DrawText(Point(4,6), u
"xABC"_ustr
, 1, 2);
848 checkText(writeAndReadStream(aGDIMetaFile
));
849 checkText(readFile(u
"text.svm"));
852 void SvmTest::checkTextArray(const GDIMetaFile
& rMetaFile
)
854 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
856 assertXPathAttrs(pDoc
, "/metafile/textarray[1]", {
857 {"x", u
"4"}, {"y", u
"6"}, {"index", u
"1"}, {"length", u
"4"},
859 assertXPathContent(pDoc
, "/metafile/textarray[1]/dxarray", u
"15 20 25 ");
860 assertXPathContent(pDoc
, "/metafile/textarray[1]/text", u
"123456");
863 void SvmTest::testTextArray()
865 GDIMetaFile aGDIMetaFile
;
866 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
867 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
868 KernArray aDX
{ 10, 15, 20, 25, 30, 35 };
869 pVirtualDev
->DrawTextArray(Point(4,6), u
"123456"_ustr
, aDX
, {}, 1, 4);
871 checkTextArray(writeAndReadStream(aGDIMetaFile
));
872 checkTextArray(readFile(u
"textarray.svm"));
875 void SvmTest::checkTextArrayWithContext(const GDIMetaFile
& rMetaFile
)
877 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
879 assertXPathAttrs(pDoc
, "/metafile/textarray[1]",
884 { "layoutcontextindex", u
"0" },
885 { "layoutcontextlength", u
"5" } });
886 assertXPathContent(pDoc
, "/metafile/textarray[1]/dxarray", u
"15 20 25 ");
887 assertXPathContent(pDoc
, "/metafile/textarray[1]/text", u
"123456");
890 void SvmTest::testTextArrayWithContext()
892 GDIMetaFile aGDIMetaFile
;
893 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
894 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
895 KernArray aDX
{ 10, 15, 20, 25, 30, 35 };
896 pVirtualDev
->DrawPartialTextArray(Point(4, 6), u
"123456"_ustr
, aDX
, {}, 0, 5, 1, 4);
898 checkTextArrayWithContext(writeAndReadStream(aGDIMetaFile
));
899 checkTextArrayWithContext(readFile(u
"textarraycontext.svm"));
902 void SvmTest::checkstretchText(const GDIMetaFile
& rMetaFile
)
904 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
906 assertXPathAttrs(pDoc
, "/metafile/stretchtext[1]", {
907 {"x", u
"4"}, {"y", u
"6"}, {"index", u
"1"}, {"length", u
"4"}, {"width", u
"10"}
910 assertXPathContent(pDoc
, "/metafile/stretchtext[1]/textcontent", u
"123456");
913 void SvmTest::teststretchText()
915 GDIMetaFile aGDIMetaFile
;
916 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
917 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
918 pVirtualDev
->DrawStretchText(Point(4,6), 10, u
"123456"_ustr
, 1, 4);
920 checkstretchText(writeAndReadStream(aGDIMetaFile
));
921 checkstretchText(readFile(u
"strecthtext.svm"));
924 void SvmTest::checkTextRect(const GDIMetaFile
& rMetaFile
)
926 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
928 assertXPathAttrs(pDoc
, "/metafile/textrect[1]", {
929 {"left", u
"0"}, {"top", u
"0"}, {"right", u
"4"}, {"bottom", u
"4"}
931 assertXPathContent(pDoc
, "/metafile/textrect[1]/textcontent", u
"123456");
932 assertXPathContent(pDoc
, "/metafile/textrect[1]/style", u
"Center");
935 void SvmTest::testTextRect()
937 GDIMetaFile aGDIMetaFile
;
938 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
939 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
940 pVirtualDev
->DrawText(tools::Rectangle(Point(0,0), Size(5,5)), u
"123456"_ustr
, DrawTextFlags::Center
);
942 checkTextRect(writeAndReadStream(aGDIMetaFile
));
943 checkTextRect(readFile(u
"textrectangle.svm"));
946 void SvmTest::checkTextLine(const GDIMetaFile
& rMetaFile
)
948 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
950 assertXPathAttrs(pDoc
, "/metafile/textline[1]", {
951 {"x", u
"4"}, {"y", u
"6"}, {"width", u
"10"},
952 {"strikeout", u
"single"}, {"underline", u
"single"}, {"overline", u
"single"}
956 void SvmTest::testTextLine()
958 GDIMetaFile aGDIMetaFile
;
959 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
960 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
961 pVirtualDev
->DrawTextLine(Point(4,6), 10, STRIKEOUT_SINGLE
, LINESTYLE_SINGLE
, LINESTYLE_SINGLE
);
963 checkTextLine(writeAndReadStream(aGDIMetaFile
));
964 checkTextLine(readFile(u
"textline.svm"));
967 void SvmTest::checkBitmaps(const GDIMetaFile
& rMetaFile
)
969 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
971 if (SkiaHelper::isVCLSkiaEnabled())
972 return; // TODO SKIA using CRCs is broken (the idea of it)
974 assertXPathAttrs(pDoc
, "/metafile/bmp[1]", {{"x", u
"1"}, {"y", u
"2"}, {"crc",
975 #if defined OSL_BIGENDIAN
978 #if !ENABLE_CAIRO_RGBA
979 u
"469f0820" // typical BGRA little-endian config
981 u
"3789377b" // atypical RGBA little-endian config
985 assertXPathAttrs(pDoc
, "/metafile/bmpscale[1]", {
986 {"x", u
"1"}, {"y", u
"2"}, {"width", u
"3"}, {"height", u
"4"}, {"crc", u
"4937e32d"}
988 assertXPathAttrs(pDoc
, "/metafile/bmpscalepart[1]", {
989 {"destx", u
"1"}, {"desty", u
"2"}, {"destwidth", u
"3"}, {"destheight", u
"4"},
990 {"srcx", u
"2"}, {"srcy", u
"1"}, {"srcwidth", u
"4"}, {"srcheight", u
"3"},
992 #if defined OSL_BIGENDIAN
995 #if !ENABLE_CAIRO_RGBA
996 u
"3789377b" // typical BGRA little-endian config
998 u
"469f0820" // atypical RGBA little-endian config
1005 void SvmTest::testBitmaps()
1007 GDIMetaFile aGDIMetaFile
;
1008 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1009 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1011 Bitmap
aBitmap1(Size(4,4), vcl::PixelFormat::N24_BPP
);
1013 BitmapScopedWriteAccess
pAccess(aBitmap1
);
1014 pAccess
->Erase(COL_RED
);
1016 Bitmap
aBitmap2(Size(4,4), vcl::PixelFormat::N24_BPP
);
1018 BitmapScopedWriteAccess
pAccess(aBitmap2
);
1019 pAccess
->Erase(COL_GREEN
);
1021 Bitmap
aBitmap3(Size(4,4), vcl::PixelFormat::N24_BPP
);
1023 BitmapScopedWriteAccess
pAccess(aBitmap3
);
1024 pAccess
->Erase(COL_BLUE
);
1026 pVirtualDev
->DrawBitmap(Point(1, 2), aBitmap1
);
1027 pVirtualDev
->DrawBitmap(Point(1, 2), Size(3, 4), aBitmap2
);
1028 pVirtualDev
->DrawBitmap(Point(1, 2), Size(3, 4), Point(2, 1), Size(4, 3), aBitmap3
);
1031 GDIMetaFile aReloadedGDIMetaFile
= writeAndReadStream(aGDIMetaFile
);
1032 checkBitmaps(aReloadedGDIMetaFile
);
1033 checkRendering(pVirtualDev
, aReloadedGDIMetaFile
, SAL_WHERE
);
1036 GDIMetaFile aFileGDIMetaFile
= readFile(u
"bitmaps.svm");
1037 checkBitmaps(aFileGDIMetaFile
);
1038 checkRendering(pVirtualDev
, aFileGDIMetaFile
, SAL_WHERE
);
1042 void SvmTest::checkBitmapExs(const GDIMetaFile
& rMetaFile
, bool bIsSvmFile
)
1044 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1046 if (SkiaHelper::isVCLSkiaEnabled())
1047 return; // TODO SKIA using CRCs is broken (the idea of it)
1049 static const std::vector
<std::u16string_view
> aExpectedCRC
1051 #if defined OSL_BIGENDIAN
1056 u
"186ff868", // 1-bit
1057 u
"33b4a07c", // 4-bit color bitmap - same as 8-bit color bitmap
1061 #if !ENABLE_CAIRO_RGBA
1062 u
"ac936607", // typical BGRA little-endian config
1064 "ecd75a28", // atypical RGBA little-endian config
1067 #if !ENABLE_CAIRO_RGBA
1068 u
"3789377b", // typical BGRA little-endian config
1070 "469f0820", // atypical RGBA little-endian config
1073 u
"236aaf55", // 1-bit
1074 u
"2949ccc7", // 4-bit color bitmap - same as 8-bit color bitmap
1080 static const std::array
<std::u16string_view
, 8> aExpectedContentChecksum
1082 u
"26bdebd04e5b18d685cea04982179e273ee3b659",
1083 u
"f4f52df6ef965a2f0fbccbe6aca35ba3457cf9d5",
1084 u
"7c953a06d34bbd38897f950d595df2880dbb0f75",
1085 u
"ca3e5cdde1c395e1ee76d339a5bf6e46fbac3249",
1086 u
"8a1ebc46f890eb0879464c6e293bffd4ce7fadc0", // 1-bit
1087 u
"23611fc9f484c23e45bbd457730adb8ab5355509", // 4-bit color bitmap - same as 8-bit color bitmap
1088 u
"23611fc9f484c23e45bbd457730adb8ab5355509",
1089 u
"97e499b74104debf12f99a774a2c4edc914d8900",
1092 assertXPathAttrs(pDoc
, "/metafile/bmpex[1]", {
1093 {"x", u
"1"}, {"y", u
"1"}, {"crc", aExpectedCRC
[0]}, {"transparenttype", u
"bitmap"}, {"contentchecksum", aExpectedContentChecksum
[0]}, {"pixelformat", u
"24BPP"}
1095 assertXPathAttrs(pDoc
, "/metafile/bmpexscale[1]", {
1096 {"x", u
"5"}, {"y", u
"0"}, {"width", u
"2"}, {"height", u
"3"},
1097 {"crc", aExpectedCRC
[1]}, {"transparenttype", u
"bitmap"}, {"contentchecksum", aExpectedContentChecksum
[1]}, {"pixelformat", u
"24BPP"}
1099 assertXPathAttrs(pDoc
, "/metafile/bmpexscalepart[1]", {
1100 {"destx", u
"7"}, {"desty", u
"1"}, {"destwidth", u
"2"}, {"destheight", u
"2"},
1101 {"srcx", u
"0"}, {"srcy", u
"0"}, {"srcwidth", u
"3"}, {"srcheight", u
"4"},
1102 {"crc", aExpectedCRC
[2]}, {"transparenttype", u
"bitmap"}, {"contentchecksum", aExpectedContentChecksum
[2]}, {"pixelformat", u
"24BPP"}
1106 assertXPathAttrs(pDoc
, "/metafile/bmpex[2]", {
1107 {"x", u
"6"}, {"y", u
"6"}, {"crc", aExpectedCRC
[3]}, {"transparenttype", u
"bitmap"}, {"contentchecksum", aExpectedContentChecksum
[3]}
1109 assertXPathAttrs(pDoc
, "/metafile/bmpex[3]", {
1110 {"x", u
"0"}, {"y", u
"6"}, {"transparenttype", u
"bitmap"}, {"contentchecksum", aExpectedContentChecksum
[4]}, {"pixelformat", u
"8BPP"}
1114 assertXPathAttrs(pDoc
, "/metafile/bmpex[3]", {
1115 {"crc", aExpectedCRC
[4]}
1118 assertXPathAttrs(pDoc
, "/metafile/bmpex[4]", {
1119 {"x", u
"2"}, {"y", u
"6"}, {"crc", aExpectedCRC
[5]}, {"transparenttype", u
"bitmap"}, {"contentchecksum", aExpectedContentChecksum
[5]}, {"pixelformat", u
"8BPP"}
1121 assertXPathAttrs(pDoc
, "/metafile/bmpex[5]", {
1122 {"x", u
"0"}, {"y", u
"8"}, {"crc", aExpectedCRC
[6]}, {"transparenttype", u
"bitmap"}, {"contentchecksum", aExpectedContentChecksum
[6]}, {"pixelformat", u
"8BPP"}
1124 assertXPathAttrs(pDoc
, "/metafile/bmpex[6]", {
1125 {"x", u
"2"}, {"y", u
"8"}, {"crc", aExpectedCRC
[7]}, {"transparenttype", u
"bitmap"}, {"contentchecksum", aExpectedContentChecksum
[7]}, {"pixelformat", u
"8BPP"}
1132 void SvmTest::testBitmapExs()
1134 GDIMetaFile aGDIMetaFile
;
1135 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1136 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1140 Bitmap
aBitmap(Size(4,4), vcl::PixelFormat::N24_BPP
);
1142 BitmapScopedWriteAccess
pAccess(aBitmap
);
1143 pAccess
->Erase(COL_YELLOW
);
1146 pVirtualDev
->DrawBitmapEx(Point(1, 1), BitmapEx(aBitmap
, COL_WHITE
));
1149 // DrawBitmapEx - Scale
1151 Bitmap
aBitmap(Size(4,4), vcl::PixelFormat::N24_BPP
);
1153 BitmapScopedWriteAccess
pAccess(aBitmap
);
1154 pAccess
->Erase(COL_GREEN
);
1156 pVirtualDev
->DrawBitmapEx(Point(5, 0), Size(2, 3), BitmapEx(aBitmap
, COL_WHITE
));
1159 // DrawBitmapEx - Scale - Part
1161 Bitmap
aBitmap(Size(4,4), vcl::PixelFormat::N24_BPP
);
1163 BitmapScopedWriteAccess
pAccess(aBitmap
);
1164 pAccess
->Erase(COL_BLUE
);
1166 pVirtualDev
->DrawBitmapEx(Point(7, 1), Size(2, 2), Point(0, 0), Size(3, 4), BitmapEx(aBitmap
, COL_WHITE
));
1169 // DrawBitmapEx - 50% transparent
1171 Bitmap
aBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP
);
1172 AlphaMask
aAlpha(Size(4, 4));
1174 BitmapScopedWriteAccess
pAccess(aBitmap
);
1175 pAccess
->Erase(COL_MAGENTA
);
1177 BitmapScopedWriteAccess
pAlphaAccess(aAlpha
);
1178 pAlphaAccess
->Erase(Color(127, 127, 127));
1180 pVirtualDev
->DrawBitmapEx(Point(6, 6), BitmapEx(aBitmap
, aAlpha
));
1183 // DrawBitmapEx - 1-bit
1185 Bitmap
aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP
);
1187 BitmapScopedWriteAccess
pAccess(aBitmap
);
1188 pAccess
->Erase(COL_MAGENTA
);
1190 aBitmap
.Convert(BmpConversion::N1BitThreshold
);
1191 pVirtualDev
->DrawBitmapEx(Point(0, 6), BitmapEx(aBitmap
, COL_WHITE
));
1194 // DrawBitmapEx - used to be 4-bit
1196 Bitmap
aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP
);
1198 BitmapScopedWriteAccess
pAccess(aBitmap
);
1199 pAccess
->Erase(COL_MAGENTA
);
1201 aBitmap
.Convert(BmpConversion::N8BitColors
);
1202 pVirtualDev
->DrawBitmapEx(Point(2, 6), BitmapEx(aBitmap
, COL_WHITE
));
1205 // DrawBitmapEx - 8-bit Color
1207 Bitmap
aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP
);
1209 BitmapScopedWriteAccess
pAccess(aBitmap
);
1210 pAccess
->Erase(COL_MAGENTA
);
1212 aBitmap
.Convert(BmpConversion::N8BitColors
);
1213 pVirtualDev
->DrawBitmapEx(Point(0, 8), BitmapEx(aBitmap
, COL_WHITE
));
1216 // DrawBitmapEx - 8-bit Grey
1218 Bitmap
aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP
);
1220 BitmapScopedWriteAccess
pAccess(aBitmap
);
1221 pAccess
->Erase(COL_MAGENTA
);
1223 aBitmap
.Convert(BmpConversion::N8BitGreys
);
1224 pVirtualDev
->DrawBitmapEx(Point(2, 8), BitmapEx(aBitmap
, COL_WHITE
));
1228 GDIMetaFile aReloadedGDIMetaFile
= writeAndReadStream(aGDIMetaFile
);
1229 checkBitmapExs(aReloadedGDIMetaFile
, /*bIsSvmFile*/false);
1230 checkRendering(pVirtualDev
, aReloadedGDIMetaFile
, SAL_WHERE
);
1233 GDIMetaFile aFileGDIMetaFile
= readFile(u
"bitmapexs.svm");
1234 checkBitmapExs(aFileGDIMetaFile
, /*bIsSvmFile*/true);
1235 checkRendering(pVirtualDev
, aFileGDIMetaFile
, SAL_WHERE
);
1239 void SvmTest::checkMasks(const GDIMetaFile
& rMetaFile
)
1241 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1243 assertXPathAttrs(pDoc
, "/metafile/mask[1]", {
1244 {"x", u
"1"}, {"y", u
"2"},
1245 {"color", u
"#000000"}
1247 assertXPathAttrs(pDoc
, "/metafile/maskscale[1]", {
1248 {"x", u
"1"}, {"y", u
"2"}, {"width", u
"3"}, {"height", u
"4"},
1249 {"color", u
"#000000"}
1251 assertXPathAttrs(pDoc
, "/metafile/maskscalepart[1]", {
1252 {"destx", u
"1"}, {"desty", u
"2"}, {"destwidth", u
"3"}, {"destheight", u
"4"},
1253 {"srcx", u
"2"}, {"srcy", u
"1"}, {"srcwidth", u
"4"}, {"srcheight", u
"3"},
1254 {"color", u
"#ff0000"}
1258 // TODO: Masks are kind-of special - we don't persist the color attribute (it is
1259 // always #000000) of the meta-action (which is wrong), but rely on alpha to do
1261 void SvmTest::testMasks()
1263 GDIMetaFile aGDIMetaFile
;
1264 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1265 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1267 Bitmap
aBitmap1(Size(4,4), vcl::PixelFormat::N24_BPP
);
1269 BitmapScopedWriteAccess
pAccess(aBitmap1
);
1270 pAccess
->Erase(COL_RED
);
1272 Bitmap
aBitmap2(Size(4,4), vcl::PixelFormat::N24_BPP
);
1274 BitmapScopedWriteAccess
pAccess(aBitmap2
);
1275 pAccess
->Erase(COL_GREEN
);
1277 Bitmap
aBitmap3(Size(4,4), vcl::PixelFormat::N24_BPP
);
1279 BitmapScopedWriteAccess
pAccess(aBitmap3
);
1280 pAccess
->Erase(COL_BLUE
);
1283 pVirtualDev
->DrawMask(Point(1, 2), aBitmap1
, COL_LIGHTRED
);
1284 pVirtualDev
->DrawMask(Point(1, 2), Size(3, 4), aBitmap2
, COL_LIGHTRED
);
1285 pVirtualDev
->DrawMask(Point(1, 2), Size(3, 4), Point(2, 1), Size(4, 3), aBitmap3
, COL_LIGHTRED
, MetaActionType::MASKSCALEPART
);
1287 checkMasks(writeAndReadStream(aGDIMetaFile
));
1288 checkMasks(readFile(u
"masks.svm"));
1291 void SvmTest::checkGradient(const GDIMetaFile
& rMetaFile
)
1293 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1295 assertXPathAttrs(pDoc
, "/metafile/gradient[1]", {
1296 {"style", u
"Linear"},
1297 {"startcolor", u
"#ffffff"},
1298 {"endcolor", u
"#000000"},
1303 {"startintensity", u
"100"},
1304 {"endintensity", u
"100"},
1307 assertXPathAttrs(pDoc
, "/metafile/gradient[1]/rectangle", {
1314 assertXPathAttrs(pDoc
, "/metafile/gradient[2]", {
1315 {"style", u
"Radial"},
1316 {"startcolor", u
"#ff0000"},
1317 {"endcolor", u
"#00ff00"},
1322 {"startintensity", u
"4"},
1323 {"endintensity", u
"14"},
1326 assertXPathAttrs(pDoc
, "/metafile/gradient[2]/rectangle", {
1334 void SvmTest::testGradient()
1336 GDIMetaFile aGDIMetaFile
;
1337 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1338 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1340 tools::Rectangle
aRectangle(Point(1, 2), Size(4,5));
1342 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, COL_WHITE
, COL_BLACK
);
1343 pVirtualDev
->DrawGradient(aRectangle
, aGradient
);
1345 tools::Rectangle
aRectangle2(Point(3, 4), Size(1,2));
1347 Gradient aGradient2
;
1348 aGradient2
.SetStyle(css::awt::GradientStyle_RADIAL
);
1349 aGradient2
.SetStartColor(COL_LIGHTRED
);
1350 aGradient2
.SetEndColor(COL_LIGHTGREEN
);
1351 aGradient2
.SetAngle(Degree10(55));
1352 aGradient2
.SetBorder(10);
1353 aGradient2
.SetOfsX(22);
1354 aGradient2
.SetOfsY(24);
1355 aGradient2
.SetStartIntensity(4);
1356 aGradient2
.SetEndIntensity(14);
1357 aGradient2
.SetSteps(64);
1358 pVirtualDev
->DrawGradient(aRectangle2
, aGradient2
);
1360 checkGradient(writeAndReadStream(aGDIMetaFile
));
1361 checkGradient(readFile(u
"gradient.svm"));
1364 void SvmTest::checkGradientEx(const GDIMetaFile
& rMetaFile
)
1366 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1368 assertXPathAttrs(pDoc
, "/metafile/gradientex[1]", {
1369 {"style", u
"Linear"},
1370 {"startcolor", u
"#ffffff"},
1371 {"endcolor", u
"#000000"},
1376 {"startintensity", u
"100"},
1377 {"endintensity", u
"100"},
1380 assertXPathAttrs(pDoc
, "/metafile/gradientex[1]/polygon/point[1]", {
1384 assertXPathAttrs(pDoc
, "/metafile/gradientex[1]/polygon/point[2]", {
1388 assertXPathAttrs(pDoc
, "/metafile/gradientex[1]/polygon/point[3]", {
1392 assertXPathAttrs(pDoc
, "/metafile/gradientex[2]", {
1393 {"style", u
"Axial"},
1394 {"startcolor", u
"#ff00ff"},
1395 {"endcolor", u
"#008080"},
1400 {"startintensity", u
"4"},
1401 {"endintensity", u
"14"},
1404 assertXPathAttrs(pDoc
, "/metafile/gradientex[2]/polygon[1]/point[1]", {
1408 assertXPathAttrs(pDoc
, "/metafile/gradientex[2]/polygon[1]/point[2]", {
1412 assertXPathAttrs(pDoc
, "/metafile/gradientex[2]/polygon[2]/point[1]", {
1416 assertXPathAttrs(pDoc
, "/metafile/gradientex[2]/polygon[2]/point[2]", {
1422 void SvmTest::testGradientEx()
1424 GDIMetaFile aGDIMetaFile
;
1425 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1426 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1428 tools::Polygon
aPolygon(3);
1429 aPolygon
.SetPoint(Point(1, 8), 0);
1430 aPolygon
.SetPoint(Point(2, 7), 1);
1431 aPolygon
.SetPoint(Point(3, 6), 2);
1433 tools::PolyPolygon
aPolyPolygon(1);
1434 aPolyPolygon
.Insert(aPolygon
);
1436 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, COL_WHITE
, COL_BLACK
);
1437 pVirtualDev
->DrawGradient(aPolyPolygon
, aGradient
);
1439 tools::Polygon
aPolygon2(2);
1440 aPolygon2
.SetPoint(Point(1, 2), 0);
1441 aPolygon2
.SetPoint(Point(3, 4), 1);
1443 tools::Polygon
aPolygon3(2);
1444 aPolygon3
.SetPoint(Point(8, 9), 0);
1445 aPolygon3
.SetPoint(Point(6, 7), 1);
1447 tools::PolyPolygon
aPolyPolygon2(1);
1448 aPolyPolygon2
.Insert(aPolygon2
);
1449 aPolyPolygon2
.Insert(aPolygon3
);
1451 Gradient aGradient2
;
1452 aGradient2
.SetStyle(css::awt::GradientStyle_AXIAL
);
1453 aGradient2
.SetStartColor(COL_LIGHTMAGENTA
);
1454 aGradient2
.SetEndColor(COL_CYAN
);
1455 aGradient2
.SetAngle(Degree10(55));
1456 aGradient2
.SetBorder(10);
1457 aGradient2
.SetOfsX(22);
1458 aGradient2
.SetOfsY(24);
1459 aGradient2
.SetStartIntensity(4);
1460 aGradient2
.SetEndIntensity(14);
1461 aGradient2
.SetSteps(64);
1462 pVirtualDev
->DrawGradient(aPolyPolygon2
, aGradient2
);
1464 checkGradientEx(writeAndReadStream(aGDIMetaFile
));
1465 checkGradientEx(readFile(u
"gradientex.svm"));
1468 void SvmTest::checkHatch(const GDIMetaFile
& rMetaFile
)
1470 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1472 assertXPathAttrs(pDoc
, "/metafile/hatch[1]/polygon/point[1]", {
1473 {"x", u
"1"}, {"y", u
"8"},
1475 assertXPathAttrs(pDoc
, "/metafile/hatch[1]/polygon/point[2]", {
1476 {"x", u
"2"}, {"y", u
"7"},
1478 assertXPathAttrs(pDoc
, "/metafile/hatch[1]/polygon/point[3]", {
1479 {"x", u
"3"}, {"y", u
"6"},
1482 assertXPathAttrs(pDoc
, "/metafile/hatch[1]/hatch", {
1483 {"style", u
"Single"},
1484 {"color", u
"#ffff00"},
1485 {"distance", u
"15"},
1490 void SvmTest::testHatch()
1492 GDIMetaFile aGDIMetaFile
;
1493 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1494 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1496 tools::Polygon
aPolygon(3);
1497 aPolygon
.SetPoint(Point(1, 8), 0);
1498 aPolygon
.SetPoint(Point(2, 7), 1);
1499 aPolygon
.SetPoint(Point(3, 6), 2);
1501 tools::PolyPolygon
aPolyPolygon(1);
1502 aPolyPolygon
.Insert(aPolygon
);
1504 Hatch
aHatch(HatchStyle::Single
, COL_YELLOW
, 15, 900_deg10
);
1506 pVirtualDev
->DrawHatch(aPolyPolygon
, aHatch
);
1508 checkHatch(writeAndReadStream(aGDIMetaFile
));
1509 checkHatch(readFile(u
"hatch.svm"));
1512 void SvmTest::checkWallpaper(const GDIMetaFile
& rMetaFile
)
1514 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1516 // Funny enough - we don't serialize the rectangle of the wallpaper so it's always EMPTY
1517 assertXPathAttrs(pDoc
, "/metafile/wallpaper[1]",
1521 {"right", u
"empty"},
1522 {"bottom", u
"empty"},
1525 assertXPathAttrs(pDoc
, "/metafile/wallpaper[1]/wallpaper",
1527 {"color", u
"#00ff00"},
1530 {"scrollable", u
"true"},
1534 void SvmTest::testWallpaper()
1536 GDIMetaFile aGDIMetaFile
;
1537 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1538 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1540 Wallpaper
aWallpaper(COL_LIGHTGREEN
);
1541 pVirtualDev
->DrawWallpaper(tools::Rectangle(Point(1, 1), Size(3, 3)), aWallpaper
);
1543 checkWallpaper(writeAndReadStream(aGDIMetaFile
));
1544 checkWallpaper(readFile(u
"wallpaper.svm"));
1547 void SvmTest::checkClipRegion(const GDIMetaFile
& rMetaFile
)
1549 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1551 assertXPathAttrs(pDoc
, "/metafile/clipregion[1]", {
1558 assertXPathAttrs(pDoc
, "/metafile/clipregion[2]/polygon[1]/point[1]", {
1563 assertXPathAttrs(pDoc
, "/metafile/clipregion[2]/polygon[1]/point[2]", {
1568 assertXPathAttrs(pDoc
, "/metafile/clipregion[2]/polygon[1]/point[3]", {
1573 assertXPathAttrs(pDoc
, "/metafile/clipregion[3]/polygon[1]/point[1]", {
1578 assertXPathAttrs(pDoc
, "/metafile/clipregion[3]/polygon[1]/point[2]", {
1583 assertXPathAttrs(pDoc
, "/metafile/clipregion[3]/polygon[1]/point[3]", {
1588 assertXPathAttrs(pDoc
, "/metafile/clipregion[3]/polygon[2]/point[1]", {
1593 assertXPathAttrs(pDoc
, "/metafile/clipregion[3]/polygon[2]/point[2]", {
1598 assertXPathAttrs(pDoc
, "/metafile/clipregion[3]/polygon[2]/point[3]", {
1603 assertXPathAttrs(pDoc
, "/metafile/clipregion[4]/polygon[1]/point[1]", {
1608 assertXPathAttrs(pDoc
, "/metafile/clipregion[4]/polygon[1]/point[2]", {
1613 assertXPathAttrs(pDoc
, "/metafile/clipregion[4]/polygon[1]/point[3]", {
1619 void SvmTest::testClipRegion()
1621 GDIMetaFile aGDIMetaFile
;
1622 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1623 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1625 vcl::Region
aRegion(tools::Rectangle(Point(2, 2), Size(4, 4)));
1627 pVirtualDev
->SetClipRegion(aRegion
);
1629 tools::Polygon
aPolygon(3);
1630 aPolygon
.SetPoint(Point(1, 8), 0);
1631 aPolygon
.SetPoint(Point(2, 7), 1);
1632 aPolygon
.SetPoint(Point(3, 6), 2);
1634 vcl::Region
aRegion2(aPolygon
);
1635 pVirtualDev
->SetClipRegion(aRegion2
);
1637 tools::Polygon
aPolygon1(3);
1638 aPolygon1
.SetPoint(Point(4, 9), 0);
1639 aPolygon1
.SetPoint(Point(5, 10), 1);
1640 aPolygon1
.SetPoint(Point(6, 11), 2);
1642 tools::PolyPolygon
aPolyPolygon(2);
1643 aPolyPolygon
.Insert(aPolygon
);
1644 aPolyPolygon
.Insert(aPolygon1
);
1646 vcl::Region
aRegion3(aPolyPolygon
);
1647 pVirtualDev
->SetClipRegion(aRegion3
);
1649 basegfx::B2DPolygon aB2DPolygon
;
1650 aB2DPolygon
.append(basegfx::B2DPoint(0.0, 1.1));
1651 aB2DPolygon
.append(basegfx::B2DPoint(2.2, 3.3));
1652 aB2DPolygon
.append(basegfx::B2DPoint(3.7, 3.8));
1654 basegfx::B2DPolyPolygon
aB2DPolyPolygon(aB2DPolygon
);
1656 vcl::Region
aRegion4(aB2DPolyPolygon
);
1657 pVirtualDev
->SetClipRegion(aRegion4
);
1659 checkClipRegion(writeAndReadStream(aGDIMetaFile
));
1660 checkClipRegion(readFile(u
"clipregion.svm"));
1663 void SvmTest::checkIntersectRectClipRegion(const GDIMetaFile
& rMetaFile
)
1665 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1667 assertXPathAttrs(pDoc
, "/metafile/sectregionclipregion[1]", {
1675 void SvmTest::testIntersectRectClipRegion()
1677 GDIMetaFile aGDIMetaFile
;
1678 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1679 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1681 tools::Rectangle
aRectangle(Point(1, 2), Size(4, 8));
1683 vcl::Region
aRegion(aRectangle
);
1685 pVirtualDev
->IntersectClipRegion(aRegion
);
1686 checkIntersectRectClipRegion(writeAndReadStream(aGDIMetaFile
));
1687 checkIntersectRectClipRegion(readFile(u
"intersectrectclipregion.svm"));
1690 void SvmTest::checkIntersectRegionClipRegion(const GDIMetaFile
& rMetaFile
)
1692 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1694 assertXPathAttrs(pDoc
, "/metafile/sectregionclipregion[1]", {
1701 assertXPathAttrs(pDoc
, "/metafile/sectregionclipregion[2]", {
1708 assertXPathAttrs(pDoc
, "/metafile/sectregionclipregion[3]", {
1716 void SvmTest::testIntersectRegionClipRegion()
1718 GDIMetaFile aGDIMetaFile
;
1719 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1720 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1722 tools::Polygon
aPolygon(3);
1723 aPolygon
.SetPoint(Point(1, 2), 0);
1724 aPolygon
.SetPoint(Point(3, 4), 1);
1725 aPolygon
.SetPoint(Point(5, 6), 2);
1727 vcl::Region
aRegion(aPolygon
);
1728 pVirtualDev
->IntersectClipRegion(aRegion
);
1730 tools::Polygon
aPolygon1(2);
1731 aPolygon1
.SetPoint(Point(5, 6), 0);
1732 aPolygon1
.SetPoint(Point(7, 8), 1);
1734 tools::PolyPolygon
aPolyPolygon(2);
1735 aPolyPolygon
.Insert(aPolygon
);
1736 aPolyPolygon
.Insert(aPolygon1
);
1738 vcl::Region
aRegion1(aPolyPolygon
);
1739 pVirtualDev
->IntersectClipRegion(aRegion1
);
1741 basegfx::B2DPolygon aB2DPolygon
;
1742 aB2DPolygon
.append(basegfx::B2DPoint(0.0, 3.3));
1743 aB2DPolygon
.append(basegfx::B2DPoint(1.1, 4.4));
1744 aB2DPolygon
.append(basegfx::B2DPoint(2.2, 5.5));
1746 basegfx::B2DPolyPolygon
aB2DPolyPolygon(aB2DPolygon
);
1748 vcl::Region
aRegion2(aB2DPolyPolygon
);
1749 pVirtualDev
->IntersectClipRegion(aRegion2
);
1751 checkIntersectRegionClipRegion(writeAndReadStream(aGDIMetaFile
));
1752 checkIntersectRegionClipRegion(readFile(u
"intersectregionclipregion.svm"));
1755 void SvmTest::checkMoveClipRegion(const GDIMetaFile
& rMetaFile
)
1757 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1759 assertXPathAttrs(pDoc
, "/metafile/moveclipregion[1]", {
1764 assertXPathAttrs(pDoc
, "/metafile/moveclipregion[2]", {
1765 {"horzmove", u
"-3"},
1770 void SvmTest::testMoveClipRegion()
1772 GDIMetaFile aGDIMetaFile
;
1773 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1774 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1776 tools::Rectangle
aRectangle(Point(1, 2), Size(4, 8));
1778 vcl::Region
aRegion(aRectangle
);
1780 pVirtualDev
->SetClipRegion(aRegion
);
1782 pVirtualDev
->MoveClipRegion(1, 2);
1783 pVirtualDev
->MoveClipRegion(-3, -4);
1785 checkMoveClipRegion(writeAndReadStream(aGDIMetaFile
));
1786 checkMoveClipRegion(readFile(u
"moveclipregion.svm"));
1789 void SvmTest::checkLineColor(const GDIMetaFile
& rMetaFile
)
1791 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1793 assertXPathAttrs(pDoc
, "/metafile/push/linecolor[1]", {
1794 {"color", u
"#654321"},
1798 void SvmTest::testLineColor()
1800 GDIMetaFile aGDIMetaFile
;
1801 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1802 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1804 pVirtualDev
->Push();
1805 pVirtualDev
->SetLineColor(Color(0x654321));
1808 checkLineColor(writeAndReadStream(aGDIMetaFile
));
1809 checkLineColor(readFile(u
"linecolor.svm"));
1812 void SvmTest::checkFillColor(const GDIMetaFile
& rMetaFile
)
1814 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1816 assertXPathAttrs(pDoc
, "/metafile/push/fillcolor[1]", {
1817 {"color", u
"#456789"},
1821 void SvmTest::testFillColor()
1823 GDIMetaFile aGDIMetaFile
;
1824 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1825 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1827 pVirtualDev
->Push();
1828 pVirtualDev
->SetFillColor(Color(0x456789));
1831 checkFillColor(writeAndReadStream(aGDIMetaFile
));
1832 checkFillColor(readFile(u
"fillcolor.svm"));
1835 void SvmTest::checkTextColor(const GDIMetaFile
& rMetaFile
)
1837 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1839 assertXPathAttrs(pDoc
, "/metafile/textcolor[1]", {
1840 {"color", u
"#123456"},
1844 void SvmTest::testTextColor()
1846 GDIMetaFile aGDIMetaFile
;
1847 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1848 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1850 pVirtualDev
->SetTextColor(Color(0x123456));
1852 checkTextColor(writeAndReadStream(aGDIMetaFile
));
1853 checkTextColor(readFile(u
"textcolor.svm"));
1856 void SvmTest::checkTextFillColor(const GDIMetaFile
& rMetaFile
)
1858 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1860 assertXPathAttrs(pDoc
, "/metafile/textfillcolor[1]", {
1861 {"color", u
"#234567"},
1865 void SvmTest::testTextFillColor()
1867 GDIMetaFile aGDIMetaFile
;
1868 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1869 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1871 pVirtualDev
->SetTextFillColor(Color(0x234567));
1873 checkTextFillColor(writeAndReadStream(aGDIMetaFile
));
1874 checkTextFillColor(readFile(u
"textfillecolor.svm"));
1877 void SvmTest::checkTextLineColor(const GDIMetaFile
& rMetaFile
)
1879 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1881 assertXPathAttrs(pDoc
, "/metafile/textlinecolor[1]", {
1882 {"color", u
"#345678"},
1886 void SvmTest::testTextLineColor()
1888 GDIMetaFile aGDIMetaFile
;
1889 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1890 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1892 pVirtualDev
->SetTextLineColor(Color(0x345678));
1894 checkTextLineColor(writeAndReadStream(aGDIMetaFile
));
1895 checkTextLineColor(readFile(u
"textlinecolor.svm"));
1898 void SvmTest::checkOverLineColor(const GDIMetaFile
& rMetaFile
)
1900 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1902 assertXPathAttrs(pDoc
, "/metafile/push/overlinecolor[1]", {
1903 {"color", u
"#345678"},
1907 void SvmTest::testOverLineColor()
1909 GDIMetaFile aGDIMetaFile
;
1910 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1911 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1913 pVirtualDev
->Push();
1914 pVirtualDev
->SetOverlineColor(Color(0x345678));
1917 checkOverLineColor(writeAndReadStream(aGDIMetaFile
));
1918 checkOverLineColor(readFile(u
"overlinecolor.svm"));
1921 void SvmTest::checkTextAlign(const GDIMetaFile
& rMetaFile
)
1923 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
1925 assertXPathAttrs(pDoc
, "/metafile/textalign[1]", {
1926 {"align", u
"bottom"},
1930 void SvmTest::testTextAlign()
1932 GDIMetaFile aGDIMetaFile
;
1933 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1934 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
1936 pVirtualDev
->SetTextAlign(TextAlign::ALIGN_BOTTOM
);
1938 checkTextAlign(writeAndReadStream(aGDIMetaFile
));
1939 checkTextAlign(readFile(u
"textalign.svm"));
1942 void SvmTest::checkMapMode(const GDIMetaFile
& rMetafile
)
1944 xmlDocUniquePtr pDoc
= dumpMeta(rMetafile
);
1946 assertXPathAttrs(pDoc
, "/metafile/mapmode[1]", {
1947 {"mapunit", u
"MapPixel"},
1950 {"scalex", u
"(1/1)"},
1951 {"scaley", u
"(1/1)"}
1954 assertXPathAttrs(pDoc
, "/metafile/mapmode[2]", {
1955 {"mapunit", u
"Map100thInch"},
1958 {"scalex", u
"(1/2)"},
1959 {"scaley", u
"(2/3)"}
1962 assertXPathAttrs(pDoc
, "/metafile/mapmode[3]", {
1963 {"mapunit", u
"MapRelative"},
1966 {"scalex", u
"(25/12)"},
1967 {"scaley", u
"(25/16)"}
1971 void SvmTest::testMapMode()
1973 if (!IsDefaultDPI())
1975 GDIMetaFile aGDIMetafile
;
1976 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
1977 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetafile
);
1981 pVirtualDev
->SetMapMode(aMapMode
);
1983 MapMode
aMapMode1(MapUnit::Map100thInch
);
1984 aMapMode1
.SetOrigin(Point(0, 1));
1985 aMapMode1
.SetScaleX(Fraction(1, 2));
1986 aMapMode1
.SetScaleY(Fraction(2, 3));
1988 pVirtualDev
->SetMetafileMapMode(aMapMode1
, false);
1991 pVirtualDev
->SetMetafileMapMode(aMapMode2
, true);
1993 checkMapMode(writeAndReadStream(aGDIMetafile
));
1994 checkMapMode(readFile(u
"mapmode.svm"));
1997 #if HAVE_MORE_FONTS && !defined(_WIN32)
1998 void SvmTest::checkFont(const GDIMetaFile
& rMetafile
)
2000 xmlDocUniquePtr pDoc
= dumpMeta(rMetafile
);
2001 assertXPathAttrs(pDoc
, "/metafile/font[1]", {
2002 {"color", u
"#ffffff"},
2003 {"fillcolor", u
"#ffffff"},
2004 {"name", u
"Liberation Sans"},
2005 {"stylename", u
"Regular"},
2008 {"orientation", u
"50"},
2009 {"weight", u
"thin"},
2010 {"vertical", u
"true"},
2015 void SvmTest::testFont()
2018 // Windows interprets Width differently causing build errors
2019 #if !defined(_WIN32)
2020 GDIMetaFile aGDIMetaFile
;
2021 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2022 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2023 vcl::Font
aFont(FontFamily::FAMILY_SCRIPT
, Size(15, 15));
2024 aFont
.SetWeight(FontWeight::WEIGHT_THIN
);
2025 aFont
.SetFamilyName(u
"Liberation Sans"_ustr
);
2026 aFont
.SetStyleName(u
"Regular"_ustr
);
2027 aFont
.SetFontHeight(12);
2028 aFont
.SetAverageFontWidth(12);
2029 aFont
.SetVertical(true);
2030 aFont
.SetOrientation(Degree10(50));
2031 pVirtualDev
->SetFont(aFont
);
2032 checkFont(writeAndReadStream(aGDIMetaFile
));
2033 checkFont(readFile(u
"font.svm"));
2038 void SvmTest::checkPushPop(const GDIMetaFile
& rMetaFile
)
2040 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
2042 assertXPathAttrs(pDoc
, "/metafile/push[1]", {{"flags", u
"PushAll"}});
2043 assertXPathAttrs(pDoc
, "/metafile/push[1]/linecolor[1]", {{"color", u
"#800000"}});
2044 assertXPathAttrs(pDoc
, "/metafile/push[1]/line[1]", {
2045 {"startx", u
"4"}, {"starty", u
"4"},
2046 {"endx", u
"6"}, {"endy", u
"6"},
2048 assertXPathAttrs(pDoc
, "/metafile/push[1]/push[1]", {{"flags", u
"PushLineColor, PushFillColor"}});
2049 assertXPathAttrs(pDoc
, "/metafile/push[1]/push[1]/line[1]", {
2050 {"startx", u
"5"}, {"starty", u
"5"},
2051 {"endx", u
"7"}, {"endy", u
"7"},
2055 void SvmTest::testPushPop()
2057 GDIMetaFile aGDIMetaFile
;
2058 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2059 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2061 pVirtualDev
->SetLineColor(COL_YELLOW
);
2062 pVirtualDev
->Push();
2063 pVirtualDev
->SetLineColor(COL_RED
);
2064 pVirtualDev
->DrawLine(Point(4,4), Point(6,6));
2065 pVirtualDev
->Push(vcl::PushFlags::FILLCOLOR
| vcl::PushFlags::LINECOLOR
);
2066 pVirtualDev
->SetLineColor(COL_LIGHTRED
);
2067 pVirtualDev
->DrawLine(Point(5,5), Point(7,7));
2070 pVirtualDev
->DrawLine(Point(1,1), Point(8,8));
2072 checkPushPop(writeAndReadStream(aGDIMetaFile
));
2073 checkPushPop(readFile(u
"pushpop.svm"));
2076 void SvmTest::checkRasterOp(const GDIMetaFile
& rMetaFile
)
2078 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
2080 assertXPathAttrs(pDoc
, "/metafile/rasterop[1]", {
2081 {"operation", u
"xor"},
2085 void SvmTest::testRasterOp()
2087 GDIMetaFile aGDIMetaFile
;
2088 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2089 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2091 pVirtualDev
->SetRasterOp(RasterOp::Xor
);
2093 checkRasterOp(writeAndReadStream(aGDIMetaFile
));
2094 checkRasterOp(readFile(u
"rasterop.svm"));
2097 void SvmTest::checkTransparent(const GDIMetaFile
& rMetaFile
)
2099 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
2101 assertXPathAttrs(pDoc
, "/metafile/transparent[1]", {
2102 {"transparence", u
"50"},
2105 assertXPathAttrs(pDoc
, "/metafile/transparent[1]/polygon/point[1]", {
2106 {"x", u
"1"}, {"y", u
"8"},
2108 assertXPathAttrs(pDoc
, "/metafile/transparent[1]/polygon/point[2]", {
2109 {"x", u
"2"}, {"y", u
"7"},
2111 assertXPathAttrs(pDoc
, "/metafile/transparent[1]/polygon/point[3]", {
2112 {"x", u
"3"}, {"y", u
"6"},
2116 void SvmTest::testTransparent()
2118 GDIMetaFile aGDIMetaFile
;
2119 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2120 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2122 tools::Polygon
aPolygon(3);
2123 aPolygon
.SetPoint(Point(1, 8), 0);
2124 aPolygon
.SetPoint(Point(2, 7), 1);
2125 aPolygon
.SetPoint(Point(3, 6), 2);
2127 tools::PolyPolygon
aPolyPolygon(1);
2128 aPolyPolygon
.Insert(aPolygon
);
2130 pVirtualDev
->DrawTransparent(tools::PolyPolygon(aPolygon
), 50);
2132 CPPUNIT_ASSERT(aGDIMetaFile
.HasTransparentActions());
2133 checkTransparent(writeAndReadStream(aGDIMetaFile
));
2134 checkTransparent(readFile(u
"transparent.svm"));
2137 void SvmTest::checkFloatTransparent(const GDIMetaFile
& rMetaFile
)
2139 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
2141 assertXPathAttrs(pDoc
, "/metafile/floattransparent[1]", {
2146 {"transparent", u
"true"}
2149 assertXPathAttrs(pDoc
, "/metafile/floattransparent[1]/gradient[1]", {
2150 {"style", u
"Linear"},
2151 {"startcolor", u
"#ffffff"},
2152 {"endcolor", u
"#000000"},
2157 {"startintensity", u
"100"},
2158 {"endintensity", u
"100"},
2162 assertXPathAttrs(pDoc
, "/metafile/floattransparent[1]/metafile[1]/point[1]", {
2167 assertXPathAttrs(pDoc
, "/metafile/floattransparent[1]/metafile[1]/point[2]", {
2173 void SvmTest::testFloatTransparent()
2175 GDIMetaFile aGDIMetaFile
;
2176 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2177 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2179 GDIMetaFile aGDIMetaFile1
;
2180 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev1
;
2181 setupBaseVirtualDevice(*pVirtualDev1
, aGDIMetaFile1
);
2183 pVirtualDev1
->DrawPixel(Point(1, 8));
2184 pVirtualDev1
->DrawPixel(Point(2, 7));
2186 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, COL_WHITE
, COL_BLACK
);
2188 pVirtualDev
->DrawTransparent(aGDIMetaFile1
, Point(1, 2), Size(3, 4), aGradient
);
2190 checkFloatTransparent(writeAndReadStream(aGDIMetaFile
));
2191 checkFloatTransparent(readFile(u
"floattransparent.svm"));
2194 void SvmTest::checkEPS(const GDIMetaFile
& rMetaFile
)
2196 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
2198 assertXPathAttrs(pDoc
, "/metafile/eps[1]", {
2205 assertXPathAttrs(pDoc
, "/metafile/eps[1]/gfxlink[1]", {
2208 {"type", u
"EpsBuffer"},
2209 {"userid", u
"12345"},
2211 {"data", u
"616263"},
2212 {"native", u
"false"},
2214 {"validmapmode", u
"true"}
2217 assertXPathAttrs(pDoc
, "/metafile/eps[1]/gfxlink[1]/prefmapmode[1]", {
2218 {"mapunit", u
"Map100thInch"},
2221 {"scalex", u
"(1/2)"},
2222 {"scaley", u
"(2/3)"}
2225 assertXPathAttrs(pDoc
, "/metafile/eps[1]/metafile[1]/point[1]", {
2230 assertXPathAttrs(pDoc
, "/metafile/eps[1]/metafile[1]/point[2]", {
2236 void SvmTest::testEPS()
2238 GDIMetaFile aGDIMetaFile
;
2239 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2240 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2242 sal_uInt8 aBuffer
[] = { 'a','b','c' };
2243 SvMemoryStream
stream(aBuffer
, std::size(aBuffer
), StreamMode::READ
);
2244 BinaryDataContainer
aContainer(stream
, std::size(aBuffer
));
2246 MapMode
aMapMode1(MapUnit::Map100thInch
);
2247 aMapMode1
.SetOrigin(Point(0, 1));
2248 aMapMode1
.SetScaleX(Fraction(1, 2));
2249 aMapMode1
.SetScaleY(Fraction(2, 3));
2251 GDIMetaFile aGDIMetaFile1
;
2252 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev1
;
2253 setupBaseVirtualDevice(*pVirtualDev1
, aGDIMetaFile1
);
2255 pVirtualDev1
->DrawPixel(Point(1, 8));
2256 pVirtualDev1
->DrawPixel(Point(2, 7));
2258 GfxLink
aGfxLink(aContainer
, GfxLinkType::EpsBuffer
);
2259 aGfxLink
.SetPrefMapMode(aMapMode1
);
2260 aGfxLink
.SetUserId(12345);
2261 aGfxLink
.SetPrefSize(Size(3, 6));
2262 pVirtualDev
->DrawEPS(Point(1, 8), Size(2, 7), aGfxLink
, &aGDIMetaFile1
);
2264 checkEPS(writeAndReadStream(aGDIMetaFile
));
2265 checkEPS(readFile(u
"eps.svm"));
2268 void SvmTest::checkRefPoint(const GDIMetaFile
& rMetaFile
)
2270 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
2272 assertXPathAttrs(pDoc
, "/metafile/refpoint[1]", {
2278 assertXPathAttrs(pDoc
, "/metafile/refpoint[2]", {
2285 void SvmTest::testRefPoint()
2287 GDIMetaFile aGDIMetaFile
;
2288 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2289 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2291 pVirtualDev
->SetRefPoint();
2293 pVirtualDev
->SetRefPoint(Point(1,2));
2295 checkRefPoint(writeAndReadStream(aGDIMetaFile
));
2296 checkRefPoint(readFile(u
"refpoint.svm"));
2299 void SvmTest::checkComment(const GDIMetaFile
& rMetafile
)
2301 xmlDocUniquePtr pDoc
= dumpMeta(rMetafile
);
2303 assertXPathAttrs(pDoc
, "/metafile/comment[1]", {
2307 assertXPathContent(pDoc
, "/metafile/comment[1]/comment[1]", u
"Test comment");
2309 assertXPathAttrs(pDoc
, "/metafile/comment[2]", {
2313 assertXPathAttrs(pDoc
, "/metafile/comment[2]", {
2314 {"data", u
"540068006500730065002000610072006500200073006f006d0065002000740065007300740020006400610074006100"}
2317 assertXPathAttrs(pDoc
, "/metafile/comment[2]", {
2321 assertXPathContent(pDoc
, "/metafile/comment[2]/comment[1]", u
"This is a test comment");
2324 void SvmTest::testComment()
2326 GDIMetaFile aGDIMetaFile
;
2327 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2328 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2330 aGDIMetaFile
.AddAction(new MetaCommentAction("Test comment"_ostr
));
2332 using namespace std::literals::string_view_literals
;
2333 static constexpr auto aString
2334 = "T\0h\0e\0s\0e\0 \0a\0r\0e\0 \0s\0o\0m\0e\0 \0t\0e\0s\0t\0 \0d\0a\0t\0a\0"sv
;
2335 aGDIMetaFile
.AddAction(new MetaCommentAction("This is a test comment"_ostr
, \
2337 reinterpret_cast<const sal_uInt8
*>(aString
.data()), \
2338 aString
.length() ));
2340 checkComment(writeAndReadStream(aGDIMetaFile
));
2341 checkComment(readFile(u
"comment.svm"));
2344 void SvmTest::checkLayoutMode(const GDIMetaFile
& rMetaFile
)
2346 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
2348 assertXPathAttrs(pDoc
, "/metafile/layoutmode[1]", {
2349 {"textlayout", u
"TextOriginLeft"}
2352 assertXPathAttrs(pDoc
, "/metafile/layoutmode[2]", {
2353 {"textlayout", u
"BiDiRtl"}
2357 void SvmTest::testLayoutMode()
2359 GDIMetaFile aGDIMetaFile
;
2360 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2361 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2363 pVirtualDev
->SetLayoutMode(vcl::text::ComplexTextLayoutFlags::TextOriginLeft
);
2364 pVirtualDev
->SetLayoutMode(vcl::text::ComplexTextLayoutFlags::BiDiRtl
);
2366 checkLayoutMode(writeAndReadStream(aGDIMetaFile
));
2367 checkLayoutMode(readFile(u
"layoutmode.svm"));
2370 void SvmTest::checkTextLanguage(const GDIMetaFile
& rMetaFile
)
2372 xmlDocUniquePtr pDoc
= dumpMeta(rMetaFile
);
2374 assertXPathAttrs(pDoc
, "/metafile/textlanguage[1]", {
2375 {"language", u
"#0408"}
2378 assertXPathAttrs(pDoc
, "/metafile/textlanguage[2]", {
2379 {"language", u
"#00ff"}
2383 void SvmTest::testTextLanguage()
2385 GDIMetaFile aGDIMetaFile
;
2386 ScopedVclPtrInstance
<VirtualDevice
> pVirtualDev
;
2387 setupBaseVirtualDevice(*pVirtualDev
, aGDIMetaFile
);
2389 pVirtualDev
->SetDigitLanguage(LANGUAGE_GREEK
);
2390 pVirtualDev
->SetDigitLanguage(LANGUAGE_NONE
);
2392 checkTextLanguage(writeAndReadStream(aGDIMetaFile
));
2393 checkTextLanguage(readFile(u
"textlanguage.svm"));
2396 CPPUNIT_TEST_SUITE_REGISTRATION(SvmTest
);
2398 CPPUNIT_PLUGIN_IMPLEMENT();
2400 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */