summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
Diffstat (limited to 'svx')
-rw-r--r--svx/Library_svxcore.mk1
-rw-r--r--svx/qa/unit/data/tdf150020-shadow-alignment.pptxbin0 -> 51529 bytes
-rw-r--r--svx/qa/unit/sdr.cxx47
-rw-r--r--svx/source/items/RectangleAlignmentItem.cxx31
-rw-r--r--svx/source/sdr/primitive2d/sdrattributecreator.cxx5
-rw-r--r--svx/source/sdr/primitive2d/sdrdecompositiontools.cxx45
-rw-r--r--svx/source/svdraw/svdattr.cxx4
7 files changed, 120 insertions, 13 deletions
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 9ecc9ec58fc4..5a7e48a47018 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -219,6 +219,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/items/customshapeitem \
svx/source/items/drawitem \
svx/source/items/e3ditem \
+ svx/source/items/RectangleAlignmentItem \
svx/source/items/galleryitem \
svx/source/items/grfitem \
svx/source/sdr/animation/scheduler \
diff --git a/svx/qa/unit/data/tdf150020-shadow-alignment.pptx b/svx/qa/unit/data/tdf150020-shadow-alignment.pptx
new file mode 100644
index 000000000000..caba1a122da5
--- /dev/null
+++ b/svx/qa/unit/data/tdf150020-shadow-alignment.pptx
Binary files differ
diff --git a/svx/qa/unit/sdr.cxx b/svx/qa/unit/sdr.cxx
index 432eeeaa4999..b98df8b58041 100644
--- a/svx/qa/unit/sdr.cxx
+++ b/svx/qa/unit/sdr.cxx
@@ -80,6 +80,53 @@ CPPUNIT_TEST_FIXTURE(SdrTest, testShadowScaleOrigin)
CPPUNIT_ASSERT_EQUAL(sal_Int32(-684), fShadowY);
}
+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);
+
+ // 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");
+
+ 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)[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)[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)[8]", "xy13", "-3022");
+ assertXPath(pDocument, "(//shadow/transform)[8]", "xy23", "-1691");
+
+ assertXPath(pDocument, "(//shadow/transform)[9]", "xy13", "-1794");
+ assertXPath(pDocument, "(//shadow/transform)[9]", "xy23", "-750");
+}
+
CPPUNIT_TEST_FIXTURE(SdrTest, testZeroWidthTextWrap)
{
// Load a document containing a 0-width shape with text.
diff --git a/svx/source/items/RectangleAlignmentItem.cxx b/svx/source/items/RectangleAlignmentItem.cxx
new file mode 100644
index 000000000000..3b0b7b0f1081
--- /dev/null
+++ b/svx/source/items/RectangleAlignmentItem.cxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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 <svx/RectangleAlignmentItem.hxx>
+#include <docmodel/theme/FormatScheme.hxx>
+
+SvxRectangleAlignmentItem::SvxRectangleAlignmentItem(sal_uInt16 nWhich,
+ model::RectangleAlignment nValue)
+ : SfxEnumItem<model::RectangleAlignment>(nWhich, nValue)
+{
+}
+
+SvxRectangleAlignmentItem::~SvxRectangleAlignmentItem() {}
+
+SvxRectangleAlignmentItem* SvxRectangleAlignmentItem::Clone(SfxItemPool*) const
+{
+ return new SvxRectangleAlignmentItem(*this);
+}
+
+sal_uInt16 SvxRectangleAlignmentItem::GetValueCount() const
+{
+ return model::RECTANGLE_ALIGNMENT_COUNT;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
index e1f6fc10c45a..963bba567f6d 100644
--- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx
+++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
@@ -53,6 +53,7 @@
#include <svx/xflbmtit.hxx>
#include <svx/xflbstit.hxx>
#include <svx/xtextit0.hxx>
+#include <svx/RectangleAlignmentItem.hxx>
#include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
#include <svx/svdotext.hxx>
#include <sdr/attribute/sdrtextattribute.hxx>
@@ -402,7 +403,9 @@ namespace drawinglayer::primitive2d
sal_Int32 nBlur(rSet.Get(SDRATTR_SHADOWBLUR).GetValue());
- return attribute::SdrShadowAttribute(aOffset, aSize, static_cast<double>(nTransparence) * 0.01,nBlur, aColor.getBColor());
+ model::RectangleAlignment eAlignment{rSet.Get(SDRATTR_SHADOWALIGNMENT).GetValue()};
+
+ return attribute::SdrShadowAttribute(aOffset, aSize, static_cast<double>(nTransparence) * 0.01, nBlur, eAlignment, aColor.getBColor());
}
}
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
index 1a5459643006..b5df830d73fe 100644
--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -49,6 +49,7 @@
#include <drawinglayer/attribute/sdrlinestartendattribute.hxx>
#include <drawinglayer/attribute/sdrshadowattribute.hxx>
#include <drawinglayer/attribute/sdrglowattribute.hxx>
+#include <docmodel/theme/FormatScheme.hxx>
#include <osl/diagnose.h>
// for SlideBackgroundFillPrimitive2D
@@ -65,6 +66,35 @@ namespace drawinglayer::primitive2d
{
namespace
{
+/// @returns the offset to apply/unapply to scale according to correct origin for a given alignment.
+basegfx::B2DTuple getShadowScaleOriginOffset(const basegfx::B2DTuple& aScale,
+ model::RectangleAlignment eAlignment)
+{
+ switch (eAlignment)
+ {
+ case model::RectangleAlignment::TopLeft:
+ return { 0, 0 };
+ case model::RectangleAlignment::Top:
+ return { aScale.getX() / 2, 0 };
+ case model::RectangleAlignment::TopRight:
+ return { aScale.getX(), 0 };
+ case model::RectangleAlignment::Left:
+ return { 0, aScale.getY() / 2 };
+ case model::RectangleAlignment::Center:
+ return { aScale.getX() / 2, aScale.getY() / 2 };
+ case model::RectangleAlignment::Right:
+ return { aScale.getX(), aScale.getY() / 2 };
+ case model::RectangleAlignment::BottomLeft:
+ return { 0, aScale.getY() };
+ case model::RectangleAlignment::Bottom:
+ return { aScale.getX() / 2, aScale.getY() };
+ case model::RectangleAlignment::BottomRight:
+ return { aScale.getX(), aScale.getY() };
+ default:
+ return { 0, 0 };
+ }
+};
+
// See also: SdrTextObj::AdjustRectToTextDistance
basegfx::B2DRange getTextAnchorRange(const attribute::SdrTextAttribute& rText,
const basegfx::B2DRange& rSnapRange)
@@ -775,19 +805,10 @@ sal_uInt32 SlideBackgroundFillPrimitive2D::getPrimitive2DID() const
double fShearX = 0;
rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
// Scale the shadow
- double nTranslateX = aTranslate.getX();
- double nTranslateY = aTranslate.getY();
-
- // The origin for scaling is the top left corner by default. A negative
- // shadow offset changes the origin.
- if (rShadow.getOffset().getX() < 0)
- nTranslateX += aScale.getX();
- if (rShadow.getOffset().getY() < 0)
- nTranslateY += aScale.getY();
-
- aShadowOffset.translate(-nTranslateX, -nTranslateY);
+ aTranslate += getShadowScaleOriginOffset(aScale, rShadow.getAlignment());
+ aShadowOffset.translate(-aTranslate);
aShadowOffset.scale(rShadow.getSize().getX() * 0.00001, rShadow.getSize().getY() * 0.00001);
- aShadowOffset.translate(nTranslateX, nTranslateY);
+ aShadowOffset.translate(aTranslate);
}
aShadowOffset.translate(rShadow.getOffset().getX(), rShadow.getOffset().getY());
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 1898f13140ae..4cc184246159 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -29,6 +29,8 @@
#include <com/sun/star/drawing/MeasureTextVertPos.hpp>
#include <com/sun/star/drawing/CircleKind.hpp>
+#include <docmodel/theme/FormatScheme.hxx>
+
#include <editeng/boxitem.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/lineitem.hxx>
@@ -95,6 +97,7 @@
#include <svx/sxmtritm.hxx>
#include <svx/sxmuitm.hxx>
#include <svx/xcolit.hxx>
+#include <svx/RectangleAlignmentItem.hxx>
#include <sxoneitm.hxx>
#include <sxopitm.hxx>
#include <sxreaitm.hxx>
@@ -135,6 +138,7 @@ SdrItemPool::SdrItemPool(
rPoolDefaults[SDRATTR_SHADOWSIZEY -SDRATTR_START]=new SdrMetricItem(SDRATTR_SHADOWSIZEY, 100000);
rPoolDefaults[SDRATTR_SHADOWTRANSPARENCE-SDRATTR_START]=new SdrPercentItem(SDRATTR_SHADOWTRANSPARENCE, 0);
rPoolDefaults[SDRATTR_SHADOWBLUR -SDRATTR_START]=new SdrMetricItem(SDRATTR_SHADOWBLUR, 0);
+ rPoolDefaults[SDRATTR_SHADOWALIGNMENT -SDRATTR_START]=new SvxRectangleAlignmentItem(SDRATTR_SHADOWALIGNMENT, model::RectangleAlignment::Unset);
rPoolDefaults[SDRATTR_SHADOW3D -SDRATTR_START]=new SfxVoidItem(SDRATTR_SHADOW3D );
rPoolDefaults[SDRATTR_SHADOWPERSP -SDRATTR_START]=new SfxVoidItem(SDRATTR_SHADOWPERSP );
rPoolDefaults[SDRATTR_CAPTIONTYPE -SDRATTR_START]=new SdrCaptionTypeItem ;