diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-20 21:05:10 +0200 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-23 10:03:59 +0200 |
commit | 642a252cf1a2f1d08c4bbfcae15527bb82c7664d (patch) | |
tree | 605b6c546b61972a9c6dd6b1fd1b3a89d3b9f0e0 /include/oox | |
parent | 21d4cfe19e2796ebf89c408e292c4473924b2bc4 (diff) |
ooxml: preserve artistic effects on shapes.
Bitmaps can define artistic effects like in the following example:
<a:blip r:embed="rId5">
<a:extLst>
<a:ext uri="{BEBA8EAE-BF5A-486C-A8C5-ECC9F3942E4B}">
<a14:imgProps
xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main">
<a14:imgLayer r:embed="rId6">
<a14:imgEffect>
<a14:artisticMarker trans="14000" size="80" />
</a14:imgEffect>
</a14:imgLayer>
</a14:imgProps>
</a:ext>
</a:extLst>
</a:blip>
LO core doesn't support them, but I'm preserving them using the shape
grab bag. Bitmaps must not be transformed to a SwXTextGraphicObject
so the grab bag of the XShape is not discarded.
Added several Context and Properties objects on the import side to
traverse and save the relevant tags, and added the corresponding code
on the export side to extract the grab bag and output the effect back.
Also added a unit test for a selection of artistic effects.
TODO: Word saves the original bitmap as an embedded wdp file so the
effect can be undone. We must preserve it too and add the reference to
the a14:imgLayer tag.
Change-Id: I61d427f83e4c8f353eb073da0114cd73ba50ba4b
Diffstat (limited to 'include/oox')
-rw-r--r-- | include/oox/drawingml/fillproperties.hxx | 24 | ||||
-rw-r--r-- | include/oox/drawingml/fillpropertiesgroupcontext.hxx | 42 | ||||
-rw-r--r-- | include/oox/export/drawingml.hxx | 1 |
3 files changed, 67 insertions, 0 deletions
diff --git a/include/oox/drawingml/fillproperties.hxx b/include/oox/drawingml/fillproperties.hxx index 447cba2fa76c..c588deec8faa 100644 --- a/include/oox/drawingml/fillproperties.hxx +++ b/include/oox/drawingml/fillproperties.hxx @@ -65,6 +65,28 @@ struct PatternFillProperties void assignUsed( const PatternFillProperties& rSourceProps ); }; +struct ArtisticEffectProperties +{ + OUString msName; + std::map< OUString, css::uno::Any > + maAttribs; + + bool isEmpty() const; + + /** Returns the struct as a PropertyValue with Name = msName and + * Value = maAttribs as a Sequence< PropertyValue >. */ + css::beans::PropertyValue getEffect(); + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const ArtisticEffectProperties& rSourceProps ); + + /** Translate effect tokens to strings. */ + static OUString getEffectString( sal_Int32 nToken ); + + /** Translate effect strings to tokens. */ + static sal_Int32 getEffectToken( OUString sName ); +}; + struct BlipFillProperties { ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > @@ -89,6 +111,8 @@ struct BlipFillProperties Color maColorChangeTo; /// Destination color of color transformation. Color maDuotoneColors[2]; /// Duotone Colors + ArtisticEffectProperties maEffect; /// Artistic effect, not supported by core. + /** Overwrites all members that are explicitly set in rSourceProps. */ void assignUsed( const BlipFillProperties& rSourceProps ); }; diff --git a/include/oox/drawingml/fillpropertiesgroupcontext.hxx b/include/oox/drawingml/fillpropertiesgroupcontext.hxx index bbeed0837903..aae88df408be 100644 --- a/include/oox/drawingml/fillpropertiesgroupcontext.hxx +++ b/include/oox/drawingml/fillpropertiesgroupcontext.hxx @@ -78,6 +78,48 @@ private: +/** Context handler that imports a14:imgProps, a14:imgLayer, a14:imgEffect containers + and the a14:artistic* effect tags defined in the MS-ODRAWXML extension. */ +class ArtisticEffectContext : public ::oox::core::ContextHandler2 +{ +public: + explicit ArtisticEffectContext( + ::oox::core::ContextHandler2Helper& rParent, + ArtisticEffectProperties& rEffect ); + virtual ~ArtisticEffectContext(); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( + sal_Int32 nElement, + const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; + +private: + ArtisticEffectProperties& maEffect; +}; + + + +/** Context handler that imports the a:extLst element inside a:blip and its + children a:ext, which can contain transformations to the bitmap. */ +class BlipExtensionContext : public ::oox::core::ContextHandler2 +{ +public: + explicit BlipExtensionContext( + ::oox::core::ContextHandler2Helper& rParent, + BlipFillProperties& rBlipProps ); + virtual ~BlipExtensionContext(); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( + sal_Int32 nElement, + const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE; + +private: + BlipFillProperties& mrBlipProps; +}; + + + /** Context handler that imports the a:duotone element containing the colors of a bitmap duotone transformation. */ class DuotoneContext : public ::oox::core::ContextHandler2 diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 86e3d0769449..98cc0dfb38a0 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -176,6 +176,7 @@ public: void WriteShapeEffects( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); void WriteShapeEffect( const OUString& sName, const css::uno::Sequence< css::beans::PropertyValue >& aEffectProps ); void WriteShape3DEffects( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); + void WriteArtisticEffect( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); static void ResetCounters(); |