include/svx/sdr/primitive2d/sdrdecompositiontools.hxx | 3 - svx/qa/unit/unodraw.cxx | 44 +++++++++++++++++- svx/source/sdr/primitive2d/sdrdecompositiontools.cxx | 5 +- svx/source/table/viewcontactoftableobj.cxx | 34 +++++++++++++ 4 files changed, 81 insertions(+), 5 deletions(-)
New commits: commit 3d851b56d288f8e9fd547848ec93dc450937edcf Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Dec 2 14:09:31 2020 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Dec 11 17:33:54 2020 +0100 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. (cherry picked from commit a75bf43a8d6c5dec6dcc86908c142ceec541aa8c) Conflicts: svx/inc/sdr/primitive2d/sdrdecompositiontools.hxx svx/source/sdr/primitive2d/sdrdecompositiontools.cxx Change-Id: I2bc64fea8062f9d8162b95d1eaccb49c3466b5c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107594 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/include/svx/sdr/primitive2d/sdrdecompositiontools.hxx b/include/svx/sdr/primitive2d/sdrdecompositiontools.hxx index 8635981dc0ae..bf2ec55f8a6f 100644 --- a/include/svx/sdr/primitive2d/sdrdecompositiontools.hxx +++ b/include/svx/sdr/primitive2d/sdrdecompositiontools.hxx @@ -73,7 +73,8 @@ namespace drawinglayer Primitive2DContainer SVX_DLLPUBLIC createEmbeddedShadowPrimitive( const Primitive2DContainer& rContent, const attribute::SdrShadowAttribute& rShadow, - const basegfx::B2DHomMatrix& rObjectMatrix = basegfx::B2DHomMatrix()); + const basegfx::B2DHomMatrix& rObjectMatrix = basegfx::B2DHomMatrix(), + const Primitive2DContainer* pContentForShadow = nullptr); } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/svx/qa/unit/unodraw.cxx b/svx/qa/unit/unodraw.cxx index 302dfcda1db7..d31bba03eb77 100644 --- a/svx/qa/unit/unodraw.cxx +++ b/svx/qa/unit/unodraw.cxx @@ -16,12 +16,23 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/XControlModel.hpp> #include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/text/XTextRange.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> #include <unotools/tempfile.hxx> +#include <svx/unopage.hxx> +#include <vcl/virdev.hxx> +#include <svx/sdr/contact/displayinfo.hxx> +#include <drawinglayer/tools/primitive2dxmldump.hxx> +#include <svx/sdr/contact/viewcontact.hxx> +#include <svx/sdr/contact/viewobjectcontact.hxx> +#include <test/xmltesttools.hxx> + +#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> 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<uno::XComponentContext> mxComponentContext; @@ -134,6 +145,37 @@ CPPUNIT_TEST_FIXTURE(UnodrawTest, testTableShadowDirect) xShapeProps->setPropertyValue("ShadowColor", uno::makeAny(nRed)); CPPUNIT_ASSERT(xShapeProps->getPropertyValue("ShadowColor") >>= nRed); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xff0000), nRed); + + // Add text. + uno::Reference<table::XCellRange> xTable(xShapeProps->getPropertyValue("Model"), + uno::UNO_QUERY); + uno::Reference<text::XTextRange> xCell(xTable->getCellByPosition(0, 0), uno::UNO_QUERY); + xCell->setString("A1"); + + // Generates drawinglayer primitives for the shape. + auto pDrawPage = dynamic_cast<SvxDrawPage*>(xDrawPage.get()); + CPPUNIT_ASSERT(pDrawPage); + SdrPage* pSdrPage = pDrawPage->GetSdrPage(); + ScopedVclPtrInstance<VirtualDevice> 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::tools::Primitive2dXmlDump aDumper; + xmlDocPtr 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); } } diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx index 48575d3b4917..1112230b78ba 100644 --- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx @@ -483,7 +483,8 @@ namespace drawinglayer Primitive2DContainer createEmbeddedShadowPrimitive( const Primitive2DContainer& rContent, const attribute::SdrShadowAttribute& rShadow, - const basegfx::B2DHomMatrix& rObjectMatrix) + const basegfx::B2DHomMatrix& rObjectMatrix, + const Primitive2DContainer* pContentForShadow) { if(!rContent.empty()) { @@ -522,7 +523,7 @@ namespace drawinglayer new ShadowPrimitive2D( aShadowOffset, rShadow.getColor(), - rContent)); + (pContentForShadow ? *pContentForShadow : rContent))); if(0.0 != rShadow.getTransparence()) { diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx index 10a6173fab56..6580c6d062f7 100644 --- a/svx/source/table/viewcontactoftableobj.cxx +++ b/svx/source/table/viewcontactoftableobj.cxx @@ -40,6 +40,7 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <svx/framelink.hxx> #include <svx/framelinkarray.hxx> +#include <svx/sdooitm.hxx> #include <vcl/canvastools.hxx> #include <cell.hxx> @@ -210,6 +211,7 @@ namespace sdr // directly to aRetval, Border info to aBorderSequence and added // later to get the correct overlapping drawinglayer::primitive2d::Primitive2DContainer aRetval; + drawinglayer::primitive2d::Primitive2DContainer aRetvalForShadow; const sal_Int32 nRowCount(xTable->getRowCount()); const sal_Int32 nColCount(xTable->getColumnCount()); const sal_Int32 nAllCount(nRowCount * nColCount); @@ -322,6 +324,16 @@ namespace sdr aCellMatrix, aAttribute)); aRetval.append(xCellReference); } + + // Create cell primitive without text. + aAttribute + = drawinglayer::primitive2d::createNewSdrFillTextAttribute( + rCellItemSet, nullptr); + const drawinglayer::primitive2d::Primitive2DReference + xCellReference( + new drawinglayer::primitive2d::SdrCellPrimitive2D( + aCellMatrix, aAttribute)); + aRetvalForShadow.append(xCellReference); } } } @@ -369,6 +381,10 @@ namespace sdr new drawinglayer::primitive2d::TransformPrimitive2D( aTransform, aCellBorderPrimitives)); + + // Borders are always the same for shadow as well. + aRetvalForShadow.append(new drawinglayer::primitive2d::TransformPrimitive2D( + aTransform, aCellBorderPrimitives)); } } @@ -381,7 +397,23 @@ namespace sdr if(!aNewShadowAttribute.isDefault()) { - aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive(aRetval, aNewShadowAttribute); + bool bDirectShadow + = rObjectItemSet.Get(SDRATTR_SHADOW, /*bSrchInParent=*/false) + .GetValue(); + if (bDirectShadow) + { + // Shadow as direct formatting: no shadow for text, to be compatible + // with PowerPoint. + basegfx::B2DHomMatrix aMatrix; + aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive( + aRetval, aNewShadowAttribute, aMatrix, &aRetvalForShadow); + } + else + { + // Shadow as style: shadow for text, to be backwards-compatible. + aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive( + aRetval, aNewShadowAttribute); + } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits