summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-03-08 14:13:16 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-03-09 16:57:56 +0100
commit55b305e21f103b74669a31b6dbed8596ecc3ca09 (patch)
tree884a5b657425a1161edf93e4ca04d98dfc9d52f8
parent3edfc84c7a1df53ccea921e2dc4e42088bafcb0c (diff)
fetch/set/clear primary selection without intermediate vcl::Window
the intermediate layer doesn't do anything useful Change-Id: I00564f43db8914445ea4013c6f387c7d7c783427 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112170 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--editeng/source/editeng/impedit.cxx11
-rw-r--r--editeng/source/editeng/impedit.hxx1
-rw-r--r--include/vcl/transfer.hxx6
-rw-r--r--include/vcl/window.hxx1
-rw-r--r--sc/source/ui/view/tabview3.cxx2
-rw-r--r--sc/source/ui/view/tabview5.cxx2
-rw-r--r--sd/source/ui/inc/View.hxx2
-rw-r--r--sd/source/ui/view/sdview2.cxx8
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx4
-rw-r--r--vcl/source/control/edit.cxx5
-rw-r--r--vcl/source/edit/textview.cxx7
-rw-r--r--vcl/source/treelist/transfer.cxx20
-rw-r--r--vcl/source/window/window.cxx9
13 files changed, 26 insertions, 52 deletions
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index f42ae0071a3c..a42223732294 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1608,13 +1608,6 @@ Reference<css::datatransfer::clipboard::XClipboard> ImpEditView::GetClipboard()
return GetSystemClipboard();
}
-Reference<css::datatransfer::clipboard::XClipboard> ImpEditView::GetSelection() const
-{
- if (vcl::Window* pWindow = GetWindow())
- return pWindow->GetPrimarySelection();
- return GetSystemPrimarySelection();
-}
-
bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * pFrameWin )
{
bool bDone = false;
@@ -1674,12 +1667,12 @@ bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent )
if ( rMouseEvent.IsMiddle() && !bReadOnly &&
Application::GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection )
{
- Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetSelection());
+ Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetSystemPrimarySelection());
Paste( aClipBoard );
}
else if ( rMouseEvent.IsLeft() && GetEditSelection().HasRange() )
{
- Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetSelection());
+ Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetSystemPrimarySelection());
CutCopy( aClipBoard, false );
}
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 8f124dd4ed84..eee427f55c6f 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -315,7 +315,6 @@ private:
void InvalidateAtWindow(const tools::Rectangle& rRect);
css::uno::Reference<css::datatransfer::clipboard::XClipboard> GetClipboard() const;
- css::uno::Reference<css::datatransfer::clipboard::XClipboard> GetSelection() const;
void SetBroadcastLOKViewCursor(bool bSet)
{
diff --git a/include/vcl/transfer.hxx b/include/vcl/transfer.hxx
index d24fd560de31..cd2b58fc29b6 100644
--- a/include/vcl/transfer.hxx
+++ b/include/vcl/transfer.hxx
@@ -249,20 +249,20 @@ protected:
virtual void DragFinished( sal_Int8 nDropAction );
virtual void ObjectReleased();
+ void CopyToSelection(const css::uno::Reference<css::datatransfer::clipboard::XClipboard> &rClipboard) const;
public:
void PrepareOLE( const TransferableObjectDescriptor& rObjDesc );
void CopyToClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard> &rClipboard) const;
- void CopyToSelection(const css::uno::Reference<css::datatransfer::clipboard::XClipboard> &rClipboard) const;
// convenience versions of the above which extract the XClipboard from the pWindow
void CopyToClipboard( vcl::Window *pWindow ) const;
- void CopyToSelection( vcl::Window *pWindow ) const;
+ void CopyToPrimarySelection() const;
void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions );
- static void ClearSelection( vcl::Window *pWindow );
+ static void ClearPrimarySelection();
static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index d2129d2b0163..51d6a7767c86 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1310,7 +1310,6 @@ public:
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard();
/// Sets a custom clipboard for the window's frame, instead of creating it on-demand using css::datatransfer::clipboard::SystemClipboard.
void SetClipboard(css::uno::Reference<css::datatransfer::clipboard::XClipboard> const & xClipboard);
- css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetPrimarySelection();
/*
* Widgets call this to inform their owner container that the widget wants
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 9ba95c3b6e97..46dea5fb338d 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -490,7 +490,7 @@ void ScTabView::CheckSelectionTransfer()
// selection of an open RefDlg dialog, so don't inform the
// desktop clipboard of the changed selection if that dialog is open
if (!lcl_IsRefDlgActive(aViewData.GetViewShell()->GetViewFrame()))
- pNew->CopyToSelection( GetActiveWin() ); // may delete pOld
+ pNew->CopyToPrimarySelection(); // may delete pOld
// Log the selection change
ScMarkData& rMark = aViewData.GetMarkData();
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index c41f08b0aca1..8f5963b9a189 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -147,7 +147,7 @@ ScTabView::~ScTabView()
{
pOld->ForgetView();
pScMod->SetSelectionTransfer( nullptr );
- TransferableHelper::ClearSelection( GetActiveWin() ); // may delete pOld
+ TransferableHelper::ClearPrimarySelection(); // may delete pOld
}
pBrushDocument.reset();
diff --git a/sd/source/ui/inc/View.hxx b/sd/source/ui/inc/View.hxx
index 3d0eca9750b5..6551e967fa0a 100644
--- a/sd/source/ui/inc/View.hxx
+++ b/sd/source/ui/inc/View.hxx
@@ -130,7 +130,7 @@ public:
CreateDragDataObject (::sd::View*, vcl::Window& rWindow,
const Point& rDragPos);
css::uno::Reference<css::datatransfer::XTransferable>
- CreateSelectionDataObject (::sd::View*, vcl::Window& rWindow);
+ CreateSelectionDataObject (::sd::View*);
void UpdateSelectionClipboard( bool bForceDeselect );
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index 5b7ba59e8e60..69790987b299 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -188,7 +188,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje
return pTransferable;
}
-css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDataObject( View* pWorkView, vcl::Window& rWindow )
+css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDataObject( View* pWorkView )
{
rtl::Reference<SdTransferable> pTransferable = new SdTransferable( &mrDoc, pWorkView, true );
std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
@@ -206,7 +206,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDat
pTransferable->SetStartPos( aMarkRect.TopLeft() );
pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
- pTransferable->CopyToSelection( &rWindow );
+ pTransferable->CopyToPrimarySelection();
return pTransferable;
}
@@ -216,10 +216,10 @@ void View::UpdateSelectionClipboard( bool bForceDeselect )
if( mpViewSh && mpViewSh->GetActiveWindow() )
{
if( !bForceDeselect && GetMarkedObjectList().GetMarkCount() )
- CreateSelectionDataObject( this, *mpViewSh->GetActiveWindow() );
+ CreateSelectionDataObject( this );
else if( SD_MOD()->pTransferSelection && ( SD_MOD()->pTransferSelection->GetView() == this ) )
{
- TransferableHelper::ClearSelection( mpViewSh->GetActiveWindow() );
+ TransferableHelper::ClearPrimarySelection();
SD_MOD()->pTransferSelection = nullptr;
}
}
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 802c726389a5..f0888e2b18ce 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -4182,7 +4182,7 @@ void SwTransferable::CreateSelection( SwWrtShell& rSh,
pNew->m_pCreatorView = _pCreatorView;
pMod->m_pXSelection = pNew.get();
- pNew->CopyToSelection( rSh.GetWin() );
+ pNew->CopyToPrimarySelection();
}
void SwTransferable::ClearSelection( SwWrtShell& rSh,
@@ -4193,7 +4193,7 @@ void SwTransferable::ClearSelection( SwWrtShell& rSh,
((!pMod->m_pXSelection->m_pWrtShell) || (pMod->m_pXSelection->m_pWrtShell == &rSh)) &&
(!_pCreatorView || (pMod->m_pXSelection->m_pCreatorView == _pCreatorView)) )
{
- TransferableHelper::ClearSelection( rSh.GetWin() );
+ TransferableHelper::ClearPrimarySelection();
}
}
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index d1322a4dcc65..82e650e88b63 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -26,6 +26,7 @@
#include <vcl/specialchars.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
+#include <vcl/transfer.hxx>
#include <vcl/uitest/uiobject.hxx>
#include <vcl/ptrstyle.hxx>
@@ -1265,7 +1266,7 @@ void Edit::ImplCopyToSelectionClipboard()
{
if ( GetSelection().Len() )
{
- css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetPrimarySelection());
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetSystemPrimarySelection());
ImplCopy( aSelection );
}
}
@@ -1366,7 +1367,7 @@ void Edit::MouseButtonUp( const MouseEvent& rMEvt )
else if ( rMEvt.IsMiddle() && !mbReadOnly &&
( GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) )
{
- css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(Window::GetPrimarySelection());
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetSystemPrimarySelection());
ImplPaste( aSelection );
Modify();
}
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index 9d37d83827f5..aef67e174cfb 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -25,6 +25,7 @@
#include <vcl/settings.hxx>
#include "textdoc.hxx"
#include <vcl/textdata.hxx>
+#include <vcl/transfer.hxx>
#include <vcl/xtextedt.hxx>
#include "textdat2.hxx"
#include <vcl/commandevent.hxx>
@@ -442,7 +443,7 @@ bool TextView::KeyInput( const KeyEvent& rKeyEvent )
{
aCurSel = ImpMoveCursor( rKeyEvent );
if ( aCurSel.HasRange() ) {
- css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetWindow()->GetPrimarySelection());
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetSystemPrimarySelection());
Copy( aSelection );
}
bMoved = true;
@@ -599,14 +600,14 @@ void TextView::MouseButtonUp( const MouseEvent& rMouseEvent )
if ( rMouseEvent.IsMiddle() && !IsReadOnly() &&
( GetWindow()->GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) )
{
- css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetWindow()->GetPrimarySelection());
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetSystemPrimarySelection());
Paste( aSelection );
if ( mpImpl->mpTextEngine->IsModified() )
mpImpl->mpTextEngine->Broadcast( TextHint( SfxHintId::TextModified ) );
}
else if ( rMouseEvent.IsLeft() && GetSelection().HasRange() )
{
- css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetWindow()->GetPrimarySelection());
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetSystemPrimarySelection());
Copy( aSelection );
}
}
diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx
index 0c639cd60fa0..56c38019ab3b 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -981,15 +981,9 @@ void TransferableHelper::CopyToSelection(const Reference<XClipboard>& rSelection
}
}
-void TransferableHelper::CopyToSelection( vcl::Window *pWindow ) const
+void TransferableHelper::CopyToPrimarySelection() const
{
- DBG_ASSERT( pWindow, "Window pointer is NULL" );
- Reference< XClipboard > xSelection;
-
- if( pWindow )
- xSelection = pWindow->GetPrimarySelection();
-
- CopyToSelection(xSelection);
+ CopyToSelection(GetSystemPrimarySelection());
}
void TransferableHelper::StartDrag( vcl::Window* pWindow, sal_Int8 nDnDSourceActions )
@@ -1033,10 +1027,9 @@ void TransferableHelper::StartDrag( vcl::Window* pWindow, sal_Int8 nDnDSourceAct
}
}
-void TransferableHelper::ClearSelection( vcl::Window *pWindow )
+void TransferableHelper::ClearPrimarySelection()
{
- DBG_ASSERT( pWindow, "Window pointer is NULL" );
- Reference< XClipboard > xSelection( pWindow->GetPrimarySelection() );
+ Reference< XClipboard > xSelection(GetSystemPrimarySelection());
if( xSelection.is() )
xSelection->setContents( nullptr, nullptr );
@@ -2182,12 +2175,9 @@ TransferableDataHelper TransferableDataHelper::CreateFromSelection( vcl::Window*
{
DBG_ASSERT( pWindow, "Window pointer is NULL" );
- Reference< XClipboard > xSelection;
+ Reference< XClipboard > xSelection(GetSystemPrimarySelection());
TransferableDataHelper aRet;
- if( pWindow )
- xSelection = pWindow->GetPrimarySelection();
-
if( xSelection.is() )
{
SolarMutexReleaser aReleaser;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 308d1c6b5b55..9c874c1487b8 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3424,15 +3424,6 @@ Reference< XClipboard > Window::GetClipboard()
return mpWindowImpl->mpFrameData->mxClipboard;
}
-Reference< XClipboard > Window::GetPrimarySelection()
-{
- 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 )
{
assert(mpOutDevData);