summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-04-23 20:15:40 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-05-28 11:50:12 +0200
commitb4de1a98e61a75782464a440a33acf7435e1bbb9 (patch)
tree8eb0199cad5d147036a7fa1d604994d042fc84e4 /vcl
parent44239426ad12050b0e3a7db87efa202288ba2e14 (diff)
Use getXWeak in vcl
Change-Id: I665c9dc8c4f9cc4a996d9bf990cbfa33822bd07f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150885 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/ios/clipboard.cxx6
-rw-r--r--vcl/osx/DragSource.cxx14
-rw-r--r--vcl/osx/DropTarget.cxx10
-rw-r--r--vcl/osx/clipboard.cxx2
-rw-r--r--vcl/qt5/QtClipboard.cxx2
-rw-r--r--vcl/qt5/QtDragAndDrop.cxx10
-rw-r--r--vcl/source/app/session.cxx2
-rw-r--r--vcl/source/components/dtranscomp.cxx8
-rw-r--r--vcl/source/filter/graphicfilter.cxx2
-rw-r--r--vcl/unx/generic/dtrans/X11_clipboard.cxx4
-rw-r--r--vcl/unx/generic/dtrans/X11_selection.cxx40
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx10
-rw-r--r--vcl/win/dtrans/clipboardmanager.cxx3
13 files changed, 54 insertions, 59 deletions
diff --git a/vcl/ios/clipboard.cxx b/vcl/ios/clipboard.cxx
index 61530b926e2a..59209504da31 100644
--- a/vcl/ios/clipboard.cxx
+++ b/vcl/ios/clipboard.cxx
@@ -121,8 +121,7 @@ void iOSClipboard::fireClipboardChangedEvent(
if (!listeners.empty())
{
- aEvent = css::datatransfer::clipboard::ClipboardEvent(static_cast<OWeakObject*>(this),
- xNewContents);
+ aEvent = css::datatransfer::clipboard::ClipboardEvent(getXWeak(), xNewContents);
}
aGuard.clear();
@@ -177,8 +176,7 @@ css::uno::Sequence<OUString> SAL_CALL iOSClipboard::getSupportedServiceNames()
css::uno::Reference<css::uno::XInterface>
IosSalInstance::CreateClipboard(const css::uno::Sequence<css::uno::Any>&)
{
- return css::uno::Reference<css::uno::XInterface>(
- static_cast<cppu::OWeakObject*>(new iOSClipboard()));
+ return getXWeak(new iOSClipboard());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/osx/DragSource.cxx b/vcl/osx/DragSource.cxx
index bf2c0c25a310..fbe3b216a653 100644
--- a/vcl/osx/DragSource.cxx
+++ b/vcl/osx/DragSource.cxx
@@ -97,7 +97,7 @@ static Sequence<OUString> dragSource_getSupportedServiceNames()
{
(void)anImage;
(void)aPoint;
- DragSourceDragEvent dsde(static_cast<OWeakObject*>(mDragSource),
+ DragSourceDragEvent dsde(mDragSource->getXWeak(),
new DragSourceContext,
mDragSource,
DNDConstants::ACTION_COPY,
@@ -116,7 +116,7 @@ static Sequence<OUString> dragSource_getSupportedServiceNames()
if( DragSource::g_DropSuccessSet )
bDropSuccess = DragSource::g_DropSuccess;
- DragSourceDropEvent dsde(static_cast<OWeakObject*>(mDragSource),
+ DragSourceDropEvent dsde(mDragSource->getXWeak(),
new DragSourceContext,
static_cast< XDragSource* >(mDragSource),
SystemToOfficeDragActions(operation),
@@ -130,7 +130,7 @@ static Sequence<OUString> dragSource_getSupportedServiceNames()
{
(void)draggedImage;
(void)screenPoint;
- DragSourceDragEvent dsde(static_cast<OWeakObject*>(mDragSource),
+ DragSourceDragEvent dsde(mDragSource->getXWeak(),
new DragSourceContext,
mDragSource,
DNDConstants::ACTION_COPY,
@@ -163,7 +163,7 @@ void SAL_CALL DragSource::initialize(const Sequence< Any >& aArguments)
if (aArguments.getLength() < 2)
{
throw Exception("DragSource::initialize: Not enough parameter.",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
Any pNSView = aArguments[1];
@@ -181,13 +181,13 @@ void SAL_CALL DragSource::initialize(const Sequence< Any >& aArguments)
![mView respondsToSelector: @selector(unregisterMouseEventListener:)])
{
throw Exception("DragSource::initialize: Provided view doesn't support mouse listener",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
NSWindow* pWin = [mView window];
if( ! pWin || ![pWin respondsToSelector: @selector(getSalFrame)] )
{
throw Exception("DragSource::initialize: Provided view is not attached to a vcl frame",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
mpFrame = reinterpret_cast<AquaSalFrame*>([pWin performSelector: @selector(getSalFrame)]);
@@ -196,7 +196,7 @@ void SAL_CALL DragSource::initialize(const Sequence< Any >& aArguments)
if (mDragSourceHelper == nil)
{
throw Exception("DragSource::initialize: Cannot initialize DragSource",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
[static_cast<id <MouseEventListener>>(mView) registerMouseEventListener: mDragSourceHelper];
diff --git a/vcl/osx/DropTarget.cxx b/vcl/osx/DropTarget.cxx
index 56407a40abe9..d9e34030d11f 100644
--- a/vcl/osx/DropTarget.cxx
+++ b/vcl/osx/DropTarget.cxx
@@ -216,7 +216,7 @@ NSDragOperation DropTarget::draggingEntered(id sender)
uno::Reference<XTransferable> xTransferable = DragSource::g_XTransferable.is() ?
DragSource::g_XTransferable : mXCurrentDragClipboard->getContents();
- DropTargetDragEnterEvent dtdee(static_cast<OWeakObject*>(this),
+ DropTargetDragEnterEvent dtdee(getXWeak(),
0,
this,
currentAction,
@@ -251,7 +251,7 @@ NSDragOperation DropTarget::draggingUpdated(id sender)
sal_Int32 posX = static_cast<sal_Int32>(dragLocation.x);
sal_Int32 posY = static_cast<sal_Int32>(dragLocation.y);
- DropTargetDragEvent dtde(static_cast<OWeakObject*>(this),
+ DropTargetDragEvent dtde(getXWeak(),
0,
this,
currentAction,
@@ -281,7 +281,7 @@ NSDragOperation DropTarget::draggingUpdated(id sender)
void DropTarget::draggingExited(id /*sender*/)
{
- DropTargetEvent dte(static_cast<OWeakObject*>(this), 0);
+ DropTargetEvent dte(getXWeak(), 0);
fire_dragExit(dte);
mDragSourceSupportedActions = DNDConstants::ACTION_NONE;
mSelectedDropAction = DNDConstants::ACTION_NONE;
@@ -317,7 +317,7 @@ BOOL DropTarget::performDragOperation()
sal_Int32 posX = static_cast<sal_Int32>(dragLocation.x);
sal_Int32 posY = static_cast<sal_Int32>(dragLocation.y);
- DropTargetDropEvent dtde(static_cast<OWeakObject*>(this),
+ DropTargetDropEvent dtde(getXWeak(),
0,
this,
mSelectedDropAction,
@@ -354,7 +354,7 @@ void SAL_CALL DropTarget::initialize(const Sequence< Any >& aArguments)
if (aArguments.getLength() < 2)
{
throw RuntimeException("DropTarget::initialize: Cannot install window event handler",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
Any pNSView = aArguments[0];
diff --git a/vcl/osx/clipboard.cxx b/vcl/osx/clipboard.cxx
index cc99c3c985d9..2dc2d5eef888 100644
--- a/vcl/osx/clipboard.cxx
+++ b/vcl/osx/clipboard.cxx
@@ -253,7 +253,7 @@ void AquaClipboard::fireClipboardChangedEvent()
if (!mClipboardListeners.empty())
{
- aEvent = datatransfer::clipboard::ClipboardEvent(static_cast<OWeakObject*>(this), getContents());
+ aEvent = datatransfer::clipboard::ClipboardEvent(getXWeak(), getContents());
}
aGuard.clear();
diff --git a/vcl/qt5/QtClipboard.cxx b/vcl/qt5/QtClipboard.cxx
index c9a7683c422d..6e73b3711799 100644
--- a/vcl/qt5/QtClipboard.cxx
+++ b/vcl/qt5/QtClipboard.cxx
@@ -52,7 +52,7 @@ css::uno::Reference<css::uno::XInterface> QtClipboard::create(const OUString& aM
auto iter = aNameToClipboardMap.find(aModeString);
if (iter != aNameToClipboardMap.end() && isSupported(iter->second))
- return static_cast<cppu::OWeakObject*>(new QtClipboard(aModeString, iter->second));
+ return cppu::getXWeak(new QtClipboard(aModeString, iter->second));
SAL_WARN("vcl.qt", "Ignoring unrecognized clipboard type: '" << aModeString << "'");
return css::uno::Reference<css::uno::XInterface>();
}
diff --git a/vcl/qt5/QtDragAndDrop.cxx b/vcl/qt5/QtDragAndDrop.cxx
index e05993718753..0148715e237b 100644
--- a/vcl/qt5/QtDragAndDrop.cxx
+++ b/vcl/qt5/QtDragAndDrop.cxx
@@ -36,7 +36,7 @@ void QtDragSource::initialize(const css::uno::Sequence<css::uno::Any>& rArgument
if (rArguments.getLength() < 2)
{
throw uno::RuntimeException("DragSource::initialize: Cannot install window event handler",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
sal_IntPtr nFrame = 0;
@@ -44,8 +44,7 @@ void QtDragSource::initialize(const css::uno::Sequence<css::uno::Any>& rArgument
if (!nFrame)
{
- throw uno::RuntimeException("DragSource::initialize: missing SalFrame",
- static_cast<OWeakObject*>(this));
+ throw uno::RuntimeException("DragSource::initialize: missing SalFrame", getXWeak());
}
m_pFrame = reinterpret_cast<QtFrame*>(nFrame);
@@ -141,7 +140,7 @@ void QtDropTarget::initialize(const uno::Sequence<uno::Any>& rArguments)
if (rArguments.getLength() < 2)
{
throw uno::RuntimeException("DropTarget::initialize: Cannot install window event handler",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
sal_IntPtr nFrame = 0;
@@ -149,8 +148,7 @@ void QtDropTarget::initialize(const uno::Sequence<uno::Any>& rArguments)
if (!nFrame)
{
- throw uno::RuntimeException("DropTarget::initialize: missing SalFrame",
- static_cast<OWeakObject*>(this));
+ throw uno::RuntimeException("DropTarget::initialize: missing SalFrame", getXWeak());
}
m_nDropAction = datatransfer::dnd::DNDConstants::ACTION_NONE;
diff --git a/vcl/source/app/session.cxx b/vcl/source/app/session.cxx
index d84777764941..c0dfe71d7bc3 100644
--- a/vcl/source/app/session.cxx
+++ b/vcl/source/app/session.cxx
@@ -391,7 +391,7 @@ void VCLSession::disposing() {
osl::MutexGuard g(m_aMutex);
vector.swap(m_aListeners);
}
- css::lang::EventObject src(static_cast<OWeakObject *>(this));
+ css::lang::EventObject src(getXWeak());
for (auto const & listener: vector) {
try {
listener.m_xListener->disposing(src);
diff --git a/vcl/source/components/dtranscomp.cxx b/vcl/source/components/dtranscomp.cxx
index b3acc0e6094d..1c16a2dd1391 100644
--- a/vcl/source/components/dtranscomp.cxx
+++ b/vcl/source/components/dtranscomp.cxx
@@ -417,7 +417,7 @@ Reference< XInterface > SalInstance::CreateClipboard( const Sequence< Any >& arg
"non-empty SalInstance::CreateClipboard arguments", {}, -1);
}
#ifdef IOS
- return Reference< XInterface >( static_cast<cppu::OWeakObject *>(new vcl::GenericClipboard()) );
+ return getXWeak(new vcl::GenericClipboard());
#else
if (comphelper::LibreOfficeKit::isActive()) {
// In LOK, each document view shall have its own clipboard instance (whereas
@@ -432,7 +432,7 @@ Reference< XInterface > SalInstance::CreateClipboard( const Sequence< Any >& arg
#endif
DBG_TESTSOLARMUTEX();
if (!m_clipboard.is()) {
- m_clipboard = static_cast<cppu::OWeakObject *>(new vcl::GenericClipboard());
+ m_clipboard = getXWeak(new vcl::GenericClipboard());
}
return m_clipboard;
}
@@ -447,7 +447,7 @@ Reference< XInterface > SalInstance::CreateDragSource(const SystemEnvData* pSysE
// We run unit tests in parallel, which is a problem when touching a shared resource
// the system clipboard, so rather use the dummy GenericClipboard.
if (Application::IsHeadlessModeEnabled() || IsRunningUnitTest())
- return Reference<XInterface>(static_cast<cppu::OWeakObject*>(new vcl::GenericDragSource()));
+ return getXWeak(new vcl::GenericDragSource());
return ImplCreateDragSource(pSysEnv);
}
@@ -460,7 +460,7 @@ Reference< XInterface > SalInstance::CreateDropTarget(const SystemEnvData* pSysE
{
// see SalInstance::CreateDragSource
if (Application::IsHeadlessModeEnabled() || IsRunningUnitTest())
- return Reference<XInterface>(static_cast<cppu::OWeakObject*>(new vcl::GenericDropTarget()));
+ return getXWeak(new vcl::GenericDropTarget());
return ImplCreateDropTarget(pSysEnv);
}
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index bb478922b5a5..7eb8918b600e 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1754,7 +1754,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, std::u16string_vi
if( xActiveDataSource.is() )
{
const css::uno::Reference< css::uno::XInterface > xStmIf(
- static_cast< ::cppu::OWeakObject* >( new ImpFilterOutputStream( *rTempStm ) ) );
+ getXWeak( new ImpFilterOutputStream( *rTempStm ) ) );
SvMemoryStream aMemStm( 65535, 65535 );
diff --git a/vcl/unx/generic/dtrans/X11_clipboard.cxx b/vcl/unx/generic/dtrans/X11_clipboard.cxx
index 9b50eff8d988..a19cc0812e99 100644
--- a/vcl/unx/generic/dtrans/X11_clipboard.cxx
+++ b/vcl/unx/generic/dtrans/X11_clipboard.cxx
@@ -101,7 +101,7 @@ void X11Clipboard::fireChangedContentsEvent()
::std::vector< Reference< XClipboardListener > > listeners( m_aListeners );
aGuard.clear();
- ClipboardEvent aEvent( static_cast<OWeakObject*>(this), m_aContents);
+ ClipboardEvent aEvent(getXWeak(), m_aContents);
for (auto const& listener : listeners)
{
if( listener.is() )
@@ -210,7 +210,7 @@ void X11Clipboard::fireContentsChanged()
Reference< XInterface > X11Clipboard::getReference() noexcept
{
- return Reference< XInterface >( static_cast< OWeakObject* >(this) );
+ return getXWeak();
}
OUString SAL_CALL X11Clipboard::getImplementationName( )
diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx
index 3547ef2b7226..493b8943d312 100644
--- a/vcl/unx/generic/dtrans/X11_selection.cxx
+++ b/vcl/unx/generic/dtrans/X11_selection.cxx
@@ -1773,7 +1773,7 @@ bool SelectionManager::handleSelectionRequest( XSelectionRequestEvent& rRequest
m_xDragSourceListener.is() )
{
DragSourceDropEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
if( aNotify.xselection.property != None )
@@ -2344,7 +2344,7 @@ void SelectionManager::dropComplete( bool bSuccess, ::Window aDropWindow )
if( m_xDragSourceListener.is() )
{
DragSourceDropEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = getUserDragAction();
@@ -2423,7 +2423,7 @@ void SelectionManager::sendDragStatus( Atom nDropAction )
}
DragSourceDragEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = m_nSourceActions;
@@ -2516,7 +2516,7 @@ bool SelectionManager::updateDragAction( int modifierState )
m_nUserDragAction = nNewDropAction;
DragSourceDragEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = m_nUserDragAction;
@@ -2544,7 +2544,7 @@ void SelectionManager::sendDropPosition( bool bForce, Time eventTime )
::Window aChild;
XTranslateCoordinates( m_pDisplay, it->second.m_aRootWindow, m_aDropWindow, m_nLastDragX, m_nLastDragY, &x, &y, &aChild );
DropTargetDragEvent dtde;
- dtde.Source = static_cast< OWeakObject* >(it->second.m_pTarget );
+ dtde.Source = it->second.m_pTarget->getXWeak();
dtde.Context = new DropTargetDragContext( m_aCurrentDropWindow, *this );
dtde.LocationX = x;
dtde.LocationY = y;
@@ -2648,7 +2648,7 @@ bool SelectionManager::handleDragEvent( XEvent const & rMessage )
{
bHandled = true;
DragSourceDragEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >( this );
dsde.UserAction = getUserDragAction();
@@ -2695,7 +2695,7 @@ bool SelectionManager::handleDragEvent( XEvent const & rMessage )
bHandled = true;
// notify the listener
DragSourceDropEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = m_nTargetAcceptAction;
@@ -2740,7 +2740,7 @@ bool SelectionManager::handleDragEvent( XEvent const & rMessage )
if( it != m_aDropTargets.end() )
{
DropTargetEvent dte;
- dte.Source = static_cast< OWeakObject* >( it->second.m_pTarget );
+ dte.Source = it->second.m_pTarget->getXWeak();
aGuard.clear();
it->second.m_pTarget->dragExit( dte );
aGuard.reset();
@@ -2761,7 +2761,7 @@ bool SelectionManager::handleDragEvent( XEvent const & rMessage )
}
// notify the listener
DragSourceDropEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = DNDConstants::ACTION_NONE;
@@ -2813,7 +2813,7 @@ bool SelectionManager::handleDragEvent( XEvent const & rMessage )
::Window aChild;
XTranslateCoordinates( m_pDisplay, rMessage.xbutton.root, m_aDropWindow, rMessage.xbutton.x_root, rMessage.xbutton.y_root, &x, &y, &aChild );
DropTargetDropEvent dtde;
- dtde.Source = static_cast< OWeakObject* >(it->second.m_pTarget );
+ dtde.Source = it->second.m_pTarget->getXWeak();
dtde.Context = new DropTargetDropContext( m_aCurrentDropWindow, *this );
dtde.LocationX = x;
dtde.LocationY = y;
@@ -2902,7 +2902,7 @@ bool SelectionManager::handleDragEvent( XEvent const & rMessage )
{
// cancel drag
DragSourceDropEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = DNDConstants::ACTION_NONE;
@@ -2950,7 +2950,7 @@ void SelectionManager::reject( ::Window aDropWindow )
if( m_bDropSent && m_xDragSourceListener.is() )
{
DragSourceDropEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = DNDConstants::ACTION_NONE;
@@ -3095,7 +3095,7 @@ void SelectionManager::updateDragWindow( int nX, int nY, ::Window aRoot )
}
DragSourceDragEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = nNewProtocolVersion >= 0 ? m_nUserDragAction : DNDConstants::ACTION_COPY;
@@ -3126,7 +3126,7 @@ void SelectionManager::updateDragWindow( int nX, int nY, ::Window aRoot )
// shortcut for own drop targets
{
DropTargetEvent dte;
- dte.Source = static_cast< OWeakObject* >( it->second.m_pTarget );
+ dte.Source = it->second.m_pTarget->getXWeak();
aGuard.clear();
it->second.m_pTarget->dragExit( dte );
aGuard.reset();
@@ -3174,7 +3174,7 @@ void SelectionManager::updateDragWindow( int nX, int nY, ::Window aRoot )
{
XTranslateCoordinates( m_pDisplay, aRoot, m_aDropWindow, nX, nY, &nWinX, &nWinY, &aChild );
DropTargetDragEnterEvent dtde;
- dtde.Source = static_cast< OWeakObject* >( it->second.m_pTarget );
+ dtde.Source = it->second.m_pTarget->getXWeak();
dtde.Context = new DropTargetDragContext( m_aCurrentDropWindow, *this );
dtde.LocationX = nWinX;
dtde.LocationY = nWinY;
@@ -3233,7 +3233,7 @@ void SelectionManager::startDrag(
<< " ).");
#endif
DragSourceDropEvent aDragFailedEvent;
- aDragFailedEvent.Source = static_cast< OWeakObject* >(this);
+ aDragFailedEvent.Source = getXWeak();
aDragFailedEvent.DragSource = static_cast< XDragSource* >(this);
aDragFailedEvent.DragSourceContext = new DragSourceContext( None, *this );
aDragFailedEvent.DropAction = DNDConstants::ACTION_NONE;
@@ -3516,7 +3516,7 @@ void SelectionManager::dragDoDispatch()
m_xDragSourceTransferable.clear();
DragSourceDropEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = DNDConstants::ACTION_NONE;
@@ -4019,7 +4019,7 @@ void SelectionManager::deregisterDropTarget( ::Window aWindow )
if( it != m_aDropTargets.end() )
{
DropTargetEvent dte;
- dte.Source = static_cast< OWeakObject* >( it->second.m_pTarget );
+ dte.Source = it->second.m_pTarget->getXWeak();
aGuard.clear();
it->second.m_pTarget->dragExit( dte );
}
@@ -4039,7 +4039,7 @@ void SelectionManager::deregisterDropTarget( ::Window aWindow )
}
// notify the listener
DragSourceDropEvent dsde;
- dsde.Source = static_cast< OWeakObject* >(this);
+ dsde.Source = getXWeak();
dsde.DragSourceContext = new DragSourceContext( m_aDropWindow, *this );
dsde.DragSource = static_cast< XDragSource* >(this);
dsde.DropAction = DNDConstants::ACTION_NONE;
@@ -4071,7 +4071,7 @@ void SelectionManager::fireContentsChanged() noexcept
css::uno::Reference< XInterface > SelectionManager::getReference() noexcept
{
- return css::uno::Reference< XInterface >( static_cast<OWeakObject*>(this) );
+ return getXWeak();
}
/*
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index adea2d9a7c10..03c89ba40f68 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -1599,7 +1599,7 @@ Reference< XInterface > GtkInstance::CreateClipboard(const Sequence< Any >& argu
if (m_aClipboards[eSelection].is())
return m_aClipboards[eSelection];
- Reference<XInterface> xClipboard(static_cast<cppu::OWeakObject *>(new VclGtkClipboard(eSelection)));
+ Reference<XInterface> xClipboard(getXWeak(new VclGtkClipboard(eSelection)));
m_aClipboards[eSelection] = xClipboard;
return xClipboard;
}
@@ -1649,7 +1649,7 @@ void GtkInstDropTarget::initialize(const Sequence<Any>& rArguments)
if (rArguments.getLength() < 2)
{
throw RuntimeException("DropTarget::initialize: Cannot install window event handler",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
sal_IntPtr nFrame = 0;
@@ -1658,7 +1658,7 @@ void GtkInstDropTarget::initialize(const Sequence<Any>& rArguments)
if (!nFrame)
{
throw RuntimeException("DropTarget::initialize: missing SalFrame",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
m_pFrame = reinterpret_cast<GtkSalFrame*>(nFrame);
@@ -1785,7 +1785,7 @@ void GtkInstDragSource::initialize(const css::uno::Sequence<css::uno::Any >& rAr
if (rArguments.getLength() < 2)
{
throw RuntimeException("DragSource::initialize: Cannot install window event handler",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
sal_IntPtr nFrame = 0;
@@ -1794,7 +1794,7 @@ void GtkInstDragSource::initialize(const css::uno::Sequence<css::uno::Any >& rAr
if (!nFrame)
{
throw RuntimeException("DragSource::initialize: missing SalFrame",
- static_cast<OWeakObject*>(this));
+ getXWeak());
}
m_pFrame = reinterpret_cast<GtkSalFrame*>(nFrame);
diff --git a/vcl/win/dtrans/clipboardmanager.cxx b/vcl/win/dtrans/clipboardmanager.cxx
index 82a1da85bd66..bff5aec49fa9 100644
--- a/vcl/win/dtrans/clipboardmanager.cxx
+++ b/vcl/win/dtrans/clipboardmanager.cxx
@@ -192,8 +192,7 @@ dtrans_ClipboardManager_get_implementation(
return nullptr;
if (!g_Instance)
g_Instance.set(new ClipboardManager());
- g_Instance->acquire();
- return static_cast<cppu::OWeakObject*>(g_Instance.get());
+ return cppu::acquire(g_Instance.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */