comphelper/source/misc/docpasswordrequest.cxx | 28 +-- framework/inc/services/layoutmanager.hxx | 6 framework/source/fwe/dispatch/interaction.cxx | 19 -- framework/source/layoutmanager/layoutmanager.cxx | 173 ++++++++------------ include/comphelper/docpasswordrequest.hxx | 13 - include/svx/unoprov.hxx | 3 sc/inc/dptabsrc.hxx | 6 sc/source/core/data/dptabsrc.cxx | 35 +--- sc/source/ui/Accessibility/AccessiblePageHeader.cxx | 82 ++------- sc/source/ui/inc/AccessiblePageHeader.hxx | 5 sot/source/sdstor/ucbstorage.cxx | 6 svx/source/unodraw/unoprov.cxx | 17 - sw/source/uibase/dochdl/swdtflvr.cxx | 4 13 files changed, 154 insertions(+), 243 deletions(-)
New commits: commit 63c40ba180a584646a69d4c95e20c8580db61211 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 15:13:03 2017 +0200 manage m_xInplaceMenuBar with rtl::Reference instead of both a raw pointer and an uno::Reference Change-Id: I44111694671371fac5c4207d1c46f99761bf10eb diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx index deeb049..85cde4b 100644 --- a/framework/inc/services/layoutmanager.hxx +++ b/framework/inc/services/layoutmanager.hxx @@ -278,8 +278,7 @@ namespace framework bool m_bMenuBarCloseButton; css::awt::Rectangle m_aDockingArea; css::uno::Reference< css::ui::XDockingAreaAcceptor > m_xDockingAreaAcceptor; - css::uno::Reference< css::lang::XComponent > m_xInplaceMenuBar; - MenuBarManager* m_pInplaceMenuBar; + rtl::Reference< MenuBarManager > m_xInplaceMenuBar; css::uno::Reference< css::ui::XUIElement > m_xMenuBar; UIElement m_aStatusBarElement; UIElement m_aProgressBarElement; diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index bf1e8db..4f3f86a 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -123,7 +123,6 @@ LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) : , m_bGlobalSettings( false ) , m_bPreserveContentSize( false ) , m_bMenuBarCloseButton( false ) - , m_pInplaceMenuBar( nullptr ) , m_xModuleManager( ModuleManager::create( xContext )) , m_xUIElementFactoryManager( ui::theUIElementFactoryManager::get(xContext) ) , m_xPersistentWindowStateSupplier( ui::theWindowStateConfiguration::get( xContext ) ) @@ -172,7 +171,7 @@ void LayoutManager::impl_clearUpMenuBar() { MenuBar* pSetMenuBar = nullptr; if ( m_xInplaceMenuBar.is() ) - pSetMenuBar = static_cast<MenuBar *>(m_pInplaceMenuBar->GetMenuBar()); + pSetMenuBar = static_cast<MenuBar *>(m_xInplaceMenuBar->GetMenuBar()); else { Reference< awt::XMenuBar > xMenuBar; @@ -205,13 +204,9 @@ void LayoutManager::impl_clearUpMenuBar() // reset inplace menubar manager VclPtr<Menu> pMenuBar; - if (m_pInplaceMenuBar) - { - pMenuBar = m_pInplaceMenuBar->GetMenuBar(); - m_pInplaceMenuBar = nullptr; - } - if ( m_xInplaceMenuBar.is() ) + if (m_xInplaceMenuBar.is()) { + pMenuBar = m_xInplaceMenuBar->GetMenuBar(); m_xInplaceMenuBar->dispose(); m_xInplaceMenuBar.clear(); } @@ -761,8 +756,7 @@ void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible ) SolarMutexResettableGuard aWriteLock; Reference< XUIElement > xMenuBar( m_xMenuBar, UNO_QUERY ); Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); - Reference< XComponent > xInplaceMenuBar( m_xInplaceMenuBar ); - MenuBarManager* pInplaceMenuBar( m_pInplaceMenuBar ); + rtl::Reference< MenuBarManager > xInplaceMenuBar( m_xInplaceMenuBar ); aWriteLock.clear(); if (( xMenuBar.is() || xInplaceMenuBar.is() ) && xContainerWindow.is() ) @@ -771,7 +765,7 @@ void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible ) MenuBar* pMenuBar( nullptr ); if ( xInplaceMenuBar.is() ) - pMenuBar = static_cast<MenuBar *>(pInplaceMenuBar->GetMenuBar()); + pMenuBar = static_cast<MenuBar *>(xInplaceMenuBar->GetMenuBar()); else { MenuBarWrapper* pMenuBarWrapper = (static_cast< MenuBarWrapper* >(xMenuBar.get()) ); @@ -1151,13 +1145,9 @@ throw (uno::RuntimeException, std::exception) // Reset old inplace menubar! VclPtr<Menu> pOldMenuBar; - if (m_pInplaceMenuBar) - { - pOldMenuBar = m_pInplaceMenuBar->GetMenuBar(); - m_pInplaceMenuBar = nullptr; - } if (m_xInplaceMenuBar.is()) { + pOldMenuBar = m_xInplaceMenuBar->GetMenuBar(); m_xInplaceMenuBar->dispose(); m_xInplaceMenuBar.clear(); } @@ -1171,15 +1161,14 @@ throw (uno::RuntimeException, std::exception) Reference< XDispatchProvider > xDispatchProvider; VclPtr<MenuBar> pMenuBar = VclPtr<MenuBar>::Create(); - m_pInplaceMenuBar = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer, xDispatchProvider, aModuleIdentifier, pMenuBar, true ); - m_pInplaceMenuBar->SetItemContainer( xMergedMenuBar ); + m_xInplaceMenuBar = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer, xDispatchProvider, aModuleIdentifier, pMenuBar, true ); + m_xInplaceMenuBar->SetItemContainer( xMergedMenuBar ); SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); if ( pSysWindow ) pSysWindow->SetMenuBar(pMenuBar); m_bInplaceMenuSet = true; - m_xInplaceMenuBar.set( static_cast<OWeakObject *>(m_pInplaceMenuBar), UNO_QUERY ); } aWriteLock.clear(); @@ -1211,13 +1200,9 @@ throw (uno::RuntimeException) // Remove inplace menu bar VclPtr<Menu> pMenuBar; - if (m_pInplaceMenuBar) - { - pMenuBar = m_pInplaceMenuBar->GetMenuBar(); - m_pInplaceMenuBar = nullptr; - } if (m_xInplaceMenuBar.is()) { + pMenuBar = m_xInplaceMenuBar->GetMenuBar(); m_xInplaceMenuBar->dispose(); m_xInplaceMenuBar.clear(); } @@ -2588,7 +2573,7 @@ bool LayoutManager::implts_resetMenuBar() MenuBar* pSetMenuBar = nullptr; if ( m_xInplaceMenuBar.is() ) - pSetMenuBar = static_cast<MenuBar *>(m_pInplaceMenuBar->GetMenuBar()); + pSetMenuBar = static_cast<MenuBar *>(m_xInplaceMenuBar->GetMenuBar()); else { MenuBarWrapper* pMenuBarWrapper = static_cast< MenuBarWrapper* >( m_xMenuBar.get() ); @@ -2831,13 +2816,9 @@ throw( RuntimeException, std::exception ) impl_clearUpMenuBar(); m_xMenuBar.clear(); VclPtr<Menu> pMenuBar; - if (m_pInplaceMenuBar) - { - pMenuBar = m_pInplaceMenuBar->GetMenuBar(); - m_pInplaceMenuBar = nullptr; - } if (m_xInplaceMenuBar.is()) { + pMenuBar = m_xInplaceMenuBar->GetMenuBar(); m_xInplaceMenuBar->dispose(); m_xInplaceMenuBar.clear(); } @@ -2895,13 +2876,9 @@ throw( RuntimeException, std::exception ) impl_clearUpMenuBar(); m_xMenuBar.clear(); VclPtr<Menu> pMenuBar; - if (m_pInplaceMenuBar) - { - pMenuBar = m_pInplaceMenuBar->GetMenuBar(); - m_pInplaceMenuBar = nullptr; - } if (m_xInplaceMenuBar.is()) { + pMenuBar = m_xInplaceMenuBar->GetMenuBar(); m_xInplaceMenuBar->dispose(); m_xInplaceMenuBar.clear(); } commit 2f4dbfdd2c94771ffa062789ed97dde0d63f0564 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 15:06:43 2017 +0200 manage m_xToolbarManager with rtl::Reference instead of both a raw pointer and an uno::Reference Change-Id: Idcdbbcd4f01c21bd32b4f00d3cfc3febd70e9194 diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx index 7a895cc..deeb049 100644 --- a/framework/inc/services/layoutmanager.hxx +++ b/framework/inc/services/layoutmanager.hxx @@ -292,8 +292,7 @@ namespace framework OUString m_aModuleIdentifier; Timer m_aAsyncLayoutTimer; ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; // container for ALL Listener - ToolbarLayoutManager* m_pToolbarManager; - css::uno::Reference< css::ui::XUIConfigurationListener > m_xToolbarManager; + rtl::Reference< ToolbarLayoutManager > m_xToolbarManager; friend class detail::InfoHelperBuilder; }; diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 711f39b..bf1e8db 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -129,8 +129,6 @@ LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) : , m_xPersistentWindowStateSupplier( ui::theWindowStateConfiguration::get( xContext ) ) , m_pGlobalSettings( nullptr ) , m_aListenerContainer( m_aMutex ) - , m_pToolbarManager( nullptr ) - , m_xToolbarManager( nullptr ) { // Initialize statusbar member m_aStatusBarElement.m_aType = "statusbar"; @@ -138,8 +136,7 @@ LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) : if (!comphelper::LibreOfficeKit::isActive()) { - m_pToolbarManager = new ToolbarLayoutManager( xContext, Reference<XUIElementFactory>(m_xUIElementFactoryManager, UNO_QUERY_THROW), this ); - m_xToolbarManager.set( static_cast< OWeakObject* >( m_pToolbarManager ), uno::UNO_QUERY ); + m_xToolbarManager = new ToolbarLayoutManager( xContext, Reference<XUIElementFactory>(m_xUIElementFactoryManager, UNO_QUERY_THROW), this ); } m_aAsyncLayoutTimer.SetTimeout( 50 ); @@ -251,7 +248,7 @@ void LayoutManager::implts_reset( bool bAttached ) Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState ); Reference< XComponentContext > xContext( m_xContext ); Reference< XNameAccess > xPersistentWindowStateSupplier( m_xPersistentWindowStateSupplier ); - ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); + rtl::Reference<ToolbarLayoutManager> xToolbarManager( m_xToolbarManager ); OUString aModuleIdentifier( m_aModuleIdentifier ); bool bAutomaticToolbars( m_bAutomaticToolbars ); aReadLock.clear(); @@ -396,19 +393,19 @@ void LayoutManager::implts_reset( bool bAttached ) /* SAFE AREA ----------------------------------------------------------------------------------------------- */ // reset/notify toolbar layout manager - if ( pToolbarManager ) + if ( xToolbarManager.is() ) { if ( bAttached ) { - pToolbarManager->attach( xFrame, xModCfgMgr, xDokCfgMgr, xPersistentWindowState ); + xToolbarManager->attach( xFrame, xModCfgMgr, xDokCfgMgr, xPersistentWindowState ); uno::Reference< awt::XWindowPeer > xParent( xContainerWindow, UNO_QUERY ); - pToolbarManager->setParentWindow( xParent ); + xToolbarManager->setParentWindow( xParent ); if ( bAutomaticToolbars ) - pToolbarManager->createStaticToolbars(); + xToolbarManager->createStaticToolbars(); } else { - pToolbarManager->reset(); + xToolbarManager->reset(); implts_destroyElements(); } } @@ -434,7 +431,7 @@ bool LayoutManager::implts_isEmbeddedLayoutManager() const void LayoutManager::implts_destroyElements() { SolarMutexResettableGuard aWriteLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aWriteLock.clear(); if ( pToolbarManager ) @@ -450,7 +447,7 @@ void LayoutManager::implts_destroyElements() void LayoutManager::implts_toggleFloatingUIElementsVisibility( bool bActive ) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -801,7 +798,7 @@ void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible ) bMustDoLayout = !implts_hideStatusBar(); aWriteLock.reset(); - ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); + ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() ); aWriteLock.clear(); if ( pToolbarManager ) @@ -1138,8 +1135,8 @@ void LayoutManager::implts_setOffset( const sal_Int32 nBottomOffset ) setZeroRectangle( aOffsetRect ); aOffsetRect.setHeight( nBottomOffset ); - if ( m_pToolbarManager ) - m_pToolbarManager->setDockingAreaOffsets( aOffsetRect ); + if ( m_xToolbarManager.is() ) + m_xToolbarManager->setDockingAreaOffsets( aOffsetRect ); } void LayoutManager::implts_setInplaceMenuBar( const Reference< XIndexAccess >& xMergedMenuBar ) @@ -1289,7 +1286,7 @@ throw ( RuntimeException, std::exception ) bool bAutomaticToolbars( m_bAutomaticToolbars ); std::vector< Reference< awt::XWindow > > oldDockingAreaWindows; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); if ( !xDockingAreaAcceptor.is() ) m_aAsyncLayoutTimer.Stop(); @@ -1407,7 +1404,7 @@ void LayoutManager::implts_reparentChildWindows() implts_resetMenuBar(); aWriteLock.reset(); - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); if ( pToolbarManager ) pToolbarManager->setParentWindow( uno::Reference< awt::XWindowPeer >( xContainerWindow, uno::UNO_QUERY )); aWriteLock.clear(); @@ -1425,7 +1422,7 @@ IMPL_LINK( LayoutManager, WindowEventListener, VclWindowEvent&, rEvent, void ) if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX ) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); + ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() ); aReadLock.clear(); if ( pToolbarManager ) @@ -1454,10 +1451,10 @@ throw (RuntimeException, std::exception) bool bNotify( false ); bool bPreviewFrame; - if (m_pToolbarManager) + if (m_xToolbarManager.is()) // Assumes that we created the ToolbarLayoutManager with our frame, if // not then we're somewhat fouled up ... - bPreviewFrame = m_pToolbarManager->isPreviewFrame(); + bPreviewFrame = m_xToolbarManager->isPreviewFrame(); else { Reference< XModel > xModel( impl_getModelFromFrame( xFrame ) ); @@ -1471,10 +1468,10 @@ throw (RuntimeException, std::exception) parseResourceURL( aName, aElementType, aElementName ); - if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ) && m_pToolbarManager != nullptr ) + if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ) && m_xToolbarManager.is() ) { - bNotify = m_pToolbarManager->createToolbar( aName ); - bMustBeLayouted = m_pToolbarManager->isLayoutDirty(); + bNotify = m_xToolbarManager->createToolbar( aName ); + bMustBeLayouted = m_xToolbarManager->isLayoutDirty(); } else if ( aElementType.equalsIgnoreAsciiCase("menubar") && aElementName.equalsIgnoreAsciiCase("menubar") ) @@ -1610,11 +1607,11 @@ throw (RuntimeException, std::exception) bMustBeLayouted = true; bNotify = true; } - else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ) && m_pToolbarManager != nullptr ) + else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ) && m_xToolbarManager.is() ) { aWriteLock.clear(); - bNotify = m_pToolbarManager->destroyToolbar( aName ); - bMustBeLayouted = m_pToolbarManager->isLayoutDirty(); + bNotify = m_xToolbarManager->destroyToolbar( aName ); + bMustBeLayouted = m_xToolbarManager->isLayoutDirty(); } else if ( aElementType.equalsIgnoreAsciiCase("dockingwindow")) { @@ -1691,7 +1688,7 @@ throw (uno::RuntimeException, std::exception) else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR ) && m_bVisible ) { bool bComponentAttached( !m_aModuleIdentifier.isEmpty() ); - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aWriteLock.clear(); if ( pToolbarManager && bComponentAttached ) @@ -1720,7 +1717,7 @@ throw (RuntimeException, std::exception) if ( !xUIElement.is() ) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); + ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() ); aReadLock.clear(); if ( pToolbarManager ) @@ -1736,7 +1733,7 @@ throw (uno::RuntimeException, std::exception) SolarMutexClearableGuard aReadLock; uno::Reference< ui::XUIElement > xMenuBar( m_xMenuBar ); uno::Reference< ui::XUIElement > xStatusBar( m_aStatusBarElement.m_xUIElement ); - ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); + ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() ); aReadLock.clear(); Sequence< Reference< ui::XUIElement > > aSeq; @@ -1816,7 +1813,7 @@ throw (RuntimeException, std::exception) else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -1901,7 +1898,7 @@ throw (RuntimeException, std::exception) else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -1939,7 +1936,7 @@ throw (RuntimeException, std::exception) if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -1956,7 +1953,7 @@ sal_Bool SAL_CALL LayoutManager::dockAllWindows( ::sal_Int16 /*nElementType*/ ) { SolarMutexClearableGuard aReadLock; bool bResult( false ); - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -1975,7 +1972,7 @@ throw (RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -1995,7 +1992,7 @@ throw (uno::RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -2015,7 +2012,7 @@ throw (uno::RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -2034,7 +2031,7 @@ throw (RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -2052,7 +2049,7 @@ throw (RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); + ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() ); aReadLock.clear(); if ( pToolbarManager ) @@ -2070,7 +2067,7 @@ throw (RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager( m_pToolbarManager ); + ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() ); aReadLock.clear(); if ( pToolbarManager ) @@ -2139,7 +2136,7 @@ throw (RuntimeException, std::exception) else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -2163,7 +2160,7 @@ throw (RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -2179,7 +2176,7 @@ throw (RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -2195,7 +2192,7 @@ throw (uno::RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -2211,7 +2208,7 @@ throw (RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -2227,7 +2224,7 @@ throw (RuntimeException, std::exception) if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); aReadLock.clear(); if ( pToolbarManager ) @@ -2411,8 +2408,8 @@ bool LayoutManager::implts_doLayout( bool bForceRequestBorderSpace, bool bOuterR // Interim solution to let the layout method within the // toolbar layout manager. implts_setOffset( implts_getStatusBarSize().Height() ); - if ( m_pToolbarManager ) - m_pToolbarManager->setDockingArea( aDockSpace ); + if ( m_xToolbarManager.is() ) + m_xToolbarManager->setDockingArea( aDockSpace ); // Subtract status bar size from our container output size. Docking area windows // don't contain the status bar! @@ -2420,8 +2417,8 @@ bool LayoutManager::implts_doLayout( bool bForceRequestBorderSpace, bool bOuterR aContainerSize = implts_getContainerWindowOutputSize(); aContainerSize.Height() -= aStatusBarSize.Height(); - if ( m_pToolbarManager ) - m_pToolbarManager->doLayout(aContainerSize); + if ( m_xToolbarManager.is() ) + m_xToolbarManager->doLayout(aContainerSize); // Position the status bar if ( aStatusBarSize.Height() > 0 ) @@ -2529,8 +2526,8 @@ awt::Rectangle LayoutManager::implts_calcDockingAreaSizes() aReadLock.clear(); awt::Rectangle aBorderSpace; - if ( m_pToolbarManager && xDockingAreaAcceptor.is() && xContainerWindow.is() ) - aBorderSpace = m_pToolbarManager->getDockingArea(); + if ( m_xToolbarManager.is() && xDockingAreaAcceptor.is() && xContainerWindow.is() ) + aBorderSpace = m_xToolbarManager->getDockingArea(); return aBorderSpace; } @@ -2849,8 +2846,8 @@ throw( RuntimeException, std::exception ) m_xContainerTopWindow.clear(); // forward disposing call to toolbar manager - if ( m_pToolbarManager != nullptr ) - m_pToolbarManager->disposing(rEvent); + if ( m_xToolbarManager.is() ) + m_xToolbarManager->disposing(rEvent); if ( m_xModuleCfgMgr.is() ) { @@ -2889,7 +2886,7 @@ throw( RuntimeException, std::exception ) else if ( rEvent.Source == Reference< XInterface >( m_xContainerWindow, UNO_QUERY )) { // Our container window gets disposed. Remove all user interface elements. - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); if ( pToolbarManager ) { uno::Reference< awt::XWindowPeer > aEmptyWindowPeer; @@ -2934,8 +2931,7 @@ void SAL_CALL LayoutManager::elementInserted( const ui::ConfigurationEvent& Even { SolarMutexClearableGuard aReadLock; Reference< XFrame > xFrame( m_xFrame ); - Reference< ui::XUIConfigurationListener > xUICfgListener( m_xToolbarManager ); - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + rtl::Reference< ToolbarLayoutManager > xToolbarManager( m_xToolbarManager ); aReadLock.clear(); if ( xFrame.is() ) @@ -2947,10 +2943,10 @@ void SAL_CALL LayoutManager::elementInserted( const ui::ConfigurationEvent& Even parseResourceURL( Event.ResourceURL, aElementType, aElementName ); if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR )) { - if ( xUICfgListener.is() ) + if ( xToolbarManager.is() ) { - xUICfgListener->elementInserted( Event ); - bRefreshLayout = pToolbarManager->isLayoutDirty(); + xToolbarManager->elementInserted( Event ); + bRefreshLayout = xToolbarManager->isLayoutDirty(); } } else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_MENUBAR )) @@ -2979,12 +2975,11 @@ void SAL_CALL LayoutManager::elementRemoved( const ui::ConfigurationEvent& Event { SolarMutexClearableGuard aReadLock; Reference< frame::XFrame > xFrame( m_xFrame ); - Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); + rtl::Reference< ToolbarLayoutManager > xToolbarManager( m_xToolbarManager ); Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); Reference< ui::XUIElement > xMenuBar( m_xMenuBar ); Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr ); Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr ); - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; aReadLock.clear(); if ( xFrame.is() ) @@ -2999,7 +2994,7 @@ void SAL_CALL LayoutManager::elementRemoved( const ui::ConfigurationEvent& Event if ( xToolbarManager.is() ) { xToolbarManager->elementRemoved( Event ); - bRefreshLayout = pToolbarManager->isLayoutDirty(); + bRefreshLayout = xToolbarManager->isLayoutDirty(); } } else @@ -3067,8 +3062,7 @@ void SAL_CALL LayoutManager::elementReplaced( const ui::ConfigurationEvent& Even { SolarMutexClearableGuard aReadLock; Reference< XFrame > xFrame( m_xFrame ); - Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager ); - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + rtl::Reference< ToolbarLayoutManager > xToolbarManager( m_xToolbarManager ); aReadLock.clear(); if ( xFrame.is() ) @@ -3083,7 +3077,7 @@ void SAL_CALL LayoutManager::elementReplaced( const ui::ConfigurationEvent& Even if ( xToolbarManager.is() ) { xToolbarManager->elementReplaced( Event ); - bRefreshLayout = pToolbarManager->isLayoutDirty(); + bRefreshLayout = xToolbarManager->isLayoutDirty(); } } else @@ -3131,7 +3125,7 @@ void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 n if (( aValue >>= bValue ) && bValue ) { SolarMutexClearableGuard aReadLock; - ToolbarLayoutManager* pToolbarManager = m_pToolbarManager; + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); bool bAutomaticToolbars( m_bAutomaticToolbars ); aReadLock.clear(); commit 04790b233278f558f5a5be3c811b9ac7a68bc8bf Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 13:07:53 2017 +0200 use rtl::Reference in RequestFilterSelect_Impl instead of raw pointers Change-Id: I86e929d71afc1ce9852d2b01339f7623cc119fcb diff --git a/framework/source/fwe/dispatch/interaction.cxx b/framework/source/fwe/dispatch/interaction.cxx index e0c3b9e..a4a7fc2e 100644 --- a/framework/source/fwe/dispatch/interaction.cxx +++ b/framework/source/fwe/dispatch/interaction.cxx @@ -96,9 +96,8 @@ public: private: css::uno::Any m_aRequest; - css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > m_lContinuations; - comphelper::OInteractionAbort* m_pAbort; - ContinuationFilterSelect* m_pFilter; + rtl::Reference<comphelper::OInteractionAbort> m_xAbort; + rtl::Reference<ContinuationFilterSelect> m_xFilter; }; // initialize instance with all necessary information @@ -113,12 +112,8 @@ RequestFilterSelect_Impl::RequestFilterSelect_Impl( const OUString& sURL ) sURL ); m_aRequest <<= aFilterRequest; - m_pAbort = new comphelper::OInteractionAbort; - m_pFilter = new ContinuationFilterSelect; - - m_lContinuations.realloc( 2 ); - m_lContinuations[0].set( m_pAbort ); - m_lContinuations[1].set( m_pFilter ); + m_xAbort = new comphelper::OInteractionAbort; + m_xFilter = new ContinuationFilterSelect; } // return abort state of interaction @@ -126,7 +121,7 @@ RequestFilterSelect_Impl::RequestFilterSelect_Impl( const OUString& sURL ) bool RequestFilterSelect_Impl::isAbort() const { - return m_pAbort->wasSelected(); + return m_xAbort->wasSelected(); } // return user selected filter @@ -134,7 +129,7 @@ bool RequestFilterSelect_Impl::isAbort() const OUString RequestFilterSelect_Impl::getFilter() const { - return m_pFilter->getFilter(); + return m_xFilter->getFilter(); } // handler call it to get type of request @@ -152,7 +147,7 @@ css::uno::Any SAL_CALL RequestFilterSelect_Impl::getRequest() throw( css::uno::R css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL RequestFilterSelect_Impl::getContinuations() throw( css::uno::RuntimeException, std::exception ) { - return m_lContinuations; + return { m_xAbort.get(), m_xFilter.get() }; } RequestFilterSelect::RequestFilterSelect( const OUString& sURL ) commit 4d3ad2640332d811d50055df81243fdd813edfc8 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 13:00:17 2017 +0200 manage SvRefBase subclass with tools::SvRef Change-Id: Ieb164a8113c7033e72feece8421dd4ef68961f7a diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index 11179f3..162b57c 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -2449,7 +2449,7 @@ bool UCBStorage::CopyStorageElement_Impl( UCBStorageElement_Impl& rElement, Base { // copy the streams data // the destination stream must not be open - std::unique_ptr<BaseStorageStream> pOtherStream(pDest->OpenStream( rNew, StreamMode::WRITE | StreamMode::SHARE_DENYALL, pImp->m_bDirect )); + tools::SvRef<BaseStorageStream> pOtherStream(pDest->OpenStream( rNew, StreamMode::WRITE | StreamMode::SHARE_DENYALL, pImp->m_bDirect )); BaseStorageStream* pStream = nullptr; bool bDeleteStream = false; @@ -2484,7 +2484,7 @@ bool UCBStorage::CopyStorageElement_Impl( UCBStorageElement_Impl& rElement, Base pStorage = rElement.m_xStorage->m_pAntiImpl; if ( !pStorage ) { - pStorage = ( const_cast < UCBStorage* > (this) )->OpenStorage( rElement.m_aName, pImp->m_nMode, pImp->m_bDirect ); + pStorage = const_cast<UCBStorage*>(this)->OpenStorage( rElement.m_aName, pImp->m_nMode, pImp->m_bDirect ); bDeleteStorage = true; } @@ -2492,7 +2492,7 @@ bool UCBStorage::CopyStorageElement_Impl( UCBStorageElement_Impl& rElement, Base UCBStorage* pUCBCopy = dynamic_cast<UCBStorage*>( pStorage ); bool bOpenUCBStorage = pUCBDest && pUCBCopy; - std::unique_ptr<BaseStorage> pOtherStorage(bOpenUCBStorage ? + tools::SvRef<BaseStorage> pOtherStorage(bOpenUCBStorage ? pDest->OpenUCBStorage( rNew, StreamMode::WRITE | StreamMode::SHARE_DENYALL, pImp->m_bDirect ) : pDest->OpenOLEStorage( rNew, StreamMode::WRITE | StreamMode::SHARE_DENYALL, pImp->m_bDirect )); commit 5830ef9a65d268ca7939d5489a75e3873bdc5d96 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 11:47:52 2017 +0200 use rtl::Reference in DocPasswordRequest and SimplePasswordRequest Change-Id: If1bad2bc852712b8315e44480ee81f797736bb95 diff --git a/comphelper/source/misc/docpasswordrequest.cxx b/comphelper/source/misc/docpasswordrequest.cxx index 29cf4a9..3ebcde4 100644 --- a/comphelper/source/misc/docpasswordrequest.cxx +++ b/comphelper/source/misc/docpasswordrequest.cxx @@ -82,10 +82,8 @@ SimplePasswordRequest::SimplePasswordRequest( PasswordRequestMode eMode ) InteractionClassification_QUERY, eMode ); maRequest <<= aRequest; - maContinuations.realloc( 2 ); - maContinuations[ 0 ].set( new AbortContinuation ); - mpPassword = new PasswordContinuation; - maContinuations[ 1 ].set( mpPassword ); + mxAbort = new AbortContinuation; + mxPassword = new PasswordContinuation; } SimplePasswordRequest::~SimplePasswordRequest() @@ -94,12 +92,12 @@ SimplePasswordRequest::~SimplePasswordRequest() bool SimplePasswordRequest::isPassword() const { - return mpPassword->isSelected(); + return mxPassword->isSelected(); } OUString SimplePasswordRequest::getPassword() const { - return mpPassword->getPassword(); + return mxPassword->getPassword(); } Any SAL_CALL SimplePasswordRequest::getRequest() throw( RuntimeException, std::exception ) @@ -109,7 +107,7 @@ Any SAL_CALL SimplePasswordRequest::getRequest() throw( RuntimeException, std::e Sequence< Reference< XInteractionContinuation > > SAL_CALL SimplePasswordRequest::getContinuations() throw( RuntimeException, std::exception ) { - return maContinuations; + return { mxAbort.get(), mxPassword.get() }; } @@ -136,10 +134,8 @@ DocPasswordRequest::DocPasswordRequest( DocPasswordRequestType eType, implementation of a new enum value. */ } - maContinuations.realloc( 2 ); - maContinuations[ 0 ].set( new AbortContinuation ); - mpPassword = new PasswordContinuation; - maContinuations[ 1 ].set( mpPassword ); + mxAbort = new AbortContinuation; + mxPassword = new PasswordContinuation; } DocPasswordRequest::~DocPasswordRequest() @@ -148,22 +144,22 @@ DocPasswordRequest::~DocPasswordRequest() bool DocPasswordRequest::isPassword() const { - return mpPassword->isSelected(); + return mxPassword->isSelected(); } OUString DocPasswordRequest::getPassword() const { - return mpPassword->getPassword(); + return mxPassword->getPassword(); } OUString DocPasswordRequest::getPasswordToModify() const { - return mpPassword->getPasswordToModify(); + return mxPassword->getPasswordToModify(); } bool DocPasswordRequest::getRecommendReadOnly() const { - return mpPassword->getRecommendReadOnly(); + return mxPassword->getRecommendReadOnly(); } Any SAL_CALL DocPasswordRequest::getRequest() throw( RuntimeException, std::exception ) @@ -173,7 +169,7 @@ Any SAL_CALL DocPasswordRequest::getRequest() throw( RuntimeException, std::exce Sequence< Reference< XInteractionContinuation > > SAL_CALL DocPasswordRequest::getContinuations() throw( RuntimeException, std::exception ) { - return maContinuations; + return { mxAbort.get(), mxPassword.get() }; } diff --git a/include/comphelper/docpasswordrequest.hxx b/include/comphelper/docpasswordrequest.hxx index f8b19b1..f5657a4 100644 --- a/include/comphelper/docpasswordrequest.hxx +++ b/include/comphelper/docpasswordrequest.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/task/PasswordRequestMode.hpp> #include <com/sun/star/task/XInteractionRequest.hpp> #include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> namespace comphelper { @@ -56,9 +57,9 @@ private: virtual css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL getContinuations() throw( css::uno::RuntimeException, std::exception ) override; private: - css::uno::Any maRequest; - css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > maContinuations; - PasswordContinuation * mpPassword; + css::uno::Any maRequest; + rtl::Reference<AbortContinuation> mxAbort; + rtl::Reference<PasswordContinuation> mxPassword; }; @@ -89,9 +90,9 @@ private: virtual css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL getContinuations() throw( css::uno::RuntimeException, std::exception ) override; private: - css::uno::Any maRequest; - css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > maContinuations; - PasswordContinuation * mpPassword; + css::uno::Any maRequest; + rtl::Reference<AbortContinuation> mxAbort; + rtl::Reference<PasswordContinuation> mxPassword; }; commit 574335a1ad68bdde15a67607f2460ef3828f6c3c Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 11:34:55 2017 +0200 use SolarMutexGuard instead of manual acquire/release Change-Id: Ieb0a2c269b46004a80f77c51ce947b0daf015644 diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index de70f27..8636db6 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -233,7 +233,7 @@ SwTransferable::SwTransferable( SwWrtShell& rSh ) SwTransferable::~SwTransferable() { - Application::GetSolarMutex().acquire(); + SolarMutexGuard aSolarGuard; // the DDELink still needs the WrtShell! if( m_xDdeLink.Is() ) @@ -275,8 +275,6 @@ SwTransferable::~SwTransferable() delete m_pBookmark; m_eBufferType = TransferBufferType::NONE; - - Application::GetSolarMutex().release(); } static SwDoc * lcl_GetDoc(SwDocFac & rDocFac) commit dd8f5e22356349345c35932fcc6b75dee503f834 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 11:28:27 2017 +0200 use rtl::Reference in ScDPDimensions/ScDPHierarchies/ScDPLevels instead of manual acquire/release Change-Id: Id0dfa1c42e12a680ed6a6144b73d03c8f45e9f3d diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx index 26e949a..6a35476 100644 --- a/sc/inc/dptabsrc.hxx +++ b/sc/inc/dptabsrc.hxx @@ -261,7 +261,7 @@ class ScDPDimensions : public cppu::WeakImplHelper< private: ScDPSource* pSource; long nDimCount; - ScDPDimension** ppDims; + rtl::Reference<ScDPDimension>* ppDims; public: ScDPDimensions( ScDPSource* pSrc ); @@ -415,7 +415,7 @@ private: // date columns have 3 hierarchies (flat/quarter/week), other columns only one // #i52547# don't offer the incomplete date hierarchy implementation static const long nHierCount = 1; - ScDPHierarchy** ppHiers; + rtl::Reference<ScDPHierarchy>* ppHiers; public: ScDPHierarchies( ScDPSource* pSrc, long nD ); @@ -492,7 +492,7 @@ private: long nDim; long nHier; long nLevCount; - ScDPLevel** ppLevs; + rtl::Reference<ScDPLevel>* ppLevs; public: ScDPLevels( ScDPSource* pSrc, long nD, long nH ); diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index f741943..d7825f0 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -1212,9 +1212,6 @@ ScDPDimensions::~ScDPDimensions() if (ppDims) { - for (long i=0; i<nDimCount; i++) - if ( ppDims[i] ) - ppDims[i]->release(); // ref-counted delete[] ppDims; } } @@ -1227,15 +1224,12 @@ void ScDPDimensions::CountChanged() { long i; long nCopy = std::min( nNewCount, nDimCount ); - ScDPDimension** ppNew = new ScDPDimension*[nNewCount]; + rtl::Reference<ScDPDimension>* ppNew = new rtl::Reference<ScDPDimension>[nNewCount]; for (i=0; i<nCopy; i++) // copy existing dims ppNew[i] = ppDims[i]; for (i=nCopy; i<nNewCount; i++) // clear additional pointers ppNew[i] = nullptr; - for (i=nCopy; i<nDimCount; i++) // delete old dims if count is decreased - if ( ppDims[i] ) - ppDims[i]->release(); // ref-counted delete[] ppDims; ppDims = ppNew; @@ -1307,17 +1301,16 @@ ScDPDimension* ScDPDimensions::getByIndex(long nIndex) const { if ( !ppDims ) { - const_cast<ScDPDimensions*>(this)->ppDims = new ScDPDimension*[nDimCount]; + const_cast<ScDPDimensions*>(this)->ppDims = new rtl::Reference<ScDPDimension>[nDimCount]; for (long i=0; i<nDimCount; i++) ppDims[i] = nullptr; } - if ( !ppDims[nIndex] ) + if ( !ppDims[nIndex].is() ) { ppDims[nIndex] = new ScDPDimension( pSource, nIndex ); - ppDims[nIndex]->acquire(); // ref-counted } - return ppDims[nIndex]; + return ppDims[nIndex].get(); } return nullptr; //TODO: exception? @@ -1690,9 +1683,6 @@ ScDPHierarchies::~ScDPHierarchies() if (ppHiers) { - for (long i=0; i<nHierCount; i++) - if ( ppHiers[i] ) - ppHiers[i]->release(); // ref-counted delete[] ppHiers; } } @@ -1761,17 +1751,16 @@ ScDPHierarchy* ScDPHierarchies::getByIndex(long nIndex) const { if ( !ppHiers ) { - const_cast<ScDPHierarchies*>(this)->ppHiers = new ScDPHierarchy*[nHierCount]; + const_cast<ScDPHierarchies*>(this)->ppHiers = new rtl::Reference<ScDPHierarchy>[nHierCount]; for (long i=0; i<nHierCount; i++) ppHiers[i] = nullptr; } - if ( !ppHiers[nIndex] ) + if ( !ppHiers[nIndex].is() ) { ppHiers[nIndex] = new ScDPHierarchy( pSource, nDim, nIndex ); - ppHiers[nIndex]->acquire(); // ref-counted } - return ppHiers[nIndex]; + return ppHiers[nIndex].get(); } return nullptr; //TODO: exception? @@ -1864,9 +1853,6 @@ ScDPLevels::~ScDPLevels() if (ppLevs) { - for (long i=0; i<nLevCount; i++) - if ( ppLevs[i] ) - ppLevs[i]->release(); // ref-counted delete[] ppLevs; } } @@ -1932,17 +1918,16 @@ ScDPLevel* ScDPLevels::getByIndex(long nIndex) const { if ( !ppLevs ) { - const_cast<ScDPLevels*>(this)->ppLevs = new ScDPLevel*[nLevCount]; + const_cast<ScDPLevels*>(this)->ppLevs = new rtl::Reference<ScDPLevel>[nLevCount]; for (long i=0; i<nLevCount; i++) ppLevs[i] = nullptr; } - if ( !ppLevs[nIndex] ) + if ( !ppLevs[nIndex].is() ) { ppLevs[nIndex] = new ScDPLevel( pSource, nDim, nHier, nIndex ); - ppLevs[nIndex]->acquire(); // ref-counted } - return ppLevs[nIndex]; + return ppLevs[nIndex].get(); } return nullptr; //TODO: exception? commit 492ccb76d75cbce976f5a4886cbe5eec3d132898 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 11:21:22 2017 +0200 use rtl::Reference to manage ScAccessiblePageHeaderArea's instead of manual acquire/release Change-Id: I368530f30388cd4bba6dbc1fe6d6a5dd1e25f298 diff --git a/sc/source/ui/Accessibility/AccessiblePageHeader.cxx b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx index 134fdf1..1d59766 100644 --- a/sc/source/ui/Accessibility/AccessiblePageHeader.cxx +++ b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx @@ -50,45 +50,13 @@ using namespace ::com::sun::star::accessibility; const sal_uInt8 MAX_AREAS = 3; -//===== internal ============================================================ -struct Acquire -{ - void operator() (ScAccessiblePageHeaderArea* pArea) - { - if (pArea) - pArea->acquire(); - } -}; - -struct Release -{ - void operator() (ScAccessiblePageHeaderArea*& pArea) - { - if (pArea) - pArea->release(); - } -}; - -struct Dispose -{ - void operator() (ScAccessiblePageHeaderArea*& pArea) - { - if (pArea) - { - pArea->dispose(); - pArea->release(); - } - pArea = nullptr; - } -}; - ScAccessiblePageHeader::ScAccessiblePageHeader( const css::uno::Reference<css::accessibility::XAccessible>& rxParent, ScPreviewShell* pViewShell, bool bHeader, sal_Int32 nIndex ) : ScAccessibleContextBase( rxParent, bHeader ? AccessibleRole::HEADER : AccessibleRole::FOOTER ), mpViewShell( pViewShell ), mnIndex( nIndex ), mbHeader( bHeader ), - maAreas(MAX_AREAS, nullptr), + maAreas(MAX_AREAS, rtl::Reference<ScAccessiblePageHeaderArea>()), mnChildCount(-1) { if (mpViewShell) @@ -113,7 +81,14 @@ void SAL_CALL ScAccessiblePageHeader::disposing() mpViewShell->RemoveAccessibilityObject(*this); mpViewShell = nullptr; } - std::for_each(maAreas.begin(), maAreas.end(), Dispose()); + for (auto & i : maAreas) + { + if (i.is()) + { + i->dispose(); + i.clear(); + } + } ScAccessibleContextBase::disposing(); } @@ -125,37 +100,35 @@ void ScAccessiblePageHeader::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) // only notify if child exist, otherwise it is not necessary if (rHint.GetId() == SfxHintId::ScDataChanged) { - ScHFAreas aOldAreas(maAreas); - std::for_each(aOldAreas.begin(), aOldAreas.end(), Acquire()); + std::vector<rtl::Reference<ScAccessiblePageHeaderArea>> aOldAreas(maAreas); mnChildCount = -1; getAccessibleChildCount(); for (sal_uInt8 i = 0; i < MAX_AREAS; ++i) { - if ((aOldAreas[i] && maAreas[i] && !ScGlobal::EETextObjEqual(aOldAreas[i]->GetEditTextObject(), maAreas[i]->GetEditTextObject())) || - (aOldAreas[i] && !maAreas[i]) || (!aOldAreas[i] && maAreas[i])) + if ((aOldAreas[i].is() && maAreas[i].is() && !ScGlobal::EETextObjEqual(aOldAreas[i]->GetEditTextObject(), maAreas[i]->GetEditTextObject())) || + (aOldAreas[i].is() && !maAreas[i].is()) || (!aOldAreas[i].is() && maAreas[i].is())) { - if (aOldAreas[i] && aOldAreas[i]->GetEditTextObject()) + if (aOldAreas[i].is() && aOldAreas[i]->GetEditTextObject()) { AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::CHILD; aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.OldValue = uno::makeAny(uno::Reference<XAccessible>(aOldAreas[i])); + aEvent.OldValue = uno::makeAny(uno::Reference<XAccessible>(aOldAreas[i].get())); CommitChange(aEvent); // child gone - event aOldAreas[i]->dispose(); } - if (maAreas[i] && maAreas[i]->GetEditTextObject()) + if (maAreas[i].is() && maAreas[i]->GetEditTextObject()) { AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::CHILD; aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.NewValue = uno::makeAny(uno::Reference<XAccessible>(maAreas[i])); + aEvent.NewValue = uno::makeAny(uno::Reference<XAccessible>(maAreas[i].get())); CommitChange(aEvent); // new child - event } } } - std::for_each(aOldAreas.begin(), aOldAreas.end(), Release()); } else if (rHint.GetId() == SfxHintId::ScAccVisAreaChanged) { @@ -188,8 +161,8 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeader::getAccessibleAtPo sal_uInt8 i(0); while(!xRet.is() && i < MAX_AREAS) { - if (maAreas[i]) - xRet = maAreas[i]; + if (maAreas[i].is()) + xRet = maAreas[i].get(); else ++i; } @@ -254,14 +227,14 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeader::getAccessibleChil if(mnChildCount < 0) getAccessibleChildCount(); - ScHFAreas::iterator aItr = maAreas.begin(); - ScHFAreas::iterator aEndItr = maAreas.end(); + auto aItr = maAreas.begin(); + auto aEndItr = maAreas.end(); while (!xRet.is() && (nIndex >= 0) && (aItr != aEndItr)) { - if (*aItr) + if (aItr->is()) { if (nIndex == 0) - xRet = *aItr; + xRet = aItr->get(); else --nIndex; } @@ -390,29 +363,22 @@ void ScAccessiblePageHeader::AddChild(const EditTextObject* pArea, sal_uInt32 nI { if (pArea && (!pArea->GetText(0).isEmpty() || (pArea->GetParagraphCount() > 1))) { - if (maAreas[nIndex]) + if (maAreas[nIndex].is()) { if (!ScGlobal::EETextObjEqual(maAreas[nIndex]->GetEditTextObject(), pArea)) { - maAreas[nIndex]->release(); maAreas[nIndex] = new ScAccessiblePageHeaderArea(this, mpViewShell, pArea, mbHeader, eAdjust); - maAreas[nIndex]->acquire(); } } else { maAreas[nIndex] = new ScAccessiblePageHeaderArea(this, mpViewShell, pArea, mbHeader, eAdjust); - maAreas[nIndex]->acquire(); } ++mnChildCount; } else { - if (maAreas[nIndex]) - { - maAreas[nIndex]->release(); - maAreas[nIndex] = nullptr; - } + maAreas[nIndex].clear(); } } diff --git a/sc/source/ui/inc/AccessiblePageHeader.hxx b/sc/source/ui/inc/AccessiblePageHeader.hxx index 395f80b..6a8645f 100644 --- a/sc/source/ui/inc/AccessiblePageHeader.hxx +++ b/sc/source/ui/inc/AccessiblePageHeader.hxx @@ -22,6 +22,7 @@ #include "AccessibleContextBase.hxx" #include <editeng/svxenum.hxx> +#include <rtl/ref.hxx> class ScPreviewShell; class EditTextObject; @@ -83,8 +84,8 @@ private: ScPreviewShell* mpViewShell; sal_Int32 mnIndex; bool mbHeader; - typedef std::vector< ScAccessiblePageHeaderArea* > ScHFAreas; - ScHFAreas maAreas; + std::vector< rtl::Reference<ScAccessiblePageHeaderArea> > + maAreas; sal_Int32 mnChildCount; bool IsDefunc( commit 3b395bc73fb8709c738adebd94de8319e27ba878 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 17 11:11:05 2017 +0200 manage SvxPropertySetInfoPool.mpInfos with rtl::Reference instead of with manual acquire() Change-Id: I9fac619730df6a070c5f0d887ecf9249bd7d65a6 diff --git a/include/svx/unoprov.hxx b/include/svx/unoprov.hxx index f8795e6..9ac270c 100644 --- a/include/svx/unoprov.hxx +++ b/include/svx/unoprov.hxx @@ -25,6 +25,7 @@ #include <svl/itemprop.hxx> #include <svx/svxdllapi.h> #include <editeng/unoipset.hxx> +#include <rtl/ref.hxx> class SvxItemPropertySet; @@ -116,7 +117,7 @@ public: SVX_DLLPUBLIC static comphelper::PropertySetInfo* getOrCreate( sal_Int32 nServiceId ) throw(); private: - static comphelper::PropertySetInfo* mpInfos[SVXUNO_SERVICEID_LASTID+1]; + static rtl::Reference<comphelper::PropertySetInfo> mxInfos[SVXUNO_SERVICEID_LASTID+1]; }; #endif diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx index 2d9f97c..32beef8 100644 --- a/svx/source/unodraw/unoprov.cxx +++ b/svx/source/unodraw/unoprov.cxx @@ -1375,21 +1375,20 @@ comphelper::PropertySetInfo* SvxPropertySetInfoPool::getOrCreate( sal_Int32 nSer return nullptr; } - if( mpInfos[ nServiceId ] == nullptr ) + if( !mxInfos[ nServiceId ].is() ) { - mpInfos[nServiceId] = new comphelper::PropertySetInfo(); - mpInfos[nServiceId]->acquire(); + mxInfos[nServiceId] = new comphelper::PropertySetInfo(); switch( nServiceId ) { case SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS: - mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS]->add( ImplGetSvxDrawingDefaultsPropertyMap() ); + mxInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS]->add( ImplGetSvxDrawingDefaultsPropertyMap() ); break; case SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER: - mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->add( ImplGetSvxDrawingDefaultsPropertyMap() ); - mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->remove( UNO_NAME_EDIT_PARA_IS_HANGING_PUNCTUATION ); + mxInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->add( ImplGetSvxDrawingDefaultsPropertyMap() ); + mxInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->remove( UNO_NAME_EDIT_PARA_IS_HANGING_PUNCTUATION ); // OD 13.10.2003 #i18732# - add property map for writer item 'IsFollowingTextFlow' - mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->add( ImplGetAdditionalWriterDrawingDefaultsPropertyMap() ); + mxInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->add( ImplGetAdditionalWriterDrawingDefaultsPropertyMap() ); break; default: @@ -1397,9 +1396,9 @@ comphelper::PropertySetInfo* SvxPropertySetInfoPool::getOrCreate( sal_Int32 nSer } } - return mpInfos[ nServiceId ]; + return mxInfos[ nServiceId ].get(); } -comphelper::PropertySetInfo* SvxPropertySetInfoPool::mpInfos[SVXUNO_SERVICEID_LASTID+1] = { nullptr }; +rtl::Reference<comphelper::PropertySetInfo> SvxPropertySetInfoPool::mxInfos[SVXUNO_SERVICEID_LASTID+1] = { nullptr }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits