From f7d6f3e4e3fda3cd4936880918e2831246634a3e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 28 Jun 2016 11:15:19 +0200 Subject: svtools: survive swapout/in of graphic with embedded pdf Use case is to insert a pdf file in Impress, then choose Save from the context menu of the image. On one hand, for some reason only bitmap images can be saved, so add an exception for the graphic-with-pdf case. SVG is not affected, as it counts as bitmap with its PNG replacement image, it seems. On the other hand, copying the GraphicObject around triggers swapout/swapin of the graphic, and there the original pdf data was lost, fix that. Change-Id: I8b4b67cd951e39b0250a101766f487ddb1088cab Reviewed-on: https://gerrit.libreoffice.org/26739 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- svtools/source/graphic/grfcache.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'svtools/source') diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx index fa3f9bf70a71..43f4d07b28c3 100644 --- a/svtools/source/graphic/grfcache.cxx +++ b/svtools/source/graphic/grfcache.cxx @@ -34,6 +34,8 @@ #define MAX_BMP_EXTENT 4096 +using namespace com::sun::star; + static const char aHexData[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; class GraphicID @@ -155,6 +157,7 @@ private: // SvgData support SvgDataPtr maSvgData; + uno::Sequence maPdfData; bool ImplInit( const GraphicObject& rObj ); void ImplFillSubstitute( Graphic& rSubstitute ); @@ -247,6 +250,8 @@ bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj ) case GraphicType::GdiMetafile: { mpMtf = new GDIMetaFile( rGraphic.GetGDIMetaFile() ); + if (rGraphic.getPdfData().hasElements()) + maPdfData = rGraphic.getPdfData(); } break; @@ -293,6 +298,8 @@ void GraphicCacheEntry::ImplFillSubstitute( Graphic& rSubstitute ) else if( mpMtf ) { rSubstitute = *mpMtf; + if (maPdfData.hasElements()) + rSubstitute.setPdfData(maPdfData); } else { @@ -379,6 +386,7 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut( const GraphicObject& /*rObj* // #119176# also reset SvgData maSvgData.reset(); + maPdfData = uno::Sequence(); } } -- cgit