From a75bf43a8d6c5dec6dcc86908c142ceec541aa8c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 2 Dec 2020 14:09:31 +0100 Subject: tdf#129961 svx: add rendering for table shadow as direct format There was already shadow support in ViewContactOfTableObj::createViewIndependentPrimitive2DSequence(), but the UNO API and UI could only set the shadow properties on a shape style, so shadow-as-direct-format is new. One difference between the PowerPoint shadow and our shadow is that we draw shadow for table text as well, while PowerPoint only does it for the borders / cell fill style. This means we're either backwards-compatible or compatible with PowerPoint. Solve this problem by leaving the style case unchanged, but render direct formatting like PowerPoint. Change-Id: I2bc64fea8062f9d8162b95d1eaccb49c3466b5c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107073 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- svx/qa/unit/unodraw.cxx | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'svx/qa') diff --git a/svx/qa/unit/unodraw.cxx b/svx/qa/unit/unodraw.cxx index 51b1c8b43847..938e44f9ca21 100644 --- a/svx/qa/unit/unodraw.cxx +++ b/svx/qa/unit/unodraw.cxx @@ -16,12 +16,23 @@ #include #include #include +#include +#include #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include + +#include using namespace ::com::sun::star; @@ -30,7 +41,7 @@ namespace char const DATA_DIRECTORY[] = "/svx/qa/unit/data/"; /// Tests for svx/source/unodraw/ code. -class UnodrawTest : public test::BootstrapFixture, public unotest::MacrosTest +class UnodrawTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { protected: uno::Reference mxComponent; @@ -132,6 +143,37 @@ CPPUNIT_TEST_FIXTURE(UnodrawTest, testTableShadowDirect) xShapeProps->setPropertyValue("ShadowColor", uno::makeAny(nRed)); CPPUNIT_ASSERT(xShapeProps->getPropertyValue("ShadowColor") >>= nRed); CPPUNIT_ASSERT_EQUAL(static_cast(0xff0000), nRed); + + // Add text. + uno::Reference xTable(xShapeProps->getPropertyValue("Model"), + uno::UNO_QUERY); + uno::Reference xCell(xTable->getCellByPosition(0, 0), uno::UNO_QUERY); + xCell->setString("A1"); + + // Generates drawinglayer primitives for the shape. + auto pDrawPage = dynamic_cast(xDrawPage.get()); + CPPUNIT_ASSERT(pDrawPage); + SdrPage* pSdrPage = pDrawPage->GetSdrPage(); + ScopedVclPtrInstance aVirtualDevice; + sdr::contact::ObjectContactOfObjListPainter aObjectContact(*aVirtualDevice, + { pSdrPage->GetObj(0) }, nullptr); + const sdr::contact::ViewObjectContact& rDrawPageVOContact + = pSdrPage->GetViewContact().GetViewObjectContact(aObjectContact); + sdr::contact::DisplayInfo aDisplayInfo; + drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence + = rDrawPageVOContact.getPrimitive2DSequenceHierarchy(aDisplayInfo); + + // Check the primitives. + drawinglayer::Primitive2dXmlDump aDumper; + xmlDocUniquePtr pDocument = aDumper.dumpAndParse(xPrimitiveSequence); + assertXPath(pDocument, "//shadow", /*nNumberOfNodes=*/1); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 1 + // i.e. there was shadow for the cell text, while here PowerPoint-compatible output is expected, + // which has no shadow for cell text (only for cell borders and cell background). + assertXPath(pDocument, "//shadow//sdrblocktext", /*nNumberOfNodes=*/0); } } -- cgit