summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-09-20 11:26:53 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-09-28 19:19:19 +0200
commit52524e52e8f061aa3f0c63219d954d2d5aefd059 (patch)
tree4e1a6bfbe086aa1a0659f51f4b840b694c52f926 /svx
parent9e634c0987738ff2951ab82d7690a8e91c7e952e (diff)
tdf#144091 svx: fix unwanted blur of shadow from table cell fill
Initial render support for shadows of table shapes were added in commit a75bf43a8d6c5dec6dcc86908c142ceec541aa8c (tdf#129961 svx: add rendering for table shadow as direct format, 2020-12-02). That already noticed a trick with the shadow of table shapes: the shadow is generate from the cell fill and the border, but not from the text. An additional trick is that when blur is enabled for the table shape's shadow, then only the border should be blurred, not the cell fill. In the bug document's case, the effective cell background was gray, with a semi-transparent red shadow. We used to render cc0000 with blur and cccccc without blur, now we correctly render cca3a3, matching PowerPoint. (cherry picked from commit 37a52d30bbfcf1d073779b50139c4dafa507be4b) Conflicts: drawinglayer/source/primitive2d/shadowprimitive2d.cxx drawinglayer/source/tools/primitive2dxmldump.cxx include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx Change-Id: I7326a5f6254cf19b2d05181084c78e734ff7a7b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122383 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122760 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/CppunitTest_svx_unit.mk1
-rw-r--r--svx/qa/unit/data/table-shadow-blur.pptxbin0 -> 33745 bytes
-rw-r--r--svx/qa/unit/table.cxx100
-rw-r--r--svx/source/table/viewcontactoftableobj.cxx13
4 files changed, 109 insertions, 5 deletions
diff --git a/svx/CppunitTest_svx_unit.mk b/svx/CppunitTest_svx_unit.mk
index 598d788392b4..7401d37808b9 100644
--- a/svx/CppunitTest_svx_unit.mk
+++ b/svx/CppunitTest_svx_unit.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \
svx/qa/unit/classicshapes \
svx/qa/unit/sdr \
svx/qa/unit/svdraw \
+ svx/qa/unit/table \
svx/qa/unit/unodraw \
svx/qa/unit/xoutdev \
svx/qa/unit/XTableImportExportTest \
diff --git a/svx/qa/unit/data/table-shadow-blur.pptx b/svx/qa/unit/data/table-shadow-blur.pptx
new file mode 100644
index 000000000000..959940e09296
--- /dev/null
+++ b/svx/qa/unit/data/table-shadow-blur.pptx
Binary files differ
diff --git a/svx/qa/unit/table.cxx b/svx/qa/unit/table.cxx
new file mode 100644
index 000000000000..4419892a42ba
--- /dev/null
+++ b/svx/qa/unit/table.cxx
@@ -0,0 +1,100 @@
+/* -*- 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 <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <test/xmltesttools.hxx>
+
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+
+#include <drawinglayer/tools/primitive2dxmldump.hxx>
+#include <rtl/ustring.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/unopage.hxx>
+#include <vcl/virdev.hxx>
+#include <sdr/contact/objectcontactofobjlistpainter.hxx>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+/// Tests for svx/source/table/ code.
+class Test : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
+{
+protected:
+ uno::Reference<lang::XComponent> mxComponent;
+
+public:
+ virtual void setUp() override
+ {
+ test::BootstrapFixture::setUp();
+ mxDesktop.set(frame::Desktop::create(m_xContext));
+ }
+
+ virtual void tearDown() override
+ {
+ if (mxComponent.is())
+ {
+ mxComponent->dispose();
+ }
+ test::BootstrapFixture::tearDown();
+ }
+ uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+
+ drawinglayer::primitive2d::Primitive2DContainer
+ renderPageToPrimitives(const uno::Reference<drawing::XDrawPage>& xDrawPage);
+};
+
+drawinglayer::primitive2d::Primitive2DContainer
+Test::renderPageToPrimitives(const uno::Reference<drawing::XDrawPage>& xDrawPage)
+{
+ 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;
+ return rDrawPageVOContact.getPrimitive2DSequenceHierarchy(aDisplayInfo);
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTableShadowBlur)
+{
+ // Given a document containing a table with a blurry shadow:
+ test::Directories aDirectories;
+ OUString aURL = aDirectories.getURLFromSrc(u"svx/qa/unit/data/table-shadow-blur.pptx");
+ getComponent() = loadFromDesktop(aURL);
+
+ // When rendering the table shadow to primitives:
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+ drawinglayer::primitive2d::Primitive2DContainer xPrimitiveSequence
+ = renderPageToPrimitives(xDrawPage);
+
+ // Then make sure that the cell fill part of the shadow is excluded from blurring:
+ drawinglayer::Primitive2dXmlDump aDumper;
+ xmlDocUniquePtr pDocument = aDumper.dumpAndParse(xPrimitiveSequence);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: true
+ // - Actual : false
+ // i.e. blur was applied on both the cell fill and the cell border.
+ assertXPath(pDocument, "//shadow/transform/modifiedColor/sdrCell[1]", "excludeFromBlur",
+ "true");
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx
index bd950a02f7fb..409e099ae3e5 100644
--- a/svx/source/table/viewcontactoftableobj.cxx
+++ b/svx/source/table/viewcontactoftableobj.cxx
@@ -320,14 +320,16 @@ namespace sdr::contact
aRetval.append(xCellReference);
}
- // Create cell primitive without text.
+ // Create cell primitive without text and blur.
aAttribute
= drawinglayer::primitive2d::createNewSdrFillTextAttribute(
rCellItemSet, nullptr);
+ rtl::Reference pCellReference
+ = new drawinglayer::primitive2d::SdrCellPrimitive2D(
+ aCellMatrix, aAttribute);
+ pCellReference->setExcludeFromBlur(true);
const drawinglayer::primitive2d::Primitive2DReference
- xCellReference(
- new drawinglayer::primitive2d::SdrCellPrimitive2D(
- aCellMatrix, aAttribute));
+ xCellReference(pCellReference.get());
aRetvalForShadow.append(xCellReference);
}
}
@@ -377,7 +379,8 @@ namespace sdr::contact
aTransform,
aCellBorderPrimitives));
- // Borders are always the same for shadow as well.
+ // Borders are always the same for shadow as well, and implicitly included
+ // in blur.
aRetvalForShadow.append(new drawinglayer::primitive2d::TransformPrimitive2D(
aTransform, aCellBorderPrimitives));
}