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>
This commit is contained in:
parent
b5dfe9b95f
commit
f7d6f3e4e3
2 changed files with 11 additions and 3 deletions
|
@ -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(), "" );
|
||||
}
|
||||
|
|
|
@ -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>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue