summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-07-09 20:29:05 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-07-15 15:45:41 +0200
commitafadb14164ccd559a36f00efa0f01bac1813bc0e (patch)
tree02e576a570fb26f64405dec139e4da86a3535942 /vcl
parent4109dfff009f017e8994ea0a57119e79291ca2c8 (diff)
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. Reviewed-on: https://gerrit.libreoffice.org/75318 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de> (cherry picked from commit f8f43e55ec4ae7e436a5043fe6f4bae7b39cc6ad) Change-Id: Ic5f9e575c1ac5d43df234426c5616eca616dea30 Reviewed-on: https://gerrit.libreoffice.org/75370 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/treelist/transfer2.cxx41
-rw-r--r--vcl/source/window/window.cxx69
2 files changed, 52 insertions, 58 deletions
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 d590daf4442d..9b7a1580bbcf 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 & e)
- {
- SAL_WARN("vcl.window", "ignoring " << e);
- }
- }
-
- 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 & e)
- {
- SAL_WARN("vcl.window", "ignoring " << e);
- }
- }
-
- 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 )