Kaydet (Commit) 7c5064d3 authored tarafından Eike Rathke's avatar Eike Rathke

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.
üst f7d3567c
...@@ -1464,15 +1464,24 @@ throw (RuntimeException) ...@@ -1464,15 +1464,24 @@ throw (RuntimeException)
if ( !xFrame.is() ) if ( !xFrame.is() )
return; return;
Reference< XModel > xModel( impl_getModelFromFrame( xFrame ) );
/* SAFE AREA ----------------------------------------------------------------------------------------------- */ /* SAFE AREA ----------------------------------------------------------------------------------------------- */
WriteGuard aWriteLock( m_aLock ); WriteGuard aWriteLock( m_aLock );
bool bMustBeLayouted( false ); bool bMustBeLayouted( false );
bool bNotify( 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 aElementType;
::rtl::OUString aElementName; ::rtl::OUString aElementName;
......
...@@ -66,6 +66,7 @@ ToolbarLayoutManager::ToolbarLayoutManager( ...@@ -66,6 +66,7 @@ ToolbarLayoutManager::ToolbarLayoutManager(
m_xUIElementFactoryManager( xUIElementFactory ), m_xUIElementFactoryManager( xUIElementFactory ),
m_pParentLayouter( pParentLayouter ), m_pParentLayouter( pParentLayouter ),
m_eDockOperation( DOCKOP_ON_COLROW ), m_eDockOperation( DOCKOP_ON_COLROW ),
m_ePreviewDetection( PREVIEWFRAME_UNKNOWN ),
m_bComponentAttached( false ), m_bComponentAttached( false ),
m_bMustLayout( false ), m_bMustLayout( false ),
m_bLayoutDirty( false ), m_bLayoutDirty( false ),
...@@ -374,6 +375,7 @@ void ToolbarLayoutManager::reset() ...@@ -374,6 +375,7 @@ void ToolbarLayoutManager::reset()
uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr ); uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr );
m_xModuleCfgMgr.clear(); m_xModuleCfgMgr.clear();
m_xDocCfgMgr.clear(); m_xDocCfgMgr.clear();
m_ePreviewDetection = PREVIEWFRAME_UNKNOWN;
m_bComponentAttached = false; m_bComponentAttached = false;
aWriteLock.unlock(); aWriteLock.unlock();
...@@ -399,6 +401,21 @@ void ToolbarLayoutManager::attach( ...@@ -399,6 +401,21 @@ void ToolbarLayoutManager::attach(
m_bComponentAttached = true; 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() void ToolbarLayoutManager::createStaticToolbars()
{ {
resetDockingArea(); resetDockingArea();
...@@ -410,18 +427,13 @@ void ToolbarLayoutManager::createStaticToolbars() ...@@ -410,18 +427,13 @@ void ToolbarLayoutManager::createStaticToolbars()
bool ToolbarLayoutManager::requestToolbar( const ::rtl::OUString& rResourceURL ) bool ToolbarLayoutManager::requestToolbar( const ::rtl::OUString& rResourceURL )
{ {
if (isPreviewFrame())
return false; // no toolbars for preview frame!
bool bNotify( false ); bool bNotify( false );
bool bMustCallCreate( false ); bool bMustCallCreate( false );
uno::Reference< ui::XUIElement > xUIElement; 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 ); UIElement aRequestedToolbar = impl_findToolbar( rResourceURL );
if ( aRequestedToolbar.m_aName != rResourceURL ) if ( aRequestedToolbar.m_aName != rResourceURL )
{ {
...@@ -970,8 +982,7 @@ void ToolbarLayoutManager::implts_createAddonsToolBars() ...@@ -970,8 +982,7 @@ void ToolbarLayoutManager::implts_createAddonsToolBars()
uno::Reference< frame::XFrame > xFrame( m_xFrame ); uno::Reference< frame::XFrame > xFrame( m_xFrame );
aWriteLock.unlock(); aWriteLock.unlock();
uno::Reference< frame::XModel > xModel( impl_getModelFromFrame( xFrame )); if (isPreviewFrame())
if ( implts_isPreviewModel( xModel ))
return; // no addon toolbars for preview frame! return; // no addon toolbars for preview frame!
UIElementVector aUIElementVector; UIElementVector aUIElementVector;
...@@ -1083,15 +1094,13 @@ void ToolbarLayoutManager::implts_createCustomToolBars() ...@@ -1083,15 +1094,13 @@ void ToolbarLayoutManager::implts_createCustomToolBars()
uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager ); uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
uno::Reference< frame::XFrame > xFrame( m_xFrame ); 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 > xModuleCfgMgr( m_xModuleCfgMgr, uno::UNO_QUERY );
uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr, uno::UNO_QUERY ); uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr, uno::UNO_QUERY );
aReadLock.unlock(); aReadLock.unlock();
if ( xFrame.is() ) if ( xFrame.is() )
{ {
xModel = impl_getModelFromFrame( xFrame ); if (isPreviewFrame())
if ( implts_isPreviewModel( xModel ))
return; // no custom toolbars for preview frame! return; // no custom toolbars for preview frame!
uno::Sequence< uno::Sequence< beans::PropertyValue > > aTbxSeq; uno::Sequence< uno::Sequence< beans::PropertyValue > > aTbxSeq;
...@@ -1115,12 +1124,11 @@ void ToolbarLayoutManager::implts_createNonContextSensitiveToolBars() ...@@ -1115,12 +1124,11 @@ void ToolbarLayoutManager::implts_createNonContextSensitiveToolBars()
if ( !m_xPersistentWindowState.is() || !m_xFrame.is() || !m_bComponentAttached ) if ( !m_xPersistentWindowState.is() || !m_xFrame.is() || !m_bComponentAttached )
return; return;
uno::Reference< frame::XFrame > xFrame( m_xFrame );
uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager ); uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
uno::Reference< container::XNameAccess > xPersistentWindowState( m_xPersistentWindowState ); uno::Reference< container::XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
aReadLock.unlock(); aReadLock.unlock();
if ( implts_isPreviewModel( impl_getModelFromFrame( xFrame ))) if (isPreviewFrame())
return; return;
std::vector< rtl::OUString > aMakeVisibleToolbars; std::vector< rtl::OUString > aMakeVisibleToolbars;
...@@ -1178,7 +1186,8 @@ void ToolbarLayoutManager::implts_createNonContextSensitiveToolBars() ...@@ -1178,7 +1186,8 @@ void ToolbarLayoutManager::implts_createNonContextSensitiveToolBars()
} }
if ( !aMakeVisibleToolbars.empty() ) 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 ) void ToolbarLayoutManager::implts_createCustomToolBars( const uno::Sequence< uno::Sequence< beans::PropertyValue > >& aTbxSeqSeq )
......
...@@ -92,6 +92,13 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a ...@@ -92,6 +92,13 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a
public: public:
enum { DOCKINGAREAS_COUNT = 4 }; 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, 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, const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElementFactory >& xUIElementFactory,
ILayoutNotifications* pParentLayouter ); ILayoutNotifications* pParentLayouter );
...@@ -111,6 +118,8 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a ...@@ -111,6 +118,8 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a
::com::sun::star::awt::Rectangle getDockingArea(); ::com::sun::star::awt::Rectangle getDockingArea();
void setDockingArea( const ::com::sun::star::awt::Rectangle& rDockingArea ); void setDockingArea( const ::com::sun::star::awt::Rectangle& rDockingArea );
bool isPreviewFrame();
// layouting // layouting
bool isLayoutDirty(); bool isLayoutDirty();
void doLayout(const ::Size& aContainerSize); void doLayout(const ::Size& aContainerSize);
...@@ -316,6 +325,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a ...@@ -316,6 +325,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a
Rectangle m_aDockingArea; Rectangle m_aDockingArea;
Rectangle m_aDockingAreaOffsets; Rectangle m_aDockingAreaOffsets;
DockingOperation m_eDockOperation; DockingOperation m_eDockOperation;
PreviewFrameDetection m_ePreviewDetection;
std::auto_ptr< AddonsOptions > m_pAddonOptions; std::auto_ptr< AddonsOptions > m_pAddonOptions;
std::auto_ptr< GlobalSettings > m_pGlobalSettings; std::auto_ptr< GlobalSettings > m_pGlobalSettings;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment