tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / vcl / qa / cppunit / svm / svmtest.cxx
blobc9096728442a24aa8ad6c4526a30b7ea42bcba5b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 */
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>
40 using namespace css;
42 class SvmTest : public test::BootstrapFixture, public XmlTestTools
44 OUString maDataUrl;
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);
68 void testPixel();
70 void checkPoint(const GDIMetaFile& rMetaFile);
71 void testPoint();
73 void checkLine(const GDIMetaFile& rMetaFile);
74 void testLine();
76 void checkRect(const GDIMetaFile& rMetaFile);
77 void testRect();
79 void checkRoundRect(const GDIMetaFile& rMetaFile);
80 void testRoundRect();
82 void checkEllipse(const GDIMetaFile& rMetaFile);
83 void testEllipse();
85 void checkArc(const GDIMetaFile& rMetaFile);
86 void testArc();
88 void checkPie(const GDIMetaFile& rMetaFile);
89 void testPie();
91 void checkChord(const GDIMetaFile& rMetaFile);
92 void testChord();
94 void checkPolyLine(const GDIMetaFile& rMetaFile);
95 void testPolyLine();
97 void checkPolygon(const GDIMetaFile& rMetaFile);
98 void testPolygon();
100 void checkPolyPolygon(const GDIMetaFile& rMetaFile);
101 void testPolyPolygon();
103 void checkText(const GDIMetaFile& rMetaFile);
104 void testText();
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);
116 void testTextRect();
118 void checkTextLine(const GDIMetaFile& rMetaFile);
119 void testTextLine();
121 void checkBitmaps(const GDIMetaFile& rMetaFile);
122 void testBitmaps();
124 void checkBitmapExs(const GDIMetaFile& rMetaFile, bool bIsSvmFile);
125 void testBitmapExs();
127 void checkMasks(const GDIMetaFile& rMetaFile);
128 void testMasks();
130 void checkGradient(const GDIMetaFile& rMetaFile);
131 void testGradient();
133 void checkGradientEx(const GDIMetaFile& rMetaFile);
134 void testGradientEx();
136 void checkHatch(const GDIMetaFile& rMetaFile);
137 void testHatch();
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);
176 void testMapMode();
178 #if HAVE_MORE_FONTS && !defined(_WIN32)
179 void checkFont(const GDIMetaFile& rMetaFile);
180 #endif
181 void testFont();
183 void checkPushPop(const GDIMetaFile& rMetaFile);
184 void testPushPop();
186 void checkRasterOp(const GDIMetaFile& rMetaFile);
187 void testRasterOp();
189 void checkTransparent(const GDIMetaFile& rMetaFile);
190 void testTransparent();
192 void checkFloatTransparent(const GDIMetaFile& rMetaFile);
193 void testFloatTransparent();
195 void checkEPS(const GDIMetaFile& rMetaFile);
196 void testEPS();
198 void checkRefPoint(const GDIMetaFile& rMetaFile);
199 void testRefPoint();
201 void checkComment(const GDIMetaFile& rMetaFile);
202 void testComment();
204 void checkLayoutMode(const GDIMetaFile& rMetaFile);
205 void testLayoutMode();
207 void checkTextLanguage(const GDIMetaFile& rMetaFile);
208 void testTextLanguage();
210 public:
211 SvmTest()
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));
274 rDevice.Erase();
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);
322 aFileStream.Close();
325 void SvmTest::writeToFile(GDIMetaFile& rMetaFile, std::u16string_view rName)
327 if (rName.empty())
328 return;
329 OUString sFilePath = getFullUrl(rName);
330 writeMetaFile(rMetaFile, sFilePath);
333 GDIMetaFile SvmTest::writeAndReadStream(GDIMetaFile& rMetaFile, std::u16string_view rName)
335 if (!rName.empty())
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);
363 checkErase(pDoc);
365 return 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"},
453 {"distance", 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"},
466 {"distance", u"1"},
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"},
679 {"distance", 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"},
691 {"distance", u"1"},
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]",
880 { { "x", u"4" },
881 { "y", u"6" },
882 { "index", u"1" },
883 { "length", u"4" },
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
976 u"5e01ddcc"
977 #else
978 #if !ENABLE_CAIRO_RGBA
979 u"469f0820" // typical BGRA little-endian config
980 #else
981 u"3789377b" // atypical RGBA little-endian config
982 #endif
983 #endif
984 }});
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"},
991 {"crc",
992 #if defined OSL_BIGENDIAN
993 u"b8dee5da"
994 #else
995 #if !ENABLE_CAIRO_RGBA
996 u"3789377b" // typical BGRA little-endian config
997 #else
998 u"469f0820" // atypical RGBA little-endian config
999 #endif
1000 #endif
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
1052 u"08feb5d3",
1053 u"281fc589",
1054 u"b8dee5da",
1055 u"4df0e464",
1056 u"186ff868", // 1-bit
1057 u"33b4a07c", // 4-bit color bitmap - same as 8-bit color bitmap
1058 u"33b4a07c",
1059 u"742c3e35",
1060 #else
1061 #if !ENABLE_CAIRO_RGBA
1062 u"ac936607", // typical BGRA little-endian config
1063 #else
1064 "ecd75a28", // atypical RGBA little-endian config
1065 #endif
1066 u"4937e32d",
1067 #if !ENABLE_CAIRO_RGBA
1068 u"3789377b", // typical BGRA little-endian config
1069 #else
1070 "469f0820", // atypical RGBA little-endian config
1071 #endif
1072 u"839e8cce",
1073 u"236aaf55", // 1-bit
1074 u"2949ccc7", // 4-bit color bitmap - same as 8-bit color bitmap
1075 u"2949ccc7",
1076 u"e5df8aad",
1077 #endif
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"}
1105 #ifndef MACOSX
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"}
1112 if (!bIsSvmFile)
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"}
1127 #else
1128 (void)bIsSvmFile;
1129 #endif
1132 void SvmTest::testBitmapExs()
1134 GDIMetaFile aGDIMetaFile;
1135 ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
1136 setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
1138 // DrawBitmapEx
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
1260 // the right thing.
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"},
1299 {"angle", u"0"},
1300 {"border", u"0"},
1301 {"offsetx", u"50"},
1302 {"offsety", u"50"},
1303 {"startintensity", u"100"},
1304 {"endintensity", u"100"},
1305 {"steps", u"0"},
1307 assertXPathAttrs(pDoc, "/metafile/gradient[1]/rectangle", {
1308 {"left", u"1"},
1309 {"top", u"2"},
1310 {"right", u"4"},
1311 {"bottom", u"6"},
1314 assertXPathAttrs(pDoc, "/metafile/gradient[2]", {
1315 {"style", u"Radial"},
1316 {"startcolor", u"#ff0000"},
1317 {"endcolor", u"#00ff00"},
1318 {"angle", u"55"},
1319 {"border", u"10"},
1320 {"offsetx", u"22"},
1321 {"offsety", u"24"},
1322 {"startintensity", u"4"},
1323 {"endintensity", u"14"},
1324 {"steps", u"64"},
1326 assertXPathAttrs(pDoc, "/metafile/gradient[2]/rectangle", {
1327 {"left", u"3"},
1328 {"top", u"4"},
1329 {"right", u"3"},
1330 {"bottom", u"5"},
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"},
1372 {"angle", u"0"},
1373 {"border", u"0"},
1374 {"offsetx", u"50"},
1375 {"offsety", u"50"},
1376 {"startintensity", u"100"},
1377 {"endintensity", u"100"},
1378 {"steps", u"0"}
1380 assertXPathAttrs(pDoc, "/metafile/gradientex[1]/polygon/point[1]", {
1381 {"x", u"1"},
1382 {"y", u"8"}
1384 assertXPathAttrs(pDoc, "/metafile/gradientex[1]/polygon/point[2]", {
1385 {"x", u"2"},
1386 {"y", u"7"}
1388 assertXPathAttrs(pDoc, "/metafile/gradientex[1]/polygon/point[3]", {
1389 {"x", u"3"},
1390 {"y", u"6"}
1392 assertXPathAttrs(pDoc, "/metafile/gradientex[2]", {
1393 {"style", u"Axial"},
1394 {"startcolor", u"#ff00ff"},
1395 {"endcolor", u"#008080"},
1396 {"angle", u"55"},
1397 {"border", u"10"},
1398 {"offsetx", u"22"},
1399 {"offsety", u"24"},
1400 {"startintensity", u"4"},
1401 {"endintensity", u"14"},
1402 {"steps", u"64"}
1404 assertXPathAttrs(pDoc, "/metafile/gradientex[2]/polygon[1]/point[1]", {
1405 {"x", u"1"},
1406 {"y", u"2"}
1408 assertXPathAttrs(pDoc, "/metafile/gradientex[2]/polygon[1]/point[2]", {
1409 {"x", u"3"},
1410 {"y", u"4"}
1412 assertXPathAttrs(pDoc, "/metafile/gradientex[2]/polygon[2]/point[1]", {
1413 {"x", u"8"},
1414 {"y", u"9"}
1416 assertXPathAttrs(pDoc, "/metafile/gradientex[2]/polygon[2]/point[2]", {
1417 {"x", u"6"},
1418 {"y", u"7"}
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"},
1486 {"angle", u"900"},
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]",
1519 {"left", u"0"},
1520 {"top", u"0"},
1521 {"right", u"empty"},
1522 {"bottom", u"empty"},
1525 assertXPathAttrs(pDoc, "/metafile/wallpaper[1]/wallpaper",
1527 {"color", u"#00ff00"},
1528 {"style", u"Tile"},
1529 {"fixed", u"true"},
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]", {
1552 {"left", u"2"},
1553 {"top", u"2"},
1554 {"right", u"5"},
1555 {"bottom", u"5"},
1558 assertXPathAttrs(pDoc, "/metafile/clipregion[2]/polygon[1]/point[1]", {
1559 {"x", u"1"},
1560 {"y", u"8"}
1563 assertXPathAttrs(pDoc, "/metafile/clipregion[2]/polygon[1]/point[2]", {
1564 {"x", u"2"},
1565 {"y", u"7"}
1568 assertXPathAttrs(pDoc, "/metafile/clipregion[2]/polygon[1]/point[3]", {
1569 {"x", u"3"},
1570 {"y", u"6"}
1573 assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[1]/point[1]", {
1574 {"x", u"1"},
1575 {"y", u"8"}
1578 assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[1]/point[2]", {
1579 {"x", u"2"},
1580 {"y", u"7"}
1583 assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[1]/point[3]", {
1584 {"x", u"3"},
1585 {"y", u"6"}
1588 assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[2]/point[1]", {
1589 {"x", u"4"},
1590 {"y", u"9"}
1593 assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[2]/point[2]", {
1594 {"x", u"5"},
1595 {"y", u"10"}
1598 assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[2]/point[3]", {
1599 {"x", u"6"},
1600 {"y", u"11"}
1603 assertXPathAttrs(pDoc, "/metafile/clipregion[4]/polygon[1]/point[1]", {
1604 {"x", u"0"},
1605 {"y", u"1"}
1608 assertXPathAttrs(pDoc, "/metafile/clipregion[4]/polygon[1]/point[2]", {
1609 {"x", u"2"},
1610 {"y", u"3"}
1613 assertXPathAttrs(pDoc, "/metafile/clipregion[4]/polygon[1]/point[3]", {
1614 {"x", u"4"},
1615 {"y", u"4"}
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]", {
1668 {"left", u"1"},
1669 {"top", u"2"},
1670 {"right", u"4"},
1671 {"bottom", u"9"}
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]", {
1695 {"left", u"1"},
1696 {"top", u"2"},
1697 {"right", u"5"},
1698 {"bottom", u"6"}
1701 assertXPathAttrs(pDoc, "/metafile/sectregionclipregion[2]", {
1702 {"left", u"1"},
1703 {"top", u"2"},
1704 {"right", u"7"},
1705 {"bottom", u"8"}
1708 assertXPathAttrs(pDoc, "/metafile/sectregionclipregion[3]", {
1709 {"left", u"0"},
1710 {"top", u"3"},
1711 {"right", u"2"},
1712 {"bottom", u"6"}
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]", {
1760 {"horzmove", u"1"},
1761 {"vertmove", u"2"}
1764 assertXPathAttrs(pDoc, "/metafile/moveclipregion[2]", {
1765 {"horzmove", u"-3"},
1766 {"vertmove", u"-4"}
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);
1779 aRegion.Move(2, 2);
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));
1806 pVirtualDev->Pop();
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));
1829 pVirtualDev->Pop();
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));
1915 pVirtualDev->Pop();
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"},
1948 {"x", u"0"},
1949 {"y", u"0"},
1950 {"scalex", u"(1/1)"},
1951 {"scaley", u"(1/1)"}
1954 assertXPathAttrs(pDoc, "/metafile/mapmode[2]", {
1955 {"mapunit", u"Map100thInch"},
1956 {"x", u"0"},
1957 {"y", u"1"},
1958 {"scalex", u"(1/2)"},
1959 {"scaley", u"(2/3)"}
1962 assertXPathAttrs(pDoc, "/metafile/mapmode[3]", {
1963 {"mapunit", u"MapRelative"},
1964 {"x", u"0"},
1965 {"y", u"-1"},
1966 {"scalex", u"(25/12)"},
1967 {"scaley", u"(25/16)"}
1971 void SvmTest::testMapMode()
1973 if (!IsDefaultDPI())
1974 return;
1975 GDIMetaFile aGDIMetafile;
1976 ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
1977 setupBaseVirtualDevice(*pVirtualDev, aGDIMetafile);
1979 MapMode aMapMode;
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);
1990 MapMode aMapMode2;
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"},
2006 {"width", u"12"},
2007 {"height", u"12"},
2008 {"orientation", u"50"},
2009 {"weight", u"thin"},
2010 {"vertical", u"true"},
2013 #endif
2015 void SvmTest::testFont()
2017 #if HAVE_MORE_FONTS
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"));
2034 #endif // _WIN32
2035 #endif
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));
2068 pVirtualDev->Pop();
2069 pVirtualDev->Pop();
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]", {
2142 {"x", u"1"},
2143 {"y", u"2"},
2144 {"width", u"3"},
2145 {"height", u"4"},
2146 {"transparent", u"true"}
2149 assertXPathAttrs(pDoc, "/metafile/floattransparent[1]/gradient[1]", {
2150 {"style", u"Linear"},
2151 {"startcolor", u"#ffffff"},
2152 {"endcolor", u"#000000"},
2153 {"angle", u"0"},
2154 {"border", u"0"},
2155 {"offsetx", u"50"},
2156 {"offsety", u"50"},
2157 {"startintensity", u"100"},
2158 {"endintensity", u"100"},
2159 {"steps", u"0"}
2162 assertXPathAttrs(pDoc, "/metafile/floattransparent[1]/metafile[1]/point[1]", {
2163 {"x", u"1"},
2164 {"y", u"8"}
2167 assertXPathAttrs(pDoc, "/metafile/floattransparent[1]/metafile[1]/point[2]", {
2168 {"x", u"2"},
2169 {"y", u"7"}
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]", {
2199 {"x", u"1"},
2200 {"y", u"8"},
2201 {"width", u"2"},
2202 {"height", u"7"}
2205 assertXPathAttrs(pDoc, "/metafile/eps[1]/gfxlink[1]", {
2206 {"width", u"3"},
2207 {"height", u"6"},
2208 {"type", u"EpsBuffer"},
2209 {"userid", u"12345"},
2210 {"datasize", u"3"},
2211 {"data", u"616263"},
2212 {"native", u"false"},
2213 {"emf", u"false"},
2214 {"validmapmode", u"true"}
2217 assertXPathAttrs(pDoc, "/metafile/eps[1]/gfxlink[1]/prefmapmode[1]", {
2218 {"mapunit", u"Map100thInch"},
2219 {"x", u"0"},
2220 {"y", u"1"},
2221 {"scalex", u"(1/2)"},
2222 {"scaley", u"(2/3)"}
2225 assertXPathAttrs(pDoc, "/metafile/eps[1]/metafile[1]/point[1]", {
2226 {"x", u"1"},
2227 {"y", u"8"}
2230 assertXPathAttrs(pDoc, "/metafile/eps[1]/metafile[1]/point[2]", {
2231 {"x", u"2"},
2232 {"y", u"7"}
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]", {
2273 {"x", u"0"},
2274 {"y", u"0"},
2275 {"set", u"false"}
2278 assertXPathAttrs(pDoc, "/metafile/refpoint[2]", {
2279 {"x", u"1"},
2280 {"y", u"2"},
2281 {"set", u"true"}
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]", {
2304 {"value", u"0"}
2307 assertXPathContent(pDoc, "/metafile/comment[1]/comment[1]", u"Test comment");
2309 assertXPathAttrs(pDoc, "/metafile/comment[2]", {
2310 {"datasize", u"48"}
2313 assertXPathAttrs(pDoc, "/metafile/comment[2]", {
2314 {"data", u"540068006500730065002000610072006500200073006f006d0065002000740065007300740020006400610074006100"}
2317 assertXPathAttrs(pDoc, "/metafile/comment[2]", {
2318 {"value", u"4"}
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, \
2336 4, \
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: */