diff options
author | Tünde Tóth <toth.tunde@nisz.hu> | 2022-11-24 15:30:37 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-11-29 17:37:28 +0100 |
commit | 01246f06cfeeb6a1070e82351e2559def4f5d820 (patch) | |
tree | 2826f750ba90cfd2c66eabbd453ec4ab75fbd218 /oox | |
parent | ae132145ff42a95dc24fb124847c04af4b8c8dab (diff) |
tdf#152152 DOCX export: fix lost WDP images in artistic effects
Handling of WDP image counter was incorrect if the
document contains embedded documents, overwriting
WDP images with the other ones.
See also commit 55b1d635350cb76ee3e19e90c938eedd38ac3342
"tdf#152153 DOCX export: fix lost images at embedded documents"
and commit cf2dc247ff5f726238856e9b46a4926a30430e14
"DOCX export: image deduplication and clean up"
and commit b5f6a5cfc517ecd8aa6ba96471d854b07b92ebaa
"ooxml: Do not repeat wdp files in artistic effects".
Change-Id: Ia26784519f6d514ee8c90c7a91a367feeba140b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143235
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/drawingml.cxx | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 1da6391412fc..3418a125fac5 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -237,8 +237,8 @@ void WriteGradientPath(const awt::Gradient& rGradient, const FSHelperPtr& pFS, c // not thread safe std::stack<sal_Int32> DrawingML::mnImageCounter; -int DrawingML::mnWdpImageCounter = 1; -std::map<OUString, OUString> DrawingML::maWdpCache; +std::stack<sal_Int32> DrawingML::mnWdpImageCounter; +std::stack<std::map<OUString, OUString>> DrawingML::maWdpCache; sal_Int32 DrawingML::mnDrawingMLCount = 0; sal_Int32 DrawingML::mnVmlCount = 0; std::stack<std::unordered_map<BitmapChecksum, OUString>> DrawingML::maExportGraphics; @@ -267,12 +267,6 @@ sal_Int16 DrawingML::GetScriptType(const OUString& rStr) return css::i18n::ScriptType::LATIN; } -void DrawingML::ResetCounters() -{ - mnWdpImageCounter = 1; - maWdpCache.clear(); -} - void DrawingML::ResetMlCounters() { mnDrawingMLCount = 0; @@ -283,12 +277,18 @@ void DrawingML::PushExportGraphics() { mnImageCounter.push(1); maExportGraphics.emplace(); + + mnWdpImageCounter.push(1); + maWdpCache.emplace(); } void DrawingML::PopExportGraphics() { mnImageCounter.pop(); maExportGraphics.pop(); + + mnWdpImageCounter.pop(); + maWdpCache.pop(); } bool DrawingML::GetProperty( const Reference< XPropertySet >& rXPropertySet, const OUString& aName ) @@ -5864,11 +5864,14 @@ void DrawingML::WriteArtisticEffect( const Reference< XPropertySet >& rXPropSet 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 ); + if (!maWdpCache.empty()) + { + std::map<OUString, OUString>::iterator aCachedItem = maWdpCache.top().find(rFileId); + if (aCachedItem != maWdpCache.top().end()) + return OUStringToOString(aCachedItem->second, RTL_TEXTENCODING_UTF8); + } - OUString sFileName = "media/hdphoto" + OUString::number( mnWdpImageCounter++ ) + ".wdp"; + OUString sFileName = "media/hdphoto" + OUString::number( mnWdpImageCounter.top()++ ) + ".wdp"; Reference< XOutputStream > xOutStream = mpFB->openFragmentStream( OUStringBuffer() .appendAscii( GetComponentDir() ) .append( "/" + sFileName ) @@ -5884,7 +5887,9 @@ OString DrawingML::WriteWdpPicture( const OUString& rFileId, const Sequence< sal .appendAscii( GetRelationCompPrefix() ) .append( sFileName ) ); - maWdpCache[rFileId] = sId; + if (!maWdpCache.empty()) + maWdpCache.top()[rFileId] = sId; + return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 ); } |