diff options
author | Eike Rathke <erack@redhat.com> | 2017-11-21 17:46:53 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-11-21 17:49:53 +0100 |
commit | fe3b63f656014675dfc6069f1aaaee9e306a7245 (patch) | |
tree | 07d5a023c2c2022236b4f6cdedf510ca213abece /sc/source/ui/view | |
parent | beacf493dc4c8a62148ed75e959688d676ce0243 (diff) |
Introduce and use ScCellShell::HasClipboardFormat(), tdf#50746 follow-up
Intead of gathering all possible formats just to check one..
Change-Id: I80f3a2c957492c9f72084c69b867aaccfbdd0530
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r-- | sc/source/ui/view/cellsh.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 17 |
2 files changed, 9 insertions, 15 deletions
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 ) |