/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include #include #include #include #include #include namespace { using namespace css::uno; using namespace css::io; using namespace css::graphic; using drawinglayer::primitive2d::arePrimitive2DSequencesEqual; class Test : public test::BootstrapFixture, public XmlTestTools { void checkRectPrimitive(css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > >& rPrimitive); void testStyles(); css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > parseSvg(const char* aSource); public: virtual void setUp() SAL_OVERRIDE; virtual void tearDown() SAL_OVERRIDE; CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testStyles); CPPUNIT_TEST_SUITE_END(); }; css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > Test::parseSvg(const char* aSource) { const Reference xSvgParser = SvgTools::create(m_xContext); OUString aUrl = getURLFromSrc(aSource); OUString aPath = getPathFromSrc(aSource); SvFileStream aFileStream(aUrl, StreamMode::READ); sal_Size nSize = aFileStream.remainingSize(); std::unique_ptr pBuffer(new sal_Int8[nSize + 1]); aFileStream.Read(pBuffer.get(), nSize); pBuffer[nSize] = 0; Sequence aData(pBuffer.get(), nSize + 1); Reference aInputStream(new comphelper::SequenceInputStream(aData)); return xSvgParser->getDecomposition(aInputStream, aPath); } void Test::setUp() { BootstrapFixture::setUp(); } void Test::tearDown() { BootstrapFixture::tearDown(); } void Test::checkRectPrimitive(css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > >& rPrimitive) { Primitive2dXmlDump dumper; xmlDocPtr pDocument = dumper.dumpAndParse(rPrimitive); CPPUNIT_ASSERT (pDocument); assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00cc00"); // rect background color assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#ff0000"); // rect stroke color assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "3"); // rect stroke width } // Attributes for an object (like rect as in this case) can be defined // in different ways (directly with xml attributes, or with CSS styles), // however the end result should be the same. void Test::testStyles() { css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > aSequenceRect = parseSvg("/svgio/qa/cppunit/data/Rect.svg"); CPPUNIT_ASSERT_EQUAL(1, (int) aSequenceRect.getLength()); checkRectPrimitive(aSequenceRect); css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > aSequenceRectWithStyle = parseSvg("/svgio/qa/cppunit/data/RectWithStyles.svg"); CPPUNIT_ASSERT_EQUAL(1, (int) aSequenceRectWithStyle.getLength()); checkRectPrimitive(aSequenceRectWithStyle); css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > aSequenceRectWithParentStyle = parseSvg("/svgio/qa/cppunit/data/RectWithParentStyles.svg"); CPPUNIT_ASSERT_EQUAL(1, (int) aSequenceRectWithParentStyle.getLength()); checkRectPrimitive(aSequenceRectWithParentStyle); css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > aSequenceRectWithStylesByGroup = parseSvg("/svgio/qa/cppunit/data/RectWithStylesByGroup.svg"); CPPUNIT_ASSERT_EQUAL(1, (int) aSequenceRectWithStylesByGroup.getLength()); checkRectPrimitive(aSequenceRectWithStylesByGroup); CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, aSequenceRectWithStyle)); CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, aSequenceRectWithParentStyle)); CPPUNIT_ASSERT(arePrimitive2DSequencesEqual(aSequenceRect, aSequenceRectWithStylesByGroup)); } CPPUNIT_TEST_SUITE_REGISTRATION(Test); } CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ n> LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-11-22 15:21:34 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-12-23 15:23:06 +0100
commit31427786778946b9d6f0f23731fdaae40e967e21 (patch)
tree7f5712a7df400b6d8644e20f325b54e2f1d6b0a6 /i18npool/source/localedata/data/en_US.xml
parentb8ea5a835ec07d0f84cd8ec2d0dab976edcfcebe (diff)
pdf: move PDFStructureWriter into own file, rename to COSWriter HEADmaster
This needs to duplicate some functions from pdfwriter_impl to make this possible. Change-Id: Ie738c9690306d6498c883f034a3fcd6483f24eef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176985 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178762 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>