diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-17 17:24:35 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-21 12:11:54 +0100 |
commit | 6fe37f133f089ebcdb943818341c3f80fa6a58e6 (patch) | |
tree | c544f664cf09f1e7cd6a84506ab022fcb924af37 | |
parent | 96c8ac6faa238e77b17f9cf48cc0f565c5ac640e (diff) |
framework: disable layout manager in hidden frames
The point of hidden frames is that they are not visible on the UI, only their
doc model / layout is accessible via the API or file format conversion. That
means that laying out the UI elements like menus and toolbars is pointless.
So change Frame::initialize() and Frame::setLayoutManager() to not enable the
layout manager for hidden frames. To do this, we need a new window style flag,
as both hidden and visible frames have an underlying hidden window at the time
the framework layout manager would be enabled.
Times for 200 hello world inputs: 5780 -> 5054 ms is spent in XHTML-load + ODT
export + close (87% of original).
Change-Id: I841507bbb62f8fc2979d20e2d579d0bb47b98f37
Reviewed-on: https://gerrit.libreoffice.org/48068
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit 4a0f506f0d8c2a017f0cf880481d3c0c32a48909)
-rw-r--r-- | framework/inc/classes/taskcreator.hxx | 3 | ||||
-rw-r--r-- | framework/source/classes/taskcreator.cxx | 10 | ||||
-rw-r--r-- | framework/source/loadenv/loadenv.cxx | 4 | ||||
-rw-r--r-- | framework/source/services/desktop.cxx | 4 | ||||
-rw-r--r-- | framework/source/services/frame.cxx | 23 | ||||
-rw-r--r-- | framework/source/services/taskcreatorsrv.cxx | 9 | ||||
-rw-r--r-- | include/vcl/window.hxx | 7 |
7 files changed, 46 insertions, 14 deletions
diff --git a/framework/inc/classes/taskcreator.hxx b/framework/inc/classes/taskcreator.hxx index 3c34bb00e1ad..ee8056f13812 100644 --- a/framework/inc/classes/taskcreator.hxx +++ b/framework/inc/classes/taskcreator.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <rtl/ustring.hxx> +#include <unotools/mediadescriptor.hxx> namespace framework{ @@ -53,7 +54,7 @@ class TaskCreator final TaskCreator( const css::uno::Reference< css::uno::XComponentContext >& xContext ); ~TaskCreator( ); - css::uno::Reference< css::frame::XFrame > createTask( const OUString& sName ); + css::uno::Reference< css::frame::XFrame > createTask( const OUString& sName, const utl::MediaDescriptor& rDesciprtor ); }; // class TaskCreator diff --git a/framework/source/classes/taskcreator.cxx b/framework/source/classes/taskcreator.cxx index 612ab433e7e3..0bf720b510ac 100644 --- a/framework/source/classes/taskcreator.cxx +++ b/framework/source/classes/taskcreator.cxx @@ -57,7 +57,7 @@ TaskCreator::~TaskCreator() /*-**************************************************************************************************** TODO document me *//*-*****************************************************************************************************/ -css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName ) +css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName, const utl::MediaDescriptor& rDescriptor ) { css::uno::Reference< css::lang::XSingleServiceFactory > xCreator; OUString sCreator = IMPLEMENTATIONNAME_FWK_TASKCREATOR; @@ -86,7 +86,7 @@ css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUStrin if ( ! xCreator.is()) xCreator = css::frame::TaskCreator::create(m_xContext); - css::uno::Sequence< css::uno::Any > lArgs(5); + css::uno::Sequence< css::uno::Any > lArgs(6); css::beans::NamedValue aArg; aArg.Name = ARGUMENT_PARENTFRAME; @@ -109,6 +109,12 @@ css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUStrin aArg.Value <<= sName; lArgs[4] <<= aArg; + bool bHidden + = rDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(), false); + aArg.Name = "Hidden"; + aArg.Value <<= bHidden; + lArgs[5] <<= aArg; + css::uno::Reference< css::frame::XFrame > xTask(xCreator->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW); return xTask; } diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index a2cfb5e2b9f7..15861f8df97d 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -87,6 +87,7 @@ #include <vcl/svapp.hxx> #include <cppuhelper/implbase.hxx> #include <comphelper/profilezone.hxx> +#include <classes/taskcreator.hxx> const char PROP_TYPES[] = "Types"; const char PROP_NAME[] = "Name"; @@ -989,7 +990,8 @@ bool LoadEnv::impl_loadContent() { if (! impl_furtherDocsAllowed()) return false; - m_xTargetFrame = m_xBaseFrame->findFrame(SPECIALTARGET_BLANK, 0); + TaskCreator aCreator(m_xContext); + m_xTargetFrame = aCreator.createTask(SPECIALTARGET_BLANK, m_lMediaDescriptor); m_bCloseFrameOnError = m_xTargetFrame.is(); } else diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index 119dd5d69697..b479687fdeae 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -967,7 +967,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS if ( sTargetFrameName==SPECIALTARGET_BLANK ) { TaskCreator aCreator( m_xContext ); - xTarget = aCreator.createTask(sTargetFrameName); + xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor()); } // I.II) "_top" @@ -1051,7 +1051,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS ) { TaskCreator aCreator( m_xContext ); - xTarget = aCreator.createTask(sTargetFrameName); + xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor()); } } diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index 5998d7902ccb..f404b6fbf9f0 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -412,6 +412,8 @@ private: bool m_bSelfClose; /// indicates, if this frame is used in hidden mode or not bool m_bIsHidden; + /// The container window has WindowExtendedStyle::DocHidden set. + bool m_bDocHidden = false; /// is used to layout the child windows of the frame. css::uno::Reference< css::frame::XLayoutManager2 > m_xLayoutManager; css::uno::Reference< css::frame::XDispatchInformationProvider > m_xDispatchInfoHelper; @@ -772,8 +774,13 @@ void SAL_CALL Frame::initialize( const css::uno::Reference< css::awt::XWindow >& // if window is initially visible, we will never get a windowShowing event VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow); - if (pWindow && pWindow->IsVisible()) - m_bIsHidden = false; + if (pWindow) + { + if (pWindow->IsVisible()) + m_bIsHidden = false; + m_bDocHidden + = static_cast<bool>(pWindow->GetExtendedStyle() & WindowExtendedStyle::DocHidden); + } css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager = m_xLayoutManager; @@ -782,7 +789,9 @@ void SAL_CALL Frame::initialize( const css::uno::Reference< css::awt::XWindow >& aWriteLock.clear(); /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ - if (xLayoutManager.is()) + // Avoid enabling the layout manager for hidden frames: it's expensive and + // provides little value. + if (xLayoutManager.is() && !m_bDocHidden) lcl_enableLayoutManager(xLayoutManager, this); // create progress helper @@ -971,7 +980,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const OUStr if ( sTargetFrameName==SPECIALTARGET_BLANK ) { TaskCreator aCreator(m_xContext); - xTarget = aCreator.createTask(sTargetFrameName); + xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor()); } // I.II) "_parent" @@ -1171,7 +1180,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const OUStr ) { TaskCreator aCreator(m_xContext); - xTarget = aCreator.createTask(sTargetFrameName); + xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor()); } } @@ -1825,7 +1834,7 @@ void SAL_CALL Frame::setLayoutManager(const css::uno::Reference<css::uno::XInter m_xLayoutManager = xNewLayoutManager; if (xOldLayoutManager.is()) disableLayoutManager(xOldLayoutManager); - if (xNewLayoutManager.is()) + if (xNewLayoutManager.is() && !m_bDocHidden) lcl_enableLayoutManager(xNewLayoutManager, this); } } @@ -2738,7 +2747,7 @@ void SAL_CALL Frame::impl_setPropertyValue(sal_Int32 nHandle, m_xLayoutManager = xNewLayoutManager; if (xOldLayoutManager.is()) disableLayoutManager(xOldLayoutManager); - if (xNewLayoutManager.is()) + if (xNewLayoutManager.is() && !m_bDocHidden) lcl_enableLayoutManager(xNewLayoutManager, this); } } diff --git a/framework/source/services/taskcreatorsrv.cxx b/framework/source/services/taskcreatorsrv.cxx index b6f6a7ff1920..e526481c709f 100644 --- a/framework/source/services/taskcreatorsrv.cxx +++ b/framework/source/services/taskcreatorsrv.cxx @@ -129,6 +129,8 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI css::uno::Reference< css::awt::XWindow > xContainerWindow = lArgs.getUnpackedValueOrDefault(ARGUMENT_CONTAINERWINDOW , css::uno::Reference< css::awt::XWindow >() ); bool bSupportPersistentWindowState = lArgs.getUnpackedValueOrDefault(ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE , false ); bool bEnableTitleBarUpdate = lArgs.getUnpackedValueOrDefault(ARGUMENT_ENABLE_TITLEBARUPDATE , true ); + // If the frame is explicitly requested to be hidden. + bool bHidden = lArgs.getUnpackedValueOrDefault("Hidden", false); // We use FrameName property to set it as API name of the new created frame later. // But those frame names must be different from the set of special target names as e.g. _blank, _self etcpp ! @@ -167,6 +169,13 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI //-------------------> // create the new frame + VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow(xContainerWindow); + if (pContainerWindow && bHidden) + { + WindowExtendedStyle eStyle = pContainerWindow->GetExtendedStyle(); + eStyle |= WindowExtendedStyle::DocHidden; + pContainerWindow->SetExtendedStyle(eStyle); + } css::uno::Reference< css::frame::XFrame2 > xFrame = implts_createFrame(xParentFrame, xContainerWindow, sRightName); // special freature: diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 477401d7d7b6..4285d0277da1 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -470,9 +470,14 @@ enum class WindowExtendedStyle { NONE = 0x0000, Document = 0x0001, DocModified = 0x0002, + /** + * This is a frame window that is requested to be hidden (not just "not yet + * shown"). + */ + DocHidden = 0x0004, }; namespace o3tl { - template<> struct typed_flags<WindowExtendedStyle> : is_typed_flags<WindowExtendedStyle, 0x0003> {}; + template<> struct typed_flags<WindowExtendedStyle> : is_typed_flags<WindowExtendedStyle, 0x0007> {}; }; namespace vcl { |