diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-04-28 11:41:31 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-28 15:08:48 +0100 |
commit | e8b97a52c96df9c8e8055407b1e40ed7cb9cfc67 (patch) | |
tree | b322529f4a54a6427862cb20cb4cf87fb6a5d065 /toolkit | |
parent | 2b0be6c0e9d23f1b8535ba7033732ae2e3bfb5c9 (diff) | |
parent | 0cde74f788a054fa2b65107a030dd463b8d11c7a (diff) |
Merge remote-tracking branch 'origin/feature/vclptr'
Resolve several thousand lines of conflicts.
Conflicts:
accessibility/source/extended/accessiblelistbox.cxx
accessibility/source/standard/vclxaccessiblecombobox.cxx
accessibility/source/standard/vclxaccessibledropdowncombobox.cxx
accessibility/source/standard/vclxaccessibledropdownlistbox.cxx
accessibility/source/standard/vclxaccessiblelistbox.cxx
accessibility/source/standard/vclxaccessibletextfield.cxx
basctl/source/basicide/basidesh.cxx
cui/source/inc/chardlg.hxx
cui/source/tabpages/tpbitmap.cxx
dbaccess/source/ui/dlg/UserAdmin.cxx
dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
extensions/source/propctrlr/propertyeditor.hxx
extensions/source/scanner/sanedlg.cxx
filter/source/pdf/impdialog.cxx
include/sfx2/mgetempl.hxx
include/sfx2/sidebar/SidebarToolBox.hxx
include/sfx2/viewsh.hxx
include/svtools/brwbox.hxx
include/svtools/filectrl.hxx
include/svtools/scrwin.hxx
include/svx/dlgctrl.hxx
include/svx/sidebar/Popup.hxx
include/svx/sidebar/PopupContainer.hxx
include/svx/sidebar/PopupControl.hxx
include/svx/sidebar/SidebarDialControl.hxx
include/svx/sidebar/ValueSetWithTextControl.hxx
sc/source/ui/condformat/condformatdlgentry.cxx
sc/source/ui/navipi/navipi.cxx
sc/source/ui/sidebar/CellBorderStyleControl.hxx
sd/source/ui/animations/CustomAnimationDialog.cxx
sd/source/ui/inc/DrawViewShell.hxx
sd/source/ui/inc/Ruler.hxx
sd/source/ui/inc/SlideSorter.hxx
sd/source/ui/inc/ViewTabBar.hxx
sd/source/ui/inc/Window.hxx
sd/source/ui/inc/morphdlg.hxx
sd/source/ui/inc/sdpreslt.hxx
sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx
sd/source/ui/sidebar/LayoutMenu.hxx
sd/source/ui/sidebar/MasterPagesSelector.hxx
sd/source/ui/sidebar/NavigatorWrapper.hxx
sd/source/ui/sidebar/PanelBase.hxx
sd/source/ui/sidebar/RecentMasterPagesSelector.cxx
sd/source/ui/sidebar/RecentMasterPagesSelector.hxx
sd/source/ui/slideshow/showwindow.hxx
sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx
sd/source/ui/slidesorter/view/SlsLayeredDevice.hxx
sd/source/ui/view/ViewShellBase.cxx
sd/source/ui/view/drviewsa.cxx
sfx2/source/appl/fileobj.hxx
sfx2/source/appl/opengrf.cxx
sfx2/source/control/thumbnailviewacc.hxx
sfx2/source/dialog/securitypage.cxx
sfx2/source/dialog/templdlg.cxx
sfx2/source/doc/docinsert.cxx
sfx2/source/doc/guisaveas.cxx
sfx2/source/inc/alienwarn.hxx
sfx2/source/sidebar/Deck.cxx
sfx2/source/sidebar/Deck.hxx
sfx2/source/sidebar/DeckTitleBar.cxx
sfx2/source/sidebar/DeckTitleBar.hxx
sfx2/source/sidebar/MenuButton.cxx
sfx2/source/sidebar/MenuButton.hxx
sfx2/source/sidebar/Panel.cxx
sfx2/source/sidebar/Panel.hxx
sfx2/source/sidebar/PanelTitleBar.hxx
sfx2/source/sidebar/SidebarDockingWindow.hxx
sfx2/source/sidebar/SidebarToolBox.cxx
sfx2/source/sidebar/TabBar.hxx
sfx2/source/sidebar/TabItem.cxx
sfx2/source/sidebar/TabItem.hxx
sfx2/source/sidebar/TitleBar.hxx
sfx2/source/toolbox/imgmgr.cxx
starmath/inc/edit.hxx
starmath/inc/smmod.hxx
starmath/qa/cppunit/test_starmath.cxx
starmath/source/edit.cxx
starmath/source/smmod.cxx
svtools/source/brwbox/brwbox1.cxx
svtools/source/brwbox/datwin.hxx
svtools/source/contnr/fileview.cxx
svtools/source/contnr/simptabl.cxx
svtools/source/control/filectrl.cxx
svtools/source/control/valueimp.hxx
svx/inc/GalleryControl.hxx
svx/source/dialog/dlgctrl.cxx
svx/source/dialog/swframeexample.cxx
svx/source/fmcomp/fmgridif.cxx
svx/source/gallery2/GalleryControl.cxx
svx/source/sidebar/EmptyPanel.hxx
svx/source/sidebar/area/AreaPropertyPanel.hxx
svx/source/sidebar/area/AreaTransparencyGradientControl.hxx
svx/source/sidebar/graphic/GraphicPropertyPanel.hxx
svx/source/sidebar/insert/InsertPropertyPanel.cxx
svx/source/sidebar/insert/InsertPropertyPanel.hxx
svx/source/sidebar/line/LinePropertyPanel.hxx
svx/source/sidebar/line/LineWidthControl.cxx
svx/source/sidebar/line/LineWidthControl.hxx
svx/source/sidebar/line/LineWidthValueSet.hxx
svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
svx/source/sidebar/possize/SidebarDialControl.cxx
svx/source/sidebar/text/TextCharacterSpacingPopup.hxx
svx/source/sidebar/text/TextPropertyPanel.hxx
svx/source/sidebar/tools/PopupContainer.cxx
svx/source/sidebar/tools/PopupControl.cxx
svx/source/sidebar/tools/ValueSetWithTextControl.cxx
svx/source/svdraw/svdfmtf.hxx
svx/source/svdraw/svdibrow.cxx
svx/source/tbxctrls/colrctrl.cxx
svx/source/tbxctrls/tbcontrl.cxx
sw/source/ui/dbui/mmaddressblockpage.cxx
sw/source/ui/dialog/uiregionsw.cxx
sw/source/ui/index/cnttab.cxx
sw/source/uibase/inc/drpcps.hxx
sw/source/uibase/sidebar/PageColumnControl.hxx
sw/source/uibase/sidebar/PageMarginControl.hxx
sw/source/uibase/sidebar/PageOrientationControl.hxx
sw/source/uibase/sidebar/PagePropertyPanel.hxx
sw/source/uibase/sidebar/PageSizeControl.hxx
sw/source/uibase/uiview/view2.cxx
sw/source/uibase/utlui/navipi.cxx
vcl/inc/svdata.hxx
vcl/source/control/combobox.cxx
vcl/source/control/lstbox.cxx
vcl/source/window/dockwin.cxx
vcl/source/window/winproc.cxx
Change-Id: I056cf3026ff17d65cca0b6e6588bda4a88fa8d95
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/awt/animatedimagespeer.cxx | 39 | ||||
-rw-r--r-- | toolkit/source/awt/scrollabledialog.cxx | 47 | ||||
-rw-r--r-- | toolkit/source/awt/vclxaccessiblecomponent.cxx | 21 | ||||
-rw-r--r-- | toolkit/source/awt/vclxdevice.cxx | 25 | ||||
-rw-r--r-- | toolkit/source/awt/vclxprinter.cxx | 2 | ||||
-rw-r--r-- | toolkit/source/awt/vclxspinbutton.cxx | 2 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtabpagecontainer.cxx | 31 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 130 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindow.cxx | 9 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 515 | ||||
-rw-r--r-- | toolkit/source/controls/accessiblecontrolcontext.cxx | 11 | ||||
-rw-r--r-- | toolkit/source/helper/unowrapper.cxx | 28 | ||||
-rw-r--r-- | toolkit/source/helper/vclunohelper.cxx | 12 |
13 files changed, 423 insertions, 449 deletions
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/scrollabledialog.cxx b/toolkit/source/awt/scrollabledialog.cxx index 823fba383af5..bcb508c8c06e 100644 --- a/toolkit/source/awt/scrollabledialog.cxx +++ b/toolkit/source/awt/scrollabledialog.cxx @@ -31,11 +31,17 @@ namespace toolkit // in the same bitmap :-( WB_VSCROLL & WB_HSCROLL apparently are only for // child classes ( whole thing is a mess if you ask me ) template< class T> -ScrollableWrapper<T>::ScrollableWrapper( vcl::Window* pParent, WinBits nStyle ) : T( pParent, nStyle & ~( WB_AUTOHSCROLL | WB_AUTOVSCROLL ) ), maHScrollBar( this, WB_HSCROLL | WB_DRAG), maVScrollBar( this, WB_VSCROLL | WB_DRAG ), mbHasHoriBar( false ), mbHasVertBar( false ), maScrollVis( None ) +ScrollableWrapper<T>::ScrollableWrapper( vcl::Window* pParent, WinBits nStyle ) + : T( pParent, nStyle & ~( WB_AUTOHSCROLL | WB_AUTOVSCROLL ) ), + maHScrollBar( VclPtr<ScrollBar>::Create(this, WB_HSCROLL | WB_DRAG) ), + maVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG) ), + mbHasHoriBar( false ), + mbHasVertBar( false ), + maScrollVis( None ) { Link aLink( LINK( this, ScrollableWrapper, ScrollBarHdl ) ); - maVScrollBar.SetScrollHdl( aLink ); - maHScrollBar.SetScrollHdl( aLink ); + maVScrollBar->SetScrollHdl( aLink ); + maHScrollBar->SetScrollHdl( aLink ); ScrollBarVisibility aVis = None; @@ -62,12 +68,12 @@ void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState ) if ( maScrollVis == Hori || maScrollVis == Both ) { mbHasHoriBar = true; - maHScrollBar.Show(); + maHScrollBar->Show(); } if ( maScrollVis == Vert || maScrollVis == Both ) { mbHasVertBar = true; - maVScrollBar.Show(); + maVScrollBar->Show(); } if ( mbHasHoriBar || mbHasVertBar ) this->SetStyle( T::GetStyle() | WB_CLIPCHILDREN | SCROLL_UPDATE ); @@ -76,6 +82,15 @@ void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState ) template< class T> ScrollableWrapper<T>::~ScrollableWrapper() { + dispose(); +} + +template< class T> +void ScrollableWrapper<T>::dispose() +{ + maHScrollBar.disposeAndClear(); + maVScrollBar.disposeAndClear(); + T::dispose(); } template< class T> @@ -91,7 +106,7 @@ void ScrollableWrapper<T>::lcl_Scroll( long nX, long nY ) for ( int index = 0; index < T::GetChildCount(); ++index ) { vcl::Window* pChild = T::GetChild( index ); - if ( pChild && pChild != &maVScrollBar && pChild != &maHScrollBar ) + if ( pChild && pChild != maVScrollBar.get() && pChild != maHScrollBar.get() ) { Point aPos = pChild->GetPosPixel(); aPos += Point( nXScroll, nYScroll ); @@ -113,9 +128,9 @@ template< class T> sal_IntPtr ScrollableWrapper<T>::ScrollBarHdl( ScrollBar* pSB ) { sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos(); - if( pSB == &maVScrollBar ) + if( pSB == maVScrollBar.get() ) lcl_Scroll(mnScrollPos.X(), nPos ); - else if( pSB == &maHScrollBar ) + else if( pSB == maHScrollBar.get() ) lcl_Scroll(nPos, mnScrollPos.Y() ); return 1; } @@ -125,7 +140,7 @@ void ScrollableWrapper<T>::SetScrollTop( long nTop ) { Point aOld = mnScrollPos; lcl_Scroll( mnScrollPos.X() , mnScrollPos.Y() - nTop ); - maHScrollBar.SetThumbPos( 0 ); + maHScrollBar->SetThumbPos( 0 ); // new pos is 0,0 mnScrollPos = aOld; } @@ -134,7 +149,7 @@ void ScrollableWrapper<T>::SetScrollLeft( long nLeft ) { Point aOld = mnScrollPos; lcl_Scroll( mnScrollPos.X() - nLeft , mnScrollPos.Y() ); - maVScrollBar.SetThumbPos( 0 ); + maVScrollBar->SetThumbPos( 0 ); // new pos is 0,0 mnScrollPos = aOld; } @@ -166,14 +181,14 @@ void ScrollableWrapper<T>::ResetScrollBars() Point aVPos( aOutSz.Width() - mnScrWidth, 0 ); Point aHPos( 0, aOutSz.Height() - mnScrWidth ); - maVScrollBar.SetPosSizePixel( aVPos, Size( mnScrWidth, T::GetSizePixel().Height() - mnScrWidth ) ); - maHScrollBar.SetPosSizePixel( aHPos, Size( T::GetSizePixel().Width() - mnScrWidth, mnScrWidth ) ); + maVScrollBar->SetPosSizePixel( aVPos, Size( mnScrWidth, T::GetSizePixel().Height() - mnScrWidth ) ); + maHScrollBar->SetPosSizePixel( aHPos, Size( T::GetSizePixel().Width() - mnScrWidth, mnScrWidth ) ); - maHScrollBar.SetRangeMax( maScrollArea.Width() + mnScrWidth ); - maHScrollBar.SetVisibleSize( T::GetSizePixel().Width() ); + maHScrollBar->SetRangeMax( maScrollArea.Width() + mnScrWidth ); + maHScrollBar->SetVisibleSize( T::GetSizePixel().Width() ); - maVScrollBar.SetRangeMax( maScrollArea.Height() + mnScrWidth ); - maVScrollBar.SetVisibleSize( T::GetSizePixel().Height() ); + maVScrollBar->SetRangeMax( maScrollArea.Height() + mnScrWidth ); + maVScrollBar->SetVisibleSize( T::GetSizePixel().Height() ); } template class ScrollableWrapper< Dialog >; 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..da7ad04a0b18 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 ) @@ -109,7 +102,7 @@ IMPL_XTYPEPROVIDER_END if ( GetOutputDevice() ) { VCLXVirtualDevice* pVDev = new VCLXVirtualDevice; - VirtualDevice* pVclVDev = new VirtualDevice( *GetOutputDevice() ); + VclPtrInstance<VirtualDevice> pVclVDev( *GetOutputDevice() ); pVclVDev->SetOutputSizePixel( Size( nWidth, nHeight ) ); pVDev->SetVirtualDevice( pVclVDev ); xRef = pVDev; @@ -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/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx index 5cef0d0c70b7..b5fbf456b876 100644 --- a/toolkit/source/awt/vclxprinter.cxx +++ b/toolkit/source/awt/vclxprinter.cxx @@ -71,7 +71,7 @@ IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXPrinterPropertySet, VCLXPrinterPropertySet VCLXPrinterPropertySet::VCLXPrinterPropertySet( const OUString& rPrinterName ) : OPropertySetHelper( BrdcstHelper ) - , mxPrinter(std::make_shared<Printer>(rPrinterName)) + , mxPrinter(VclPtrInstance< Printer >(rPrinterName)) { SolarMutexGuard aSolarGuard; 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/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 22ce65128c78..50106d844729 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -800,67 +800,67 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, switch ( (WindowType)nType ) { case WINDOW_CANCELBUTTON: - pNewWindow = new CancelButton( pParent, nWinBits ); + pNewWindow = VclPtr<CancelButton>::Create( pParent, nWinBits ); *ppNewComp = new VCLXButton; break; case WINDOW_CHECKBOX: - pNewWindow = new CheckBox( pParent, nWinBits ); + pNewWindow = VclPtr<CheckBox>::Create( pParent, nWinBits ); *ppNewComp = new VCLXCheckBox; break; case WINDOW_COMBOBOX: - pNewWindow = new ComboBox( pParent, nWinBits|WB_AUTOHSCROLL ); + pNewWindow = VclPtr<ComboBox>::Create( pParent, nWinBits|WB_AUTOHSCROLL ); static_cast<ComboBox*>(pNewWindow)->EnableAutoSize( false ); *ppNewComp = new VCLXComboBox; break; case WINDOW_CURRENCYBOX: - pNewWindow = new CurrencyBox( pParent, nWinBits ); + pNewWindow = VclPtr<CurrencyBox>::Create( pParent, nWinBits ); break; case WINDOW_CURRENCYFIELD: - pNewWindow = new CurrencyField( pParent, nWinBits ); + pNewWindow = VclPtr<CurrencyField>::Create( pParent, nWinBits ); static_cast<CurrencyField*>(pNewWindow)->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXNumericField; static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( (FormatterBase*)static_cast<CurrencyField*>(pNewWindow) ); break; case WINDOW_DATEBOX: - pNewWindow = new DateBox( pParent, nWinBits ); + pNewWindow = VclPtr<DateBox>::Create( pParent, nWinBits ); break; case WINDOW_DATEFIELD: - pNewWindow = new DateField( pParent, nWinBits ); + pNewWindow = VclPtr<DateField>::Create( pParent, nWinBits ); static_cast<DateField*>(pNewWindow)->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXDateField; static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( (FormatterBase*)static_cast<DateField*>(pNewWindow) ); break; case WINDOW_DOCKINGAREA: - pNewWindow = new DockingAreaWindow( pParent ); + pNewWindow = VclPtr<DockingAreaWindow>::Create( pParent ); break; case WINDOW_MULTILINEEDIT: case WINDOW_EDIT: - pNewWindow = new Edit( pParent, nWinBits ); + pNewWindow = VclPtr<Edit>::Create( pParent, nWinBits ); *ppNewComp = new VCLXEdit; break; case WINDOW_ERRORBOX: - pNewWindow = new ErrorBox( pParent, nWinBits, OUString() ); + pNewWindow = VclPtr<ErrorBox>::Create( pParent, nWinBits, OUString() ); *ppNewComp = new VCLXMessageBox; break; case WINDOW_FIXEDBITMAP: - pNewWindow = new FixedBitmap( pParent, nWinBits ); + pNewWindow = VclPtr<FixedBitmap>::Create( pParent, nWinBits ); break; case WINDOW_FIXEDIMAGE: - pNewWindow = new ImageControl( pParent, nWinBits ); + pNewWindow = VclPtr<ImageControl>::Create( pParent, nWinBits ); *ppNewComp = new VCLXImageControl; break; case WINDOW_FIXEDLINE: - pNewWindow = new FixedLine( pParent, nWinBits ); + pNewWindow = VclPtr<FixedLine>::Create( pParent, nWinBits ); break; case WINDOW_FIXEDTEXT: - pNewWindow = new FixedText( pParent, nWinBits ); + pNewWindow = VclPtr<FixedText>::Create( pParent, nWinBits ); *ppNewComp = new VCLXFixedText; break; case WINDOW_FLOATINGWINDOW: - pNewWindow = new FloatingWindow( pParent, nWinBits ); + pNewWindow = VclPtr<FloatingWindow>::Create( pParent, nWinBits ); break; case WINDOW_GROUPBOX: - pNewWindow = new GroupBox( pParent, nWinBits ); + pNewWindow = VclPtr<GroupBox>::Create( pParent, nWinBits ); if ( bFrameControl ) { GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow ); @@ -871,43 +871,43 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, } break; case WINDOW_HELPBUTTON: - pNewWindow = new HelpButton( pParent, nWinBits ); + pNewWindow = VclPtr<HelpButton>::Create( pParent, nWinBits ); *ppNewComp = new VCLXButton; break; case WINDOW_IMAGEBUTTON: - pNewWindow = new ImageButton( pParent, nWinBits ); + pNewWindow = VclPtr<ImageButton>::Create( pParent, nWinBits ); *ppNewComp = new VCLXButton; break; case WINDOW_INFOBOX: - pNewWindow = new InfoBox( pParent, OUString() ); + pNewWindow = VclPtr<InfoBox>::Create( pParent, OUString() ); *ppNewComp = new VCLXMessageBox; break; case WINDOW_LISTBOX: - pNewWindow = new ListBox( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL ); + pNewWindow = VclPtr<ListBox>::Create( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL ); static_cast<ListBox*>(pNewWindow)->EnableAutoSize( false ); *ppNewComp = new VCLXListBox; break; case WINDOW_LONGCURRENCYBOX: - pNewWindow = new LongCurrencyBox( pParent, nWinBits ); + pNewWindow = VclPtr<LongCurrencyBox>::Create( pParent, nWinBits ); break; case WINDOW_LONGCURRENCYFIELD: - pNewWindow = new LongCurrencyField( pParent, nWinBits ); + pNewWindow = VclPtr<LongCurrencyField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXCurrencyField; static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( (FormatterBase*)static_cast<LongCurrencyField*>(pNewWindow) ); break; case WINDOW_MENUBUTTON: - pNewWindow = new MenuButton( pParent, nWinBits ); + pNewWindow = VclPtr<MenuButton>::Create( pParent, nWinBits ); *ppNewComp = new VCLXButton; break; case WINDOW_MESSBOX: - pNewWindow = new MessBox( pParent, nWinBits, OUString(), OUString() ); + pNewWindow = VclPtr<MessBox>::Create( pParent, nWinBits, OUString(), OUString() ); *ppNewComp = new VCLXMessageBox; break; case WINDOW_METRICBOX: - pNewWindow = new MetricBox( pParent, nWinBits ); + pNewWindow = VclPtr<MetricBox>::Create( pParent, nWinBits ); break; case WINDOW_METRICFIELD: - pNewWindow = new MetricField( pParent, nWinBits ); + pNewWindow = VclPtr<MetricField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXMetricField; static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( (FormatterBase*)static_cast<MetricField*>(pNewWindow) ); break; @@ -930,44 +930,44 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, } break; case WINDOW_MOREBUTTON: - pNewWindow = new MoreButton( pParent, nWinBits ); + pNewWindow = VclPtr<MoreButton>::Create( pParent, nWinBits ); *ppNewComp = new VCLXButton; break; case WINDOW_MULTILISTBOX: - pNewWindow = new MultiListBox( pParent, nWinBits ); + pNewWindow = VclPtr<MultiListBox>::Create( pParent, nWinBits ); *ppNewComp = new VCLXListBox; break; case WINDOW_NUMERICBOX: - pNewWindow = new NumericBox( pParent, nWinBits ); + pNewWindow = VclPtr<NumericBox>::Create( pParent, nWinBits ); break; case WINDOW_NUMERICFIELD: - pNewWindow = new NumericField( pParent, nWinBits ); + pNewWindow = VclPtr<NumericField>::Create( pParent, nWinBits ); static_cast<NumericField*>(pNewWindow)->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXNumericField; static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( (FormatterBase*)static_cast<NumericField*>(pNewWindow) ); break; case WINDOW_OKBUTTON: - pNewWindow = new OKButton( pParent, nWinBits ); + pNewWindow = VclPtr<OKButton>::Create( pParent, nWinBits ); *ppNewComp = new VCLXButton; break; case WINDOW_PATTERNBOX: - pNewWindow = new PatternBox( pParent, nWinBits ); + pNewWindow = VclPtr<PatternBox>::Create( pParent, nWinBits ); break; case WINDOW_PATTERNFIELD: - pNewWindow = new PatternField( pParent, nWinBits ); + pNewWindow = VclPtr<PatternField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXPatternField; static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( (FormatterBase*)static_cast<PatternField*>(pNewWindow) ); break; case WINDOW_PUSHBUTTON: - pNewWindow = new PushButton( pParent, nWinBits ); + pNewWindow = VclPtr<PushButton>::Create( pParent, nWinBits ); *ppNewComp = new VCLXButton; break; case WINDOW_QUERYBOX: - pNewWindow = new QueryBox( pParent, nWinBits, OUString() ); + pNewWindow = VclPtr<QueryBox>::Create( pParent, nWinBits, OUString() ); *ppNewComp = new VCLXMessageBox; break; case WINDOW_RADIOBUTTON: - pNewWindow = new RadioButton( pParent, nWinBits ); + pNewWindow = VclPtr<RadioButton>::Create( pParent, nWinBits ); *ppNewComp = new VCLXRadioButton; // by default, disable RadioCheck @@ -982,64 +982,64 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, static_cast<RadioButton*>(pNewWindow)->EnableRadioCheck( false ); break; case WINDOW_SCROLLBAR: - pNewWindow = new ScrollBar( pParent, nWinBits ); + pNewWindow = VclPtr<ScrollBar>::Create( pParent, nWinBits ); *ppNewComp = new VCLXScrollBar; break; case WINDOW_SCROLLBARBOX: - pNewWindow = new ScrollBarBox( pParent, nWinBits ); + pNewWindow = VclPtr<ScrollBarBox>::Create( pParent, nWinBits ); break; case WINDOW_SPINBUTTON: - pNewWindow = new SpinButton( pParent, nWinBits ); + pNewWindow = VclPtr<SpinButton>::Create( pParent, nWinBits ); *ppNewComp = new ::toolkit::VCLXSpinButton; break; case WINDOW_SPINFIELD: - pNewWindow = new SpinField( pParent, nWinBits ); + pNewWindow = VclPtr<SpinField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXNumericField; break; case WINDOW_SPLITTER: - pNewWindow = new Splitter( pParent, nWinBits ); + pNewWindow = VclPtr<Splitter>::Create( pParent, nWinBits ); break; case WINDOW_SPLITWINDOW: - pNewWindow = new SplitWindow( pParent, nWinBits ); + pNewWindow = VclPtr<SplitWindow>::Create( pParent, nWinBits ); break; case WINDOW_STATUSBAR: - pNewWindow = new StatusBar( pParent, nWinBits ); + pNewWindow = VclPtr<StatusBar>::Create( pParent, nWinBits ); break; case VCLWINDOW_SYSTEMCHILDWINDOW: - pNewWindow = new SystemChildWindow( pParent, nWinBits ); + pNewWindow = VclPtr<SystemChildWindow>::Create( pParent, nWinBits ); *ppNewComp = new VCLXSystemDependentWindow(); break; case WINDOW_TABCONTROL: - pNewWindow = new TabControl( pParent, nWinBits ); + pNewWindow = VclPtr<TabControl>::Create( pParent, nWinBits ); *ppNewComp = new VCLXMultiPage; break; case WINDOW_TABDIALOG: - pNewWindow = new TabDialog( pParent, nWinBits ); + pNewWindow = VclPtr<TabDialog>::Create( pParent, nWinBits ); break; case WINDOW_TABPAGE: { - pNewWindow = new TabPage( pParent, nWinBits ); + pNewWindow = VclPtr<TabPage>::Create( pParent, nWinBits ); *ppNewComp = new VCLXTabPage; } break; case WINDOW_TIMEBOX: - pNewWindow = new TimeBox( pParent, nWinBits ); + pNewWindow = VclPtr<TimeBox>::Create( pParent, nWinBits ); break; case WINDOW_TIMEFIELD: - pNewWindow = new TimeField( pParent, nWinBits ); + pNewWindow = VclPtr<TimeField>::Create( pParent, nWinBits ); static_cast<TimeField*>(pNewWindow)->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXTimeField; static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( (FormatterBase*)static_cast<TimeField*>(pNewWindow) ); break; case WINDOW_TOOLBOX: - pNewWindow = new ToolBox( pParent, nWinBits ); + pNewWindow = VclPtr<ToolBox>::Create( pParent, nWinBits ); *ppNewComp = new VCLXToolBox; break; case WINDOW_TRISTATEBOX: - pNewWindow = new TriStateBox( pParent, nWinBits ); + pNewWindow = VclPtr<TriStateBox>::Create( pParent, nWinBits ); break; case WINDOW_WARNINGBOX: - pNewWindow = new WarningBox( pParent, nWinBits, OUString() ); + pNewWindow = VclPtr<WarningBox>::Create( pParent, nWinBits, OUString() ); *ppNewComp = new VCLXMessageBox; break; case WINDOW_WORKWINDOW: @@ -1049,7 +1049,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_TOP ) { if (nType == WINDOW_DOCKINGWINDOW ) - pNewWindow = new DockingWindow( pParent, nWinBits ); + pNewWindow = VclPtr<DockingWindow>::Create( pParent, nWinBits ); else { if ((pParent == NULL) && rDescriptor.Parent.is()) @@ -1108,13 +1108,13 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, #elif defined WNT aParentData.hWnd = reinterpret_cast<HWND>(nWindowHandle); #endif - pNewWindow = new WorkWindow( &aParentData ); + pNewWindow = VclPtr<WorkWindow>::Create( &aParentData ); } } } if (!pNewWindow) - pNewWindow = new WorkWindow( pParent, nWinBits ); + pNewWindow = VclPtr<WorkWindow>::Create( pParent, nWinBits ); } *ppNewComp = new VCLXTopWindow( pNewWindow->GetType() == WINDOW_WORKWINDOW ); @@ -1122,17 +1122,17 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, else if ( rDescriptor.Type == ::com::sun::star::awt::WindowClass_CONTAINER ) { if (nType == WINDOW_DOCKINGWINDOW ) - pNewWindow = new DockingWindow( pParent, nWinBits ); + pNewWindow = VclPtr<DockingWindow>::Create( pParent, nWinBits ); else - pNewWindow = new vcl::Window( pParent, nWinBits ); + pNewWindow = VclPtr<vcl::Window>::Create( pParent, nWinBits ); *ppNewComp = new VCLXContainer; } else { if (nType == WINDOW_DOCKINGWINDOW ) - pNewWindow = new DockingWindow( pParent, nWinBits ); + pNewWindow = VclPtr<DockingWindow>::Create( pParent, nWinBits ); else - pNewWindow = new vcl::Window( pParent, nWinBits ); + pNewWindow = VclPtr<vcl::Window>::Create( pParent, nWinBits ); *ppNewComp = new VCLXWindow; } break; @@ -1140,12 +1140,12 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase( "tabpagecontainer" ) ) { - pNewWindow = new TabControl( pParent, nWinBits ); + pNewWindow = VclPtr<TabControl>::Create( pParent, nWinBits ); *ppNewComp = new VCLXTabPageContainer; } else if ( aServiceName == "animatedimages" ) { - pNewWindow = new Throbber( pParent, nWinBits ); + pNewWindow = VclPtr<Throbber>::Create( pParent, nWinBits ); *ppNewComp = new ::toolkit::AnimatedImagesPeer; } break; @@ -1293,7 +1293,7 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( // ::com::sun::star::awt::XSystemChildFactory ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > VCLXToolkit::createSystemChild( const ::com::sun::star::uno::Any& Parent, const ::com::sun::star::uno::Sequence< sal_Int8 >& /*ProcessId*/, sal_Int16 nSystemType ) throw(::com::sun::star::uno::RuntimeException, std::exception) { - vcl::Window* pChildWindow = NULL; + VclPtr<vcl::Window> pChildWindow; if ( nSystemType == SYSTEM_DEPENDENT_TYPE ) { // use sal_Int64 here to accommodate all int types @@ -1340,7 +1340,7 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( SolarMutexGuard aGuard; try { - pChildWindow = new WorkWindow( &aParentData ); + pChildWindow.reset( VclPtr<WorkWindow>::Create( &aParentData ) ); } catch ( const ::com::sun::star::uno::RuntimeException & rEx ) { @@ -1349,14 +1349,14 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( "VCLXToolkit::createSystemChild: caught %s\n", OUStringToOString( rEx.Message, RTL_TEXTENCODING_UTF8).getStr()); - pChildWindow = NULL; + pChildWindow.clear(); } } } else if (nSystemType == com::sun::star::lang::SystemDependent::SYSTEM_JAVA) { SolarMutexGuard aGuard; - pChildWindow = new WorkWindow(0, Parent); + pChildWindow.reset(VclPtr<WorkWindow>::Create(nullptr, Parent)); } ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer; diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 3d7a22dbeb23..ba8e5b3feb11 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( const VclPtr<vcl::Window> &pWindow ) { if ( GetWindow() ) { @@ -922,10 +922,11 @@ 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(); + pOutDev.disposeAndClear(); + SetOutputDevice( NULL ); } // #i14103# dispose the accessible context after the window has been destroyed, @@ -1921,7 +1922,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 a8c8cc0c4cd5..9b70dcf6daae 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 ) { @@ -260,10 +262,7 @@ void VCLXGraphicControl::setProperty( const OUString& PropertyName, const ::com: { sal_Int16 nAlignment = sal_Int16(); if ( Value >>= nAlignment ) - { - Button* pButton = static_cast< Button* >( GetWindow() ); - pButton->SetImageAlign( static_cast< ImageAlign >( nAlignment ) ); - } + GetAs< Button >()->SetImageAlign( static_cast< ImageAlign >( nAlignment ) ); } } break; @@ -277,8 +276,7 @@ void VCLXGraphicControl::setProperty( const OUString& PropertyName, const ::com: { sal_Int16 nImagePosition = 2; OSL_VERIFY( Value >>= nImagePosition ); - Button* pButton = static_cast< Button* >( GetWindow() ); - pButton->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) ); + GetAs<Button>()->SetImageAlign( ::toolkit::translateImagePosition( nImagePosition ) ); } } break; @@ -310,7 +308,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 +321,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 +444,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 +463,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 +490,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 +519,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 +536,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 +559,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 +658,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 +694,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 +731,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 +863,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 +892,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 +911,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 +937,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 +953,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 +990,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 +1025,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 +1125,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 +1168,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 +1235,7 @@ void VCLXRadioButton::setState( sal_Bool b ) throw(::com::sun::star::uno::Runtim { SolarMutexGuard aGuard; - RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow()); + VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >(); if ( pRadioButton) { pRadioButton->Check( b ); @@ -1254,7 +1254,7 @@ sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeExcepti { SolarMutexGuard aGuard; - RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow()); + VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >(); return pRadioButton ? pRadioButton->IsChecked() : sal_False; } @@ -1263,7 +1263,7 @@ sal_Bool VCLXRadioButton::getState() throw(::com::sun::star::uno::RuntimeExcepti SolarMutexGuard aGuard; Size aSz; - RadioButton* pRadioButton = static_cast<RadioButton*>(GetWindow()); + VclPtr< RadioButton > pRadioButton = GetAs< RadioButton >(); if ( pRadioButton ) aSz = pRadioButton->CalcMinimumSize(); return AWTSize(aSz); @@ -1279,7 +1279,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 > pRadioButton = GetAs< RadioButton >(); if ( pRadioButton ) { Size aMinSz = pRadioButton->CalcMinimumSize(); @@ -1325,7 +1325,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 > pRadioButton = GetAs< RadioButton >(); if ( pRadioButton && ( pRadioButton->IsRadioCheckEnabled() == bToggled ) && ( bToggled || pRadioButton->IsStateChanged() ) && maItemListeners.getLength() ) { ::com::sun::star::awt::ItemEvent aEvent; @@ -1381,7 +1381,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 +1390,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 +1399,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 +1408,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 +1549,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 +1557,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 +1580,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 +1592,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 +1601,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 +1612,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 +1629,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 +1638,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 +1654,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 +1665,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 +1680,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 +1699,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 +1730,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 +1738,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 +1751,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 +1760,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 +1770,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 +1778,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 +1794,7 @@ void VCLXListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { case VCLEVENT_LISTBOX_SELECT: { - ListBox* pListBox = static_cast<ListBox*>(GetWindow()); - + VclPtr< ListBox > pListBox = GetAs< ListBox >(); if( pListBox ) { bool bDropDown = ( pListBox->GetStyle() & WB_DROPDOWN ) != 0; @@ -1830,7 +1820,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 +1841,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 +1917,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 +1970,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 +1980,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 +1994,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 +2004,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 +2014,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 +2027,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 +2066,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 +2080,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 +2092,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 +2111,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 +2123,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 +2213,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 +2221,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 +2231,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 +2278,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 +2286,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 +2294,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 +2304,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; @@ -2343,7 +2317,7 @@ sal_Int16 VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException, s sal_Int16 nRet = 0; if ( GetWindow() ) { - Dialog* pDlg = static_cast<Dialog*>(GetWindow()); + VclPtr< Dialog > pDlg = GetAs< Dialog >(); vcl::Window* pParent = pDlg->GetWindow( WINDOW_PARENTOVERLAP ); vcl::Window* pOldParent = NULL; vcl::Window* pSetParent = NULL; @@ -2376,8 +2350,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 ) { OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); @@ -2396,7 +2369,7 @@ void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::s ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); SolarMutexGuard aGuard; - Dialog* pDlg = static_cast<Dialog*>(GetWindow()); + VclPtr< Dialog > pDlg = GetAs< Dialog >(); if ( pDlg ) pDlg->GetDrawWindowBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset ); @@ -2409,8 +2382,7 @@ void SAL_CALL VCLXDialog::setProperty( throw(::com::sun::star::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - - Dialog* pDialog = static_cast<Dialog*>(GetWindow()); + VclPtr< Dialog > pDialog = GetAs< Dialog >(); if ( pDialog ) { bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; @@ -2510,7 +2482,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 ) { @@ -2563,7 +2535,7 @@ throw(::com::sun::star::uno::RuntimeException, std::exception) SolarMutexGuard aGuard; OSL_TRACE(" **** VCLXMultiPage::setProperty( %s )", OUStringToOString( PropertyName, RTL_TEXTENCODING_UTF8 ).getStr() ); - TabControl* pTabControl = static_cast<TabControl*>(GetWindow()); + VclPtr< TabControl > pTabControl = GetAs< TabControl >(); if ( pTabControl ) { bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; @@ -2615,7 +2587,7 @@ throw(::com::sun::star::uno::RuntimeException, std::exception) TabControl *VCLXMultiPage::getTabControl() const throw (uno::RuntimeException) { - TabControl *pTabControl = dynamic_cast< TabControl* >( GetWindow() ); + VclPtr<TabControl> pTabControl = GetAsDynamic< TabControl >(); if ( pTabControl ) return pTabControl; throw uno::RuntimeException(); @@ -2623,7 +2595,7 @@ TabControl *VCLXMultiPage::getTabControl() const throw (uno::RuntimeException) sal_Int32 SAL_CALL VCLXMultiPage::insertTab() throw (uno::RuntimeException, std::exception) { TabControl *pTabControl = getTabControl(); - TabPage* pTab = new TabPage( pTabControl ); + VclPtrInstance<TabPage> pTab( pTabControl ); OUString title (""); return static_cast< sal_Int32 >( insertTab( pTab, title ) ); } @@ -2787,7 +2759,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 ) { @@ -2816,8 +2788,7 @@ void SAL_CALL VCLXTabPage::setProperty( throw(::com::sun::star::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - - TabPage* pTabPage = static_cast<TabPage*>(GetWindow()); + VclPtr< TabPage > pTabPage = GetAs< TabPage >(); if ( pTabPage ) { bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; @@ -2867,7 +2838,7 @@ throw(::com::sun::star::uno::RuntimeException, std::exception) TabPage *VCLXTabPage::getTabPage() const throw (uno::RuntimeException) { - TabPage *pTabPage = dynamic_cast< TabPage* >( GetWindow() ); + VclPtr< TabPage > pTabPage = GetAsDynamic< TabPage >(); if ( pTabPage ) return pTabPage; throw uno::RuntimeException(); @@ -2928,7 +2899,7 @@ void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEve { // open the URL OUString sURL; - FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow()); + VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >(); if ( pBase ) sURL = pBase->GetURL(); Reference< ::com::sun::star::system::XSystemShellExecute > xSystemShellExecute( ::com::sun::star::system::SystemShellExecute::create( @@ -2962,8 +2933,7 @@ void VCLXFixedHyperlink::ProcessWindowEvent( const VclWindowEvent& rVclWindowEve void VCLXFixedHyperlink::setText( const OUString& Text ) throw(::com::sun::star::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - - FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow()); + VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >(); if (pBase) pBase->SetText(Text); } @@ -2973,7 +2943,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; @@ -2982,8 +2952,7 @@ OUString VCLXFixedHyperlink::getText() throw(::com::sun::star::uno::RuntimeExcep void VCLXFixedHyperlink::setURL( const OUString& URL ) throw(::com::sun::star::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - - FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow()); + VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >(); if ( pBase ) pBase->SetURL( URL ); } @@ -2993,7 +2962,7 @@ OUString VCLXFixedHyperlink::getURL( ) throw(::com::sun::star::uno::RuntimeExce SolarMutexGuard aGuard; OUString aText; - FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow()); + VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >(); if ( pBase ) aText = pBase->GetURL(); return aText; @@ -3003,7 +2972,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 +2994,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(); @@ -3054,9 +3023,8 @@ void VCLXFixedHyperlink::removeActionListener( const ::com::sun::star::uno::Refe ::com::sun::star::awt::Size VCLXFixedHyperlink::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - Size aSz; - FixedText* pFixedText = static_cast<FixedText*>(GetWindow()); + VclPtr< FixedText > pFixedText = GetAs< FixedText >(); if ( pFixedText ) aSz = pFixedText->CalcMinimumSize(); return AWTSize(aSz); @@ -3083,7 +3051,7 @@ void VCLXFixedHyperlink::setProperty( const OUString& PropertyName, const ::com: { SolarMutexGuard aGuard; - FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow()); + VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >(); if ( pBase ) { sal_uInt16 nPropType = GetPropertyId( PropertyName ); @@ -3118,7 +3086,7 @@ void VCLXFixedHyperlink::setProperty( const OUString& PropertyName, const ::com: SolarMutexGuard aGuard; ::com::sun::star::uno::Any aProp; - FixedHyperlink* pBase = static_cast<FixedHyperlink*>(GetWindow()); + VclPtr< FixedHyperlink > pBase = GetAs< FixedHyperlink >(); if ( pBase ) { sal_uInt16 nPropType = GetPropertyId( PropertyName ); @@ -3225,7 +3193,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 +3203,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 +3213,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 +3235,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(); @@ -3286,7 +3254,7 @@ short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeExceptio SolarMutexGuard aGuard; Size aSz; - FixedText* pFixedText = static_cast<FixedText*>(GetWindow()); + VclPtr< FixedText > pFixedText = GetAs< FixedText >(); if ( pFixedText ) aSz = pFixedText->CalcMinimumSize(); return AWTSize(aSz); @@ -3302,7 +3270,7 @@ short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeExceptio SolarMutexGuard aGuard; Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) ); - FixedText* pFixedText = static_cast<FixedText*>(GetWindow()); + VclPtr< FixedText > pFixedText = GetAs< FixedText >(); if ( pFixedText ) aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width ); return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize ); @@ -3391,7 +3359,7 @@ void VCLXScrollBar::setValue( sal_Int32 n ) throw(::com::sun::star::uno::Runtime { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) pScrollBar->DoScroll( n ); } @@ -3400,7 +3368,7 @@ void VCLXScrollBar::setValues( sal_Int32 nValue, sal_Int32 nVisible, sal_Int32 n { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) { pScrollBar->SetVisibleSize( nVisible ); @@ -3413,7 +3381,7 @@ sal_Int32 VCLXScrollBar::getValue() throw(::com::sun::star::uno::RuntimeExceptio { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); return pScrollBar ? pScrollBar->GetThumbPos() : 0; } @@ -3421,7 +3389,7 @@ void VCLXScrollBar::setMaximum( sal_Int32 n ) throw(::com::sun::star::uno::Runti { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) pScrollBar->SetRangeMax( n ); } @@ -3430,7 +3398,7 @@ sal_Int32 VCLXScrollBar::getMaximum() throw(::com::sun::star::uno::RuntimeExcept { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); return pScrollBar ? pScrollBar->GetRangeMax() : 0; } @@ -3438,7 +3406,7 @@ void VCLXScrollBar::setMinimum( sal_Int32 n ) throw(::com::sun::star::uno::Runti { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() ); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) pScrollBar->SetRangeMin( n ); } @@ -3447,7 +3415,7 @@ sal_Int32 VCLXScrollBar::getMinimum() throw(::com::sun::star::uno::RuntimeExcept { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() ); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); return pScrollBar ? pScrollBar->GetRangeMin() : 0; } @@ -3455,7 +3423,7 @@ void VCLXScrollBar::setLineIncrement( sal_Int32 n ) throw(::com::sun::star::uno: { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) pScrollBar->SetLineSize( n ); } @@ -3464,7 +3432,7 @@ sal_Int32 VCLXScrollBar::getLineIncrement() throw(::com::sun::star::uno::Runtime { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); return pScrollBar ? pScrollBar->GetLineSize() : 0; } @@ -3472,7 +3440,7 @@ void VCLXScrollBar::setBlockIncrement( sal_Int32 n ) throw(::com::sun::star::uno { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) pScrollBar->SetPageSize( n ); } @@ -3481,7 +3449,7 @@ sal_Int32 VCLXScrollBar::getBlockIncrement() throw(::com::sun::star::uno::Runtim { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); return pScrollBar ? pScrollBar->GetPageSize() : 0; } @@ -3489,7 +3457,7 @@ void VCLXScrollBar::setVisibleSize( sal_Int32 n ) throw(::com::sun::star::uno::R { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) pScrollBar->SetVisibleSize( n ); } @@ -3498,7 +3466,7 @@ sal_Int32 VCLXScrollBar::getVisibleSize() throw(::com::sun::star::uno::RuntimeEx { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); return pScrollBar ? pScrollBar->GetVisibleSize() : 0; } @@ -3506,7 +3474,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 +3494,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(); @@ -3544,7 +3512,7 @@ void VCLXScrollBar::setProperty( const OUString& PropertyName, const ::com::sun: { SolarMutexGuard aGuard; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) { bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; @@ -3660,7 +3628,7 @@ void VCLXScrollBar::setProperty( const OUString& PropertyName, const ::com::sun: SolarMutexGuard aGuard; ::com::sun::star::uno::Any aProp; - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) { sal_uInt16 nPropType = GetPropertyId( PropertyName ); @@ -3737,7 +3705,7 @@ void VCLXScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) if ( maAdjustmentListeners.getLength() ) { - ScrollBar* pScrollBar = static_cast<ScrollBar*>(GetWindow()); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if( pScrollBar ) { @@ -3877,7 +3845,7 @@ void VCLXEdit::setText( const OUString& aText ) throw(::com::sun::star::uno::Run { SolarMutexGuard aGuard; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { pEdit->SetText( aText ); @@ -3894,7 +3862,7 @@ void VCLXEdit::insertText( const ::com::sun::star::awt::Selection& rSel, const O { SolarMutexGuard aGuard; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { pEdit->SetSelection( Selection( rSel.Min, rSel.Max ) ); @@ -3913,7 +3881,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; @@ -3924,7 +3892,7 @@ OUString VCLXEdit::getSelectedText() throw(::com::sun::star::uno::RuntimeExcepti SolarMutexGuard aGuard; OUString aText; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit) aText = pEdit->GetSelected(); return aText; @@ -3935,7 +3903,7 @@ void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection { SolarMutexGuard aGuard; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) pEdit->SetSelection( Selection( aSelection.Min, aSelection.Max ) ); } @@ -3945,7 +3913,7 @@ void VCLXEdit::setSelection( const ::com::sun::star::awt::Selection& aSelection SolarMutexGuard aGuard; Selection aSel; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) aSel = pEdit->GetSelection(); return ::com::sun::star::awt::Selection( aSel.Min(), aSel.Max() ); @@ -3955,7 +3923,7 @@ sal_Bool VCLXEdit::isEditable() throw(::com::sun::star::uno::RuntimeException, s { SolarMutexGuard aGuard; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); return ( pEdit && !pEdit->IsReadOnly() && pEdit->IsEnabled() ) ? sal_True : sal_False; } @@ -3963,7 +3931,7 @@ void VCLXEdit::setEditable( sal_Bool bEditable ) throw(::com::sun::star::uno::Ru { SolarMutexGuard aGuard; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) pEdit->SetReadOnly( !bEditable ); } @@ -3973,7 +3941,7 @@ void VCLXEdit::setMaxTextLen( sal_Int16 nLen ) throw(::com::sun::star::uno::Runt { SolarMutexGuard aGuard; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) pEdit->SetMaxTextLen( nLen ); } @@ -3982,7 +3950,7 @@ sal_Int16 VCLXEdit::getMaxTextLen() throw(::com::sun::star::uno::RuntimeExceptio { SolarMutexGuard aGuard; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); return pEdit ? pEdit->GetMaxTextLen() : 0; } @@ -3990,7 +3958,7 @@ void VCLXEdit::setEchoChar( sal_Unicode cEcho ) throw(::com::sun::star::uno::Run { SolarMutexGuard aGuard; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) pEdit->SetEchoChar( cEcho ); } @@ -3999,7 +3967,7 @@ void VCLXEdit::setProperty( const OUString& PropertyName, const ::com::sun::star { SolarMutexGuard aGuard; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { sal_uInt16 nPropType = GetPropertyId( PropertyName ); @@ -4045,7 +4013,7 @@ void VCLXEdit::setProperty( const OUString& PropertyName, const ::com::sun::star SolarMutexGuard aGuard; ::com::sun::star::uno::Any aProp; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { sal_uInt16 nPropType = GetPropertyId( PropertyName ); @@ -4077,7 +4045,7 @@ void VCLXEdit::setProperty( const OUString& PropertyName, const ::com::sun::star SolarMutexGuard aGuard; Size aSz; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) aSz = pEdit->CalcMinimumSize(); return AWTSize(aSz); @@ -4088,7 +4056,7 @@ void VCLXEdit::setProperty( const OUString& PropertyName, const ::com::sun::star SolarMutexGuard aGuard; Size aSz; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { aSz = pEdit->CalcMinimumSize(); @@ -4114,7 +4082,7 @@ void VCLXEdit::setProperty( const OUString& PropertyName, const ::com::sun::star SolarMutexGuard aGuard; Size aSz; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { if ( nCols ) @@ -4131,7 +4099,7 @@ void VCLXEdit::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(: nLines = 1; nCols = 0; - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) nCols = pEdit->GetMaxVisChars(); } @@ -4257,7 +4225,7 @@ void VCLXComboBox::addItem( const OUString& aItem, sal_Int16 nPos ) throw(::com: { SolarMutexGuard aGuard; - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); if ( pBox ) pBox->InsertEntry( aItem, nPos ); } @@ -4266,7 +4234,7 @@ void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence< OUString>& a { SolarMutexGuard aGuard; - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); if ( pBox ) { sal_uInt16 nP = nPos; @@ -4287,7 +4255,7 @@ void VCLXComboBox::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(::com:: { SolarMutexGuard aGuard; - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); if ( pBox ) { for ( sal_uInt16 n = nCount; n; ) @@ -4299,7 +4267,7 @@ sal_Int16 VCLXComboBox::getItemCount() throw(::com::sun::star::uno::RuntimeExcep { SolarMutexGuard aGuard; - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); return pBox ? pBox->GetEntryCount() : 0; } @@ -4308,7 +4276,7 @@ OUString VCLXComboBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::Ru SolarMutexGuard aGuard; OUString aItem; - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); if ( pBox ) aItem = pBox->GetEntry( nPos ); return aItem; @@ -4319,7 +4287,7 @@ OUString VCLXComboBox::getItem( sal_Int16 nPos ) throw(::com::sun::star::uno::Ru SolarMutexGuard aGuard; ::com::sun::star::uno::Sequence< OUString> aSeq; - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); if ( pBox ) { sal_uInt16 nEntries = pBox->GetEntryCount(); @@ -4337,7 +4305,7 @@ void VCLXComboBox::setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::st { SolarMutexGuard aGuard; - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); if ( pBox ) pBox->SetDropDownLineCount( nLines ); } @@ -4347,7 +4315,7 @@ sal_Int16 VCLXComboBox::getDropDownLineCount() throw(::com::sun::star::uno::Runt SolarMutexGuard aGuard; sal_Int16 nLines = 0; - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); if ( pBox ) nLines = pBox->GetDropDownLineCount(); return nLines; @@ -4357,7 +4325,7 @@ void VCLXComboBox::setProperty( const OUString& PropertyName, const ::com::sun:: { SolarMutexGuard aGuard; - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); if ( pComboBox ) { sal_uInt16 nPropType = GetPropertyId( PropertyName ); @@ -4414,7 +4382,7 @@ void VCLXComboBox::setProperty( const OUString& PropertyName, const ::com::sun:: SolarMutexGuard aGuard; ::com::sun::star::uno::Any aProp; - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); if ( pComboBox ) { sal_uInt16 nPropType = GetPropertyId( PropertyName ); @@ -4462,7 +4430,7 @@ void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) case VCLEVENT_COMBOBOX_SELECT: if ( maItemListeners.getLength() ) { - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); if( pComboBox ) { if ( !pComboBox->IsTravelSelect() ) @@ -4501,7 +4469,7 @@ void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) SolarMutexGuard aGuard; Size aSz; - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); if ( pComboBox ) aSz = pComboBox->CalcMinimumSize(); return AWTSize(aSz); @@ -4512,7 +4480,7 @@ void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) SolarMutexGuard aGuard; Size aSz; - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); if ( pComboBox ) { aSz = pComboBox->CalcMinimumSize(); @@ -4527,7 +4495,7 @@ void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) SolarMutexGuard aGuard; Size aSz = VCLSize(rNewSize); - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); if ( pComboBox ) aSz = pComboBox->CalcAdjustedSize( aSz ); return AWTSize(aSz); @@ -4538,7 +4506,7 @@ void VCLXComboBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) SolarMutexGuard aGuard; Size aSz; - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); if ( pComboBox ) aSz = pComboBox->CalcBlockSize( nCols, nLines ); return AWTSize(aSz); @@ -4549,7 +4517,7 @@ void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) thr SolarMutexGuard aGuard; nCols = nLines = 0; - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); if ( pComboBox ) { sal_uInt16 nC, nL; @@ -4562,7 +4530,7 @@ void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent ) th { SolarMutexGuard aGuard; - ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >(); ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" ); ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pComboBox->GetEntryCount() ) ), @@ -4577,7 +4545,7 @@ void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent ) thr { SolarMutexGuard aGuard; - ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >(); ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" ); ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ), @@ -4590,7 +4558,7 @@ void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent ) th { SolarMutexGuard aGuard; - ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >(); ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" ); ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ), @@ -4609,7 +4577,7 @@ void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& i_rEvent ) throw { SolarMutexGuard aGuard; - ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >(); ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" ); pComboBox->Clear(); @@ -4621,7 +4589,7 @@ void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent ) throw { SolarMutexGuard aGuard; - ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + VclPtr< ComboBox > pComboBox = GetAsDynamic< ComboBox >(); ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" ); pComboBox->Clear(); @@ -4816,7 +4784,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 ); @@ -4853,8 +4821,8 @@ void VCLXDateField::setProperty( const OUString& PropertyName, const ::com::sun: { if ( bVoid ) { - static_cast<DateField*>(GetWindow())->EnableEmptyFieldValue( true ); - static_cast<DateField*>(GetWindow())->SetEmptyFieldValue(); + GetAs< DateField >()->EnableEmptyFieldValue( true ); + GetAs< DateField >()->SetEmptyFieldValue(); } else { @@ -4882,21 +4850,21 @@ void VCLXDateField::setProperty( const OUString& PropertyName, const ::com::sun: { sal_Int16 n = sal_Int16(); if ( Value >>= n ) - static_cast<DateField*>(GetWindow())->SetExtDateFormat( (ExtDateFieldFormat) n ); + GetAs< DateField >()->SetExtDateFormat( (ExtDateFieldFormat) n ); } break; case BASEPROPERTY_DATESHOWCENTURY: { bool b = bool(); if ( Value >>= b ) - static_cast<DateField*>(GetWindow())->SetShowDateCentury( b ); + GetAs< DateField >()->SetShowDateCentury( b ); } break; case BASEPROPERTY_ENFORCE_FORMAT: { bool bEnforce( true ); OSL_VERIFY( Value >>= bEnforce ); - static_cast< DateField* >( GetWindow() )->EnforceValidValue( bEnforce ); + GetAs< DateField >()->EnforceValidValue( bEnforce ); } break; default: @@ -4935,12 +4903,12 @@ void VCLXDateField::setProperty( const OUString& PropertyName, const ::com::sun: break; case BASEPROPERTY_DATESHOWCENTURY: { - aProp <<= static_cast<DateField*>(GetWindow())->IsShowDateCentury(); + aProp <<= GetAs< DateField >()->IsShowDateCentury(); } break; case BASEPROPERTY_ENFORCE_FORMAT: { - aProp <<= static_cast< DateField* >( GetWindow() )->IsEnforceValidValue( ); + aProp <<= GetAs< DateField >()->IsEnforceValidValue( ); } break; default: @@ -4957,7 +4925,7 @@ void VCLXDateField::setDate( const util::Date& aDate ) throw(::com::sun::star::u { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) { pDateField->SetDate( aDate ); @@ -4974,7 +4942,7 @@ util::Date VCLXDateField::getDate() throw(::com::sun::star::uno::RuntimeExceptio { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) return pDateField->GetDate().GetUNODate(); else @@ -4985,7 +4953,7 @@ void VCLXDateField::setMin( const util::Date& aDate ) throw(::com::sun::star::un { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) pDateField->SetMin( aDate ); } @@ -4994,7 +4962,7 @@ util::Date VCLXDateField::getMin() throw(::com::sun::star::uno::RuntimeException { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) return pDateField->GetMin().GetUNODate(); else @@ -5005,7 +4973,7 @@ void VCLXDateField::setMax( const util::Date& aDate ) throw(::com::sun::star::un { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) pDateField->SetMax( aDate ); } @@ -5014,7 +4982,7 @@ util::Date VCLXDateField::getMax() throw(::com::sun::star::uno::RuntimeException { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) return pDateField->GetMax().GetUNODate(); else @@ -5025,7 +4993,7 @@ void VCLXDateField::setFirst( const util::Date& aDate ) throw(::com::sun::star:: { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) pDateField->SetFirst( aDate ); } @@ -5034,7 +5002,7 @@ util::Date VCLXDateField::getFirst() throw(::com::sun::star::uno::RuntimeExcepti { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) return pDateField->GetFirst().GetUNODate(); else @@ -5045,7 +5013,7 @@ void VCLXDateField::setLast( const util::Date& aDate ) throw(::com::sun::star::u { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) pDateField->SetLast( aDate ); } @@ -5054,7 +5022,7 @@ util::Date VCLXDateField::getLast() throw(::com::sun::star::uno::RuntimeExceptio { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) return pDateField->GetLast().GetUNODate(); else @@ -5065,7 +5033,7 @@ void VCLXDateField::setLongFormat( sal_Bool bLong ) throw(::com::sun::star::uno: { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) pDateField->SetLongFormat( bLong ); } @@ -5074,7 +5042,7 @@ sal_Bool VCLXDateField::isLongFormat() throw(::com::sun::star::uno::RuntimeExcep { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); return pDateField ? pDateField->IsLongFormat() : sal_False; } @@ -5082,7 +5050,7 @@ void VCLXDateField::setEmpty() throw(::com::sun::star::uno::RuntimeException, st { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); if ( pDateField ) { pDateField->SetEmptyDate(); @@ -5099,7 +5067,7 @@ sal_Bool VCLXDateField::isEmpty() throw(::com::sun::star::uno::RuntimeException, { SolarMutexGuard aGuard; - DateField* pDateField = static_cast<DateField*>(GetWindow()); + VclPtr< DateField > pDateField = GetAs< DateField >(); return pDateField ? pDateField->IsEmptyDate() : sal_False; } @@ -5164,7 +5132,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 ); @@ -5190,7 +5158,7 @@ void VCLXTimeField::setTime( const util::Time& aTime ) throw(::com::sun::star::u { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) { pTimeField->SetTime( aTime ); @@ -5207,7 +5175,7 @@ util::Time VCLXTimeField::getTime() throw(::com::sun::star::uno::RuntimeExceptio { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) return pTimeField->GetTime().GetUNOTime(); else @@ -5218,7 +5186,7 @@ void VCLXTimeField::setMin( const util::Time& aTime ) throw(::com::sun::star::un { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) pTimeField->SetMin( aTime ); } @@ -5227,7 +5195,7 @@ util::Time VCLXTimeField::getMin() throw(::com::sun::star::uno::RuntimeException { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) return pTimeField->GetMin().GetUNOTime(); else @@ -5238,7 +5206,7 @@ void VCLXTimeField::setMax( const util::Time& aTime ) throw(::com::sun::star::un { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) pTimeField->SetMax( aTime ); } @@ -5247,7 +5215,7 @@ util::Time VCLXTimeField::getMax() throw(::com::sun::star::uno::RuntimeException { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) return pTimeField->GetMax().GetUNOTime(); else @@ -5258,7 +5226,7 @@ void VCLXTimeField::setFirst( const util::Time& aTime ) throw(::com::sun::star:: { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) pTimeField->SetFirst( aTime ); } @@ -5267,7 +5235,7 @@ util::Time VCLXTimeField::getFirst() throw(::com::sun::star::uno::RuntimeExcepti { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) return pTimeField->GetFirst().GetUNOTime(); else @@ -5278,7 +5246,7 @@ void VCLXTimeField::setLast( const util::Time& aTime ) throw(::com::sun::star::u { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) pTimeField->SetLast( aTime ); } @@ -5287,7 +5255,7 @@ util::Time VCLXTimeField::getLast() throw(::com::sun::star::uno::RuntimeExceptio { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) return pTimeField->GetLast().GetUNOTime(); else @@ -5298,7 +5266,7 @@ void VCLXTimeField::setEmpty() throw(::com::sun::star::uno::RuntimeException, st { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); if ( pTimeField ) pTimeField->SetEmptyTime(); } @@ -5307,7 +5275,7 @@ sal_Bool VCLXTimeField::isEmpty() throw(::com::sun::star::uno::RuntimeException, { SolarMutexGuard aGuard; - TimeField* pTimeField = static_cast<TimeField*>(GetWindow()); + VclPtr< TimeField > pTimeField = GetAs< TimeField >(); return pTimeField ? pTimeField->IsEmptyTime() : sal_False; } @@ -5337,8 +5305,8 @@ void VCLXTimeField::setProperty( const OUString& PropertyName, const ::com::sun: { if ( bVoid ) { - static_cast<TimeField*>(GetWindow())->EnableEmptyFieldValue( true ); - static_cast<TimeField*>(GetWindow())->SetEmptyFieldValue(); + GetAs< TimeField >()->EnableEmptyFieldValue( true ); + GetAs< TimeField >()->SetEmptyFieldValue(); } else { @@ -5366,14 +5334,14 @@ void VCLXTimeField::setProperty( const OUString& PropertyName, const ::com::sun: { sal_Int16 n = sal_Int16(); if ( Value >>= n ) - static_cast<TimeField*>(GetWindow())->SetExtFormat( (ExtTimeFieldFormat) n ); + GetAs< TimeField >()->SetExtFormat( (ExtTimeFieldFormat) n ); } break; case BASEPROPERTY_ENFORCE_FORMAT: { bool bEnforce( true ); OSL_VERIFY( Value >>= bEnforce ); - static_cast< TimeField* >( GetWindow() )->EnforceValidValue( bEnforce ); + GetAs< TimeField >()->EnforceValidValue( bEnforce ); } break; default: @@ -5411,7 +5379,7 @@ void VCLXTimeField::setProperty( const OUString& PropertyName, const ::com::sun: break; case BASEPROPERTY_ENFORCE_FORMAT: { - aProp <<= static_cast< TimeField* >( GetWindow() )->IsEnforceValidValue( ); + aProp <<= GetAs< TimeField >()->IsEnforceValidValue( ); } break; default: @@ -5499,7 +5467,7 @@ void VCLXNumericField::setValue( double Value ) throw(::com::sun::star::uno::Run (long)ImplCalcLongValue( Value, pNumericFormatter->GetDecimalDigits() ) ); // #107218# Call same listeners like VCL would do after user interaction - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { SetSynthesizingVCLEvent( true ); @@ -5564,7 +5532,7 @@ void VCLXNumericField::setFirst( double Value ) throw(::com::sun::star::uno::Run { SolarMutexGuard aGuard; - NumericField* pNumericField = static_cast<NumericField*>(GetWindow()); + VclPtr< NumericField > pNumericField = GetAs< NumericField >(); if ( pNumericField ) pNumericField->SetFirst( (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) ); @@ -5574,7 +5542,7 @@ double VCLXNumericField::getFirst() throw(::com::sun::star::uno::RuntimeExceptio { SolarMutexGuard aGuard; - NumericField* pNumericField = static_cast<NumericField*>(GetWindow()); + VclPtr< NumericField > pNumericField = GetAs< NumericField >(); return pNumericField ? ImplCalcDoubleValue( (double)pNumericField->GetFirst(), pNumericField->GetDecimalDigits() ) : 0; @@ -5584,7 +5552,7 @@ void VCLXNumericField::setLast( double Value ) throw(::com::sun::star::uno::Runt { SolarMutexGuard aGuard; - NumericField* pNumericField = static_cast<NumericField*>(GetWindow()); + VclPtr< NumericField > pNumericField = GetAs< NumericField >(); if ( pNumericField ) pNumericField->SetLast( (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) ); @@ -5594,7 +5562,7 @@ double VCLXNumericField::getLast() throw(::com::sun::star::uno::RuntimeException { SolarMutexGuard aGuard; - NumericField* pNumericField = static_cast<NumericField*>(GetWindow()); + VclPtr< NumericField > pNumericField = GetAs< NumericField >(); return pNumericField ? ImplCalcDoubleValue( (double)pNumericField->GetLast(), pNumericField->GetDecimalDigits() ) : 0; @@ -5615,7 +5583,7 @@ void VCLXNumericField::setSpinSize( double Value ) throw(::com::sun::star::uno:: { SolarMutexGuard aGuard; - NumericField* pNumericField = static_cast<NumericField*>(GetWindow()); + VclPtr< NumericField > pNumericField = GetAs< NumericField >(); if ( pNumericField ) pNumericField->SetSpinSize( (long)ImplCalcLongValue( Value, pNumericField->GetDecimalDigits() ) ); @@ -5625,7 +5593,7 @@ double VCLXNumericField::getSpinSize() throw(::com::sun::star::uno::RuntimeExcep { SolarMutexGuard aGuard; - NumericField* pNumericField = static_cast<NumericField*>(GetWindow()); + VclPtr< NumericField > pNumericField = GetAs< NumericField >(); return pNumericField ? ImplCalcDoubleValue( (double)pNumericField->GetSpinSize(), pNumericField->GetDecimalDigits() ) : 0; @@ -5667,8 +5635,8 @@ void VCLXNumericField::setProperty( const OUString& PropertyName, const ::com::s { if ( bVoid ) { - static_cast<NumericField*>(GetWindow())->EnableEmptyFieldValue( true ); - static_cast<NumericField*>(GetWindow())->SetEmptyFieldValue(); + GetAs< NumericField >()->EnableEmptyFieldValue( true ); + GetAs< NumericField >()->SetEmptyFieldValue(); } else { @@ -5710,7 +5678,7 @@ void VCLXNumericField::setProperty( const OUString& PropertyName, const ::com::s { bool b = bool(); if ( Value >>= b ) - static_cast<NumericField*>(GetWindow())->SetUseThousandSep( b ); + GetAs< NumericField >()->SetUseThousandSep( b ); } break; default: @@ -5754,7 +5722,7 @@ void VCLXNumericField::setProperty( const OUString& PropertyName, const ::com::s break; case BASEPROPERTY_NUMSHOWTHOUSANDSEP: { - aProp <<= static_cast<NumericField*>(GetWindow())->IsUseThousandSep(); + aProp <<= GetAs< NumericField >()->IsUseThousandSep(); } break; default: @@ -5822,7 +5790,7 @@ MetricFormatter *VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::u MetricField *VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException) { - MetricField *pField = static_cast<MetricField *>(GetWindow()); + VclPtr< MetricField > pField = GetAs< MetricField >(); if (!pField) throw ::com::sun::star::uno::RuntimeException(); return pField; @@ -5880,7 +5848,7 @@ METRIC_MAP_PAIR(Last, Field) void VCLXMetricField::CallListeners() { // #107218# Call same listeners like VCL would do after user interaction - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { SetSynthesizingVCLEvent( true ); @@ -5960,21 +5928,21 @@ void VCLXMetricField::setProperty( const OUString& PropertyName, const ::com::su { bool b = false; if ( Value >>= b ) - static_cast<NumericField*>(GetWindow())->SetUseThousandSep( b ); + GetAs< NumericField >()->SetUseThousandSep( b ); } break; case BASEPROPERTY_UNIT: { sal_uInt16 nVal = 0; if ( Value >>= nVal ) - static_cast<MetricField*>(GetWindow())->SetUnit( (FieldUnit) nVal ); + GetAs< MetricField >()->SetUnit( (FieldUnit) nVal ); break; } case BASEPROPERTY_CUSTOMUNITTEXT: { OUString aStr; if ( Value >>= aStr ) - static_cast<MetricField*>(GetWindow())->SetCustomUnitText( aStr ); + GetAs< MetricField >()->SetCustomUnitText( aStr ); break; } default: @@ -5998,13 +5966,13 @@ void VCLXMetricField::setProperty( const OUString& PropertyName, const ::com::su switch ( nPropType ) { case BASEPROPERTY_NUMSHOWTHOUSANDSEP: - aProp <<= static_cast<NumericField*>(GetWindow())->IsUseThousandSep(); + aProp <<= GetAs< NumericField >()->IsUseThousandSep(); break; case BASEPROPERTY_UNIT: - aProp <<= (sal_uInt16) (static_cast<MetricField*>(GetWindow())->GetUnit()); + aProp <<= (sal_uInt16) (GetAs< MetricField >()->GetUnit()); break; case BASEPROPERTY_CUSTOMUNITTEXT: - aProp <<= OUString( static_cast<MetricField*>(GetWindow())->GetCustomUnitText() ); + aProp <<= OUString( GetAs< MetricField >()->GetCustomUnitText() ); break; default: { @@ -6095,7 +6063,7 @@ void VCLXCurrencyField::setValue( double Value ) throw(::com::sun::star::uno::Ru ImplCalcLongValue( Value, pCurrencyFormatter->GetDecimalDigits() ) ); // #107218# Call same listeners like VCL would do after user interaction - Edit* pEdit = static_cast<Edit*>(GetWindow()); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { SetSynthesizingVCLEvent( true ); @@ -6160,7 +6128,7 @@ void VCLXCurrencyField::setFirst( double Value ) throw(::com::sun::star::uno::Ru { SolarMutexGuard aGuard; - LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow()); + VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >(); if ( pCurrencyField ) pCurrencyField->SetFirst( ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) ); @@ -6170,7 +6138,7 @@ double VCLXCurrencyField::getFirst() throw(::com::sun::star::uno::RuntimeExcepti { SolarMutexGuard aGuard; - LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow()); + VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >(); return pCurrencyField ? ImplCalcDoubleValue( (double)pCurrencyField->GetFirst(), pCurrencyField->GetDecimalDigits() ) : 0; @@ -6180,7 +6148,7 @@ void VCLXCurrencyField::setLast( double Value ) throw(::com::sun::star::uno::Run { SolarMutexGuard aGuard; - LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow()); + VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >(); if ( pCurrencyField ) pCurrencyField->SetLast( ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) ); @@ -6190,7 +6158,7 @@ double VCLXCurrencyField::getLast() throw(::com::sun::star::uno::RuntimeExceptio { SolarMutexGuard aGuard; - LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow()); + VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >(); return pCurrencyField ? ImplCalcDoubleValue( (double)pCurrencyField->GetLast(), pCurrencyField->GetDecimalDigits() ) : 0; @@ -6200,7 +6168,7 @@ void VCLXCurrencyField::setSpinSize( double Value ) throw(::com::sun::star::uno: { SolarMutexGuard aGuard; - LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow()); + VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >(); if ( pCurrencyField ) pCurrencyField->SetSpinSize( ImplCalcLongValue( Value, pCurrencyField->GetDecimalDigits() ) ); @@ -6210,7 +6178,7 @@ double VCLXCurrencyField::getSpinSize() throw(::com::sun::star::uno::RuntimeExce { SolarMutexGuard aGuard; - LongCurrencyField* pCurrencyField = static_cast<LongCurrencyField*>(GetWindow()); + VclPtr< LongCurrencyField > pCurrencyField = GetAs< LongCurrencyField >(); return pCurrencyField ? ImplCalcDoubleValue( (double)pCurrencyField->GetSpinSize(), pCurrencyField->GetDecimalDigits() ) : 0; @@ -6263,8 +6231,8 @@ void VCLXCurrencyField::setProperty( const OUString& PropertyName, const ::com:: { if ( bVoid ) { - static_cast<LongCurrencyField*>(GetWindow())->EnableEmptyFieldValue( true ); - static_cast<LongCurrencyField*>(GetWindow())->SetEmptyFieldValue(); + GetAs< LongCurrencyField >()->EnableEmptyFieldValue( true ); + GetAs< LongCurrencyField >()->SetEmptyFieldValue(); } else { @@ -6306,14 +6274,14 @@ void VCLXCurrencyField::setProperty( const OUString& PropertyName, const ::com:: { OUString aString; if ( Value >>= aString ) - static_cast<LongCurrencyField*>(GetWindow())->SetCurrencySymbol( aString ); + GetAs< LongCurrencyField >()->SetCurrencySymbol( aString ); } break; case BASEPROPERTY_NUMSHOWTHOUSANDSEP: { bool b = bool(); if ( Value >>= b ) - static_cast<LongCurrencyField*>(GetWindow())->SetUseThousandSep( b ); + GetAs< LongCurrencyField >()->SetUseThousandSep( b ); } break; default: @@ -6357,12 +6325,12 @@ void VCLXCurrencyField::setProperty( const OUString& PropertyName, const ::com:: break; case BASEPROPERTY_CURRENCYSYMBOL: { - aProp <<= OUString( static_cast<LongCurrencyField*>(GetWindow())->GetCurrencySymbol() ); + aProp <<= OUString( GetAs< LongCurrencyField >()->GetCurrencySymbol() ); } break; case BASEPROPERTY_NUMSHOWTHOUSANDSEP: { - aProp <<= static_cast<LongCurrencyField*>(GetWindow())->IsUseThousandSep(); + aProp <<= GetAs< LongCurrencyField >()->IsUseThousandSep(); } break; default: @@ -6434,7 +6402,7 @@ void VCLXPatternField::setMasks( const OUString& EditMask, const OUString& Liter { SolarMutexGuard aGuard; - PatternField* pPatternField = static_cast<PatternField*>(GetWindow()); + VclPtr< PatternField > pPatternField = GetAs< PatternField >(); if ( pPatternField ) { pPatternField->SetMask( OUStringToOString(EditMask, RTL_TEXTENCODING_ASCII_US), LiteralMask ); @@ -6445,7 +6413,7 @@ void VCLXPatternField::getMasks( OUString& EditMask, OUString& LiteralMask ) thr { SolarMutexGuard aGuard; - PatternField* pPatternField = static_cast<PatternField*>(GetWindow()); + VclPtr< PatternField > pPatternField = GetAs< PatternField >(); if ( pPatternField ) { EditMask = OStringToOUString(pPatternField->GetEditMask(), RTL_TEXTENCODING_ASCII_US); @@ -6456,12 +6424,9 @@ void VCLXPatternField::getMasks( OUString& EditMask, OUString& LiteralMask ) thr void VCLXPatternField::setString( const OUString& Str ) throw(::com::sun::star::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - - PatternField* pPatternField = static_cast<PatternField*>(GetWindow()); + VclPtr< PatternField > pPatternField = GetAs< PatternField >(); if ( pPatternField ) - { pPatternField->SetString( Str ); - } } OUString VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeException, std::exception) @@ -6469,7 +6434,7 @@ OUString VCLXPatternField::getString() throw(::com::sun::star::uno::RuntimeExcep SolarMutexGuard aGuard; OUString aString; - PatternField* pPatternField = static_cast<PatternField*>(GetWindow()); + VclPtr< PatternField > pPatternField = GetAs< PatternField >(); if ( pPatternField ) aString = pPatternField->GetString(); return aString; @@ -6608,7 +6573,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 ) { diff --git a/toolkit/source/controls/accessiblecontrolcontext.cxx b/toolkit/source/controls/accessiblecontrolcontext.cxx index d8084d46832e..bf8f38065672 100644 --- a/toolkit/source/controls/accessiblecontrolcontext.cxx +++ b/toolkit/source/controls/accessiblecontrolcontext.cxx @@ -225,17 +225,18 @@ namespace toolkit } - vcl::Window* OAccessibleControlContext::implGetWindow( Reference< awt::XWindow >* _pxUNOWindow ) const + VclPtr< vcl::Window > OAccessibleControlContext::implGetWindow( Reference< awt::XWindow >* _pxUNOWindow ) const { Reference< awt::XControl > xControl( getAccessibleCreator(), UNO_QUERY ); Reference< awt::XWindow > xWindow; if ( xControl.is() ) xWindow.set(xControl->getPeer(), css::uno::UNO_QUERY); - vcl::Window* pWindow = xWindow.is() ? VCLUnoHelper::GetWindow( xWindow ) : NULL; + VclPtr< vcl::Window > pWindow = xWindow.is() ? VCLUnoHelper::GetWindow( xWindow ) : VclPtr< vcl::Window >(); if ( _pxUNOWindow ) *_pxUNOWindow = xWindow; + return pWindow; } @@ -259,7 +260,7 @@ namespace toolkit // our control Reference< awt::XWindow > xWindow; - vcl::Window* pVCLWindow = implGetWindow( &xWindow ); + VclPtr< vcl::Window > pVCLWindow = implGetWindow( &xWindow ); awt::Rectangle aBounds( 0, 0, 0, 0 ); if ( xWindow.is() ) @@ -319,7 +320,7 @@ namespace toolkit // want to do some VCL stuff here ... OContextEntryGuard aGuard( this ); - vcl::Window* pWindow = implGetWindow( ); + VclPtr< vcl::Window > pWindow = implGetWindow(); sal_Int32 nColor = 0; if ( pWindow ) { @@ -345,7 +346,7 @@ namespace toolkit // want to do some VCL stuff here ... OContextEntryGuard aGuard( this ); - vcl::Window* pWindow = implGetWindow( ); + VclPtr< vcl::Window > pWindow = implGetWindow(); sal_Int32 nColor = 0; if ( pWindow ) { diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx index 3681847a26f9..56b620c62a77 100644 --- a/toolkit/source/helper/unowrapper.cxx +++ b/toolkit/source/helper/unowrapper.cxx @@ -219,13 +219,13 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) { // their still might be some children created with ::com::sun::star::loader::Java // that would otherwise not be destroyed until the garbage collector cleans up - vcl::Window* pChild = pWindow->GetWindow( WINDOW_FIRSTCHILD ); + VclPtr< vcl::Window > pChild = pWindow->GetWindow( WINDOW_FIRSTCHILD ); while ( pChild ) { - vcl::Window* pNextChild = pChild->GetWindow( WINDOW_NEXT ); + VclPtr< vcl::Window > pNextChild = pChild->GetWindow( WINDOW_NEXT ); - vcl::Window* pClient = pChild->GetWindow( WINDOW_CLIENT ); - if ( pClient->GetWindowPeer() ) + VclPtr< vcl::Window > pClient = pChild->GetWindow( WINDOW_CLIENT ); + if ( pClient && pClient->GetWindowPeer() ) { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( false ), ::com::sun::star::uno::UNO_QUERY ); xComp->dispose(); @@ -235,16 +235,16 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) } // System-Windows suchen... - vcl::Window* pOverlap = pWindow->GetWindow( WINDOW_OVERLAP ); + VclPtr< vcl::Window > pOverlap = pWindow->GetWindow( WINDOW_OVERLAP ); if ( pOverlap ) { pOverlap = pOverlap->GetWindow( WINDOW_FIRSTOVERLAP ); while ( pOverlap ) { - vcl::Window* pNextOverlap = pOverlap->GetWindow( WINDOW_NEXT ); - vcl::Window* pClient = pOverlap->GetWindow( WINDOW_CLIENT ); + VclPtr< vcl::Window > pNextOverlap = pOverlap->GetWindow( WINDOW_NEXT ); + VclPtr< vcl::Window > pClient = pOverlap->GetWindow( WINDOW_CLIENT ); - if ( pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) ) + if ( pClient && pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) ) { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( false ), ::com::sun::star::uno::UNO_QUERY ); xComp->dispose(); @@ -254,9 +254,11 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) } } - vcl::Window* pParent = pWindow->GetParent(); - if ( pParent && pParent->GetWindowPeer() ) - pParent->GetWindowPeer()->notifyWindowRemoved( *pWindow ); + { + VclPtr< vcl::Window > pParent = pWindow->GetParent(); + if ( pParent && pParent->GetWindowPeer() ) + pParent->GetWindowPeer()->notifyWindowRemoved( *pWindow ); + } VCLXWindow* pWindowPeer = pWindow->GetWindowPeer(); uno::Reference< lang::XComponent > xWindowPeerComp( pWindow->GetComponentInterface( false ), uno::UNO_QUERY ); @@ -276,13 +278,13 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) // #i42462#/#116855# no, don't loop: Instead, just ensure that all our top-window-children // are disposed, too (which should also be a valid fix for #102132#, but doesn't have the extreme // performance penalties) - vcl::Window* pTopWindowChild = pWindow->GetWindow( WINDOW_FIRSTTOPWINDOWCHILD ); + VclPtr< vcl::Window > pTopWindowChild = pWindow->GetWindow( WINDOW_FIRSTTOPWINDOWCHILD ); while ( pTopWindowChild ) { OSL_ENSURE( pTopWindowChild->GetParent() == pWindow, "UnoWrapper::WindowDestroyed: inconsistency in the SystemWindow relationship!" ); - vcl::Window* pNextTopChild = pTopWindowChild->GetWindow( WINDOW_NEXTTOPWINDOWSIBLING ); + VclPtr< vcl::Window > pNextTopChild = pTopWindowChild->GetWindow( WINDOW_NEXTTOPWINDOWSIBLING ); //the window still could be on the stack, so we have to // use lazy delete ( it will automatically diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx index 7b80bc7a26e6..005caccf8871 100644 --- a/toolkit/source/helper/vclunohelper.cxx +++ b/toolkit/source/helper/vclunohelper.cxx @@ -108,22 +108,22 @@ BitmapEx VCLUnoHelper::GetBitmap( const ::com::sun::star::uno::Reference< ::com: return xBmp; } -vcl::Window* VCLUnoHelper::GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>& rxWindow ) +VclPtr< vcl::Window > VCLUnoHelper::GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>& rxWindow ) { VCLXWindow* pVCLXWindow = VCLXWindow::GetImplementation( rxWindow ); - return pVCLXWindow ? pVCLXWindow->GetWindow() : NULL; + return pVCLXWindow ? pVCLXWindow->GetWindow() : VclPtr< vcl::Window >(); } -vcl::Window* VCLUnoHelper::GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow2>& rxWindow ) +VclPtr< vcl::Window > VCLUnoHelper::GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow2>& rxWindow ) { VCLXWindow* pVCLXWindow = VCLXWindow::GetImplementation( rxWindow ); - return pVCLXWindow ? pVCLXWindow->GetWindow() : NULL; + return pVCLXWindow ? pVCLXWindow->GetWindow() : VclPtr< vcl::Window >(); } -vcl::Window* VCLUnoHelper::GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& rxWindow ) +VclPtr< vcl::Window > VCLUnoHelper::GetWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& rxWindow ) { VCLXWindow* pVCLXWindow = VCLXWindow::GetImplementation( rxWindow ); - return pVCLXWindow ? pVCLXWindow->GetWindow() : NULL; + return pVCLXWindow ? pVCLXWindow->GetWindow() : VclPtr< vcl::Window >(); } vcl::Region VCLUnoHelper::GetRegion( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XRegion >& rxRegion ) |