summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-11-21 17:46:53 +0100
committerEike Rathke <erack@redhat.com>2017-11-21 17:49:53 +0100
commitfe3b63f656014675dfc6069f1aaaee9e306a7245 (patch)
tree07d5a023c2c2022236b4f6cdedf510ca213abece
parentbeacf493dc4c8a62148ed75e959688d676ce0243 (diff)
Introduce and use ScCellShell::HasClipboardFormat(), tdf#50746 follow-up
Intead of gathering all possible formats just to check one.. Change-Id: I80f3a2c957492c9f72084c69b867aaccfbdd0530
-rw-r--r--sc/source/ui/inc/cellsh.hxx2
-rw-r--r--sc/source/ui/view/cellsh.cxx7
-rw-r--r--sc/source/ui/view/cellsh1.cxx17
3 files changed, 11 insertions, 15 deletions
diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx
index a60d1fcafaae..30e89c4612e0 100644
--- a/sc/source/ui/inc/cellsh.hxx
+++ b/sc/source/ui/inc/cellsh.hxx
@@ -31,6 +31,7 @@
#include <address.hxx>
#include <vcl/window.hxx>
#include <rtl/ref.hxx>
+#include <sot/formats.hxx>
class SvxClipboardFormatItem;
class TransferableDataHelper;
@@ -55,6 +56,7 @@ private:
bool bPastePossible;
void GetPossibleClipboardFormats( SvxClipboardFormatItem& rFormats );
+ bool HasClipboardFormat( SotClipboardFormatId nFormatId );
void ExecuteExternalSource(
const OUString& _rFile, const OUString& _rFilter, const OUString& _rOptions,
const OUString& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest );
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 086c33e4fa3d..8167be10088f 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -514,6 +514,13 @@ static bool lcl_IsCellPastePossible( const TransferableDataHelper& rData )
return bPossible;
}
+bool ScCellShell::HasClipboardFormat( SotClipboardFormatId nFormatId )
+{
+ vcl::Window* pWin = GetViewData()->GetActiveWin();
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ));
+ return aDataHelper.HasFormat( nFormatId );
+}
+
IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
{
bPastePossible = lcl_IsCellPastePossible( *pDataHelper );
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index ba1b05f93483..ded46a83bde3 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1651,21 +1651,8 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
// and paste the SotClipboardFormatId::STRING_TSVC if it is available.
// Which makes a difference if the clipboard contains cells with embedded line breaks.
- SotClipboardFormatId nFormat = SotClipboardFormatId::STRING;
- {
- SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
- GetPossibleClipboardFormats( aFormats );
-
- const sal_uInt16 nFormatCount = aFormats.Count();
- for (sal_uInt16 i=0; i<nFormatCount; i++)
- {
- if (SotClipboardFormatId::STRING_TSVC == aFormats.GetClipbrdFormatId( i ))
- {
- nFormat = SotClipboardFormatId::STRING_TSVC;
- break;
- }
- }
- }
+ SotClipboardFormatId nFormat = HasClipboardFormat( SotClipboardFormatId::STRING_TSVC) ?
+ SotClipboardFormatId::STRING_TSVC : SotClipboardFormatId::STRING;
const bool bRet = pTabViewShell->PasteFromSystem(nFormat, true); // TRUE: no error messages
if ( bRet )