[Libreoffice-commits] core.git: 2 commits - framework/inc framework/source include/vcl solenv/clang-format

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 18 08:15:03 UTC 2018


 framework/inc/classes/taskcreator.hxx        |    3 ++-
 framework/source/classes/taskcreator.cxx     |   10 ++++++++--
 framework/source/loadenv/loadenv.cxx         |    4 +++-
 framework/source/services/desktop.cxx        |    4 ++--
 framework/source/services/frame.cxx          |   23 ++++++++++++++++-------
 framework/source/services/taskcreatorsrv.cxx |    9 +++++++++
 include/vcl/window.hxx                       |    7 ++++++-
 solenv/clang-format/reformat-formatted-files |   18 ++++++++++++++++--
 8 files changed, 62 insertions(+), 16 deletions(-)

New commits:
commit abe4eaf57be93300be4710aee0bc283055403f4b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Jan 17 23:07:50 2018 +0100

    clang-format: allow just listing formatted files
    
    Without running clang-format on them. Also format one file at a time, so
    we don't run into command line length limits as the number of formatted
    files grows.
    
    Change-Id: Ie559d566db784e04965678f056dcb81cefe95378
    Reviewed-on: https://gerrit.libreoffice.org/48085
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/solenv/clang-format/reformat-formatted-files b/solenv/clang-format/reformat-formatted-files
index 5059251682d3..04b0adde8e4e 100755
--- a/solenv/clang-format/reformat-formatted-files
+++ b/solenv/clang-format/reformat-formatted-files
@@ -7,6 +7,7 @@
 
 # Reformat files which are not blacklisted. This is interesting if the
 # clang-format version or config changes.
+# -n allows just listing the formatted files.
 
 use strict;
 use warnings;
@@ -17,6 +18,7 @@ my $clang_format = ClangFormat::find();
 my $src = ClangFormat::get_extension_regex();
 my $blacklist_names = ClangFormat::get_blacklist();
 my @filenames = ();
+my $dry_run = 0;
 
 # Get a list of files.
 open (FILES, "git ls-files |") ||  die "Cannot run git ls-files.";
@@ -29,7 +31,19 @@ while (my $filename = <FILES>)
     }
 }
 
-print("$clang_format -i " . join(" ", @filenames) . "\n");
-system("$clang_format -i " . join(" ", @filenames) . "\n");
+if ($#ARGV ge 0 && $ARGV[0] eq "-n")
+{
+    $dry_run = 1;
+}
+
+foreach my $filename (@filenames)
+{
+    my $command = $clang_format . " -i " . $filename;
+    print($filename . "\n");
+    if (!$dry_run)
+    {
+        system($command);
+    }
+}
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
commit 4a0f506f0d8c2a017f0cf880481d3c0c32a48909
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Jan 17 17:24:35 2018 +0100

    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 at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

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 6fd8f5b54061..d5819ebb6675 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 b7fc1a152ed3..fbfe5cd9f7c6 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 adc174a8ad3a..0357a4955b82 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 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 26708477a502..c0f98832cd69 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 34dca718c4c0..528ba110bd04 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 {


More information about the Libreoffice-commits mailing list