diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-09-07 08:42:46 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-09-07 08:45:29 +0200 |
commit | b484e9814c66d8d51cea974390963a6944bc9d73 (patch) | |
tree | ccc0ea56520d0ede32a0bd93bb14a3dcfb45004b /sw | |
parent | 5963c6c1a0158d9d93dd8a0433ab08d424bf7675 (diff) |
tdf#83227 oox: reuse RelId in DML/VML export for the same graphic
So that large images are written only once to the ZIP container when
they are exported using both markups. This affects drawinglayer images,
the Writer ones are handled directly in sw and were already
deduplicated.
Change-Id: Iff7c769329b42939833056b727b070f6a60da5e3
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf83227.docx | bin | 0 -> 14647 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 16 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 4 |
4 files changed, 32 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf83227.docx b/sw/qa/extras/ooxmlexport/data/tdf83227.docx Binary files differnew file mode 100644 index 000000000000..bca19a955ecf --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf83227.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index f14190096e50..37c19c2939c3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -800,6 +800,18 @@ DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx") } +DECLARE_OOXMLEXPORT_TEST(testTdf83227, "tdf83227.docx") +{ + // Bug document contains a rotated image, which is handled as a draw shape (not as a Writer image) on export. + if (!mbExported) + return; + + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); + CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/media/image1.png"))); + // This was also true, image was written twice. + CPPUNIT_ASSERT_EQUAL(false, bool(xNameAccess->hasByName("word/media/image2.png"))); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 6f9251ef2ca9..d3ccb5a0c791 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4125,6 +4125,22 @@ void DocxAttributeOutput::WriteSrcRect(const SdrObject* pSdrObj ) void DocxAttributeOutput::ClearRelIdCache() { m_aRelIdCache.clear(); + m_aSdrRelIdCache.clear(); +} + +OUString DocxAttributeOutput::FindRelId(BitmapChecksum nChecksum) +{ + OUString aRet; + + if (m_aSdrRelIdCache.find(nChecksum) != m_aSdrRelIdCache.end()) + aRet = m_aSdrRelIdCache[nChecksum]; + + return aRet; +} + +void DocxAttributeOutput::CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId) +{ + m_aSdrRelIdCache[nChecksum] = rRelId; } void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size& rSize, const SwFlyFrameFormat* pOLEFrameFormat, SwOLENode* pOLENode, const SdrObject* pSdrObj ) diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 54d3f11ccb8f..6479726f0e64 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -906,6 +906,8 @@ private: /// RelId <-> Graphic* cache, so that in case of alternate content, the same graphic only gets written once. std::map<const Graphic*, OString> m_aRelIdCache; + /// RelId <-> BitmapChecksum cache, similar to m_aRelIdCache, but used for non-Writer graphics, handled in oox. + std::map<BitmapChecksum, OUString> m_aSdrRelIdCache; /// members to control the existence of grabbagged SDT properties in the paragraph sal_Int32 m_nParagraphSdtPrToken; @@ -963,6 +965,8 @@ public: virtual void WriteVMLTextBox(css::uno::Reference<css::drawing::XShape> xShape) SAL_OVERRIDE; /// DMLTextExport virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) SAL_OVERRIDE; + virtual OUString FindRelId(BitmapChecksum nChecksum) SAL_OVERRIDE; + virtual void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId) SAL_OVERRIDE; virtual oox::drawingml::DrawingML& GetDrawingML() SAL_OVERRIDE; void BulletDefinition(int nId, const Graphic& rGraphic, Size aSize) SAL_OVERRIDE; |