summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2022-04-04 11:49:59 +0200
committerLászló Németh <nemeth@numbertext.org>2022-04-26 18:07:40 +0200
commitcf2dc247ff5f726238856e9b46a4926a30430e14 (patch)
tree8c319026977124ce3c6bbd1fdef418d09149325d /oox
parent2fbf0f418ccb25010add33449d4e42b8b3f7fd0b (diff)
DOCX export: image deduplication and clean up
Follow-up to commit aea8043bc5f5187498fa450505d6de9d6986e2a6 "tdf#74670 tdf#91286 PPTX XLSX export: save image once". This reverts commit 797fef38612fb2fd62d1f6591619b9361e526bca "tdf#118535 DOCX export: save header image once" and commit 32ada80a9f47b095d7b0c4d16e3422f6ef7f2ac2 "DOCX export: make sure a graphic is only written once" and commit b484e9814c66d8d51cea974390963a6944bc9d73 "tdf#83227 oox: reuse RelId in DML/VML export for the same graphic". Change-Id: I2d90249808174290b6b3e4eb957b3ac87ad41f95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132506 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.cxx35
-rw-r--r--oox/source/export/vmlexport.cxx20
2 files changed, 7 insertions, 48 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 78eac3d00f60..87ca05452513 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1271,7 +1271,7 @@ const char* DrawingML::GetRelationCompPrefix() const
return "unknown";
}
-OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia, OUString* pFileName )
+OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia )
{
GfxLink aLink = rGraphic.GetGfxLink ();
BitmapChecksum aChecksum = rGraphic.GetChecksum();
@@ -1280,8 +1280,8 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia,
OUString sRelId;
OUString sPath;
- // tdf#74670 tdf#91286 Save image only once (this is no problem for DOCX)
- if (GetDocumentType() != DOCUMENT_DOCX && !maExportGraphics.empty())
+ // tdf#74670 tdf#91286 Save image only once
+ if (!maExportGraphics.empty())
{
auto aIterator = maExportGraphics.top().find(aChecksum);
if (aIterator != maExportGraphics.top().end())
@@ -1394,7 +1394,7 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia,
.appendAscii(pExtension)
.makeStringAndClear();
- if (GetDocumentType() != DOCUMENT_DOCX && !maExportGraphics.empty())
+ if (!maExportGraphics.empty())
maExportGraphics.top()[aChecksum] = sPath;
}
@@ -1402,8 +1402,6 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia,
oox::getRelationship(Relationship::IMAGE),
sPath );
- if (pFileName)
- *pFileName = sPath;
return sRelId;
}
@@ -1566,35 +1564,12 @@ OUString DrawingML::WriteXGraphicBlip(uno::Reference<beans::XPropertySet> const
bool bRelPathToMedia)
{
OUString sRelId;
- OUString sFileName;
if (!rxGraphic.is())
return sRelId;
Graphic aGraphic(rxGraphic);
- if (mpTextExport)
- {
- BitmapChecksum nChecksum = aGraphic.GetChecksum();
- sRelId = mpTextExport->FindRelId(nChecksum);
- sFileName = mpTextExport->FindFileName(nChecksum);
- }
- if (sRelId.isEmpty())
- {
- sRelId = WriteImage(aGraphic, bRelPathToMedia, &sFileName);
- if (mpTextExport)
- {
- BitmapChecksum nChecksum = aGraphic.GetChecksum();
- mpTextExport->CacheRelId(nChecksum, sRelId, sFileName);
- }
- }
- else
- {
- // Include the same relation again. This makes it possible to
- // reuse an image across different headers.
- sRelId = mpFB->addRelation( mpFS->getOutputStream(),
- oox::getRelationship(Relationship::IMAGE),
- sFileName );
- }
+ sRelId = WriteImage(aGraphic, bRelPathToMedia);
mpFS->startElementNS(XML_a, XML_blip, FSNS(XML_r, XML_embed), sRelId);
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 544a5599c932..32f60ff65c9a 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -718,15 +718,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle&
const uno::Reference<graphic::XGraphic>& xGraphic
= pSdrGrafObj->getSignatureLineUnsignedGraphic();
Graphic aGraphic(xGraphic);
-
- BitmapChecksum nChecksum = aGraphic.GetChecksum();
- OUString aImageId = m_pTextExport->FindRelId(nChecksum);
- if (aImageId.isEmpty())
- {
- OUString aFileName;
- aImageId = m_pTextExport->GetDrawingML().WriteImage(aGraphic, false, &aFileName);
- m_pTextExport->CacheRelId(nChecksum, aImageId, aFileName);
- }
+ OUString aImageId = m_pTextExport->GetDrawingML().WriteImage(aGraphic, false);
pAttrList->add(FSNS(XML_r, XML_id), aImageId);
imageData = true;
}
@@ -740,15 +732,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle&
aStream.Seek(0);
Graphic aGraphic;
GraphicConverter::Import(aStream, aGraphic);
-
- BitmapChecksum nChecksum = aGraphic.GetChecksum();
- OUString aImageId = m_pTextExport->FindRelId(nChecksum);
- if (aImageId.isEmpty())
- {
- OUString aFileName;
- aImageId = m_pTextExport->GetDrawingML().WriteImage(aGraphic, false, &aFileName);
- m_pTextExport->CacheRelId(nChecksum, aImageId, aFileName);
- }
+ OUString aImageId = m_pTextExport->GetDrawingML().WriteImage(aGraphic, false);
pAttrList->add(FSNS(XML_r, XML_id), aImageId);
imageData = true;
}