summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-05-08 23:25:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-05-11 00:12:33 +0200
commit5952331844450dad93e21d2e329d51841ae1700e (patch)
treeee95ae8c96b27928ba6ae30620e9e524c1982d3e /oox/source
parentce0933c0d8cc0d51774d0168a8be4e9bb3153463 (diff)
tdf#49247: implement soft edges document model and import/export
... for ODF and OOXML. Two object properties added: SoftEdge (boolean, effect enabled/disabled) SoftEdgeRad (sal_Int32, effect radius in 100ths of mm) Two corresponding ODF attributes added: loext:softedge ("visible"/"hidden") loext:softedge-radius (metric) Change-Id: I0dc4d7fc3e5b0c2c36092d430568ebcfd3a68c9c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93833 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/drawingml/effectproperties.cxx6
-rw-r--r--oox/source/drawingml/effectproperties.hxx8
-rw-r--r--oox/source/drawingml/effectpropertiescontext.cxx8
-rw-r--r--oox/source/drawingml/shape.cxx9
-rw-r--r--oox/source/export/drawingml.cxx32
5 files changed, 55 insertions, 8 deletions
diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx
index dd5fdd0693f9..4d0c7c334ab5 100644
--- a/oox/source/drawingml/effectproperties.cxx
+++ b/oox/source/drawingml/effectproperties.cxx
@@ -22,6 +22,11 @@ void EffectGlowProperties ::assignUsed(const EffectGlowProperties& rSourceProps)
moGlowColor.assignIfUsed( rSourceProps.moGlowColor );
}
+void EffectSoftEdgeProperties::assignUsed(const EffectSoftEdgeProperties& rSourceProps)
+{
+ moRad.assignIfUsed(rSourceProps.moRad);
+}
+
void EffectShadowProperties::assignUsed(const EffectShadowProperties& rSourceProps)
{
moShadowDist.assignIfUsed( rSourceProps.moShadowDist );
@@ -35,6 +40,7 @@ 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();
diff --git a/oox/source/drawingml/effectproperties.hxx b/oox/source/drawingml/effectproperties.hxx
index e1e42d485789..2d2b20e2e8e5 100644
--- a/oox/source/drawingml/effectproperties.hxx
+++ b/oox/source/drawingml/effectproperties.hxx
@@ -29,6 +29,13 @@ struct EffectGlowProperties
void assignUsed( const EffectGlowProperties& rSourceProps );
};
+struct EffectSoftEdgeProperties
+{
+ OptValue<sal_Int64> moRad; // size of effect
+
+ void assignUsed(const EffectSoftEdgeProperties& rSourceProps);
+};
+
struct EffectShadowProperties
{
OptValue< sal_Int64 > moShadowDist;
@@ -54,6 +61,7 @@ struct EffectProperties
{
EffectShadowProperties maShadow;
EffectGlowProperties maGlow;
+ EffectSoftEdgeProperties maSoftEdge;
/** Stores all effect properties, including those not supported by core yet */
std::vector<std::unique_ptr<Effect>> m_Effects;
diff --git a/oox/source/drawingml/effectpropertiescontext.cxx b/oox/source/drawingml/effectpropertiescontext.cxx
index 28fdd8ea4fcf..afd00d2dd097 100644
--- a/oox/source/drawingml/effectpropertiescontext.cxx
+++ b/oox/source/drawingml/effectpropertiescontext.cxx
@@ -106,12 +106,14 @@ ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement,
}
case A_TOKEN( softEdge ):
+ {
+ mrEffectProperties.maSoftEdge.moRad = rAttribs.getInteger(XML_rad, 0);
+ return this; // no inner elements
+ }
case A_TOKEN( reflection ):
case A_TOKEN( blur ):
{
- if( nElement == A_TOKEN( softEdge ) )
- mrEffectProperties.m_Effects[nPos]->msName = "softEdge";
- else if( nElement == A_TOKEN( reflection ) )
+ if (nElement == A_TOKEN(reflection))
mrEffectProperties.m_Effects[nPos]->msName = "reflection";
else if( nElement == A_TOKEN( blur ) )
mrEffectProperties.m_Effects[nPos]->msName = "blur";
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 92629b2419b5..92e145fbe1da 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1474,6 +1474,15 @@ Reference< XShape > const & Shape::createAndInsert(
propertySet->setPropertyValue("GlowEffectColor", makeAny(aEffectProperties.maGlow.moGlowColor.getColor(rGraphicHelper)));
propertySet->setPropertyValue("GlowEffectTransparency", makeAny(aEffectProperties.maGlow.moGlowColor.getTransparency()));
}
+
+ // Set soft edge effect properties
+ if (aEffectProperties.maSoftEdge.moRad.has())
+ {
+ uno::Reference<beans::XPropertySet> propertySet(mxShape, uno::UNO_QUERY);
+ propertySet->setPropertyValue("SoftEdge", makeAny(true));
+ propertySet->setPropertyValue(
+ "SoftEdgeRad", makeAny(convertEmuToHmm(aEffectProperties.maSoftEdge.moRad.get())));
+ }
}
if( mxShape.is() )
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index e2149b648f84..134fa648aff6 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3750,12 +3750,13 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
bool bHasShadow = false;
if( GetProperty( rXPropSet, "Shadow" ) )
mAny >>= bHasShadow;
- bool bHasGlow = false;
- if( GetProperty( rXPropSet, "GlowEffect") )
- mAny >>= bHasGlow;
- //rXPropSet->getPropertyValue("GlowEffect") >>= bHasGlow;
+ bool bHasEffects = bHasShadow;
+ if (!bHasEffects && GetProperty(rXPropSet, "GlowEffect"))
+ mAny >>= bHasEffects;
+ if (!bHasEffects && GetProperty(rXPropSet, "SoftEdge"))
+ mAny >>= bHasEffects;
- if( bHasShadow || bHasGlow )
+ if (bHasEffects)
{
mpFS->startElementNS(XML_a, XML_effectLst);
WriteGlowEffect(rXPropSet);
@@ -3782,6 +3783,7 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
WriteShapeEffect( "outerShdw", aShadowGrabBag );
}
+ WriteSoftEdgeEffect(rXPropSet);
mpFS->endElementNS(XML_a, XML_effectLst);
}
}
@@ -3848,6 +3850,7 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet )
}
if (!bGlowWritten)
WriteGlowEffect(rXPropSet);
+ WriteSoftEdgeEffect(rXPropSet); // the last
mpFS->endElementNS(XML_a, XML_effectLst);
}
@@ -3877,6 +3880,25 @@ void DrawingML::WriteGlowEffect(const Reference< XPropertySet >& rXPropSet)
WriteShapeEffect("glow", aGlowProps);
}
+void DrawingML::WriteSoftEdgeEffect(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet)
+{
+ bool hasEffect = false;
+ rXPropSet->getPropertyValue("SoftEdge") >>= hasEffect;
+ if (!hasEffect)
+ return;
+
+ sal_Int32 nRad = 0;
+ rXPropSet->getPropertyValue("SoftEdgeRad") >>= nRad;
+ css::uno::Sequence<css::beans::PropertyValue> aAttribs(1);
+ aAttribs[0].Name = "rad";
+ aAttribs[0].Value <<= oox::drawingml::convertHmmToEmu(nRad);
+ css::uno::Sequence<css::beans::PropertyValue> aProps(1);
+ aProps[0].Name = "Attribs";
+ aProps[0].Value <<= aAttribs;
+
+ WriteShapeEffect("softEdge", aProps);
+}
+
void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
{
// check existence of the grab bag