svx/qa/unit/data/tdf150020-shadow-alignment.pptx |binary svx/qa/unit/sdr.cxx | 81 ++++++++++++++--------- svx/source/table/viewcontactoftableobj.cxx | 54 ++++++++------- 3 files changed, 81 insertions(+), 54 deletions(-)
New commits: commit fcf776a09a2c5cd692480c8ec4a678e3d04739c9 Author: Sarper Akdemir <sarper.akde...@collabora.com> AuthorDate: Wed Apr 19 15:17:27 2023 +0300 Commit: Sarper Akdemir <sarper.akde...@collabora.com> CommitDate: Wed Apr 19 19:06:54 2023 +0200 tdf#150020: pass transform and scale matrix for the table shadow primitive Shadow scaling related bits in createEmbeddedShadowPrimitive, requires the ObjectMatrix with scale and translate. Pass these in for table shadow creation too. Change-Id: I28c30fe49d3c90e3ca03fb5294ca97eb5ba22773 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150639 Tested-by: Jenkins Reviewed-by: Sarper Akdemir <sarper.akde...@collabora.com> diff --git a/svx/qa/unit/data/tdf150020-shadow-alignment.pptx b/svx/qa/unit/data/tdf150020-shadow-alignment.pptx index caba1a122da5..0002667bd4d9 100644 Binary files a/svx/qa/unit/data/tdf150020-shadow-alignment.pptx and b/svx/qa/unit/data/tdf150020-shadow-alignment.pptx differ diff --git a/svx/qa/unit/sdr.cxx b/svx/qa/unit/sdr.cxx index b98df8b58041..4d6c4226d11b 100644 --- a/svx/qa/unit/sdr.cxx +++ b/svx/qa/unit/sdr.cxx @@ -85,46 +85,67 @@ CPPUNIT_TEST_FIXTURE(SdrTest, testShadowAlignment) loadFromURL(u"tdf150020-shadow-alignment.pptx"); uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), - uno::UNO_QUERY); - drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence - = renderPageToPrimitives(xDrawPage); + { + // Page 1 contains 9 shapes with each shadow alignment + uno::Reference<drawing::XDrawPage> xDrawPage( + xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); + drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence + = renderPageToPrimitives(xDrawPage); - // Examine the created primitives. - drawinglayer::Primitive2dXmlDump aDumper; - xmlDocUniquePtr pDocument = aDumper.dumpAndParse(xPrimitiveSequence); + // Examine the created primitives. + drawinglayer::Primitive2dXmlDump aDumper; + xmlDocUniquePtr pDocument = aDumper.dumpAndParse(xPrimitiveSequence); - // Without the accompanying fix in place, this test would have failed with: - // - Expected: -567 - // - Actual : 162 - // - In <>, attribute 'xy13' of '(//shadow/transform)[1]' incorrect value. - // i.e. shadow alignment was ignored while scaling the shadow. - assertXPath(pDocument, "(//shadow/transform)[1]", "xy13", "-567"); - assertXPath(pDocument, "(//shadow/transform)[1]", "xy23", "162"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: -567 + // - Actual : 162 + // - In <>, attribute 'xy13' of '(//shadow/transform)[1]' incorrect value. + // i.e. shadow alignment was ignored while scaling the shadow. + assertXPath(pDocument, "(//shadow/transform)[1]", "xy13", "-567"); + assertXPath(pDocument, "(//shadow/transform)[1]", "xy23", "162"); - assertXPath(pDocument, "(//shadow/transform)[2]", "xy13", "-1794"); - assertXPath(pDocument, "(//shadow/transform)[2]", "xy23", "162"); + assertXPath(pDocument, "(//shadow/transform)[2]", "xy13", "-1794"); + assertXPath(pDocument, "(//shadow/transform)[2]", "xy23", "162"); - assertXPath(pDocument, "(//shadow/transform)[3]", "xy13", "-3021"); - assertXPath(pDocument, "(//shadow/transform)[3]", "xy23", "161"); + assertXPath(pDocument, "(//shadow/transform)[3]", "xy13", "-3021"); + assertXPath(pDocument, "(//shadow/transform)[3]", "xy23", "161"); - assertXPath(pDocument, "(//shadow/transform)[4]", "xy13", "-567"); - assertXPath(pDocument, "(//shadow/transform)[4]", "xy23", "-749"); + assertXPath(pDocument, "(//shadow/transform)[4]", "xy13", "-567"); + assertXPath(pDocument, "(//shadow/transform)[4]", "xy23", "-749"); - assertXPath(pDocument, "(//shadow/transform)[5]", "xy13", "-3021"); - assertXPath(pDocument, "(//shadow/transform)[5]", "xy23", "-750"); + assertXPath(pDocument, "(//shadow/transform)[5]", "xy13", "-3021"); + assertXPath(pDocument, "(//shadow/transform)[5]", "xy23", "-750"); - assertXPath(pDocument, "(//shadow/transform)[6]", "xy13", "-566"); - assertXPath(pDocument, "(//shadow/transform)[6]", "xy23", "-1691"); + assertXPath(pDocument, "(//shadow/transform)[6]", "xy13", "-566"); + assertXPath(pDocument, "(//shadow/transform)[6]", "xy23", "-1691"); - assertXPath(pDocument, "(//shadow/transform)[7]", "xy13", "-1794"); - assertXPath(pDocument, "(//shadow/transform)[7]", "xy23", "-1693"); + assertXPath(pDocument, "(//shadow/transform)[7]", "xy13", "-1794"); + assertXPath(pDocument, "(//shadow/transform)[7]", "xy23", "-1693"); - assertXPath(pDocument, "(//shadow/transform)[8]", "xy13", "-3022"); - assertXPath(pDocument, "(//shadow/transform)[8]", "xy23", "-1691"); + assertXPath(pDocument, "(//shadow/transform)[8]", "xy13", "-3022"); + assertXPath(pDocument, "(//shadow/transform)[8]", "xy23", "-1691"); - assertXPath(pDocument, "(//shadow/transform)[9]", "xy13", "-1794"); - assertXPath(pDocument, "(//shadow/transform)[9]", "xy23", "-750"); + assertXPath(pDocument, "(//shadow/transform)[9]", "xy13", "-1794"); + assertXPath(pDocument, "(//shadow/transform)[9]", "xy23", "-750"); + } + { + // Page 2 contains a table with shadow alignment center + uno::Reference<drawing::XDrawPage> xDrawPage( + xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY); + drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence + = renderPageToPrimitives(xDrawPage); + + // Examine the created primitives. + drawinglayer::Primitive2dXmlDump aDumper; + xmlDocUniquePtr pDocument = aDumper.dumpAndParse(xPrimitiveSequence); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: -5196 + // - Actual : 0 + // - In<>, attribute 'xy13' of '//shadow/transform' incorrect value. + assertXPath(pDocument, "//shadow/transform", "xy13", "-5196"); + assertXPath(pDocument, "//shadow/transform", "xy23", "-2290"); + } } CPPUNIT_TEST_FIXTURE(SdrTest, testZeroWidthTextWrap) diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx index 3f17c5ccae21..5b9418ab06bf 100644 --- a/svx/source/table/viewcontactoftableobj.cxx +++ b/svx/source/table/viewcontactoftableobj.cxx @@ -448,33 +448,39 @@ namespace sdr::contact aRetvalForShadow.append(new drawinglayer::primitive2d::TransformPrimitive2D( aTransform, std::move(aCellBorderPrimitives))); } - } - - if(!aRetval.empty()) - { - // check and create evtl. shadow for created content - const SfxItemSet& rObjectItemSet = rTableObj.GetMergedItemSet(); - const drawinglayer::attribute::SdrShadowAttribute aNewShadowAttribute( - drawinglayer::primitive2d::createNewSdrShadowAttribute(rObjectItemSet)); - if(!aNewShadowAttribute.isDefault()) + if(!aRetval.empty()) { - 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( - std::move(aRetval), aNewShadowAttribute, aMatrix, &aRetvalForShadow); - } - else + // check and create evtl. shadow for created content + const SfxItemSet& rObjectItemSet = rTableObj.GetMergedItemSet(); + const drawinglayer::attribute::SdrShadowAttribute aNewShadowAttribute( + drawinglayer::primitive2d::createNewSdrShadowAttribute(rObjectItemSet)); + + if(!aNewShadowAttribute.isDefault()) { - // Shadow as style: shadow for text, to be backwards-compatible. - aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive( - std::move(aRetval), aNewShadowAttribute); + // pass in table's transform and scale matrix, to + // correctly scale and align shadows + const basegfx::B2DHomMatrix aTransformScaleMatrix + = basegfx::utils::createScaleTranslateB2DHomMatrix( + aObjectRange.getRange(), aObjectRange.getMinimum()); + + bool bDirectShadow + = rObjectItemSet.Get(SDRATTR_SHADOW, /*bSrchInParent=*/false) + .GetValue(); + if (bDirectShadow) + { + // Shadow as direct formatting: no shadow for text, to be compatible + // with PowerPoint. + aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive( + std::move(aRetval), aNewShadowAttribute, aTransformScaleMatrix, + &aRetvalForShadow); + } + else + { + // Shadow as style: shadow for text, to be backwards-compatible. + aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive( + std::move(aRetval), aNewShadowAttribute, aTransformScaleMatrix); + } } } }