summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcvcastro@gmail.com>2015-02-22 19:30:42 -0400
committerAndras Timar <andras.timar@collabora.com>2015-03-05 12:58:38 +0100
commit997195580a4436409c752a357391107ffd91119e (patch)
tree8fdaf3e6e82dab8f5ad14f897d91e6d6d1bcdb02
parentfe00fba292a9ad1c416acc199e7aba6657ab40b3 (diff)
Resolves tdf#71095 Calc doesn't paste images copied from some web browsers
Fixed. When I try to paste an web image copied from web browser, it paste now Reviewed-on: https://gerrit.libreoffice.org/14529 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit b05330c64799067ca2e0b8ea8bfdee8ce8b023b2) Signed-off-by: Andras Timar <andras.timar@collabora.com> Conflicts: sc/source/ui/view/viewfun3.cxx Change-Id: I696feb3438022b506303b2f354ac9c4d306e08f4
-rw-r--r--sc/source/ui/view/viewfun3.cxx158
1 files changed, 95 insertions, 63 deletions
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 562135a0d5e0..ecff06eb1013 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -475,80 +475,112 @@ void ScViewFunc::PasteFromSystem()
sal_uLong nBiff8 = SotExchange::RegisterFormatName(OUString("Biff8"));
sal_uLong nBiff5 = SotExchange::RegisterFormatName(OUString("Biff5"));
- // als erstes SvDraw-Model, dann Grafik
- // (Grafik darf nur bei einzelner Grafik drinstehen)
-
- if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ))
+ sal_uInt16 nDestination = EXCHG_DEST_SCDOC_FREE_AREA;
+ sal_uInt16 nSourceOptions = EXCHG_IN_ACTION_COPY;
+ sal_uLong nFormat; // output param for GetExchangeAction
+ sal_uInt16 nEventAction; // output param for GetExchangeAction
+
+ uno::Reference<com::sun::star::datatransfer::XTransferable> xTransferable( aDataHelper.GetXTransferable() );
+ sal_uInt16 nAction = SotExchange::GetExchangeAction(
+ aDataHelper.GetDataFlavorExVector(),
+ nDestination,
+ nSourceOptions,
+ EXCHG_IN_ACTION_DEFAULT,
+ nFormat, nEventAction, 0,
+ &xTransferable );
+
+ if ( nAction != EXCHG_INOUT_ACTION_NONE )
{
- // special case for tables from drawing
- if( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
- {
- PasteFromSystem( FORMAT_RTF );
- }
- else
+ nAction = ( nAction & EXCHG_ACTION_MASK );
+
+ switch( nAction )
{
- PasteFromSystem( SOT_FORMATSTR_ID_DRAWING );
+ case EXCHG_OUT_ACTION_INSERT_SVXB:
+ case EXCHG_OUT_ACTION_INSERT_GDIMETAFILE:
+ case EXCHG_OUT_ACTION_INSERT_BITMAP:
+ case EXCHG_OUT_ACTION_INSERT_GRAPH:
+ // FORMAT_BITMAP
+ // SOT_FORMATSTR_ID_PNG
+ // FORMAT_GDIMETAFILE
+ // SOT_FORMATSTR_ID_SVXB
+ PasteFromSystem(nFormat);
+ break;
+ default:
+ nAction = EXCHG_INOUT_ACTION_NONE;
}
}
- else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ))
- PasteFromSystem( SOT_FORMATSTR_ID_SVXB );
- else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ))
- {
- // If it's a Writer object, insert RTF instead of OLE
- // Else, if the class id is all-zero, and SYLK is available,
- // it probably is spreadsheet cells that have been put
- // on the clipboard by OOo, so use the SYLK. (fdo#31077)
+ if ( nAction == EXCHG_INOUT_ACTION_NONE )
+ {
+ // first SvDraw-model, then drawing
+ // (only one drawing is allowed)
- bool bDoRtf = false;
- TransferableObjectDescriptor aObjDesc;
- if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) )
+ if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ))
{
- bDoRtf = ( ( aObjDesc.maClassName == SvGlobalName( SO3_SW_CLASSID ) ||
- aObjDesc.maClassName == SvGlobalName( SO3_SWWEB_CLASSID ) )
- && aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ // special case for tables from drawing
+ if( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
+ {
+ PasteFromSystem( FORMAT_RTF );
+ }
+ else
+ {
+ PasteFromSystem( SOT_FORMATSTR_ID_DRAWING );
+ }
}
- if ( bDoRtf )
- PasteFromSystem( FORMAT_RTF );
- else if ( aObjDesc.maClassName == SvGlobalName( 0,0,0,0,0,0,0,0,0,0,0 )
- && aDataHelper.HasFormat( SOT_FORMATSTR_ID_SYLK ))
- PasteFromSystem( SOT_FORMATSTR_ID_SYLK );
- else
- PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ))
+ {
+ // If it's a Writer object, insert RTF instead of OLE
+
+ // Else, if the class id is all-zero, and SYLK is available,
+ // it probably is spreadsheet cells that have been put
+ // on the clipboard by OOo, so use the SYLK. (fdo#31077)
+
+ bool bDoRtf = false;
+ TransferableObjectDescriptor aObjDesc;
+ if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) )
+ {
+ bDoRtf = ( ( aObjDesc.maClassName == SvGlobalName( SO3_SW_CLASSID ) ||
+ aObjDesc.maClassName == SvGlobalName( SO3_SWWEB_CLASSID ) )
+ && aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ }
+ if ( bDoRtf )
+ PasteFromSystem( FORMAT_RTF );
+ else if ( aObjDesc.maClassName == SvGlobalName( 0,0,0,0,0,0,0,0,0,0,0 )
+ && aDataHelper.HasFormat( SOT_FORMATSTR_ID_SYLK ))
+ PasteFromSystem( SOT_FORMATSTR_ID_SYLK );
+ else
+ PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ }
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ))
+ PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE );
+ // the following format can not affect scenario from #89579#
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ))
+ PasteFromSystem( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE );
+ // FORMAT_PRIVATE no longer here (can't work if pOwnClip is NULL)
+ else if (aDataHelper.HasFormat(nBiff8)) // before xxx_OLE formats
+ PasteFromSystem(nBiff8);
+ else if (aDataHelper.HasFormat(nBiff5))
+ PasteFromSystem(nBiff5);
+ else if (aDataHelper.HasFormat(FORMAT_RTF))
+ PasteFromSystem(FORMAT_RTF);
+ else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML))
+ PasteFromSystem(SOT_FORMATSTR_ID_HTML);
+ else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE))
+ PasteFromSystem(SOT_FORMATSTR_ID_HTML_SIMPLE);
+ else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_SYLK))
+ PasteFromSystem(SOT_FORMATSTR_ID_SYLK);
+ else if (aDataHelper.HasFormat(FORMAT_STRING))
+ PasteFromSystem(FORMAT_STRING);
+ // xxx_OLE formats come last, like in SotExchange tables
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ))
+ PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE );
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ))
+ PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE_OLE );
}
- else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ))
- PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE );
- // the following format can not affect scenario from #89579#
- else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ))
- PasteFromSystem( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE );
- // FORMAT_PRIVATE no longer here (can't work if pOwnClip is NULL)
- else if (aDataHelper.HasFormat(nBiff8)) // before xxx_OLE formats
- PasteFromSystem(nBiff8);
- else if (aDataHelper.HasFormat(nBiff5))
- PasteFromSystem(nBiff5);
- else if (aDataHelper.HasFormat(FORMAT_RTF))
- PasteFromSystem(FORMAT_RTF);
- else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML))
- PasteFromSystem(SOT_FORMATSTR_ID_HTML);
- else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE))
- PasteFromSystem(SOT_FORMATSTR_ID_HTML_SIMPLE);
- else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_SYLK))
- PasteFromSystem(SOT_FORMATSTR_ID_SYLK);
- else if (aDataHelper.HasFormat(FORMAT_STRING))
- PasteFromSystem(FORMAT_STRING);
- else if (aDataHelper.HasFormat(FORMAT_GDIMETAFILE))
- PasteFromSystem(FORMAT_GDIMETAFILE);
- else if (aDataHelper.HasFormat(FORMAT_BITMAP))
- PasteFromSystem(FORMAT_BITMAP);
- // xxx_OLE formats come last, like in SotExchange tables
- else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ))
- PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE );
- else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ))
- PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE_OLE );
}
}
- // keine Fehlermeldung, weil SID_PASTE in der idl das FastCall-Flag hat,
- // also auch gerufen wird, wenn nichts im Clipboard steht (#42531#)
+ // no exception-> SID_PASTE has FastCall-flag from idl
+ // will be called in case of empty clipboard (#42531#)
}
void ScViewFunc::PasteFromTransferable( const uno::Reference<datatransfer::XTransferable>& rxTransferable )