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/.
10 #include <test/unoapi_test.hxx>
12 #include <sfx2/objsh.hxx>
13 #include <sfx2/sfxbasemodel.hxx>
14 #include <vcl/BitmapReadAccess.hxx>
15 #include <vcl/filter/PngImageWriter.hxx>
16 #include <vcl/gdimtf.hxx>
17 #include <tools/stream.hxx>
19 using namespace com::sun::star
;
21 class Test
: public UnoApiTest
25 : UnoApiTest(u
"/cppcanvas/qa/extras/emfplus/data/"_ustr
)
29 Bitmap
load(const char* pName
)
31 loadFromFile(OUString::createFromAscii(pName
));
32 SfxBaseModel
* pModel
= dynamic_cast<SfxBaseModel
*>(mxComponent
.get());
33 CPPUNIT_ASSERT(pModel
);
34 SfxObjectShell
* pShell
= pModel
->GetObjectShell();
35 std::shared_ptr
<GDIMetaFile
> xMetaFile
= pShell
->GetPreviewMetaFile();
36 BitmapEx aResultBitmap
;
37 CPPUNIT_ASSERT(xMetaFile
->CreateThumbnail(aResultBitmap
));
38 // If this is set, the metafile will be dumped as a PNG one for debug purposes.
39 char* pEnv
= getenv("CPPCANVAS_DEBUG_EMFPLUS_DUMP_TO");
42 SvFileStream
aStream(OUString::fromUtf8(pEnv
), StreamMode::WRITE
);
43 vcl::PngImageWriter
aWriter(aStream
);
44 CPPUNIT_ASSERT(aWriter
.write(aResultBitmap
));
47 return aResultBitmap
.GetBitmap();
51 CPPUNIT_TEST_FIXTURE(Test
, testFdo77229
)
53 Bitmap aBitmap
= load("fdo77229.emf");
54 BitmapScopedReadAccess
pAccess(aBitmap
);
55 // The green star was missing.
56 Color
aColor(pAccess
->GetPixel(284, 280));
57 CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), aColor
.GetRed());
58 CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), aColor
.GetBlue());
59 CPPUNIT_ASSERT(aColor
.GetGreen() == 0xfe || aColor
.GetGreen() == 0xff);
62 CPPUNIT_PLUGIN_IMPLEMENT();
64 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */