diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-04-11 07:52:38 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-04-25 06:58:07 +0200 |
commit | 33c2443134cfd2110258d5424645ace9e1db127f (patch) | |
tree | ade87f7ad0b6deef7d77eb51a53bbd93b3a45dd3 /oox | |
parent | 2f48aae12ae949056654cb172873f4025104af67 (diff) |
oox: extract image / graphic export into GraphicExport class
Change-Id: Ib37aee6c5f664e80d45530dae0de9c172e0773a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150259
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/drawingml.cxx | 34 |
1 files changed, 13 insertions, 21 deletions
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<XPropertySet>& 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<XOutputStream> xOutStream = mpFB->openFragmentStream( + Reference<XOutputStream> 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<css::drawing::XShape>& xShape) { SdrMediaObj* pMediaObj = dynamic_cast<SdrMediaObj*>(SdrObject::getSdrObjectFromXShape(xShape)); |