[Libreoffice-commits] core.git: framework/source
Chris Sherlock
chris.sherlock79 at gmail.com
Sat May 10 22:54:36 PDT 2014
framework/source/layoutmanager/toolbarlayoutmanager.cxx | 184 +++++++---------
framework/source/layoutmanager/toolbarlayoutmanager.hxx | 1
2 files changed, 89 insertions(+), 96 deletions(-)
New commits:
commit 75071783b7ef256e3cfdc08711fc3f69504d4723
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Fri May 9 15:06:49 2014 +1000
Remove unnecessary function ToolbarLayoutManger::implts_createToolBar()
This function is not necessary. I have merged it into createToolbar().
There are just too many function calls when I try to get a backtrace.
Change-Id: I3b1c08b97e24ba18a268f105b00670ed2799f60a
Reviewed-on: https://gerrit.libreoffice.org/9308
Tested-by: LibreOffice gerrit bot <gerrit at libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index a9ce19e..68e64b8 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -448,9 +448,92 @@ bool ToolbarLayoutManager::requestToolbar( const OUString& rResourceURL )
bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL )
{
bool bNotify( false );
- uno::Reference< ui::XUIElement > xUITempElement;
- implts_createToolBar( rResourceURL, bNotify, xUITempElement );
+ SolarMutexClearableGuard aReadLock;
+ uno::Reference< frame::XFrame > xFrame( m_xFrame );
+ uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
+ aReadLock.clear();
+
+ bNotify = false;
+
+ if ( !xFrame.is() || !xContainerWindow.is() )
+ return false;
+
+ UIElement aToolbarElement = implts_findToolbar( rResourceURL );
+ if ( !aToolbarElement.m_xUIElement.is() )
+ {
+ uno::Reference< ui::XUIElement > xUIElement = implts_createElement( rResourceURL );
+
+ bool bVisible( false );
+ bool bFloating( false );
+ if ( xUIElement.is() )
+ {
+ uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
+ uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
+ if ( xDockWindow.is() && xWindow.is() )
+ {
+ try
+ {
+ xDockWindow->addDockableWindowListener( uno::Reference< awt::XDockableWindowListener >(
+ static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
+ xWindow->addWindowListener( uno::Reference< awt::XWindowListener >(
+ static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
+ xDockWindow->enableDocking( sal_True );
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+
+ /* SAFE AREA ----------------------------------------------------------------------------------------------- */
+ SolarMutexClearableGuard aWriteLock;
+
+ UIElement& rElement = impl_findToolbar( rResourceURL );
+ if ( !rElement.m_aName.isEmpty() )
+ {
+ // Reuse a local entry so we are able to use the latest
+ // UI changes for this document.
+ implts_setElementData( rElement, xDockWindow );
+ rElement.m_xUIElement = xUIElement;
+ bVisible = rElement.m_bVisible;
+ bFloating = rElement.m_bFloating;
+ }
+ else
+ {
+ // Create new UI element and try to read its state data
+ UIElement aNewToolbar( rResourceURL, UIRESOURCETYPE_TOOLBAR, xUIElement );
+ implts_readWindowStateData( rResourceURL, aNewToolbar );
+ implts_setElementData( aNewToolbar, xDockWindow );
+ implts_insertToolbar( aNewToolbar );
+ bVisible = aNewToolbar.m_bVisible;
+ bFloating = rElement.m_bFloating;
+ }
+ aWriteLock.clear();
+ /* SAFE AREA ----------------------------------------------------------------------------------------------- */
+
+ // set toolbar menu style according to customize command state
+ SvtCommandOptions aCmdOptions;
+
+ SolarMutexGuard aGuard;
+ Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+ if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
+ {
+ ToolBox* pToolbar = (ToolBox *)pWindow;
+ sal_uInt16 nMenuType = pToolbar->GetMenuType();
+ if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, "ConfigureDialog" ))
+ pToolbar->SetMenuType( nMenuType & ~TOOLBOX_MENUTYPE_CUSTOMIZE );
+ else
+ pToolbar->SetMenuType( nMenuType | TOOLBOX_MENUTYPE_CUSTOMIZE );
+ }
+ bNotify = true;
+
+ implts_sortUIElements();
+
+ if ( bVisible && !bFloating )
+ implts_setLayoutDirty();
+ }
+ }
+
return bNotify;
}
@@ -1205,9 +1288,10 @@ void ToolbarLayoutManager::implts_createCustomToolBar( const OUString& aTbxResNa
{
if ( !aTbxResName.isEmpty() )
{
- bool bNotify( false );
- uno::Reference< ui::XUIElement > xUIElement;
- implts_createToolBar( aTbxResName, bNotify, xUIElement );
+ if ( !createToolbar( aTbxResName ) )
+ SAL_WARN("fwk.uielement", "ToolbarLayoutManager cannot create custom toolbar");
+
+ uno::Reference< ui::XUIElement > xUIElement = getToolbar( aTbxResName );
if ( !aTitle.isEmpty() && xUIElement.is() )
{
@@ -1290,96 +1374,6 @@ bool ToolbarLayoutManager::implts_isToolbarCreationActive()
return m_bToolbarCreation;
}
-void ToolbarLayoutManager::implts_createToolBar( const OUString& aName, bool& bNotify, uno::Reference< ui::XUIElement >& rUIElement )
-{
- SolarMutexClearableGuard aReadLock;
- uno::Reference< frame::XFrame > xFrame( m_xFrame );
- uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
- aReadLock.clear();
-
- bNotify = false;
-
- if ( !xFrame.is() || !xContainerWindow.is() )
- return;
-
- UIElement aToolbarElement = implts_findToolbar( aName );
- if ( !aToolbarElement.m_xUIElement.is() )
- {
- uno::Reference< ui::XUIElement > xUIElement = implts_createElement( aName );
-
- bool bVisible( false );
- bool bFloating( false );
- if ( xUIElement.is() )
- {
- rUIElement = xUIElement;
-
- uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
- uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
- if ( xDockWindow.is() && xWindow.is() )
- {
- try
- {
- xDockWindow->addDockableWindowListener( uno::Reference< awt::XDockableWindowListener >(
- static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
- xWindow->addWindowListener( uno::Reference< awt::XWindowListener >(
- static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
- xDockWindow->enableDocking( sal_True );
- }
- catch (const uno::Exception&)
- {
- }
- }
-
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
- SolarMutexClearableGuard aWriteLock;
-
- UIElement& rElement = impl_findToolbar( aName );
- if ( !rElement.m_aName.isEmpty() )
- {
- // Reuse a local entry so we are able to use the latest
- // UI changes for this document.
- implts_setElementData( rElement, xDockWindow );
- rElement.m_xUIElement = xUIElement;
- bVisible = rElement.m_bVisible;
- bFloating = rElement.m_bFloating;
- }
- else
- {
- // Create new UI element and try to read its state data
- UIElement aNewToolbar( aName, UIRESOURCETYPE_TOOLBAR, xUIElement );
- implts_readWindowStateData( aName, aNewToolbar );
- implts_setElementData( aNewToolbar, xDockWindow );
- implts_insertToolbar( aNewToolbar );
- bVisible = aNewToolbar.m_bVisible;
- bFloating = rElement.m_bFloating;
- }
- aWriteLock.clear();
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
-
- // set toolbar menu style according to customize command state
- SvtCommandOptions aCmdOptions;
-
- SolarMutexGuard aGuard;
- Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
- if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
- {
- ToolBox* pToolbar = (ToolBox *)pWindow;
- sal_uInt16 nMenuType = pToolbar->GetMenuType();
- if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, "ConfigureDialog" ))
- pToolbar->SetMenuType( nMenuType & ~TOOLBOX_MENUTYPE_CUSTOMIZE );
- else
- pToolbar->SetMenuType( nMenuType | TOOLBOX_MENUTYPE_CUSTOMIZE );
- }
- bNotify = true;
-
- implts_sortUIElements();
-
- if ( bVisible && !bFloating )
- implts_setLayoutDirty();
- }
- }
-}
-
uno::Reference< ui::XUIElement > ToolbarLayoutManager::implts_createElement( const OUString& aName )
{
uno::Reference< ui::XUIElement > xUIElement;
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.hxx b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
index d6f6986..52d9139 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.hxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
@@ -258,7 +258,6 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a
void implts_createNonContextSensitiveToolBars();
void implts_createCustomToolBars( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aCustomTbxSeq );
void implts_createCustomToolBar( const OUString& aTbxResName, const OUString& aTitle );
- void implts_createToolBar( const OUString& aName, bool& bNotify, ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement >& rUIElement );
css::uno::Reference< css::ui::XUIElement > implts_createElement( const OUString& aName );
void implts_setToolbarCreation( bool bStart = true );
bool implts_isToolbarCreationActive();
More information about the Libreoffice-commits
mailing list