summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2012-05-04 23:14:51 +0200
committerCaolán McNamara <caolanm@redhat.com>2012-05-08 10:24:48 +0100
commit52fc5dc51fc3f5f8cf212898e45fc90066fa7f8d (patch)
treea24c42fdfd6ce66668871cbc295df29c3d564e8f
parent9b03e5c64482a4725459daa5ccc16fa686a3bffb (diff)
resolved fdo#46160 query model only once whether it is a preview
Query a frame's model only once whether it is a preview model, instead of doing it for each toolbar and menubar and statusbar and progressbar. Each call via SfxBaseModel::getArgs() results in SfxObjectShell::GetVisArea() that at least in Calc determines how far visible attributes extend, with several toolbars requested on each cell edit. getArgs() calls GetVisArea() still too many times when loading a document even if the caller doesn't evaluate the WinExtent property, this is an opportunity for further optimization. (cherry picked from commit 7c5064d3bd57a0d5e57e188274d74d61a3ac9922) Signed-off-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--framework/source/layoutmanager/layoutmanager.cxx15
-rw-r--r--framework/source/layoutmanager/toolbarlayoutmanager.cxx41
-rw-r--r--framework/source/layoutmanager/toolbarlayoutmanager.hxx10
3 files changed, 47 insertions, 19 deletions
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index 0db2c84994b0..1de8b7a266a2 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -1474,15 +1474,24 @@ throw (RuntimeException)
if ( !xFrame.is() )
return;
- Reference< XModel > xModel( impl_getModelFromFrame( xFrame ) );
-
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
WriteGuard aWriteLock( m_aLock );
bool bMustBeLayouted( false );
bool bNotify( false );
- if ( m_xContainerWindow.is() && !implts_isPreviewModel( xModel ) ) // no UI elements on preview frames
+ bool bPreviewFrame;
+ if (m_pToolbarManager)
+ // Assumes that we created the ToolbarLayoutManager with our frame, if
+ // not then we're somewhat fouled up ...
+ bPreviewFrame = m_pToolbarManager->isPreviewFrame();
+ else
+ {
+ Reference< XModel > xModel( impl_getModelFromFrame( xFrame ) );
+ bPreviewFrame = implts_isPreviewModel( xModel );
+ }
+
+ if ( m_xContainerWindow.is() && !bPreviewFrame ) // no UI elements on preview frames
{
::rtl::OUString aElementType;
::rtl::OUString aElementName;
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index d14803e898a0..e27ebc3b77ea 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -66,6 +66,7 @@ ToolbarLayoutManager::ToolbarLayoutManager(
m_xUIElementFactoryManager( xUIElementFactory ),
m_pParentLayouter( pParentLayouter ),
m_eDockOperation( DOCKOP_ON_COLROW ),
+ m_ePreviewDetection( PREVIEWFRAME_UNKNOWN ),
m_bComponentAttached( false ),
m_bMustLayout( false ),
m_bLayoutDirty( false ),
@@ -374,6 +375,7 @@ void ToolbarLayoutManager::reset()
uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr );
m_xModuleCfgMgr.clear();
m_xDocCfgMgr.clear();
+ m_ePreviewDetection = PREVIEWFRAME_UNKNOWN;
m_bComponentAttached = false;
aWriteLock.unlock();
@@ -399,6 +401,21 @@ void ToolbarLayoutManager::attach(
m_bComponentAttached = true;
}
+bool ToolbarLayoutManager::isPreviewFrame()
+{
+ ReadGuard aReadLock( m_aLock );
+ if (m_ePreviewDetection == PREVIEWFRAME_UNKNOWN)
+ {
+ uno::Reference< frame::XFrame > xFrame( m_xFrame );
+
+ uno::Reference< frame::XModel > xModel( impl_getModelFromFrame( xFrame ));
+
+ WriteGuard aWriteLock( m_aLock );
+ m_ePreviewDetection = (implts_isPreviewModel( xModel ) ? PREVIEWFRAME_YES : PREVIEWFRAME_NO);
+ }
+ return m_ePreviewDetection == PREVIEWFRAME_YES;
+}
+
void ToolbarLayoutManager::createStaticToolbars()
{
resetDockingArea();
@@ -410,18 +427,13 @@ void ToolbarLayoutManager::createStaticToolbars()
bool ToolbarLayoutManager::requestToolbar( const ::rtl::OUString& rResourceURL )
{
+ if (isPreviewFrame())
+ return false; // no toolbars for preview frame!
+
bool bNotify( false );
bool bMustCallCreate( false );
uno::Reference< ui::XUIElement > xUIElement;
- ReadGuard aReadLock( m_aLock );
- uno::Reference< frame::XFrame > xFrame( m_xFrame );
- aReadLock.unlock();
-
- uno::Reference< frame::XModel > xModel( impl_getModelFromFrame( xFrame ));
- if ( implts_isPreviewModel( xModel ))
- return false; // no toolbars for preview frame!
-
UIElement aRequestedToolbar = impl_findToolbar( rResourceURL );
if ( aRequestedToolbar.m_aName != rResourceURL )
{
@@ -971,8 +983,7 @@ void ToolbarLayoutManager::implts_createAddonsToolBars()
uno::Reference< frame::XFrame > xFrame( m_xFrame );
aWriteLock.unlock();
- uno::Reference< frame::XModel > xModel( impl_getModelFromFrame( xFrame ));
- if ( implts_isPreviewModel( xModel ))
+ if (isPreviewFrame())
return; // no addon toolbars for preview frame!
UIElementVector aUIElementVector;
@@ -1084,15 +1095,13 @@ void ToolbarLayoutManager::implts_createCustomToolBars()
uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
uno::Reference< frame::XFrame > xFrame( m_xFrame );
- uno::Reference< frame::XModel > xModel;
uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr, uno::UNO_QUERY );
uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr, uno::UNO_QUERY );
aReadLock.unlock();
if ( xFrame.is() )
{
- xModel = impl_getModelFromFrame( xFrame );
- if ( implts_isPreviewModel( xModel ))
+ if (isPreviewFrame())
return; // no custom toolbars for preview frame!
uno::Sequence< uno::Sequence< beans::PropertyValue > > aTbxSeq;
@@ -1116,12 +1125,11 @@ void ToolbarLayoutManager::implts_createNonContextSensitiveToolBars()
if ( !m_xPersistentWindowState.is() || !m_xFrame.is() || !m_bComponentAttached )
return;
- uno::Reference< frame::XFrame > xFrame( m_xFrame );
uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
uno::Reference< container::XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
aReadLock.unlock();
- if ( implts_isPreviewModel( impl_getModelFromFrame( xFrame )))
+ if (isPreviewFrame())
return;
std::vector< rtl::OUString > aMakeVisibleToolbars;
@@ -1178,7 +1186,8 @@ void ToolbarLayoutManager::implts_createNonContextSensitiveToolBars()
}
if ( !aMakeVisibleToolbars.empty() )
- ::std::for_each( aMakeVisibleToolbars.begin(), aMakeVisibleToolbars.end(),::boost::bind( &ToolbarLayoutManager::requestToolbar, this,_1 ));
+ ::std::for_each( aMakeVisibleToolbars.begin(), aMakeVisibleToolbars.end(),
+ ::boost::bind( &ToolbarLayoutManager::requestToolbar, this, _1));
}
void ToolbarLayoutManager::implts_createCustomToolBars( const uno::Sequence< uno::Sequence< beans::PropertyValue > >& aTbxSeqSeq )
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.hxx b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
index eb2b22e30fce..b52fe4f9cd86 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.hxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
@@ -92,6 +92,13 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a
public:
enum { DOCKINGAREAS_COUNT = 4 };
+ enum PreviewFrameDetection
+ {
+ PREVIEWFRAME_UNKNOWN,
+ PREVIEWFRAME_NO,
+ PREVIEWFRAME_YES
+ };
+
ToolbarLayoutManager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMGR,
const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElementFactory >& xUIElementFactory,
ILayoutNotifications* pParentLayouter );
@@ -111,6 +118,8 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a
::com::sun::star::awt::Rectangle getDockingArea();
void setDockingArea( const ::com::sun::star::awt::Rectangle& rDockingArea );
+ bool isPreviewFrame();
+
// layouting
bool isLayoutDirty();
void doLayout(const ::Size& aContainerSize);
@@ -316,6 +325,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a
Rectangle m_aDockingArea;
Rectangle m_aDockingAreaOffsets;
DockingOperation m_eDockOperation;
+ PreviewFrameDetection m_ePreviewDetection;
std::auto_ptr< AddonsOptions > m_pAddonOptions;
std::auto_ptr< GlobalSettings > m_pGlobalSettings;