summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-06-28 11:15:19 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-06-28 10:49:30 +0000
commitf7d6f3e4e3fda3cd4936880918e2831246634a3e (patch)
treea4f75f0ed98cc1ea56f48dab8598a5529f35db21
parentb5dfe9b95fa0f995542c151d8e1b79a03e91c626 (diff)
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 <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--sd/source/ui/view/drviews2.cxx6
-rw-r--r--svtools/source/graphic/grfcache.cxx8
2 files changed, 11 insertions, 3 deletions
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index b603583845fc..bec691d69132 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -926,10 +926,10 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
if( rMarkList.GetMarkCount() == 1 )
{
- SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
- if( pObj && dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap )
+ const SdrGrafObj* pObj = dynamic_cast<const SdrGrafObj*>(rMarkList.GetMark(0)->GetMarkedSdrObj());
+ if (pObj && (pObj->GetGraphicType() == GraphicType::Bitmap || pObj->GetGraphicObject().GetGraphic().getPdfData().hasElements()))
{
- GraphicObject aGraphicObject( static_cast<SdrGrafObj*>( pObj )->GetGraphicObject() );
+ GraphicObject aGraphicObject(pObj->GetGraphicObject());
{
GraphicHelper::ExportGraphic( aGraphicObject.GetGraphic(), "" );
}
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<sal_Int8> 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<sal_Int8>();
}
}