nss: upgrade to release 3.73
[LibreOffice.git] / svx / qa / unit / table.cxx
blobf65118e536c6ef003ed29401bc0c8351498076ed
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/.
8 */
10 #include <test/bootstrapfixture.hxx>
11 #include <unotest/macros_test.hxx>
12 #include <test/xmltesttools.hxx>
14 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
15 #include <com/sun/star/drawing/XDrawPage.hpp>
16 #include <com/sun/star/frame/Desktop.hpp>
18 #include <drawinglayer/tools/primitive2dxmldump.hxx>
19 #include <rtl/ustring.hxx>
20 #include <svx/sdr/contact/displayinfo.hxx>
21 #include <svx/sdr/contact/viewcontact.hxx>
22 #include <svx/sdr/contact/viewobjectcontact.hxx>
23 #include <svx/svdpage.hxx>
24 #include <svx/unopage.hxx>
25 #include <vcl/virdev.hxx>
26 #include <sdr/contact/objectcontactofobjlistpainter.hxx>
28 using namespace ::com::sun::star;
30 namespace
32 /// Tests for svx/source/table/ code.
33 class Test : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
35 protected:
36 uno::Reference<lang::XComponent> mxComponent;
38 public:
39 virtual void setUp() override
41 test::BootstrapFixture::setUp();
42 mxDesktop.set(frame::Desktop::create(m_xContext));
45 virtual void tearDown() override
47 if (mxComponent.is())
49 mxComponent->dispose();
51 test::BootstrapFixture::tearDown();
53 uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
55 drawinglayer::primitive2d::Primitive2DContainer
56 renderPageToPrimitives(const uno::Reference<drawing::XDrawPage>& xDrawPage);
59 drawinglayer::primitive2d::Primitive2DContainer
60 Test::renderPageToPrimitives(const uno::Reference<drawing::XDrawPage>& xDrawPage)
62 auto pDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPage.get());
63 CPPUNIT_ASSERT(pDrawPage);
64 SdrPage* pSdrPage = pDrawPage->GetSdrPage();
65 ScopedVclPtrInstance<VirtualDevice> aVirtualDevice;
66 sdr::contact::ObjectContactOfObjListPainter aObjectContact(*aVirtualDevice,
67 { pSdrPage->GetObj(0) }, nullptr);
68 const sdr::contact::ViewObjectContact& rDrawPageVOContact
69 = pSdrPage->GetViewContact().GetViewObjectContact(aObjectContact);
70 sdr::contact::DisplayInfo aDisplayInfo;
71 return rDrawPageVOContact.getPrimitive2DSequenceHierarchy(aDisplayInfo);
74 CPPUNIT_TEST_FIXTURE(Test, testTableShadowBlur)
76 // Given a document containing a table with a blurry shadow:
77 test::Directories aDirectories;
78 OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/table-shadow-blur.pptx");
79 getComponent() = loadFromDesktop(aURL);
81 // When rendering the table shadow to primitives:
82 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
83 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
84 uno::UNO_QUERY);
85 drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence
86 = renderPageToPrimitives(xDrawPage);
88 // Then make sure that the cell fill part of the shadow is excluded from blurring:
89 drawinglayer::Primitive2dXmlDump aDumper;
90 xmlDocUniquePtr pDocument = aDumper.dumpAndParse(xPrimitiveSequence);
91 // Without the accompanying fix in place, this test would have failed with:
92 // - number of nodes is incorrect
93 // - Expected: 1
94 // - Actual : 0
95 // i.e. the shadow itself was not transparent and that resulted in a non-transparent rendering
96 // as well, while the rendering transparency should be based on the transparency of the shadow
97 // itself and the transparency of the cell fill.
98 assertXPath(pDocument, "//objectinfo/unifiedtransparence[1]", "transparence", "0.8");
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */