@@ -57,7 +57,7 @@ ProgressMonitor::ProgressMonitor( const css::uno::Reference< XComponentContext > m_xTopic_Bottom = css::uno::Reference< XFixedText > ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); m_xText_Bottom = css::uno::Reference< XFixedText > ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); m_xButton = css::uno::Reference< XButton > ( rxContext->getServiceManager()->createInstanceWithContext( BUTTON_SERVICENAME, rxContext ), UNO_QUERY ); - m_xProgressBar = new ProgressBar(rxContext); + m_xProgressBar = VclPtr<ProgressBar>::Create(rxContext); // ... cast controls to Reference< XControl > (for "setModel"!) ... css::uno::Reference< XControl > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ); @@ -47,7 +47,7 @@ StatusIndicator::StatusIndicator( const css::uno::Reference< XComponentContext > // Create instances for fixedtext and progress ... m_xText = css::uno::Reference< XFixedText > ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); - m_xProgressBar = new ProgressBar(rxContext); + m_xProgressBar = VclPtr<ProgressBar>::Create(rxContext); // ... cast controls to css::uno::Reference< XControl > and set model ... // ( ProgressBar has no model !!! ) css::uno::Reference< XControl > xTextControl ( m_xText , UNO_QUERY ); @@ -23,6 +23,8 @@ #include <com/sun/star/lang/XServiceName.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <vcl/vclptr.hxx> + #include "basecontrol.hxx" // namespaces @@ -30,11 +30,8 @@ class SvtIconChoiceCtrl; - namespace accessibility { - - typedef ::cppu::ImplHelper2< ::com::sun::star::accessibility::XAccessible , ::com::sun::star::accessibility::XAccessibleSelection> AccessibleIconChoiceCtrl_BASE; @@ -55,7 +52,8 @@ namespace accessibility virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) SAL_OVERRIDE; virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) SAL_OVERRIDE; - SvtIconChoiceCtrl* getCtrl(); + VclPtr< SvtIconChoiceCtrl > getCtrl(); + public: /** OAccessibleBase needs a valid view @param _rIconCtrl @@ -35,6 +35,7 @@ #include <comphelper/broadcasthelper.hxx> #include <comphelper/accessibletexthelper.hxx> #include <tools/gen.hxx> +#include <vcl/vclptr.hxx> // forward @@ -63,7 +64,7 @@ namespace accessibility { private: /** The treelistbox control */ - SvtIconChoiceCtrl* m_pIconCtrl; + VclPtr<SvtIconChoiceCtrl> m_pIconCtrl; sal_Int32 m_nIndex; protected: @@ -62,7 +62,7 @@ namespace accessibility virtual void ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent ) SAL_OVERRIDE; virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) SAL_OVERRIDE; - SvTreeListBox* getListBox() const; + VclPtr< SvTreeListBox > getListBox() const; void RemoveChildEntries(SvTreeListEntry*); @@ -22,6 +22,7 @@ #include <comphelper/accessiblecomponenthelper.hxx> #include <tools/link.hxx> +#include <vcl/vclptr.hxx> class TabBar; class VCLExternalSolarLock; @@ -57,7 +58,7 @@ private: protected: VCLExternalSolarLock* m_pExternalLock; - TabBar* m_pTabBar; + VclPtr<TabBar> m_pTabBar; }; @@ -43,7 +43,7 @@ class AccessibleTabListBox ,public ::svt::IAccessibleTabListBox { private: - SvHeaderTabListBox* m_pTabListBox; + VclPtr<SvHeaderTabListBox> m_pTabListBox; public: /** ctor() @@ -37,7 +37,7 @@ typedef ::cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessibleSelecti class AccessibleTabListBoxTable : public AccessibleBrowseBoxTable, public AccessibleTabListBoxTableImplHelper { private: - SvHeaderTabListBox* m_pTabListBox; + VclPtr<SvHeaderTabListBox> m_pTabListBox; ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xCurChild; @@ -22,6 +22,7 @@ #include <com/sun/star/uno/RuntimeException.hpp> #include <tools/link.hxx> +#include <vcl/vclptr.hxx> class SvTreeListBox; class VclSimpleEvent; @@ -41,7 +42,7 @@ namespace accessibility class ListBoxAccessibleBase { private: - SvTreeListBox* m_pWindow; + VclPtr<SvTreeListBox> m_pWindow; protected: inline SvTreeListBox* getListBox() const @@ -49,7 +50,7 @@ namespace accessibility return const_cast< ListBoxAccessibleBase* >( this )->m_pWindow; } - inline bool isAlive() const { return NULL != m_pWindow; } + inline bool isAlive() const { return nullptr != m_pWindow; } public: ListBoxAccessibleBase( SvTreeListBox& _rWindow ); @@ -99,7 +99,7 @@ public: private: ::Link m_aListener; - vcl::Window * m_pNotifier; + VclPtr<vcl::Window> m_pNotifier; }; class ParagraphInfo @@ -21,6 +21,7 @@ #define INCLUDED_ACCESSIBILITY_INC_ACCESSIBILITY_STANDARD_VCLXACCESSIBLEMENUBAR_HXX #include <accessibility/standard/accessiblemenucomponent.hxx> +#include <vcl/vclptr.hxx> class VclSimpleEvent; class VclWindowEvent; @@ -34,7 +35,7 @@ namespace vcl { class Window; } class VCLXAccessibleMenuBar : public OAccessibleMenuComponent { protected: - vcl::Window* m_pWindow; + VclPtr<vcl::Window> m_pWindow; virtual bool IsFocused() SAL_OVERRIDE; @@ -21,6 +21,7 @@ #define INCLUDED_ACCESSIBILITY_INC_ACCESSIBILITY_STANDARD_VCLXACCESSIBLESTATUSBAR_HXX #include <toolkit/awt/vclxaccessiblecomponent.hxx> +#include <vcl/vclptr.hxx> #include <vector> @@ -36,7 +37,7 @@ private: typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > AccessibleChildren; AccessibleChildren m_aAccessibleChildren; - StatusBar* m_pStatusBar; + VclPtr<StatusBar> m_pStatusBar; protected: void UpdateShowing( sal_Int32 i, bool bShowing ); @@ -24,7 +24,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <comphelper/accessibletexthelper.hxx> #include <cppuhelper/implbase2.hxx> - +#include <vcl/vclptr.hxx> class StatusBar; class VCLExternalSolarLock; @@ -51,14 +51,14 @@ class VCLXAccessibleStatusBarItem : public AccessibleTextHelper_BASE, private: VCLExternalSolarLock* m_pExternalLock; - StatusBar* m_pStatusBar; + VclPtr<StatusBar> m_pStatusBar; sal_uInt16 m_nItemId; OUString m_sItemName; OUString m_sItemText; - bool m_bShowing; + bool m_bShowing; protected: - bool IsShowing(); + bool IsShowing(); void SetShowing( bool bShowing ); void SetItemName( const OUString& sItemName ); OUString GetItemName(); @@ -22,6 +22,7 @@ #include <toolkit/awt/vclxaccessiblecomponent.hxx> #include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <vcl/vclptr.hxx> #include <vector> @@ -42,7 +43,7 @@ private: typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > AccessibleChildren; AccessibleChildren m_aAccessibleChildren; - TabControl* m_pTabControl; + VclPtr<TabControl> m_pTabControl; protected: void UpdateFocused(); @@ -24,6 +24,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <comphelper/accessibletexthelper.hxx> #include <cppuhelper/implbase2.hxx> +#include <vcl/vclptr.hxx> class TabControl; @@ -51,7 +52,7 @@ class VCLXAccessibleTabPage : public AccessibleTextHelper_BASE, private: VCLExternalSolarLock* m_pExternalLock; - TabControl* m_pTabControl; + VclPtr<TabControl> m_pTabControl; sal_uInt16 m_nPageId; bool m_bFocused; bool m_bSelected; @@ -21,6 +21,7 @@ #define INCLUDED_ACCESSIBILITY_INC_ACCESSIBILITY_STANDARD_VCLXACCESSIBLETABPAGEWINDOW_HXX #include <toolkit/awt/vclxaccessiblecomponent.hxx> +#include <vcl/vclptr.hxx> class TabControl; @@ -34,8 +35,8 @@ class TabPage; class VCLXAccessibleTabPageWindow : public VCLXAccessibleComponent { private: - TabControl* m_pTabControl; - TabPage* m_pTabPage; + VclPtr<TabControl> m_pTabControl; + VclPtr<TabPage> m_pTabPage; sal_uInt16 m_nPageId; protected: @@ -30,6 +30,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/implbase4.hxx> #include <comphelper/accessibletexthelper.hxx> +#include <vcl/vclptr.hxx> class ToolBox; @@ -46,13 +47,13 @@ class VCLXAccessibleToolBoxItem : public AccessibleTextHelper_BASE, { private: OUString m_sOldName; - ToolBox* m_pToolBox; + VclPtr<ToolBox> m_pToolBox; VCLExternalSolarLock* m_pExternalLock; sal_Int32 m_nIndexInParent; sal_Int16 m_nRole; - sal_uInt16 m_nItemId; - bool m_bHasFocus; - bool m_bIsChecked; + sal_uInt16 m_nItemId; + bool m_bHasFocus; + bool m_bIsChecked; bool m_bIndeterminate; ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xChild; @@ -80,9 +81,9 @@ public: VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_Int32 _nPos ); void SetFocus( bool _bFocus ); - inline bool HasFocus() const { return m_bHasFocus; } + inline bool HasFocus() const { return m_bHasFocus; } void SetChecked( bool _bCheck ); - inline bool IsChecked() const { return m_bIsChecked; } + inline bool IsChecked() const { return m_bIsChecked; } void SetIndeterminate( bool _bIndeterminate ); inline bool IsIndeterminate() const { return m_bIndeterminate; } inline void ReleaseToolBox() { m_pToolBox = NULL; } @@ -76,7 +76,7 @@ namespace accessibility ); void checkDisposed(); - bool isDisposed() const { return m_pPanelDeck == NULL; } + bool isDisposed() const { return m_pPanelDeck == nullptr; } void dispose(); virtual ~AccessibleToolPanelDeck_Impl(); @@ -95,7 +95,7 @@ namespace accessibility public: AccessibleToolPanelDeck& m_rAntiImpl; Reference< XAccessible > m_xAccessibleParent; - ::svt::ToolPanelDeck* m_pPanelDeck; + VclPtr<::svt::ToolPanelDeck> m_pPanelDeck; Reference< XAccessible > m_xActivePanelAccessible; }; @@ -141,7 +141,7 @@ namespace accessibility { ENSURE_OR_RETURN_VOID( !isDisposed(), "disposed twice" ); m_pPanelDeck->RemoveListener( *this ); - m_pPanelDeck = NULL; + m_pPanelDeck.clear(); m_xAccessibleParent.clear(); } @@ -120,7 +120,7 @@ namespace accessibility AccessibleToolPanelTabBar& m_rAntiImpl; Reference< XAccessible > m_xAccessibleParent; ::svt::IToolPanelDeck* m_pPanelDeck; - ::svt::PanelTabBar* m_pTabBar; + VclPtr<::svt::PanelTabBar> m_pTabBar; ::std::vector< Reference< XAccessible > > m_aChildren; }; @@ -163,7 +163,7 @@ namespace accessibility m_pTabBar->GetScrollButton( true ).RemoveEventListener( LINK( this, AccessibleToolPanelTabBar_Impl, OnWindowEvent ) ); m_pTabBar->GetScrollButton( false ).RemoveEventListener( LINK( this, AccessibleToolPanelTabBar_Impl, OnWindowEvent ) ); - m_pTabBar = NULL; + m_pTabBar.clear(); m_xAccessibleParent.clear(); } @@ -105,7 +105,7 @@ namespace accessibility AccessibleToolPanelDeckTabBarItem& m_rAntiImpl; Reference< XAccessible > m_xAccessibleParent; ::svt::IToolPanelDeck* m_pPanelDeck; - ::svt::PanelTabBar* m_pTabBar; + VclPtr<::svt::PanelTabBar> m_pTabBar; size_t m_nItemPos; }; @@ -139,7 +139,7 @@ namespace accessibility m_xAccessibleParent.clear(); m_pPanelDeck->RemoveListener( *this ); m_pPanelDeck = NULL; - m_pTabBar = NULL; + m_pTabBar.clear(); } Reference< XAccessibleComponent > AccessibleToolPanelDeckTabBarItem_Impl::getParentAccessibleComponent() const @@ -367,12 +367,11 @@ namespace accessibility } } - SvtIconChoiceCtrl* AccessibleIconChoiceCtrl::getCtrl() + VclPtr< SvtIconChoiceCtrl > AccessibleIconChoiceCtrl::getCtrl() { - return static_cast<SvtIconChoiceCtrl*>(GetWindow()); + return GetAs<SvtIconChoiceCtrl >(); } - }// namespace accessibility @@ -91,7 +91,7 @@ throw(RuntimeException, std::exception) if ( _rSource.Source == m_xParent ) { dispose(); - OSL_ENSURE( !m_xParent.is() && ( NULL == m_pIconCtrl ), "" ); + OSL_ENSURE( !m_xParent.is() && ( nullptr == m_pIconCtrl ), "" ); } } @@ -67,11 +67,6 @@ namespace accessibility IMPLEMENT_FORWARD_XINTERFACE2(AccessibleListBox, VCLXAccessibleComponent, AccessibleListBox_BASE) IMPLEMENT_FORWARD_XTYPEPROVIDER2(AccessibleListBox, VCLXAccessibleComponent, AccessibleListBox_BASE) - SvTreeListBox* AccessibleListBox::getListBox() const - { - return static_cast< SvTreeListBox* >( GetWindow() ); - } - void AccessibleListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { if ( isAlive() ) @@ -592,7 +587,10 @@ namespace accessibility } } - + VclPtr< SvTreeListBox > AccessibleListBox::getListBox() const + { + return GetAs< SvTreeListBox >(); + } }// namespace accessibility @@ -47,17 +47,17 @@ void SfxListenerGuard::endListening() void WindowListenerGuard::startListening(vcl::Window & rNotifier) { - OSL_ENSURE(m_pNotifier == 0, "called more than once"); + OSL_ENSURE(m_pNotifier == nullptr, "called more than once"); m_pNotifier = &rNotifier; m_pNotifier->AddEventListener(m_aListener); } void WindowListenerGuard::endListening() { - if (m_pNotifier != 0) + if (m_pNotifier) { m_pNotifier->RemoveEventListener(m_aListener); - m_pNotifier = 0; + m_pNotifier = nullptr; } } @@ -257,7 +257,7 @@ Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLX Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXListBox* _pXWindow ) { bool bIsDropDownBox = false; - ListBox* pBox = static_cast< ListBox* >( _pXWindow->GetWindow() ); + VclPtr< ListBox > pBox = _pXWindow->GetAs< ListBox >(); if ( pBox ) bIsDropDownBox = ( ( pBox->GetStyle() & WB_DROPDOWN ) == WB_DROPDOWN ); @@ -290,7 +290,7 @@ Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLX Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXComboBox* _pXWindow ) { bool bIsDropDownBox = false; - ComboBox* pBox = static_cast< ComboBox* >( _pXWindow->GetWindow() ); + VclPtr< ComboBox > pBox = _pXWindow->GetAs< ComboBox >(); if ( pBox ) bIsDropDownBox = ( ( pBox->GetStyle() & WB_DROPDOWN ) == WB_DROPDOWN ); @@ -75,8 +75,8 @@ void VCLXAccessibleBox::ProcessWindowChildEvent( const VclWindowEvent& rVclWindo // be removed in a short time. if (m_aBoxType==COMBOBOX) { - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); - if ( ( pComboBox != NULL ) && ( pChildWindow != NULL ) ) + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); + if ( ( pComboBox != nullptr ) && ( pChildWindow != NULL ) ) if (pChildWindow == pComboBox->GetSubEdit()) { if (rVclWindowEvent.GetId() == VCLEVENT_WINDOW_SHOW) @@ -327,8 +327,8 @@ Reference<XAccessible> SAL_CALL VCLXAccessibleBox::getAccessibleChild (sal_Int32 { if (m_aBoxType==COMBOBOX) { - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); - if (pComboBox!=NULL && pComboBox->GetSubEdit()!=NULL) + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); + if (pComboBox!=nullptr && pComboBox->GetSubEdit()!=NULL) //Set the edit's acc name the same as parent { pComboBox->GetSubEdit()->SetAccessibleName(getAccessibleName()); @@ -398,8 +398,8 @@ sal_Bool SAL_CALL VCLXAccessibleBox::doAccessibleAction (sal_Int32 nIndex) if (m_aBoxType == COMBOBOX) { - ComboBox* pComboBox = static_cast< ComboBox* >( GetWindow() ); - if (pComboBox != NULL) + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); + if (pComboBox != nullptr) { pComboBox->ToggleDropDown(); bNotify = true; @@ -407,8 +407,8 @@ sal_Bool SAL_CALL VCLXAccessibleBox::doAccessibleAction (sal_Int32 nIndex) } else if (m_aBoxType == LISTBOX) { - ListBox* pListBox = static_cast< ListBox* >( GetWindow() ); - if (pListBox != NULL) + VclPtr< ListBox > pListBox = GetAs< ListBox >(); + if (pListBox != nullptr) { pListBox->ToggleDropDown(); bNotify = true; @@ -532,8 +532,8 @@ void VCLXAccessibleBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& r { OUString sText; sal_Int32 nEntryCount = 0; - ComboBox* pComboBox = static_cast<ComboBox*>(GetWindow()); - if (pComboBox != NULL) + VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); + if (pComboBox != nullptr) { Edit* pSubEdit = pComboBox->GetSubEdit(); if ( pSubEdit) @@ -546,8 +546,8 @@ void VCLXAccessibleBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& r else if (m_aBoxType == LISTBOX && m_bIsDropDownBox) { sal_Int32 nSelectedEntryCount = 0; - ListBox* pListBox = static_cast< ListBox* >( GetWindow() ); - if (pListBox != NULL && pListBox->GetEntryCount() > 0) + VclPtr< ListBox > pListBox = GetAs< ListBox >(); + if (pListBox != nullptr && pListBox->GetEntryCount() > 0) { nSelectedEntryCount = pListBox->GetSelectEntryCount(); if ( nSelectedEntryCount == 0) @@ -65,7 +65,7 @@ void VCLXAccessibleButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowE Any aOldValue; Any aNewValue; - PushButton* pButton = static_cast<PushButton*>( GetWindow() ); + VclPtr< PushButton > pButton = GetAs< PushButton >(); if ( pButton && pButton->GetState() == TRISTATE_TRUE ) aNewValue <<= AccessibleStateType::CHECKED; else @@ -85,7 +85,7 @@ void VCLXAccessibleButton::FillAccessibleStateSet( utl::AccessibleStateSetHelper { VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet ); - PushButton* pButton = static_cast<PushButton*>( GetWindow() ); + VclPtr< PushButton > pButton = GetAs< PushButton >(); if ( pButton ) { rStateSet.AddState( AccessibleStateType::FOCUSABLE ); @@ -196,7 +196,7 @@ sal_Bool VCLXAccessibleButton::doAccessibleAction ( sal_Int32 nIndex ) throw (In if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) throw IndexOutOfBoundsException(); - PushButton* pButton = static_cast<PushButton*>( GetWindow() ); + VclPtr< PushButton > pButton = GetAs< PushButton >(); if ( pButton ) pButton->Click(); @@ -264,7 +264,7 @@ Any VCLXAccessibleButton::getCurrentValue( ) throw (RuntimeException, std::exce Any aValue; - PushButton* pButton = static_cast<PushButton*>( GetWindow() ); + VclPtr< PushButton > pButton = GetAs< PushButton >(); if ( pButton ) aValue <<= (sal_Int32) pButton->IsPressed(); @@ -279,7 +279,7 @@ sal_Bool VCLXAccessibleButton::setCurrentValue( const Any& aNumber ) throw (Runt bool bReturn = false; - PushButton* pButton = static_cast<PushButton*>( GetWindow() ); + VclPtr< PushButton > pButton = GetAs< PushButton >(); if ( pButton ) { sal_Int32 nValue = 0; @@ -198,7 +198,7 @@ sal_Bool VCLXAccessibleCheckBox::doAccessibleAction ( sal_Int32 nIndex ) throw ( if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) throw IndexOutOfBoundsException(); - CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow()); + VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >(); VCLXCheckBox* pVCLXCheckBox = static_cast< VCLXCheckBox* >( GetVCLXWindow() ); if ( pCheckBox && pVCLXCheckBox ) { @@ -328,7 +328,7 @@ Any VCLXAccessibleCheckBox::getMaximumValue( ) throw (RuntimeException, std::ex Any aValue; - CheckBox* pCheckBox = static_cast<CheckBox*>(GetWindow()); + VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >(); if ( pCheckBox && pCheckBox->IsTriStateEnabled() ) aValue <<= (sal_Int32) 2; else @@ -43,18 +43,11 @@ VCLXAccessibleComboBox::~VCLXAccessibleComboBox() { } - - - bool VCLXAccessibleComboBox::IsValid() const { - return static_cast<ComboBox*>(GetWindow()) != NULL; - + return GetWindow().get() != NULL; } - - - void VCLXAccessibleComboBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent) { VCLXAccessibleBox::ProcessWindowEvent( rVclWindowEvent ); @@ -57,17 +57,11 @@ VCLXAccessibleDropDownComboBox::~VCLXAccessibleDropDownComboBox() { } - - bool VCLXAccessibleDropDownComboBox::IsValid() const { - return static_cast<ComboBox*>(GetWindow()) != NULL; - + return GetWindow().get() != NULL; } - - - void VCLXAccessibleDropDownComboBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent) { switch ( rVclWindowEvent.GetId() ) @@ -56,18 +56,11 @@ VCLXAccessibleDropDownListBox::~VCLXAccessibleDropDownListBox() { } - - - bool VCLXAccessibleDropDownListBox::IsValid() const { - return static_cast<ListBox*>(GetWindow()) != NULL; - + return GetWindow().get() != NULL; } - - - void VCLXAccessibleDropDownListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { VCLXAccessibleBox::ProcessWindowEvent (rVclWindowEvent); @@ -133,7 +133,7 @@ OUString VCLXAccessibleEdit::implGetText() { OUString aText; - Edit* pEdit = static_cast< Edit* >( GetWindow() ); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit ) { aText = OutputDevice::GetNonMnemonicString( pEdit->GetText() ); @@ -225,7 +225,7 @@ sal_Int16 VCLXAccessibleEdit::getAccessibleRole( ) throw (RuntimeException, std OExternalLockGuard aGuard( this ); sal_Int16 nRole; - Edit* pEdit = static_cast< Edit* >( GetWindow() ); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pEdit && ( ( pEdit->GetStyle() & WB_PASSWORD ) || pEdit->GetEchoChar() ) ) nRole = AccessibleRole::PASSWORD_TEXT; else @@ -336,7 +336,7 @@ awt::Rectangle VCLXAccessibleEdit::getCharacterBounds( sal_Int32 nIndex ) throw if ( !implIsValidRange( nIndex, nIndex, nLength ) ) throw IndexOutOfBoundsException(); - Control* pControl = static_cast< Control* >( GetWindow() ); + VclPtr< Control > pControl = GetAs< Control >(); if ( pControl ) { if ( nIndex == nLength ) @@ -425,7 +425,7 @@ sal_Bool VCLXAccessibleEdit::setSelection( sal_Int32 nStartIndex, sal_Int32 nEnd throw IndexOutOfBoundsException(); VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() ); - Edit* pEdit = static_cast< Edit* >( GetWindow() ); + VclPtr< Edit > pEdit = GetAs< Edit >(); if ( pVCLXEdit && pEdit && pEdit->IsEnabled() ) { pVCLXEdit->setSelection( awt::Selection( nStartIndex, nEndIndex ) ); @@ -72,16 +72,16 @@ VCLXAccessibleList::VCLXAccessibleList (VCLXWindow* pVCLWindow, BoxType aBoxType { case COMBOBOX: { - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); - if ( pBox != NULL ) + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); + if ( pBox ) m_pListBoxHelper = new VCLListBoxHelper<ComboBox> (*pBox); break; } case LISTBOX: { - ListBox* pBox = static_cast<ListBox*>(GetWindow()); - if ( pBox != NULL ) + VclPtr< ListBox > pBox = GetAs< ListBox >(); + if ( pBox ) m_pListBoxHelper = new VCLListBoxHelper<ListBox> (*pBox); break; } @@ -189,8 +189,8 @@ void VCLXAccessibleList::UpdateSelection_Acc (const ::rtl::OUString& sTextOfSele { if ( m_aBoxType == COMBOBOX ) { - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); - if ( pBox != NULL ) + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); + if ( pBox ) { // Find the index of the selected item inside the VCL control... sal_Int32 nIndex = pBox->GetEntryPos(sTextOfSelectedItem); @@ -458,7 +458,7 @@ void VCLXAccessibleList::ProcessWindowEvent (const VclWindowEvent& rVclWindowEve void VCLXAccessibleList::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) { - ListBox* pBox = static_cast<ListBox*>(GetWindow()); + VclPtr< ListBox > pBox = GetAs< ListBox >(); if( m_aBoxType == LISTBOX ) { if (m_pListBoxHelper && (m_pListBoxHelper->GetStyle() & WB_DROPDOWN ) != WB_DROPDOWN) @@ -483,8 +483,8 @@ void VCLXAccessibleList::UpdateSelection (const OUString& sTextOfSelectedItem) { if ( m_aBoxType == COMBOBOX ) { - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); - if ( pBox != NULL ) + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); + if ( pBox ) { // Find the index of the selected item inside the VCL control... sal_Int32 nIndex = pBox->GetEntryPos(sTextOfSelectedItem); @@ -930,7 +930,7 @@ awt::Rectangle VCLXAccessibleList::implGetBounds() throw (uno::RuntimeException) aBounds.Y = 0; if ( m_aBoxType == COMBOBOX ) { - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); if ( pBox ) { Size aSize = pBox->GetSubEdit()->GetSizePixel(); @@ -960,7 +960,7 @@ awt::Point VCLXAccessibleList::getLocationOnScreen( ) throw (uno::RuntimeExcept aPos = VCLXAccessibleComponent::getLocationOnScreen(); if ( m_aBoxType == COMBOBOX ) { - ComboBox* pBox = static_cast<ComboBox*>(GetWindow()); + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); if ( pBox ) { aPos.Y += pBox->GetSubEdit()->GetSizePixel().Height(); @@ -54,26 +54,16 @@ VCLXAccessibleListBox::~VCLXAccessibleListBox() { } - - - bool VCLXAccessibleListBox::IsValid() const { - return static_cast<ListBox*>(GetWindow()) != NULL; - + return GetWindow().get() != NULL; } - - - void VCLXAccessibleListBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent) { VCLXAccessibleBox::ProcessWindowEvent( rVclWindowEvent ); } - - - //===== XServiceInfo ======================================================== OUString VCLXAccessibleListBox::getImplementationName() @@ -90,16 +90,16 @@ void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelati { VCLXAccessibleTextComponent::FillAccessibleRelationSet( rRelationSet ); - RadioButton* pRadioButton = dynamic_cast< RadioButton* >( GetWindow() ); + VclPtr< RadioButton > pRadioButton = GetAsDynamic< RadioButton >(); if ( pRadioButton ) { - ::std::vector< RadioButton* > aGroup(pRadioButton->GetRadioButtonGroup(true)); + ::std::vector< VclPtr<RadioButton> > aGroup(pRadioButton->GetRadioButtonGroup(true)); if (!aGroup.empty()) { sal_Int32 i = 0; Sequence< Reference< XInterface > > aSequence( static_cast< sal_Int32 >( aGroup.size() ) ); - ::std::vector< RadioButton* >::const_iterator aEndItr = aGroup.end(); - for ( ::std::vector< RadioButton* >::const_iterator aItr = aGroup.begin(); aItr < aEndItr; ++aItr ) + auto aEndItr = aGroup.end(); + for ( auto aItr = aGroup.begin(); aItr < aEndItr; ++aItr ) { aSequence[i++] = (*aItr)->GetAccessible(); } @@ -139,7 +139,7 @@ sal_Bool VCLXAccessibleScrollBar::doAccessibleAction ( sal_Int32 nIndex ) throw throw IndexOutOfBoundsException(); bool bReturn = false; - ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() ); + VclPtr< ScrollBar > pScrollBar = GetAs< ScrollBar >(); if ( pScrollBar ) { ScrollType eScrollType; @@ -38,7 +38,7 @@ using namespace ::comphelper; VCLXAccessibleStatusBar::VCLXAccessibleStatusBar( VCLXWindow* pVCLXWindow ) :VCLXAccessibleComponent( pVCLXWindow ) { - m_pStatusBar = static_cast< StatusBar* >( GetWindow() ); + m_pStatusBar = static_cast< StatusBar *>( GetWindow().get() ); if ( m_pStatusBar ) m_aAccessibleChildren.assign( m_pStatusBar->GetItemCount(), Reference< XAccessible >() ); @@ -43,7 +43,7 @@ using namespace ::comphelper; VCLXAccessibleTabControl::VCLXAccessibleTabControl( VCLXWindow* pVCLXWindow ) :VCLXAccessibleComponent( pVCLXWindow ) { - m_pTabControl = static_cast< TabControl* >( GetWindow() ); + m_pTabControl = static_cast< TabControl* >( GetWindow().get() ); if ( m_pTabControl ) m_aAccessibleChildren.assign( m_pTabControl->GetPageCount(), Reference< XAccessible >() ); @@ -36,7 +36,7 @@ using namespace ::comphelper; VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindow ) :VCLXAccessibleComponent( pVCLXWindow ) { - m_pTabPage = static_cast< TabPage* >( GetWindow() ); + m_pTabPage = static_cast< TabPage* >( GetWindow().get() ); m_pTabControl = 0; m_nPageId = 0; if ( m_pTabPage ) @@ -50,7 +50,7 @@ VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindo for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i ) { sal_uInt16 nPageId = m_pTabControl->GetPageId( i ); - if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage ) + if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage.get() ) m_nPageId = nPageId; } } @@ -254,7 +254,7 @@ awt::Rectangle VCLXAccessibleTextComponent::getCharacterBounds( sal_Int32 nIndex throw IndexOutOfBoundsException(); awt::Rectangle aRect; - Control* pControl = static_cast< Control* >( GetWindow() ); + VclPtr< Control > pControl = GetAs< Control >(); if ( pControl ) aRect = AWTRectangle( pControl->GetCharacterBounds( nIndex ) ); @@ -277,7 +277,7 @@ sal_Int32 VCLXAccessibleTextComponent::getIndexAtPoint( const awt::Point& aPoint OExternalLockGuard aGuard( this ); sal_Int32 nIndex = -1; - Control* pControl = static_cast< Control* >( GetWindow() ); + VclPtr< Control > pControl = GetAs< Control >(); if ( pControl ) nIndex = pControl->GetIndexForPoint( VCLPoint( aPoint ) ); @@ -53,22 +53,16 @@ VCLXAccessibleTextField::~VCLXAccessibleTextField() { } - - - OUString VCLXAccessibleTextField::implGetText() { OUString aText; - ListBox* pListBox = static_cast<ListBox*>(GetWindow()); - if (pListBox!=NULL && !pListBox->IsInDropDown()) + VclPtr< ListBox > pListBox = GetAs< ListBox >(); + if (pListBox && !pListBox->IsInDropDown()) aText = pListBox->GetSelectEntry(); return aText; } - - - IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE) IMPLEMENT_FORWARD_XTYPEPROVIDER2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE) @@ -184,7 +184,7 @@ VCLXAccessibleToolBox::~VCLXAccessibleToolBox() VCLXAccessibleToolBoxItem* VCLXAccessibleToolBox::GetItem_Impl( sal_Int32 _nPos, bool _bMustHaveFocus ) { VCLXAccessibleToolBoxItem* pItem = NULL; - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox && ( !_bMustHaveFocus || pToolBox->HasFocus() ) ) { ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos ); @@ -198,7 +198,7 @@ VCLXAccessibleToolBoxItem* VCLXAccessibleToolBox::GetItem_Impl( sal_Int32 _nPos, void VCLXAccessibleToolBox::UpdateFocus_Impl() { - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if( !pToolBox ) return; @@ -250,7 +250,7 @@ void VCLXAccessibleToolBox::UpdateFocus_Impl() void VCLXAccessibleToolBox::ReleaseFocus_Impl( sal_Int32 _nPos ) { - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox ) // #107124#, do not check for focus because this message is also handled in losefocus { ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos ); @@ -266,7 +266,7 @@ void VCLXAccessibleToolBox::ReleaseFocus_Impl( sal_Int32 _nPos ) void VCLXAccessibleToolBox::UpdateChecked_Impl( sal_Int32 _nPos ) { - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox ) { sal_uInt16 nFocusId = pToolBox->GetItemId( (sal_uInt16)_nPos ); @@ -291,7 +291,7 @@ void VCLXAccessibleToolBox::UpdateChecked_Impl( sal_Int32 _nPos ) void VCLXAccessibleToolBox::UpdateIndeterminate_Impl( sal_Int32 _nPos ) { - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox ) { sal_uInt16 nItemId = pToolBox->GetItemId( (sal_uInt16)_nPos ); @@ -347,7 +347,7 @@ void VCLXAccessibleToolBox::UpdateItem_Impl( sal_Int32 _nPos, bool _bItemAdded ) return; } - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox ) { if ( !_bItemAdded ) @@ -403,7 +403,7 @@ void VCLXAccessibleToolBox::UpdateItem_Impl( sal_Int32 _nPos, bool _bItemAdded ) void VCLXAccessibleToolBox::UpdateAllItems_Impl() { - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox ) { // deregister the old items @@ -427,7 +427,7 @@ void VCLXAccessibleToolBox::UpdateAllItems_Impl() void VCLXAccessibleToolBox::UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, bool bOpen ) { - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if( pWindow && pToolBox ) { const sal_uInt16 nDownItem = pToolBox->GetDownItemId(); @@ -465,7 +465,7 @@ void VCLXAccessibleToolBox::UpdateItemEnabled_Impl( sal_Int32 _nPos ) void VCLXAccessibleToolBox::HandleSubToolBarEvent( const VclWindowEvent& rVclWindowEvent, bool _bShow ) { vcl::Window* pChildWindow = static_cast<vcl::Window *>(rVclWindowEvent.GetData()); - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pChildWindow && pToolBox && pToolBox == pChildWindow->GetParent() @@ -486,7 +486,7 @@ void VCLXAccessibleToolBox::HandleSubToolBarEvent( const VclWindowEvent& rVclWin void VCLXAccessibleToolBox::ReleaseSubToolBox( ToolBox* _pSubToolBox ) { - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( !pToolBox ) return; @@ -512,7 +512,7 @@ void VCLXAccessibleToolBox::FillAccessibleStateSet( utl::AccessibleStateSetHelpe { VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet ); - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox ) { rStateSet.AddState( AccessibleStateType::FOCUSABLE ); @@ -533,7 +533,7 @@ void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindow case VCLEVENT_TOOLBOX_CLICK: case VCLEVENT_TOOLBOX_SELECT: { - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( rVclWindowEvent.GetData() ) { UpdateChecked_Impl( (sal_Int32)reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData()) ); @@ -617,14 +617,14 @@ void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindow case VCLEVENT_OBJECT_DYING : { // if this toolbox is a subtoolbox, we have to relese it from its parent - vcl::Window * pWin = GetWindow(); + VclPtr< vcl::Window > pWin = GetAs< vcl::Window >(); if ( pWin && pWin->GetParent() && pWin->GetParent()->GetType() == WINDOW_TOOLBOX ) { VCLXAccessibleToolBox* pParent = static_cast< VCLXAccessibleToolBox* >( pWin->GetParent()->GetAccessible()->getAccessibleContext().get() ); if ( pParent ) - pParent->ReleaseSubToolBox(static_cast<ToolBox *>(pWin)); + pParent->ReleaseSubToolBox(static_cast<ToolBox *>(pWin.get())); } // dispose all items @@ -704,7 +704,7 @@ sal_Int32 SAL_CALL VCLXAccessibleToolBox::getAccessibleChildCount( ) throw (Run comphelper::OExternalLockGuard aGuard( this ); sal_Int32 nCount = 0; - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox ) nCount = pToolBox->GetItemCount(); @@ -718,7 +718,7 @@ Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleChild( sal comphelper::OExternalLockGuard aGuard( this ); - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox ) { Reference< XAccessible > xChild; @@ -763,7 +763,7 @@ Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleAtPoint( c comphelper::OExternalLockGuard aGuard( this ); Reference< XAccessible > xAccessible; - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pToolBox ) { sal_uInt16 nItemPos = pToolBox->GetItemPos( VCLPoint( _rPoint ) ); @@ -778,7 +778,7 @@ Reference< XAccessible > VCLXAccessibleToolBox::GetItemWindowAccessible( const V { Reference< XAccessible > xReturn; vcl::Window* pChildWindow = static_cast<vcl::Window *>(rVclWindowEvent.GetData()); - ToolBox* pToolBox = static_cast< ToolBox* >( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); if ( pChildWindow && pToolBox ) { sal_uInt16 nCount = pToolBox->GetItemCount(); @@ -808,7 +808,7 @@ void VCLXAccessibleToolBox::selectAccessibleChild( sal_Int32 nChildIndex ) throw OExternalLockGuard aGuard( this ); if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) throw IndexOutOfBoundsException(); - ToolBox * pToolBox = static_cast < ToolBox * > ( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); sal_uInt16 nPos = static_cast < sal_uInt16 > (nChildIndex); pToolBox->ChangeHighlight( nPos ); } @@ -818,9 +818,9 @@ sal_Bool VCLXAccessibleToolBox::isAccessibleChildSelected( sal_Int32 nChildIndex OExternalLockGuard aGuard( this ); if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) throw IndexOutOfBoundsException(); - ToolBox * pToolBox = static_cast < ToolBox * > ( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); sal_uInt16 nPos = static_cast < sal_uInt16 > (nChildIndex); - if ( pToolBox != NULL && pToolBox->GetHighlightItemId() == pToolBox->GetItemId( nPos ) ) + if ( pToolBox && pToolBox->GetHighlightItemId() == pToolBox->GetItemId( nPos ) ) return true; else return false; @@ -829,7 +829,7 @@ sal_Bool VCLXAccessibleToolBox::isAccessibleChildSelected( sal_Int32 nChildIndex void VCLXAccessibleToolBox::clearAccessibleSelection( ) throw (RuntimeException, std::exception) { OExternalLockGuard aGuard( this ); - ToolBox * pToolBox = static_cast < ToolBox * > ( GetWindow() ); + VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); pToolBox -> LoseFocus(); } @@ -58,6 +58,7 @@ public: MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyle ); virtual ~MediaControl(); + virtual void dispose() SAL_OVERRIDE; const Size& getMinSizePixel() const; @@ -89,13 +90,13 @@ private: ImageList maImageList; Idle maIdle; MediaItem maItem; - ToolBox maPlayToolBox; - Slider maTimeSlider; - ToolBox maMuteToolBox; - Slider maVolumeSlider; - ToolBox maZoomToolBox; - ListBox* mpZoomListBox; - Edit maTimeEdit; + VclPtr<ToolBox> maPlayToolBox; + VclPtr<Slider> maTimeSlider; + VclPtr<ToolBox> maMuteToolBox; + VclPtr<Slider> maVolumeSlider; + VclPtr<ToolBox> maZoomToolBox; + VclPtr<ListBox> mpZoomListBox; + VclPtr<Edit> maTimeEdit; Size maMinSize; MediaControlStyle meControlStyle; bool mbLocked; @@ -65,13 +65,13 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl Control( pParent ), maImageList( SvtMiscOptions().AreCurrentSymbolsLarge() ? AVMEDIA_RESID( AVMEDIA_IMGLST_L ) : AVMEDIA_RESID( AVMEDIA_IMGLST ) ), maItem( 0, AVMediaSetMask::ALL ), - maPlayToolBox( this, WB_3DLOOK ), - maTimeSlider( this, WB_HORZ | WB_DRAG | WB_3DLOOK | WB_SLIDERSET ), - maMuteToolBox( this, WB_3DLOOK ), - maVolumeSlider( this, WB_HORZ | WB_DRAG | WB_SLIDERSET ), - maZoomToolBox( this, WB_3DLOOK ), - mpZoomListBox( new ListBox( &maZoomToolBox, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_3DLOOK ) ), - maTimeEdit( this, WB_CENTER | WB_READONLY | WB_BORDER | WB_3DLOOK | WB_READONLY ), + maPlayToolBox( VclPtr<ToolBox>::Create(this, WB_3DLOOK) ), + maTimeSlider( VclPtr<Slider>::Create(this, WB_HORZ | WB_DRAG | WB_3DLOOK | WB_SLIDERSET) ), + maMuteToolBox( VclPtr<ToolBox>::Create(this, WB_3DLOOK) ), + maVolumeSlider( VclPtr<Slider>::Create(this, WB_HORZ | WB_DRAG | WB_SLIDERSET) ), + maZoomToolBox( VclPtr<ToolBox>::Create(this, WB_3DLOOK) ), + mpZoomListBox( VclPtr<ListBox>::Create( maZoomToolBox.get(), WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_3DLOOK ) ), + maTimeEdit( VclPtr<Edit>::Create(this, WB_CENTER | WB_READONLY | WB_BORDER | WB_3DLOOK | WB_READONLY) ), meControlStyle( eControlStyle ), mbLocked( false ) { @@ -83,88 +83,88 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl if( MEDIACONTROLSTYLE_SINGLELINE != meControlStyle ) { - maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_OPEN, implGetImage( AVMEDIA_IMG_OPEN ), OUString( AVMEDIA_RESID( AVMEDIA_STR_OPEN ) ) ); - maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_OPEN, HID_AVMEDIA_TOOLBOXITEM_OPEN ); + maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_OPEN, implGetImage( AVMEDIA_IMG_OPEN ), OUString( AVMEDIA_RESID( AVMEDIA_STR_OPEN ) ) ); + maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_OPEN, HID_AVMEDIA_TOOLBOXITEM_OPEN ); - maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_INSERT, implGetImage( AVMEDIA_IMG_INSERT ), OUString( AVMEDIA_RESID( AVMEDIA_STR_INSERT ) ) ); - maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_INSERT, HID_AVMEDIA_TOOLBOXITEM_INSERT ); + maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_INSERT, implGetImage( AVMEDIA_IMG_INSERT ), OUString( AVMEDIA_RESID( AVMEDIA_STR_INSERT ) ) ); + maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_INSERT, HID_AVMEDIA_TOOLBOXITEM_INSERT ); - maPlayToolBox.InsertSeparator(); + maPlayToolBox->InsertSeparator(); } else { mpZoomListBox->SetBackground(); - maZoomToolBox.SetBackground(); - maZoomToolBox.SetPaintTransparent( true ); - maPlayToolBox.SetBackground(); - maPlayToolBox.SetPaintTransparent( true ); - maMuteToolBox.SetBackground(); - maMuteToolBox.SetPaintTransparent( true ); + maZoomToolBox->SetBackground(); + maZoomToolBox->SetPaintTransparent( true ); + maPlayToolBox->SetBackground(); + maPlayToolBox->SetPaintTransparent( true ); + maMuteToolBox->SetBackground(); + maMuteToolBox->SetPaintTransparent( true ); } - maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_PLAY, implGetImage( AVMEDIA_IMG_PLAY ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PLAY ) ), ToolBoxItemBits::CHECKABLE ); - maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_PLAY, HID_AVMEDIA_TOOLBOXITEM_PLAY ); + maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_PLAY, implGetImage( AVMEDIA_IMG_PLAY ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PLAY ) ), ToolBoxItemBits::CHECKABLE ); + maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_PLAY, HID_AVMEDIA_TOOLBOXITEM_PLAY ); - maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_PAUSE, implGetImage( AVMEDIA_IMG_PAUSE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PAUSE ) ), ToolBoxItemBits::CHECKABLE ); - maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_PAUSE, HID_AVMEDIA_TOOLBOXITEM_PAUSE ); + maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_PAUSE, implGetImage( AVMEDIA_IMG_PAUSE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PAUSE ) ), ToolBoxItemBits::CHECKABLE ); + maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_PAUSE, HID_AVMEDIA_TOOLBOXITEM_PAUSE ); - maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_STOP, implGetImage( AVMEDIA_IMG_STOP ), OUString( AVMEDIA_RESID( AVMEDIA_STR_STOP ) ), ToolBoxItemBits::CHECKABLE ); - maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_STOP, HID_AVMEDIA_TOOLBOXITEM_STOP ); + maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_STOP, implGetImage( AVMEDIA_IMG_STOP ), OUString( AVMEDIA_RESID( AVMEDIA_STR_STOP ) ), ToolBoxItemBits::CHECKABLE ); + maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_STOP, HID_AVMEDIA_TOOLBOXITEM_STOP ); - maPlayToolBox.InsertSeparator(); + maPlayToolBox->InsertSeparator(); - maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_LOOP, implGetImage( AVMEDIA_IMG_ENDLESS ), OUString( AVMEDIA_RESID( AVMEDIA_STR_ENDLESS ) ) ); - maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_LOOP, HID_AVMEDIA_TOOLBOXITEM_LOOP ); + maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_LOOP, implGetImage( AVMEDIA_IMG_ENDLESS ), OUString( AVMEDIA_RESID( AVMEDIA_STR_ENDLESS ) ) ); + maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_LOOP, HID_AVMEDIA_TOOLBOXITEM_LOOP ); if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle ) - maPlayToolBox.InsertSeparator(); - - maPlayToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) ); - maPlayToolBox.SetSizePixel( maPlayToolBox.CalcWindowSizePixel() ); - maPlayToolBox.Show(); - maMinSize = maPlayToolBox.GetSizePixel(); - - maTimeSlider.SetSlideHdl( LINK( this, MediaControl, implTimeHdl ) ); - maTimeSlider.SetEndSlideHdl( LINK( this, MediaControl, implTimeEndHdl ) ); - maTimeSlider.SetRange( Range( 0, AVMEDIA_TIME_RANGE ) ); - maTimeSlider.SetHelpId( HID_AVMEDIA_TIMESLIDER ); - maTimeSlider.SetUpdateMode( true ); - maTimeSlider.SetSizePixel( Size( 128, maPlayToolBox.GetSizePixel().Height() ) ); - maTimeSlider.Show(); - maMinSize.Width() += maTimeSlider.GetSizePixel().Width(); - - maTimeEdit.SetText( aTimeText ); - maTimeEdit.SetUpdateMode( true ); - maTimeEdit.SetSizePixel( Size( maTimeEdit.GetTextWidth( aTimeText ) + 8, maPlayToolBox.GetSizePixel().Height() ) ); - maTimeEdit.SetControlBackground( Application::GetSettings().GetStyleSettings().GetWindowColor() ); - maTimeEdit.SetHelpId( HID_AVMEDIA_TIMEEDIT ); - maTimeEdit.Disable(); - maTimeEdit.Show(); - maMinSize.Width() += maTimeEdit.GetSizePixel().Width(); + maPlayToolBox->InsertSeparator(); + + maPlayToolBox->SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) ); + maPlayToolBox->SetSizePixel( maPlayToolBox->CalcWindowSizePixel() ); + maPlayToolBox->Show(); + maMinSize = maPlayToolBox->GetSizePixel(); + + maTimeSlider->SetSlideHdl( LINK( this, MediaControl, implTimeHdl ) ); + maTimeSlider->SetEndSlideHdl( LINK( this, MediaControl, implTimeEndHdl ) ); + maTimeSlider->SetRange( Range( 0, AVMEDIA_TIME_RANGE ) ); + maTimeSlider->SetHelpId( HID_AVMEDIA_TIMESLIDER ); + maTimeSlider->SetUpdateMode( true ); + maTimeSlider->SetSizePixel( Size( 128, maPlayToolBox->GetSizePixel().Height() ) ); + maTimeSlider->Show(); + maMinSize.Width() += maTimeSlider->GetSizePixel().Width(); + + maTimeEdit->SetText( aTimeText ); + maTimeEdit->SetUpdateMode( true ); + maTimeEdit->SetSizePixel( Size( maTimeEdit->GetTextWidth( aTimeText ) + 8, maPlayToolBox->GetSizePixel().Height() ) ); + maTimeEdit->SetControlBackground( Application::GetSettings().GetStyleSettings().GetWindowColor() ); + maTimeEdit->SetHelpId( HID_AVMEDIA_TIMEEDIT ); + maTimeEdit->Disable(); + maTimeEdit->Show(); + maMinSize.Width() += maTimeEdit->GetSizePixel().Width(); if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle ) - maMuteToolBox.InsertSeparator(); - - maMuteToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_MUTE, implGetImage( AVMEDIA_IMG_MUTE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_MUTE ) ) ); - maMuteToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_MUTE, HID_AVMEDIA_TOOLBOXITEM_MUTE ); - - maMuteToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) ); - maMuteToolBox.SetSizePixel( maMuteToolBox.CalcWindowSizePixel() ); - maMuteToolBox.Show(); - maMinSize.Width() += maMuteToolBox.GetSizePixel().Width(); - - maVolumeSlider.SetSlideHdl( LINK( this, MediaControl, implVolumeHdl ) ); - maVolumeSlider.SetEndSlideHdl( LINK( this, MediaControl, implVolumeEndHdl ) ); - maVolumeSlider.SetRange( Range( AVMEDIA_DB_RANGE, 0 ) ); - maVolumeSlider.SetUpdateMode( true ); - maVolumeSlider.SetHelpId( HID_AVMEDIA_VOLUMESLIDER ); - maVolumeSlider.SetSizePixel( Size( 48, maPlayToolBox.GetSizePixel().Height() ) ); - maVolumeSlider.Show(); - maMinSize.Width() += maVolumeSlider.GetSizePixel().Width(); - - mpZoomListBox->SetSizePixel( Size( maTimeEdit.GetSizePixel().Width(), 260 ) ); + maMuteToolBox->InsertSeparator(); + + maMuteToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_MUTE, implGetImage( AVMEDIA_IMG_MUTE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_MUTE ) ) ); + maMuteToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_MUTE, HID_AVMEDIA_TOOLBOXITEM_MUTE ); + + maMuteToolBox->SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) ); + maMuteToolBox->SetSizePixel( maMuteToolBox->CalcWindowSizePixel() ); + maMuteToolBox->Show(); + maMinSize.Width() += maMuteToolBox->GetSizePixel().Width(); + + maVolumeSlider->SetSlideHdl( LINK( this, MediaControl, implVolumeHdl ) ); + maVolumeSlider->SetEndSlideHdl( LINK( this, MediaControl, implVolumeEndHdl ) ); + maVolumeSlider->SetRange( Range( AVMEDIA_DB_RANGE, 0 ) ); + maVolumeSlider->SetUpdateMode( true ); + maVolumeSlider->SetHelpId( HID_AVMEDIA_VOLUMESLIDER ); + maVolumeSlider->SetSizePixel( Size( 48, maPlayToolBox->GetSizePixel().Height() ) ); + maVolumeSlider->Show(); + maMinSize.Width() += maVolumeSlider->GetSizePixel().Width(); + + mpZoomListBox->SetSizePixel( Size( maTimeEdit->GetSizePixel().Width(), 260 ) ); mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_50 ) ), AVMEDIA_ZOOMLEVEL_50 ); mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_100 ) ), AVMEDIA_ZOOMLEVEL_100 ); mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_200 ) ), AVMEDIA_ZOOMLEVEL_200 ); @@ -172,14 +172,14 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl mpZoomListBox->SetSelectHdl( LINK( this, MediaControl, implZoomSelectHdl ) ); mpZoomListBox->SetHelpId( HID_AVMEDIA_ZOOMLISTBOX ); - maZoomToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_ZOOM, OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM ) ) ); - maZoomToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_ZOOM, HID_AVMEDIA_ZOOMLISTBOX ); + maZoomToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_ZOOM, OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM ) ) ); + maZoomToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_ZOOM, HID_AVMEDIA_ZOOMLISTBOX ); - maZoomToolBox.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, mpZoomListBox ); - maZoomToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) ); - maZoomToolBox.SetSizePixel( maZoomToolBox.CalcWindowSizePixel() ); - maZoomToolBox.Show(); - maMinSize.Width() += maZoomToolBox.GetSizePixel().Width(); + maZoomToolBox->SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, mpZoomListBox ); + maZoomToolBox->SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) ); + maZoomToolBox->SetSizePixel( maZoomToolBox->CalcWindowSizePixel() ); + maZoomToolBox->Show(); + maMinSize.Width() += maZoomToolBox->GetSizePixel().Width(); if( MEDIACONTROLSTYLE_MULTILINE == meControlStyle ) { @@ -196,8 +196,20 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl MediaControl::~MediaControl() { - maZoomToolBox.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, NULL ); - delete mpZoomListBox; + disposeOnce(); +} + +void MediaControl::dispose() +{ + maZoomToolBox->SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, NULL ); + mpZoomListBox.disposeAndClear(); + maTimeEdit.disposeAndClear(); + maZoomToolBox.disposeAndClear(); + maVolumeSlider.disposeAndClear(); + maMuteToolBox.disposeAndClear(); + maTimeSlider.disposeAndClear(); + maPlayToolBox.disposeAndClear(); + Control::dispose(); } @@ -212,56 +224,56 @@ const Size& MediaControl::getMinSizePixel() const void MediaControl::Resize() { Point aPos( 0, 0 ); - const sal_Int32 nPlayToolBoxWidth = maPlayToolBox.GetSizePixel().Width(); - const sal_Int32 nMuteToolBoxWidth = maMuteToolBox.GetSizePixel().Width(); - const sal_Int32 nVolumeSliderWidth = maVolumeSlider.GetSizePixel().Width(); - const sal_Int32 nZoomToolBoxWidth = maZoomToolBox.GetSizePixel().Width(); - const sal_Int32 nTimeEditWidth = maTimeEdit.GetSizePixel().Width(); - const sal_Int32 nTimeSliderHeight = maTimeSlider.GetSizePixel().Height(); + const sal_Int32 nPlayToolBoxWidth = maPlayToolBox->GetSizePixel().Width(); + const sal_Int32 nMuteToolBoxWidth = maMuteToolBox->GetSizePixel().Width(); + const sal_Int32 nVolumeSliderWidth = maVolumeSlider->GetSizePixel().Width(); + const sal_Int32 nZoomToolBoxWidth = maZoomToolBox->GetSizePixel().Width(); + const sal_Int32 nTimeEditWidth = maTimeEdit->GetSizePixel().Width(); + const sal_Int32 nTimeSliderHeight = maTimeSlider->GetSizePixel().Height(); if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle ) { const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - ( AVMEDIA_CONTROLOFFSET * 3 ) - nPlayToolBoxWidth - nMuteToolBoxWidth - nVolumeSliderWidth - nTimeEditWidth - nZoomToolBoxWidth; - maPlayToolBox.SetPosSizePixel( aPos, maPlayToolBox.GetSizePixel() ); + maPlayToolBox->SetPosSizePixel( aPos, maPlayToolBox->GetSizePixel() ); aPos.X() += nPlayToolBoxWidth; - maTimeSlider.SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) ); + maTimeSlider->SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) ); aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET; - maTimeEdit.SetPosSizePixel( aPos, maTimeEdit.GetSizePixel() ); + maTimeEdit->SetPosSizePixel( aPos, maTimeEdit->GetSizePixel() ); aPos.X() += nTimeEditWidth + AVMEDIA_CONTROLOFFSET; - maMuteToolBox.SetPosSizePixel( aPos, maMuteToolBox.GetSizePixel() ); + maMuteToolBox->SetPosSizePixel( aPos, maMuteToolBox->GetSizePixel() ); aPos.X() += nMuteToolBoxWidth; - maVolumeSlider.SetPosSizePixel( aPos, maVolumeSlider.GetSizePixel() ); + maVolumeSlider->SetPosSizePixel( aPos, maVolumeSlider->GetSizePixel() ); aPos.X() += nVolumeSliderWidth + AVMEDIA_CONTROLOFFSET; - maZoomToolBox.SetPosSizePixel( aPos, maZoomToolBox.GetSizePixel() ); + maZoomToolBox->SetPosSizePixel( aPos, maZoomToolBox->GetSizePixel() ); } else { const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - AVMEDIA_CONTROLOFFSET - nTimeEditWidth; - maTimeSlider.SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) ); + maTimeSlider->SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) ); aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET; - maTimeEdit.SetPosSizePixel( aPos, maTimeEdit.GetSizePixel() ); + maTimeEdit->SetPosSizePixel( aPos, maTimeEdit->GetSizePixel() ); aPos.X() = 0; aPos.Y() += nTimeSliderHeight + AVMEDIA_CONTROLOFFSET; - maPlayToolBox.SetPosSizePixel( aPos, maPlayToolBox.GetSizePixel() ); + maPlayToolBox->SetPosSizePixel( aPos, maPlayToolBox->GetSizePixel() ); aPos.X() = GetSizePixel().Width() - nVolumeSliderWidth - nMuteToolBoxWidth - nZoomToolBoxWidth - AVMEDIA_CONTROLOFFSET; - maMuteToolBox.SetPosSizePixel( aPos, maMuteToolBox.GetSizePixel() ); + maMuteToolBox->SetPosSizePixel( aPos, maMuteToolBox->GetSizePixel() ); aPos.X() += nMuteToolBoxWidth; - maVolumeSlider.SetPosSizePixel( aPos, maVolumeSlider.GetSizePixel() ); + maVolumeSlider->SetPosSizePixel( aPos, maVolumeSlider->GetSizePixel() ); aPos.X() = GetSizePixel().Width() - nZoomToolBoxWidth; - maZoomToolBox.SetPosSizePixel( aPos, maZoomToolBox.GetSizePixel() ); + maZoomToolBox->SetPosSizePixel( aPos, maZoomToolBox->GetSizePixel() ); } } @@ -286,48 +298,48 @@ void MediaControl::implUpdateToolboxes() { const bool bValidURL = !maItem.getURL().isEmpty(); - maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_INSERT, bValidURL ); - maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PLAY, bValidURL ); - maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PAUSE, bValidURL ); - maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_STOP, bValidURL ); - maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_LOOP, bValidURL ); - maMuteToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_MUTE, bValidURL ); + maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_INSERT, bValidURL ); + maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_PLAY, bValidURL ); + maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_PAUSE, bValidURL ); + maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_STOP, bValidURL ); + maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_LOOP, bValidURL ); + maMuteToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_MUTE, bValidURL ); if( !bValidURL || !IsEnabled() ) { mpZoomListBox->Disable(); if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle ) - maPlayToolBox.Disable(); + maPlayToolBox->Disable(); - maMuteToolBox.Disable(); + maMuteToolBox->Disable(); } else { - maPlayToolBox.Enable(); - maMuteToolBox.Enable(); + maPlayToolBox->Enable(); + maMuteToolBox->Enable(); if( MEDIASTATE_PLAY == maItem.getState() ) { - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, true ); - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false ); - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, true ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false ); } else if( maItem.getTime() > 0.0 && ( maItem.getTime() < maItem.getDuration() ) ) { - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false ); - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, true ); - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, true ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false ); } else { - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false ); - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false ); - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, true ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_STOP, true ); } - maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_LOOP, maItem.isLoop() ); - maMuteToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_MUTE, maItem.isMute() ); + maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_LOOP, maItem.isLoop() ); + maMuteToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_MUTE, maItem.isMute() ); if( !mpZoomListBox->IsTravelSelect() && !mpZoomListBox->IsInDropDown() ) { @@ -360,10 +372,10 @@ void MediaControl::implUpdateToolboxes() void MediaControl::implUpdateTimeSlider() { if( maItem.getURL().isEmpty() || !IsEnabled() ) - maTimeSlider.Disable(); + maTimeSlider->Disable(); else { - maTimeSlider.Enable(); + maTimeSlider->Enable(); const double fDuration = maItem.getDuration(); @@ -371,13 +383,13 @@ void MediaControl::implUpdateTimeSlider() { const double fTime = ::std::min( maItem.getTime(), fDuration ); - if( !maTimeSlider.GetLineSize() ) - maTimeSlider.SetLineSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_LINEINCREMENT / fDuration ) ); + if( !maTimeSlider->GetLineSize() ) + maTimeSlider->SetLineSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_LINEINCREMENT / fDuration ) ); - if( !maTimeSlider.GetPageSize() ) - maTimeSlider.SetPageSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_PAGEINCREMENT / fDuration ) ); + if( !maTimeSlider->GetPageSize() ) + maTimeSlider->SetPageSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_PAGEINCREMENT / fDuration ) ); - maTimeSlider.SetThumbPos( static_cast< sal_Int32 >( fTime / fDuration * AVMEDIA_TIME_RANGE ) ); + maTimeSlider->SetThumbPos( static_cast< sal_Int32 >( fTime / fDuration * AVMEDIA_TIME_RANGE ) ); } } } @@ -387,14 +399,14 @@ void MediaControl::implUpdateTimeSlider() void MediaControl::implUpdateVolumeSlider() { if( maItem.getURL().isEmpty() || !IsEnabled() ) - maVolumeSlider.Disable(); + maVolumeSlider->Disable(); else { - maVolumeSlider.Enable(); + maVolumeSlider->Enable(); const sal_Int32 nVolumeDB = maItem.getVolumeDB(); - maVolumeSlider.SetThumbPos( ::std::min( ::std::max( nVolumeDB, static_cast< sal_Int32 >( AVMEDIA_DB_RANGE ) ), + maVolumeSlider->SetThumbPos( ::std::min( ::std::max( nVolumeDB, static_cast< sal_Int32 >( AVMEDIA_DB_RANGE ) ), static_cast< sal_Int32 >( 0 ) ) ); } } @@ -414,8 +426,8 @@ void MediaControl::implUpdateTimeField( double fCurTime ) " / " + rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( maItem.getDuration() ) )) ); - if( maTimeEdit.GetText() != aTimeString ) - maTimeEdit.SetText( aTimeString ); + if( maTimeEdit->GetText() != aTimeString ) + maTimeEdit->SetText( aTimeString ); } } @@ -535,13 +547,13 @@ IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p ) case( AVMEDIA_TOOLBOXITEM_MUTE ): { - aExecItem.setMute( !maMuteToolBox.IsItemChecked( AVMEDIA_TOOLBOXITEM_MUTE ) ); + aExecItem.setMute( !maMuteToolBox->IsItemChecked( AVMEDIA_TOOLBOXITEM_MUTE ) ); } break; case( AVMEDIA_TOOLBOXITEM_LOOP ): { - aExecItem.setLoop( !maPlayToolBox.IsItemChecked( AVMEDIA_TOOLBOXITEM_LOOP ) ); + aExecItem.setLoop( !maPlayToolBox->IsItemChecked( AVMEDIA_TOOLBOXITEM_LOOP ) ); } break; @@ -40,9 +40,9 @@ namespace avmedia MediaPlayer::MediaPlayer( vcl::Window* _pParent, sal_uInt16 nId, SfxBindings* _pBindings, SfxChildWinInfo* pInfo ) : SfxChildWindow( _pParent, nId ) { - pWindow = new MediaFloater( _pBindings, this, _pParent ); + pWindow.reset( VclPtr<MediaFloater>::Create( _pBindings, this, _pParent ) ); eChildAlignment = SfxChildAlignment::NOALIGNMENT; - static_cast< MediaFloater* >( pWindow )->Initialize( pInfo ); + static_cast< MediaFloater* >( pWindow.get() )->Initialize( pInfo ); }; @@ -75,8 +75,14 @@ MediaFloater::MediaFloater( SfxBindings* _pBindings, SfxChildWindow* pCW, vcl::W MediaFloater::~MediaFloater() { + disposeOnce(); +} + +void MediaFloater::dispose() +{ delete mpMediaWindow; mpMediaWindow = NULL; + SfxDockingWindow::dispose(); } @@ -42,7 +42,6 @@ class MediaToolBoxControl_Impl : public MediaControl public: MediaToolBoxControl_Impl( vcl::Window& rParent, MediaToolBoxControl& rControl ); - virtual ~MediaToolBoxControl_Impl(); void update() SAL_OVERRIDE; void execute( const MediaItem& rItem ) SAL_OVERRIDE; @@ -63,12 +62,6 @@ MediaToolBoxControl_Impl::MediaToolBoxControl_Impl( vcl::Window& rParent, MediaT -MediaToolBoxControl_Impl::~MediaToolBoxControl_Impl() -{ -} - - - void MediaToolBoxControl_Impl::update() { mpToolBoxControl->implUpdateMediaControl(); @@ -131,9 +124,9 @@ void MediaToolBoxControl::StateChanged( sal_uInt16 /* nSID */, SfxItemState eSta -vcl::Window* MediaToolBoxControl::CreateItemWindow( vcl::Window *pParent ) +VclPtr<vcl::Window> MediaToolBoxControl::CreateItemWindow( vcl::Window *pParent ) { - return( pParent ? new MediaToolBoxControl_Impl( *pParent, *this ) : NULL ); + return ( pParent ? VclPtr<MediaToolBoxControl_Impl>::Create( *pParent, *this ) : nullptr ); } @@ -45,7 +45,7 @@ MediaEventListenersImpl::~MediaEventListenersImpl() void MediaEventListenersImpl::cleanUp() { - Application::RemoveMouseAndKeyEvents( reinterpret_cast< vcl::Window* >( mpNotifyWindow ) ); + Application::RemoveMouseAndKeyEvents( reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ) ); mpNotifyWindow = NULL; } @@ -72,7 +72,7 @@ void SAL_CALL MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt:: ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); - Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, reinterpret_cast< vcl::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); + Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLKeyEvt ); } } @@ -91,7 +91,7 @@ void SAL_CALL MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt: ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); - Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, reinterpret_cast< vcl::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); + Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLKeyEvt ); } } @@ -112,7 +112,7 @@ void SAL_CALL MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), e.Modifiers ); - Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, reinterpret_cast< vcl::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLMouseEvt ); } } @@ -133,7 +133,7 @@ void SAL_CALL MediaEventListenersImpl::mouseReleased( const ::com::sun::star::aw ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), e.Modifiers ); - Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, reinterpret_cast< vcl::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLMouseEvt ); } } @@ -174,7 +174,7 @@ void SAL_CALL MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt if( mpNotifyWindow ) { MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, MouseEventModifiers::NONE, e.Buttons, e.Modifiers ); - Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< vcl::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLMouseEvt ); } } @@ -189,7 +189,7 @@ void SAL_CALL MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt:: if( mpNotifyWindow ) { MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, MouseEventModifiers::NONE, e.Buttons, e.Modifiers ); - Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< vcl::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLMouseEvt ); } } @@ -26,6 +26,7 @@ #include <com/sun/star/awt/XMouseListener.hpp> #include <com/sun/star/awt/XMouseMotionListener.hpp> #include <com/sun/star/awt/XFocusListener.hpp> +#include <vcl/vclptr.hxx> namespace avmedia { @@ -69,7 +70,7 @@ namespace avmedia private: - vcl::Window* mpNotifyWindow; + VclPtr<vcl::Window> mpNotifyWindow; mutable ::osl::Mutex maMutex; }; } @@ -46,7 +46,7 @@ namespace avmedia { MediaWindow::MediaWindow( vcl::Window* parent, bool bInternalMediaControl ) : - mpImpl( new priv::MediaWindowImpl( parent, this, bInternalMediaControl ) ) + mpImpl( VclPtr<priv::MediaWindowImpl>::Create( parent, this, bInternalMediaControl ) ) { mpImpl->Show(); } @@ -327,9 +327,10 @@ bool MediaWindow::executeMediaURLDialog(vcl::Window* /* pParent */, void MediaWindow::executeFormatErrorBox( vcl::Window* pParent ) { - MessageDialog aErrBox( pParent, AVMEDIA_RESID( AVMEDIA_STR_ERR_URL ) ); + ScopedVclPtrInstance< MessageDialog > aErrBox( pParent, AVMEDIA_RESID( AVMEDIA_STR_ERR_URL ) ); - aErrBox.Execute(); + aErrBox->Execute(); + aErrBox.disposeAndClear(); } @@ -56,12 +56,6 @@ MediaWindowControl::MediaWindowControl( vcl::Window* pParent ) : -MediaWindowControl::~MediaWindowControl() -{ -} - - - void MediaWindowControl::update() { MediaItem aItem; @@ -93,12 +87,6 @@ MediaChildWindow::MediaChildWindow( vcl::Window* pParent, SystemWindowData* pDat } #endif -MediaChildWindow::~MediaChildWindow() -{ -} - - - void MediaChildWindow::MouseMove( const MouseEvent& rMEvt ) { const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), @@ -168,7 +156,7 @@ MediaWindowImpl::MediaWindowImpl( vcl::Window* pParent, MediaWindow* pMediaWindo mpMediaWindow( pMediaWindow ), mpEvents( NULL ), mbEventTransparent(true), - mpMediaWindowControl( bInternalMediaControl ? new MediaWindowControl( this ) : NULL ), + mpMediaWindowControl( bInternalMediaControl ? VclPtr<MediaWindowControl>::Create( this ) : nullptr ), mpEmptyBmpEx( NULL ), mpAudioBmpEx( NULL ) { @@ -183,6 +171,11 @@ MediaWindowImpl::MediaWindowImpl( vcl::Window* pParent, MediaWindow* pMediaWindo MediaWindowImpl::~MediaWindowImpl() { + disposeOnce(); +} + +void MediaWindowImpl::dispose() +{ if( mpEvents ) mpEvents->cleanUp(); @@ -208,8 +201,13 @@ MediaWindowImpl::~MediaWindowImpl() mpMediaWindow = NULL; delete mpEmptyBmpEx; + mpEmptyBmpEx = NULL; delete mpAudioBmpEx; - delete mpMediaWindowControl; + mpAudioBmpEx = NULL; + mpMediaWindowControl.disposeAndClear(); + mpChildWindow.disposeAndClear(); + + Control::dispose(); } uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& rURL, const OUString& rReferer, const OUString* pMimeType ) @@ -510,13 +508,15 @@ void MediaWindowImpl::onURLChanged() { if( m_sMimeType == AVMEDIA_MIMETYPE_COMMON ) { - mpChildWindow.reset(new MediaChildWindow(this) ); + mpChildWindow.disposeAndClear(); + mpChildWindow.reset(VclPtr<MediaChildWindow>::Create(this) ); } #if HAVE_FEATURE_GLTF else if ( m_sMimeType == AVMEDIA_MIMETYPE_JSON ) { SystemWindowData aWinData = OpenGLContext::generateWinData(this, false); - mpChildWindow.reset(new MediaChildWindow(this,&aWinData)); + mpChildWindow.disposeAndClear(); + mpChildWindow.reset(VclPtr<MediaChildWindow>::Create(this,&aWinData)); mbEventTransparent = false; } #endif @@ -49,7 +49,6 @@ namespace avmedia public: MediaWindowControl( vcl::Window* pParent ); - virtual ~MediaWindowControl(); protected: @@ -67,7 +66,6 @@ namespace avmedia MediaChildWindow( vcl::Window* pParent ); MediaChildWindow( vcl::Window* pParent, SystemWindowData* pData ); - virtual ~MediaChildWindow(); protected: @@ -94,6 +92,7 @@ namespace avmedia MediaWindowImpl( vcl::Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl ); virtual ~MediaWindowImpl(); + virtual void dispose() SAL_OVERRIDE; static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const OUString& rURL, const OUString& rReferer, const OUString* pMimeType = 0 ); @@ -173,8 +172,8 @@ namespace avmedia ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxEventsIf; MediaEventListenersImpl* mpEvents; bool mbEventTransparent; - std::unique_ptr<MediaChildWindow> mpChildWindow; - MediaWindowControl* mpMediaWindowControl; + VclPtr<MediaChildWindow> mpChildWindow; + VclPtr<MediaWindowControl> mpMediaWindowControl; BitmapEx* mpEmptyBmpEx; BitmapEx* mpAudioBmpEx; }; @@ -51,7 +51,9 @@ DocShell::DocShell() } DocShell::~DocShell() -{ } +{ + pPrinter.disposeAndClear(); +} SfxPrinter* DocShell::GetPrinter( bool bCreate ) { @@ -66,7 +68,10 @@ SfxPrinter* DocShell::GetPrinter( bool bCreate ) void DocShell::SetPrinter( SfxPrinter* pPr ) { if (pPr != pPrinter.get()) + { + pPrinter.disposeAndClear(); pPrinter.reset(pPr); + } } void DocShell::FillClass( SvGlobalName*, SotClipboardFormatId*, OUString*, OUString*, OUString*, sal_Int32, bool bTemplate) const @@ -23,17 +23,16 @@ #include <iderid.hxx> #include <sfx2/docfac.hxx> #include <svx/ifaceids.hxx> - +#include <vcl/vclptr.hxx> +#include <sfx2/printer.hxx> #include <boost/scoped_ptr.hpp> -class SfxPrinter; - namespace basctl { class DocShell: public SfxObjectShell { - boost::scoped_ptr<SfxPrinter> pPrinter; + ScopedVclPtr<SfxPrinter> pPrinter; protected: virtual void Draw( OutputDevice *, const JobSetup & rSetup, @@ -46,12 +46,6 @@ LibBoxControl::LibBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx -LibBoxControl::~LibBoxControl() -{ -} - - - void LibBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState ) { LibBox* pBox = static_cast<LibBox*>(GetToolBox().GetItemWindow(GetId())); @@ -71,9 +65,9 @@ void LibBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPool -vcl::Window* LibBoxControl::CreateItemWindow( vcl::Window *pParent ) +VclPtr<vcl::Window> LibBoxControl::CreateItemWindow( vcl::Window *pParent ) { - return new LibBox( pParent, m_xFrame ); + return VclPtr<LibBox>::Create( pParent, m_xFrame ); } @@ -88,7 +82,13 @@ DocListenerBox::DocListenerBox( vcl::Window* pParent ) DocListenerBox::~DocListenerBox() { + disposeOnce(); +} + +void DocListenerBox::dispose() +{ m_aNotifier.dispose(); + ListBox::dispose(); } void DocListenerBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ ) @@ -156,7 +156,13 @@ LibBox::LibBox( vcl::Window* pParent, const uno::Reference< frame::XFrame >& rFr LibBox::~LibBox() { + disposeOnce(); +} + +void LibBox::dispose() +{ ClearBox(); + DocListenerBox::dispose(); } void LibBox::Update( const SfxStringItem* pItem ) @@ -341,10 +347,6 @@ LanguageBoxControl::LanguageBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, Tool { } -LanguageBoxControl::~LanguageBoxControl() -{ -} - void LanguageBoxControl::StateChanged( sal_uInt16 nID, SfxItemState eState, const SfxPoolItem* pItem ) { (void)nID; @@ -360,9 +362,9 @@ void LanguageBoxControl::StateChanged( sal_uInt16 nID, SfxItemState eState, cons } } -vcl::Window* LanguageBoxControl::CreateItemWindow( vcl::Window *pParent ) +VclPtr<vcl::Window> LanguageBoxControl::CreateItemWindow( vcl::Window *pParent ) { - return new LanguageBox( pParent ); + return VclPtr<LanguageBox>::Create( pParent ); } // class basctl::LanguageBox ----------------------------------------------- @@ -384,7 +386,13 @@ LanguageBox::LanguageBox( vcl::Window* pParent ) : LanguageBox::~LanguageBox() { + disposeOnce(); +} + +void LanguageBox::dispose() +{ ClearBox(); + DocListenerBox::dispose(); } void LanguageBox::FillBox() @@ -33,11 +33,10 @@ public: SFX_DECL_TOOLBOX_CONTROL(); LibBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); - virtual ~LibBoxControl(); virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SAL_OVERRIDE; - virtual vcl::Window* CreateItemWindow( vcl::Window *pParent ) SAL_OVERRIDE; + virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) SAL_OVERRIDE; }; /** base class for list boxes which need to update their content according to the list @@ -49,6 +48,7 @@ class DocListenerBox :public ListBox protected: DocListenerBox( vcl::Window* pParent ); virtual ~DocListenerBox(); + virtual void dispose() SAL_OVERRIDE; protected: virtual void FillBox() = 0; @@ -95,7 +95,8 @@ protected: public: LibBox( vcl::Window* pParent, const com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); - virtual ~LibBox(); + virtual ~LibBox(); + virtual void dispose() SAL_OVERRIDE; using Window::Update; void Update( const SfxStringItem* pItem ); @@ -107,10 +108,9 @@ public: SFX_DECL_TOOLBOX_CONTROL(); LanguageBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ); - virtual ~LanguageBoxControl(); virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SAL_OVERRIDE; - virtual vcl::Window* CreateItemWindow( vcl::Window *pParent ) SAL_OVERRIDE; + virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) SAL_OVERRIDE; }; class LanguageBox : public DocListenerBox @@ -135,6 +135,7 @@ protected: public: LanguageBox( vcl::Window* pParent ); virtual ~LanguageBox(); + virtual void dispose() SAL_OVERRIDE; using Window::Update; void Update( const SfxStringItem* pItem ); @@ -77,17 +77,17 @@ Renderable::~Renderable() { } -Printer* Renderable::getPrinter() +VclPtr< Printer > Renderable::getPrinter() { - Printer* pPrinter = NULL; + VclPtr< Printer > pPrinter; Any aValue( getValue( "RenderDevice" ) ); Reference<awt::XDevice> xRenderDevice; if( aValue >>= xRenderDevice ) { VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice); - OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL; - pPrinter = dynamic_cast<Printer*>(pOut); + VclPtr< OutputDevice > pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >(); + pPrinter = dynamic_cast<Printer*>(pOut.get()); } return pPrinter; } @@ -33,10 +33,10 @@ class Renderable : public cppu::WeakComponentImplHelper1< com::sun::star::view::XRenderable >, public vcl::PrinterOptionsHelper { - BaseWindow* mpWindow; + VclPtr<BaseWindow> mpWindow; osl::Mutex maMutex; - Printer* getPrinter(); + VclPtr<Printer> getPrinter(); public: Renderable (BaseWindow*); virtual ~Renderable(); @@ -192,10 +192,10 @@ ModulWindow::ModulWindow ( BaseWindow(pParent, rDocument, aLibName, aName), rLayout(*pParent), nValid(ValidWindow), - aXEditorWindow(this), + aXEditorWindow(VclPtr<ComplexEditorWindow>::Create(this)), m_aModule(aModule) { - aXEditorWindow.Show(); + aXEditorWindow->Show(); SetBackground(); } @@ -227,9 +227,15 @@ SbModuleRef ModulWindow::XModule() ModulWindow::~ModulWindow() { - nValid = 0; + disposeOnce(); +} +void ModulWindow::dispose() +{ + nValid = 0; StarBASIC::Stop(); + aXEditorWindow.disposeAndClear(); + BaseWindow::dispose(); } @@ -237,7 +243,7 @@ void ModulWindow::GetFocus() { if (nValid != ValidWindow) return; - aXEditorWindow.GetEdtWindow().GrabFocus(); + aXEditorWindow->GetEdtWindow().GrabFocus(); // don't call basic calls because focus is somewhere else... } @@ -256,7 +262,7 @@ void ModulWindow::Paint( const Rectangle& ) void ModulWindow::Resize() { - aXEditorWindow.SetPosSizePixel( Point( 0, 0 ), + aXEditorWindow->SetPosSizePixel( Point( 0, 0 ), Size( GetOutputSizePixel() ) ); } @@ -580,7 +586,7 @@ bool ModulWindow::BasicToggleBreakPoint() bNewBreakPoint = true; } - aXEditorWindow.GetBrkWindow().Invalidate(); + aXEditorWindow->GetBrkWindow().Invalidate(); return bNewBreakPoint; } @@ -613,8 +619,8 @@ void ModulWindow::BasicToggleBreakPointEnabled() void ModulWindow::ManageBreakPoints() { BreakPointWindow& rBrkWin = GetBreakPointWindow(); - BreakPointDialog aBrkDlg( &rBrkWin, GetBreakPoints() ); - aBrkDlg.Execute(); + ScopedVclPtrInstance< BreakPointDialog > aBrkDlg( &rBrkWin, GetBreakPoints() ); + aBrkDlg->Execute(); rBrkWin.Invalidate(); } @@ -638,7 +644,7 @@ bool ModulWindow::BasicErrorHdl( StarBASIC * pBasic ) // if other basic, the IDE should try to display the correct module bool const bMarkError = pBasic == GetBasic(); if ( bMarkError ) - aXEditorWindow.GetBrkWindow().SetMarkerPos(nErrorLine, true); + aXEditorWindow->GetBrkWindow().SetMarkerPos(nErrorLine, true); // #i47002# Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( this ); @@ -651,7 +657,7 @@ bool ModulWindow::BasicErrorHdl( StarBASIC * pBasic ) return false; if ( bMarkError ) - aXEditorWindow.GetBrkWindow().SetNoMarker(); + aXEditorWindow->GetBrkWindow().SetNoMarker(); return false; } @@ -676,7 +682,7 @@ long ModulWindow::BasicBreakHdl( StarBASIC* pBasic ) AssertValidEditEngine(); GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, 0 ), TextPaM( nErrorLine, 0 ) ) ); - aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine ); + aXEditorWindow->GetBrkWindow().SetMarkerPos( nErrorLine ); rLayout.UpdateDebug(false); @@ -691,7 +697,7 @@ long ModulWindow::BasicBreakHdl( StarBASIC* pBasic ) Application::Yield(); aStatus.bIsInReschedule = false; - aXEditorWindow.GetBrkWindow().SetNoMarker(); + aXEditorWindow->GetBrkWindow().SetNoMarker(); ClearStatus( BASWIN_INRESCHEDULE ); @@ -1022,7 +1028,7 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq) { SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), false); bSourceLinesEnabled = pItem && pItem->GetValue(); - aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled); + aXEditorWindow->SetLineNumberDisplay(bSourceLinesEnabled); } break; case SID_BASICIDE_DELETECURRENT: @@ -1037,9 +1043,9 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq) break; case SID_GOTOLINE: { - GotoLineDialog aGotoDlg(this); - if (aGotoDlg.Execute()) - if (sal_Int32 const nLine = aGotoDlg.GetLineNumber()) + ScopedVclPtrInstance< GotoLineDialog > aGotoDlg(this); + if (aGotoDlg->Execute()) + if (sal_Int32 const nLine = aGotoDlg->GetLineNumber()) { TextSelection const aSel(TextPaM(nLine - 1, 0), TextPaM(nLine - 1, 0)); GetEditView()->SetSelection(aSel); @@ -1236,7 +1242,7 @@ void ModulWindow::AssertValidEditEngine() void ModulWindow::Activating () { - aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled); + aXEditorWindow->SetLineNumberDisplay(bSourceLinesEnabled); Show(); } @@ -1420,7 +1426,7 @@ bool ModulWindow::IsPasteAllowed() void ModulWindow::OnNewDocument () { - aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled); + aXEditorWindow->SetLineNumberDisplay(bSourceLinesEnabled); } char const* ModulWindow::GetHid () const @@ -1464,15 +1470,28 @@ void ModulWindow::UpdateModule () ModulWindowLayout::ModulWindowLayout (vcl::Window* pParent, ObjectCatalog& rObjectCatalog_) : Layout(pParent), pChild(0), - aWatchWindow(this), - aStackWindow(this), + aWatchWindow(VclPtr<WatchWindow>::Create(this)), + aStackWindow(VclPtr<StackWindow>::Create(this)), rObjectCatalog(rObjectCatalog_) { } +ModulWindowLayout::~ModulWindowLayout() +{ + disposeOnce(); +} + +void ModulWindowLayout::dispose() +{ + aWatchWindow.disposeAndClear(); + aStackWindow.disposeAndClear(); + pChild.clear(); + Layout::dispose(); +} + void ModulWindowLayout::UpdateDebug (bool bBasicStopped) { - aWatchWindow.UpdateWatches(bBasicStopped); - aStackWindow.UpdateCalls(); + aWatchWindow->UpdateWatches(bBasicStopped); + aStackWindow->UpdateCalls(); } void ModulWindowLayout::Paint (Rectangle const&) @@ -1493,8 +1512,8 @@ void ModulWindowLayout::Activating (BaseWindow& rChild) { assert(dynamic_cast<ModulWindow*>(&rChild)); pChild = &static_cast<ModulWindow&>(rChild); - aWatchWindow.Show(); - aStackWindow.Show(); + aWatchWindow->Show(); + aStackWindow->Show(); rObjectCatalog.Show(); rObjectCatalog.SetLayoutWindow(this); rObjectCatalog.UpdateEntries(); @@ -1506,8 +1525,8 @@ void ModulWindowLayout::Deactivating () { aSyntaxColors.SetActiveEditor(0); Layout::Deactivating(); - aWatchWindow.Hide(); - aStackWindow.Hide(); + aWatchWindow->Hide(); + aStackWindow->Hide(); rObjectCatalog.Hide(); pChild = 0; } @@ -1528,19 +1547,19 @@ void ModulWindowLayout::GetState (SfxItemSet &rSet, unsigned nWhich) void ModulWindowLayout::BasicAddWatch (OUString const& rWatchStr) { - aWatchWindow.AddWatch(rWatchStr); + aWatchWindow->AddWatch(rWatchStr); } void ModulWindowLayout::BasicRemoveWatch () { - aWatchWindow.RemoveSelectedWatch(); + aWatchWindow->RemoveSelectedWatch(); } void ModulWindowLayout::OnFirstSize (long const nWidth, long const nHeight) { AddToLeft(&rObjectCatalog, Size(nWidth * 0.20, nHeight * 0.75)); - AddToBottom(&aWatchWindow, Size(nWidth * 0.67, nHeight * 0.25)); - AddToBottom(&aStackWindow, Size(nWidth * 0.33, nHeight * 0.25)); + AddToBottom(aWatchWindow.get(), Size(nWidth * 0.67, nHeight * 0.25)); + AddToBottom(aStackWindow.get(), Size(nWidth * 0.33, nHeight * 0.25)); } @@ -109,7 +109,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface(bool bCreate = true) SAL_OVERRIDE; CodeCompleteDataCache aCodeCompleteCache; - boost::scoped_ptr< CodeCompleteWindow > pCodeCompleteWnd; + VclPtr<CodeCompleteWindow> pCodeCompleteWnd; OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number void SetupAndShowCodeCompleteWnd(const std::vector< OUString >& aEntryVect, TextSelection aSel ); void HandleAutoCorrect(); @@ -137,6 +137,7 @@ protected: public: EditorWindow (vcl::Window* pParent, ModulWindow*); virtual ~EditorWindow(); + virtual void dispose() SAL_OVERRIDE; ExtTextEngine* GetEditEngine() const { return pEditEngine.get(); } ExtTextView* GetEditView() const { return pEditView.get(); } @@ -186,7 +187,6 @@ protected: public: BreakPointWindow (vcl::Window* pParent, ModulWindow*); - virtual ~BreakPointWindow(); void SetMarkerPos( sal_uInt16 nLine, bool bErrorMarker = false ); void SetNoMarker (); @@ -211,6 +211,7 @@ protected: public: WatchTreeListBox( vcl::Window* pParent, WinBits nWinBits ); virtual ~WatchTreeListBox(); + virtual void dispose() SAL_OVERRIDE; void RequestingChildren( SvTreeListEntry * pParent ) SAL_OVERRIDE; void UpdateWatches( bool bBasicStopped = false ); @@ -225,10 +226,10 @@ class WatchWindow : public DockingWindow { private: OUString aWatchStr; - ExtendedEdit aXEdit; - ImageButton aRemoveWatchButton; - WatchTreeListBox aTreeListBox; - HeaderBar aHeaderBar; + VclPtr<ExtendedEdit> aXEdit; + VclPtr<ImageButton> aRemoveWatchButton; + VclPtr<WatchTreeListBox> aTreeListBox; + VclPtr<HeaderBar> aHeaderBar; protected: virtual void Resize() SAL_OVERRIDE; @@ -243,20 +244,21 @@ protected: public: WatchWindow (Layout* pParent); virtual ~WatchWindow(); + virtual void dispose() SAL_OVERRIDE; void AddWatch( const OUString& rVName ); bool RemoveSelectedWatch(); void UpdateWatches( bool bBasicStopped = false ); - WatchTreeListBox& GetWatchTreeListBox() { return aTreeListBox; } + WatchTreeListBox& GetWatchTreeListBox() { return *aTreeListBox.get(); } }; class StackWindow : public DockingWindow { private: - SvTreeListBox aTreeListBox; - OUString aStackStr; + VclPtr<SvTreeListBox> aTreeListBox; + OUString aStackStr; protected: virtual void Resize() SAL_OVERRIDE; @@ -265,6 +267,7 @@ protected: public: StackWindow (Layout* pParent); virtual ~StackWindow(); + virtual void dispose() SAL_OVERRIDE; void UpdateCalls(); }; @@ -273,10 +276,10 @@ public: class ComplexEditorWindow : public vcl::Window { private: - BreakPointWindow aBrkWindow; - LineNumberWindow aLineNumberWindow; - EditorWindow aEdtWindow; - ScrollBar aEWVScrollBar; + VclPtr<BreakPointWindow> aBrkWindow; + VclPtr<LineNumberWindow> aLineNumberWindow; + VclPtr<EditorWindow> aEdtWindow; + VclPtr<ScrollBar> aEWVScrollBar; virtual void DataChanged(DataChangedEvent const & rDCEvt) SAL_OVERRIDE; @@ -286,11 +289,12 @@ protected: public: ComplexEditorWindow( ModulWindow* pParent ); - - BreakPointWindow& GetBrkWindow() { return aBrkWindow; } - LineNumberWindow& GetLineNumberWindow() { return aLineNumberWindow; } - EditorWindow& GetEdtWindow() { return aEdtWindow; } - ScrollBar& GetEWVScrollBar() { return aEWVScrollBar; } + virtual ~ComplexEditorWindow(); + virtual void dispose() SAL_OVERRIDE; + BreakPointWindow& GetBrkWindow() { return *aBrkWindow.get(); } + LineNumberWindow& GetLineNumberWindow() { return *aLineNumberWindow.get(); } + EditorWindow& GetEdtWindow() { return *aEdtWindow.get(); } + ScrollBar& GetEWVScrollBar() { return *aEWVScrollBar.get(); } void SetLineNumberDisplay(bool b); }; @@ -302,7 +306,7 @@ private: ModulWindowLayout& rLayout; StarBASICRef xBasic; short nValid; - ComplexEditorWindow aXEditorWindow; + VclPtr<ComplexEditorWindow> aXEditorWindow; BasicStatus aStatus; SbModuleRef xModule; OUString aCurPath; @@ -328,6 +332,7 @@ public: ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, OUString& aModule ); virtual ~ModulWindow(); + virtual void dispose() SAL_OVERRIDE; virtual void ExecuteCommand (SfxRequest& rReq) SAL_OVERRIDE; virtual void ExecuteGlobal (SfxRequest& rReq) SAL_OVERRIDE; @@ -386,10 +391,10 @@ public: virtual SearchOptionFlags GetSearchOptions() SAL_OVERRIDE; virtual sal_uInt16 StartSearchAndReplace (SvxSearchItem const&, bool bFromStart = false) SAL_OVERRIDE; - EditorWindow& GetEditorWindow() { return aXEditorWindow.GetEdtWindow(); } - BreakPointWindow& GetBreakPointWindow() { return aXEditorWindow.GetBrkWindow(); } - LineNumberWindow& GetLineNumberWindow() { return aXEditorWindow.GetLineNumberWindow(); } - ScrollBar& GetEditVScrollBar() { return aXEditorWindow.GetEWVScrollBar(); } + EditorWindow& GetEditorWindow() { return aXEditorWindow->GetEdtWindow(); } + BreakPointWindow& GetBreakPointWindow() { return aXEditorWindow->GetBrkWindow(); } + LineNumberWindow& GetLineNumberWindow() { return aXEditorWindow->GetLineNumberWindow(); } + ScrollBar& GetEditVScrollBar() { return aXEditorWindow->GetEWVScrollBar(); } ExtTextEngine* GetEditEngine() { return GetEditorWindow().GetEditEngine(); } ExtTextView* GetEditView() { return GetEditorWindow().GetEditView(); } BreakPointList& GetBreakPoints() { return GetBreakPointWindow().GetBreakPoints(); } @@ -419,6 +424,8 @@ class ModulWindowLayout: public Layout { public: ModulWindowLayout (vcl::Window* pParent, ObjectCatalog&); + virtual ~ModulWindowLayout(); + virtual void dispose() SAL_OVERRIDE; public: // Layout: virtual void Activating (BaseWindow&) SAL_OVERRIDE; @@ -438,10 +445,10 @@ protected: private: // main child window - ModulWindow* pChild; + VclPtr<ModulWindow> pChild; // dockable windows - WatchWindow aWatchWindow; - StackWindow aStackWindow; + VclPtr<WatchWindow> aWatchWindow; + VclPtr<StackWindow> aStackWindow; ObjectCatalog& rObjectCatalog; private: virtual void DataChanged (DataChangedEvent const& rDCEvt) SAL_OVERRIDE; @@ -468,7 +475,7 @@ private: // the configuration svtools::ColorConfig aConfig; // the active editor - EditorWindow* pEditor; + VclPtr<EditorWindow> pEditor; } aSyntaxColors; }; @@ -482,7 +489,7 @@ private: /* a buffer to build up function name when typing * a function name, used for showing/hiding listbox values * */ - CodeCompleteWindow* pCodeCompleteWindow; // parent window + VclPtr<CodeCompleteWindow> pCodeCompleteWindow; // parent window void SetMatchingEntries(); // sets the visible entries based on aFuncBuffer variable void HideAndRestoreFocus(); @@ -490,6 +497,8 @@ private: public: CodeCompleteListBox( CodeCompleteWindow* pPar ); + virtual ~CodeCompleteListBox(); + virtual void dispose() SAL_OVERRIDE; void InsertSelectedEntry(); //insert the selected entry DECL_LINK(ImplDoubleClickHdl, void*); @@ -503,15 +512,16 @@ class CodeCompleteWindow: public vcl::Window { friend class CodeCompleteListBox; private: - EditorWindow* pParent; // parent window + VclPtr<EditorWindow> pParent; // parent window TextSelection aTextSelection; - CodeCompleteListBox* pListBox; + VclPtr<CodeCompleteListBox> pListBox; void InitListBox(); // initialize the ListBox public: CodeCompleteWindow( EditorWindow* pPar ); - virtual ~CodeCompleteWindow(){ delete pListBox; } + virtual ~CodeCompleteWindow(); + virtual void dispose() SAL_OVERRIDE; void InsertEntry( const OUString& aStr ); void ClearListBox(); @@ -227,7 +227,7 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : bHighlightning(false), bDoSyntaxHighlight(true), bDelayHighlight(true), - pCodeCompleteWnd(new CodeCompleteWindow(this)) + pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this)) { SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor())); SetPointer( Pointer( POINTER_TEXT ) ); @@ -250,6 +250,11 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) : EditorWindow::~EditorWindow() { + disposeOnce(); +} + +void EditorWindow::dispose() +{ Reference< beans::XMultiPropertySet > n; { osl::MutexGuard g(mutex_); @@ -266,6 +271,8 @@ EditorWindow::~EditorWindow() EndListening( *pEditEngine ); pEditEngine->RemoveView(pEditView.get()); } + pCodeCompleteWnd.disposeAndClear(); + vcl::Window::dispose(); } OUString EditorWindow::GetWordAtCursor() @@ -1376,12 +1383,6 @@ BreakPointWindow::BreakPointWindow (vcl::Window* pParent, ModulWindow* pModulWin SetHelpId(HID_BASICIDE_BREAKPOINTWINDOW); } -BreakPointWindow::~BreakPointWindow() -{ -} - - - void BreakPointWindow::Paint( const Rectangle& ) { if ( SyncYOffset() ) @@ -1519,9 +1520,9 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt ) break; case RID_BRKPROPS: { - BreakPointDialog aBrkDlg( this, GetBreakPoints() ); - aBrkDlg.SetCurrentBreakPoint( pBrk ); - aBrkDlg.Execute(); + ScopedVclPtrInstance< BreakPointDialog > aBrkDlg( this, GetBreakPoints() ); + aBrkDlg->SetCurrentBreakPoint( pBrk ); + aBrkDlg->Execute(); Invalidate(); } break; @@ -1534,8 +1535,8 @@ void BreakPointWindow::Command( const CommandEvent& rCEvt ) { case RID_BRKDLG: { - BreakPointDialog aBrkDlg( this, GetBreakPoints() ); - aBrkDlg.Execute(); + ScopedVclPtrInstance< BreakPointDialog > aBrkDlg( this, GetBreakPoints() ); + aBrkDlg->Execute(); Invalidate(); } break; @@ -1598,69 +1599,69 @@ namespace WatchWindow::WatchWindow (Layout* pParent) : DockingWindow(pParent), aWatchStr( IDEResId( RID_STR_REMOVEWATCH ) ), - aXEdit( this, IDEResId( RID_EDT_WATCHEDIT ) ), - aRemoveWatchButton( this, IDEResId( RID_IMGBTN_REMOVEWATCH ) ), - aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HASBUTTONS | WB_HASLINES | WB_HSCROLL | WB_TABSTOP - | WB_HASLINESATROOT | WB_HASBUTTONSATROOT ), - aHeaderBar( this, WB_BUTTONSTYLE | WB_BORDER ) + aXEdit( VclPtr<ExtendedEdit>::Create(this, IDEResId( RID_EDT_WATCHEDIT )) ), + aRemoveWatchButton( VclPtr<ImageButton>::Create(this, IDEResId( RID_IMGBTN_REMOVEWATCH )) ), + aTreeListBox( VclPtr<WatchTreeListBox>::Create(this, WB_BORDER | WB_3DLOOK | WB_HASBUTTONS | WB_HASLINES | WB_HSCROLL | WB_TABSTOP + | WB_HASLINESATROOT | WB_HASBUTTONSATROOT) ), + aHeaderBar( VclPtr<HeaderBar>::Create( this, WB_BUTTONSTYLE | WB_BORDER ) ) { - aXEdit.SetAccessibleName(IDEResId(RID_STR_WATCHNAME).toString()); - aTreeListBox.SetAccessibleName(IDEResId(RID_STR_WATCHNAME).toString()); + aXEdit->SetAccessibleName(IDEResId(RID_STR_WATCHNAME).toString()); + aTreeListBox->SetAccessibleName(IDEResId(RID_STR_WATCHNAME).toString()); long nTextLen = GetTextWidth( aWatchStr ) + DWBORDER + 3; - aXEdit.SetPosPixel( Point( nTextLen, 3 ) ); - aXEdit.SetAccHdl( LINK( this, WatchWindow, EditAccHdl ) ); - aXEdit.GetAccelerator().InsertItem( 1, vcl::KeyCode( KEY_RETURN ) ); - aXEdit.GetAccelerator().InsertItem( 2, vcl::KeyCode( KEY_ESCAPE ) ); - aXEdit.Show(); - - aRemoveWatchButton.Disable(); - aRemoveWatchButton.SetClickHdl( LINK( this, WatchWindow, ButtonHdl ) ); - aRemoveWatchButton.SetPosPixel( Point( nTextLen + aXEdit.GetSizePixel().Width() + 4, 2 ) ); - Size aSz( aRemoveWatchButton.GetModeImage().GetSizePixel() ); + aXEdit->SetPosPixel( Point( nTextLen, 3 ) ); + aXEdit->SetAccHdl( LINK( this, WatchWindow, EditAccHdl ) ); + aXEdit->GetAccelerator().InsertItem( 1, vcl::KeyCode( KEY_RETURN ) ); + aXEdit->GetAccelerator().InsertItem( 2, vcl::KeyCode( KEY_ESCAPE ) ); + aXEdit->Show(); + + aRemoveWatchButton->Disable(); + aRemoveWatchButton->SetClickHdl( LINK( this, WatchWindow, ButtonHdl ) ); + aRemoveWatchButton->SetPosPixel( Point( nTextLen + aXEdit->GetSizePixel().Width() + 4, 2 ) ); + Size aSz( aRemoveWatchButton->GetModeImage().GetSizePixel() ); aSz.Width() += 6; aSz.Height() += 6; - aRemoveWatchButton.SetSizePixel( aSz ); - aRemoveWatchButton.Show(); + aRemoveWatchButton->SetSizePixel( aSz ); + aRemoveWatchButton->Show(); - long nRWBtnSize = aRemoveWatchButton.GetModeImage().GetSizePixel().Height() + 10; - nVirtToolBoxHeight = aXEdit.GetSizePixel().Height() + 7; + long nRWBtnSize = aRemoveWatchButton->GetModeImage().GetSizePixel().Height() + 10; + nVirtToolBoxHeight = aXEdit->GetSizePixel().Height() + 7; if ( nRWBtnSize > nVirtToolBoxHeight ) nVirtToolBoxHeight = nRWBtnSize; nHeaderBarHeight = 16; - aTreeListBox.SetHelpId(HID_BASICIDE_WATCHWINDOW_LIST); - aTreeListBox.EnableInplaceEditing(true); - aTreeListBox.SetSelectHdl( LINK( this, WatchWindow, TreeListHdl ) ); - aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight + nHeaderBarHeight ) ); - aTreeListBox.SetHighlightRange( 1, 5 ); + aTreeListBox->SetHelpId(HID_BASICIDE_WATCHWINDOW_LIST); + aTreeListBox->EnableInplaceEditing(true); + aTreeListBox->SetSelectHdl( LINK( this, WatchWindow, TreeListHdl ) ); + aTreeListBox->SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight + nHeaderBarHeight ) ); + aTreeListBox->SetHighlightRange( 1, 5 ); Point aPnt( DWBORDER, nVirtToolBoxHeight + 1 ); - aHeaderBar.SetPosPixel( aPnt ); - aHeaderBar.SetEndDragHdl( LINK( this, WatchWindow, implEndDragHdl ) ); + aHeaderBar->SetPosPixel( aPnt ); + aHeaderBar->SetEndDragHdl( LINK( this, WatchWindow, implEndDragHdl ) ); long nVarTabWidth = 220; long nValueTabWidth = 100; long nTypeTabWidth = 1250; - aHeaderBar.InsertItem( ITEM_ID_VARIABLE, IDEResId(RID_STR_WATCHVARIABLE).toString(), nVarTabWidth ); - aHeaderBar.InsertItem( ITEM_ID_VALUE, IDEResId(RID_STR_WATCHVALUE).toString(), nValueTabWidth ); - aHeaderBar.InsertItem( ITEM_ID_TYPE, IDEResId(RID_STR_WATCHTYPE).toString(), nTypeTabWidth ); + aHeaderBar->InsertItem( ITEM_ID_VARIABLE, IDEResId(RID_STR_WATCHVARIABLE).toString(), nVarTabWidth ); + aHeaderBar->InsertItem( ITEM_ID_VALUE, IDEResId(RID_STR_WATCHVALUE).toString(), nValueTabWidth ); + aHeaderBar->InsertItem( ITEM_ID_TYPE, IDEResId(RID_STR_WATCHTYPE).toString(), nTypeTabWidth ); long tabs[ 4 ]; tabs[ 0 ] = 3; // two tabs tabs[ 1 ] = 0; tabs[ 2 ] = nVarTabWidth; tabs[ 3 ] = nVarTabWidth + nValueTabWidth; - aTreeListBox.SvHeaderTabListBox::SetTabs( tabs, MAP_PIXEL ); - aTreeListBox.InitHeaderBar( &aHeaderBar ); + aTreeListBox->SvHeaderTabListBox::SetTabs( tabs, MAP_PIXEL ); + aTreeListBox->InitHeaderBar( aHeaderBar.get() ); - aTreeListBox.SetNodeDefaultImages( ); + aTreeListBox->SetNodeDefaultImages( ); - aHeaderBar.Show(); + aHeaderBar->Show(); - aTreeListBox.Show(); + aTreeListBox->Show(); SetText(IDEResId(RID_STR_WATCHNAME).toString()); @@ -1674,7 +1675,18 @@ WatchWindow::WatchWindow (Layout* pParent) : WatchWindow::~WatchWindow() { - GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + disposeOnce(); +} + +void WatchWindow::dispose() +{ + aXEdit.disposeAndClear(); + aRemoveWatchButton.disposeAndClear(); + aHeaderBar.disposeAndClear(); + aTreeListBox.disposeAndClear(); + if (!IsDisposed()) + GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + DockingWindow::dispose(); } @@ -1698,11 +1710,11 @@ void WatchWindow::Resize() aBoxSz.Height() = 0; aBoxSz.Height() -= nHeaderBarHeight; - aTreeListBox.SetSizePixel( aBoxSz ); - aTreeListBox.GetHScroll()->SetPageSize( aTreeListBox.GetHScroll()->GetVisibleSize() ); + aTreeListBox->SetSizePixel( aBoxSz ); + aTreeListBox->GetHScroll()->SetPageSize( aTreeListBox->GetHScroll()->GetVisibleSize() ); aBoxSz.Height() = nHeaderBarHeight; - aHeaderBar.SetSizePixel( aBoxSz ); + aHeaderBar->SetSizePixel( aBoxSz ); Invalidate(); } @@ -1766,29 +1778,29 @@ void WatchWindow::AddWatch( const OUString& rVName ) OUString aWatchStr_( aVar ); aWatchStr_ += "\t\t"; - SvTreeListEntry* pNewEntry = aTreeListBox.InsertEntry( aWatchStr_, 0, true, TREELIST_APPEND ); + SvTreeListEntry* pNewEntry = aTreeListBox->InsertEntry( aWatchStr_, 0, true, TREELIST_APPEND ); pNewEntry->SetUserData( pWatchItem ); - aTreeListBox.Select(pNewEntry, true); - aTreeListBox.MakeVisible(pNewEntry); - aRemoveWatchButton.Enable(); + aTreeListBox->Select(pNewEntry, true); + aTreeListBox->MakeVisible(pNewEntry); + aRemoveWatchButton->Enable(); UpdateWatches(); } bool WatchWindow::RemoveSelectedWatch() { - SvTreeListEntry* pEntry = aTreeListBox.GetCurEntry(); + SvTreeListEntry* pEntry = aTreeListBox->GetCurEntry(); if ( pEntry ) { - aTreeListBox.GetModel()->Remove( pEntry ); - pEntry = aTreeListBox.GetCurEntry(); + aTreeListBox->GetModel()->Remove( pEntry ); + pEntry = aTreeListBox->GetCurEntry(); if ( pEntry ) - aXEdit.SetText( static_cast<WatchItem*>(pEntry->GetUserData())->maName ); + aXEdit->SetText( static_cast<WatchItem*>(pEntry->GetUserData())->maName ); else - aXEdit.SetText( OUString() ); - if ( !aTreeListBox.GetEntryCount() ) - aRemoveWatchButton.Disable(); + aXEdit->SetText( OUString() ); + if ( !aTreeListBox->GetEntryCount() ) + aRemoveWatchButton->Disable(); return true; } else @@ -1798,7 +1810,7 @@ bool WatchWindow::RemoveSelectedWatch() IMPL_LINK_INLINE_START( WatchWindow, ButtonHdl, ImageButton *, pButton ) { - if (pButton == &aRemoveWatchButton) + if (pButton == aRemoveWatchButton.get()) if (SfxDispatcher* pDispatcher = GetDispatcher()) pDispatcher->Execute(SID_BASICIDE_REMOVEWATCH); return 0; @@ -1809,9 +1821,9 @@ IMPL_LINK_INLINE_END( WatchWindow, ButtonHdl, ImageButton *, pButton ) IMPL_LINK_NOARG_INLINE_START(WatchWindow, TreeListHdl) { - SvTreeListEntry* pCurEntry = aTreeListBox.GetCurEntry(); + SvTreeListEntry* pCurEntry = aTreeListBox->GetCurEntry(); if ( pCurEntry && pCurEntry->GetUserData() ) - aXEdit.SetText( static_cast<WatchItem*>(pCurEntry->GetUserData())->maName ); + aXEdit->SetText( static_cast<WatchItem*>(pCurEntry->GetUserData())->maName ); return 0; } @@ -1824,29 +1836,29 @@ IMPL_LINK_INLINE_START( WatchWindow, implEndDragHdl, HeaderBar *, pBar ) const sal_Int32 TAB_WIDTH_MIN = 10; sal_Int32 nMaxWidth = - aHeaderBar.GetSizePixel().getWidth() - 2 * TAB_WIDTH_MIN; + aHeaderBar->GetSizePixel().getWidth() - 2 * TAB_WIDTH_MIN; - sal_Int32 nVariableWith = aHeaderBar.GetItemSize( ITEM_ID_VARIABLE ); + sal_Int32 nVariableWith = aHeaderBar->GetItemSize( ITEM_ID_VARIABLE ); if( nVariableWith < TAB_WIDTH_MIN ) - aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, TAB_WIDTH_MIN ); + aHeaderBar->SetItemSize( ITEM_ID_VARIABLE, TAB_WIDTH_MIN ); else if( nVariableWith > nMaxWidth ) - aHeaderBar.SetItemSize( ITEM_ID_VARIABLE, nMaxWidth ); + aHeaderBar->SetItemSize( ITEM_ID_VARIABLE, nMaxWidth ); - sal_Int32 nValueWith = aHeaderBar.GetItemSize( ITEM_ID_VALUE ); + sal_Int32 nValueWith = aHeaderBar->GetItemSize( ITEM_ID_VALUE ); if( nValueWith < TAB_WIDTH_MIN ) - aHeaderBar.SetItemSize( ITEM_ID_VALUE, TAB_WIDTH_MIN ); + aHeaderBar->SetItemSize( ITEM_ID_VALUE, TAB_WIDTH_MIN ); else if( nValueWith > nMaxWidth ) - aHeaderBar.SetItemSize( ITEM_ID_VALUE, nMaxWidth ); + aHeaderBar->SetItemSize( ITEM_ID_VALUE, nMaxWidth ); - if (aHeaderBar.GetItemSize( ITEM_ID_TYPE ) < TAB_WIDTH_MIN) - aHeaderBar.SetItemSize( ITEM_ID_TYPE, TAB_WIDTH_MIN ); + if (aHeaderBar->GetItemSize( ITEM_ID_TYPE ) < TAB_WIDTH_MIN) + aHeaderBar->SetItemSize( ITEM_ID_TYPE, TAB_WIDTH_MIN ); sal_Int32 nPos = 0; - sal_uInt16 nTabs = aHeaderBar.GetItemCount(); + sal_uInt16 nTabs = aHeaderBar->GetItemCount(); for( sal_uInt16 i = 1 ; i < nTabs ; ++i ) { - nPos += aHeaderBar.GetItemSize( i ); - aTreeListBox.SetTab( i, nPos, MAP_PIXEL ); + nPos += aHeaderBar->GetItemSize( i ); + aTreeListBox->SetTab( i, nPos, MAP_PIXEL ); } return 0; } @@ -1859,17 +1871,17 @@ IMPL_LINK( WatchWindow, EditAccHdl, Accelerator *, pAcc ) { case KEY_RETURN: { - OUString aCurText( aXEdit.GetText() ); + OUString aCurText( aXEdit->GetText() ); if ( !aCurText.isEmpty() ) { AddWatch( aCurText ); - aXEdit.SetSelection( Selection( 0, 0xFFFF ) ); + aXEdit->SetSelection( Selection( 0, 0xFFFF ) ); } } break; case KEY_ESCAPE: { - aXEdit.SetText( OUString() ); + aXEdit->SetText( OUString() ); } break; } @@ -1879,7 +1891,7 @@ IMPL_LINK( WatchWindow, EditAccHdl, Accelerator *, pAcc ) void WatchWindow::UpdateWatches( bool bBasicStopped ) { - aTreeListBox.UpdateWatches( bBasicStopped ); + aTreeListBox->UpdateWatches( bBasicStopped ); } @@ -1890,16 +1902,16 @@ void WatchWindow::UpdateWatches( bool bBasicStopped ) StackWindow::StackWindow (Layout* pParent) : DockingWindow(pParent), - aTreeListBox( this, WB_BORDER | WB_3DLOOK | WB_HSCROLL | WB_TABSTOP ), + aTreeListBox( VclPtr<SvTreeListBox>::Create(this, WB_BORDER | WB_3DLOOK | WB_HSCROLL | WB_TABSTOP) ), aStackStr( IDEResId( RID_STR_STACK ) ) { - aTreeListBox.SetHelpId(HID_BASICIDE_STACKWINDOW_LIST); - aTreeListBox.SetAccessibleName(IDEResId(RID_STR_STACKNAME).toString()); - aTreeListBox.SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight ) ); - aTreeListBox.SetHighlightRange(); - aTreeListBox.SetSelectionMode( NO_SELECTION ); - aTreeListBox.InsertEntry( OUString(), 0, false, TREELIST_APPEND ); - aTreeListBox.Show(); + aTreeListBox->SetHelpId(HID_BASICIDE_STACKWINDOW_LIST); + aTreeListBox->SetAccessibleName(IDEResId(RID_STR_STACKNAME).toString()); + aTreeListBox->SetPosPixel( Point( DWBORDER, nVirtToolBoxHeight ) ); + aTreeListBox->SetHighlightRange(); + aTreeListBox->SetSelectionMode( NO_SELECTION ); + aTreeListBox->InsertEntry( OUString(), 0, false, TREELIST_APPEND ); + aTreeListBox->Show(); SetText(IDEResId(RID_STR_STACKNAME).toString()); @@ -1913,7 +1925,15 @@ StackWindow::StackWindow (Layout* pParent) : StackWindow::~StackWindow() { - GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + disposeOnce(); +} + +void StackWindow::dispose() +{ + if (!IsDisposed()) + GetSystemWindow()->GetTaskPaneList()->RemoveWindow( this ); + aTreeListBox.disposeAndClear(); + DockingWindow::dispose(); } @@ -1936,20 +1956,20 @@ void StackWindow::Resize() if ( aBoxSz.Height() < 4 ) aBoxSz.Height() = 0; - aTreeListBox.SetSizePixel( aBoxSz ); + aTreeListBox->SetSizePixel( aBoxSz ); Invalidate(); } void StackWindow::UpdateCalls() { - aTreeListBox.SetUpdateMode(false); - aTreeListBox.Clear(); + aTreeListBox->SetUpdateMode(false); + aTreeListBox->Clear(); if ( StarBASIC::IsRunning() ) { SbxError eOld = SbxBase::GetError(); - aTreeListBox.SetSelectionMode( SINGLE_SELECTION ); + aTreeListBox->SetSelectionMode( SINGLE_SELECTION ); sal_Int32 nScope = 0; SbMethod* pMethod = StarBASIC::GetActiveMethod( nScope ); @@ -1998,7 +2018,7 @@ void StackWindow::UpdateCalls() } aEntry += ")"; } - aTreeListBox.InsertEntry( aEntry, 0, false, TREELIST_APPEND ); + aTreeListBox->InsertEntry( aEntry, 0, false, TREELIST_APPEND ); nScope++; pMethod = StarBASIC::GetActiveMethod( nScope ); } @@ -2009,11 +2029,11 @@ void StackWindow::UpdateCalls() } else { - aTreeListBox.SetSelectionMode( NO_SELECTION ); - aTreeListBox.InsertEntry( OUString(), 0, false, TREELIST_APPEND ); + aTreeListBox->SetSelectionMode( NO_SELECTION ); + aTreeListBox->InsertEntry( OUString(), 0, false, TREELIST_APPEND ); } - aTreeListBox.SetUpdateMode(true); + aTreeListBox->SetUpdateMode(true); } @@ -2024,18 +2044,33 @@ void StackWindow::UpdateCalls() ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) : Window( pParent, WB_3DLOOK | WB_CLIPCHILDREN ), - aBrkWindow(this, pParent), - aLineNumberWindow(this, pParent), - aEdtWindow(this, pParent), - aEWVScrollBar( this, WB_VSCROLL | WB_DRAG ) + aBrkWindow(VclPtr<BreakPointWindow>::Create(this, pParent)), + aLineNumberWindow(VclPtr<LineNumberWindow>::Create(this, pParent)), + aEdtWindow(VclPtr<EditorWindow>::Create(this, pParent)), + aEWVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG) ) +{ + aEdtWindow->Show(); + aBrkWindow->Show(); + + aEWVScrollBar->SetLineSize(nScrollLine); + aEWVScrollBar->SetPageSize(nScrollPage); + aEWVScrollBar->SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) ); + aEWVScrollBar->Show(); +} + + +ComplexEditorWindow::~ComplexEditorWindow() { - aEdtWindow.Show(); - aBrkWindow.Show(); + disposeOnce(); +} - aEWVScrollBar.SetLineSize(nScrollLine); - aEWVScrollBar.SetPageSize(nScrollPage); - aEWVScrollBar.SetScrollHdl( LINK( this, ComplexEditorWindow, ScrollHdl ) ); - aEWVScrollBar.Show(); +void ComplexEditorWindow::dispose() +{ + aBrkWindow.disposeAndClear(); + aLineNumberWindow.disposeAndClear(); + aEdtWindow.disposeAndClear(); + aEWVScrollBar.disposeAndClear(); + vcl::Window::dispose(); } void ComplexEditorWindow::Resize() @@ -2045,40 +2080,40 @@ void ComplexEditorWindow::Resize() aSz.Width() -= 2*DWBORDER; aSz.Height() -= 2*DWBORDER; long nBrkWidth = 20; - long nSBWidth = aEWVScrollBar.GetSizePixel().Width(); + long nSBWidth = aEWVScrollBar->GetSizePixel().Width(); Size aBrkSz(nBrkWidth, aSz.Height()); - Size aLnSz(aLineNumberWindow.GetWidth(), aSz.Height()); + Size aLnSz(aLineNumberWindow->GetWidth(), aSz.Height()); - if (aLineNumberWindow.IsVisible()) + if (aLineNumberWindow->IsVisible()) { - aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz ); - aLineNumberWindow.SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aLnSz); - Size aEWSz(aSz.Width() - nBrkWidth - aLineNumberWindow.GetWidth() - nSBWidth + 2, aSz.Height()); - aEdtWindow.SetPosSizePixel( Point( DWBORDER + aBrkSz.Width() + aLnSz.Width() - 1, DWBORDER ), aEWSz ); + aBrkWindow->SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz ); + aLineNumberWindow->SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aLnSz); + Size aEWSz(aSz.Width() - nBrkWidth - aLineNumberWindow->GetWidth() - nSBWidth + 2, aSz.Height()); + aEdtWindow->SetPosSizePixel( Point( DWBORDER + aBrkSz.Width() + aLnSz.Width() - 1, DWBORDER ), aEWSz ); } else { - aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz ); + aBrkWindow->SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz ); Size aEWSz(aSz.Width() - nBrkWidth - nSBWidth + 2, aSz.Height()); - aEdtWindow.SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aEWSz); + aEdtWindow->SetPosSizePixel(Point(DWBORDER + aBrkSz.Width() - 1, DWBORDER), aEWSz); } - aEWVScrollBar.SetPosSizePixel( Point( aOutSz.Width() - DWBORDER - nSBWidth, DWBORDER ), Size( nSBWidth, aSz.Height() ) ); + aEWVScrollBar->SetPosSizePixel( Point( aOutSz.Width() - DWBORDER - nSBWidth, DWBORDER ), Size( nSBWidth, aSz.Height() ) ); } IMPL_LINK( ComplexEditorWindow, ScrollHdl, ScrollBar *, pCurScrollBar ) { - if ( aEdtWindow.GetEditView() ) + if ( aEdtWindow->GetEditView() ) { - DBG_ASSERT( pCurScrollBar == &aEWVScrollBar, "Wer scrollt hier ?" ); - long nDiff = aEdtWindow.GetEditView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos(); - aEdtWindow.GetEditView()->Scroll( 0, nDiff ); - aBrkWindow.DoScroll( 0, nDiff ); - aLineNumberWindow.DoScroll(0, nDiff); - aEdtWindow.GetEditView()->ShowCursor(false, true); - pCurScrollBar->SetThumbPos( aEdtWindow.GetEditView()->GetStartDocPos().Y() ); + DBG_ASSERT( pCurScrollBar == aEWVScrollBar.get(), "Wer scrollt hier ?" ); + long nDiff = aEdtWindow->GetEditView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos(); + aEdtWindow->GetEditView()->Scroll( 0, nDiff ); + aBrkWindow->DoScroll( 0, nDiff ); + aLineNumberWindow->DoScroll(0, nDiff); + aEdtWindow->GetEditView()->ShowCursor(false, true); + pCurScrollBar->SetThumbPos( aEdtWindow->GetEditView()->GetStartDocPos().Y() ); } return 0; @@ -2102,7 +2137,7 @@ void ComplexEditorWindow::DataChanged(DataChangedEvent const & rDCEvt) void ComplexEditorWindow::SetLineNumberDisplay(bool b) { - aLineNumberWindow.Show(b); + aLineNumberWindow->Show(b); Resize(); } @@ -2135,13 +2170,20 @@ WatchTreeListBox::WatchTreeListBox( vcl::Window* pParent, WinBits nWinBits ) WatchTreeListBox::~WatchTreeListBox() { + disposeOnce(); +} + +void WatchTreeListBox::dispose() +{ // Destroy user data SvTreeListEntry* pEntry = First(); while ( pEntry ) { delete static_cast<WatchItem*>(pEntry->GetUserData()); + pEntry->SetUserData(NULL); pEntry = Next( pEntry ); } + SvHeaderTabListBox::dispose(); } void WatchTreeListBox::SetTabs() @@ -2642,6 +2684,17 @@ pCodeCompleteWindow( pPar ) SetSelectHdl(LINK(this, CodeCompleteListBox, ImplSelectHdl)); } +CodeCompleteListBox::~CodeCompleteListBox() +{ + disposeOnce(); +} + +void CodeCompleteListBox::dispose() +{ + pCodeCompleteWindow.clear(); + ListBox::dispose(); +} + IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) { InsertSelectedEntry(); @@ -2807,12 +2860,24 @@ void CodeCompleteListBox::HideAndRestoreFocus() CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar ) : Window( pPar ), pParent( pPar ), -pListBox( new CodeCompleteListBox(this) ) +pListBox( VclPtr<CodeCompleteListBox>::Create(this) ) { SetSizePixel( Size(151,151) ); //default, later it changes InitListBox(); } +CodeCompleteWindow::~CodeCompleteWindow() +{ + disposeOnce(); +} + +void CodeCompleteWindow::dispose() +{ + pListBox.disposeAndClear(); + pParent.clear(); + vcl::Window::dispose(); +} + void CodeCompleteWindow::InitListBox() { pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length @@ -100,9 +100,6 @@ DialogWindow::DialogWindow ( SetReadOnly(true); } -DialogWindow::~DialogWindow() -{ } - void DialogWindow::LoseFocus() { if ( IsModified() ) @@ -1027,8 +1024,8 @@ bool implImportDialog( vcl::Window* pWin, const OUString& rCurPath, const Script OUString aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_CLASH_TEXT)); aQueryBoxText = aQueryBoxText.replaceAll("$(ARG1)", aXmlDlgName); - NameClashQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText ); - sal_uInt16 nRet = aQueryBox.Execute(); + ScopedVclPtrInstance< NameClashQueryBox > aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText ); + sal_uInt16 nRet = aQueryBox->Execute(); if( RET_YES == nRet ) { // RET_YES == Rename, see NameClashQueryBox::NameClashQueryBox @@ -1089,8 +1086,8 @@ bool implImportDialog( vcl::Window* pWin, const OUString& rCurPath, const Script { OUString aQueryBoxTitle(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TITLE)); OUString aQueryBoxText(IDE_RESSTR(RID_STR_DLGIMP_MISMATCH_TEXT)); - LanguageMismatchQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText ); - sal_uInt16 nRet = aQueryBox.Execute(); + ScopedVclPtrInstance< LanguageMismatchQueryBox > aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText ); + sal_uInt16 nRet = aQueryBox->Execute(); if( RET_YES == nRet ) { // RET_YES == Add, see LanguageMismatchQueryBox::LanguageMismatchQueryBox @@ -1411,11 +1408,16 @@ DialogWindowLayout::DialogWindowLayout (vcl::Window* pParent, ObjectCatalog& rOb DialogWindowLayout::~DialogWindowLayout() { - if (pPropertyBrowser != 0) - { + disposeOnce(); +} + +void DialogWindowLayout::dispose() +{ + if (pPropertyBrowser) Remove(pPropertyBrowser); - delete pPropertyBrowser; - } + pPropertyBrowser.disposeAndClear(); + pChild.clear(); + Layout::dispose(); } // shows the property browser (and creates if necessary) @@ -1425,7 +1427,7 @@ void DialogWindowLayout::ShowPropertyBrowser () if (!pPropertyBrowser) { // creating - pPropertyBrowser = new PropBrw(*this); + pPropertyBrowser = VclPtr<PropBrw>::Create(*this); pPropertyBrowser->Show(); // after OnFirstSize(): if (HasSize()) @@ -126,7 +126,7 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) break; if (it != aWindowTable.end()) ++it; - BaseWindow* pWin = it != aWindowTable.end() ? it->second : 0; + BaseWindow* pWin = it != aWindowTable.end() ? it->second.get() : 0; bool bSearchedFromStart = false; while ( !nFound && !bCanceled && ( pWin || !bSearchedFromStart ) ) @@ -136,8 +136,8 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) SfxViewFrame* pViewFrame = GetViewFrame(); SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SEARCH_DLG ) : NULL; vcl::Window* pParent = pChildWin ? pChildWin->GetWindow() : NULL; - QueryBox aQuery(pParent, WB_YES_NO|WB_DEF_YES, IDE_RESSTR(RID_STR_SEARCHFROMSTART)); - if ( aQuery.Execute() == RET_YES ) + ScopedVclPtrInstance< QueryBox > aQuery(pParent, WB_YES_NO|WB_DEF_YES, IDE_RESSTR(RID_STR_SEARCHFROMSTART)); + if ( aQuery->Execute() == RET_YES ) { it = aWindowTable.begin(); if ( it != aWindowTable.end() ) @@ -166,7 +166,7 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) { if ( it != aWindowTable.end() ) ++it; - pWin = it != aWindowTable.end() ? it->second : 0; + pWin = it != aWindowTable.end() ? it->second.get() : 0; } else pWin = 0; @@ -202,7 +202,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) case SID_BASICSTOP: { // maybe do not simply stop if on breakpoint! - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) pMCurWin->BasicStop(); StopBasic(); } @@ -330,7 +330,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) case SID_BASICIDE_OBJCAT: // toggling object catalog - aObjectCatalog.Show(!aObjectCatalog.IsVisible()); + aObjectCatalog->Show(!aObjectCatalog->IsVisible()); if (pLayout) pLayout->ArrangeWindows(); // refresh the button state @@ -676,8 +676,8 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) case SID_BASICIDE_MANAGE_LANG: { - ManageLanguageDialog aDlg(pCurWin, m_pCurLocalizationMgr); - aDlg.Execute(); + ScopedVclPtrInstance< ManageLanguageDialog > aDlg(pCurWin, m_pCurLocalizationMgr); + aDlg->Execute(); rReq.Done(); } break; @@ -750,7 +750,7 @@ void Shell::GetState(SfxItemSet &rSet) break; case SID_BASICIDE_OBJCAT: if (pLayout) - rSet.Put(SfxBoolItem(nWh, aObjectCatalog.IsVisible())); + rSet.Put(SfxBoolItem(nWh, aObjectCatalog->IsVisible())); else rSet.Put(SfxVisibilityItem(nWh, false)); break; @@ -769,7 +769,7 @@ void Shell::GetState(SfxItemSet &rSet) case SID_BASICSAVEAS: case SID_BASICIDE_MATCHGROUP: { - if (!dynamic_cast<ModulWindow*>(pCurWin)) + if (!dynamic_cast<ModulWindow*>(pCurWin.get())) rSet.DisableItem( nWh ); else if ( ( nWh == SID_BASICLOAD ) && ( StarBASIC::IsRunning() || ( pCurWin && pCurWin->IsReadOnly() ) ) ) rSet.DisableItem( nWh ); @@ -782,7 +782,7 @@ void Shell::GetState(SfxItemSet &rSet) case SID_BASICIDE_TOGGLEBRKPNT: case SID_BASICIDE_MANAGEBRKPNTS: { - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) { if (StarBASIC::IsRunning() && !pMCurWin->GetBasicStatus().bIsInReschedule) rSet.DisableItem(nWh); @@ -793,7 +793,7 @@ void Shell::GetState(SfxItemSet &rSet) break; case SID_BASICCOMPILE: { - if (StarBASIC::IsRunning() || !dynamic_cast<ModulWindow*>(pCurWin)) + if (StarBASIC::IsRunning() || !dynamic_cast<ModulWindow*>(pCurWin.get())) rSet.DisableItem( nWh ); } break; @@ -814,7 +814,7 @@ void Shell::GetState(SfxItemSet &rSet) case SID_INSERT_FORM_HSCROLL: case SID_INSERT_FORM_SPIN: { - if (!dynamic_cast<DialogWindow*>(pCurWin)) + if (!dynamic_cast<DialogWindow*>(pCurWin.get())) rSet.DisableItem( nWh ); } break; @@ -945,7 +945,7 @@ void Shell::GetState(SfxItemSet &rSet) // if this is not a module window hide the // setting, doesn't make sense for example if the // dialog editor is open - if (pCurWin && !dynamic_cast<ModulWindow*>(pCurWin)) + if (pCurWin && !dynamic_cast<ModulWindow*>(pCurWin.get())) { rSet.DisableItem( nWh ); rSet.Put(SfxVisibilityItem(nWh, false)); @@ -968,7 +968,7 @@ bool Shell::HasUIFeature( sal_uInt32 nFeature ) if ( (nFeature & BASICIDE_UI_FEATURE_SHOW_BROWSER) == BASICIDE_UI_FEATURE_SHOW_BROWSER ) { // fade out (in) property browser in module (dialog) windows - if (dynamic_cast<DialogWindow*>(pCurWin) && !pCurWin->IsReadOnly()) + if (dynamic_cast<DialogWindow*>(pCurWin.get()) && !pCurWin->IsReadOnly()) bResult = true; } @@ -1032,10 +1032,10 @@ void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRemembe GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW ); SfxObjectShell::SetCurrentComponent(0); } - aObjectCatalog.SetCurrentEntry(pCurWin); + aObjectCatalog->SetCurrentEntry(pCurWin); SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : 0 ); InvalidateBasicIDESlots(); - EnableScrollbars(pCurWin != 0); + EnableScrollbars(pCurWin != nullptr); if ( m_pCurLocalizationMgr ) m_pCurLocalizationMgr->handleTranslationbar(); @@ -1067,7 +1067,7 @@ void Shell::ManageToolbars() if ( xLayoutManager.is() ) { xLayoutManager->lock(); - if (dynamic_cast<DialogWindow*>(pCurWin)) + if (dynamic_cast<DialogWindow*>(pCurWin.get())) { xLayoutManager->destroyElement( aMacroBarResName ); @@ -1188,13 +1188,13 @@ void Shell::AdjustPosSizePixel( const Point &rPos, const Size &rSize ) return; Size aSz( rSize ); - Size aScrollBarBoxSz( aScrollBarBox.GetSizePixel() ); + Size aScrollBarBoxSz( aScrollBarBox->GetSizePixel() ); aSz.Height() -= aScrollBarBoxSz.Height(); Size aOutSz( aSz ); aSz.Width() -= aScrollBarBoxSz.Width(); - aScrollBarBox.SetPosPixel( Point( rSize.Width() - aScrollBarBoxSz.Width(), rSize.Height() - aScrollBarBoxSz.Height() ) ); - aVScrollBar.SetPosSizePixel( Point( rPos.X()+aSz.Width(), rPos.Y() ), Size( aScrollBarBoxSz.Width(), aSz.Height() ) ); + aScrollBarBox->SetPosPixel( Point( rSize.Width() - aScrollBarBoxSz.Width(), rSize.Height() - aScrollBarBoxSz.Height() ) ); + aVScrollBar->SetPosSizePixel( Point( rPos.X()+aSz.Width(), rPos.Y() ), Size( aScrollBarBoxSz.Width(), aSz.Height() ) ); if ( bTabBarSplitted ) { // SplitSize is 0 at a resize! @@ -1203,17 +1203,17 @@ void Shell::AdjustPosSizePixel( const Point &rPos, const Size &rSize ) nSplitPos = aSz.Width(); pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( nSplitPos, aScrollBarBoxSz.Height() ) ); long nScrlStart = rPos.X() + nSplitPos; - aHScrollBar.SetPosSizePixel( Point( nScrlStart, rPos.Y()+aSz.Height() ), Size( aSz.Width() - nScrlStart + 1, aScrollBarBoxSz.Height() ) ); - aHScrollBar.Update(); + aHScrollBar->SetPosSizePixel( Point( nScrlStart, rPos.Y()+aSz.Height() ), Size( aSz.Width() - nScrlStart + 1, aScrollBarBoxSz.Height() ) ); + aHScrollBar->Update(); } else { - aHScrollBar.SetPosSizePixel( Point( rPos.X()+ aSz.Width()/2 - 1, rPos.Y()+aSz.Height() ), Size( aSz.Width()/2 + 2, aScrollBarBoxSz.Height() ) ); + aHScrollBar->SetPosSizePixel( Point( rPos.X()+ aSz.Width()/2 - 1, rPos.Y()+aSz.Height() ), Size( aSz.Width()/2 + 2, aScrollBarBoxSz.Height() ) ); pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aSz.Width()/2, aScrollBarBoxSz.Height() ) ); } if (pLayout) - pLayout->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin) ? aSz : aOutSz); + pLayout->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin.get()) ? aSz : aOutSz); } Reference< XModel > Shell::GetCurrentDocument() const @@ -1230,7 +1230,7 @@ void Shell::Activate( bool bMDI ) if ( bMDI ) { - if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin)) + if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin.get())) pDCurWin->UpdateBrowser(); } } @@ -1241,7 +1241,7 @@ void Shell::Deactivate( bool bMDI ) // deactivate due to a MessageBox bMDI is false if ( bMDI ) { - if (DialogWindow* pXDlgWin = dynamic_cast<DialogWindow*>(pCurWin)) + if (DialogWindow* pXDlgWin = dynamic_cast<DialogWindow*>(pCurWin.get())) { pXDlgWin->DisableBrowser(); if( pXDlgWin->IsModified() ) @@ -44,7 +44,7 @@ Reference< view::XRenderable > Shell::GetRenderable() bool Shell::HasSelection( bool /* bText */ ) const { - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) { TextView* pEditView = pMCurWin->GetEditView(); if ( pEditView && pEditView->HasSelection() ) @@ -56,7 +56,7 @@ bool Shell::HasSelection( bool /* bText */ ) const OUString Shell::GetSelectionText( bool bWholeWord ) { OUString aText; - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) { if (TextView* pEditView = pMCurWin->GetEditView()) { @@ -166,8 +166,8 @@ ModulWindow* Shell::CreateBasWin( const ScriptDocument& rDocument, const OUStrin { // new module window if (!pModulLayout) - pModulLayout.reset(new ModulWindowLayout(&GetViewFrame()->GetWindow(), aObjectCatalog)); - pWin = new ModulWindow(pModulLayout.get(), rDocument, aLibName, aModName, aModule); + pModulLayout.reset(VclPtr<ModulWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog.get())); + pWin = VclPtr<ModulWindow>::Create(pModulLayout.get(), rDocument, aLibName, aModName, aModule); nKey = InsertWindowInTable( pWin ); } else // we've gotten called recursively ( via listener from createModule above ), get outta here @@ -195,7 +195,7 @@ ModulWindow* Shell::CreateBasWin( const ScriptDocument& rDocument, const OUStrin pTabBar->Sort(); if(pWin) { - pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar ); + pWin->GrabScrollBars( aHScrollBar.get(), aVScrollBar.get() ); if ( !pCurWin ) SetCurWindow( pWin, false, false ); } @@ -220,14 +220,14 @@ void Shell::Move() void Shell::ShowCursor( bool bOn ) { - if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin)) + if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin.get())) pMCurWin->ShowCursor(bOn); } // only if basic window above: void Shell::ExecuteBasic( SfxRequest& rReq ) { - if (dynamic_cast<ModulWindow*>(pCurWin)) + if (dynamic_cast<ModulWindow*>(pCurWin.get())) { pCurWin->ExecuteCommand( rReq ); if (nShellCount) @@ -77,8 +77,8 @@ DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUStri // new dialog window if (!pDialogLayout) - pDialogLayout.reset(new DialogWindowLayout(&GetViewFrame()->GetWindow(), aObjectCatalog)); - pWin = new DialogWindow(pDialogLayout.get(), rDocument, aLibName, aDlgName, xDialogModel); + pDialogLayout.reset(VclPtr<DialogWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog.get())); + pWin = VclPtr<DialogWindow>::Create(pDialogLayout.get(), rDocument, aLibName, aDlgName, xDialogModel); nKey = InsertWindowInTable( pWin ); } } @@ -96,7 +96,7 @@ DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUStri if( pWin ) { - pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar ); + pWin->GrabScrollBars( aHScrollBar.get(), aVScrollBar.get() ); pTabBar->InsertPage( (sal_uInt16)nKey, aDlgName ); pTabBar->Sort(); if ( !pCurWin ) @@ -128,7 +128,7 @@ sal_uInt16 Shell::GetWindowId(const BaseWindow* pWin) const SdrView* Shell::GetCurDlgView() const { - if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin)) + if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin.get())) return &pDCurWin->GetView(); else return 0; @@ -137,7 +137,7 @@ SdrView* Shell::GetCurDlgView() const // only if dialogue window above: void Shell::ExecuteDialog( SfxRequest& rReq ) { - if (pCurWin && (dynamic_cast<DialogWindow*>(pCurWin) || rReq.GetSlot() == SID_IMPORT_DIALOG)) + if (pCurWin && (dynamic_cast<DialogWindow*>(pCurWin.get()) || rReq.GetSlot() == SID_IMPORT_DIALOG)) pCurWin->ExecuteCommand(rReq); } @@ -148,11 +148,11 @@ unsigned Shell::nShellCount = 0; Shell::Shell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell */ ) : SfxViewShell( pFrame_, SfxViewShellFlags::CAN_PRINT | SfxViewShellFlags::NO_NEWWINDOW ), m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ), - aHScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG ) ), - aVScrollBar( &GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG ) ), - aScrollBarBox( &GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE ) ), + aHScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG )) ), + aVScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG )) ), + aScrollBarBox( VclPtr<ScrollBarBox>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE )) ), pLayout(0), - aObjectCatalog(&GetViewFrame()->GetWindow()), + aObjectCatalog(VclPtr<ObjectCatalog>::Create(&GetViewFrame()->GetWindow())), m_bAppBasicModified( false ), m_aNotifier( *this ) { @@ -188,7 +188,7 @@ void Shell::Init() m_aCurDocument = ScriptDocument::getApplicationScriptDocument(); bCreatingWindow = false; - pTabBar.reset(new TabBar(&GetViewFrame()->GetWindow())); + pTabBar.reset(VclPtr<TabBar>::Create(&GetViewFrame()->GetWindow())); pTabBar->SetSplitHdl( LINK( this, Shell, TabBarSplitHdl ) ); bTabBarSplitted = false; @@ -225,12 +225,15 @@ Shell::~Shell() SetWindow( 0 ); SetCurWindow( 0 ); - for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) + for (WindowTable::iterator it = aWindowTable.begin(); it != aWindowTable.end(); ++it) { // no store; does already happen when the BasicManagers are destroyed - delete it->second; + it->second.disposeAndClear(); } + // no store; does already happen when the BasicManagers are destroyed + aWindowTable.clear(); + // Destroy all ContainerListeners for Basic Container. if (ContainerListenerImpl* pListener = static_cast<ContainerListenerImpl*>(m_xLibListener.get())) pListener->removeContainerListener(m_aCurDocument, m_aCurLibName); @@ -290,7 +293,7 @@ void Shell::onDocumentClosed( const ScriptDocument& _rDocument ) bool bSetCurWindow = false; bool bSetCurLib = ( _rDocument == m_aCurDocument ); - std::vector<BaseWindow*> aDeleteVec; + std::vector<VclPtr<BaseWindow> > aDeleteVec; // remove all windows which belong to this document for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) @@ -311,7 +314,7 @@ void Shell::onDocumentClosed( const ScriptDocument& _rDocument ) } } // delete windows outside main loop so we don't invalidate the original iterator - for (std::vector<BaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it) + for (auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it) { BaseWindow* pWin = *it; pWin->StoreData(); @@ -409,15 +412,15 @@ bool Shell::PrepareClose( bool bUI ) void Shell::InitScrollBars() { - aVScrollBar.SetLineSize( 300 ); - aVScrollBar.SetPageSize( 2000 ); - aHScrollBar.SetLineSize( 300 ); - aHScrollBar.SetPageSize( 2000 ); - aHScrollBar.Enable(); - aVScrollBar.Enable(); - aVScrollBar.Show(); - aHScrollBar.Show(); - aScrollBarBox.Show(); + aVScrollBar->SetLineSize( 300 ); + aVScrollBar->SetPageSize( 2000 ); + aHScrollBar->SetLineSize( 300 ); + aHScrollBar->SetPageSize( 2000 ); + aHScrollBar->Enable(); + aVScrollBar->Enable(); + aVScrollBar->Show(); + aHScrollBar->Show(); + aScrollBarBox->Show(); } @@ -485,16 +488,16 @@ bool Shell::NextPage( bool bPrev ) void Shell::ArrangeTabBar() { - long nBoxPos = aScrollBarBox.GetPosPixel().X() - 1; + long nBoxPos = aScrollBarBox->GetPosPixel().X() - 1; long nPos = pTabBar->GetSplitSize(); if ( nPos <= nBoxPos ) { Point aPnt( pTabBar->GetPosPixel() ); - long nH = aHScrollBar.GetSizePixel().Height(); + long nH = aHScrollBar->GetSizePixel().Height(); pTabBar->SetPosSizePixel( aPnt, Size( nPos, nH ) ); long nScrlStart = aPnt.X() + nPos; - aHScrollBar.SetPosSizePixel( Point( nScrlStart, aPnt.Y() ), Size( nBoxPos - nScrlStart + 2, nH ) ); - aHScrollBar.Update(); + aHScrollBar->SetPosSizePixel( Point( nScrlStart, aPnt.Y() ), Size( nBoxPos - nScrlStart + 2, nH ) ); + aHScrollBar->Update(); } } @@ -523,7 +526,7 @@ void Shell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&, case SFX_HINT_DYING: { EndListening( rBC, true /* log off all */ ); - aObjectCatalog.UpdateEntries(); + aObjectCatalog->UpdateEntries(); } break; } @@ -592,14 +595,14 @@ void Shell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&, void Shell::CheckWindows() { bool bSetCurWindow = false; - std::vector<BaseWindow*> aDeleteVec; + std::vector<VclPtr<BaseWindow> > aDeleteVec; for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) { BaseWindow* pWin = it->second; if ( pWin->GetStatus() & BASWIN_TOBEKILLED ) aDeleteVec.push_back( pWin ); } - for ( std::vector<BaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) + for ( auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) { BaseWindow* pWin = *it; pWin->StoreData(); @@ -615,15 +618,15 @@ void Shell::CheckWindows() void Shell::RemoveWindows( const ScriptDocument& rDocument, const OUString& rLibName, bool bDestroy ) { - bool bChangeCurWindow = pCurWin == nullptr; - std::vector<BaseWindow*> aDeleteVec; + bool bChangeCurWindow = pCurWin; + std::vector<VclPtr<BaseWindow> > aDeleteVec; for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) { BaseWindow* pWin = it->second; if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName ) aDeleteVec.push_back( pWin ); } - for ( std::vector<BaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) + for ( auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) { BaseWindow* pWin = *it; if ( pWin == pCurWin ) @@ -643,7 +646,7 @@ void Shell::UpdateWindows() bool bChangeCurWindow = pCurWin == nullptr; if ( !m_aCurLibName.isEmpty() ) { - std::vector<BaseWindow*> aDeleteVec; + std::vector<VclPtr<BaseWindow> > aDeleteVec; for (WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it) { BaseWindow* pWin = it->second; @@ -659,7 +662,7 @@ void Shell::UpdateWindows() aDeleteVec.push_back( pWin ); } } - for ( std::vector<BaseWindow*>::const_iterator it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) + for ( auto it = aDeleteVec.begin(); it != aDeleteVec.end(); ++it ) { RemoveWindow( *it, false, false ); } @@ -806,7 +809,7 @@ void Shell::RemoveWindow( BaseWindow* pWindow_, bool bDestroy, bool bAllowChange { if ( !( pWindow_->GetStatus() & BASWIN_INRESCHEDULE ) ) { - delete pWindow_; + pWindow_->disposeOnce(); } else { @@ -901,8 +904,8 @@ void Shell::InvalidateBasicIDESlots() void Shell::EnableScrollbars( bool bEnable ) { - aHScrollBar.Enable(bEnable); - aVScrollBar.Enable(bEnable); + aHScrollBar->Enable(bEnable); + aVScrollBar->Enable(bEnable); } void Shell::SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows, bool bCheck ) @@ -149,16 +149,16 @@ bool RenameModule ( if ( rDocument.hasModule( rLibName, rNewName ) ) { - MessageDialog aError(pErrorParent, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(pErrorParent, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2)); + aError->Execute(); return false; } // #i74440 if ( rNewName.isEmpty() ) { - MessageDialog aError(pErrorParent, IDE_RESSTR(RID_STR_BADSBXNAME)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(pErrorParent, IDE_RESSTR(RID_STR_BADSBXNAME)); + aError->Execute(); return false; } @@ -242,7 +242,7 @@ OUString ChooseMacro( const uno::Reference< frame::XModel >& rxLimitToDocument, OUString aScriptURL; SbMethod* pMethod = NULL; - boost::scoped_ptr< MacroChooser > pChooser( new MacroChooser( NULL, true ) ); + ScopedVclPtrInstance< MacroChooser > pChooser( nullptr, true ); if ( bChooseOnly || !SvtModuleOptions::IsBasicIDE() ) pChooser->SetMode(MacroChooser::ChooseOnly); @@ -155,16 +155,16 @@ bool RenameDialog ( if ( rDocument.hasDialog( rLibName, rNewName ) ) { - MessageDialog aError(pErrorParent, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(pErrorParent, IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2)); + aError->Execute(); return false; } // #i74440 if ( rNewName.isEmpty() ) { - MessageDialog aError(pErrorParent, IDE_RESSTR(RID_STR_BADSBXNAME)); - aError.Execute(); + ScopedVclPtrInstance< MessageDialog > aError(pErrorParent, IDE_RESSTR(RID_STR_BADSBXNAME)); + aError->Execute(); return false; } @@ -206,15 +206,22 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeTreeListBox(vcl::Windo TreeListBox::~TreeListBox () { + disposeOnce(); +} + +void TreeListBox::dispose() +{ m_aNotifier.dispose(); // destroy user data SvTreeListEntry* pEntry = First(); while ( pEntry ) { - delete static_cast<Entry*>(pEntry->GetUserData()); + delete static_cast<Entry*>( pEntry->GetUserData() ); + pEntry->SetUserData( NULL ); pEntry = Next( pEntry ); } + SvTreeListBox::dispose(); } void TreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation ) @@ -208,6 +208,7 @@ public: TreeListBox(vcl::Window* pParent, const ResId& rRes); TreeListBox(vcl::Window* pParent, WinBits nStyle); virtual ~TreeListBox(); + virtual void dispose() SAL_OVERRIDE; void ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation ); void ScanAllEntries(); @@ -56,10 +56,18 @@ BaseWindow::BaseWindow( vcl::Window* pParent, const ScriptDocument& rDocument, c BaseWindow::~BaseWindow() { + disposeOnce(); +} + +void BaseWindow::dispose() +{ if ( pShellVScrollBar ) pShellVScrollBar->SetScrollHdl( Link() ); if ( pShellHScrollBar ) pShellHScrollBar->SetScrollHdl( Link() ); + pShellVScrollBar.clear(); + pShellHScrollBar.clear(); + vcl::Window::dispose(); } @@ -274,6 +282,17 @@ DockingWindow::DockingWindow (Layout* pParent) : nShowCount(0) { } +DockingWindow::~DockingWindow() +{ + disposeOnce(); +} + +void DockingWindow::dispose() +{ + pLayout.clear(); + ::DockingWindow::dispose(); +} + // Sets the position and the size of the docking window. This property is saved // when the window is floating. Called by Layout. void DockingWindow::ResizeIfDocking (Point const& rPos, Size const& rSize) @@ -521,7 +540,7 @@ void TabBar::Command( const CommandEvent& rCEvt ) { Shell::WindowTable& aWindowTable = pShell->GetWindowTable(); Shell::WindowTableIt it = aWindowTable.find( GetCurPageId() ); - if (it != aWindowTable.end() && dynamic_cast<ModulWindow*>(it->second)) + if (it != aWindowTable.end() && dynamic_cast<ModulWindow*>(it->second.get())) { SbModule* pActiveModule = pBasic->FindModule( it->second->GetName() ); if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) ) @@ -785,8 +804,8 @@ bool QueryDel( const OUString& rName, const ResId& rId, vcl::Window* pParent ) aNameBuf.append('\''); aNameBuf.insert(0, '\''); aQuery = aQuery.replaceAll("XX", aNameBuf.makeStringAndClear()); - MessageDialog aQueryBox(pParent, aQuery, VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); - return ( aQueryBox.Execute() == RET_YES ); + ScopedVclPtrInstance< MessageDialog > aQueryBox(pParent, aQuery, VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO); + return ( aQueryBox->Execute() == RET_YES ); } bool QueryDelMacro( const OUString& rName, vcl::Window* pParent ) @@ -822,19 +841,19 @@ bool QueryPassword( const Reference< script::XLibraryContainer >& xLibContainer, do { // password dialog - SfxPasswordDialog aDlg(Application::GetDefDialogParent()); - aDlg.SetMinLen( 1 ); + ScopedVclPtrInstance< SfxPasswordDialog > aDlg(Application::GetDefDialogParent()); + aDlg->SetMinLen( 1 ); // set new title if ( bNewTitle ) { OUString aTitle(IDE_RESSTR(RID_STR_ENTERPASSWORD)); aTitle = aTitle.replaceAll("XX", rLibName); - aDlg.SetText( aTitle ); + aDlg->SetText( aTitle ); } // execute dialog - nRet = aDlg.Execute(); + nRet = aDlg->Execute(); // verify password if ( nRet == RET_OK ) @@ -844,14 +863,14 @@ bool QueryPassword( const Reference< script::XLibraryContainer >& xLibContainer, Reference< script::XLibraryContainerPassword > xPasswd( xLibContainer, UNO_QUERY ); if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( rLibName ) && !xPasswd->isLibraryPasswordVerified( rLibName ) ) { - rPassword = aDlg.GetPassword(); + rPassword = aDlg->GetPassword(); // OUString aOUPassword( rPassword ); bOK = xPasswd->verifyLibraryPassword( rLibName, rPassword ); if ( !bOK ) { - MessageDialog aErrorBox(Application::GetDefDialogParent(), IDE_RESSTR(RID_STR_WRONGPASSWORD)); - aErrorBox.Execute(); + ScopedVclPtrInstance< MessageDialog > aErrorBox(Application::GetDefDialogParent(), IDE_RESSTR(RID_STR_WRONGPASSWORD)); + aErrorBox->Execute(); } } } @@ -106,6 +106,22 @@ BreakPointDialog::BreakPointDialog( vcl::Window* pParent, BreakPointList& rBrkPn CheckButtons(); } +BreakPointDialog::~BreakPointDialog() +{ + disposeOnce(); +} + +void BreakPointDialog::dispose() +{ + m_pComboBox.clear(); + m_pOKButton.clear(); + m_pNewButton.clear(); + m_pDelButton.clear(); + m_pNumericField.clear(); + m_pCheckBox.clear(); + ModalDialog::dispose(); +} + void BreakPointDialog::SetCurrentBreakPoint( BreakPoint* pBrk ) { OUString aStr( "# " + OUString::number(pBrk->nLine) ); @@ -31,12 +31,12 @@ namespace basctl class BreakPointDialog : public ModalDialog { private: - ComboBox* m_pComboBox; - OKButton* m_pOKButton; - PushButton* m_pNewButton; - PushButton* m_pDelButton; - ::CheckBox* m_pCheckBox; - NumericField* m_pNumericField; + VclPtr<ComboBox> m_pComboBox; + VclPtr<OKButton> m_pOKButton; + VclPtr<PushButton> m_pNewButton; + VclPtr<PushButton> m_pDelButton; + VclPtr<CheckBox> m_pCheckBox; + VclPtr<NumericField> m_pNumericField; BreakPointList & m_rOriginalBreakPointList; BreakPointList m_aModifiedBreakPointList; @@ -53,6 +53,8 @@ protected: public: BreakPointDialog( vcl::Window* pParent, BreakPointList& rBrkList ); + virtual ~BreakPointDialog(); + virtual void dispose() SAL_OVERRIDE; void SetCurrentBreakPoint( BreakPoint* pBrk ); }; @@ -53,9 +53,16 @@ Layout::Layout (vcl::Window* pParent) : SetFont(aFont); } -// virtual dtor Layout::~Layout() -{ } +{ + disposeOnce(); +} + +void Layout::dispose() +{ + pChild.clear(); + Window::dispose(); +} // removes a docking window void Layout::Remove (DockingWindow* pWin) @@ -166,9 +173,9 @@ Layout::SplittedSide::SplittedSide (Layout* pParent, Side eSide) : bVertical(eSide == Left || eSide == Right), bLower(eSide == Left || eSide == Top), nSize(0), - aSplitter(pParent, bVertical ? WB_HSCROLL : WB_VSCROLL) + aSplitter(VclPtr<Splitter>::Create(pParent, bVertical ? WB_HSCROLL : WB_VSCROLL)) { - InitSplitter(aSplitter); + InitSplitter(*aSplitter.get()); } @@ -188,7 +195,7 @@ void Layout::SplittedSide::Add (DockingWindow* pWin, Size const& rSize) // splitter if (!vItems.empty()) { - aItem.pSplit = boost::make_shared<Splitter>(&rLayout, bVertical ? WB_VSCROLL : WB_HSCROLL); + aItem.pSplit = VclPtr<Splitter>::Create(&rLayout, bVertical ? WB_VSCROLL : WB_HSCROLL); aItem.pSplit->SetSplitPosPixel(aItem.nStartPos - nSplitThickness); InitSplitter(*aItem.pSplit); } @@ -267,19 +274,19 @@ void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect) // shown if any of the windows is docked if (!bEmpty) { - aSplitter.Show(); + aSplitter->Show(); // split position - aSplitter.SetSplitPosPixel((bLower ? nSize : nPos1) - nSplitThickness); + aSplitter->SetSplitPosPixel((bLower ? nSize : nPos1) - nSplitThickness); // the actual position and size - aSplitter.SetPosSizePixel( - MakePoint(nPos2, aSplitter.GetSplitPosPixel()), + aSplitter->SetPosSizePixel( + MakePoint(nPos2, aSplitter->GetSplitPosPixel()), MakeSize(nLength, nSplitThickness) ); // dragging rectangle - aSplitter.SetDragRectPixel(aRect); + aSplitter->SetDragRectPixel(aRect); } else - aSplitter.Hide(); + aSplitter->Hide(); // positioning separator lines and windows bool bPrevDocking = false; // is the previous window docked? @@ -350,7 +357,7 @@ IMPL_LINK(Layout::SplittedSide, SplitHdl, Splitter*, pSplitter) // checking margins CheckMarginsFor(pSplitter); // changing stored sizes - if (pSplitter == &aSplitter) + if (pSplitter == aSplitter.get()) { // nSize if (bLower) @@ -21,6 +21,7 @@ #define INCLUDED_BASCTL_SOURCE_BASICIDE_LAYOUT_HXX #include <vcl/split.hxx> +#include <vcl/vclptr.hxx> class DockingWindow; @@ -49,9 +50,11 @@ public: virtual void GetState (SfxItemSet&, unsigned nWhich) = 0; virtual void UpdateDebug (bool bBasicStopped ) = 0; + virtual ~Layout(); + virtual void dispose() SAL_OVERRIDE; + protected: Layout (vcl::Window* pParent); - virtual ~Layout (); void AddToLeft (DockingWindow* pWin, Size const& rSize) { aLeftSide.Add(pWin, rSize); } void AddToBottom (DockingWindow* pWin, Size const& rSize) { aBottomSide.Add(pWin, rSize); } @@ -67,7 +70,7 @@ protected: private: // the main child window (either ModulWindow or DialogWindow) - BaseWindow* pChild; + VclPtr<BaseWindow> pChild; // when this window has at first (nonempty) size bool bFirstSize; @@ -96,12 +99,12 @@ private: // size (width or height) long nSize; // the main splitting line - Splitter aSplitter; + VclPtr<Splitter> aSplitter; // the dockable windows (and some data) struct Item { // pointer to the dockable window - DockingWindow* pWin; + VclPtr<DockingWindow> pWin; // starting and ending position in the strip // They may be different from the actual window position, because // the window may fill the space of the adjacent currently @@ -110,7 +113,7 @@ private: long nStartPos, nEndPos; // splitter line window before the window // (the first one is always nullptr) - boost::shared_ptr<Splitter> pSplit; + VclPtr<Splitter> pSplit; }; std::vector<Item> vItems; private: @@ -26,7 +26,15 @@ LineNumberWindow::LineNumberWindow (vcl::Window* pParent, ModulWindow* pModulWin } LineNumberWindow::~LineNumberWindow() -{ } +{ + disposeOnce(); +} + +void LineNumberWindow::dispose() +{ + m_pModulWindow.clear(); + Window::dispose(); +} void LineNumberWindow::Paint( const Rectangle& ) { @@ -19,7 +19,7 @@ class ModulWindow; class LineNumberWindow : public vcl::Window { private: - ModulWindow* m_pModulWindow; + VclPtr<ModulWindow> m_pModulWindow; int m_nWidth; long m_nCurYOffset; int m_nBaseWidth; @@ -31,6 +31,7 @@ protected: public: LineNumberWindow (vcl::Window* pParent, ModulWindow* pModulWin); virtual ~LineNumberWindow(); + virtual void dispose() SAL_OVERRIDE; void DoScroll( long nHorzScroll, long nVertScroll ); @@ -112,8 +112,31 @@ MacroChooser::MacroChooser( vcl::Window* pParnt, bool bCreateEntries ) MacroChooser::~MacroChooser() { + disposeOnce(); +} + +void MacroChooser::dispose() +{ if ( bForceStoreBasic ) + { SfxGetpApp()->SaveBasicAndDialogContainer(); + bForceStoreBasic = false; + } + m_pMacroNameEdit.clear(); + m_pMacroFromTxT.clear(); + m_pMacrosSaveInTxt.clear(); + m_pBasicBox.clear(); + m_pMacrosInTxt.clear(); + m_pMacroBox.clear(); + m_pRunButton.clear(); + m_pCloseButton.clear(); + m_pAssignButton.clear(); + m_pEditButton.clear(); + m_pDelButton.clear(); + m_pOrganizeButton.clear(); + m_pNewLibButton.clear(); + m_pNewModButton.clear(); + SfxModalDialog::dispose(); } void MacroChooser::StoreMacroDescription() @@ -754,7 +777,7 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton ) StoreMacroDescription(); EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(m_pBasicBox->FirstSelected()); - boost::scoped_ptr<OrganizeDialog> pDlg(new OrganizeDialog( this, 0, aDesc )); + VclPtrInstance< OrganizeDialog > pDlg( this, 0, aDesc ); sal_uInt16 nRet = pDlg->Execute(); pDlg.reset(); @@ -45,22 +45,22 @@ public: }; private: - Edit* m_pMacroNameEdit; - FixedText* m_pMacroFromTxT; - FixedText* m_pMacrosSaveInTxt; - TreeListBox* m_pBasicBox; - FixedText* m_pMacrosInTxt; + VclPtr<Edit> m_pMacroNameEdit; + VclPtr<FixedText> m_pMacroFromTxT; + VclPtr<FixedText> m_pMacrosSaveInTxt; + VclPtr<TreeListBox> m_pBasicBox; + VclPtr<FixedText> m_pMacrosInTxt; OUString m_aMacrosInTxtBaseStr; - SvTreeListBox* m_pMacroBox; + VclPtr<SvTreeListBox> m_pMacroBox; - PushButton* m_pRunButton; - CloseButton* m_pCloseButton; - PushButton* m_pAssignButton; - PushButton* m_pEditButton; - PushButton* m_pDelButton; - PushButton* m_pOrganizeButton; - PushButton* m_pNewLibButton; - PushButton* m_pNewModButton; + VclPtr<PushButton> m_pRunButton; + VclPtr<CloseButton> m_pCloseButton; + VclPtr<PushButton> m_pAssignButton; + VclPtr<PushButton> m_pEditButton; + VclPtr<PushButton> m_pDelButton; + VclPtr<PushButton> m_pOrganizeButton; + VclPtr<PushButton> m_pNewLibButton; + VclPtr<PushButton> m_pNewModButton; bool bNewDelIsDel; bool bForceStoreBasic; @@ -87,6 +87,7 @@ private: public: MacroChooser( vcl::Window* pParent, bool bCreateEntries = true ); virtual ~MacroChooser(); + virtual void dispose() SAL_OVERRIDE; SbMethod* GetMacro(); void DeleteMacro(); @@ -161,15 +161,23 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeCheckBox(vcl::Window * CheckBox::~CheckBox() { + disposeOnce(); +} + +void CheckBox::dispose() +{ delete pCheckButton; + pCheckButton = NULL; // delete user data SvTreeListEntry* pEntry = First(); while ( pEntry ) { - delete static_cast<LibUserData*>(pEntry->GetUserData()); + delete static_cast<LibUserData*>( pEntry->GetUserData() ); + pEntry->SetUserData( NULL ); pEntry = Next( pEntry ); } + SvTabListBox::dispose(); } void CheckBox::Init() @@ -384,6 +392,18 @@ NewObjectDialog::NewObjectDialog(vcl::Window * pParent, ObjectMode::Mode eMode, m_pOKButton->SetClickHdl(LINK(this, NewObjectDialog, OkButtonHandler)); } +NewObjectDialog::~NewObjectDialog() +{ + disposeOnce(); +} + +void NewObjectDialog::dispose() +{ + m_pEdit.clear(); + m_pOKButton.clear(); + ModalDialog::dispose(); +} + // GotoLineDialog GotoLineDialog::GotoLineDialog(vcl::Window * pParent ) : ModalDialog(pParent, "GotoLineDialog", @@ -395,6 +415,18 @@ GotoLineDialog::GotoLineDialog(vcl::Window * pParent ) m_pOKButton->SetClickHdl(LINK(this, GotoLineDialog, OkButtonHandler)); } +GotoLineDialog::~GotoLineDialog() +{ + disposeOnce(); +} + +void GotoLineDialog::dispose() +{ + m_pEdit.clear(); + m_pOKButton.clear(); + ModalDialog::dispose(); +} + sal_Int32 GotoLineDialog::GetLineNumber() const { return m_pEdit->GetText().toInt32(); @@ -429,6 +461,18 @@ ExportDialog::ExportDialog(vcl::Window * pParent) m_pOKButton->SetClickHdl(LINK(this, ExportDialog, OkButtonHandler)); } +ExportDialog::~ExportDialog() +{ + disposeOnce(); +} + +void ExportDialog::dispose() +{ + m_pExportAsPackageButton.clear(); + m_pOKButton.clear(); + ModalDialog::dispose(); +} + // LibPage LibPage::LibPage(vcl::Window * pParent) : TabPage(pParent, "LibPage", @@ -476,12 +520,30 @@ LibPage::LibPage(vcl::Window * pParent) LibPage::~LibPage() { - sal_uInt16 nCount = m_pBasicsBox->GetEntryCount(); - for ( sal_uInt16 i = 0; i < nCount; ++i ) + disposeOnce(); +} + +void LibPage::dispose() +{ + if (m_pBasicsBox) { - DocumentEntry* pEntry = static_cast<DocumentEntry*>(m_pBasicsBox->GetEntryData( i )); - delete pEntry; + sal_uInt16 nCount = m_pBasicsBox->GetEntryCount(); + for ( sal_uInt16 i = 0; i < nCount; ++i ) + { + DocumentEntry* pEntry = static_cast<DocumentEntry*>(m_pBasicsBox->GetEntryData( i )); + delete pEntry; + } } + m_pBasicsBox.clear(); + m_pLibBox.clear(); + m_pEditButton.clear(); + m_pPasswordButton.clear(); + m_pNewLibButton.clear(); + m_pInsertLibButton.clear(); + m_pExportButton.clear(); + m_pDelButton.clear(); + pTabDlg.clear(); + TabPage::dispose(); } void LibPage::CheckButtons() @@ -626,7 +688,7 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton ) bool const bProtected = xPasswd->isLibraryPasswordProtected( aLibName ); // change password dialog - boost::scoped_ptr<SvxPasswordDialog> pDlg(new SvxPasswordDialog( this, true, !bProtected )); + VclPtrInstance< SvxPasswordDialog > pDlg( this, true, !bProtected ); pDlg->SetCheckPasswordHdl( LINK( this, LibPage, CheckPasswordHdl ) ); if ( pDlg->Execute() == RET_OK ) @@ -764,7 +826,7 @@ void LibPage::InsertLib() if ( xModLibContImport.is() || xDlgLibContImport.is() ) { - boost::scoped_ptr<LibDialog> pLibDlg; + VclPtr<LibDialog> pLibDlg; Reference< script::XLibraryContainer > xModLibContImp( xModLibContImport, UNO_QUERY ); Reference< script::XLibraryContainer > xDlgLibContImp( xDlgLibContImport, UNO_QUERY ); @@ -776,7 +838,7 @@ void LibPage::InsertLib() // library import dialog if ( !pLibDlg ) { - pLibDlg.reset(new LibDialog( this )); + pLibDlg.reset(VclPtr<LibDialog>::Create( this )); pLibDlg->SetStorageName( aURLObj.getName() ); pLibDlg->GetLibBox().SetMode(ObjectMode::Library); } @@ -1066,12 +1128,12 @@ void LibPage::Export() return; } - ExportDialog aNewDlg(this); - if (aNewDlg.Execute() == RET_OK) + ScopedVclPtrInstance< ExportDialog > aNewDlg(this); + if (aNewDlg->Execute() == RET_OK) { try { - if (aNewDlg.isExportAsPackage()) + if (aNewDlg->isExportAsPackage()) ExportAsPackage( aLibName ); else ExportAsBasic( aLibName ); @@ -1442,13 +1504,13 @@ void createLibImpl( vcl::Window* pWin, const ScriptDocument& rDocument, i++; } - NewObjectDialog aNewDlg(pWin, ObjectMode::Library); - aNewDlg.SetObjectName(aLibName); + ScopedVclPtrInstance< NewObjectDialog > aNewDlg(pWin, ObjectMode::Library); + aNewDlg->SetObjectName(aLibName); - if (aNewDlg.Execute()) + if (aNewDlg->Execute()) { - if (!aNewDlg.GetObjectName().isEmpty()) - aLibName = aNewDlg.GetObjectName(); + if (!aNewDlg->GetObjectName().isEmpty()) + aLibName = aNewDlg->GetObjectName(); if ( aLibName.getLength() > 30 ) { @@ -62,9 +62,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeExtTreeListBox(vcl::Wi return new ExtTreeListBox(pParent, nWinBits); } -ExtTreeListBox::~ExtTreeListBox () -{ } - bool ExtTreeListBox::EditingEntry( SvTreeListEntry* pEntry, Selection& ) { bool bRet = false; @@ -489,8 +486,19 @@ OrganizeDialog::OrganizeDialog(vcl::Window* pParent, sal_Int16 tabId, OrganizeDialog::~OrganizeDialog() { - for ( sal_uInt16 i = 0; i < m_pTabCtrl->GetPageCount(); i++ ) - delete m_pTabCtrl->GetTabPage( m_pTabCtrl->GetPageId( i ) ); + disposeOnce(); +} + +void OrganizeDialog::dispose() +{ + if (m_pTabCtrl) + { + for ( sal_uInt16 i = 0; i < m_pTabCtrl->GetPageCount(); i++ ) + VclPtr<vcl::Window>(m_pTabCtrl->GetTabPage( m_pTabCtrl->GetPageId( i ) )).disposeAndClear(); + } + m_pTabCtrl.clear(); + + TabDialog::dispose(); }; short OrganizeDialog::Execute() @@ -510,25 +518,25 @@ IMPL_LINK( OrganizeDialog, ActivatePageHdl, TabControl *, pTabCtrl ) if ( !pTabCtrl->GetTabPage( nId ) ) { OString sPageName(pTabCtrl->GetPageName(nId)); - TabPage* pNewTabPage = 0; + VclPtr<TabPage> pNewTabPage; if (sPageName == "modules") { - ObjectPage* pObjectPage = new ObjectPage(pTabCtrl, "ModulePage", BROWSEMODE_MODULES); - pNewTabPage = pObjectPage; + VclPtrInstance<ObjectPage> pObjectPage(pTabCtrl, "ModulePage", BROWSEMODE_MODULES); + pNewTabPage.reset(pObjectPage); pObjectPage->SetTabDlg(this); pObjectPage->SetCurrentEntry(m_aCurEntry); } else if (sPageName == "dialogs") { - ObjectPage* pObjectPage = new ObjectPage( pTabCtrl, "DialogPage", BROWSEMODE_DIALOGS ); - pNewTabPage = pObjectPage; + VclPtrInstance<ObjectPage> pObjectPage( pTabCtrl, "DialogPage", BROWSEMODE_DIALOGS ); + pNewTabPage.reset(pObjectPage); pObjectPage->SetTabDlg(this); pObjectPage->SetCurrentEntry(m_aCurEntry); } else if (sPageName == "libraries") { - LibPage* pLibPage = new LibPage( pTabCtrl ); - pNewTabPage = pLibPage; + VclPtrInstance<LibPage> pLibPage( pTabCtrl ); + pNewTabPage.reset(pLibPage); pLibPage->SetTabDlg( this ); } else @@ -590,6 +598,22 @@ ObjectPage::ObjectPage(vcl::Window *pParent, const OString &rName, sal_uInt16 nM CheckButtons(); } +ObjectPage::~ObjectPage() +{ + disposeOnce(); +} + +void ObjectPage::dispose() +{ + m_pBasicBox.clear(); + m_pEditButton.clear(); + m_pNewModButton.clear(); + m_pNewDlgButton.clear(); + m_pDelButton.clear(); + pTabDlg.clear(); + TabPage::dispose(); +} + void ObjectPage::SetCurrentEntry (EntryDescriptor& rDesc) { m_pBasicBox->SetCurrentEntry( rDesc ); @@ -801,12 +825,12 @@ void ObjectPage::NewDialog() { aDocument.getOrCreateLibrary( E_DIALOGS, aLibName ); - NewObjectDialog aNewDlg(this, ObjectMode::Dialog, true); - aNewDlg.SetObjectName( aDocument.createObjectName( E_DIALOGS, aLibName ) ); + ScopedVclPtrInstance< NewObjectDialog > aNewDlg(this, ObjectMode::Dialog, true); + aNewDlg->SetObjectName( aDocument.createObjectName( E_DIALOGS, aLibName ) ); - if (aNewDlg.Execute() != 0) + if (aNewDlg->Execute() != 0) { - OUString aDlgName = aNewDlg.GetObjectName(); + OUString aDlgName = aNewDlg->GetObjectName(); if (aDlgName.isEmpty()) aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName); @@ -919,6 +943,21 @@ LibDialog::LibDialog( vcl::Window* pParent ) m_pLibBox->set_width_request(m_pLibBox->approximate_char_width() * 32); } +LibDialog::~LibDialog() +{ + disposeOnce(); +} + +void LibDialog::dispose() +{ + m_pStorageFrame.clear(); + m_pLibBox.clear(); + m_pReferenceBox.clear(); + m_pReplaceBox.clear(); + ModalDialog::dispose(); +} + + void LibDialog::SetStorageName( const OUString& rName ) { OUString aName( IDE_RESSTR(RID_STR_FILENAME) ); @@ -944,13 +983,13 @@ SbModule* createModImpl( vcl::Window* pWin, const ScriptDocument& rDocument, if ( aModName.isEmpty() ) aModName = rDocument.createObjectName( E_SCRIPTS, aLibName ); - NewObjectDialog aNewDlg(pWin, ObjectMode::Module, true); - aNewDlg.SetObjectName( aModName ); + ScopedVclPtrInstance< NewObjectDialog > aNewDlg(pWin, ObjectMode::Module, true); + aNewDlg->SetObjectName( aModName ); - if (aNewDlg.Execute() != 0) + if (aNewDlg->Execute() != 0) { - if (!aNewDlg.GetObjectName().isEmpty() ) - aModName = aNewDlg.GetObjectName(); + if (!aNewDlg->GetObjectName().isEmpty() ) + aModName = aNewDlg->GetObjectName(); try { @@ -48,12 +48,14 @@ namespace ObjectMode class NewObjectDialog : public ModalDialog { private: - Edit* m_pEdit; - OKButton* m_pOKButton; + VclPtr<Edit> m_pEdit; + VclPtr<OKButton> m_pOKButton; DECL_LINK(OkButtonHandler, void *); public: NewObjectDialog (vcl::Window* pParent, ObjectMode::Mode, bool bCheckName = false); + virtual ~NewObjectDialog(); + virtual void dispose() SAL_OVERRIDE; OUString GetObjectName() const { return m_pEdit->GetText(); } void SetObjectName( const OUString& rName ) { @@ -64,19 +66,21 @@ public: class GotoLineDialog : public ModalDialog { - Edit* m_pEdit; - OKButton* m_pOKButton; + VclPtr<Edit> m_pEdit; + VclPtr<OKButton> m_pOKButton; DECL_LINK(OkButtonHandler, void *); public: GotoLineDialog(vcl::Window * pParent); + virtual ~GotoLineDialog(); + virtual void dispose() SAL_OVERRIDE; sal_Int32 GetLineNumber() const; }; class ExportDialog : public ModalDialog { private: - RadioButton* m_pExportAsPackageButton; - OKButton* m_pOKButton; + VclPtr<RadioButton> m_pExportAsPackageButton; + VclPtr<OKButton> m_pOKButton; bool mbExportAsPackage; @@ -84,6 +88,8 @@ private: public: ExportDialog( vcl::Window * pParent ); + virtual ~ExportDialog(); + virtual void dispose() SAL_OVERRIDE; bool isExportAsPackage () const { return mbExportAsPackage; } }; @@ -107,7 +113,6 @@ protected: public: ExtTreeListBox(vcl::Window* pParent, WinBits nStyle); - virtual ~ExtTreeListBox(); }; class CheckBox : public SvTabListBox @@ -121,6 +126,7 @@ private: public: CheckBox(vcl::Window* pParent, WinBits nStyle); virtual ~CheckBox(); + virtual void dispose() SAL_OVERRIDE; SvTreeListEntry* DoInsertEntry( const OUString& rStr, sal_uLong nPos = LISTBOX_APPEND ); SvTreeListEntry* FindEntry( const OUString& rName ); @@ -141,13 +147,15 @@ public: class LibDialog: public ModalDialog { private: - VclFrame* m_pStorageFrame; - CheckBox* m_pLibBox; - ::CheckBox* m_pReferenceBox; - ::CheckBox* m_pReplaceBox; + VclPtr<VclFrame> m_pStorageFrame; + VclPtr<CheckBox> m_pLibBox; + VclPtr<::CheckBox> m_pReferenceBox; + VclPtr<::CheckBox> m_pReplaceBox; public: LibDialog( vcl::Window* pParent ); + virtual ~LibDialog(); + virtual void dispose() SAL_OVERRIDE; void SetStorageName( const OUString& rName ); @@ -162,12 +170,13 @@ public: class OrganizeDialog : public TabDialog { private: - TabControl* m_pTabCtrl; + VclPtr<TabControl> m_pTabCtrl; EntryDescriptor m_aCurEntry; public: OrganizeDialog( vcl::Window* pParent, sal_Int16 tabId, EntryDescriptor& rDesc ); virtual ~OrganizeDialog(); + virtual void dispose() SAL_OVERRIDE; virtual short Execute() SAL_OVERRIDE; @@ -177,11 +186,11 @@ public: class ObjectPage: public TabPage { protected: - ExtTreeListBox* m_pBasicBox; - PushButton* m_pEditButton; - PushButton* m_pNewModButton; - PushButton* m_pNewDlgButton; - PushButton* m_pDelButton; + VclPtr<ExtTreeListBox> m_pBasicBox; + VclPtr<PushButton> m_pEditButton; + VclPtr<PushButton> m_pNewModButton; + VclPtr<PushButton> m_pNewDlgButton; + VclPtr<PushButton> m_pDelButton; DECL_LINK( BasicBoxHighlightHdl, TreeListBox * ); DECL_LINK( ButtonHdl, Button * ); @@ -192,13 +201,15 @@ protected: void NewDialog(); void EndTabDialog( sal_uInt16 nRet ); - TabDialog* pTabDlg; + VclPtr<TabDialog> pTabDlg; virtual void ActivatePage() SAL_OVERRIDE; virtual void DeactivatePage() SAL_OVERRIDE; public: ObjectPage(vcl::Window* pParent, const OString& rName, sal_uInt16 nMode); + virtual ~ObjectPage(); + virtual void dispose() SAL_OVERRIDE; void SetCurrentEntry( EntryDescriptor& rDesc ); void SetTabDlg( TabDialog* p ) { pTabDlg = p;} @@ -208,14 +219,14 @@ public: class LibPage: public TabPage { protected: - ListBox* m_pBasicsBox; - CheckBox* m_pLibBox; - PushButton* m_pEditButton; - PushButton* m_pPasswordButton; - PushButton* m_pNewLibButton; - PushButton* m_pInsertLibButton; - PushButton* m_pExportButton; - PushButton* m_pDelButton; + VclPtr<ListBox> m_pBasicsBox; + VclPtr<CheckBox> m_pLibBox; + VclPtr<PushButton> m_pEditButton; + VclPtr<PushButton> m_pPasswordButton; + VclPtr<PushButton> m_pNewLibButton; + VclPtr<PushButton> m_pInsertLibButton; + VclPtr<PushButton> m_pExportButton; + VclPtr<PushButton> m_pDelButton; ScriptDocument m_aCurDocument; LibraryLocation m_eCurLocation; @@ -241,11 +252,12 @@ protected: virtual void ActivatePage() SAL_OVERRIDE; virtual void DeactivatePage() SAL_OVERRIDE; - TabDialog* pTabDlg; + VclPtr<TabDialog> pTabDlg; public: LibPage( vcl::Window* pParent ); virtual ~LibPage(); + virtual void dispose() SAL_OVERRIDE; void SetTabDlg( TabDialog* p ) { pTabDlg = p;} }; @@ -30,27 +30,27 @@ namespace basctl ObjectCatalog::ObjectCatalog (vcl::Window* pParent) : DockingWindow(pParent), - aTitle(this), - aTree(this, IDEResId(RID_TLB_MACROS)) + aTitle(VclPtr<FixedText>::Create(this)), + aTree(VclPtr<TreeListBox>::Create(this, IDEResId(RID_TLB_MACROS))) { SetHelpId("basctl:FloatingWindow:RID_BASICIDE_OBJCAT"); SetText(IDEResId(RID_BASICIDE_OBJCAT).toString()); // title - aTitle.SetText(IDEResId(RID_BASICIDE_OBJCAT).toString()); - aTitle.SetStyle(WB_CENTER); + aTitle->SetText(IDEResId(RID_BASICIDE_OBJCAT).toString()); + aTitle->SetStyle(WB_CENTER); // tree list - aTree.Hide(); - aTree.SetStyle( + aTree->Hide(); + aTree->SetStyle( WB_BORDER | WB_TABSTOP | WB_HSCROLL | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONS | WB_HASBUTTONSATROOT ); - aTree.SetAccessibleName(IDEResId(RID_STR_TLB_MACROS).toString()); - aTree.SetHelpId(HID_BASICIDE_OBJECTCAT); - aTree.ScanAllEntries(); - aTree.GrabFocus(); + aTree->SetAccessibleName(IDEResId(RID_STR_TLB_MACROS).toString()); + aTree->SetHelpId(HID_BASICIDE_OBJECTCAT); + aTree->ScanAllEntries(); + aTree->GrabFocus(); { // centered after AppWin: @@ -67,9 +67,18 @@ ObjectCatalog::ObjectCatalog (vcl::Window* pParent) : GetParent()->GetSystemWindow()->GetTaskPaneList()->AddWindow(this); } -ObjectCatalog::~ObjectCatalog () +ObjectCatalog::~ObjectCatalog() { - GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this); + disposeOnce(); +} + +void ObjectCatalog::dispose() +{ + if (!IsDisposed()) + GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this); + aTitle.disposeAndClear(); + aTree.disposeAndClear(); + DockingWindow::dispose(); } // Resize() -- called by Window @@ -97,14 +106,14 @@ void ObjectCatalog::ArrangeWindows () // title // (showing only if no title bar) if (bFloating) - aTitle.Hide(); + aTitle->Hide(); else { Size aTitleSize = LogicToPixel(Size(3, 10), MAP_APPFONT); aTitleSize.Width() = aSize.Width() - 2*aTitleSize.Width(); - aTitle.SetPosPixel(LogicToPixel(Point(3, 3), MAP_APPFONT)); - aTitle.SetSizePixel(aTitleSize); - aTitle.Show(); + aTitle->SetPosPixel(LogicToPixel(Point(3, 3), MAP_APPFONT)); + aTitle->SetSizePixel(aTitleSize); + aTitle->Show(); } // tree @@ -116,11 +125,11 @@ void ObjectCatalog::ArrangeWindows () ); if (aTreeSize.Height() > 0) { - aTree.SetPosSizePixel(aTreePos, aTreeSize); - aTree.Show(); + aTree->SetPosSizePixel(aTreePos, aTreeSize); + aTree->Show(); } else - aTree.Hide(); + aTree->Hide(); } void ObjectCatalog::SetCurrentEntry (BaseWindow* pCurWin) @@ -128,7 +137,7 @@ void ObjectCatalog::SetCurrentEntry (BaseWindow* pCurWin) EntryDescriptor aDescriptor; if (pCurWin) aDescriptor = pCurWin->CreateEntryDescriptor(); - aTree.SetCurrentEntry(aDescriptor); + aTree->SetCurrentEntry(aDescriptor); } @@ -37,15 +37,16 @@ class ObjectCatalog : public DockingWindow public: ObjectCatalog (vcl::Window* pParent); virtual ~ObjectCatalog (); + virtual void dispose() SAL_OVERRIDE; public: - void UpdateEntries () { aTree.UpdateEntries(); } + void UpdateEntries () { aTree->UpdateEntries(); } void SetCurrentEntry (BaseWindow* pCurWin); private: // title: "Object Catalog" - FixedText aTitle; + VclPtr<FixedText> aTitle; // the tree-list of the objects - TreeListBox aTree; + VclPtr<TreeListBox> aTree; private: virtual void Resize () SAL_OVERRIDE; // Window @@ -141,7 +141,7 @@ void TbxControls::Select( sal_uInt16 nModifier ) |* rItemRect are the screen coordinates |* \************************************************************************/ -SfxPopupWindow* TbxControls::CreatePopupWindow() +VclPtr<SfxPopupWindow> TbxControls::CreatePopupWindow() { if ( GetSlotId() == SID_CHOOSE_CONTROLS ) createAndPositionSubToolBar( aSubToolBarResName ); @@ -46,7 +46,7 @@ public: virtual ~TbxControls() {} virtual SfxPopupWindowType GetPopupWindowType() const SAL_OVERRIDE; - virtual SfxPopupWindow* CreatePopupWindow() SAL_OVERRIDE; + virtual VclPtr<SfxPopupWindow> CreatePopupWindow() SAL_OVERRIDE; using SfxToolBoxControl::Select; void Select( sal_uInt16 nModifier ) SAL_OVERRIDE; @@ -75,7 +75,17 @@ ManageLanguageDialog::ManageLanguageDialog(vcl::Window* pParent, boost::shared_p ManageLanguageDialog::~ManageLanguageDialog() { + disposeOnce(); +} + +void ManageLanguageDialog::dispose() +{ ClearLanguageBox(); + m_pLanguageLB.clear(); + m_pAddPB.clear(); + m_pDeletePB.clear(); + m_pMakeDefPB.clear(); + ModalDialog::dispose(); } void ManageLanguageDialog::Init() @@ -136,11 +146,11 @@ void ManageLanguageDialog::ClearLanguageBox() IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl) { - SetDefaultLanguageDialog aDlg( this, m_xLocalizationMgr ); - if ( RET_OK == aDlg.Execute() ) + ScopedVclPtrInstance< SetDefaultLanguageDialog > aDlg( this, m_xLocalizationMgr ); + if ( RET_OK == aDlg->Execute() ) { // add new locales - Sequence< Locale > aLocaleSeq = aDlg.GetLocales(); + Sequence< Locale > aLocaleSeq = aDlg->GetLocales(); m_xLocalizationMgr->handleAddLocales( aLocaleSeq ); // update listbox ClearLanguageBox(); @@ -154,8 +164,8 @@ IMPL_LINK_NOARG(ManageLanguageDialog, AddHdl) IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl) { - MessageDialog aQBox(this, "DeleteLangDialog", "modules/BasicIDE/ui/deletelang.ui"); - if ( aQBox.Execute() == RET_OK ) + ScopedVclPtrInstance< MessageDialog > aQBox(this, "DeleteLangDialog", "modules/BasicIDE/ui/deletelang.ui"); + if ( aQBox->Execute() == RET_OK ) { sal_uInt16 i, nCount = m_pLanguageLB->GetSelectEntryCount(); sal_uInt16 nPos = m_pLanguageLB->GetSelectEntryPos(); @@ -247,6 +257,22 @@ SetDefaultLanguageDialog::SetDefaultLanguageDialog(vcl::Window* pParent, boost:: FillLanguageBox(); } +SetDefaultLanguageDialog::~SetDefaultLanguageDialog() +{ + disposeOnce(); +} + +void SetDefaultLanguageDialog::dispose() +{ + m_pLanguageFT.clear(); + m_pLanguageLB.clear(); + m_pCheckLangFT.clear(); + m_pCheckLangLB.clear(); + m_pDefinedFT.clear(); + m_pAddedFT.clear(); + ModalDialog::dispose(); +} + void SetDefaultLanguageDialog::FillLanguageBox() { // fill list with all languages @@ -190,8 +190,14 @@ void PropBrw::ImplReCreateController() PropBrw::~PropBrw() { + disposeOnce(); +} + +void PropBrw::dispose() +{ if ( m_xBrowserController.is() ) ImplDestroyController(); + DockingWindow::dispose(); } @@ -24,6 +24,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <comphelper/accessiblecomponenthelper.hxx> #include <cppuhelper/implbase3.hxx> +#include <vcl/vclptr.hxx> namespace vcl { class Window; } class VCLExternalSolarLock; @@ -56,7 +57,7 @@ class AccessibleDialogControlShape : public AccessibleExtendedComponentHelper private: VCLExternalSolarLock* m_pExternalLock; - DialogWindow* m_pDialogWindow; + VclPtr<DialogWindow> m_pDialogWindow; DlgEdObj* m_pDlgEdObj; bool m_bFocused; bool m_bSelected; @@ -26,6 +26,7 @@ #include <cppuhelper/implbase3.hxx> #include <svl/lstner.hxx> #include <tools/link.hxx> +#include <vcl/vclptr.hxx> class VCLExternalSolarLock; class VclSimpleEvent; @@ -80,7 +81,7 @@ private: AccessibleChildren m_aAccessibleChildren; VCLExternalSolarLock* m_pExternalLock; - basctl::DialogWindow* m_pDialogWindow; + VclPtr<basctl::DialogWindow> m_pDialogWindow; DlgEditor* m_pDlgEditor; DlgEdModel* m_pDlgEdModel; @@ -81,8 +81,7 @@ protected: public: TYPEINFO_OVERRIDE(); DialogWindow (DialogWindowLayout* pParent, ScriptDocument const& rDocument, const OUString& aLibName, const OUString& aName, com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> const& xDialogModel); - DialogWindow( DialogWindow* pCurView ); // never implemented - virtual ~DialogWindow(); + DialogWindow( DialogWindow* pCurView ); // never implemented virtual void ExecuteCommand( SfxRequest& rReq ) SAL_OVERRIDE; virtual void GetState( SfxItemSet& ) SAL_OVERRIDE; @@ -129,6 +128,7 @@ class DialogWindowLayout : public Layout public: DialogWindowLayout (vcl::Window* pParent, ObjectCatalog&); virtual ~DialogWindowLayout(); + virtual void dispose() SAL_OVERRIDE; public: void ShowPropertyBrowser (); void UpdatePropertyBrowser (); @@ -146,12 +146,12 @@ protected: private: // child window - DialogWindow* pChild; + VclPtr<DialogWindow> pChild; // dockable windows: // object catalog (owned by Shell) ObjectCatalog& rObjectCatalog; // property browser (created by this, deleted by toolkit) - PropBrw* pPropertyBrowser; + VclPtr<PropBrw> pPropertyBrowser; private: void AddPropertyBrowser (); @@ -56,7 +56,7 @@ class Shell : public DocumentEventListener { public: - typedef std::map<sal_uInt16, BaseWindow*> WindowTable; + typedef std::map<sal_uInt16, VclPtr<BaseWindow> > WindowTable; typedef WindowTable::const_iterator WindowTableIt; private: @@ -64,26 +64,26 @@ private: friend class LocalizationMgr; friend bool implImportDialog( vcl::Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& aLibName ); // defined in baside3.cxx - WindowTable aWindowTable; + WindowTable aWindowTable; sal_uInt16 nCurKey; - BaseWindow* pCurWin; + VclPtr<BaseWindow> pCurWin; ScriptDocument m_aCurDocument; OUString m_aCurLibName; boost::shared_ptr<LocalizationMgr> m_pCurLocalizationMgr; - ScrollBar aHScrollBar; - ScrollBar aVScrollBar; - ScrollBarBox aScrollBarBox; - boost::scoped_ptr<TabBar> pTabBar; // basctl::TabBar + VclPtr<ScrollBar> aHScrollBar; + VclPtr<ScrollBar> aVScrollBar; + VclPtr<ScrollBarBox> aScrollBarBox; + VclPtr<TabBar> pTabBar; // basctl::TabBar bool bTabBarSplitted; bool bCreatingWindow; // layout windows - boost::scoped_ptr<ModulWindowLayout> pModulLayout; - boost::scoped_ptr<DialogWindowLayout> pDialogLayout; + VclPtr<ModulWindowLayout> pModulLayout; + VclPtr<DialogWindowLayout> pDialogLayout; // the active layout window - Layout* pLayout; + VclPtr<Layout> pLayout; // common object catalog window - ObjectCatalog aObjectCatalog; + VclPtr<ObjectCatalog> aObjectCatalog; bool m_bAppBasicModified; DocumentEventNotifier m_aNotifier; @@ -163,9 +163,9 @@ public: OUString const& GetCurLibName() const { return m_aCurLibName; } boost::shared_ptr<LocalizationMgr> GetCurLocalizationMgr() const { return m_pCurLocalizationMgr; } - ScrollBar& GetHScrollBar() { return aHScrollBar; } - ScrollBar& GetVScrollBar() { return aVScrollBar; } - ScrollBarBox& GetScrollBarBox() { return aScrollBarBox; } + ScrollBar& GetHScrollBar() { return *aHScrollBar.get(); } + ScrollBar& GetVScrollBar() { return *aVScrollBar.get(); } + ScrollBarBox& GetScrollBarBox() { return *aScrollBarBox.get(); } TabBar& GetTabBar() { return *pTabBar; } WindowTable& GetWindowTable() { return aWindowTable; } sal_uInt16 GetWindowId (BaseWindow const* pWin) const; @@ -212,7 +212,7 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetCurrentDocument() const SAL_OVERRIDE; - void UpdateObjectCatalog () { aObjectCatalog.UpdateEntries(); } + void UpdateObjectCatalog () { aObjectCatalog->UpdateEntries(); } void RemoveWindow (BaseWindow* pWindow, bool bDestroy, bool bAllowChangeCurWindow = true); }; @@ -81,7 +81,8 @@ class DockingWindow : public ::DockingWindow public: DockingWindow (vcl::Window* pParent); DockingWindow (Layout* pParent); -public: + virtual ~DockingWindow(); + virtual void dispose() SAL_OVERRIDE; void ResizeIfDocking (Point const&, Size const&); void ResizeIfDocking (Size const&); Size GetDockingSize () const { return aDockingRect.GetSize(); } @@ -103,7 +104,7 @@ private: // the position and the size of the docking window Rectangle aDockingRect; // the parent layout window (only when docking) - Layout* pLayout; + VclPtr<Layout> pLayout; // > 0: shown, <= 0: hidden, ++ by Show() and -- by Hide() int nShowCount; @@ -149,8 +150,8 @@ class EntryDescriptor; class BaseWindow : public vcl::Window { private: - ScrollBar* pShellHScrollBar; - ScrollBar* pShellVScrollBar; + VclPtr<ScrollBar> pShellHScrollBar; + VclPtr<ScrollBar> pShellVScrollBar; DECL_LINK( ScrollHdl, ScrollBar * ); int nStatus; @@ -169,6 +170,7 @@ public: TYPEINFO(); BaseWindow( vcl::Window* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName ); virtual ~BaseWindow(); + virtual void dispose() SAL_OVERRIDE; void Init(); virtual void DoInit(); @@ -30,6 +30,7 @@ #include <tools/gen.hxx> #include <vcl/timer.hxx> #include <vcl/idle.hxx> +#include <vcl/vclptr.hxx> #include <boost/scoped_ptr.hpp> @@ -106,8 +107,8 @@ private: static void Print( Printer* pPrinter, const OUString& rTitle ); private: - ScrollBar* pHScroll; - ScrollBar* pVScroll; + VclPtr<ScrollBar> pHScroll; + VclPtr<ScrollBar> pVScroll; boost::scoped_ptr<DlgEdModel> pDlgEdModel; // never nullptr DlgEdPage* pDlgEdPage; // never nullptr boost::scoped_ptr<DlgEdView> pDlgEdView; // never nullptr @@ -52,10 +52,10 @@ extern bool localesAreEqual( const ::com::sun::star::lang::Locale& rLocaleLeft, class ManageLanguageDialog : public ModalDialog { private: - ListBox* m_pLanguageLB; - PushButton* m_pAddPB; - PushButton* m_pDeletePB; - PushButton* m_pMakeDefPB; + VclPtr<ListBox> m_pLanguageLB; + VclPtr<PushButton> m_pAddPB; + VclPtr<PushButton> m_pDeletePB; + VclPtr<PushButton> m_pMakeDefPB; boost::shared_ptr<LocalizationMgr> m_xLocalizationMgr; @@ -74,17 +74,18 @@ private: public: ManageLanguageDialog( vcl::Window* pParent, boost::shared_ptr<LocalizationMgr> _pLMgr ); virtual ~ManageLanguageDialog(); + virtual void dispose() SAL_OVERRIDE; }; class SetDefaultLanguageDialog : public ModalDialog { private: - FixedText* m_pLanguageFT; - SvxLanguageBox* m_pLanguageLB; - FixedText* m_pCheckLangFT; - SvxCheckListBox* m_pCheckLangLB; - FixedText* m_pDefinedFT; - FixedText* m_pAddedFT; + VclPtr<FixedText> m_pLanguageFT; + VclPtr<SvxLanguageBox> m_pLanguageLB; + VclPtr<FixedText> m_pCheckLangFT; + VclPtr<SvxCheckListBox> m_pCheckLangLB; + VclPtr<FixedText> m_pDefinedFT; + VclPtr<FixedText> m_pAddedFT; boost::shared_ptr<LocalizationMgr> m_xLocalizationMgr; @@ -92,6 +93,8 @@ private: public: SetDefaultLanguageDialog(vcl::Window* pParent, boost::shared_ptr<LocalizationMgr> xLMgr); + virtual ~SetDefaultLanguageDialog(); + virtual void dispose() SAL_OVERRIDE; ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > GetLocales() const; }; @@ -75,6 +75,7 @@ protected: public: explicit PropBrw (DialogWindowLayout&); virtual ~PropBrw(); + virtual void dispose() SAL_OVERRIDE; using Window::Update; // note: changing the Context document to an instance other than the one given in the ctor is not supported // currently @@ -30,10 +30,10 @@ class SvRTLInputBox : public ModalDialog { - Edit aEdit; - OKButton aOk; - CancelButton aCancel; - FixedText aPromptText; + VclPtr<Edit> aEdit; + VclPtr<OKButton> aOk; + VclPtr<CancelButton> aCancel; + VclPtr<FixedText> aPromptText; OUString aText; void PositionDialog( long nXTwips, long nYTwips, const Size& rDlgSize ); @@ -46,6 +46,8 @@ class SvRTLInputBox : public ModalDialog public: SvRTLInputBox( vcl::Window* pParent, const OUString& rPrompt, const OUString& rTitle, const OUString& rDefault, long nXTwips = -1, long nYTwips = -1 ); + virtual ~SvRTLInputBox() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE; OUString GetText() const SAL_OVERRIDE { return aText; } }; @@ -53,8 +55,8 @@ SvRTLInputBox::SvRTLInputBox( vcl::Window* pParent, const OUString& rPrompt, const OUString& rTitle, const OUString& rDefault, long nXTwips, long nYTwips ) : ModalDialog( pParent,WB_3DLOOK | WB_MOVEABLE | WB_CLOSEABLE ), - aEdit( this, WB_LEFT | WB_BORDER ), - aOk( this ), aCancel( this ), aPromptText( this, WB_WORDBREAK ) + aEdit( VclPtr<Edit>::Create(this, WB_LEFT | WB_BORDER) ), + aOk( new OKButton(this) ), aCancel( new CancelButton(this) ), aPromptText( VclPtr<FixedText>::Create(this, WB_WORDBREAK) ) { SetMapMode( MapMode( MAP_APPFONT ) ); Size aDlgSizeApp( 280, 80 ); @@ -62,29 +64,38 @@ SvRTLInputBox::SvRTLInputBox( vcl::Window* pParent, const OUString& rPrompt, InitButtons( aDlgSizeApp ); PositionEdit( aDlgSizeApp ); PositionPrompt( rPrompt, aDlgSizeApp ); - aOk.Show(); - aCancel.Show(); - aEdit.Show(); - aPromptText.Show(); + aOk->Show(); + aCancel->Show(); + aEdit->Show(); + aPromptText->Show(); SetText( rTitle ); vcl::Font aFont( GetFont()); Color aColor( GetBackground().GetColor() ); aFont.SetFillColor( aColor ); - aEdit.SetFont( aFont ); - aEdit.SetText( rDefault ); - aEdit.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); + aEdit->SetFont( aFont ); + aEdit->SetText( rDefault ); + aEdit->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); +} + +void SvRTLInputBox::dispose() +{ + aEdit.disposeAndClear(); + aOk.disposeAndClear(); + aCancel.disposeAndClear(); + aPromptText.disposeAndClear(); + ModalDialog::dispose(); } void SvRTLInputBox::InitButtons( const Size& rDlgSize ) { - aOk.SetSizePixel( LogicToPixel( Size( 45, 15) )); - aCancel.SetSizePixel( LogicToPixel( Size( 45, 15) )); + aOk->SetSizePixel( LogicToPixel( Size( 45, 15) )); + aCancel->SetSizePixel( LogicToPixel( Size( 45, 15) )); Point aPos( rDlgSize.Width()-45-10, 5 ); - aOk.SetPosPixel( LogicToPixel( Point(aPos) )); + aOk->SetPosPixel( LogicToPixel( Point(aPos) )); aPos.Y() += 16; - aCancel.SetPosPixel( LogicToPixel( Point(aPos) )); - aOk.SetClickHdl(LINK(this,SvRTLInputBox, OkHdl)); - aCancel.SetClickHdl(LINK(this,SvRTLInputBox,CancelHdl)); + aCancel->SetPosPixel( LogicToPixel( Point(aPos) )); + aOk->SetClickHdl(LINK(this,SvRTLInputBox, OkHdl)); + aCancel->SetClickHdl(LINK(this,SvRTLInputBox,CancelHdl)); } void SvRTLInputBox::PositionDialog(long nXTwips, long nYTwips, const Size& rDlgSize) @@ -99,8 +110,8 @@ void SvRTLInputBox::PositionDialog(long nXTwips, long nYTwips, const Size& rDlgS void SvRTLInputBox::PositionEdit( const Size& rDlgSize ) { - aEdit.SetPosPixel( LogicToPixel( Point( 5,rDlgSize.Height()-35))); - aEdit.SetSizePixel( LogicToPixel( Size(rDlgSize.Width()-15,12))); + aEdit->SetPosPixel( LogicToPixel( Point( 5,rDlgSize.Height()-35))); + aEdit->SetSizePixel( LogicToPixel( Size(rDlgSize.Width()-15,12))); } @@ -109,12 +120,12 @@ void SvRTLInputBox::PositionPrompt(const OUString& rPrompt,const Size& rDlgSize) if ( rPrompt.isEmpty() ) return; OUString aText_(convertLineEnd(rPrompt, LINEEND_CR)); - aPromptText.SetPosPixel( LogicToPixel(Point(5,5))); - aPromptText.SetText( aText_ ); + aPromptText->SetPosPixel( LogicToPixel(Point(5,5))); + aPromptText->SetText( aText_ ); Size aSize( rDlgSize ); aSize.Width() -= 70; aSize.Height() -= 50; - aPromptText.SetSizePixel( LogicToPixel(aSize)); + aPromptText->SetSizePixel( LogicToPixel(aSize)); } @@ -122,7 +133,7 @@ IMPL_LINK_INLINE_START( SvRTLInputBox, OkHdl, Button *, pButton ) { (void)pButton; - aText = aEdit.GetText(); + aText = aEdit->GetText(); EndDialog( 1 ); return 0; } @@ -172,8 +183,8 @@ RTLFUNC(InputBox) nX = rPar.Get(4)->GetLong(); nY = rPar.Get(5)->GetLong(); } - boost::scoped_ptr<SvRTLInputBox> pDlg(new SvRTLInputBox(Application::GetDefDialogParent(), - rPrompt,aTitle,aDefault,nX,nY)); + VclPtrInstance<SvRTLInputBox> pDlg(Application::GetDefDialogParent(), + rPrompt,aTitle,aDefault,nX,nY); pDlg->Execute(); rPar.Get(0)->PutString( pDlg->GetText() ); } @@ -66,25 +66,27 @@ using namespace com::sun::star::bridge; class SbiInputDialog : public ModalDialog { - Edit aInput; - OKButton aOk; - CancelButton aCancel; + VclPtr<Edit> aInput; + VclPtr<OKButton> aOk; + VclPtr<CancelButton> aCancel; OUString aText; DECL_LINK( Ok, vcl::Window * ); DECL_LINK( Cancel, vcl::Window * ); public: SbiInputDialog( vcl::Window*, const OUString& ); + virtual ~SbiInputDialog() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE; const OUString& GetInput() { return aText; } }; SbiInputDialog::SbiInputDialog( vcl::Window* pParent, const OUString& rPrompt ) :ModalDialog( pParent, WB_3DLOOK | WB_MOVEABLE | WB_CLOSEABLE ), - aInput( this, WB_3DLOOK | WB_LEFT | WB_BORDER ), - aOk( this ), aCancel( this ) + aInput( VclPtr<Edit>::Create(this, WB_3DLOOK | WB_LEFT | WB_BORDER) ), + aOk( new OKButton(this) ), aCancel( VclPtr<CancelButton>::Create(this) ) { SetText( rPrompt ); - aOk.SetClickHdl( LINK( this, SbiInputDialog, Ok ) ); - aCancel.SetClickHdl( LINK( this, SbiInputDialog, Cancel ) ); + aOk->SetClickHdl( LINK( this, SbiInputDialog, Ok ) ); + aCancel->SetClickHdl( LINK( this, SbiInputDialog, Cancel ) ); SetMapMode( MapMode( MAP_APPFONT ) ); Point aPt = LogicToPixel( Point( 50, 50 ) ); @@ -92,24 +94,32 @@ SbiInputDialog::SbiInputDialog( vcl::Window* pParent, const OUString& rPrompt ) SetPosSizePixel( aPt, aSz ); aPt = LogicToPixel( Point( 10, 10 ) ); aSz = LogicToPixel( Size( 120, 12 ) ); - aInput.SetPosSizePixel( aPt, aSz ); + aInput->SetPosSizePixel( aPt, aSz ); aPt = LogicToPixel( Point( 15, 30 ) ); aSz = LogicToPixel( Size( 45, 15) ); - aOk.SetPosSizePixel( aPt, aSz ); + aOk->SetPosSizePixel( aPt, aSz ); aPt = LogicToPixel( Point( 80, 30 ) ); aSz = LogicToPixel( Size( 45, 15) ); - aCancel.SetPosSizePixel( aPt, aSz ); + aCancel->SetPosSizePixel( aPt, aSz ); - aInput.Show(); - aOk.Show(); - aCancel.Show(); + aInput->Show(); + aOk->Show(); + aCancel->Show(); +} + +void SbiInputDialog::dispose() +{ + aInput.disposeAndClear(); + aOk.disposeAndClear(); + aCancel.disposeAndClear(); + ModalDialog::dispose(); } IMPL_LINK_INLINE_START( SbiInputDialog, Ok, vcl::Window *, pWindow ) { (void)pWindow; - aText = aInput.GetText(); + aText = aInput->GetText(); EndDialog( 1 ); return 0; } @@ -956,10 +966,10 @@ void SbiIoSystem::CloseAll() void SbiIoSystem::ReadCon(OString& rIn) { OUString aPromptStr(OStringToOUString(aPrompt, osl_getThreadTextEncoding())); - SbiInputDialog aDlg( NULL, aPromptStr ); - if( aDlg.Execute() ) + ScopedVclPtrInstance< SbiInputDialog > aDlg(nullptr, aPromptStr); + if( aDlg->Execute() ) { - rIn = OUStringToOString(aDlg.GetInput(), osl_getThreadTextEncoding()); + rIn = OUStringToOString(aDlg->GetInput(), osl_getThreadTextEncoding()); } else { @@ -4611,7 +4611,7 @@ RTLFUNC(MsgBox) } nType &= (16+32+64); - boost::scoped_ptr<MessBox> pBox; + VclPtr<MessBox> pBox; SolarMutexGuard aSolarGuard; @@ -4619,19 +4619,19 @@ RTLFUNC(MsgBox) switch( nType ) { case 16: - pBox.reset(new ErrorBox( pParent, nWinBits, aMsg )); + pBox.reset(VclPtr<ErrorBox>::Create( pParent, nWinBits, aMsg )); break; case 32: - pBox.reset(new QueryBox( pParent, nWinBits, aMsg )); + pBox.reset(VclPtr<QueryBox>::Create( pParent, nWinBits, aMsg )); break; case 48: - pBox.reset(new WarningBox( pParent, nWinBits, aMsg )); + pBox.reset(VclPtr<WarningBox>::Create( pParent, nWinBits, aMsg )); break; case 64: - pBox.reset(new InfoBox( pParent, nWinBits, aMsg )); + pBox.reset(VclPtr<InfoBox>::Create( pParent, nWinBits, aMsg )); break; default: - pBox.reset(new MessBox( pParent, nWinBits, aTitle, aMsg )); + pBox.reset(VclPtr<MessBox>::Create( pParent, nWinBits, aTitle, aMsg )); } pBox->SetText( aTitle ); short nRet = pBox->Execute(); @@ -63,7 +63,7 @@ namespace cairocanvas // adjust to stretched/shrunk font if( !::rtl::math::approxEqual( rFontMatrix.m00, rFontMatrix.m11) ) { - OutputDevice* pOutDev( mpRefDevice->getOutputDevice() ); + VclPtr<OutputDevice> pOutDev( mpRefDevice->getOutputDevice() ); if( pOutDev ) { @@ -83,7 +83,7 @@ namespace cairocanvas { mpSurface.reset(); mpCairo.reset(); - mpVirtualDevice.reset(); + mpVirtualDevice.disposeAndClear(); mpDevice = NULL; mpSurfaceProvider = NULL; } @@ -105,7 +105,7 @@ namespace cairocanvas void CanvasHelper::setSurface( const SurfaceSharedPtr& pSurface, bool bHasAlpha ) { mbHaveAlpha = bHasAlpha; - mpVirtualDevice.reset(); + mpVirtualDevice.disposeAndClear(); mpSurface = pSurface; mpCairo = pSurface->getCairo(); } @@ -28,6 +28,8 @@ #include <basegfx/vector/b2dsize.hxx> #include <com/sun/star/rendering/XLinePolyPolygon2D.hpp> +#include <vcl/vclptr.hxx> +#include <vcl/virdev.hxx> #include <boost/utility.hpp> #include <vcl/cairo.hxx> @@ -269,7 +271,7 @@ namespace cairocanvas private: - boost::shared_ptr<VirtualDevice> mpVirtualDevice; + VclPtr<VirtualDevice> mpVirtualDevice; void useStates( const ::com::sun::star::rendering::ViewState& viewState, const ::com::sun::star::rendering::RenderState& renderState, @@ -175,7 +175,7 @@ namespace cairocanvas class DeviceSettingsGuard { private: - OutputDevice *mpVirtualDevice; + VclPtr<OutputDevice> mpVirtualDevice; cairo_t *mpCairo; bool mbMappingWasEnabled; public: @@ -272,7 +272,7 @@ namespace cairocanvas cairo_fill(mpCairo.get()); #endif ::Point aOutpos; - if( !setupTextOutput( *mpVirtualDevice, pOwner, aOutpos, viewState, renderState, xFont ) ) + if( !setupTextOutput( *mpVirtualDevice.get(), pOwner, aOutpos, viewState, renderState, xFont ) ) return uno::Reference< rendering::XCachedPrimitive >(NULL); // no output necessary // change text direction and layout mode @@ -209,7 +209,7 @@ namespace cairocanvas uno::Any DeviceHelper::getDeviceHandle() const { - return uno::makeAny( reinterpret_cast< sal_Int64 >(mpRefDevice) ); + return uno::makeAny( reinterpret_cast< sal_Int64 >(mpRefDevice.get()) ); } uno::Any DeviceHelper::getSurfaceHandle() const @@ -116,7 +116,7 @@ namespace cairocanvas */ SurfaceProvider* mpSurfaceProvider; - OutputDevice* mpRefDevice; + VclPtr<OutputDevice> mpRefDevice; ::cairo::SurfaceSharedPtr mpSurface; }; } @@ -179,14 +179,14 @@ namespace cairocanvas if( !pOutDev ) return geometry::RealRectangle2D(); - VirtualDevice aVDev( *pOutDev ); - aVDev.SetFont( mpFont->getVCLFont() ); + ScopedVclPtrInstance< VirtualDevice > pVDev( *pOutDev ); + pVDev->SetFont( mpFont->getVCLFont() ); // need metrics for Y offset, the XCanvas always renders // relative to baseline - const ::FontMetric& aMetric( aVDev.GetFontMetric() ); + const ::FontMetric& aMetric( pVDev->GetFontMetric() ); - setupLayoutMode( aVDev, mnTextDirection ); + setupLayoutMode( *pVDev.get(), mnTextDirection ); const sal_Int32 nAboveBaseline( -aMetric.GetIntLeading() - aMetric.GetAscent() ); const sal_Int32 nBelowBaseline( aMetric.GetDescent() ); @@ -200,7 +200,7 @@ namespace cairocanvas else { return geometry::RealRectangle2D( 0, nAboveBaseline, - aVDev.GetTextWidth( + pVDev->GetTextWidth( maText.Text, ::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition), ::canvas::tools::numeric_cast<sal_uInt16>(maText.Length) ), @@ -666,7 +666,8 @@ namespace dxcanvas maVertexCache.reserve(1024); mpWindow.reset( - new SystemChildWindow( + VclPtr<SystemChildWindow>::Create( + const_cast<vcl::Window *>(&rWindow), 0) ); // system child window must not receive mouse events @@ -52,6 +52,10 @@ namespace dxcanvas { } + DeviceHelper::~DeviceHelper() + { + } + void DeviceHelper::init( HDC hdc, OutputDevice* pOutDev, rendering::XGraphicDevice& rDevice ) { @@ -191,7 +195,7 @@ namespace dxcanvas uno::Any DeviceHelper::getDeviceHandle() const { - return uno::makeAny( reinterpret_cast< sal_Int64 >(mpOutDev) ); + return uno::makeAny( reinterpret_cast< sal_Int64 >(mpOutDev.get()) ); } uno::Any DeviceHelper::getSurfaceHandle() const @@ -28,7 +28,7 @@ #include "dx_bitmap.hxx" #include <canvas/rendering/isurfaceproxymanager.hxx> - +#include <vcl/vclptr.hxx> #include <boost/utility.hpp> class OutputDevice; @@ -40,6 +40,7 @@ namespace dxcanvas { public: DeviceHelper(); + ~DeviceHelper(); /** Init the device helper @@ -105,7 +106,7 @@ namespace dxcanvas */ com::sun::star::rendering::XGraphicDevice* mpDevice; HDC mnHDC; - OutputDevice* mpOutDev; + VclPtr<OutputDevice> mpOutDev; }; typedef ::rtl::Reference< com::sun::star::rendering::XGraphicDevice > DeviceRef; @@ -725,8 +725,8 @@ namespace oglcanvas if( mpDevice ) { - VirtualDevice aVDev; - aVDev.EnableOutput(false); + ScopedVclPtrInstance< VirtualDevice > pVDev; + pVDev->EnableOutput(false); CanvasFont* pFont=dynamic_cast<CanvasFont*>(xLayoutetText->getFont().get()); const rendering::StringContext& rTxt=xLayoutetText->getText(); @@ -749,7 +749,7 @@ namespace oglcanvas // adjust to stretched font if(!::rtl::math::approxEqual(rFontMatrix.m00, rFontMatrix.m11)) { - const Size aSize = aVDev.GetFontMetric( aFont ).GetSize(); + const Size aSize = pVDev->GetFontMetric( aFont ).GetSize(); const double fDividend( rFontMatrix.m10 + rFontMatrix.m11 ); double fStretch = (rFontMatrix.m00 + rFontMatrix.m01); @@ -762,7 +762,7 @@ namespace oglcanvas } // set font - aVDev.SetFont(aFont); + pVDev->SetFont(aFont); mpRecordedActions->push_back( Action() ); Action& rAct=mpRecordedActions->back(); @@ -780,7 +780,7 @@ namespace oglcanvas pDXArray[i] = basegfx::fround( aLogicalAdvancements[i] ); // get the glyphs - aVDev.GetTextOutlines(rAct.maPolyPolys, + pVDev->GetTextOutlines(rAct.maPolyPolys, rTxt.Text, 0, rTxt.StartPosition, @@ -792,7 +792,7 @@ namespace oglcanvas else { // get the glyphs - aVDev.GetTextOutlines(rAct.maPolyPolys, + pVDev->GetTextOutlines(rAct.maPolyPolys, rTxt.Text, 0, rTxt.StartPosition, @@ -25,7 +25,7 @@ namespace vclcanvas { BackBuffer::BackBuffer( const OutputDevice& rRefDevice, bool bMonochromeBuffer ) : - maVDev( new VirtualDevice( rRefDevice, + maVDev( VclPtr<VirtualDevice>::Create( rRefDevice, sal_uInt16(bMonochromeBuffer) ) ) { if( !bMonochromeBuffer ) @@ -43,14 +43,20 @@ namespace vclcanvas } } + BackBuffer::~BackBuffer() + { + SolarMutexGuard aGuard; + maVDev.disposeAndClear(); + } + OutputDevice& BackBuffer::getOutDev() { - return maVDev.get(); + return *maVDev.get(); } const OutputDevice& BackBuffer::getOutDev() const { - return maVDev.get(); + return *maVDev.get(); } void BackBuffer::setSize( const ::Size& rNewSize ) @@ -43,6 +43,7 @@ namespace vclcanvas */ BackBuffer( const OutputDevice& rRefDevice, bool bMonochromeBuffer=false ); + virtual ~BackBuffer(); virtual OutputDevice& getOutDev() SAL_OVERRIDE; virtual const OutputDevice& getOutDev() const SAL_OVERRIDE; @@ -50,7 +51,7 @@ namespace vclcanvas void setSize( const ::Size& rNewSize ); private: - ::canvas::vcltools::VCLObject<VirtualDevice> maVDev; + VclPtr< VirtualDevice > maVDev; }; typedef ::boost::shared_ptr< BackBuffer > BackBufferSharedPtr; @@ -45,8 +45,7 @@ namespace vclcanvas // are supposed to be called with already locked solar mutex) SolarMutexGuard aGuard; - if( mpVDev ) - delete mpVDev; + mpVDev.disposeAndClear(); } OutputDevice& BitmapBackBuffer::getOutDev() @@ -113,8 +112,8 @@ namespace vclcanvas // VDev not yet created, do it now. Create an alpha-VDev, // if bitmap has transparency. mpVDev = maBitmap->IsTransparent() ? - new VirtualDevice( mrRefDevice, 0, 0 ) : - new VirtualDevice( mrRefDevice ); + VclPtr<VirtualDevice>::Create( mrRefDevice, 0, 0 ) : + VclPtr<VirtualDevice>::Create( mrRefDevice ); OSL_ENSURE( mpVDev, "BitmapBackBuffer::createVDev(): Unable to create VirtualDevice" ); @@ -66,7 +66,7 @@ namespace vclcanvas void updateVDev() const; ::canvas::vcltools::VCLObject<BitmapEx> maBitmap; - mutable VirtualDevice* mpVDev; // created only on demand + mutable VclPtr<VirtualDevice> mpVDev; // created only on demand const OutputDevice& mrRefDevice; @@ -121,9 +121,9 @@ namespace vclcanvas SolarMutexGuard aGuard; OutputDevice& rOutDev = mpOutDevProvider->getOutDev(); - VirtualDevice aVDev( rOutDev ); - aVDev.SetFont(getVCLFont()); - const ::FontMetric& aMetric( aVDev.GetFontMetric() ); + ScopedVclPtrInstance< VirtualDevice > pVDev( rOutDev ); + pVDev->SetFont(getVCLFont()); + const ::FontMetric& aMetric( pVDev->GetFontMetric() ); return rendering::FontMetrics( aMetric.GetAscent(), @@ -1026,8 +1026,8 @@ namespace vclcanvas // cannot do direct XOR, but have to // prepare the filled polygon within a // VDev - VirtualDevice aVDev( rOutDev ); - aVDev.SetOutputSizePixel( aPolygonDeviceRect.GetSize() ); + ScopedVclPtrInstance< VirtualDevice > pVDev( rOutDev ); + pVDev->SetOutputSizePixel( aPolygonDeviceRect.GetSize() ); // shift output to origin of VDev const ::Point aOutPos( aPt - aPolygonDeviceRect.TopLeft() ); @@ -1036,8 +1036,8 @@ namespace vclcanvas const vcl::Region aPolyClipRegion( aPolyPoly ); - aVDev.SetClipRegion( aPolyClipRegion ); - textureFill( aVDev, + pVDev->SetClipRegion( aPolyClipRegion ); + textureFill( *pVDev.get(), *pGrfObj, aOutPos, aIntegerNextTileX, @@ -1051,12 +1051,12 @@ namespace vclcanvas // target position. const ::Point aEmptyPoint; Bitmap aContentBmp( - aVDev.GetBitmap( aEmptyPoint, - aVDev.GetOutputSizePixel() ) ); + pVDev->GetBitmap( aEmptyPoint, + pVDev->GetOutputSizePixel() ) ); sal_uInt8 nCol( static_cast< sal_uInt8 >( ::basegfx::fround( 255.0*( 1.0 - textures[0].Alpha ) ) ) ); - AlphaMask aAlpha( aVDev.GetOutputSizePixel(), + AlphaMask aAlpha( pVDev->GetOutputSizePixel(), &nCol ); BitmapEx aOutputBmpEx( aContentBmp, aAlpha ); @@ -158,7 +158,7 @@ namespace vclcanvas } } - OutputDevice* mpOutDev; + VclPtr<OutputDevice> mpOutDev; const bool mbMappingWasEnabled; const sal_uInt16 mnAntiAliasing; }; @@ -189,6 +189,12 @@ namespace vclcanvas #endif } + SpriteCanvasHelper::~SpriteCanvasHelper() + { + SolarMutexGuard aGuard; + maVDev.disposeAndClear(); + } + void SpriteCanvasHelper::init( const OutDevProviderSharedPtr& rOutDev, SpriteCanvas& rOwningSpriteCanvas, ::canvas::SpriteRedrawManager& rManager, @@ -318,7 +324,7 @@ namespace vclcanvas mpRedrawManager->forEachSprite( ::boost::bind( &spriteRedraw, - ::boost::ref( maVDev.get() ), + ::boost::ref( *maVDev.get() ), _1 ) ); // flush to screen @@ -576,7 +582,7 @@ namespace vclcanvas ::std::for_each( rSortedUpdateSprites.begin(), rSortedUpdateSprites.end(), ::boost::bind( &spriteRedrawStub2, - ::boost::ref( maVDev.get() ), + ::boost::ref( *maVDev.get() ), ::vcl::unotools::b2DPointFromPoint( aOutputPosition), _1 ) ); @@ -23,6 +23,7 @@ #include <com/sun/star/rendering/XSpriteCanvas.hpp> #include <com/sun/star/rendering/XIntegerBitmap.hpp> +#include <vcl/vclptr.hxx> #include <vcl/virdev.hxx> #include <canvas/spriteredrawmanager.hxx> @@ -40,6 +41,7 @@ namespace vclcanvas { public: SpriteCanvasHelper(); + ~SpriteCanvasHelper(); void init( const OutDevProviderSharedPtr& rOutDev, SpriteCanvas& rOwningSpriteCanvas, @@ -150,7 +152,7 @@ namespace vclcanvas Typically, sprites will be composited in the background, before pushing them to screen. This happens here. */ - ::canvas::vcltools::VCLObject< VirtualDevice > maVDev; + VclPtr< VirtualDevice > maVDev; /// For the frame counter timings ::canvas::tools::ElapsedTime maLastUpdate; @@ -104,10 +104,10 @@ namespace vclcanvas SolarMutexGuard aGuard; OutputDevice& rOutDev = mpOutDevProvider->getOutDev(); - VirtualDevice aVDev( rOutDev ); - aVDev.SetFont( mpFont->getVCLFont() ); + ScopedVclPtrInstance< VirtualDevice > pVDev( rOutDev ); + pVDev->SetFont( mpFont->getVCLFont() ); - setupLayoutMode( aVDev, mnTextDirection ); + setupLayoutMode( *pVDev.get(), mnTextDirection ); const rendering::ViewState aViewState( geometry::AffineMatrix2D(1,0,0, 0,1,0), @@ -124,7 +124,7 @@ namespace vclcanvas uno::Sequence< uno::Reference< rendering::XPolyPolygon2D> > aOutlineSequence; ::basegfx::B2DPolyPolygonVector aOutlines; - if (aVDev.GetTextOutlines( + if (pVDev->GetTextOutlines( aOutlines, maText.Text, maText.StartPosition, @@ -157,10 +157,10 @@ namespace vclcanvas OutputDevice& rOutDev = mpOutDevProvider->getOutDev(); - VirtualDevice aVDev( rOutDev ); - aVDev.SetFont( mpFont->getVCLFont() ); + ScopedVclPtrInstance< VirtualDevice > pVDev( rOutDev ); + pVDev->SetFont( mpFont->getVCLFont() ); - setupLayoutMode( aVDev, mnTextDirection ); + setupLayoutMode( *pVDev.get(), mnTextDirection ); const rendering::ViewState aViewState( geometry::AffineMatrix2D(1,0,0, 0,1,0), @@ -177,7 +177,7 @@ namespace vclcanvas MetricVector aMetricVector; uno::Sequence<geometry::RealRectangle2D> aBoundingBoxes; - if (aVDev.GetGlyphBoundRects( + if (pVDev->GetGlyphBoundRects( Point(0,0), maText.Text, ::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition), @@ -237,14 +237,14 @@ namespace vclcanvas OutputDevice& rOutDev = mpOutDevProvider->getOutDev(); - VirtualDevice aVDev( rOutDev ); - aVDev.SetFont( mpFont->getVCLFont() ); + ScopedVclPtrInstance< VirtualDevice > pVDev( rOutDev ); + pVDev->SetFont( mpFont->getVCLFont() ); // need metrics for Y offset, the XCanvas always renders // relative to baseline - const ::FontMetric& aMetric( aVDev.GetFontMetric() ); + const ::FontMetric& aMetric( pVDev->GetFontMetric() ); - setupLayoutMode( aVDev, mnTextDirection ); + setupLayoutMode( *pVDev.get(), mnTextDirection ); const sal_Int32 nAboveBaseline( /*-aMetric.GetIntLeading()*/ - aMetric.GetAscent() ); const sal_Int32 nBelowBaseline( aMetric.GetDescent() ); @@ -258,7 +258,7 @@ namespace vclcanvas else { return geometry::RealRectangle2D( 0, nAboveBaseline, - aVDev.GetTextWidth( + pVDev->GetTextWidth( maText.Text, ::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition), ::canvas::tools::numeric_cast<sal_uInt16>(maText.Length) ), @@ -618,7 +618,7 @@ private: sal_Int32 mnStart; sal_Int32 mnEnd; bool bSet; - OpenGLWindow* mpOpenGLWindow; + VclPtr<OpenGLWindow> mpOpenGLWindow; }; } // namespace chart @@ -20,6 +20,7 @@ #define INCLUDED_CHART2_SOURCE_CONTROLLER_ACCESSIBILITY_ACCESSIBLEVIEWFORWARDER_HXX #include <vcl/mapmod.hxx> +#include <vcl/vclptr.hxx> #include <svx/IAccessibleViewForwarder.hxx> namespace vcl { class Window; } @@ -48,7 +49,7 @@ private: AccessibleViewForwarder& operator=( AccessibleViewForwarder& ) SAL_DELETED_FUNCTION; AccessibleChartView* m_pAccChartView; - vcl::Window* m_pWindow; + VclPtr<vcl::Window> m_pWindow; MapMode m_aMapMode; }; @@ -281,8 +281,8 @@ private: DECL_LINK( ChangeLineCountHdl, void* ); private: - FixedText* m_pFT_NumberOfLines; - NumericField* m_pMF_NumberOfLines; + VclPtr<FixedText> m_pFT_NumberOfLines; + VclPtr<NumericField> m_pMF_NumberOfLines; }; class BubbleChartDialogController : public ChartTypeDialogController @@ -102,7 +102,6 @@ class SeriesHeaderEdit : public Edit { public: SeriesHeaderEdit( vcl::Window * pParent ); - virtual ~SeriesHeaderEdit(); virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; void setStartColumn( sal_Int32 nStartColumn ); @@ -122,9 +121,6 @@ SeriesHeaderEdit::SeriesHeaderEdit( vcl::Window * pParent ) : SetHelpId(HID_SCH_DATA_SERIES_LABEL); } -SeriesHeaderEdit::~SeriesHeaderEdit() -{} - void SeriesHeaderEdit::setStartColumn( sal_Int32 nStartColumn ) { m_nStartColumn = nStartColumn; @@ -182,11 +178,11 @@ public: bool HasFocus() const; private: - ::boost::shared_ptr< FixedImage > m_spSymbol; - ::boost::shared_ptr< SeriesHeaderEdit > m_spSeriesName; - ::boost::shared_ptr< FixedText > m_spColorBar; - OutputDevice * m_pDevice; - Link m_aChangeLink; + VclPtr< FixedImage > m_spSymbol; + VclPtr< SeriesHeaderEdit > m_spSeriesName; + VclPtr< FixedText > m_spColorBar; + VclPtr< OutputDevice> m_pDevice; + Link m_aChangeLink; void notifyChanges(); DECL_LINK( SeriesNameChanged, void * ); @@ -204,9 +200,9 @@ private: }; SeriesHeader::SeriesHeader( vcl::Window * pParent, vcl::Window *pColorParent ) : - m_spSymbol( new FixedImage( pParent, WB_NOBORDER )), - m_spSeriesName( new SeriesHeaderEdit( pParent )), - m_spColorBar( new FixedText( pColorParent, WB_NOBORDER )), + m_spSymbol( VclPtr<FixedImage>::Create( pParent, WB_NOBORDER )), + m_spSeriesName( VclPtr<SeriesHeaderEdit>::Create( pParent )), + m_spColorBar( VclPtr<FixedText>::Create( pColorParent, WB_NOBORDER )), m_pDevice( pParent ), m_nStartCol( 0 ), m_nEndCol( 0 ), @@ -457,21 +453,29 @@ DataBrowser::DataBrowser( vcl::Window* pParent, WinBits nStyle, bool bLiveUpdate m_bIsDirty( false ), m_bLiveUpdate( bLiveUpdate ), m_bDataValid( true ), - m_aNumberEditField( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ), - m_aTextEditField( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ), - m_rNumberEditController( new ::svt::FormattedFieldCellController( & m_aNumberEditField )), - m_rTextEditController( new ::svt::EditCellController( & m_aTextEditField )) + m_aNumberEditField( VclPtr<FormattedField>::Create( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ) ), + m_aTextEditField( VclPtr<Edit>::Create( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ) ), + m_rNumberEditController( new ::svt::FormattedFieldCellController( m_aNumberEditField.get() )), + m_rTextEditController( new ::svt::EditCellController( m_aTextEditField.get() )) { double fNan; ::rtl::math::setNan( & fNan ); - m_aNumberEditField.SetDefaultValue( fNan ); - m_aNumberEditField.TreatAsNumber( true ); + m_aNumberEditField->SetDefaultValue( fNan ); + m_aNumberEditField->TreatAsNumber( true ); RenewTable(); SetClean(); } DataBrowser::~DataBrowser() { + disposeOnce(); +} + +void DataBrowser::dispose() +{ + m_aNumberEditField.disposeAndClear(); + m_aTextEditField.disposeAndClear(); + ::svt::EditBrowseBox::dispose(); } bool DataBrowser::MayInsertRow() const @@ -762,9 +766,9 @@ void DataBrowser::ShowWarningBox() bool DataBrowser::ShowQueryBox() { - QueryBox* pQueryBox = new QueryBox(this, WB_YES_NO, SCH_RESSTR(STR_DATA_EDITOR_INCORRECT_INPUT)); + ScopedVclPtrInstance<QueryBox> pQueryBox(this, WB_YES_NO, SCH_RESSTR(STR_DATA_EDITOR_INCORRECT_INPUT)); - return ( pQueryBox->Execute() == RET_YES ); + return pQueryBox->Execute() == RET_YES; } bool DataBrowser::IsDataValid() @@ -777,7 +781,7 @@ bool DataBrowser::IsDataValid() { sal_uInt32 nDummy = 0; double fDummy = 0.0; - OUString aText( m_aNumberEditField.GetText()); + OUString aText( m_aNumberEditField->GetText()); if( !aText.isEmpty() && m_spNumberFormatterWrapper.get() && @@ -821,7 +825,7 @@ void DataBrowser::SetDataFromModel( Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ))); if( m_spNumberFormatterWrapper.get() ) - m_aNumberEditField.SetFormatter( m_spNumberFormatterWrapper->getSvNumberFormatter() ); + m_aNumberEditField->SetFormatter( m_spNumberFormatterWrapper->getSvNumberFormatter() ); RenewTable(); @@ -1041,8 +1045,8 @@ bool DataBrowser::IsTabAllowed( bool bForward ) const if( CellContainsNumbers( nRow, nCol )) { - m_aNumberEditField.UseInputStringForFormatting(); - m_aNumberEditField.SetFormatKey( GetNumberFormatKey( nRow, nCol )); + m_aNumberEditField->UseInputStringForFormatting(); + m_aNumberEditField->SetFormatKey( GetNumberFormatKey( nRow, nCol )); return m_rNumberEditController; } @@ -1055,19 +1059,19 @@ void DataBrowser::InitController( if( rController == m_rTextEditController ) { OUString aText( GetCellText( nRow, nCol ) ); - m_aTextEditField.SetText( aText ); - m_aTextEditField.SetSelection( Selection( 0, aText.getLength() )); + m_aTextEditField->SetText( aText ); + m_aTextEditField->SetSelection( Selection( 0, aText.getLength() )); } else if( rController == m_rNumberEditController ) { // treat invalid and empty text as Nan - m_aNumberEditField.EnableNotANumber( true ); + m_aNumberEditField->EnableNotANumber( true ); if( ::rtl::math::isNan( GetCellNumber( nRow, nCol ))) - m_aNumberEditField.SetTextValue( OUString()); + m_aNumberEditField->SetTextValue( OUString()); else - m_aNumberEditField.SetValue( GetCellNumber( nRow, nCol ) ); - OUString aText( m_aNumberEditField.GetText()); - m_aNumberEditField.SetSelection( Selection( 0, aText.getLength())); + m_aNumberEditField->SetValue( GetCellNumber( nRow, nCol ) ); + OUString aText( m_aNumberEditField->GetText()); + m_aNumberEditField->SetSelection( Selection( 0, aText.getLength())); } else { @@ -1125,7 +1129,7 @@ bool DataBrowser::SaveModified() { sal_uInt32 nDummy = 0; double fDummy = 0.0; - OUString aText( m_aNumberEditField.GetText()); + OUString aText( m_aNumberEditField->GetText()); // an empty string is valid, if no numberformatter exists, all // values are treated as valid if( !aText.isEmpty() && pSvNumberFormatter && @@ -1135,14 +1139,14 @@ bool DataBrowser::SaveModified() } else { - double fData = m_aNumberEditField.GetValue(); + double fData = m_aNumberEditField->GetValue(); bChangeValid = m_apDataBrowserModel->setCellNumber( nCol, nRow, fData ); } } break; case DataBrowserModel::TEXTORDATE: { - OUString aText( m_aTextEditField.GetText() ); + OUString aText( m_aTextEditField->GetText() ); double fDateValue = 0.0; bChangeValid = false; if( isDateString( aText, fDateValue ) ) @@ -1153,7 +1157,7 @@ bool DataBrowser::SaveModified() break; case DataBrowserModel::TEXT: { - OUString aText( m_aTextEditField.GetText()); + OUString aText( m_aTextEditField->GetText()); bChangeValid = m_apDataBrowserModel->setCellText( nCol, nRow, aText ); } break; @@ -69,6 +69,7 @@ protected: public: DataBrowser( vcl::Window* pParent, WinBits nStyle, bool bLiveUpdate ); virtual ~DataBrowser(); + virtual void dispose() SAL_OVERRIDE; /** GetCellText returns the text at the given position @param nRow @@ -164,8 +165,8 @@ private: bool m_bLiveUpdate; bool m_bDataValid; - FormattedField m_aNumberEditField; - Edit m_aTextEditField; + VclPtr<FormattedField> m_aNumberEditField; + VclPtr<Edit> m_aTextEditField; /// note: m_aNumberEditField must precede this member! ::svt::CellControllerRef m_rNumberEditController; @@ -47,10 +47,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeTextDirectionListBox(v return new TextDirectionListBox(pParent); } -TextDirectionListBox::~TextDirectionListBox() -{ -} - } //namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ @@ -42,7 +42,8 @@ ChartTypeDialog::ChartTypeDialog( vcl::Window* pParent , m_xChartModel(xChartModel) , m_xCC( xContext ) { - m_pChartTypeTabPage = new ChartTypeTabPage( + m_pChartTypeTabPage = VclPtr<ChartTypeTabPage>::Create( + get_content_area(), uno::Reference<XChartDocument>::query(m_xChartModel), m_xCC, @@ -55,7 +56,13 @@ ChartTypeDialog::ChartTypeDialog( vcl::Window* pParent ChartTypeDialog::~ChartTypeDialog() { - delete m_pChartTypeTabPage; + disposeOnce(); +} + +void ChartTypeDialog::dispose() +{ + m_pChartTypeTabPage.disposeAndClear(); + ModalDialog::dispose(); } } //namespace chart @@ -79,9 +79,9 @@ void ChartTypeUnoDlg::implInitialize(const uno::Any& _rValue) else ChartTypeUnoDlg_BASE::implInitialize(_rValue); } -Dialog* ChartTypeUnoDlg::createDialog(vcl::Window* _pParent) +VclPtr<Dialog> ChartTypeUnoDlg::createDialog(vcl::Window* _pParent) { - return new ChartTypeDialog( _pParent, m_xChartModel, m_aContext ); + return VclPtr<ChartTypeDialog>::Create( _pParent, m_xChartModel, m_aContext ); } uno::Reference<beans::XPropertySetInfo> SAL_CALL ChartTypeUnoDlg::getPropertySetInfo() throw(uno::RuntimeException, std::exception) { @@ -106,13 +106,9 @@ CreationWizard::CreationWizard( vcl::Window* pParent, const uno::Reference< fram ActivatePage(); } -CreationWizard::~CreationWizard() +VclPtr<TabPage> CreationWizard::createPage(WizardState nState) { -} - -svt::OWizardPage* CreationWizard::createPage(WizardState nState) -{ - svt::OWizardPage* pRet = 0; + VclPtr<svt::OWizardPage> pRet; if(m_nOnePageOnlyIndex!=-1 && m_nOnePageOnlyIndex!=nState) return pRet; bool bDoLiveUpdate = m_nOnePageOnlyIndex == -1; @@ -121,7 +117,7 @@ svt::OWizardPage* CreationWizard::createPage(WizardState nState) case STATE_CHARTTYPE: { m_aTimerTriggeredControllerLock.startTimer(); - ChartTypeTabPage* pChartTypeTabPage = new ChartTypeTabPage(this,m_xChartModel,m_xCC,bDoLiveUpdate); + VclPtrInstance<ChartTypeTabPage> pChartTypeTabPage(this,m_xChartModel,m_xCC,bDoLiveUpdate); pRet = pChartTypeTabPage; m_pTemplateProvider = pChartTypeTabPage; if (m_pDialogModel) @@ -131,18 +127,18 @@ svt::OWizardPage* CreationWizard::createPage(WizardState nState) case STATE_SIMPLE_RANGE: { m_aTimerTriggeredControllerLock.startTimer(); - pRet = new RangeChooserTabPage(this, *m_pDialogModel, m_pTemplateProvider, this); + pRet = VclPtr<RangeChooserTabPage>::Create(this, *m_pDialogModel, m_pTemplateProvider, this); } break; case STATE_DATA_SERIES: { m_aTimerTriggeredControllerLock.startTimer(); - pRet = new DataSourceTabPage(this, *m_pDialogModel, m_pTemplateProvider, this); + pRet = VclPtr<DataSourceTabPage>::Create(this, *m_pDialogModel, m_pTemplateProvider, this); } break; case STATE_OBJECTS: { - pRet = new TitlesAndObjectsTabPage(this,m_xChartModel,m_xCC); + pRet = VclPtr<TitlesAndObjectsTabPage>::Create(this,m_xChartModel,m_xCC); m_aTimerTriggeredControllerLock.startTimer(); } break; @@ -54,11 +54,7 @@ CreationWizardUnoDlg::CreationWizardUnoDlg( const uno::Reference< uno::XComponen CreationWizardUnoDlg::~CreationWizardUnoDlg() { SolarMutexGuard aSolarGuard; - if( m_pDialog ) - { - delete m_pDialog; - m_pDialog = 0; - } + m_pDialog.disposeAndClear(); } // lang::XServiceInfo OUString SAL_CALL CreationWizardUnoDlg::getImplementationName() @@ -216,7 +212,7 @@ void CreationWizardUnoDlg::createDialogOnDemand() uno::Reference< XComponent > xComp( this ); if( m_xChartModel.is() ) { - m_pDialog = new CreationWizard( pParent, m_xChartModel, m_xCC ); + m_pDialog = VclPtr<CreationWizard>::Create( pParent, m_xChartModel, m_xCC ); m_pDialog->AddEventListener( LINK( this, CreationWizardUnoDlg, DialogEventHdl ) ); } } @@ -272,11 +268,7 @@ void SAL_CALL CreationWizardUnoDlg::disposing() m_xParentWindow.clear(); SolarMutexGuard aSolarGuard; - if( m_pDialog ) - { - delete m_pDialog; - m_pDialog = 0; - } + m_pDialog.disposeAndClear(); try { @@ -48,7 +48,7 @@ DataEditor::DataEditor(vcl::Window* pParent, , m_xChartDoc(xChartDoc) , m_xContext(xContext) { - m_xBrwData.reset(new DataBrowser(get<vcl::Window>("datawindow"), WB_BORDER | WB_TABSTOP, true /* bLiveUpdate */)); + m_xBrwData.reset(VclPtr<DataBrowser>::Create(get<vcl::Window>("datawindow"), WB_BORDER | WB_TABSTOP, true /* bLiveUpdate */)); m_xBrwData->set_hexpand(true); m_xBrwData->set_vexpand(true); m_xBrwData->set_expand(true); @@ -95,12 +95,20 @@ DataEditor::DataEditor(vcl::Window* pParent, DataEditor::~DataEditor() { + disposeOnce(); +} + +void DataEditor::dispose() +{ notifySystemWindow( this, m_pTbxData, ::comphelper::mem_fun( & TaskPaneList::RemoveWindow )); SvtMiscOptions aMiscOptions; aMiscOptions.RemoveListenerLink( LINK( this, DataEditor, MiscHdl ) ); OSL_TRACE( "DataEditor: DTOR" ); + m_pTbxData.clear(); + m_xBrwData.disposeAndClear(); + ModalDialog::dispose(); } // react on click (or keypress) on toolbar icon @@ -133,7 +133,7 @@ DataSourceDialog::DataSourceDialog(vcl::Window * pParent, , m_xContext(xContext) , m_apDocTemplateProvider(new DocumentChartTypeTemplateProvider(xChartDocument)) , m_apDialogModel(new DialogModel(xChartDocument, xContext)) - , m_pTabControl(new DataSourceTabControl(get_content_area())) + , m_pTabControl(VclPtr<DataSourceTabControl>::Create(get_content_area())) , m_pRangeChooserTabePage(0) , m_pDataSourceTabPage(0) , m_bRangeChooserTabIsValid(true) @@ -143,9 +143,9 @@ DataSourceDialog::DataSourceDialog(vcl::Window * pParent, m_pTabControl->Show(); - m_pRangeChooserTabePage = new RangeChooserTabPage( m_pTabControl, *(m_apDialogModel.get()), + m_pRangeChooserTabePage = VclPtr<RangeChooserTabPage>::Create( m_pTabControl, *(m_apDialogModel.get()), m_apDocTemplateProvider.get(), this, true /* bHideDescription */ ); - m_pDataSourceTabPage = new DataSourceTabPage( m_pTabControl, *(m_apDialogModel.get()), + m_pDataSourceTabPage = VclPtr<DataSourceTabPage>::Create( m_pTabControl, *(m_apDialogModel.get()), m_apDocTemplateProvider.get(), this, true /* bHideDescription */ ); m_pTabControl->InsertPage( TP_RANGECHOOSER, SCH_RESSTR(STR_PAGE_DATA_RANGE) ); @@ -159,11 +159,18 @@ DataSourceDialog::DataSourceDialog(vcl::Window * pParent, DataSourceDialog::~DataSourceDialog() { - delete m_pRangeChooserTabePage; - delete m_pDataSourceTabPage; + disposeOnce(); +} - m_nLastPageId = m_pTabControl->GetCurPageId(); - delete m_pTabControl; +void DataSourceDialog::dispose() +{ + m_pRangeChooserTabePage.disposeAndClear(); + m_pDataSourceTabPage.disposeAndClear(); + if (m_pTabControl) + m_nLastPageId = m_pTabControl->GetCurPageId(); + m_pTabControl.disposeAndClear(); + m_pBtnOK.clear(); + TabDialog::dispose(); } short DataSourceDialog::Execute() @@ -83,8 +83,21 @@ SchAxisDlg::SchAxisDlg(vcl::Window* pWindow, SchAxisDlg::~SchAxisDlg() { + disposeOnce(); } +void SchAxisDlg::dispose() +{ + m_pCbPrimaryX.clear(); + m_pCbPrimaryY.clear(); + m_pCbPrimaryZ.clear(); + m_pCbSecondaryX.clear(); + m_pCbSecondaryY.clear(); + m_pCbSecondaryZ.clear(); + ModalDialog::dispose(); +} + + void SchAxisDlg::getResult( InsertAxisOrGridDialogData& rOutput ) { rOutput.aExistenceList[0]=m_pCbPrimaryX->IsChecked(); @@ -100,10 +113,6 @@ SchGridDlg::SchGridDlg( vcl::Window* pParent, const InsertAxisOrGridDialogData& { } -SchGridDlg::~SchGridDlg() -{ -} - } //namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ @@ -34,10 +34,6 @@ DataLabelsDialog::DataLabelsDialog(vcl::Window* pWindow, const SfxItemSet& rInAt Reset(); } -DataLabelsDialog::~DataLabelsDialog() -{ -} - void DataLabelsDialog::Reset() { m_apDataLabelResources->Reset(m_rInAttrs); @@ -57,10 +57,6 @@ InsertErrorBarsDialog::InsertErrorBarsDialog( m_apErrorBarResources->SetChartDocumentForRangeChoosing( xChartDocument ); } -InsertErrorBarsDialog::~InsertErrorBarsDialog() -{ -} - void InsertErrorBarsDialog::FillItemSet(SfxItemSet& rOutAttrs) { m_apErrorBarResources->FillItemSet(rOutAttrs); @@ -44,10 +44,6 @@ NumberFormatDialog::NumberFormatDialog(vcl::Window* pParent, SfxItemSet& rSet) } } -NumberFormatDialog::~NumberFormatDialog() -{ -} - SfxItemSet NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( SfxItemPool& rItemPool ) { static const sal_uInt16 nWhichPairs[] = @@ -30,8 +30,7 @@ namespace chart class NumberFormatDialog : public SfxSingleTabDialog { public: - NumberFormatDialog(vcl::Window* pParent, SfxItemSet& rSet); - virtual ~NumberFormatDialog(); + NumberFormatDialog(vcl::Window* pParent, SfxItemSet& rSet); static SfxItemSet CreateEmptyItemSetForNumberFormatDialog( SfxItemPool& rItemPool ); }; @@ -481,8 +481,16 @@ SchAttribTabDlg::SchAttribTabDlg(vcl::Window* pParent, SchAttribTabDlg::~SchAttribTabDlg() { + disposeOnce(); +} + +void SchAttribTabDlg::dispose() +{ delete m_pSymbolShapeProperties; + m_pSymbolShapeProperties = NULL; delete m_pAutoSymbolGraphic; + m_pAutoSymbolGraphic = NULL; + SfxTabDialog::dispose(); } void SchAttribTabDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) @@ -49,9 +49,9 @@ View3DDialog::View3DDialog(vcl::Window* pParent, const uno::Reference< frame::XM get(m_pTabControl, "tabcontrol"); uno::Reference< beans::XPropertySet > xSceneProperties( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); - m_pGeometry = new ThreeD_SceneGeometry_TabPage(m_pTabControl,xSceneProperties,m_aControllerLocker); - m_pAppearance = new ThreeD_SceneAppearance_TabPage(m_pTabControl,xChartModel,m_aControllerLocker); - m_pIllumination = new ThreeD_SceneIllumination_TabPage(m_pTabControl,xSceneProperties,xChartModel,pColorTable); + m_pGeometry = VclPtr<ThreeD_SceneGeometry_TabPage>::Create(m_pTabControl,xSceneProperties,m_aControllerLocker); + m_pAppearance = VclPtr<ThreeD_SceneAppearance_TabPage>::Create(m_pTabControl,xChartModel,m_aControllerLocker); + m_pIllumination = VclPtr<ThreeD_SceneIllumination_TabPage>::Create(m_pTabControl,xSceneProperties,xChartModel,pColorTable); m_pTabControl->InsertPage( TP_3D_SCENEGEOMETRY, SCH_RESSTR(STR_PAGE_PERSPECTIVE) ); m_pTabControl->InsertPage( TP_3D_SCENEAPPEARANCE, SCH_RESSTR(STR_PAGE_APPEARANCE) ); @@ -66,11 +66,18 @@ View3DDialog::View3DDialog(vcl::Window* pParent, const uno::Reference< frame::XM View3DDialog::~View3DDialog() { - delete m_pGeometry; - delete m_pAppearance; - delete m_pIllumination; + disposeOnce(); +} - m_nLastPageId = m_pTabControl->GetCurPageId(); +void View3DDialog::dispose() +{ + m_pGeometry.disposeAndClear(); + m_pAppearance.disposeAndClear(); + m_pIllumination.disposeAndClear(); + if (m_pTabControl) + m_nLastPageId = m_pTabControl->GetCurPageId(); + m_pTabControl.clear(); + TabDialog::dispose(); } short View3DDialog::Execute() @@ -41,8 +41,8 @@ public: void SetSelectHdl( const Link& rLink ); private: - FixedText* m_pFT_Geometry; - ListBox* m_pLB_Geometry; + VclPtr<FixedText> m_pFT_Geometry; + VclPtr<ListBox> m_pLB_Geometry; }; } //namespace chart @@ -205,12 +205,12 @@ IMPL_LINK( DataLabelResources, NumberFormatDialogHdl, PushButton *, pButton ) aNumberSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, rnFormatKey )); aNumberSet.Put( SfxBoolItem( SID_ATTR_NUMBERFORMAT_SOURCE, rUseSourceFormat )); - NumberFormatDialog aDlg(m_pWindow, aNumberSet); + ScopedVclPtrInstance< NumberFormatDialog > aDlg(m_pWindow, aNumberSet); if( bPercent ) - aDlg.SetText( m_pFT_NumberFormatForPercent->GetText()); - if( RET_OK == aDlg.Execute() ) + aDlg->SetText( m_pFT_NumberFormatForPercent->GetText()); + if( RET_OK == aDlg->Execute() ) { - const SfxItemSet* pResult = aDlg.GetOutputItemSet(); + const SfxItemSet* pResult = aDlg->GetOutputItemSet(); if( pResult ) { bool bOldSource = rUseSourceFormat; @@ -45,28 +45,28 @@ public: void SetNumberFormatter( SvNumberFormatter* pFormatter ); private: - CheckBox* m_pCBNumber; - PushButton* m_pPB_NumberFormatForValue; - CheckBox* m_pCBPercent; - PushButton* m_pPB_NumberFormatForPercent; - FixedText* m_pFT_NumberFormatForPercent; - CheckBox* m_pCBCategory; - CheckBox* m_pCBSymbol; - - VclHBox* m_pSeparatorResources; - ListBox* m_pLB_Separator; + VclPtr<CheckBox> m_pCBNumber; + VclPtr<PushButton> m_pPB_NumberFormatForValue; + VclPtr<CheckBox> m_pCBPercent; + VclPtr<PushButton> m_pPB_NumberFormatForPercent; + VclPtr<FixedText> m_pFT_NumberFormatForPercent; + VclPtr<CheckBox> m_pCBCategory; + VclPtr<CheckBox> m_pCBSymbol; + + VclPtr<VclHBox> m_pSeparatorResources; + VclPtr<ListBox> m_pLB_Separator; OUString m_aEntryMap[NUMBER_SEPARATORS]; - VclHBox* m_pBxLabelPlacement; - ListBox* m_pLB_LabelPlacement; + VclPtr<VclHBox> m_pBxLabelPlacement; + VclPtr<ListBox> m_pLB_LabelPlacement; - VclHBox* m_pBxOrientation; - svx::DialControl* m_pDC_Dial; - FixedText* m_pFT_Dial; - NumericField* m_pNF_Degrees; + VclPtr<VclHBox> m_pBxOrientation; + VclPtr<svx::DialControl> m_pDC_Dial; + VclPtr<FixedText> m_pFT_Dial; + VclPtr<NumericField> m_pNF_Degrees; - VclHBox* m_pBxTextDirection; - TextDirectionListBox* m_pLB_TextDirection; + VclPtr<VclHBox> m_pBxTextDirection; + VclPtr<TextDirectionListBox> m_pLB_TextDirection; ::std::map< sal_Int32, sal_uInt16 > m_aPlacementToListBoxMap; ::std::map< sal_uInt16, sal_Int32 > m_aListBoxToPlacementMap; @@ -82,7 +82,7 @@ private: bool m_bSourceFormatForValue; bool m_bSourceFormatForPercent; - vcl::Window* m_pWindow; + VclPtr<vcl::Window> m_pWindow; SfxItemPool* m_pPool; DECL_LINK(NumberFormatDialogHdl, PushButton * ); @@ -46,29 +46,29 @@ public: void SetNbPoints( sal_Int32 nNbPoints ); private: - RadioButton* m_pRB_Linear; - RadioButton* m_pRB_Logarithmic; - RadioButton* m_pRB_Exponential; - RadioButton* m_pRB_Power; - RadioButton* m_pRB_Polynomial; - RadioButton* m_pRB_MovingAverage; - - FixedImage* m_pFI_Linear; - FixedImage* m_pFI_Logarithmic; - FixedImage* m_pFI_Exponential; - FixedImage* m_pFI_Power; - FixedImage* m_pFI_Polynomial; - FixedImage* m_pFI_MovingAverage; - - NumericField* m_pNF_Degree; - NumericField* m_pNF_Period; - Edit* m_pEE_Name; - FormattedField* m_pFmtFld_ExtrapolateForward; - FormattedField* m_pFmtFld_ExtrapolateBackward; - CheckBox* m_pCB_SetIntercept; - FormattedField* m_pFmtFld_InterceptValue; - CheckBox* m_pCB_ShowEquation; - CheckBox* m_pCB_ShowCorrelationCoeff; + VclPtr<RadioButton> m_pRB_Linear; + VclPtr<RadioButton> m_pRB_Logarithmic; + VclPtr<RadioButton> m_pRB_Exponential; + VclPtr<RadioButton> m_pRB_Power; + VclPtr<RadioButton> m_pRB_Polynomial; + VclPtr<RadioButton> m_pRB_MovingAverage; + + VclPtr<FixedImage> m_pFI_Linear; + VclPtr<FixedImage> m_pFI_Logarithmic; + VclPtr<FixedImage> m_pFI_Exponential; + VclPtr<FixedImage> m_pFI_Power; + VclPtr<FixedImage> m_pFI_Polynomial; + VclPtr<FixedImage> m_pFI_MovingAverage; + + VclPtr<NumericField> m_pNF_Degree; + VclPtr<NumericField> m_pNF_Period; + VclPtr<Edit> m_pEE_Name; + VclPtr<FormattedField> m_pFmtFld_ExtrapolateForward; + VclPtr<FormattedField> m_pFmtFld_ExtrapolateBackward; + VclPtr<CheckBox> m_pCB_SetIntercept; + VclPtr<FormattedField> m_pFmtFld_InterceptValue; + VclPtr<CheckBox> m_pCB_ShowEquation; + VclPtr<CheckBox> m_pCB_ShowCorrelationCoeff; SvxChartRegress m_eTrendLineType; @@ -121,7 +121,18 @@ ThreeD_SceneAppearance_TabPage::ThreeD_SceneAppearance_TabPage( } ThreeD_SceneAppearance_TabPage::~ThreeD_SceneAppearance_TabPage() -{} +{ + disposeOnce(); +} + +void ThreeD_SceneAppearance_TabPage::dispose() +{ + m_pLB_Scheme.clear(); + m_pCB_Shading.clear(); + m_pCB_ObjectLines.clear(); + m_pCB_RoundedEdge.clear(); + TabPage::dispose(); +} void ThreeD_SceneAppearance_TabPage::ActivatePage() { @@ -39,6 +39,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xChartModel, ControllerLockHelper & rControllerLockHelper ); virtual ~ThreeD_SceneAppearance_TabPage(); + virtual void dispose() SAL_OVERRIDE; virtual void ActivatePage() SAL_OVERRIDE; @@ -56,11 +57,11 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; - ListBox* m_pLB_Scheme; + VclPtr<ListBox> m_pLB_Scheme; - CheckBox* m_pCB_Shading; - CheckBox* m_pCB_ObjectLines; - CheckBox* m_pCB_RoundedEdge; + VclPtr<CheckBox> m_pCB_Shading; + VclPtr<CheckBox> m_pCB_ObjectLines; + VclPtr<CheckBox> m_pCB_RoundedEdge; bool m_bUpdateOtherControls; bool m_bCommitToModel; @@ -149,8 +149,22 @@ ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage( vcl::Window* pWindow ThreeD_SceneGeometry_TabPage::~ThreeD_SceneGeometry_TabPage() { + disposeOnce(); } +void ThreeD_SceneGeometry_TabPage::dispose() +{ + m_pCbxRightAngledAxes.clear(); + m_pMFXRotation.clear(); + m_pMFYRotation.clear(); + m_pFtZRotation.clear(); + m_pMFZRotation.clear(); + m_pCbxPerspective.clear(); + m_pMFPerspective.clear(); + TabPage::dispose(); +} + + void ThreeD_SceneGeometry_TabPage::commitPendingChanges() { ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); @@ -40,6 +40,7 @@ public: ::com::sun::star::beans::XPropertySet > & xSceneProperties, ControllerLockHelper & rControllerLockHelper ); virtual ~ThreeD_SceneGeometry_TabPage(); + virtual void dispose() SAL_OVERRIDE; // has to be called in case the dialog was closed with OK void commitPendingChanges(); @@ -64,17 +65,17 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSceneProperties; - CheckBox* m_pCbxRightAngledAxes; + VclPtr<CheckBox> m_pCbxRightAngledAxes; - MetricField* m_pMFXRotation; + VclPtr<MetricField> m_pMFXRotation; - MetricField* m_pMFYRotation; + VclPtr<MetricField> m_pMFYRotation; - FixedText* m_pFtZRotation; - MetricField* m_pMFZRotation; + VclPtr<FixedText> m_pFtZRotation; + VclPtr<MetricField> m_pMFZRotation; - CheckBox* m_pCbxPerspective; - MetricField* m_pMFPerspective; + VclPtr<CheckBox> m_pCbxPerspective; + VclPtr<MetricField> m_pMFPerspective; //to keep old values when switching to right angled axes sal_Int64 m_nXRotation; @@ -48,10 +48,6 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeLightButton(vcl::Windo return new LightButton(pParent); } -LightButton::~LightButton() -{ -} - void LightButton::switchLightOn(bool bOn) { if( m_bLightOn==bOn ) @@ -82,7 +78,7 @@ struct LightSource struct LightSourceInfo { - LightButton* pButton; + VclPtr<LightButton> pButton; LightSource aLightSource; LightSourceInfo(); @@ -298,7 +294,27 @@ ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( vcl::Window* ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage() { + disposeOnce(); +} + +void ThreeD_SceneIllumination_TabPage::dispose() +{ delete[] m_pLightSourceInfoList; + m_pLightSourceInfoList = NULL; + m_pBtn_Light1.clear(); + m_pBtn_Light2.clear(); + m_pBtn_Light3.clear(); + m_pBtn_Light4.clear(); + m_pBtn_Light5.clear(); + m_pBtn_Light6.clear(); + m_pBtn_Light7.clear(); + m_pBtn_Light8.clear(); + m_pLB_LightSource.clear(); + m_pBtn_LightSource_Color.clear(); + m_pLB_AmbientLight.clear(); + m_pBtn_AmbientLight_Color.clear(); + m_pCtl_Preview.clear(); + TabPage::dispose(); } IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, fillControlsFromModel) @@ -37,7 +37,6 @@ class LightButton : public ImageButton { public: LightButton( vcl::Window* pParent); - virtual ~LightButton(); void switchLightOn(bool bOn); bool isLightOn() const { return m_bLightOn;} @@ -58,6 +57,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel, const XColorListRef &pColorTable ); virtual ~ThreeD_SceneIllumination_TabPage(); + virtual void dispose() SAL_OVERRIDE; private: DECL_LINK( ClickLightSourceButtonHdl, LightButton* ); @@ -74,22 +74,22 @@ private: void applyLightSourceToModel( sal_uInt32 nLightNumber ); void applyLightSourcesToModel(); - LightButton* m_pBtn_Light1; - LightButton* m_pBtn_Light2; - LightButton* m_pBtn_Light3; - LightButton* m_pBtn_Light4; - LightButton* m_pBtn_Light5; - LightButton* m_pBtn_Light6; - LightButton* m_pBtn_Light7; - LightButton* m_pBtn_Light8; + VclPtr<LightButton> m_pBtn_Light1; + VclPtr<LightButton> m_pBtn_Light2; + VclPtr<LightButton> m_pBtn_Light3; + VclPtr<LightButton> m_pBtn_Light4; + VclPtr<LightButton> m_pBtn_Light5; + VclPtr<LightButton> m_pBtn_Light6; + VclPtr<LightButton> m_pBtn_Light7; + VclPtr<LightButton> m_pBtn_Light8; - ColorLB* m_pLB_LightSource; - PushButton* m_pBtn_LightSource_Color; + VclPtr<ColorLB> m_pLB_LightSource; + VclPtr<PushButton> m_pBtn_LightSource_Color; - ColorLB* m_pLB_AmbientLight; - PushButton* m_pBtn_AmbientLight_Color; + VclPtr<ColorLB> m_pLB_AmbientLight; + VclPtr<PushButton> m_pBtn_AmbientLight_Color; - SvxLightCtl3D* m_pCtl_Preview; + VclPtr<SvxLightCtl3D> m_pCtl_Preview; LightSourceInfo* m_pLightSourceInfoList; @@ -71,11 +71,37 @@ SchAxisLabelTabPage::SchAxisLabelTabPage( vcl::Window* pParent, const SfxItemSet } SchAxisLabelTabPage::~SchAxisLabelTabPage() -{delete m_pOrientHlp;} +{ + disposeOnce(); +} + +void SchAxisLabelTabPage::dispose() +{ + delete m_pOrientHlp; + m_pOrientHlp = NULL; + m_pCbShowDescription.clear(); + m_pFlOrder.clear(); + m_pRbSideBySide.clear(); + m_pRbUpDown.clear(); + m_pRbDownUp.clear(); + m_pRbAuto.clear(); + m_pFlTextFlow.clear(); + m_pCbTextOverlap.clear(); + m_pCbTextBreak.clear(); + m_pFtABCD.clear(); + m_pFlOrient.clear(); + m_pCtrlDial.clear(); + m_pFtRotate.clear(); + m_pNfRotate.clear(); + m_pCbStacked.clear(); + m_pFtTextDirection.clear(); + m_pLbTextDirection.clear(); + SfxTabPage::dispose(); +} -SfxTabPage* SchAxisLabelTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrs ) +VclPtr<SfxTabPage> SchAxisLabelTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrs ) { - return new SchAxisLabelTabPage( pParent, *rAttrs ); + return VclPtr<SchAxisLabelTabPage>::Create( pParent, *rAttrs ); } bool SchAxisLabelTabPage::FillItemSet( SfxItemSet* rOutAttrs ) @@ -35,27 +35,27 @@ namespace chart class SchAxisLabelTabPage : public SfxTabPage { private: - CheckBox* m_pCbShowDescription; + VclPtr<CheckBox> m_pCbShowDescription; - FixedText* m_pFlOrder; - RadioButton* m_pRbSideBySide; - RadioButton* m_pRbUpDown; - RadioButton* m_pRbDownUp; - RadioButton* m_pRbAuto; + VclPtr<FixedText> m_pFlOrder; + VclPtr<RadioButton> m_pRbSideBySide; + VclPtr<RadioButton> m_pRbUpDown; + VclPtr<RadioButton> m_pRbDownUp; + VclPtr<RadioButton> m_pRbAuto; - FixedText* m_pFlTextFlow; - CheckBox* m_pCbTextOverlap; - CheckBox* m_pCbTextBreak; - FixedText* m_pFtABCD; - FixedText* m_pFlOrient; - svx::DialControl* m_pCtrlDial; - FixedText* m_pFtRotate; - NumericField* m_pNfRotate; - TriStateBox* m_pCbStacked; + VclPtr<FixedText> m_pFlTextFlow; + VclPtr<CheckBox> m_pCbTextOverlap; + VclPtr<CheckBox> m_pCbTextBreak; + VclPtr<FixedText> m_pFtABCD; + VclPtr<FixedText> m_pFlOrient; + VclPtr<svx::DialControl> m_pCtrlDial; + VclPtr<FixedText> m_pFtRotate; + VclPtr<NumericField> m_pNfRotate; + VclPtr<TriStateBox> m_pCbStacked; svx::OrientationHelper* m_pOrientHlp; - FixedText* m_pFtTextDirection; - TextDirectionListBox* m_pLbTextDirection; + VclPtr<FixedText> m_pFtTextDirection; + VclPtr<TextDirectionListBox> m_pLbTextDirection; bool m_bShowStaggeringControls; @@ -70,8 +70,9 @@ private: public: SchAxisLabelTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); virtual ~SchAxisLabelTabPage(); + virtual void dispose() SAL_OVERRIDE; - static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); + static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); virtual bool FillItemSet( SfxItemSet* rOutAttrs ) SAL_OVERRIDE; virtual void Reset( const SfxItemSet* rInAttrs ) SAL_OVERRIDE; @@ -84,9 +84,33 @@ AxisPositionsTabPage::AxisPositionsTabPage(vcl::Window* pWindow,const SfxItemSet m_pLB_PlaceTicks->SetDropDownLineCount( m_pLB_PlaceTicks->GetEntryCount() ); } -SfxTabPage* AxisPositionsTabPage::Create(vcl::Window* pWindow,const SfxItemSet* rOutAttrs) +AxisPositionsTabPage::~AxisPositionsTabPage() { - return new AxisPositionsTabPage(pWindow, *rOutAttrs); + disposeOnce(); +} + +void AxisPositionsTabPage::dispose() +{ + m_pFL_AxisLine.clear(); + m_pLB_CrossesAt.clear(); + m_pED_CrossesAt.clear(); + m_pED_CrossesAtCategory.clear(); + m_pCB_AxisBetweenCategories.clear(); + m_pFL_Labels.clear(); + m_pLB_PlaceLabels.clear(); + m_pED_LabelDistance.clear(); + m_pCB_TicksInner.clear(); + m_pCB_TicksOuter.clear(); + m_pCB_MinorInner.clear(); + m_pCB_MinorOuter.clear(); + m_pBxPlaceTicks.clear(); + m_pLB_PlaceTicks.clear(); + SfxTabPage::dispose(); +} + +VclPtr<SfxTabPage> AxisPositionsTabPage::Create(vcl::Window* pWindow,const SfxItemSet* rOutAttrs) +{ + return VclPtr<AxisPositionsTabPage>::Create(pWindow, *rOutAttrs); } bool AxisPositionsTabPage::FillItemSet(SfxItemSet* rOutAttrs) @@ -33,8 +33,10 @@ class AxisPositionsTabPage : public SfxTabPage { public: AxisPositionsTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); + virtual ~AxisPositionsTabPage(); + virtual void dispose() SAL_OVERRIDE; - static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); + static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); virtual bool FillItemSet( SfxItemSet* rOutAttrs ) SAL_OVERRIDE; virtual void Reset( const SfxItemSet* rInAttrs ) SAL_OVERRIDE; using TabPage::DeactivatePage; @@ -52,30 +54,30 @@ private: //methods: DECL_LINK( PlaceLabelsSelectHdl, void* ); private: //member: - VclFrame* m_pFL_AxisLine; - ListBox* m_pLB_CrossesAt; - FormattedField* m_pED_CrossesAt; - ComboBox* m_pED_CrossesAtCategory; - CheckBox* m_pCB_AxisBetweenCategories; + VclPtr<VclFrame> m_pFL_AxisLine; + VclPtr<ListBox> m_pLB_CrossesAt; + VclPtr<FormattedField> m_pED_CrossesAt; + VclPtr<ComboBox> m_pED_CrossesAtCategory; + VclPtr<CheckBox> m_pCB_AxisBetweenCategories; - VclFrame* m_pFL_Labels; - ListBox* m_pLB_PlaceLabels; - FormattedField* m_pED_LabelDistance; + VclPtr<VclFrame> m_pFL_Labels; + VclPtr<ListBox> m_pLB_PlaceLabels; + VclPtr<FormattedField> m_pED_LabelDistance; - CheckBox* m_pCB_TicksInner; - CheckBox* m_pCB_TicksOuter; + VclPtr<CheckBox> m_pCB_TicksInner; + VclPtr<CheckBox> m_pCB_TicksOuter; - CheckBox* m_pCB_MinorInner; - CheckBox* m_pCB_MinorOuter; + VclPtr<CheckBox> m_pCB_MinorInner; + VclPtr<CheckBox> m_pCB_MinorOuter; - VclBox* m_pBxPlaceTicks; - ListBox* m_pLB_PlaceTicks; + VclPtr<VclBox> m_pBxPlaceTicks; + VclPtr<ListBox> m_pLB_PlaceTicks; // Not implemented -// CheckBox* m_pCB_MajorGrid; -// PushButton* m_pPB_MajorGrid; -// CheckBox* m_pCB_MinorGrid; -// PushButton* m_pPB_MinorGrid; +// VclPtr<CheckBox> m_pCB_MajorGrid; +// VclPtr<PushButton> m_pPB_MajorGrid; +// VclPtr<CheckBox> m_pCB_MinorGrid; +// VclPtr<PushButton> m_pPB_MinorGrid; SvNumberFormatter* m_pNumFormatter; @@ -56,8 +56,8 @@ private: DECL_LINK( SelectSchemeHdl, void* ); private: - CheckBox* m_pCB_3DLook; - ListBox* m_pLB_Scheme; + VclPtr<CheckBox> m_pCB_3DLook; + VclPtr<ListBox> m_pLB_Scheme; }; Dim3DLookResourceGroup::Dim3DLookResourceGroup(VclBuilderContainer* pWindow) @@ -129,7 +129,7 @@ private: DECL_LINK( SortByXValuesCheckHdl, void* ); private: - CheckBox* m_pCB_XValueSorting; + VclPtr<CheckBox> m_pCB_XValueSorting; }; SortByXValuesResourceGroup::SortByXValuesResourceGroup(VclBuilderContainer* pWindow ) @@ -176,10 +176,10 @@ private: DECL_LINK( StackingEnableHdl, void* ); private: - CheckBox* m_pCB_Stacked; - RadioButton* m_pRB_Stack_Y; - RadioButton* m_pRB_Stack_Y_Percent; - RadioButton* m_pRB_Stack_Z; + VclPtr<CheckBox> m_pCB_Stacked; + VclPtr<RadioButton> m_pRB_Stack_Y; + VclPtr<RadioButton> m_pRB_Stack_Y_Percent; + VclPtr<RadioButton> m_pRB_Stack_Z; bool m_bShowDeepStacking; }; @@ -278,7 +278,7 @@ public: private: DECL_LINK( SettingChangedHdl, void* ); private: - CheckBox* m_pCB_RoundedEdge; + VclPtr<CheckBox> m_pCB_RoundedEdge; }; GL3DResourceGroup::GL3DResourceGroup( VclBuilderContainer* pWindow ) @@ -313,7 +313,8 @@ class SplinePropertiesDialog : public ModalDialog { public: SplinePropertiesDialog( vcl::Window* pParent ); - virtual ~SplinePropertiesDialog(); + virtual ~SplinePropertiesDialog() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE; void fillControls( const ChartTypeParameter& rParameter ); void fillParameter( ChartTypeParameter& rParameter, bool bSmoothLines ); @@ -324,11 +325,11 @@ private: DECL_LINK( SplineTypeListBoxHdl, void* ); private: - ListBox* m_pLB_Spline_Type; + VclPtr<ListBox> m_pLB_Spline_Type; - NumericField* m_pMF_SplineResolution; - FixedText* m_pFT_SplineOrder; - NumericField* m_pMF_SplineOrder; + VclPtr<NumericField> m_pMF_SplineResolution; + VclPtr<FixedText> m_pFT_SplineOrder; + VclPtr<NumericField> m_pMF_SplineOrder; }; const sal_uInt16 CUBIC_SPLINE_POS = 0; @@ -347,8 +348,13 @@ SplinePropertiesDialog::SplinePropertiesDialog( vcl::Window* pParent ) m_pLB_Spline_Type->SetSelectHdl( LINK (this, SplinePropertiesDialog, SplineTypeListBoxHdl ) ); } -SplinePropertiesDialog::~SplinePropertiesDialog() +void SplinePropertiesDialog::dispose() { + m_pLB_Spline_Type.clear(); + m_pMF_SplineResolution.clear(); + m_pFT_SplineOrder.clear(); + m_pMF_SplineOrder.clear(); + ModalDialog::dispose(); } void SplinePropertiesDialog::StateChanged( StateChangedType nType ) @@ -400,7 +406,8 @@ class SteppedPropertiesDialog : public ModalDialog { public: SteppedPropertiesDialog( vcl::Window* pParent ); - virtual ~SteppedPropertiesDialog(); + virtual ~SteppedPropertiesDialog() { disposeOnce(); } + virtual void dispose() SAL_OVERRIDE; void fillControls( const ChartTypeParameter& rParameter ); void fillParameter( ChartTypeParameter& rParameter, bool bSteppedLines ); @@ -410,10 +417,10 @@ public: private: private: - RadioButton* m_pRB_Start; - RadioButton* m_pRB_End; - RadioButton* m_pRB_CenterX; - RadioButton* m_pRB_CenterY; + VclPtr<RadioButton> m_pRB_Start; + VclPtr<RadioButton> m_pRB_End; + VclPtr<RadioButton> m_pRB_CenterX; + VclPtr<RadioButton> m_pRB_CenterY; }; SteppedPropertiesDialog::SteppedPropertiesDialog( vcl::Window* pParent ) @@ -427,8 +434,13 @@ SteppedPropertiesDialog::SteppedPropertiesDialog( vcl::Window* pParent ) SetText(SCH_RESSTR(STR_DLG_STEPPED_LINE_PROPERTIES)); } -SteppedPropertiesDialog::~SteppedPropertiesDialog() +void SteppedPropertiesDialog::dispose() { + m_pRB_Start.clear(); + m_pRB_End.clear(); + m_pRB_CenterX.clear(); + m_pRB_CenterY.clear(); + ModalDialog::dispose(); } void SteppedPropertiesDialog::StateChanged( StateChangedType nType ) @@ -490,11 +502,11 @@ private: SteppedPropertiesDialog& getSteppedPropertiesDialog(); private: - FixedText* m_pFT_LineType; - ListBox* m_pLB_LineType; - PushButton* m_pPB_DetailsDialog; - boost::scoped_ptr< SplinePropertiesDialog > m_pSplinePropertiesDialog; - boost::scoped_ptr< SteppedPropertiesDialog > m_pSteppedPropertiesDialog; + VclPtr<FixedText> m_pFT_LineType; + VclPtr<ListBox> m_pLB_LineType; + VclPtr<PushButton> m_pPB_DetailsDialog; + VclPtr< SplinePropertiesDialog > m_pSplinePropertiesDialog; + VclPtr< SteppedPropertiesDialog > m_pSteppedPropertiesDialog; }; SplineResourceGroup::SplineResourceGroup(VclBuilderContainer* pWindow) @@ -510,7 +522,7 @@ SplineResourceGroup::SplineResourceGroup(VclBuilderContainer* pWindow) SplinePropertiesDialog& SplineResourceGroup::getSplinePropertiesDialog() { if( !m_pSplinePropertiesDialog.get() ) - m_pSplinePropertiesDialog.reset( new SplinePropertiesDialog( m_pPB_DetailsDialog->GetParentDialog() ) ); + m_pSplinePropertiesDialog.reset( VclPtr<SplinePropertiesDialog>::Create( m_pPB_DetailsDialog->GetParentDialog() ) ); return *m_pSplinePropertiesDialog; } @@ -518,7 +530,7 @@ SteppedPropertiesDialog& SplineResourceGroup::getSteppedPropertiesDialog() { if( !m_pSteppedPropertiesDialog.get() ) { - m_pSteppedPropertiesDialog.reset( new SteppedPropertiesDialog( m_pPB_DetailsDialog->GetParentDialog() ) ); + m_pSteppedPropertiesDialog.reset( VclPtr<SteppedPropertiesDialog>::Create( m_pPB_DetailsDialog->GetParentDialog() ) ); } return *m_pSteppedPropertiesDialog; } @@ -774,6 +786,11 @@ ChartTypeTabPage::ChartTypeTabPage(vcl::Window* pParent ChartTypeTabPage::~ChartTypeTabPage() { + disposeOnce(); +} + +void ChartTypeTabPage::dispose() +{ //delete all dialog controller ::std::vector< ChartTypeDialogController* >::const_iterator aIter = m_aChartTypeDialogControllerList.begin(); const ::std::vector< ChartTypeDialogController* >::const_iterator aEnd = m_aChartTypeDialogControllerList.end(); @@ -785,12 +802,23 @@ ChartTypeTabPage::~ChartTypeTabPage() //delete all resource helper delete m_pDim3DLookResourceGroup; + m_pDim3DLookResourceGroup = NULL; delete m_pStackingResourceGroup; + m_pStackingResourceGroup = NULL; delete m_pSplineResourceGroup; + m_pSplineResourceGroup = NULL; delete m_pGeometryResourceGroup; + m_pGeometryResourceGroup = NULL; delete m_pSortByXValuesResourceGroup; + m_pSortByXValuesResourceGroup = NULL; delete m_pGL3DResourceGroup; + m_pGL3DResourceGroup = NULL; + m_pFT_ChooseType.clear(); + m_pMainTypeList.clear(); + m_pSubTypeList.clear(); + svt::OWizardPage::dispose(); } + ChartTypeParameter ChartTypeTabPage::getCurrentParamter() const { ChartTypeParameter aParameter; @@ -55,6 +55,7 @@ public: ::com::sun::star::uno::XComponentContext >& xContext , bool bDoLiveUpdate, bool bShowDescription = true ); virtual ~ChartTypeTabPage(); + virtual void dispose() SAL_OVERRIDE; virtual void initializePage() SAL_OVERRIDE; virtual bool commitPage( ::svt::WizardTypes::CommitPageReason eReason ) SAL_OVERRIDE; @@ -77,9 +78,9 @@ protected: DECL_LINK( SelectSubTypeHdl, void* ); protected: - FixedText* m_pFT_ChooseType; - ListBox* m_pMainTypeList; - ValueSet* m_pSubTypeList; + VclPtr<FixedText> m_pFT_ChooseType; + VclPtr<ListBox> m_pMainTypeList; + VclPtr<ValueSet> m_pSubTypeList; Dim3DLookResourceGroup* m_pDim3DLookResourceGroup; StackingResourceGroup* m_pStackingResourceGroup; @@ -34,13 +34,9 @@ DataLabelsTabPage::DataLabelsTabPage(vcl::Window* pWindow, const SfxItemSet& rIn { } -DataLabelsTabPage::~DataLabelsTabPage() +VclPtr<SfxTabPage> DataLabelsTabPage::Create(vcl::Window* pWindow, const SfxItemSet* rOutAttrs) { -} - -SfxTabPage* DataLabelsTabPage::Create(vcl::Window* pWindow, const SfxItemSet* rOutAttrs) -{ - return new DataLabelsTabPage(pWindow, *rOutAttrs); + return VclPtr<DataLabelsTabPage>::Create(pWindow, *rOutAttrs); } bool DataLabelsTabPage::FillItemSet(SfxItemSet* rOutAttrs) @@ -34,9 +34,8 @@ class DataLabelsTabPage : public SfxTabPage { public: DataLabelsTabPage(vcl::Window* pWindow, const SfxItemSet& rInAttrs); - virtual ~DataLabelsTabPage(); - static SfxTabPage* Create(vcl::Window* pWindow, const SfxItemSet* rInAttrs); + static VclPtr<SfxTabPage> Create(vcl::Window* pWindow, const SfxItemSet* rInAttrs); void SetNumberFormatter( SvNumberFormatter* pFormatter ); @@ -274,7 +274,32 @@ DataSourceTabPage::DataSourceTabPage( } DataSourceTabPage::~DataSourceTabPage() -{} +{ + disposeOnce(); +} + +void DataSourceTabPage::dispose() +{ + m_pFT_CAPTION.clear(); + m_pFT_SERIES.clear(); + m_pLB_SERIES.clear(); + m_pBTN_ADD.clear(); + m_pBTN_REMOVE.clear(); + m_pBTN_UP.clear(); + m_pBTN_DOWN.clear(); + m_pFT_ROLE.clear(); + m_pLB_ROLE.clear(); + m_pFT_RANGE.clear(); + m_pEDT_RANGE.clear(); + m_pIMB_RANGE_MAIN.clear(); + m_pFT_CATEGORIES.clear(); + m_pFT_DATALABELS.clear(); + m_pEDT_CATEGORIES.clear(); + m_pIMB_RANGE_CAT.clear(); + m_pCurrentRangeChoosingField.clear(); + m_pParentDialog.clear(); + ::svt::OWizardPage::dispose(); +} void DataSourceTabPage::ActivatePage() { @@ -59,6 +59,7 @@ public: Dialog * pParentDialog, bool bHideDescription = false ); virtual ~DataSourceTabPage(); + virtual void dispose() SAL_OVERRIDE; void commitPage(); @@ -118,34 +119,34 @@ protected: void fillRoleListBox(); private: - FixedText* m_pFT_CAPTION; - FixedText* m_pFT_SERIES; - SvTreeListBox* m_pLB_SERIES; - PushButton* m_pBTN_ADD; - PushButton* m_pBTN_REMOVE; - PushButton* m_pBTN_UP; - PushButton* m_pBTN_DOWN; - - FixedText* m_pFT_ROLE; - SvTabListBox* m_pLB_ROLE; - FixedText* m_pFT_RANGE; - Edit* m_pEDT_RANGE; - PushButton* m_pIMB_RANGE_MAIN; - - FixedText* m_pFT_CATEGORIES; - FixedText* m_pFT_DATALABELS;//used for xy charts - Edit* m_pEDT_CATEGORIES; - PushButton* m_pIMB_RANGE_CAT; + VclPtr<FixedText> m_pFT_CAPTION; + VclPtr<FixedText> m_pFT_SERIES; + VclPtr<SvTreeListBox> m_pLB_SERIES; + VclPtr<PushButton> m_pBTN_ADD; + VclPtr<PushButton> m_pBTN_REMOVE; + VclPtr<PushButton> m_pBTN_UP; + VclPtr<PushButton> m_pBTN_DOWN; + + VclPtr<FixedText> m_pFT_ROLE; + VclPtr<SvTabListBox> m_pLB_ROLE; + VclPtr<FixedText> m_pFT_RANGE; + VclPtr<Edit> m_pEDT_RANGE; + VclPtr<PushButton> m_pIMB_RANGE_MAIN; + + VclPtr<FixedText> m_pFT_CATEGORIES; + VclPtr<FixedText> m_pFT_DATALABELS;//used for xy charts + VclPtr<Edit> m_pEDT_CATEGORIES; + VclPtr<PushButton> m_pIMB_RANGE_CAT; OUString m_aFixedTextRange; ChartTypeTemplateProvider * m_pTemplateProvider; DialogModel & m_rDialogModel; - Edit * m_pCurrentRangeChoosingField; + VclPtr<Edit> m_pCurrentRangeChoosingField; bool m_bIsDirty; sal_Int32 m_nLastChartTypeGroupIndex; - Dialog * m_pParentDialog; + VclPtr<Dialog> m_pParentDialog; TabPageNotifiable * m_pTabPageNotifiable; }; @@ -41,10 +41,10 @@ ErrorBarsTabPage::ErrorBarsTabPage( vcl::Window* pParent, const SfxItemSet& rInA { } -SfxTabPage* ErrorBarsTabPage::Create( +VclPtr<SfxTabPage> ErrorBarsTabPage::Create( vcl::Window* pParent, const SfxItemSet* rOutAttrs ) { - return new ErrorBarsTabPage( pParent, *rOutAttrs ); + return VclPtr<ErrorBarsTabPage>::Create( pParent, *rOutAttrs ); } bool ErrorBarsTabPage::FillItemSet( SfxItemSet* rOutAttrs ) @@ -37,7 +37,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDocument ); - static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); + static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); virtual bool FillItemSet( SfxItemSet* rOutAttrs ) SAL_OVERRIDE; virtual void Reset( const SfxItemSet* rInAttrs ) SAL_OVERRIDE; @@ -41,9 +41,21 @@ SchLegendPosTabPage::SchLegendPosTabPage(vcl::Window* pWindow, const SfxItemSet& m_pLbTextDirection->SetDropDownLineCount(3); } -SfxTabPage* SchLegendPosTabPage::Create(vcl::Window* pWindow, const SfxItemSet* rOutAttrs) +SchLegendPosTabPage::~SchLegendPosTabPage() { - return new SchLegendPosTabPage(pWindow, *rOutAttrs); + disposeOnce(); +} + +void SchLegendPosTabPage::dispose() +{ + m_pLbTextDirection.clear(); + SfxTabPage::dispose(); +} + + +VclPtr<SfxTabPage> SchLegendPosTabPage::Create(vcl::Window* pWindow, const SfxItemSet* rOutAttrs) +{ + return VclPtr<SchLegendPosTabPage>::Create(pWindow, *rOutAttrs); } bool SchLegendPosTabPage::FillItemSet(SfxItemSet* rOutAttrs) @@ -33,12 +33,14 @@ class SchLegendPosTabPage : public SfxTabPage private: LegendPositionResources m_aLegendPositionResources; - TextDirectionListBox* m_pLbTextDirection; + VclPtr<TextDirectionListBox> m_pLbTextDirection; public: SchLegendPosTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs); + virtual ~SchLegendPosTabPage(); + virtual void dispose() SAL_OVERRIDE; - static SfxTabPage* Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); + static VclPtr<SfxTabPage> Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); virtual bool FillItemSet(SfxItemSet* rOutAttrs) SAL_OVERRIDE; virtual void Reset(const SfxItemSet* rInAttrs) SAL_OVERRIDE; }; @@ -39,13 +39,20 @@ SchLayoutTabPage::SchLayoutTabPage(vcl::Window* pWindow,const SfxItemSet& rInAtt SchLayoutTabPage::~SchLayoutTabPage() { + disposeOnce(); +} + +void SchLayoutTabPage::dispose() +{ delete m_pGeometryResources; + m_pGeometryResources = NULL; + SfxTabPage::dispose(); } -SfxTabPage* SchLayoutTabPage::Create(vcl::Window* pWindow, - const SfxItemSet* rOutAttrs) +VclPtr<SfxTabPage> SchLayoutTabPage::Create(vcl::Window* pWindow, + const SfxItemSet* rOutAttrs) { - return new SchLayoutTabPage(pWindow, *rOutAttrs); + return VclPtr<SchLayoutTabPage>::Create(pWindow, *rOutAttrs); } bool SchLayoutTabPage::FillItemSet(SfxItemSet* rOutAttrs) @@ -30,8 +30,9 @@ class SchLayoutTabPage : public SfxTabPage public: SchLayoutTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs); virtual ~SchLayoutTabPage(); + virtual void dispose() SAL_OVERRIDE; - static SfxTabPage* Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); + static VclPtr<SfxTabPage> Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); virtual bool FillItemSet(SfxItemSet* rOutAttrs) SAL_OVERRIDE; virtual void Reset(const SfxItemSet* rInAttrs) SAL_OVERRIDE; @@ -46,11 +46,23 @@ PolarOptionsTabPage::PolarOptionsTabPage( vcl::Window* pWindow,const SfxItemSet& PolarOptionsTabPage::~PolarOptionsTabPage() { + disposeOnce(); } -SfxTabPage* PolarOptionsTabPage::Create( vcl::Window* pWindow,const SfxItemSet* rOutAttrs ) +void PolarOptionsTabPage::dispose() { - return new PolarOptionsTabPage( pWindow, *rOutAttrs ); + m_pCB_Clockwise.clear(); + m_pFL_StartingAngle.clear(); + m_pAngleDial.clear(); + m_pNF_StartingAngle.clear(); + m_pFL_PlotOptions.clear(); + m_pCB_IncludeHiddenCells.clear(); + SfxTabPage::dispose(); +} + +VclPtr<SfxTabPage> PolarOptionsTabPage::Create( vcl::Window* pWindow,const SfxItemSet* rOutAttrs ) +{ + return VclPtr<PolarOptionsTabPage>::Create( pWindow, *rOutAttrs ); } bool PolarOptionsTabPage::FillItemSet( SfxItemSet* rOutAttrs ) @@ -34,18 +34,19 @@ class PolarOptionsTabPage : public SfxTabPage public: PolarOptionsTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs ); virtual ~PolarOptionsTabPage(); + virtual void dispose() SAL_OVERRIDE; - static SfxTabPage* Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); + static VclPtr<SfxTabPage> Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); virtual bool FillItemSet(SfxItemSet* rOutAttrs) SAL_OVERRIDE; virtual void Reset(const SfxItemSet* rInAttrs) SAL_OVERRIDE; private: - CheckBox* m_pCB_Clockwise; - VclFrame* m_pFL_StartingAngle; - svx::DialControl* m_pAngleDial; - NumericField* m_pNF_StartingAngle; - VclFrame* m_pFL_PlotOptions; - CheckBox* m_pCB_IncludeHiddenCells; + VclPtr<CheckBox> m_pCB_Clockwise; + VclPtr<VclFrame> m_pFL_StartingAngle; + VclPtr<svx::DialControl> m_pAngleDial; + VclPtr<NumericField> m_pNF_StartingAngle; + VclPtr<VclFrame> m_pFL_PlotOptions; + VclPtr<CheckBox> m_pCB_IncludeHiddenCells; }; } //namespace chart @@ -124,8 +124,28 @@ RangeChooserTabPage::RangeChooserTabPage( vcl::Window* pParent RangeChooserTabPage::~RangeChooserTabPage() { + disposeOnce(); } +void RangeChooserTabPage::dispose() +{ + m_pFT_Caption.clear(); + m_pFT_Range.clear(); + m_pED_Range.clear(); + m_pIB_Range.clear(); + m_pRB_Rows.clear(); + m_pRB_Columns.clear(); + m_pCB_FirstRowAsLabel.clear(); + m_pCB_FirstColumnAsLabel.clear(); + m_pFTTitle.clear(); + m_pCB_TimeBased.clear(); + m_pEd_TimeStart.clear(); + m_pEd_TimeEnd.clear(); + m_pParentDialog.clear(); + OWizardPage::dispose(); +} + + void RangeChooserTabPage::ActivatePage() { OWizardPage::ActivatePage(); @@ -48,7 +48,8 @@ public: , ChartTypeTemplateProvider* pTemplateProvider , Dialog * pParentDialog , bool bHideDescription = false ); -virtual ~RangeChooserTabPage(); + virtual ~RangeChooserTabPage(); + virtual void dispose() SAL_OVERRIDE; //RangeSelectionListenerParent virtual void listeningFinished( const OUString & rNewRange ) SAL_OVERRIDE; @@ -76,21 +77,21 @@ protected: //methods protected: //member - FixedText* m_pFT_Caption; - FixedText* m_pFT_Range; - Edit* m_pED_Range; - PushButton* m_pIB_Range; + VclPtr<FixedText> m_pFT_Caption; + VclPtr<FixedText> m_pFT_Range; + VclPtr<Edit> m_pED_Range; + VclPtr<PushButton> m_pIB_Range; - RadioButton* m_pRB_Rows; - RadioButton* m_pRB_Columns; + VclPtr<RadioButton> m_pRB_Rows; + VclPtr<RadioButton> m_pRB_Columns; - CheckBox* m_pCB_FirstRowAsLabel; - CheckBox* m_pCB_FirstColumnAsLabel; - FixedText* m_pFTTitle; + VclPtr<CheckBox> m_pCB_FirstRowAsLabel; + VclPtr<CheckBox> m_pCB_FirstColumnAsLabel; + VclPtr<FixedText> m_pFTTitle; - CheckBox* m_pCB_TimeBased; - Edit* m_pEd_TimeStart; - Edit* m_pEd_TimeEnd; + VclPtr<CheckBox> m_pCB_TimeBased; + VclPtr<Edit> m_pEd_TimeStart; + VclPtr<Edit> m_pEd_TimeEnd; sal_Int32 m_nChangingControlCalls; bool m_bIsDirty; @@ -106,7 +107,7 @@ protected: //member ChartTypeTemplateProvider* m_pTemplateProvider; DialogModel & m_rDialogModel; - Dialog * m_pParentDialog; + VclPtr<Dialog> m_pParentDialog; TabPageNotifiable * m_pTabPageNotifiable; }; @@ -122,6 +122,41 @@ ScaleTabPage::ScaleTabPage(vcl::Window* pWindow,const SfxItemSet& rInAttrs) : HideAllControls(); } +ScaleTabPage::~ScaleTabPage() +{ + disposeOnce(); +} + +void ScaleTabPage::dispose() +{ + m_pCbxReverse.clear(); + m_pCbxLogarithm.clear(); + m_pBxType.clear(); + m_pLB_AxisType.clear(); + m_pBxMinMax.clear(); + m_pFmtFldMin.clear(); + m_pCbxAutoMin.clear(); + m_pFmtFldMax.clear(); + m_pCbxAutoMax.clear(); + m_pBxResolution.clear(); + m_pLB_TimeResolution.clear(); + m_pCbx_AutoTimeResolution.clear(); + m_pTxtMain.clear(); + m_pFmtFldStepMain.clear(); + m_pMt_MainDateStep.clear(); + m_pLB_MainTimeUnit.clear(); + m_pCbxAutoStepMain.clear(); + m_pTxtHelpCount.clear(); + m_pTxtHelp.clear(); + m_pMtStepHelp.clear(); + m_pLB_HelpTimeUnit.clear(); + m_pCbxAutoStepHelp.clear(); + m_pFmtFldOrigin.clear(); + m_pCbxAutoOrigin.clear(); + m_pBxOrigin.clear(); + SfxTabPage::dispose(); +} + IMPL_LINK( ScaleTabPage, FmtFieldModifiedHdl, FormattedField*, pFmtFied ) { if( pFmtFied ) @@ -236,9 +271,9 @@ IMPL_LINK_NOARG(ScaleTabPage, SelectAxisTypeHdl) return 0; } -SfxTabPage* ScaleTabPage::Create(vcl::Window* pWindow,const SfxItemSet* rOutAttrs) +VclPtr<SfxTabPage> ScaleTabPage::Create(vcl::Window* pWindow,const SfxItemSet* rOutAttrs) { - return new ScaleTabPage(pWindow, *rOutAttrs); + return VclPtr<ScaleTabPage>::Create(pWindow, *rOutAttrs); } bool ScaleTabPage::FillItemSet(SfxItemSet* rOutAttrs) @@ -33,8 +33,10 @@ class ScaleTabPage : public SfxTabPage { public: ScaleTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); + virtual ~ScaleTabPage(); + virtual void dispose() SAL_OVERRIDE; - static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); + static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); virtual bool FillItemSet( SfxItemSet* rOutAttrs ) SAL_OVERRIDE; virtual void Reset( const SfxItemSet* rInAttrs ) SAL_OVERRIDE; using TabPage::DeactivatePage; @@ -48,38 +50,38 @@ public: virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE; private: - CheckBox* m_pCbxReverse; - CheckBox* m_pCbxLogarithm; - - VclBox* m_pBxType; - ListBox* m_pLB_AxisType; - - VclGrid* m_pBxMinMax; - FormattedField* m_pFmtFldMin; - CheckBox* m_pCbxAutoMin; - - FormattedField* m_pFmtFldMax; - CheckBox* m_pCbxAutoMax; - - VclBox* m_pBxResolution; - ListBox* m_pLB_TimeResolution; - CheckBox* m_pCbx_AutoTimeResolution; - - FixedText* m_pTxtMain; - FormattedField* m_pFmtFldStepMain; - MetricField* m_pMt_MainDateStep; - ListBox* m_pLB_MainTimeUnit; - CheckBox* m_pCbxAutoStepMain; - - FixedText* m_pTxtHelpCount; - FixedText* m_pTxtHelp; - MetricField* m_pMtStepHelp; - ListBox* m_pLB_HelpTimeUnit; - CheckBox* m_pCbxAutoStepHelp; - - FormattedField* m_pFmtFldOrigin; - CheckBox* m_pCbxAutoOrigin; - VclBox* m_pBxOrigin; + VclPtr<CheckBox> m_pCbxReverse; + VclPtr<CheckBox> m_pCbxLogarithm; + + VclPtr<VclBox> m_pBxType; + VclPtr<ListBox> m_pLB_AxisType; + + VclPtr<VclGrid> m_pBxMinMax; + VclPtr<FormattedField> m_pFmtFldMin; + VclPtr<CheckBox> m_pCbxAutoMin; + + VclPtr<FormattedField> m_pFmtFldMax; + VclPtr<CheckBox> m_pCbxAutoMax; + + VclPtr<VclBox> m_pBxResolution; + VclPtr<ListBox> m_pLB_TimeResolution; + VclPtr<CheckBox> m_pCbx_AutoTimeResolution; + + VclPtr<FixedText> m_pTxtMain; + VclPtr<FormattedField> m_pFmtFldStepMain; + VclPtr<MetricField> m_pMt_MainDateStep; + VclPtr<ListBox> m_pLB_MainTimeUnit; + VclPtr<CheckBox> m_pCbxAutoStepMain; + + VclPtr<FixedText> m_pTxtHelpCount; + VclPtr<FixedText> m_pTxtHelp; + VclPtr<MetricField> m_pMtStepHelp; + VclPtr<ListBox> m_pLB_HelpTimeUnit; + VclPtr<CheckBox> m_pCbxAutoStepHelp; + + VclPtr<FormattedField> m_pFmtFldOrigin; + VclPtr<CheckBox> m_pCbxAutoOrigin; + VclPtr<VclBox> m_pBxOrigin; double fMin; double fMax; @@ -65,6 +65,26 @@ SchOptionTabPage::SchOptionTabPage(vcl::Window* pWindow,const SfxItemSet& rInAtt SchOptionTabPage::~SchOptionTabPage() { + disposeOnce(); +} + +void SchOptionTabPage::dispose() +{ + m_pGrpAxis.clear(); + m_pRbtAxis1.clear(); + m_pRbtAxis2.clear(); + m_pGrpBar.clear(); + m_pMTGap.clear(); + m_pMTOverlap.clear(); + m_pCBConnect.clear(); + m_pCBAxisSideBySide.clear(); + m_pGrpPlotOptions.clear(); + m_pGridPlotOptions.clear(); + m_pRB_DontPaint.clear(); + m_pRB_AssumeZero.clear(); + m_pRB_ContinueLine.clear(); + m_pCBIncludeHiddenCells.clear(); + SfxTabPage::dispose(); } IMPL_LINK_NOARG(SchOptionTabPage, EnableHdl) @@ -77,9 +97,10 @@ IMPL_LINK_NOARG(SchOptionTabPage, EnableHdl) return 0; } -SfxTabPage* SchOptionTabPage::Create(vcl::Window* pWindow,const SfxItemSet* rOutAttrs) +VclPtr<SfxTabPage> SchOptionTabPage::Create(vcl::Window* pWindow, + const SfxItemSet* rOutAttrs) { - return new SchOptionTabPage(pWindow, *rOutAttrs); + return VclPtr<SchOptionTabPage>::Create(pWindow, *rOutAttrs); } bool SchOptionTabPage::FillItemSet(SfxItemSet* rOutAttrs) @@ -32,8 +32,9 @@ class SchOptionTabPage : public SfxTabPage public: SchOptionTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs); virtual ~SchOptionTabPage(); + virtual void dispose() SAL_OVERRIDE; - static SfxTabPage* Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); + static VclPtr<SfxTabPage> Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); virtual bool FillItemSet(SfxItemSet* rOutAttrs) SAL_OVERRIDE; virtual void Reset(const SfxItemSet* rInAttrs) SAL_OVERRIDE; @@ -43,23 +44,23 @@ private: //methods void AdaptControlPositionsAndVisibility(); private: //member - VclFrame* m_pGrpAxis; - RadioButton* m_pRbtAxis1; - RadioButton* m_pRbtAxis2; - - VclFrame* m_pGrpBar; - MetricField* m_pMTGap; - MetricField* m_pMTOverlap; - CheckBox* m_pCBConnect; - CheckBox* m_pCBAxisSideBySide; - - VclFrame* m_pGrpPlotOptions; - VclGrid* m_pGridPlotOptions; - RadioButton* m_pRB_DontPaint; - RadioButton* m_pRB_AssumeZero; - RadioButton* m_pRB_ContinueLine; - - CheckBox* m_pCBIncludeHiddenCells; + VclPtr<VclFrame> m_pGrpAxis; + VclPtr<RadioButton> m_pRbtAxis1; + VclPtr<RadioButton> m_pRbtAxis2; + + VclPtr<VclFrame> m_pGrpBar; + VclPtr<MetricField> m_pMTGap; + VclPtr<MetricField> m_pMTOverlap; + VclPtr<CheckBox> m_pCBConnect; + VclPtr<CheckBox> m_pCBAxisSideBySide; + + VclPtr<VclGrid> m_pGrpPlotOptions; + VclPtr<VclGrid> m_pGridPlotOptions; + VclPtr<RadioButton> m_pRB_DontPaint; + VclPtr<RadioButton> m_pRB_AssumeZero; + VclPtr<RadioButton> m_pRB_ContinueLine; + + VclPtr<CheckBox> m_pCBIncludeHiddenCells; DECL_LINK(EnableHdl, void * ); @@ -57,19 +57,33 @@ SchAlignmentTabPage::SchAlignmentTabPage(vcl::Window* pWindow, SchAlignmentTabPage::~SchAlignmentTabPage() { + disposeOnce(); +} + +void SchAlignmentTabPage::dispose() +{ delete m_pOrientHlp; + m_pOrientHlp = NULL; + m_pCtrlDial.clear(); + m_pFtRotate.clear(); + m_pNfRotate.clear(); + m_pCbStacked.clear(); + m_pFtTextDirection.clear(); + m_pLbTextDirection.clear(); + m_pFtABCD.clear(); + SfxTabPage::dispose(); } -SfxTabPage* SchAlignmentTabPage::Create(vcl::Window* pParent, - const SfxItemSet* rInAttrs) +VclPtr<SfxTabPage> SchAlignmentTabPage::Create(vcl::Window* pParent, + const SfxItemSet* rInAttrs) { - return new SchAlignmentTabPage(pParent, *rInAttrs); + return VclPtr<SchAlignmentTabPage>::Create(pParent, *rInAttrs); } -SfxTabPage* SchAlignmentTabPage::CreateWithoutRotation(vcl::Window* pParent, - const SfxItemSet* rInAttrs) +VclPtr<SfxTabPage> SchAlignmentTabPage::CreateWithoutRotation(vcl::Window* pParent, + const SfxItemSet* rInAttrs) { - return new SchAlignmentTabPage(pParent, *rInAttrs, false); + return VclPtr<SchAlignmentTabPage>::Create(pParent, *rInAttrs, false); } bool SchAlignmentTabPage::FillItemSet(SfxItemSet* rOutAttrs) @@ -31,21 +31,22 @@ namespace chart class SchAlignmentTabPage : public SfxTabPage { private: - svx::DialControl* m_pCtrlDial; - FixedText* m_pFtRotate; - NumericField* m_pNfRotate; - TriStateBox* m_pCbStacked; + VclPtr<svx::DialControl> m_pCtrlDial; + VclPtr<FixedText> m_pFtRotate; + VclPtr<NumericField> m_pNfRotate; + VclPtr<TriStateBox> m_pCbStacked; svx::OrientationHelper* m_pOrientHlp; - FixedText* m_pFtTextDirection; - TextDirectionListBox* m_pLbTextDirection; - FixedText* m_pFtABCD; + VclPtr<FixedText> m_pFtTextDirection; + VclPtr<TextDirectionListBox> m_pLbTextDirection; + VclPtr<FixedText> m_pFtABCD; public: SchAlignmentTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs, bool bWithRotation = true); virtual ~SchAlignmentTabPage(); + virtual void dispose() SAL_OVERRIDE; - static SfxTabPage* Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); - static SfxTabPage* CreateWithoutRotation(vcl::Window* pParent, const SfxItemSet* rInAttrs); + static VclPtr<SfxTabPage> Create(vcl::Window* pParent, const SfxItemSet* rInAttrs); + static VclPtr<SfxTabPage> CreateWithoutRotation(vcl::Window* pParent, const SfxItemSet* rInAttrs); virtual bool FillItemSet(SfxItemSet* rOutAttrs) SAL_OVERRIDE; virtual void Reset(const SfxItemSet* rInAttrs) SAL_OVERRIDE; }; @@ -31,14 +31,10 @@ TrendlineTabPage::TrendlineTabPage( vcl::Window* pParent, const SfxItemSet& rInA { } -TrendlineTabPage::~TrendlineTabPage() -{ -} - -SfxTabPage* TrendlineTabPage::Create( +VclPtr<SfxTabPage> TrendlineTabPage::Create( vcl::Window* pParent, const SfxItemSet* rOutAttrs ) { - return new TrendlineTabPage( pParent, *rOutAttrs ); + return VclPtr<TrendlineTabPage>::Create( pParent, *rOutAttrs ); } bool TrendlineTabPage::FillItemSet( SfxItemSet* rOutAttrs ) @@ -30,9 +30,8 @@ class TrendlineTabPage : public SfxTabPage { public: TrendlineTabPage ( vcl::Window* pParent, const SfxItemSet& rInAttrs ); - virtual ~TrendlineTabPage (); - static SfxTabPage* Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); + static VclPtr<SfxTabPage> Create( vcl::Window* pParent, const SfxItemSet* rInAttrs ); virtual bool FillItemSet( SfxItemSet* rOutAttrs ) SAL_OVERRIDE; virtual void Reset( const SfxItemSet* rInAttrs ) SAL_OVERRIDE; @@ -57,6 +57,19 @@ TitlesAndObjectsTabPage::TitlesAndObjectsTabPage( svt::OWizardMachine* pParent m_pCB_Grid_Z->SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); } +TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage() +{ + disposeOnce(); +} + +void TitlesAndObjectsTabPage::dispose() +{ + m_pCB_Grid_X.clear(); + m_pCB_Grid_Y.clear(); + m_pCB_Grid_Z.clear(); + OWizardPage::dispose(); +} + void TitlesAndObjectsTabPage::initializePage() { m_bCommitToModel = false; @@ -44,6 +44,8 @@ public: ::com::sun::star::chart2::XChartDocument >& xChartModel , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ); + virtual ~TitlesAndObjectsTabPage(); + virtual void dispose() SAL_OVERRIDE; virtual void initializePage() SAL_OVERRIDE; virtual bool commitPage( ::svt::WizardTypes::CommitPageReason eReason ) SAL_OVERRIDE; @@ -57,9 +59,9 @@ protected: boost::scoped_ptr< TitleResources > m_xTitleResources; boost::scoped_ptr< LegendPositionResources > m_xLegendPositionResources; - CheckBox* m_pCB_Grid_X; - CheckBox* m_pCB_Grid_Y; - CheckBox* m_pCB_Grid_Z; + VclPtr<CheckBox> m_pCB_Grid_X; + VclPtr<CheckBox> m_pCB_Grid_Y; + VclPtr<CheckBox> m_pCB_Grid_Z; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartModel; @@ -143,14 +143,14 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co nStandardSymbol %= pSymbolList->GetObjCount(); SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol); - VirtualDevice aVDev; - aVDev.SetMapMode(MapMode(MAP_100TH_MM)); + ScopedVclPtrInstance< VirtualDevice > pVDev; + pVDev->SetMapMode(MapMode(MAP_100TH_MM)); SdrModel* pModel = new SdrModel(); pModel->GetItemPool().FreezeIdRanges(); SdrPage* pPage = new SdrPage( *pModel, false ); pPage->SetSize(Size(1000,1000)); pModel->InsertPage( pPage, 0 ); - SdrView* pView = new SdrView( pModel, &aVDev ); + SdrView* pView = new SdrView( pModel, pVDev ); pView->hideMarkHandles(); SdrPageView* pPageView = pView->ShowSdrPage(pPage); @@ -32,7 +32,6 @@ class TextDirectionListBox : public svx::FrameDirectionListBox public: explicit TextDirectionListBox( vcl::Window* pParent, vcl::Window* pWindow1 = 0, vcl::Window* pWindow2 = 0 ); - virtual ~TextDirectionListBox(); }; } //namespace chart @@ -38,9 +38,10 @@ public: , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ); virtual ~ChartTypeDialog(); + virtual void dispose() SAL_OVERRIDE; private: - ChartTypeTabPage* m_pChartTypeTabPage; + VclPtr<ChartTypeTabPage> m_pChartTypeTabPage; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; @@ -44,7 +44,7 @@ private: // OGenericUnoDialog overridables virtual void implInitialize(const com::sun::star::uno::Any& _rValue) SAL_OVERRIDE; - virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE; + virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE; // XTypeProvider virtual com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; @@ -22,6 +22,7 @@ #include "TimerTriggeredControllerLock.hxx" #include "TabPageNotifiable.hxx" +#include "../dialogs/DialogModel.hxx" #include <com/sun/star/chart2/XChartDocument.hpp> #include <svtools/roadmapwizard.hxx> @@ -36,7 +37,6 @@ namespace chart class RangeChooserTabPage; class DataSourceTabPage; class ChartTypeTemplateProvider; -class DialogModel; class CreationWizard : public svt::RoadmapWizard, public TabPageNotifiable { @@ -47,7 +47,6 @@ public: , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext , sal_Int32 nOnePageOnlyIndex=-1 );//if nOnePageOnlyIndex is an index of an exsisting page starting with 0, then only this page is displayed without next/previous and roadmap - virtual ~CreationWizard(); bool isClosable() { /*@todo*/ return m_bIsClosable;} @@ -66,7 +65,7 @@ private: //no default constructor CreationWizard(); - virtual svt::OWizardPage* createPage(WizardState nState) SAL_OVERRIDE; + virtual VclPtr<TabPage> createPage(WizardState nState) SAL_OVERRIDE; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartModel; @@ -119,7 +119,7 @@ private: com::sun::star::uno::Reference< com::sun::star::awt::XWindow > m_xParentWindow; - CreationWizard* m_pDialog; + VclPtr<CreationWizard> m_pDialog; bool m_bUnlockControllersOnExecute; }; @@ -48,6 +48,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext ); virtual ~DataEditor(); + virtual void dispose() SAL_OVERRIDE; // Dialog virtual bool Close() SAL_OVERRIDE; @@ -65,8 +66,8 @@ private: sal_uInt16 TBI_DATA_SWAP_ROW; bool m_bReadOnly; - boost::scoped_ptr<DataBrowser> m_xBrwData; - ToolBox* m_pTbxData; + VclPtr<DataBrowser> m_xBrwData; + VclPtr<ToolBox> m_pTbxData; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartDoc; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > @@ -50,6 +50,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext ); virtual ~DataSourceDialog(); + virtual void dispose() SAL_OVERRIDE; // from Dialog (base of TabDialog) virtual short Execute() SAL_OVERRIDE; @@ -67,11 +68,11 @@ protected: ::std::unique_ptr< DialogModel > m_apDialogModel; private: - DataSourceTabControl* m_pTabControl; - OKButton* m_pBtnOK; + VclPtr<DataSourceTabControl> m_pTabControl; + VclPtr<OKButton> m_pBtnOK; - RangeChooserTabPage * m_pRangeChooserTabePage; - DataSourceTabPage * m_pDataSourceTabPage; + VclPtr<RangeChooserTabPage> m_pRangeChooserTabePage; + VclPtr<DataSourceTabPage> m_pDataSourceTabPage; bool m_bRangeChooserTabIsValid; bool m_bDataSourceTabIsValid; @@ -43,16 +43,17 @@ struct InsertAxisOrGridDialogData class SchAxisDlg : public ModalDialog { protected: - CheckBox* m_pCbPrimaryX; - CheckBox* m_pCbPrimaryY; - CheckBox* m_pCbPrimaryZ; - CheckBox* m_pCbSecondaryX; - CheckBox* m_pCbSecondaryY; - CheckBox* m_pCbSecondaryZ; + VclPtr<CheckBox> m_pCbPrimaryX; + VclPtr<CheckBox> m_pCbPrimaryY; + VclPtr<CheckBox> m_pCbPrimaryZ; + VclPtr<CheckBox> m_pCbSecondaryX; + VclPtr<CheckBox> m_pCbSecondaryY; + VclPtr<CheckBox> m_pCbSecondaryZ; public: SchAxisDlg(vcl::Window* pParent, const InsertAxisOrGridDialogData& rInput, bool bAxisDlg=true); virtual ~SchAxisDlg(); + virtual void dispose() SAL_OVERRIDE; void getResult( InsertAxisOrGridDialogData& rOutput ); }; @@ -66,7 +67,6 @@ class SchGridDlg : public SchAxisDlg { public: SchGridDlg( vcl::Window* pParent, const InsertAxisOrGridDialogData& rInput ); - virtual ~SchGridDlg(); }; } //namespace chart @@ -23,13 +23,13 @@ #include <vcl/button.hxx> #include <svl/itemset.hxx> #include <boost/scoped_ptr.hpp> +#include "../dialogs/res_DataLabel.hxx" class SvNumberFormatter; namespace chart { -class DataLabelResources; class DataLabelsDialog : public ModalDialog { private: @@ -44,7 +44,6 @@ private: public: DataLabelsDialog(vcl::Window* pParent, const SfxItemSet& rInAttrs, SvNumberFormatter* pFormatter); - virtual ~DataLabelsDialog(); void FillItemSet(SfxItemSet& rOutAttrs); }; @@ -36,7 +36,6 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDocument, ErrorBarResources::tErrorBarType eType ); - virtual ~InsertErrorBarsDialog(); void SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ); @@ -132,6 +132,7 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); virtual ~SchAttribTabDlg(); + virtual void dispose() SAL_OVERRIDE; //pSymbolShapeProperties: Properties to be set on the symbollist shapes //pAutoSymbolGraphic: Graphic to be shown if AutoSymbol gets selected @@ -41,16 +41,17 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xChartModel, const XColorListRef &pColorTable ); virtual ~View3DDialog(); + virtual void dispose() SAL_OVERRIDE; // from Dialog (base of TabDialog) virtual short Execute() SAL_OVERRIDE; private: - TabControl* m_pTabControl; + VclPtr<TabControl> m_pTabControl; - ThreeD_SceneGeometry_TabPage* m_pGeometry; - ThreeD_SceneAppearance_TabPage* m_pAppearance; - ThreeD_SceneIllumination_TabPage* m_pIllumination; + VclPtr<ThreeD_SceneGeometry_TabPage> m_pGeometry; + VclPtr<ThreeD_SceneAppearance_TabPage> m_pAppearance; + VclPtr<ThreeD_SceneIllumination_TabPage> m_pIllumination; ControllerLockHelper m_aControllerLocker; @@ -67,36 +67,36 @@ public: private: // category - RadioButton* m_pRbNone; - RadioButton* m_pRbConst; - RadioButton* m_pRbPercent; - RadioButton* m_pRbFunction; - RadioButton* m_pRbRange; - ListBox* m_pLbFunction; + VclPtr<RadioButton> m_pRbNone; + VclPtr<RadioButton> m_pRbConst; + VclPtr<RadioButton> m_pRbPercent; + VclPtr<RadioButton> m_pRbFunction; + VclPtr<RadioButton> m_pRbRange; + VclPtr<ListBox> m_pLbFunction; // parameters - VclFrame* m_pFlParameters; - VclBox* m_pBxPositive; - MetricField* m_pMfPositive; - Edit* m_pEdRangePositive; - PushButton* m_pIbRangePositive; - VclBox* m_pBxNegative; - MetricField* m_pMfNegative; - Edit* m_pEdRangeNegative; - PushButton* m_pIbRangeNegative; - CheckBox* m_pCbSyncPosNeg; + VclPtr<VclFrame> m_pFlParameters; + VclPtr<VclBox> m_pBxPositive; + VclPtr<MetricField> m_pMfPositive; + VclPtr<Edit> m_pEdRangePositive; + VclPtr<PushButton> m_pIbRangePositive; + VclPtr<VclBox> m_pBxNegative; + VclPtr<MetricField> m_pMfNegative; + VclPtr<Edit> m_pEdRangeNegative; + VclPtr<PushButton> m_pIbRangeNegative; + VclPtr<CheckBox> m_pCbSyncPosNeg; // indicator - RadioButton* m_pRbBoth; - RadioButton* m_pRbPositive; - RadioButton* m_pRbNegative; - FixedImage* m_pFiBoth; - FixedImage* m_pFiPositive; - FixedImage* m_pFiNegative; + VclPtr<RadioButton> m_pRbBoth; + VclPtr<RadioButton> m_pRbPositive; + VclPtr<RadioButton> m_pRbNegative; + VclPtr<FixedImage> m_pFiBoth; + VclPtr<FixedImage> m_pFiPositive; + VclPtr<FixedImage> m_pFiNegative; - FixedText* m_pUIStringPos; - FixedText* m_pUIStringNeg; - FixedText* m_pUIStringRbRange; + VclPtr<FixedText> m_pUIStringPos; + VclPtr<FixedText> m_pUIStringNeg; + VclPtr<FixedText> m_pUIStringRbRange; SvxChartKindError m_eErrorKind; SvxChartIndicate m_eIndicate; @@ -116,9 +116,9 @@ private: double m_fPlusValue; double m_fMinusValue; - Dialog * m_pParentDialog; + VclPtr<Dialog> m_pParentDialog; boost::scoped_ptr< RangeSelectionHelper > m_apRangeSelectionHelper; - Edit * m_pCurrentRangeChoosingField; + VclPtr<Edit> m_pCurrentRangeChoosingField; bool m_bHasInternalDataProvider; bool m_bEnableDataTableDialog; @@ -60,12 +60,12 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xCC; - CheckBox* m_pCbxShow; + VclPtr<CheckBox> m_pCbxShow; - RadioButton* m_pRbtLeft; - RadioButton* m_pRbtRight; - RadioButton* m_pRbtTop; - RadioButton* m_pRbtBottom; + VclPtr<RadioButton> m_pRbtLeft; + VclPtr<RadioButton> m_pRbtRight; + VclPtr<RadioButton> m_pRbtTop; + VclPtr<RadioButton> m_pRbtBottom; Link m_aChangeLink; }; @@ -40,22 +40,22 @@ public: void ClearModifyFlag(); private: - FixedText* m_pFT_Main; - FixedText* m_pFT_Sub; - Edit* m_pEd_Main; - Edit* m_pEd_Sub; + VclPtr<FixedText> m_pFT_Main; + VclPtr<FixedText> m_pFT_Sub; + VclPtr<Edit> m_pEd_Main; + VclPtr<Edit> m_pEd_Sub; - FixedText* m_pFT_XAxis; - FixedText* m_pFT_YAxis; - FixedText* m_pFT_ZAxis; - Edit* m_pEd_XAxis; - Edit* m_pEd_YAxis; - Edit* m_pEd_ZAxis; + VclPtr<FixedText> m_pFT_XAxis; + VclPtr<FixedText> m_pFT_YAxis; + VclPtr<FixedText> m_pFT_ZAxis; + VclPtr<Edit> m_pEd_XAxis; + VclPtr<Edit> m_pEd_YAxis; + VclPtr<Edit> m_pEd_ZAxis; - FixedText* m_pFT_SecondaryXAxis; - FixedText* m_pFT_SecondaryYAxis; - Edit* m_pEd_SecondaryXAxis; - Edit* m_pEd_SecondaryYAxis; + VclPtr<FixedText> m_pFT_SecondaryXAxis; + VclPtr<FixedText> m_pFT_SecondaryYAxis; + VclPtr<Edit> m_pEd_SecondaryXAxis; + VclPtr<Edit> m_pEd_SecondaryYAxis; }; } //namespace chart @@ -388,7 +388,7 @@ void SAL_CALL ChartController::attachFrame( { // calls to VCL SolarMutexGuard aSolarGuard; - m_pChartWindow = new ChartWindow(this,pParent,pParent?pParent->GetStyle():0); + m_pChartWindow = VclPtr<ChartWindow>::Create(this,pParent,pParent?pParent->GetStyle():0); m_pChartWindow->SetBackground();//no Background m_xViewWindow = uno::Reference< awt::XWindow >( m_pChartWindow->GetComponentInterface(), uno::UNO_QUERY ); m_pChartWindow->Show(); @@ -1271,8 +1271,8 @@ void ChartController::executeDispatch_ChartType() SolarMutexGuard aSolarGuard; //prepare and open dialog - ChartTypeDialog aDlg( m_pChartWindow, getModel(), m_xCC ); - if( aDlg.Execute() == RET_OK ) + ScopedVclPtrInstance< ChartTypeDialog > aDlg( m_pChartWindow, getModel(), m_xCC ); + if( aDlg->Execute() == RET_OK ) { impl_adaptDataSeriesAutoResize(); aUndoGuard.commit(); @@ -1292,8 +1292,8 @@ void ChartController::executeDispatch_SourceData() if( xChartDoc.is()) { SolarMutexGuard aSolarGuard; - ::chart::DataSourceDialog aDlg( m_pChartWindow, xChartDoc, m_xCC ); - if( aDlg.Execute() == RET_OK ) + ScopedVclPtrInstance< ::chart::DataSourceDialog > aDlg( m_pChartWindow, xChartDoc, m_xCC ); + if( aDlg->Execute() == RET_OK ) { impl_adaptDataSeriesAutoResize(); aUndoGuard.commit(); @@ -508,7 +508,7 @@ private: TheModelRef m_aModel; //view - ChartWindow* m_pChartWindow; + VclPtr<ChartWindow> m_pChartWindow; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xViewWindow; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xChartView; @@ -54,10 +54,9 @@ void ChartController::executeDispatch_EditData() UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData( SCH_RESSTR( STR_ACTION_EDIT_CHART_DATA ), m_xUndoManager ); - vcl::Window* pParent( NULL ); - DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC ); - if (aDataEditorDialog.Execute() == RET_OK) - aDataEditorDialog.ApplyChangesToModel(); + ScopedVclPtrInstance<DataEditor> aDataEditorDialog( nullptr, xChartDoc, m_xCC ); + if (aDataEditorDialog->Execute() == RET_OK) + aDataEditorDialog->ApplyChangesToModel(); aUndoGuard.commit(); } } @@ -109,14 +109,14 @@ void ChartController::executeDispatch_InsertAxes() AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram, true ); SolarMutexGuard aGuard; - SchAxisDlg aDlg( m_pChartWindow, aDialogInput ); - if( aDlg.Execute() == RET_OK ) + ScopedVclPtrInstance<SchAxisDlg> aDlg( m_pChartWindow, aDialogInput ); + if( aDlg->Execute() == RET_OK ) { // lock controllers till end of block ControllerLockGuardUNO aCLGuard( getModel() ); InsertAxisOrGridDialogData aDialogOutput; - aDlg.getResult( aDialogOutput ); + aDlg->getResult( aDialogOutput ); boost::scoped_ptr< ReferenceSizeProvider > mpRefSizeProvider( impl_createReferenceSizeProvider()); bool bChanged = AxisHelper::changeVisibilityOfAxes( xDiagram @@ -147,13 +147,13 @@ void ChartController::executeDispatch_InsertGrid() AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram, false ); SolarMutexGuard aGuard; - SchGridDlg aDlg( m_pChartWindow, aDialogInput );//aItemSet, b3D, bNet, bSecondaryX, bSecondaryY ); - if( aDlg.Execute() == RET_OK ) + ScopedVclPtrInstance<SchGridDlg> aDlg(m_pChartWindow, aDialogInput);//aItemSet, b3D, bNet, bSecondaryX, bSecondaryY ); + if( aDlg->Execute() == RET_OK ) { // lock controllers till end of block ControllerLockGuardUNO aCLGuard( getModel() ); InsertAxisOrGridDialogData aDialogOutput; - aDlg.getResult( aDialogOutput ); + aDlg->getResult( aDialogOutput ); bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC ); if( bChanged ) @@ -179,13 +179,13 @@ void ChartController::executeDispatch_InsertTitles() aDialogInput.readFromModel( getModel() ); SolarMutexGuard aGuard; - SchTitleDlg aDlg( m_pChartWindow, aDialogInput ); - if( aDlg.Execute() == RET_OK ) + ScopedVclPtrInstance< SchTitleDlg > aDlg( m_pChartWindow, aDialogInput ); + if( aDlg->Execute() == RET_OK ) { // lock controllers till end of block ControllerLockGuardUNO aCLGuard( getModel() ); TitleDialogData aDialogOutput(impl_createReferenceSizeProvider()); - aDlg.getResult( aDialogOutput ); + aDlg->getResult( aDialogOutput ); bool bChanged = aDialogOutput.writeDifferenceToModel( getModel(), m_xCC, &aDialogInput ); if( bChanged ) aUndoGuard.commit(); @@ -232,13 +232,13 @@ void ChartController::executeDispatch_OpenLegendDialog() { //prepare and open dialog SolarMutexGuard aGuard; - SchLegendDlg aDlg( m_pChartWindow, m_xCC ); - aDlg.init( getModel() ); - if( aDlg.Execute() == RET_OK ) + ScopedVclPtrInstance< SchLegendDlg > aDlg( m_pChartWindow, m_xCC ); + aDlg->init( getModel() ); + if( aDlg->Execute() == RET_OK ) { // lock controllers till end of block ControllerLockGuardUNO aCLGuard( getModel() ); - bool bChanged = aDlg.writeToModel( getModel() ); + bool bChanged = aDlg->writeToModel( getModel() ); if( bChanged ) aUndoGuard.commit(); } @@ -292,12 +292,12 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); SvNumberFormatter* pNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter(); - DataLabelsDialog aDlg( m_pChartWindow, aItemSet, pNumberFormatter); + ScopedVclPtrInstance< DataLabelsDialog > aDlg( m_pChartWindow, aItemSet, pNumberFormatter); - if( aDlg.Execute() == RET_OK ) + if( aDlg->Execute() == RET_OK ) { SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); - aDlg.FillItemSet( aOutItemSet ); + aDlg- |