summaryrefslogtreecommitdiffstats
path: root/oox/source/drawingml/effectproperties.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /oox/source/drawingml/effectproperties.cxx
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'oox/source/drawingml/effectproperties.cxx')
-rw-r--r--oox/source/drawingml/effectproperties.cxx132
1 files changed, 132 insertions, 0 deletions
diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx
new file mode 100644
index 000000000..88d69a16d
--- /dev/null
+++ b/oox/source/drawingml/effectproperties.cxx
@@ -0,0 +1,132 @@
+/* -*- 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 "effectproperties.hxx"
+#include <oox/drawingml/drawingmltypes.hxx>
+#include <oox/helper/graphichelper.hxx>
+#include <oox/token/properties.hxx>
+
+#include <basegfx/numeric/ftools.hxx>
+#include <comphelper/propertyvalue.hxx>
+
+#include <algorithm>
+
+namespace oox::drawingml {
+
+void EffectGlowProperties ::assignUsed(const EffectGlowProperties& rSourceProps)
+{
+ moGlowRad.assignIfUsed( rSourceProps.moGlowRad );
+ moGlowColor.assignIfUsed( rSourceProps.moGlowColor );
+}
+
+void EffectSoftEdgeProperties::assignUsed(const EffectSoftEdgeProperties& rSourceProps)
+{
+ moRad.assignIfUsed(rSourceProps.moRad);
+}
+
+void EffectShadowProperties::assignUsed(const EffectShadowProperties& rSourceProps)
+{
+ moShadowDist.assignIfUsed( rSourceProps.moShadowDist );
+ moShadowDir.assignIfUsed( rSourceProps.moShadowDir );
+ moShadowSx.assignIfUsed( rSourceProps.moShadowSx );
+ moShadowSy.assignIfUsed( rSourceProps.moShadowSy );
+ moShadowColor.assignIfUsed( rSourceProps.moShadowColor );
+ moShadowBlur.assignIfUsed( rSourceProps.moShadowBlur );
+
+}
+
+void EffectProperties::assignUsed( const EffectProperties& rSourceProps )
+{
+ maShadow.assignUsed(rSourceProps.maShadow);
+ maGlow.assignUsed(rSourceProps.maGlow);
+ maSoftEdge.assignUsed(rSourceProps.maSoftEdge);
+ if (!rSourceProps.m_Effects.empty())
+ {
+ m_Effects.clear();
+ m_Effects.reserve(rSourceProps.m_Effects.size());
+ for (auto const& it : rSourceProps.m_Effects)
+ {
+ m_Effects.push_back(std::make_unique<Effect>(*it));
+ }
+ }
+}
+
+void EffectProperties::pushToPropMap( PropertyMap& rPropMap,
+ const GraphicHelper& rGraphicHelper ) const
+{
+ for (auto const& it : m_Effects)
+ {
+ if( it->msName == "outerShdw" )
+ {
+ sal_Int32 nAttrDir = 0, nAttrDist = 0;
+ sal_Int32 nAttrSizeX = 100000, nAttrSizeY = 100000; // If shadow size is %100=100000 (means equal to object's size), sx sy is not exists,
+ // Default values of sx, sy should be 100000 in this case.
+ sal_Int32 nAttrBlur = 0;
+
+ std::map< OUString, css::uno::Any >::const_iterator attribIt = it->maAttribs.find( "dir" );
+ if( attribIt != it->maAttribs.end() )
+ attribIt->second >>= nAttrDir;
+
+ attribIt = it->maAttribs.find( "dist" );
+ if( attribIt != it->maAttribs.end() )
+ attribIt->second >>= nAttrDist;
+
+ attribIt = it->maAttribs.find( "sx" );
+ if( attribIt != it->maAttribs.end() )
+ attribIt->second >>= nAttrSizeX;
+
+ attribIt = it->maAttribs.find( "sy" );
+ if( attribIt != it->maAttribs.end() )
+ attribIt->second >>= nAttrSizeY;
+
+ attribIt = it->maAttribs.find( "blurRad" );
+ if( attribIt != it->maAttribs.end() )
+ attribIt->second >>= nAttrBlur;
+
+ // Negative X or Y dist indicates left or up, respectively
+ // Negative X or Y dist indicates left or up, respectively
+ double nAngle = basegfx::deg2rad(static_cast<double>(nAttrDir) / PER_DEGREE);
+ sal_Int32 nDist = convertEmuToHmm( nAttrDist );
+ sal_Int32 nXDist = cos(nAngle) * nDist;
+ sal_Int32 nYDist = sin(nAngle) * nDist;
+
+
+ rPropMap.setProperty( PROP_Shadow, true );
+ rPropMap.setProperty( PROP_ShadowXDistance, nXDist);
+ rPropMap.setProperty( PROP_ShadowYDistance, nYDist);
+ rPropMap.setProperty( PROP_ShadowSizeX, nAttrSizeX);
+ rPropMap.setProperty( PROP_ShadowSizeY, nAttrSizeY);
+ rPropMap.setProperty( PROP_ShadowColor, it->moColor.getColor(rGraphicHelper ) );
+ rPropMap.setProperty( PROP_ShadowTransparence, it->moColor.getTransparency());
+ rPropMap.setProperty( PROP_ShadowBlur, convertEmuToHmm(nAttrBlur));
+
+ }
+ }
+}
+
+css::beans::PropertyValue Effect::getEffect()
+{
+ css::beans::PropertyValue aRet;
+ if( msName.isEmpty() )
+ return aRet;
+
+ css::uno::Sequence< css::beans::PropertyValue > aSeq( maAttribs.size() );
+ std::transform(maAttribs.begin(), maAttribs.end(), aSeq.getArray(),
+ [](const auto& attrib)
+ { return comphelper::makePropertyValue(attrib.first, attrib.second); });
+
+ aRet.Name = msName;
+ aRet.Value <<= aSeq;
+
+ return aRet;
+}
+
+} // namespace oox::drawingml
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */