summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-05-20 20:11:13 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-06-03 15:00:45 +0000
commit727938b395693be2bf0956fff687193cff95f028 (patch)
tree09862b3df760b2580451b2956891282a28ff4ef5 /writerfilter
parent7c5afbf494873ea2729e3db3f8bef5d960d1ca75 (diff)
oox, writerfilter: Support for artistic effects on pictures
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> They are defined in the MS-ODRAWXML extension. Ref: http://msdn.microsoft.com/en-us/library/dd905216(v=office.12).aspx 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. When Word applies an artistic effect, it creates two embedded files; one contains the bitmap with the effect and the other one contains the original bitmap to be able to undo the effect. We also read the original bitmap, store it in the shape grab bag and save it back to the docx file. When two pictures apply different effects to the same picture, it is only saved once in the original document. Added a cache to DrawingML to know if the picture has already been exported. Finally, added unit tests for a selection of artistic effects. [Squashing commits from master: 21d4cfe19e2796ebf89c408e292c4473924b2bc4 642a252cf1a2f1d08c4bbfcae15527bb82c7664d 2e68a1468c035fc3bb4d02ad0b3187872fe1e67b b5f6a5cfc517ecd8aa6ba96471d854b07b92ebaa 38d7b82c277599f2e613256c4353aa7dfdc219ec] Change-Id: I39327a8118e23829c029122154a31ce3af5b48cd Reviewed-on: https://gerrit.libreoffice.org/9495 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/CustomTarget_source.mk1
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx3
-rw-r--r--writerfilter/source/ooxml/model.xml412
3 files changed, 415 insertions, 1 deletions
diff --git a/writerfilter/CustomTarget_source.mk b/writerfilter/CustomTarget_source.mk
index 789a627bdc2e..249ebca5b6bb 100644
--- a/writerfilter/CustomTarget_source.mk
+++ b/writerfilter/CustomTarget_source.mk
@@ -41,6 +41,7 @@ writerfilter_OOXMLNAMESPACES= \
mce \
wp14 \
w14 \
+ a14 \
wml
writerfilter_ALL = \
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 1d19df08de5b..11f5a73345c2 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -650,7 +650,8 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
{
// if the shape contains effects in the grab bag, we should not transform it
// in a XTextContent so those effects can be preserved
- if( aGrabBag[i].Name == "EffectProperties" || aGrabBag[i].Name == "3DEffectProperties" )
+ if( aGrabBag[i].Name == "EffectProperties" || aGrabBag[i].Name == "3DEffectProperties" ||
+ aGrabBag[i].Name == "ArtisticEffectProperties" )
bContainsEffects = true;
}
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 6f43179712be..36a37f61e736 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -46,6 +46,7 @@
<namespace-alias name="http://schemas.openxmlformats.org/markup-compatibility/2006" alias="mce" id="mce"/>
<namespace-alias name="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" alias="wp14" id="wp14"/>
<namespace-alias name="http://schemas.microsoft.com/office/word/2010/wordml" alias="w14" id="w14"/>
+ <namespace-alias name="http://schemas.microsoft.com/office/drawing/2010/main" alias="a14" id="a14"/>
<namespace-alias name="http://sprm" alias="sprm" id="sprm"/>
<token tokenid="ooxml:shape"/>
<token tokenid="ooxml:token"/>
@@ -6793,6 +6794,417 @@
<element name="cntxtAlts" tokenid="ooxml:cntxtAlts_cntxtAlts"/>
</resource>
</namespace>
+ <namespace name="a14" file="a14.rng">
+ <grammar xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2006/xpath-functions" xmlns="http://relaxng.org/ns/structure/1.0" ns="http://schemas.microsoft.com/office/drawingml/2010/main" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+ <!-- Simple types -->
+ <define name="ST_ArtisticEffectParam10">
+ <data type="integer">
+ <xs:documentation>Integer value (0 to 10)</xs:documentation>
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">10</param>
+ </data>
+ </define>
+ <define name="ST_ArtisticEffectParam100">
+ <data type="integer">
+ <xs:documentation>Integer value (0 to 100)</xs:documentation>
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">100</param>
+ </data>
+ </define>
+ <define name="ST_ArtisticEffectParam4">
+ <data type="integer">
+ <xs:documentation>Integer value (0 to 4)</xs:documentation>
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">4</param>
+ </data>
+ </define>
+ <define name="ST_ArtisticEffectParam6">
+ <data type="integer">
+ <xs:documentation>Integer value (0 to 6)</xs:documentation>
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">6</param>
+ </data>
+ </define>
+ <define name="ST_ColorTemperature">
+ <data type="integer">
+ <xs:documentation>Integer value (1500 to 11500)</xs:documentation>
+ <param name="minInclusive">1500</param>
+ <param name="maxInclusive">11500</param>
+ </data>
+ </define>
+ <define name="ST_LegacySpreadsheetColorIndex">
+ <data type="integer">
+ <xs:documentation>Integer value (0 to 80)</xs:documentation>
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">80</param>
+ </data>
+ </define>
+ <define name="ST_SaturationAmount">
+ <data type="integer">
+ <xs:documentation>Integer value (0 to 400000)</xs:documentation>
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">400000</param>
+ </data>
+ </define>
+
+ <!-- Complex types for effects -->
+ <define name="CT_PictureEffectBlur">
+ <optional>
+ <attribute name="visible">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectCement">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="crackSpacing">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectChalkSketch">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="pressure">
+ <ref name="ST_ArtisticEffectParam4"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectCrisscrossEtching">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="pressure">
+ <ref name="ST_ArtisticEffectParam4"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectCutout">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="numberOfShades">
+ <ref name="ST_ArtisticEffectParam6"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectFilmGrain">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="grainSize">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectGlass">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="scaling">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectGlowDiffused">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="intensity">
+ <ref name="ST_ArtisticEffectParam10"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectGlowEdges">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="smoothness">
+ <ref name="ST_ArtisticEffectParam10"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectLightScreen">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="gridSize">
+ <ref name="ST_ArtisticEffectParam10"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectLineDrawing">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="pencilSize">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectMarker">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="size">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectMosiaicBubbles">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="pressure">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectPaintStrokes">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="intensity">
+ <ref name="ST_ArtisticEffectParam10"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectPaintBrush">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="brushSize">
+ <ref name="ST_ArtisticEffectParam10"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectPastelsSmooth">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="scaling">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectPencilGrayscale">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="pencilSize">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectPencilSketch">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="pressure">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectPhotocopy">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="detail">
+ <ref name="ST_ArtisticEffectParam10"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectPlasticWrap">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="smoothness">
+ <ref name="ST_ArtisticEffectParam10"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectTexturizer">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="scaling">
+ <ref name="ST_ArtisticEffectParam100"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectWatercolorSponge">
+ <optional>
+ <attribute name="trans">
+ <ref name="a:ST_PositiveFixedPercentage"/>
+ </attribute>
+ <attribute name="brushSize">
+ <ref name="ST_ArtisticEffectParam10"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectBrightnessContrast">
+ <optional>
+ <attribute name="bright">
+ <ref name="a:ST_FixedPercentage"/>
+ </attribute>
+ <attribute name="contrast">
+ <ref name="a:ST_FixedPercentage"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectColorTemperature">
+ <optional>
+ <attribute name="colorTemp">
+ <ref name="ST_ColorTemperature"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectSaturation">
+ <optional>
+ <attribute name="sat">
+ <ref name="ST_SaturationAmount"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureEffectSharpenSoften">
+ <optional>
+ <attribute name="amount">
+ <ref name="ST_FixedPercentage"/>
+ </attribute>
+ </optional>
+ </define>
+
+ <!-- Complex types for containers -->
+ <define name="CT_PictureEffect">
+ <choice>
+ <element name="artisticBlur">
+ <ref name="CT_PictureEffectBlur"/>
+ </element>
+ <element name="artisticCement">
+ <ref name="CT_PictureEffectCement"/>
+ </element>
+ <element name="artisticChalkSketch">
+ <ref name="CT_PictureEffectChalkSketch"/>
+ </element>
+ <element name="artisticCrisscrossEtching">
+ <ref name="CT_PictureEffectCrisscrossEtching"/>
+ </element>
+ <element name="artisticCutout">
+ <ref name="CT_PictureEffectCutout"/>
+ </element>
+ <element name="artisticFilmGrain">
+ <ref name="CT_PictureEffectFilmGrain"/>
+ </element>
+ <element name="artisticGlass">
+ <ref name="CT_PictureEffectGlass"/>
+ </element>
+ <element name="artisticGlowDiffused">
+ <ref name="CT_PictureEffectGlowDiffused"/>
+ </element>
+ <element name="artisticGlowEdges">
+ <ref name="CT_PictureEffectGlowEdges"/>
+ </element>
+ <element name="artisticLightScreen">
+ <ref name="CT_PictureEffectLightScreen"/>
+ </element>
+ <element name="artisticLineDrawing">
+ <ref name="CT_PictureEffectLineDrawing"/>
+ </element>
+ <element name="artisticMarker">
+ <ref name="CT_PictureEffectMarker"/>
+ </element>
+ <element name="artisticMosiaicBubbles">
+ <ref name="CT_PictureEffectMosiaicBubbles"/>
+ </element>
+ <element name="artisticPaintStrokes">
+ <ref name="CT_PictureEffectPaintStrokes"/>
+ </element>
+ <element name="artisticPaintBrush">
+ <ref name="CT_PictureEffectPaintBrush"/>
+ </element>
+ <element name="artisticPastelsSmooth">
+ <ref name="CT_PictureEffectPastelsSmooth"/>
+ </element>
+ <element name="artisticPencilGrayscale">
+ <ref name="CT_PictureEffectPencilGrayscale"/>
+ </element>
+ <element name="artisticPencilSketch">
+ <ref name="CT_PictureEffectPencilSketch"/>
+ </element>
+ <element name="artisticPhotocopy">
+ <ref name="CT_PictureEffectPhotocopy"/>
+ </element>
+ <element name="artisticPlasticWrap">
+ <ref name="CT_PictureEffectPlasticWrap"/>
+ </element>
+ <element name="artisticTexturizer">
+ <ref name="CT_PictureEffectTexturizer"/>
+ </element>
+ <element name="artisticWatercolorSponge">
+ <ref name="CT_PictureEffectWatercolorSponge"/>
+ </element>
+ <element name="artisticBrightnessContrast">
+ <ref name="CT_PictureEffectBrightnessContrast"/>
+ </element>
+ <element name="artisticColorTemperature">
+ <ref name="CT_PictureEffectColorTemperature"/>
+ </element>
+ <element name="artisticSaturation">
+ <ref name="CT_PictureEffectSaturation"/>
+ </element>
+ <element name="artisticSharpenSoften">
+ <ref name="CT_PictureEffectSharpenSoften"/>
+ </element>
+ </choice>
+ <optional>
+ <attribute name="visible">
+ <data type="boolean"/>
+ </attribute>
+ </optional>
+ </define>
+ <define name="CT_PictureLayer">
+ <zeroOrMore>
+ <element name="imgEffect">
+ <ref name="CT_PictureEffect"/>
+ </element>
+ </zeroOrMore>
+ <attribute name="r:embed">
+ <text/>
+ <xs:documentation>Embedded Image Relationship Target</xs:documentation>
+ </attribute>
+ </define>
+ <define name="CT_Photo">
+ <zeroOrMore>
+ <element name="imgLayer">
+ <ref name="CT_PictureLayer"/>
+ </element>
+ </zeroOrMore>
+ </define>
+ </grammar>
+ </namespace>
<namespace name="dml-shapeGeometry" file="dml-shapeGeometry.rng" todo="ignore">
<grammar xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2006/xpath-functions" xmlns="http://relaxng.org/ns/structure/1.0" ns="http://schemas.openxmlformats.org/drawingml/2006/main" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<!-- ISO RELAX NG Schema -->