[Libreoffice-commits] core.git: include/oox oox/source sc/qa sc/source sd/qa sd/source
include/oox/export/drawingml.hxx |8 + oox/source/export/drawingml.cxx | 207 +-- sc/qa/unit/data/ods/tdf91286.ods |binary sc/qa/unit/subsequent_export_test2.cxx | 26 +++ sc/source/filter/excel/xestream.cxx |4 sd/qa/unit/data/odp/tdf74670.odp |binary sd/qa/unit/export-tests-ooxml3.cxx | 26 +++ sd/source/filter/eppt/pptx-epptooxml.cxx |2 8 files changed, 182 insertions(+), 91 deletions(-) New commits: commit aea8043bc5f5187498fa450505d6de9d6986e2a6 Author: Tünde Tóth AuthorDate: Tue Mar 22 09:47:57 2022 +0100 Commit: László Németh CommitDate: Wed Mar 30 18:24:45 2022 +0200 tdf#74670 tdf#91286 PPTX XLSX export: save image once Impress and Calc used to dump the same image file as many times as it was featured in the document, resulting redundant, sometimes huge documents. Note: using only checksum to recognize image duplication is a regression, because checksum collision results image loss. This is a very unlikely event, and the following commits have got the same problem. The solution is comparing the images with the same checksum byte for byte. See also commit b484e9814c66d8d51cea974390963a6944bc9d73 "tdf#83227 oox: reuse RelId in DML/VML export for the same graphic" and commit 797fef38612fb2fd62d1f6591619b9361e526bca "tdf#118535 DOCX export: save header image once". Change-Id: I9f233d521941381746634cf4f9b5991da0dadda9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131928 Tested-by: László Németh Reviewed-by: László Németh diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index fb125dd647ad..9a7f744520c8 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -21,7 +21,9 @@ #define INCLUDED_OOX_EXPORT_DRAWINGML_HXX #include +#include #include +#include #include #include @@ -41,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -150,6 +153,7 @@ private: static std::map maWdpCache; static sal_Int32 mnDrawingMLCount; static sal_Int32 mnVmlCount; +static std::stack> maExportGraphics; /// To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC). DocumentType meDocumentType; @@ -342,9 +346,11 @@ public: sal_Int32 getBulletMarginIndentation (const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, std::u16string_view propName); static void ResetCounters(); - static void ResetMlCounters(); +static void PushExportGraphics(); +static void PopExportGraphics(); + static sal_Int32 getNewDrawingUniqueId() { return ++mnDrawingMLCount; } static sal_Int32 getNewVMLUniqueId() { return ++mnVmlCount; } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index a790a643abc0..a99a0474a458 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -111,7 +111,6 @@ #include #include #include -#include #include #include #include @@ -237,6 +236,7 @@ int DrawingML::mnWdpImageCounter = 1; std::map DrawingML::maWdpCache; sal_Int32 DrawingML::mnDrawingMLCount = 0; sal_Int32 DrawingML::mnVmlCount = 0; +std::stack> DrawingML::maExportGraphics; sal_Int16 DrawingML::GetScriptType(const OUString& rStr) { @@ -275,6 +275,16 @@ void DrawingML::ResetMlCounters() mnVmlCount = 0; } +void DrawingML::PushExportGraphics() +{ +maExportGraphics.emplace(); +} + +void DrawingML::PopExportGraphics() +{ +maExportGraphics.pop(); +} + bool DrawingML::GetProperty( const Reference< XPropertySet >& rXPropertySet, const OUString& aName ) { try @@ -1264,113 +1274,130 @@ const char* DrawingML::GetRelationCompPrefix() const OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia, OUString* pFileName ) { GfxLink aLink = rGraphic.GetGfxLink (); +BitmapChecksum aChecksum = rGraphic.GetChecksum(); OUString sMediaType; const char* pExtension = ""; OUString sRelId; +OUString sPath; -SvMemoryStream aStream; -const void* aData = aLink.GetData(); -std::size_t nDataSize = aLink.GetDataSize(); - -switch ( aLink.GetType() ) +// tdf#74670 tdf#91286 Save image only once (this is no problem for DOCX) +if (GetDocumentType() != DOCUMENT_DOCX && !maExportGraphics.empty()) { -case GfxLinkType::NativeGif: -sMediaType = "image/gif"; -pExtension = ".gif"; -break; +auto aIterator = maExportGraphics.top().find(aChecksum); +if (aIterator != maExportGraphics.top().end()) +sPath = aIterator->second; +} -// #i15508# added BMP type for better exports -// export not yet active, so adding for reference (not checked) -case GfxLinkType::NativeBmp: -sMed
[Libreoffice-commits] core.git: include/oox oox/source sc/qa sc/source sd/qa sd/source sw/qa
include/oox/core/xmlfilterbase.hxx|6 +- oox/source/core/xmlfilterbase.cxx |2 -- sc/qa/unit/subsequent_export-test.cxx |4 sc/source/filter/excel/excdoc.cxx |3 ++- sd/qa/unit/export-tests-ooxml1.cxx|4 ++-- sd/source/filter/eppt/pptx-epptooxml.cxx |4 ++-- sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 11 +++ 7 files changed, 26 insertions(+), 8 deletions(-) New commits: commit bf5c486946f2b0a708a251c8ff614293ae37c6ba Author: Jan Holesovsky Date: Thu Mar 8 12:24:48 2018 +0100 tdf#116283 oox customXml: Don't write the Relationship to DOCX files twice. Change-Id: Id3da40138e86c142707e377aa897df372aacb704 Reviewed-on: https://gerrit.libreoffice.org/50947 Reviewed-by: Jan Holesovsky Tested-by: Jan Holesovsky diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index 75fc03920b79..69586fe020bb 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -226,7 +226,12 @@ public: */ void exportDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xProperties ); +/** Write the customXml entries we are preserving (xlsx and pptx only). */ +void exportCustomFragments(); + +/** Read the document properties and also the customXml entries (xlsx and pptx only). */ void importDocumentProperties(); + static void putPropertiesToDocumentGrabBag(const css::uno::Reference& xDstDoc, const comphelper::SequenceAsHashMap& rProperties); @@ -259,7 +264,6 @@ private: const css::uno::Reference< css::io::XStream >& rxOutStream ) const override; void importCustomFragments(css::uno::Reference& xDocumentStorage); -void exportCustomFragments(); private: ::std::unique_ptr< XmlFilterBaseImpl > mxImpl; diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 0388fae5f473..00d202b315da 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -841,8 +841,6 @@ void XmlFilterBase::exportDocumentProperties( const Reference< XDocumentProperti writeAppProperties( *this, xProperties ); writeCustomProperties( *this, xProperties ); } - -exportCustomFragments(); } // protected -- diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 595e563dc301..ff4063f8ed84 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -3055,6 +3055,10 @@ void ScExportTest::testCustomXml() xmlDocPtr pRelsDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "customXml/_rels/item1.xml.rels"); CPPUNIT_ASSERT(pRelsDoc); +// Check there is a relation to itemProps1.xml. +assertXPath(pRelsDoc, "/r:Relationships/r:Relationship", 1); +assertXPath(pRelsDoc, "/r:Relationships/r:Relationship[@Id='rId1']", "Target", "itemProps1.xml"); + std::shared_ptr pStream = XPathHelper::parseExportStream(pXPathFile, m_xSFactory, "ddp/ddpfile.xen"); CPPUNIT_ASSERT(pStream); } diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index d2dd5d147b0e..bc0d4e3de177 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -830,7 +830,8 @@ void ExcDocument::WriteXml( XclExpXmlStream& rStrm ) uno::Reference xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW ); uno::Reference xDocProps = xDPS->getDocumentProperties(); -rStrm.exportDocumentProperties( xDocProps ); +rStrm.exportDocumentProperties(xDocProps); +rStrm.exportCustomFragments(); sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream(); rWorkbook->startElement( XML_workbook, diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 2ccc48982727..54e411a482f7 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -847,8 +847,8 @@ void SdOOXMLExportTest1::testCustomXml() CPPUNIT_ASSERT(pRelsDoc); // Check there is a relation to itemProps1.xml. -const OUString sXmlPath = "/rels:Relationships/rels:Relationship[@Id='rId1']"; -assertXPath(pRelsDoc, OUStringToOString(sXmlPath, RTL_TEXTENCODING_UTF8), "Target", "itemProps1.xml"); +assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship", 1); +assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target", "itemProps1.xml"); std::shared_ptr pStream = parseExportStream(tempFile, "ddp/ddpfile.xen"); CPPUNIT_ASSERT(pStream); diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index ca5f9ef56c67..2672f17c185f 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-ep