[Libreoffice-commits] core.git: sc/source
Eike Rathke
erack at redhat.com
Tue Nov 21 16:50:38 UTC 2017
sc/source/ui/inc/cellsh.hxx | 2 ++
sc/source/ui/view/cellsh.cxx | 7 +++++++
sc/source/ui/view/cellsh1.cxx | 17 ++---------------
3 files changed, 11 insertions(+), 15 deletions(-)
New commits:
commit fe3b63f656014675dfc6069f1aaaee9e306a7245
Author: Eike Rathke <erack at redhat.com>
Date: Tue Nov 21 17:46:53 2017 +0100
Introduce and use ScCellShell::HasClipboardFormat(), tdf#50746 follow-up
Intead of gathering all possible formats just to check one..
Change-Id: I80f3a2c957492c9f72084c69b867aaccfbdd0530
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 )
More information about the Libreoffice-commits
mailing list