diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-22 16:05:23 +0200 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-23 10:04:00 +0200 |
commit | b5f6a5cfc517ecd8aa6ba96471d854b07b92ebaa (patch) | |
tree | c13eb4badf6272158be9adae54099632a1b9fbb7 /oox | |
parent | 2e68a1468c035fc3bb4d02ad0b3187872fe1e67b (diff) |
ooxml: Do not repeat wdp files in artistic effects
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, and added a test
for it.
Change-Id: Ia25f3d8f2f46d61f18aefc22fdfdbcdc72f2d916
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 8 | ||||
-rw-r--r-- | oox/source/drawingml/fillpropertiesgroupcontext.cxx | 3 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 22 |
3 files changed, 29 insertions, 4 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 7d816758f459..96770425b047 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -619,8 +619,14 @@ css::beans::PropertyValue ArtisticEffectProperties::getEffect() if( mrOleObjectInfo.maEmbeddedData.hasElements() ) { + css::uno::Sequence< css::beans::PropertyValue > aGraphicSeq( 2 ); + aGraphicSeq[0].Name = "Id"; + aGraphicSeq[0].Value = uno::makeAny( mrOleObjectInfo.maProgId ); + aGraphicSeq[1].Name = "Data"; + aGraphicSeq[1].Value = uno::makeAny( mrOleObjectInfo.maEmbeddedData ); + aSeq[i].Name = "OriginalGraphic"; - aSeq[i].Value = uno::makeAny( mrOleObjectInfo.maEmbeddedData ); + aSeq[i].Value = uno::makeAny( aGraphicSeq ); } pRet.Name = msName; diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx index ac8f215a9d03..e60f68947738 100644 --- a/oox/source/drawingml/fillpropertiesgroupcontext.cxx +++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx @@ -339,7 +339,10 @@ ContextHandlerRef ArtisticEffectContext::onCreateContext( { OUString aFragmentPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( embed ), OUString() ) ); if( !aFragmentPath.isEmpty() ) + { getFilter().importBinaryData( maEffect.mrOleObjectInfo.maEmbeddedData, aFragmentPath ); + maEffect.mrOleObjectInfo.maProgId = aFragmentPath; + } } return new ArtisticEffectContext( *this, maEffect ); } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 141455452809..05faa6d696bc 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -120,11 +120,13 @@ namespace drawingml { // not thread safe int DrawingML::mnImageCounter = 1; int DrawingML::mnWdpImageCounter = 1; +std::map<OUString, OUString> DrawingML::maWdpCache; void DrawingML::ResetCounters() { mnImageCounter = 1; mnWdpImageCounter = 1; + maWdpCache.clear(); } bool DrawingML::GetProperty( Reference< XPropertySet > rXPropSet, const OUString& aName ) @@ -2604,9 +2606,18 @@ void DrawingML::WriteArtisticEffect( Reference< XPropertySet > rXPropSet ) } else if( aAttrs[i].Name == "OriginalGraphic" ) { + Sequence< PropertyValue > aGraphic; + aAttrs[i].Value >>= aGraphic; Sequence< sal_Int8 > aGraphicData; - aAttrs[i].Value >>= aGraphicData; - sRelId = WriteWdpPicture( aGraphicData ); + OUString sGraphicId; + for( sal_Int32 j=0; j < aGraphic.getLength(); ++j ) + { + if( aGraphic[j].Name == "Id" ) + aGraphic[j].Value >>= sGraphicId; + else if( aGraphic[j].Name == "Data" ) + aGraphic[j].Value >>= aGraphicData; + } + sRelId = WriteWdpPicture( sGraphicId, aGraphicData ); } } @@ -2632,8 +2643,12 @@ void DrawingML::WriteArtisticEffect( Reference< XPropertySet > rXPropSet ) mpFS->endElementNS( XML_a, XML_extLst ); } -OString DrawingML::WriteWdpPicture( const Sequence< sal_Int8 >& rPictureData ) +OString DrawingML::WriteWdpPicture( const OUString& rFileId, const Sequence< sal_Int8 >& rPictureData ) { + std::map<OUString, OUString>::iterator aCachedItem = maWdpCache.find( rFileId ); + if( aCachedItem != maWdpCache.end() ) + return OUStringToOString( aCachedItem->second, RTL_TEXTENCODING_UTF8 ); + OUString sFileName = "media/hdphoto" + OUString::number( mnWdpImageCounter++ ) + ".wdp"; uno::Reference< io::XOutputStream > xOutStream = mpFB->openFragmentStream( "word/" + sFileName, @@ -2646,6 +2661,7 @@ OString DrawingML::WriteWdpPicture( const Sequence< sal_Int8 >& rPictureData ) "http://schemas.microsoft.com/office/2007/relationships/hdphoto", sFileName, false ); + maWdpCache[rFileId] = sId; return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 ); } |