From 33c2443134cfd2110258d5424645ace9e1db127f Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Tue, 11 Apr 2023 07:52:38 +0900 Subject: oox: extract image / graphic export into GraphicExport class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib37aee6c5f664e80d45530dae0de9c172e0773a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150259 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- oox/source/export/drawingml.cxx | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'oox') diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 773aa6c4ae0c..97c5210d95f6 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1467,29 +1467,15 @@ void DrawingML::WriteOutline( const Reference& rXPropSet, Referenc const char* DrawingML::GetComponentDir() const { - switch ( meDocumentType ) - { - case DOCUMENT_DOCX: return "word"; - case DOCUMENT_PPTX: return "ppt"; - case DOCUMENT_XLSX: return "xl"; - } - - return "unknown"; + return getComponentDir(meDocumentType); } const char* DrawingML::GetRelationCompPrefix() const { - switch ( meDocumentType ) - { - case DOCUMENT_DOCX: return ""; - case DOCUMENT_PPTX: - case DOCUMENT_XLSX: return "../"; - } - - return "unknown"; + return getRelationCompPrefix(meDocumentType); } -OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) +OUString GraphicExport::write(const Graphic& rGraphic , bool bRelPathToMedia) { GfxLink aLink = rGraphic.GetGfxLink (); BitmapChecksum aChecksum = rGraphic.GetChecksum(); @@ -1586,9 +1572,9 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) } sal_Int32 nImageCount = rGraphicExportCache.nextImageCount(); - Reference xOutStream = mpFB->openFragmentStream( + Reference xOutStream = mpFilterBase->openFragmentStream( OUStringBuffer() - .appendAscii(GetComponentDir()) + .appendAscii(getComponentDir(meDocumentType)) .append("/media/image" + OUString::number(nImageCount)) .appendAscii(pExtension) .makeStringAndClear(), @@ -1601,7 +1587,7 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) if (bRelPathToMedia) sRelationCompPrefix = "../"; else - sRelationCompPrefix = GetRelationCompPrefix(); + sRelationCompPrefix = getRelationCompPrefix(meDocumentType); sPath = OUStringBuffer() .appendAscii(sRelationCompPrefix.getStr()) .appendAscii(sRelPathToMedia.getStr()) @@ -1612,13 +1598,19 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) rGraphicExportCache.addExportGraphics(aChecksum, sPath); } - sRelId = mpFB->addRelation( mpFS->getOutputStream(), + sRelId = mpFilterBase->addRelation( mpFS->getOutputStream(), oox::getRelationship(Relationship::IMAGE), sPath ); return sRelId; } +OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia ) +{ + GraphicExport exporter(mpFS, mpFB, meDocumentType); + return exporter.write(rGraphic, bRelPathToMedia); +} + void DrawingML::WriteMediaNonVisualProperties(const css::uno::Reference& xShape) { SdrMediaObj* pMediaObj = dynamic_cast(SdrObject::getSdrObjectFromXShape(xShape)); -- cgit