summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/oox/export/drawingml.hxx3
-rw-r--r--oox/source/drawingml/fillproperties.cxx8
-rw-r--r--oox/source/drawingml/fillpropertiesgroupcontext.cxx3
-rw-r--r--oox/source/export/drawingml.cxx22
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx19
5 files changed, 38 insertions, 17 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 77d54b48b014..e97f05da8cf5 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -83,6 +83,7 @@ public:
private:
static int mnImageCounter;
static int mnWdpImageCounter;
+ static std::map<OUString, OUString> maWdpCache;
/// To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC).
DocumentType meDocumentType;
@@ -178,7 +179,7 @@ public:
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 );
- OString WriteWdpPicture( const ::com::sun::star::uno::Sequence< sal_Int8 >& rPictureData );
+ OString WriteWdpPicture( const OUString& rFileId, const ::com::sun::star::uno::Sequence< sal_Int8 >& rPictureData );
static void ResetCounters();
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 );
}
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 0284347daa86..611da2b04d8b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -1378,9 +1378,7 @@ DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artisti
OUString sEmbedId2 = getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
"embed");
- sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId2 + "']";
- sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target");
- CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile)));
+ CPPUNIT_ASSERT_EQUAL(sEmbedId1, sEmbedId2);
// 3rd picture: pencil sketch
assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
@@ -1395,9 +1393,7 @@ DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artisti
OUString sEmbedId3 = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
"embed");
- sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId3 + "']";
- sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target");
- CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile)));
+ CPPUNIT_ASSERT_EQUAL(sEmbedId1, sEmbedId3);
// 4th picture: light screen
assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
@@ -1425,9 +1421,7 @@ DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artisti
OUString sEmbedId5 = getXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
"embed");
- sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId5 + "']";
- sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target");
- CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile)));
+ CPPUNIT_ASSERT_EQUAL(sEmbedId1, sEmbedId5);
// 6th picture: photocopy (no attributes)
assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/"
@@ -1437,9 +1431,10 @@ DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artisti
OUString sEmbedId6 = getXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer",
"embed");
- sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId6 + "']";
- sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target");
- CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile)));
+ CPPUNIT_ASSERT_EQUAL(sEmbedId1, sEmbedId6);
+
+ // no redundant wdp files saved
+ CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess->hasByName("word/media/hdphoto3.wdp")));
}
DECLARE_OOXMLEXPORT_TEST(fdo77719, "fdo77719.docx")