summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-03-14 22:17:43 +0000
committerMichael Meeks <michael.meeks@collabora.com>2015-04-10 11:04:01 +0100
commit51e97b2ffd8f0ae0591d1880d621cba4596583b7 (patch)
tree8ae6029cf4dd89e29b81a318128ab725dbcadb4c
parentbc139dde60a25a7ccb60446c7cb8475ab794bfdc (diff)
toolkit: first cut at switching to VclPtr.
Toolkit has traditionally had a very odd lifecycle relationship with VCL - start to fix that; first partial cut. Change-Id: I77e5e62ebde101d32746d12d83dae92c49970001
-rw-r--r--include/toolkit/awt/vclxaccessiblecomponent.hxx3
-rw-r--r--include/toolkit/awt/vclxdevice.hxx19
-rw-r--r--include/toolkit/awt/vclxwindow.hxx8
-rw-r--r--sfx2/source/view/viewprn.cxx2
-rw-r--r--toolkit/source/awt/animatedimagespeer.cxx39
-rw-r--r--toolkit/source/awt/vclxaccessiblecomponent.cxx21
-rw-r--r--toolkit/source/awt/vclxdevice.cxx23
-rw-r--r--toolkit/source/awt/vclxspinbutton.cxx2
-rw-r--r--toolkit/source/awt/vclxtabpagecontainer.cxx31
-rw-r--r--toolkit/source/awt/vclxwindow.cxx10
-rw-r--r--toolkit/source/awt/vclxwindows.cxx210
11 files changed, 169 insertions, 199 deletions
diff --git a/include/toolkit/awt/vclxaccessiblecomponent.hxx b/include/toolkit/awt/vclxaccessiblecomponent.hxx
index 62d167ba10f1..d168ee133199 100644
--- a/include/toolkit/awt/vclxaccessiblecomponent.hxx
+++ b/include/toolkit/awt/vclxaccessiblecomponent.hxx
@@ -33,6 +33,7 @@
#include <comphelper/accessiblecomponenthelper.hxx>
#include <tools/link.hxx>
+#include <vcl/vclptr.hxx>
namespace vcl { class Window; }
class VCLXWindow;
@@ -83,7 +84,7 @@ public:
virtual ~VCLXAccessibleComponent();
VCLXWindow* GetVCLXWindow() const { return mpVCLXindow; }
- vcl::Window* GetWindow() const;
+ VclPtr<vcl::Window> GetWindow() const;
virtual void SAL_CALL disposing() SAL_OVERRIDE;
diff --git a/include/toolkit/awt/vclxdevice.hxx b/include/toolkit/awt/vclxdevice.hxx
index 61d568911b38..751ffd8280b1 100644
--- a/include/toolkit/awt/vclxdevice.hxx
+++ b/include/toolkit/awt/vclxdevice.hxx
@@ -27,43 +27,40 @@
#include <cppuhelper/weak.hxx>
#include <osl/mutex.hxx>
#include <vcl/virdev.hxx>
+#include <vcl/vclptr.hxx>
#include <com/sun/star/awt/XUnitConversion.hpp>
class OutputDevice;
class VirtualDevice;
-
-// class VCLXDevice
-
-
// For using nDummy, no incompatible update, add a sal_Bool bCreatedWithToolkitMember later...
#define FLAGS_CREATEDWITHTOOLKIT 0x00000001
-class TOOLKIT_DLLPUBLIC VCLXDevice : public ::com::sun::star::awt::XDevice,
+/// An UNO wrapper for the VCL OutputDevice
+class TOOLKIT_DLLPUBLIC VCLXDevice :
+ public ::com::sun::star::awt::XDevice,
public ::com::sun::star::lang::XTypeProvider,
public ::com::sun::star::lang::XUnoTunnel,
public ::com::sun::star::awt::XUnitConversion,
public ::cppu::OWeakObject
{
friend class VCLXGraphics;
+ friend class VCLXVirtualDevice;
private:
- OutputDevice* mpOutputDevice;
+ VclPtr<OutputDevice> mpOutputDevice;
public:
void* pDummy;
sal_uInt32 nFlags;
-protected:
- void DestroyOutputDevice();
-
public:
VCLXDevice();
virtual ~VCLXDevice();
- void SetOutputDevice( OutputDevice* pOutDev ) { mpOutputDevice = pOutDev; }
- OutputDevice* GetOutputDevice() const { return mpOutputDevice; }
+ void SetOutputDevice( VclPtr<OutputDevice> pOutDev ) { mpOutputDevice = pOutDev; }
+ VclPtr<OutputDevice> GetOutputDevice() const { return mpOutputDevice; }
void SetCreatedWithToolkit( bool bCreatedWithToolkit );
diff --git a/include/toolkit/awt/vclxwindow.hxx b/include/toolkit/awt/vclxwindow.hxx
index 6306ce6717e3..dfc42aa54f99 100644
--- a/include/toolkit/awt/vclxwindow.hxx
+++ b/include/toolkit/awt/vclxwindow.hxx
@@ -128,8 +128,12 @@ public:
VCLXWindow( bool bWithDefaultProps = false );
virtual ~VCLXWindow();
- virtual void SetWindow( vcl::Window* pWindow );
- vcl::Window* GetWindow() const { return static_cast<vcl::Window*>(GetOutputDevice()); }
+ virtual void SetWindow( VclPtr<vcl::Window> pWindow );
+ template< class derived_type > VclPtr< derived_type > GetAs() const {
+ return VclPtr< derived_type >( static_cast< derived_type * >( GetOutputDevice().get() ) ); }
+ template< class derived_type > VclPtr< derived_type > GetAsDynamic() const {
+ return VclPtr< derived_type >( dynamic_cast< derived_type * >( GetOutputDevice().get() ) ); }
+ VclPtr<vcl::Window> GetWindow() const { return GetAs<vcl::Window>(); }
void suspendVclEventListening( );
void resumeVclEventListening( );
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 71ff494c5ab0..d30b5eeecc58 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -209,7 +209,7 @@ Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const
{
mpLastPrinter = xPrinter.get();
VCLXDevice* pXDevice = new VCLXDevice();
- pXDevice->SetOutputDevice( mpLastPrinter );
+ pXDevice->SetOutputDevicePtr( mpLastPrinter );
mxDevice = Reference< awt::XDevice >( pXDevice );
}
diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx
index 13da483cde92..b9215fcdbfb4 100644
--- a/toolkit/source/awt/animatedimagespeer.cxx
+++ b/toolkit/source/awt/animatedimagespeer.cxx
@@ -182,8 +182,8 @@ namespace toolkit
void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data )
{
- Throbber* pThrobber = dynamic_cast< Throbber* >( i_data.rAntiImpl.GetWindow() );
- if ( pThrobber == NULL )
+ VclPtr<Throbber> pThrobber = i_data.rAntiImpl.GetAsDynamic<Throbber>();
+ if ( !pThrobber )
return;
try
@@ -308,40 +308,37 @@ namespace toolkit
}
- void SAL_CALL AnimatedImagesPeer::startAnimation( ) throw (RuntimeException, std::exception)
+ void SAL_CALL AnimatedImagesPeer::startAnimation() throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
- if ( pThrobber != NULL)
+ VclPtr<Throbber> pThrobber = GetAsDynamic<Throbber>();
+ if (pThrobber)
pThrobber->start();
}
-
- void SAL_CALL AnimatedImagesPeer::stopAnimation( ) throw (RuntimeException, std::exception)
+ void SAL_CALL AnimatedImagesPeer::stopAnimation() throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
- if ( pThrobber != NULL)
+ VclPtr<Throbber> pThrobber = GetAsDynamic<Throbber>();
+ if (pThrobber)
pThrobber->stop();
}
-
- sal_Bool SAL_CALL AnimatedImagesPeer::isAnimationRunning( ) throw (RuntimeException, std::exception)
+ sal_Bool SAL_CALL AnimatedImagesPeer::isAnimationRunning() throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
- if ( pThrobber != NULL)
+ VclPtr<Throbber> pThrobber = GetAsDynamic<Throbber>();
+ if (pThrobber)
return pThrobber->isRunning();
return sal_False;
}
-
void SAL_CALL AnimatedImagesPeer::setProperty( const OUString& i_propertyName, const Any& i_value ) throw(RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
- if ( pThrobber == NULL )
+ VclPtr<Throbber> pThrobber = GetAsDynamic<Throbber>();
+ if ( pThrobber )
{
VCLXWindow::setProperty( i_propertyName, i_value );
return;
@@ -368,11 +365,9 @@ namespace toolkit
case BASEPROPERTY_IMAGE_SCALE_MODE:
{
sal_Int16 nScaleMode( ImageScaleMode::ANISOTROPIC );
- ImageControl* pImageControl = dynamic_cast< ImageControl* >( GetWindow() );
+ VclPtr<ImageControl> pImageControl = GetAsDynamic< ImageControl >();
if ( pImageControl && ( i_value >>= nScaleMode ) )
- {
pImageControl->SetScaleMode( nScaleMode );
- }
}
break;
@@ -389,8 +384,8 @@ namespace toolkit
Any aReturn;
- Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
- if ( pThrobber == NULL )
+ VclPtr<Throbber> pThrobber = GetAsDynamic<Throbber>();
+ if ( !pThrobber )
return VCLXWindow::getProperty( i_propertyName );
const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName );
@@ -406,7 +401,7 @@ namespace toolkit
case BASEPROPERTY_IMAGE_SCALE_MODE:
{
- ImageControl const* pImageControl = dynamic_cast< ImageControl* >( GetWindow() );
+ VclPtr<ImageControl> pImageControl = GetAsDynamic<ImageControl>();
aReturn <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::ANISOTROPIC );
}
break;
diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx
index b1f338690563..1dcb9b88f3d7 100644
--- a/toolkit/source/awt/vclxaccessiblecomponent.cxx
+++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx
@@ -356,14 +356,15 @@ void VCLXAccessibleComponent::disposing()
mpVCLXindow = NULL;
}
-vcl::Window* VCLXAccessibleComponent::GetWindow() const
+VclPtr<vcl::Window> VCLXAccessibleComponent::GetWindow() const
{
- return GetVCLXWindow() ? GetVCLXWindow()->GetWindow() : NULL;
+ return GetVCLXWindow() ? GetVCLXWindow()->GetWindow()
+ : VclPtr<vcl::Window>();
}
void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet )
{
- vcl::Window* pWindow = GetWindow();
+ VclPtr<vcl::Window> pWindow = GetWindow();
if ( pWindow )
{
vcl::Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy();
@@ -394,7 +395,7 @@ void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelation
void VCLXAccessibleComponent::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
{
- vcl::Window* pWindow = GetWindow();
+ VclPtr<vcl::Window> pWindow = GetWindow();
if ( pWindow )
{
if ( pWindow->IsVisible() )
@@ -433,7 +434,7 @@ void VCLXAccessibleComponent::FillAccessibleStateSet( utl::AccessibleStateSetHel
rStateSet.AddState( accessibility::AccessibleStateType::MOVEABLE );
if( pWindow->IsDialog() )
{
- Dialog *pDlg = static_cast< Dialog* >( pWindow );
+ Dialog *pDlg = static_cast< Dialog* >( pWindow.get() );
if( pDlg->IsInExecute() )
rStateSet.AddState( accessibility::AccessibleStateType::MODAL );
}
@@ -442,26 +443,26 @@ void VCLXAccessibleComponent::FillAccessibleStateSet( utl::AccessibleStateSetHel
if( pWindow && pWindow->GetType() == WINDOW_COMBOBOX )
{
if( !( pWindow->GetStyle() & WB_READONLY) ||
- !static_cast<Edit*>(pWindow)->IsReadOnly() )
+ !static_cast<Edit*>(pWindow.get())->IsReadOnly() )
rStateSet.AddState( accessibility::AccessibleStateType::EDITABLE );
}
- vcl::Window* pChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
+ VclPtr<vcl::Window> pChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
while( pWindow && pChild )
{
- vcl::Window* pWinTemp = pChild->GetWindow( WINDOW_FIRSTCHILD );
+ VclPtr<vcl::Window> pWinTemp = pChild->GetWindow( WINDOW_FIRSTCHILD );
if( pWinTemp && pWinTemp->GetType() == WINDOW_EDIT )
{
if( !( pWinTemp->GetStyle() & WB_READONLY) ||
- !static_cast<Edit*>(pWinTemp)->IsReadOnly() )
+ !static_cast<Edit*>(pWinTemp.get())->IsReadOnly() )
rStateSet.AddState( accessibility::AccessibleStateType::EDITABLE );
break;
}
if( pChild->GetType() == WINDOW_EDIT )
{
if( !( pChild->GetStyle() & WB_READONLY) ||
- !static_cast<Edit*>(pChild)->IsReadOnly())
+ !static_cast<Edit*>(pChild.get())->IsReadOnly())
rStateSet.AddState( accessibility::AccessibleStateType::EDITABLE );
break;
}
diff --git a/toolkit/source/awt/vclxdevice.cxx b/toolkit/source/awt/vclxdevice.cxx
index 57cd040d40e0..e464d72705c0 100644
--- a/toolkit/source/awt/vclxdevice.cxx
+++ b/toolkit/source/awt/vclxdevice.cxx
@@ -43,8 +43,7 @@
// class VCLXDevice
VCLXDevice::VCLXDevice()
- : mpOutputDevice(NULL)
- , pDummy(NULL)
+ : pDummy(NULL)
, nFlags(0)
{
}
@@ -53,12 +52,6 @@ VCLXDevice::~VCLXDevice()
{
}
-void VCLXDevice::DestroyOutputDevice()
-{
- delete mpOutputDevice;
- mpOutputDevice = NULL;
-}
-
void VCLXDevice::SetCreatedWithToolkit( bool bCreatedWithToolkit )
{
if ( bCreatedWithToolkit )
@@ -129,14 +122,14 @@ IMPL_XTYPEPROVIDER_END
OutDevType eDevType = mpOutputDevice->GetOutDevType();
if ( eDevType == OUTDEV_WINDOW )
{
- aDevSz = static_cast<vcl::Window*>(mpOutputDevice)->GetSizePixel();
- static_cast<vcl::Window*>(mpOutputDevice)->GetBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
+ aDevSz = static_cast<vcl::Window*>(mpOutputDevice.get())->GetSizePixel();
+ static_cast<vcl::Window*>(mpOutputDevice.get())->GetBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
}
else if ( eDevType == OUTDEV_PRINTER )
{
- aDevSz = static_cast<Printer*>(mpOutputDevice)->GetPaperSizePixel();
+ aDevSz = static_cast<Printer*>(mpOutputDevice.get())->GetPaperSizePixel();
Size aOutSz = mpOutputDevice->GetOutputSizePixel();
- Point aOffset = static_cast<Printer*>(mpOutputDevice)->GetPageOffset();
+ Point aOffset = static_cast<Printer*>(mpOutputDevice.get())->GetPageOffset();
aInfo.LeftInset = aOffset.X();
aInfo.TopInset = aOffset.Y();
aInfo.RightInset = aDevSz.Width() - aOutSz.Width() - aOffset.X();
@@ -228,19 +221,15 @@ IMPL_XTYPEPROVIDER_END
return xDBmp;
}
-
VCLXVirtualDevice::~VCLXVirtualDevice()
{
SolarMutexGuard aGuard;
- DestroyOutputDevice();
+ mpOutputDevice.disposeAndClear();
}
-
-
// Interface implementation of ::com::sun::star::awt::XUnitConversion
-
::com::sun::star::awt::Point SAL_CALL VCLXDevice::convertPointToLogic( const ::com::sun::star::awt::Point& aPoint, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
{
(void)aPoint;
diff --git a/toolkit/source/awt/vclxspinbutton.cxx b/toolkit/source/awt/vclxspinbutton.cxx
index b3ab308edd92..2488359b13b7 100644
--- a/toolkit/source/awt/vclxspinbutton.cxx
+++ b/toolkit/source/awt/vclxspinbutton.cxx
@@ -199,7 +199,7 @@ namespace toolkit
{
SolarMutexClearableGuard aGuard;
Reference< XSpinValue > xKeepAlive( this );
- SpinButton* pSpinButton = static_cast< SpinButton* >( GetWindow() );
+ VclPtr<SpinButton> pSpinButton = GetAs<SpinButton>();
if ( !pSpinButton )
return;
diff --git a/toolkit/source/awt/vclxtabpagecontainer.cxx b/toolkit/source/awt/vclxtabpagecontainer.cxx
index b0e0ef1807bb..7eb39fa623e5 100644
--- a/toolkit/source/awt/vclxtabpagecontainer.cxx
+++ b/toolkit/source/awt/vclxtabpagecontainer.cxx
@@ -57,7 +57,7 @@ VCLXTabPageContainer::~VCLXTabPageContainer()
void SAL_CALL VCLXTabPageContainer::draw( sal_Int32 nX, sal_Int32 nY ) throw(RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- TabControl* pTabControl = static_cast<TabControl*>(GetWindow());
+ VclPtr<TabControl> pTabControl = GetAs<TabControl>();
if ( pTabControl )
{
TabPage *pTabPage = pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( pTabControl->GetCurPageId( ) ) );
@@ -86,37 +86,40 @@ void SAL_CALL VCLXTabPageContainer::draw( sal_Int32 nX, sal_Int32 nY ) throw(Run
void SAL_CALL VCLXTabPageContainer::setProperty(const OUString& PropertyName, const Any& Value ) throw(RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- TabControl* pTabPage = static_cast<TabControl*>(GetWindow());
+ VclPtr<TabControl> pTabPage = GetAs<TabControl>();
if ( pTabPage )
- {
VCLXWindow::setProperty( PropertyName, Value );
- }
}
+
::sal_Int16 SAL_CALL VCLXTabPageContainer::getActiveTabPageID() throw (RuntimeException, std::exception)
{
- TabControl* pTabCtrl = static_cast<TabControl*>(GetWindow());
- return pTabCtrl != NULL ? pTabCtrl->GetCurPageId( ) : 0;
+ VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
+ return pTabCtrl ? pTabCtrl->GetCurPageId( ) : 0;
}
+
void SAL_CALL VCLXTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (RuntimeException, std::exception)
{
- TabControl* pTabCtrl = static_cast<TabControl*>(GetWindow());
+ VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
if ( pTabCtrl )
pTabCtrl->SelectTabPage(_activetabpageid);
}
+
::sal_Int16 SAL_CALL VCLXTabPageContainer::getTabPageCount( ) throw (RuntimeException, std::exception)
{
- TabControl* pTabCtrl = static_cast<TabControl*>(GetWindow());
- return pTabCtrl != NULL ? pTabCtrl->GetPageCount() : 0;
+ VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
+ return pTabCtrl ? pTabCtrl->GetPageCount() : 0;
}
+
sal_Bool SAL_CALL VCLXTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) throw (RuntimeException, std::exception)
{
return (getActiveTabPageID() == tabPageIndex);
}
+
Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) throw (RuntimeException, std::exception)
{
return (tabPageIndex >= 0 && tabPageIndex < static_cast<sal_Int16>(m_aTabPages.size())) ? m_aTabPages[tabPageIndex] : NULL;
}
+
Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
@@ -135,10 +138,12 @@ Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer:
}
return xTabPage;
}
+
void SAL_CALL VCLXTabPageContainer::addTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException, std::exception)
{
m_aTabPageListeners.addInterface( listener );
}
+
void SAL_CALL VCLXTabPageContainer::removeTabPageContainerListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException, std::exception)
{
m_aTabPageListeners.removeInterface( listener );
@@ -147,7 +152,7 @@ void SAL_CALL VCLXTabPageContainer::removeTabPageContainerListener( const Refere
void VCLXTabPageContainer::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent )
{
SolarMutexClearableGuard aGuard;
- TabControl* pTabControl = static_cast< TabControl* >( GetWindow() );
+ VclPtr<TabControl> pTabControl = GetAs<TabControl>();
if ( pTabControl )
{
switch ( _rVclWindowEvent.GetId() )
@@ -172,7 +177,7 @@ void SAL_CALL VCLXTabPageContainer::disposing( const ::com::sun::star::lang::Eve
void SAL_CALL VCLXTabPageContainer::elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- TabControl* pTabCtrl = static_cast<TabControl*>(GetWindow());
+ VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY);
if ( pTabCtrl && xTabPage.is() )
{
@@ -196,7 +201,7 @@ void SAL_CALL VCLXTabPageContainer::elementInserted( const ::com::sun::star::con
void SAL_CALL VCLXTabPageContainer::elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- TabControl* pTabCtrl = static_cast<TabControl*>(GetWindow());
+ VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY);
if ( pTabCtrl && xTabPage.is() )
{
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx
index 3d7a22dbeb23..84a1d75940af 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -366,7 +366,7 @@ void VCLXWindow::ImplExecuteAsyncWithoutSolarLock( const Callback& i_callback )
return mpImpl->getAccessibleFactory().getFactory();
}
-void VCLXWindow::SetWindow( vcl::Window* pWindow )
+void VCLXWindow::SetWindow( VclPtr<vcl::Window> pWindow )
{
if ( GetWindow() )
{
@@ -922,10 +922,10 @@ void VCLXWindow::dispose( ) throw(::com::sun::star::uno::RuntimeException, std:
if ( GetWindow() )
{
- OutputDevice* pOutDev = GetOutputDevice();
+ VclPtr<OutputDevice> pOutDev = GetOutputDevice();
SetWindow( NULL ); // so that handlers are logged off, if necessary (virtual)
- SetOutputDevice( pOutDev );
- DestroyOutputDevice();
+ SetOutputDevice( NULL );
+ pOutDev.disposeAndClear();
}
// #i14103# dispose the accessible context after the window has been destroyed,
@@ -1921,7 +1921,7 @@ void VCLXWindow::setProperty( const OUString& PropertyName, const ::com::sun::st
{
case BASEPROPERTY_REFERENCE_DEVICE:
{
- Control* pControl = dynamic_cast< Control* >( GetWindow() );
+ VclPtr<Control> pControl = GetAsDynamic<Control >();
OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
if ( !pControl )
break;
diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx
index a30695d5afd5..b3c07eb478bd 100644
--- a/toolkit/source/awt/vclxwindows.cxx
+++ b/toolkit/source/awt/vclxwindows.cxx
@@ -215,7 +215,7 @@ void VCLXGraphicControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
void VCLXGraphicControl::ImplSetNewImage()
{
OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" );
- Button* pButton = static_cast< Button* >( GetWindow() );
+ VclPtr< Button > pButton = GetAsDynamic< Button >();
pButton->SetModeImage( GetImage() );
}
@@ -236,8 +236,10 @@ void VCLXGraphicControl::setProperty( const OUString& PropertyName, const ::com:
{
SolarMutexGuard aGuard;
- if ( !GetWindow() )
+ VclPtr< Button > pButton = GetAs< Button >();
+ if ( !pButton )
return;
+
sal_uInt16 nPropType = GetPropertyId( PropertyName );
switch ( nPropType )
{
@@ -310,7 +312,8 @@ void VCLXGraphicControl::setProperty( const OUString& PropertyName, const ::com:
|| ( eType == WINDOW_CHECKBOX )
)
{
- aProp <<= ::toolkit::getCompatibleImageAlign( static_cast< Button* >( GetWindow() )->GetImageAlign() );
+ aProp <<= ::toolkit::getCompatibleImageAlign(
+ GetAs<Button>()->GetImageAlign() );
}
}
break;
@@ -322,7 +325,8 @@ void VCLXGraphicControl::setProperty( const OUString& PropertyName, const ::com:
|| ( eType == WINDOW_CHECKBOX )
)
{
- aProp <<= ::toolkit::translateImagePosition( static_cast< Button* >( GetWindow() )->GetImageAlign() );
+ aProp <<= ::toolkit::translateImagePosition(
+ GetAs< Button >()->GetImageAlign() );
}
}
break;
@@ -444,7 +448,7 @@ void VCLXButton::setActionCommand( const OUString& rCommand ) throw(::com::sun::
SolarMutexGuard aGuard;
Size aSz;
- PushButton* pButton = static_cast<PushButton*>(GetWindow());
+ VclPtr< PushButton > pButton = GetAs< PushButton >();
if ( pButton )
aSz = pButton->CalcMinimumSize();
return AWTSize(aSz);
@@ -463,7 +467,7 @@ void VCLXButton::setActionCommand( const OUString& rCommand ) throw(::com::sun::
SolarMutexGuard aGuard;
Size aSz = VCLSize(rNewSize);
- PushButton* pButton = static_cast<PushButton*>( GetWindow() );
+ VclPtr< PushButton > pButton = GetAs< PushButton >();
if ( pButton )
{
Size aMinSz = pButton->CalcMinimumSize();
@@ -490,7 +494,7 @@ void VCLXButton::setProperty( const OUString& PropertyName, const ::com::sun::st
{
SolarMutexGuard aGuard;
- Button* pButton = static_cast<Button*>(GetWindow());
+ VclPtr< Button > pButton = GetAs< Button >();
if ( pButton )
{
sal_uInt16 nPropType = GetPropertyId( PropertyName );
@@ -519,7 +523,7 @@ void VCLXButton::setProperty( const OUString& PropertyName, const ::com::sun::st
{
sal_Int16 n = sal_Int16();
if ( Value >>= n )
- static_cast<PushButton*>(pButton)->SetState( (TriState)n );
+ static_cast<PushButton*>(pButton.get())->SetState( (TriState)n );
}
}
break;
@@ -536,7 +540,7 @@ void VCLXButton::setProperty( const OUString& PropertyName, const ::com::sun::st
SolarMutexGuard aGuard;
::com::sun::star::uno::Any aProp;
- Button* pButton = static_cast<Button*>(GetWindow());
+ VclPtr< Button > pButton = GetAs< Button >();
if ( pButton )
{
sal_uInt16 nPropType = GetPropertyId( PropertyName );
@@ -559,7 +563,7 @@ void VCLXButton::setProperty( const OUString& PropertyName, const ::com::sun::st
{
if ( GetWindow()->GetType() == WINDOW_PUSHBUTTON )
{
- aProp <<= (sal_Int16)static_cast<PushButton*>(pButton)->GetState();
+ aProp <<= (sal_Int16)static_cast<PushButton*>(pButton.get())->GetState();
}
}
break;
@@ -658,7 +662,7 @@ VCLXImageControl::~VCLXImageControl()
void VCLXImageControl::ImplSetNewImage()
{
OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" );
- ImageControl* pControl = static_cast< ImageControl* >( GetWindow() );
+ VclPtr<ImageControl> pControl = GetAs< ImageControl >();
pControl->SetImage( GetImage() );
}
@@ -694,7 +698,7 @@ void VCLXImageControl::setProperty( const OUString& PropertyName, const ::com::s
{
SolarMutexGuard aGuard;
- ImageControl* pImageControl = static_cast<ImageControl*>(GetWindow());
+ VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
sal_uInt16 nPropType = GetPropertyId( PropertyName );
switch ( nPropType )
@@ -731,7 +735,7 @@ void VCLXImageControl::setProperty( const OUString& PropertyName, const ::com::s
SolarMutexGuard aGuard;
::com::sun::star::uno::Any aProp;
- ImageControl* pImageControl = static_cast<ImageControl*>(GetWindow());
+ VclPtr< ImageControl > pImageControl = GetAs< ImageControl >();
sal_uInt16 nPropType = GetPropertyId( PropertyName );
switch ( nPropType )
@@ -863,7 +867,7 @@ void VCLXCheckBox::setState( short n ) throw(::com::sun::star::uno::RuntimeExcep
{
SolarMutexGuard aGuard;
- CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
+ VclPtr< CheckBox> pCheckBox = GetAs< CheckBox >();
if ( pCheckBox)
{
TriState eState;
@@ -892,7 +896,7 @@ short VCLXCheckBox::getState() throw(::com::sun::star::uno::RuntimeException, st
SolarMutexGuard aGuard;
short nState = -1;
- CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
+ VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
if ( pCheckBox )
{
switch ( pCheckBox->GetState() )
@@ -911,23 +915,23 @@ void VCLXCheckBox::enableTriState( sal_Bool b ) throw(::com::sun::star::uno::Run
{
SolarMutexGuard aGuard;
- CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
+ VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
if ( pCheckBox)
pCheckBox->EnableTriState( b );
}
-::com::sun::star::awt::Size VCLXCheckBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
+::com::sun::star::awt::Size VCLXCheckBox::getMinimumSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
Size aSz;
- CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
+ VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
if ( pCheckBox )
aSz = pCheckBox->CalcMinimumSize();
return AWTSize(aSz);
}
-::com::sun::star::awt::Size VCLXCheckBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
+::com::sun::star::awt::Size VCLXCheckBox::getPreferredSize() throw(::com::sun::star::uno::RuntimeException, std::exception)
{
return getMinimumSize();
}
@@ -937,7 +941,7 @@ void VCLXCheckBox::enableTriState( sal_Bool b ) throw(::com::sun::star::uno::Run
SolarMutexGuard aGuard;
Size aSz = VCLSize(rNewSize);
- CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
+ VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
if ( pCheckBox )
{
Size aMinSz = pCheckBox->CalcMinimumSize();
@@ -953,7 +957,7 @@ void VCLXCheckBox::setProperty( const OUString& PropertyName, const ::com::sun::
{
SolarMutexGuard aGuard;
- CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
+ VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
if ( pCheckBox )
{
sal_uInt16 nPropType = GetPropertyId( PropertyName );
@@ -990,7 +994,7 @@ void VCLXCheckBox::setProperty( const OUString& PropertyName, const ::com::sun::
SolarMutexGuard aGuard;
::com::sun::star::uno::Any aProp;
- CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
+ VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
if ( pCheckBox )
{
sal_uInt16 nPropType = GetPropertyId( PropertyName );
@@ -1025,7 +1029,7 @@ void VCLXCheckBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
// in during the listener call. To prevent the resulting crashs, we keep us
// alive as long as we're here
- CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow());
+ VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >();
if ( pCheckBox )
{
if ( maItemListeners.getLength() )
@@ -1125,7 +1129,7 @@ void VCLXRadioButton::setProperty( const OUString& PropertyName, const ::com::su
{
SolarMutexGuard aGuard;
- RadioButton* pButton = static_cast<RadioButton*>(GetWindow());
+ VclPtr< RadioButton > pButton = GetAs< RadioButton >();
if ( pButton )
{
sal_uInt16 nPropType = GetPropertyId( PropertyName );
@@ -1168,7 +1172,7 @@ void VCLXRadioButton::setProperty( const OUString& PropertyName, const ::com::su
SolarMutexGuard aGuard;
::com::sun::star::uno::Any aProp;
- RadioButton* pButton = static_cast<RadioButton*>(GetWindow());
+ VclPtr< RadioButton > pButton = GetAs< RadioButton >();
if ( pButton )
{
sal_uInt16 nPropType = GetPropertyId( PropertyName );
@@ -1235,7 +1239,7 @@ void VCLXRadioButton::setState( sal_Bool b ) throw(::com::sun::star::uno::Runtim
{
SolarMutexGuard aGuard;
- RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
+ VclPtr< RadioButton > pButton = GetAs< RadioButton >();
if ( pRadioButton)
{
pRadioButton->Check( b );
@@ -1254,7 +1258,7 @@ sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeExcepti
{
SolarMutexGuard aGuard;
- RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
+ VclPtr< RadioButton > pButton = GetAs< RadioButton >();
return pRadioButton ? pRadioButton->IsChecked() : sal_False;
}
@@ -1263,7 +1267,7 @@ sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeExcepti
SolarMutexGuard aGuard;
Size aSz;
- RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
+ VclPtr< RadioButton > pButton = GetAs< RadioButton >();
if ( pRadioButton )
aSz = pRadioButton->CalcMinimumSize();
return AWTSize(aSz);
@@ -1279,7 +1283,7 @@ sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeExcepti
SolarMutexGuard aGuard;
Size aSz = VCLSize(rNewSize);
- RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
+ VclPtr< RadioButton > pButton = GetAs< RadioButton >();
if ( pRadioButton )
{
Size aMinSz = pRadioButton->CalcMinimumSize();
@@ -1325,7 +1329,7 @@ void VCLXRadioButton::ImplClickedOrToggled( bool bToggled )
{
// In the formulars, RadioChecked is not enabled, call itemStateChanged only for click
// In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled
- RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow());
+ VclPtr< RadioButton > pButton = GetAs< RadioButton >();
if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() )
{
::com::sun::star::awt::ItemEvent aEvent;
@@ -1381,7 +1385,7 @@ void VCLXSpinField::up() throw(::com::sun::star::uno::RuntimeException, std::exc
{
SolarMutexGuard aGuard;
- SpinField* pSpinField = static_cast<SpinField*>(GetWindow());
+ VclPtr< SpinField > pSpinField = GetAs< SpinField >();
if ( pSpinField )
pSpinField->Up();
}
@@ -1390,7 +1394,7 @@ void VCLXSpinField::down() throw(::com::sun::star::uno::RuntimeException, std::e
{
SolarMutexGuard aGuard;
- SpinField* pSpinField = static_cast<SpinField*>(GetWindow());
+ VclPtr< SpinField > pSpinField = GetAs< SpinField >();
if ( pSpinField )
pSpinField->Down();
}
@@ -1399,7 +1403,7 @@ void VCLXSpinField::first() throw(::com::sun::star::uno::RuntimeException, std::
{
SolarMutexGuard aGuard;
- SpinField* pSpinField = static_cast<SpinField*>(GetWindow());
+ VclPtr< SpinField > pSpinField = GetAs< SpinField >();
if ( pSpinField )
pSpinField->First();
}
@@ -1408,7 +1412,7 @@ void VCLXSpinField::last() throw(::com::sun::star::uno::RuntimeException, std::e
{
SolarMutexGuard aGuard;
- SpinField* pSpinField = static_cast<SpinField*>(GetWindow());
+ VclPtr< SpinField > pSpinField = GetAs< SpinField >();
if ( pSpinField )
pSpinField->Last();
}
@@ -1549,8 +1553,7 @@ void VCLXListBox::removeActionListener( const ::com::sun::star::uno::Reference<
void VCLXListBox::addItem( const OUString& aItem, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
pBox->InsertEntry( aItem, nPos );
}
@@ -1558,8 +1561,7 @@ void VCLXListBox::addItem( const OUString& aItem, sal_Int16 nPos ) throw(::com::
void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
{
sal_uInt16 nP = nPos;
@@ -1582,8 +1584,7 @@ void VCLXListBox::addItems( const ::com::sun::star::uno::Sequence< OUString>& aI
void VCLXListBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
{
for ( sal_uInt16 n = nCount; n; )
@@ -1595,7 +1596,7 @@ sal_Int16 VCLXListBox::getItemCount() throw(::com::sun::star::uno::RuntimeExcept
{
SolarMutexGuard aGuard;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
return pBox ? pBox->GetEntryCount() : 0;
}
@@ -1604,7 +1605,7 @@ OUString VCLXListBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::Run
SolarMutexGuard aGuard;
OUString aItem;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
aItem = pBox->GetEntry( nPos );
return aItem;
@@ -1615,7 +1616,7 @@ OUString VCLXListBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::Run
SolarMutexGuard aGuard;
::com::sun::star::uno::Sequence< OUString> aSeq;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
{
sal_uInt16 nEntries = pBox->GetEntryCount();
@@ -1632,8 +1633,7 @@ OUString VCLXListBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::Run
sal_Int16 VCLXListBox::getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
return pBox ? pBox->GetSelectEntryPos() : 0;
}
@@ -1642,7 +1642,7 @@ sal_Int16 VCLXListBox::getSelectedItemPos() throw(::com::sun::star::uno::Runtime
SolarMutexGuard aGuard;
::com::sun::star::uno::Sequence<sal_Int16> aSeq;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
{
sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
@@ -1658,7 +1658,7 @@ OUString VCLXListBox::getSelectedItem() throw(::com::sun::star::uno::RuntimeExce
SolarMutexGuard aGuard;
OUString aItem;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
aItem = pBox->GetSelectEntry();
return aItem;
@@ -1669,7 +1669,7 @@ OUString VCLXListBox::getSelectedItem() throw(::com::sun::star::uno::RuntimeExce
SolarMutexGuard aGuard;
::com::sun::star::uno::Sequence< OUString> aSeq;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
{
sal_uInt16 nSelEntries = pBox->GetSelectEntryCount();
@@ -1684,7 +1684,7 @@ void VCLXListBox::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(::com:
{
SolarMutexGuard aGuard;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox && ( pBox->IsEntryPosSelected( nPos ) != bool(bSelect) ) )
{
pBox->SelectEntryPos( nPos, bSelect );
@@ -1703,7 +1703,7 @@ void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence<sal_Int1
{
SolarMutexGuard aGuard;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
{
bool bChanged = false;
@@ -1734,7 +1734,7 @@ void VCLXListBox::selectItem( const OUString& rItemText, sal_Bool bSelect ) thro
{
SolarMutexGuard aGuard;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
{
OUString aItemText( rItemText );
@@ -1742,12 +1742,10 @@ void VCLXListBox::selectItem( const OUString& rItemText, sal_Bool bSelect ) thro
}
}
-
void VCLXListBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
pBox->SetDropDownLineCount( nLines );
}
@@ -1757,7 +1755,7 @@ sal_Int16 VCLXListBox::getDropDownLineCount() throw(::com::sun::star::uno::Runti
SolarMutexGuard aGuard;
sal_Int16 nLines = 0;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
nLines = pBox->GetDropDownLineCount();
return nLines;
@@ -1766,9 +1764,8 @@ sal_Int16 VCLXListBox::getDropDownLineCount() throw(::com::sun::star::uno::Runti
sal_Bool VCLXListBox::isMutipleMode() throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
bool bMulti = false;
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
bMulti = pBox->IsMultiSelectionEnabled();
return bMulti;
@@ -1777,8 +1774,7 @@ sal_Bool VCLXListBox::isMutipleMode() throw(::com::sun::star::uno::RuntimeExcept
void VCLXListBox::setMultipleMode( sal_Bool bMulti ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
pBox->EnableMultiSelection( bMulti );
}
@@ -1786,8 +1782,7 @@ void VCLXListBox::setMultipleMode( sal_Bool bMulti ) throw(::com::sun::star::uno
void VCLXListBox::makeVisible( sal_Int16 nEntry ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if ( pBox )
pBox->SetTopEntry( nEntry );
}
@@ -1803,8 +1798,7 @@ void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
{
case VCLEVENT_LISTBOX_SELECT:
{
- ListBox* pListBox = static_cast<ListBox*>(GetWindow());
-
+ VclPtr< ListBox > pBox = GetAs< ListBox >();
if( pListBox )
{
bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) ? sal_True : sal_False;
@@ -1830,7 +1824,7 @@ void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
{
::com::sun::star::awt::ActionEvent aEvent;
aEvent.Source = (::cppu::OWeakObject*)this;
- aEvent.ActionCommand = static_cast<ListBox*>(GetWindow())->GetSelectEntry();
+ aEvent.ActionCommand = GetAs<ListBox>()->GetSelectEntry();
maActionListeners.actionPerformed( aEvent );
}
break;
@@ -1851,8 +1845,7 @@ void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
void VCLXListBox::setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pListBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
if ( pListBox )
{
sal_uInt16 nPropType = GetPropertyId( PropertyName );
@@ -1928,9 +1921,8 @@ void VCLXListBox::setProperty( const OUString& PropertyName, const ::com::sun::s
::com::sun::star::uno::Any VCLXListBox::getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
::com::sun::star::uno::Any aProp;
- ListBox* pListBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
if ( pListBox )
{
sal_uInt16 nPropType = GetPropertyId( PropertyName );
@@ -1982,9 +1974,8 @@ void VCLXListBox::setProperty( const OUString& PropertyName, const ::com::sun::s
::com::sun::star::awt::Size VCLXListBox::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
Size aSz;
- ListBox* pListBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
if ( pListBox )
aSz = pListBox->CalcMinimumSize();
return AWTSize(aSz);
@@ -1993,9 +1984,8 @@ void VCLXListBox::setProperty( const OUString& PropertyName, const ::com::sun::s
::com::sun::star::awt::Size VCLXListBox::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
Size aSz;
- ListBox* pListBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
if ( pListBox )
{
aSz = pListBox->CalcMinimumSize();
@@ -2008,9 +1998,8 @@ void VCLXListBox::setProperty( const OUString& PropertyName, const ::com::sun::s
::com::sun::star::awt::Size VCLXListBox::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
Size aSz = VCLSize(rNewSize);
- ListBox* pListBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
if ( pListBox )
aSz = pListBox->CalcAdjustedSize( aSz );
return AWTSize(aSz);
@@ -2019,9 +2008,8 @@ void VCLXListBox::setProperty( const OUString& PropertyName, const ::com::sun::s
::com::sun::star::awt::Size VCLXListBox::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
Size aSz;
- ListBox* pListBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
if ( pListBox )
aSz = pListBox->CalcBlockSize( nCols, nLines );
return AWTSize(aSz);
@@ -2030,9 +2018,8 @@ void VCLXListBox::setProperty( const OUString& PropertyName, const ::com::sun::s
void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
nCols = nLines = 0;
- ListBox* pListBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
if ( pListBox )
{
sal_uInt16 nC, nL;
@@ -2044,7 +2031,7 @@ void VCLXListBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) thro
void VCLXListBox::ImplCallItemListeners()
{
- ListBox* pListBox = static_cast<ListBox*>(GetWindow());
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
if ( pListBox && maItemListeners.getLength() )
{
::com::sun::star::awt::ItemEvent aEvent;
@@ -2083,8 +2070,7 @@ namespace
void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" );
ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pListBox->GetEntryCount() ) ),
@@ -2098,8 +2084,7 @@ void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) thr
void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" );
ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
@@ -2111,8 +2096,7 @@ void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent ) thro
void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ),
@@ -2131,7 +2115,7 @@ void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& i_rEvent ) throw
{
SolarMutexGuard aGuard;
- ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
pListBox->Clear();
@@ -2143,7 +2127,7 @@ void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent ) throw
{
SolarMutexGuard aGuard;
- ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() );
+ VclPtr< ListBox > pListBox = GetAs< ListBox >();
ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" );
pListBox->Clear();
@@ -2233,8 +2217,7 @@ OUString VCLXMessageBox::getCaptionText() throw(::com::sun::star::uno::RuntimeEx
void VCLXMessageBox::setMessageText( const OUString& rText ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- MessBox* pBox = static_cast<MessBox*>(GetWindow());
+ VclPtr< MessBox > pBox = GetAs< MessBox >();
if ( pBox )
pBox->SetMessText( rText );
}
@@ -2242,9 +2225,8 @@ void VCLXMessageBox::setMessageText( const OUString& rText ) throw(::com::sun::s
OUString VCLXMessageBox::getMessageText() throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
OUString aText;
- MessBox* pBox = static_cast<MessBox*>(GetWindow());
+ VclPtr< MessBox > pBox = GetAs< MessBox >();
if ( pBox )
aText = pBox->GetMessText();
return aText;
@@ -2253,8 +2235,7 @@ OUString VCLXMessageBox::getMessageText() throw(::com::sun::star::uno::RuntimeEx
sal_Int16 VCLXMessageBox::execute() throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- MessBox* pBox = static_cast<MessBox*>(GetWindow());
+ VclPtr< MessBox > pBox = GetAs< MessBox >();
return pBox ? pBox->Execute() : 0;
}
@@ -2301,8 +2282,7 @@ IMPL_XTYPEPROVIDER_END
void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result ) throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- Dialog* pDialog = dynamic_cast< Dialog* >( GetWindow() );
+ VclPtr<Dialog> pDialog = GetAsDynamic< Dialog >();
if ( pDialog )
pDialog->EndDialog( i_result );
}
@@ -2310,8 +2290,7 @@ void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result ) throw (RuntimeExcept
void SAL_CALL VCLXDialog::setHelpId( const OUString& rId ) throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
pWindow->SetHelpId( OUStringToOString( rId, RTL_TEXTENCODING_UTF8 ) );
}
@@ -2319,8 +2298,7 @@ void SAL_CALL VCLXDialog::setHelpId( const OUString& rId ) throw (RuntimeExcepti
void VCLXDialog::setTitle( const OUString& Title ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
-
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
pWindow->SetText( Title );
}
@@ -2330,7 +2308,7 @@ OUString VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException, s
SolarMutexGuard aGuard;
OUString aTitle;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
aTitle = pWindow->GetText();
return aTitle;
@@ -2376,7 +2354,7 @@ void VCLXDialog::endExecute() throw(::com::sun::star::uno::RuntimeException, std
void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
@@ -2510,7 +2488,7 @@ void SAL_CALL VCLXMultiPage::draw( sal_Int32 nX, sal_Int32 nY )
throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
@@ -2787,7 +2765,7 @@ void SAL_CALL VCLXTabPage::draw( sal_Int32 nX, sal_Int32 nY )
throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
@@ -2973,7 +2951,7 @@ OUString VCLXFixedHyperlink::getText() throw(::com::sun::star::uno::RuntimeExcep
SolarMutexGuard aGuard;
OUString aText;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
aText = pWindow->GetText();
return aText;
@@ -3003,7 +2981,7 @@ void VCLXFixedHyperlink::setAlignment( short nAlign ) throw(::com::sun::star::un
{
SolarMutexGuard aGuard;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
WinBits nNewBits = 0;
@@ -3025,7 +3003,7 @@ short VCLXFixedHyperlink::getAlignment() throw(::com::sun::star::uno::RuntimeExc
SolarMutexGuard aGuard;
short nAlign = 0;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
WinBits nStyle = pWindow->GetStyle();
@@ -3225,7 +3203,7 @@ void VCLXFixedText::setText( const OUString& Text ) throw(::com::sun::star::uno:
{
SolarMutexGuard aGuard;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
pWindow->SetText( Text );
}
@@ -3235,7 +3213,7 @@ OUString VCLXFixedText::getText() throw(::com::sun::star::uno::RuntimeException,
SolarMutexGuard aGuard;
OUString aText;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
aText = pWindow->GetText();
return aText;
@@ -3245,7 +3223,7 @@ void VCLXFixedText::setAlignment( short nAlign ) throw(::com::sun::star::uno::Ru
{
SolarMutexGuard aGuard;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
WinBits nNewBits = 0;
@@ -3267,7 +3245,7 @@ short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeExceptio
SolarMutexGuard aGuard;
short nAlign = 0;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
WinBits nStyle = pWindow->GetStyle();
@@ -3506,7 +3484,7 @@ void VCLXScrollBar::setOrientation( sal_Int32 n ) throw(::com::sun::star::uno::R
{
SolarMutexGuard aGuard;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
WinBits nStyle = pWindow->GetStyle();
@@ -3526,7 +3504,7 @@ sal_Int32 VCLXScrollBar::getOrientation() throw(::com::sun::star::uno::RuntimeEx
SolarMutexGuard aGuard;
sal_Int32 n = 0;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
WinBits nStyle = pWindow->GetStyle();
@@ -3913,7 +3891,7 @@ OUString VCLXEdit::getText() throw(::com::sun::star::uno::RuntimeException, std:
SolarMutexGuard aGuard;
OUString aText;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
aText = pWindow->GetText();
return aText;
@@ -4816,7 +4794,7 @@ VCLXDateField::~VCLXDateField()
//change the window type here to match the role
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXDateField::CreateAccessibleContext()
{
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
pWindow->SetType( WINDOW_DATEFIELD );
@@ -5164,7 +5142,7 @@ VCLXTimeField::~VCLXTimeField()
//change the window type here to match the role
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXTimeField::CreateAccessibleContext()
{
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{
pWindow->SetType( WINDOW_TIMEFIELD );
@@ -6608,7 +6586,7 @@ void SAL_CALL VCLXFrame::draw( sal_Int32 nX, sal_Int32 nY )
throw(::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- vcl::Window* pWindow = GetWindow();
+ VclPtr< vcl::Window > pWindow = GetWindow();
if ( pWindow )
{