editeng/source/editeng/impedit.cxx | 13 +++++- editeng/source/editeng/impedit.hxx | 1 include/vcl/transfer.hxx | 4 ++ vcl/source/treelist/transfer2.cxx | 41 +++++++++++++++++++++ vcl/source/window/window.cxx | 69 +++++-------------------------------- 5 files changed, 67 insertions(+), 61 deletions(-)
New commits: commit f8f43e55ec4ae7e436a5043fe6f4bae7b39cc6ad Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Tue Jul 9 20:29:05 2019 +0000 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Wed Jul 10 17:51:43 2019 +0200 tdf#126316 revert Clipboard to PrimarySelection Regression from commit ce9795954d39 ("fix crash in header/footer calc dialog"), which replaced some GetPrimarySelection() calls with GetClipboard() calls. This replaces the Window class calls for clipboard with global GetSystem* calls in vcl/transfer.hxx. Not sure if this is the best place, but the crowded Window class is definitly not. Change-Id: Ic5f9e575c1ac5d43df234426c5616eca616dea30 Reviewed-on: https://gerrit.libreoffice.org/75318 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 15937acb1cf2..15a25c4cdd68 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -1279,7 +1279,14 @@ Reference<css::datatransfer::clipboard::XClipboard> ImpEditView::GetClipboard() { if (vcl::Window* pWindow = GetWindow()) return pWindow->GetClipboard(); - return css::datatransfer::clipboard::SystemClipboard::create(comphelper::getProcessComponentContext()); + return GetSystemClipboard(); +} + +Reference<css::datatransfer::clipboard::XClipboard> ImpEditView::GetSelection() +{ + if (vcl::Window* pWindow = GetWindow()) + return pWindow->GetPrimarySelection(); + return GetSystemPrimarySelection(); } bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * pFrameWin ) @@ -1343,12 +1350,12 @@ bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent ) if ( rMouseEvent.IsMiddle() && !bReadOnly && ( pWindow->GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) ) { - Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetClipboard()); + Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetSelection()); Paste( aClipBoard ); } else if ( rMouseEvent.IsLeft() && GetEditSelection().HasRange() ) { - Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetClipboard()); + Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetSelection()); CutCopy( aClipBoard, false ); } } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index b7f7d5db0323..0ef1130322c0 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -283,6 +283,7 @@ private: void InvalidateAtWindow(const tools::Rectangle& rRect); css::uno::Reference<css::datatransfer::clipboard::XClipboard> GetClipboard(); + css::uno::Reference<css::datatransfer::clipboard::XClipboard> GetSelection(); protected: diff --git a/include/vcl/transfer.hxx b/include/vcl/transfer.hxx index 3e1c4ee5b325..888fe254e115 100644 --- a/include/vcl/transfer.hxx +++ b/include/vcl/transfer.hxx @@ -31,6 +31,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/datatransfer/XTransferable2.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp> #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> #include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp> @@ -503,6 +504,9 @@ public: const Link<sal_Int8,void>& rCallbck ); }; +css::uno::Reference<css::datatransfer::clipboard::XClipboard> VCL_DLLPUBLIC GetSystemClipboard(); +css::uno::Reference<css::datatransfer::clipboard::XClipboard> VCL_DLLPUBLIC GetSystemPrimarySelection(); + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/treelist/transfer2.cxx b/vcl/source/treelist/transfer2.cxx index a731ec2abf23..9160ba416e02 100644 --- a/vcl/source/treelist/transfer2.cxx +++ b/vcl/source/treelist/transfer2.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <config_features.h> + #include <osl/mutex.hxx> #include <sot/exchange.hxx> #include <sot/storage.hxx> @@ -26,9 +28,12 @@ #include <vcl/svapp.hxx> #include <vcl/window.hxx> #include <comphelper/fileformat.h> +#include <comphelper/processfactory.hxx> +#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp> #include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp> #include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp> #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +#include <com/sun/star/uno/DeploymentException.hpp> #include <svl/urlbmk.hxx> #include <vcl/inetimg.hxx> #include <vcl/imap.hxx> @@ -460,4 +465,40 @@ void TransferDataContainer::DragFinished( sal_Int8 nDropAction ) pImpl->aFinshedLnk.Call( nDropAction ); } +Reference<XClipboard> GetSystemClipboard() +{ + Reference<XClipboard> xClipboard; + try + { + xClipboard = css::datatransfer::clipboard::SystemClipboard::create( + comphelper::getProcessComponentContext()); + } + catch (DeploymentException const &) {} + return xClipboard; +} + +Reference<XClipboard> GetSystemPrimarySelection() +{ + Reference<XClipboard> xSelection; + try + { + Reference<XComponentContext> xContext(comphelper::getProcessComponentContext()); +#if HAVE_FEATURE_X11 + // A hack, making the primary selection available as an instance + // of the SystemClipboard service on X11: + Sequence< Any > args(1); + args[0] <<= OUString("PRIMARY"); + xSelection.set(xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.datatransfer.clipboard.SystemClipboard", args, xContext), UNO_QUERY_THROW); +#else + static Reference< XClipboard > s_xSelection( + xContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.datatransfer.clipboard.GenericClipboard", xContext), UNO_QUERY); + xSelection = s_xSelection; +#endif + } + catch (RuntimeException const &) {} + return xSelection; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 826ba0cbadbe..3b26f70d7040 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -46,6 +46,7 @@ #include <vcl/sysdata.hxx> #include <vcl/ptrstyle.hxx> #include <vcl/IDialogRenderable.hxx> +#include <vcl/transfer.hxx> #include <vcl/uitest/uiobject.hxx> #include <vcl/uitest/uitest.hxx> @@ -3273,68 +3274,20 @@ void Window::SetClipboard(Reference<XClipboard> const & xClipboard) Reference< XClipboard > Window::GetClipboard() { - - if( mpWindowImpl->mpFrameData ) - { - if( ! mpWindowImpl->mpFrameData->mxClipboard.is() ) - { - try - { - mpWindowImpl->mpFrameData->mxClipboard - = css::datatransfer::clipboard::SystemClipboard::create( - comphelper::getProcessComponentContext()); - } - catch (DeploymentException const &) - { - TOOLS_WARN_EXCEPTION("vcl.window", "ignoring"); - } - } - - return mpWindowImpl->mpFrameData->mxClipboard; - } - - return static_cast < XClipboard * > (nullptr); + if (!mpWindowImpl->mpFrameData) + return static_cast<XClipboard*>(nullptr); + if (!mpWindowImpl->mpFrameData->mxClipboard.is()) + mpWindowImpl->mpFrameData->mxClipboard = GetSystemClipboard(); + return mpWindowImpl->mpFrameData->mxClipboard; } Reference< XClipboard > Window::GetPrimarySelection() { - - if( mpWindowImpl->mpFrameData ) - { - if( ! mpWindowImpl->mpFrameData->mxSelection.is() ) - { - try - { - Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); - -#if HAVE_FEATURE_X11 - // A hack, making the primary selection available as an instance - // of the SystemClipboard service on X11: - Sequence< Any > args(1); - args[0] <<= OUString("PRIMARY"); - mpWindowImpl->mpFrameData->mxSelection.set( - (xContext->getServiceManager()-> - createInstanceWithArgumentsAndContext( - "com.sun.star.datatransfer.clipboard.SystemClipboard", - args, xContext)), - UNO_QUERY_THROW); -#else - static Reference< XClipboard > s_xSelection( - xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.datatransfer.clipboard.GenericClipboard", xContext ), UNO_QUERY ); - - mpWindowImpl->mpFrameData->mxSelection = s_xSelection; -#endif - } - catch (RuntimeException const &) - { - TOOLS_WARN_EXCEPTION("vcl.window", "ignoring"); - } - } - - return mpWindowImpl->mpFrameData->mxSelection; - } - - return static_cast < XClipboard * > (nullptr); + if (!mpWindowImpl->mpFrameData) + return static_cast<XClipboard*>(nullptr); + if (!mpWindowImpl->mpFrameData->mxSelection.is()) + mpWindowImpl->mpFrameData->mxSelection = GetSystemPrimarySelection(); + return mpWindowImpl->mpFrameData->mxSelection; } void Window::RecordLayoutData( vcl::ControlLayoutData* pLayout, const tools::Rectangle& rRect ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits