diff options
author | Tünde Tóth <toth.tunde@nisz.hu> | 2022-11-21 11:30:16 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-11-23 17:48:37 +0100 |
commit | 55b1d635350cb76ee3e19e90c938eedd38ac3342 (patch) | |
tree | 403ed09b858f63077a752f66a910b6e3a957d80e /oox | |
parent | d1dd9b9733511ff451e264169537c08fa14c574f (diff) |
tdf#152153 DOCX export: fix lost images at embedded documents
Handling of image counter was incorrect if the
document contains embedded documents, overwriting
images with the other ones.
See also commit cf2dc247ff5f726238856e9b46a4926a30430e14
"DOCX export: image deduplication and clean up" and
commit 3f6df3835fec71ea61894f9a3bbfe5e4a06a5495
"DOCX export: fix image counters for multiple documents".
Change-Id: I3ce3e370f96fa8b9feca3bc73f06ddca933215d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143036
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 | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index f7bf0ffdb6fe..16affd23295b 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -235,7 +235,7 @@ void WriteGradientPath(const awt::Gradient& rGradient, const FSHelperPtr& pFS, c } // not thread safe -int DrawingML::mnImageCounter = 1; +std::stack<sal_Int32> DrawingML::mnImageCounter; int DrawingML::mnWdpImageCounter = 1; std::map<OUString, OUString> DrawingML::maWdpCache; sal_Int32 DrawingML::mnDrawingMLCount = 0; @@ -268,7 +268,6 @@ sal_Int16 DrawingML::GetScriptType(const OUString& rStr) void DrawingML::ResetCounters() { - mnImageCounter = 1; mnWdpImageCounter = 1; maWdpCache.clear(); } @@ -281,11 +280,13 @@ void DrawingML::ResetMlCounters() void DrawingML::PushExportGraphics() { + mnImageCounter.push(1); maExportGraphics.emplace(); } void DrawingML::PopExportGraphics() { + mnImageCounter.pop(); maExportGraphics.pop(); } @@ -1394,7 +1395,7 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) Reference<XOutputStream> xOutStream = mpFB->openFragmentStream( OUStringBuffer() .appendAscii(GetComponentDir()) - .append("/media/image" + OUString::number(mnImageCounter)) + .append("/media/image" + OUString::number(mnImageCounter.top())) .appendAscii(pExtension) .makeStringAndClear(), sMediaType); @@ -1410,7 +1411,7 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) sPath = OUStringBuffer() .appendAscii(sRelationCompPrefix.getStr()) .appendAscii(sRelPathToMedia.getStr()) - .append(static_cast<sal_Int32>(mnImageCounter++)) + .append(static_cast<sal_Int32>(mnImageCounter.top()++)) .appendAscii(pExtension) .makeStringAndClear(); @@ -1489,7 +1490,7 @@ void DrawingML::WriteMediaNonVisualProperties(const css::uno::Reference<css::dra Reference<XOutputStream> xOutStream = mpFB->openFragmentStream(OUStringBuffer() .appendAscii(GetComponentDir()) .append("/media/media" + - OUString::number(mnImageCounter) + + OUString::number(mnImageCounter.top()) + aExtension) .makeStringAndClear(), aMimeType); @@ -1501,7 +1502,7 @@ void DrawingML::WriteMediaNonVisualProperties(const css::uno::Reference<css::dra // create the relation OUString aPath = OUStringBuffer().appendAscii(GetRelationCompPrefix()) - .append("media/media" + OUString::number(mnImageCounter++) + aExtension) + .append("media/media" + OUString::number(mnImageCounter.top()++) + aExtension) .makeStringAndClear(); aVideoFileRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(eMediaType), aPath); aMediaRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::MEDIA), aPath); |