summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-02-21 12:57:57 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-21 13:02:31 +0100
commit32ada80a9f47b095d7b0c4d16e3422f6ef7f2ac2 (patch)
tree13734c176bb71fb272384b37b88c71ff89ac0dbd /sw/source
parent3f6df3835fec71ea61894f9a3bbfe5e4a06a5495 (diff)
DOCX export: make sure a graphic is only written once
Even if it's referenced multiple times, because of mc:AlternateContent. Change-Id: Ie4cb0ec088d12be5421bac43113c8ae4636028e0
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx14
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx3
2 files changed, 14 insertions, 3 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index afeb0573e071..ab71fd93075f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3020,10 +3020,18 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
else
pGraphic = pOLENode->GetGraphic();
- m_rDrawingML.SetFS( m_pSerializer ); // to be sure that we write to the right stream
- OUString aImageId = m_rDrawingML.WriteImage( *pGraphic );
+ if (m_aRelIdCache.find(pGraphic) != m_aRelIdCache.end())
+ // We already have a RelId for this Graphic.
+ aRelId = m_aRelIdCache[pGraphic];
+ else
+ {
+ // Not in cache, then need to write it.
+ m_rDrawingML.SetFS( m_pSerializer ); // to be sure that we write to the right stream
+ OUString aImageId = m_rDrawingML.WriteImage( *pGraphic );
- aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 );
+ aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 );
+ m_aRelIdCache[pGraphic] = aRelId;
+ }
nImageType = XML_embed;
}
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index e25606deb4c6..47ce782b8443 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -824,6 +824,9 @@ private:
bool m_setFootnote;
+ /// RelId <-> Graphic* cache, so that in case of alternate content, the same graphic only gets written once.
+ std::map<const Graphic*, OString> m_aRelIdCache;
+
public:
DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML );