summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svtools/transfer.hxx10
-rw-r--r--sc/source/ui/view/viewfun5.cxx7
-rw-r--r--svtools/source/misc/transfer.cxx6
-rw-r--r--sw/source/ui/dochdl/swdtflvr.cxx7
4 files changed, 25 insertions, 5 deletions
diff --git a/include/svtools/transfer.hxx b/include/svtools/transfer.hxx
index 8980e88303f2..969312bc2f38 100644
--- a/include/svtools/transfer.hxx
+++ b/include/svtools/transfer.hxx
@@ -321,7 +321,15 @@ public:
sal_Bool GetBitmapEx( SotFormatStringId nFormat, BitmapEx& rBmp );
sal_Bool GetBitmapEx( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, BitmapEx& rBmp );
- sal_Bool GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf );
+ /** Return as GDI metafile.
+
+ @param nMaxAction Allows you to limit the amount of actions; defaults to 0 which means no limit.
+
+ Whet you eg. Ctrl+a in Excel, you can get the entire sheet as
+ metafile, with over 3 million (!) actions; which is just too large for
+ any reasonable handling - and you need to set a limit.
+ */
+ sal_Bool GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf, size_t nMaxActions = 0 );
sal_Bool GetGDIMetaFile( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, GDIMetaFile& rMtf );
sal_Bool GetGraphic( SotFormatStringId nFormat, Graphic& rGraphic );
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 3a4457931590..c4107ffc6ad4 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -181,8 +181,13 @@ bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
Graphic aGraphic;
sal_uLong nGrFormat = 0;
- if (aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
+ // limit the size of the preview metafile to 100000 actions
+ GDIMetaFile aMetafile;
+ if (aDataHelper.GetGDIMetaFile(FORMAT_GDIMETAFILE, aMetafile, 100000))
+ {
nGrFormat = SOT_FORMAT_GDIMETAFILE;
+ aGraphic = aMetafile;
+ }
// insert replacement image ( if there is one ) into the object helper
if ( nGrFormat )
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index a7b63547c57f..def8b3d54ae0 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -1777,10 +1777,12 @@ sal_Bool TransferableDataHelper::GetBitmapEx( const DataFlavor& rFlavor, BitmapE
-sal_Bool TransferableDataHelper::GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf )
+sal_Bool TransferableDataHelper::GetGDIMetaFile(SotFormatStringId nFormat, GDIMetaFile& rMtf, size_t nMaxActions)
{
DataFlavor aFlavor;
- return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetGDIMetaFile( aFlavor, rMtf ) );
+ return SotExchange::GetFormatDataFlavor(nFormat, aFlavor) &&
+ GetGDIMetaFile(aFlavor, rMtf) &&
+ (nMaxActions == 0 || rMtf.GetActionSize() < nMaxActions);
}
diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx
index 085115cdf1fd..9d4acca9e51c 100644
--- a/sw/source/ui/dochdl/swdtflvr.cxx
+++ b/sw/source/ui/dochdl/swdtflvr.cxx
@@ -1816,8 +1816,13 @@ bool SwTransferable::_PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
Graphic aGraphic;
sal_uLong nGrFormat = 0;
- if( rData.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
+ // limit the size of the preview metafile to 100000 actions
+ GDIMetaFile aMetafile;
+ if (rData.GetGDIMetaFile(FORMAT_GDIMETAFILE, aMetafile, 100000))
+ {
nGrFormat = SOT_FORMAT_GDIMETAFILE;
+ aGraphic = aMetafile;
+ }
// insert replacement image ( if there is one ) into the object helper
if ( nGrFormat )