Introduce and use ScCellShell::HasClipboardFormat(), tdf#50746 follow-up
Intead of gathering all possible formats just to check one.. Change-Id: I80f3a2c957492c9f72084c69b867aaccfbdd0530
This commit is contained in:
parent
beacf493dc
commit
fe3b63f656
3 changed files with 11 additions and 15 deletions
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in a new issue