include/vcl/transfer.hxx | 1 + vcl/source/treelist/transfer.cxx | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-)
New commits: commit 3f3b2aa014fd8c610825ecdf0c91fe6271a8aad3 Author: Caolán McNamara <[email protected]> AuthorDate: Sun Jan 19 17:06:43 2020 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Sun Jan 19 20:24:29 2020 +0100 refactor CreateFromClipboard to support not passing in a vcl::Window Change-Id: I0474f390b34649debae18defdd1e860d7806b045 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87044 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/include/vcl/transfer.hxx b/include/vcl/transfer.hxx index 188e78132380..2a72fd6fab23 100644 --- a/include/vcl/transfer.hxx +++ b/include/vcl/transfer.hxx @@ -363,6 +363,7 @@ public: css::uno::Reference<css::io::XInputStream> GetInputStream( SotClipboardFormatId nFormat, const OUString& rDestDoc ); css::uno::Reference<css::io::XInputStream> GetInputStream( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); + static TransferableDataHelper CreateFromClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& rClipboard); static TransferableDataHelper CreateFromSystemClipboard( vcl::Window * pWindow ); static TransferableDataHelper CreateFromSelection( vcl::Window * pWindow ); static bool IsEqual( const css::datatransfer::DataFlavor& rInternalFlavor, diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx index 6383e43e0c70..51f6f2e14f8f 100644 --- a/vcl/source/treelist/transfer.cxx +++ b/vcl/source/treelist/transfer.cxx @@ -2118,28 +2118,21 @@ void TransferableDataHelper::StopClipboardListening( ) } } - -TransferableDataHelper TransferableDataHelper::CreateFromSystemClipboard( vcl::Window * pWindow ) +TransferableDataHelper TransferableDataHelper::CreateFromClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& rClipboard) { - DBG_ASSERT( pWindow, "Window pointer is NULL" ); - - Reference< XClipboard > xClipboard; TransferableDataHelper aRet; - if( pWindow ) - xClipboard = pWindow->GetClipboard(); - - if( xClipboard.is() ) + if( rClipboard.is() ) { try { - Reference< XTransferable > xTransferable( xClipboard->getContents() ); + Reference< XTransferable > xTransferable( rClipboard->getContents() ); if( xTransferable.is() ) { aRet = TransferableDataHelper( xTransferable ); // also copy the clipboard - aRet.mxClipboard = xClipboard; + aRet.mxClipboard = rClipboard; } } catch( const css::uno::Exception& ) @@ -2150,6 +2143,18 @@ TransferableDataHelper TransferableDataHelper::CreateFromSystemClipboard( vcl::W return aRet; } +TransferableDataHelper TransferableDataHelper::CreateFromSystemClipboard( vcl::Window * pWindow ) +{ + DBG_ASSERT( pWindow, "Window pointer is NULL" ); + + Reference< XClipboard > xClipboard; + + if( pWindow ) + xClipboard = pWindow->GetClipboard(); + + return CreateFromClipboard(xClipboard); +} + TransferableDataHelper TransferableDataHelper::CreateFromSelection( vcl::Window* pWindow ) { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
