[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - include/sfx2 include/vcl sfx2/Library_sfx.mk sfx2/source vcl/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 23 07:30:24 UTC 2020


 include/sfx2/notebookbar/SfxNotebookBar.hxx          |    4 
 include/sfx2/notebookbar/WeldedTabbedNotebookbar.hxx |   35 ++++++++
 include/vcl/notebookbar.hxx                          |   10 ++
 sfx2/Library_sfx.mk                                  |    1 
 sfx2/source/notebookbar/SfxNotebookBar.cxx           |   30 ++++---
 sfx2/source/notebookbar/WeldedTabbedNotebookbar.cxx  |   25 ++++++
 vcl/source/control/notebookbar.cxx                   |   79 ++++++++++++++-----
 vcl/source/window/builder.cxx                        |    5 +
 8 files changed, 159 insertions(+), 30 deletions(-)

New commits:
commit 86578b072fac17b952e81fd82bac1d8f8a7e2476
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Jun 16 08:40:13 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Jun 23 09:29:55 2020 +0200

    notebookbar: use JSInstanceBuilder for styles preview in online
    
    Change-Id: I826ca92aec5e324b935dfc7c52fc95c6ce5c5e05
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96915
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 1997f64a3f5f..eaca96c6e57c 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -167,6 +167,11 @@ weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString
 
 weld::Builder* Application::CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile)
 {
+    if (comphelper::LibreOfficeKit::isActive() && rUIFile == "svx/ui/stylespreview.ui")
+    {
+        return new JSInstanceBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile, css::uno::Reference<css::frame::XFrame>());
+    }
+
     return ImplGetSVData()->mpDefInst->CreateInterimBuilder(pParent, VclBuilderContainer::getUIRootDir(), rUIFile);
 }
 
commit a69efab5583c289ed5d775b1e90a0b357637eb58
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Jun 5 06:42:45 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Jun 23 09:29:46 2020 +0200

    notebookbar: build using weld::Builder
    
    and provide welded implementation for writer tabbed
    
    Change-Id: Id6c71234cb1f40fd3889555785fcdbe84b801edd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96917
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx
index 1a3babd53d9e..4fbda295cace 100644
--- a/include/sfx2/notebookbar/SfxNotebookBar.hxx
+++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx
@@ -19,6 +19,7 @@ namespace com::sun::star::uno { template <typename > class Reference; }
 class SfxBindings;
 class SfxViewFrame;
 class SystemWindow;
+class WeldedTabbedNotebookbar;
 
 namespace sfx2 {
 
@@ -59,6 +60,9 @@ public:
 private:
     static bool m_bLock;
     static bool m_bHide;
+    static std::unique_ptr<WeldedTabbedNotebookbar> m_pNotebookBarWeldedWrapper;
+
+    DECL_STATIC_LINK(SfxNotebookBar, VclDisposeHdl, const void*, void);
 };
 
 } // namespace sfx2
diff --git a/include/sfx2/notebookbar/WeldedTabbedNotebookbar.hxx b/include/sfx2/notebookbar/WeldedTabbedNotebookbar.hxx
new file mode 100644
index 000000000000..d709fc64fcf1
--- /dev/null
+++ b/include/sfx2/notebookbar/WeldedTabbedNotebookbar.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SFX2_NOTEBOOKBAR_WRITERTABBEDNOTEBOOKBAR_HXX
+#define INCLUDED_SFX2_NOTEBOOKBAR_WRITERTABBEDNOTEBOOKBAR_HXX
+
+#include <sfx2/dllapi.h>
+#include <rtl/ustring.hxx>
+#include <vcl/weld.hxx>
+#include <sfx2/weldutils.hxx>
+#include <com/sun/star/frame/XFrame.hpp>
+
+/** Tabbed implementation of NotebookBar for Writer
+*/
+class SFX2_DLLPUBLIC WeldedTabbedNotebookbar
+{
+    std::unique_ptr<weld::Builder> m_xBuilder;
+
+    std::unique_ptr<weld::Container> m_xContainer;
+    std::unique_ptr<weld::Notebook> m_xNotebook;
+
+public:
+    WeldedTabbedNotebookbar(VclPtr<vcl::Window>& pContainerWindow, const OUString& rUIFilePath,
+                            const css::uno::Reference<css::frame::XFrame>& rFrame);
+};
+
+#endif // INCLUDED_SFX2_NOTEBOOKBAR_SFXNOTEBOOKBAR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx
index 457a64b9a206..3b4fa740e779 100644
--- a/include/vcl/notebookbar.hxx
+++ b/include/vcl/notebookbar.hxx
@@ -47,6 +47,11 @@ public:
     void ControlListenerForCurrentController(bool bListen);
     void StopListeningAllControllers();
 
+    bool IsWelded() { return m_bIsWelded; }
+    VclPtr<vcl::Window>& GetMainContainer() { return m_xVclContentArea; }
+    OUString GetUIFilePath() { return m_sUIXMLDescription; }
+    void SetDisposeCallback(const Link<const void*, void> rDisposeCallback);
+
 private:
     VclPtr<SystemWindow> m_pSystemWindow;
     css::uno::Reference<css::ui::XContextChangeEventListener> m_pEventListener;
@@ -54,6 +59,11 @@ private:
     std::vector<NotebookbarContextControl*> m_pContextContainers;
     css::uno::Reference<css::frame::XFrame> mxFrame;
 
+    VclPtr<vcl::Window> m_xVclContentArea;
+    bool m_bIsWelded;
+    OUString m_sUIXMLDescription;
+    Link<const void*, void> m_rDisposeLink;
+
     AllSettings DefaultSettings;
     AllSettings PersonaSettings;
 
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index cc2386fe5f82..b8b33751581c 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -243,6 +243,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/notebookbar/SfxNotebookBar \
     sfx2/source/notebookbar/NotebookbarPopup \
     sfx2/source/notebookbar/NotebookbarTabControl \
+    sfx2/source/notebookbar/WeldedTabbedNotebookbar \
     sfx2/source/notify/eventsupplier \
     sfx2/source/notify/globalevents \
     sfx2/source/notify/hintpost \
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 8f97aa045918..29f47dbf9ce6 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -32,6 +32,8 @@
 #include <framework/addonsoptions.hxx>
 #include <vcl/NotebookBarAddonsMerger.hxx>
 #include <vector>
+#include <sfx2/notebookbar/WeldedTabbedNotebookbar.hxx>
+
 using namespace sfx2;
 using namespace css::uno;
 using namespace css::ui;
@@ -44,6 +46,7 @@ static const char MERGE_NOTEBOOKBAR_IMAGEID[] = "ImageIdentifier";
 
 bool SfxNotebookBar::m_bLock = false;
 bool SfxNotebookBar::m_bHide = false;
+std::unique_ptr<WeldedTabbedNotebookbar> SfxNotebookBar::m_pNotebookBarWeldedWrapper;
 
 static void NotebookbarAddonValues(
     std::vector<Image>& aImageValues,
@@ -358,18 +361,9 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
         OUString sCurrentFile;
         VclPtr<NotebookBar> pNotebookBar = pSysWindow->GetNotebookBar();
         if ( pNotebookBar )
-            sCurrentFile = OStringToOUString( pNotebookBar->getUIFile(), RTL_TEXTENCODING_ASCII_US );
-
-        bool bChangedFile = true;
-        if ( sCurrentFile.getLength() && sNewFile.getLength() )
-        {
-            // delete "/"
-            sCurrentFile = sCurrentFile.copy( 0, sCurrentFile.getLength() - 1 );
-            // delete ".ui"
-            sNewFile = sNewFile.copy( 0, sNewFile.getLength() - 3 );
+            sCurrentFile = pNotebookBar->GetUIFilePath();
 
-            bChangedFile = sNewFile != sCurrentFile;
-        }
+        bool bChangedFile = sNewFile != sCurrentFile;
 
         if ((!sFile.isEmpty() && bChangedFile) || !pNotebookBar || !pNotebookBar->IsVisible()
             || bReloadNotebookbar)
@@ -390,6 +384,15 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
             pSysWindow->SetNotebookBar(aBuf, xFrame, aNotebookBarAddonsItem , bReloadNotebookbar);
             pNotebookBar = pSysWindow->GetNotebookBar();
             pNotebookBar->Show();
+
+            if ((!m_pNotebookBarWeldedWrapper || bReloadNotebookbar) && pNotebookBar->IsWelded())
+            {
+                m_pNotebookBarWeldedWrapper.reset(new WeldedTabbedNotebookbar(pNotebookBar->GetMainContainer(),
+                                                                              pNotebookBar->GetUIFilePath(),
+                                                                              xFrame));
+                pNotebookBar->SetDisposeCallback(LINK(nullptr, SfxNotebookBar, VclDisposeHdl));
+            }
+
             pNotebookBar->GetParent()->Resize();
 
             utl::OConfigurationTreeRoot aRoot(lcl_getCurrentImplConfigRoot());
@@ -557,4 +560,9 @@ void SfxNotebookBar::ReloadNotebookBar(const OUString& sUIPath)
     }
 }
 
+IMPL_STATIC_LINK_NOARG(SfxNotebookBar, VclDisposeHdl, const void*, void)
+{
+    m_pNotebookBarWeldedWrapper.reset();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/WeldedTabbedNotebookbar.cxx b/sfx2/source/notebookbar/WeldedTabbedNotebookbar.cxx
new file mode 100644
index 000000000000..f5bb4ee99a6e
--- /dev/null
+++ b/sfx2/source/notebookbar/WeldedTabbedNotebookbar.cxx
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sfx2/notebookbar/WeldedTabbedNotebookbar.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/jsdialog/jsdialogbuilder.hxx>
+
+WeldedTabbedNotebookbar::WeldedTabbedNotebookbar(
+    VclPtr<vcl::Window>& pContainerWindow, const OUString& rUIFilePath,
+    const css::uno::Reference<css::frame::XFrame>& rFrame)
+    : m_xBuilder(new JSInstanceBuilder(pContainerWindow, VclBuilderContainer::getUIRootDir(),
+                                       rUIFilePath, rFrame))
+{
+    m_xContainer = m_xBuilder->weld_container("NotebookBar");
+    m_xNotebook = m_xBuilder->weld_notebook("ContextContainer");
+    m_xNotebook->set_current_page("HomeLabel");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx
index bcf2f7563ff5..c954c7d3b558 100644
--- a/vcl/source/control/notebookbar.cxx
+++ b/vcl/source/control/notebookbar.cxx
@@ -19,6 +19,7 @@
 #include <config_folders.h>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
+#include <comphelper/lok.hxx>
 
 static OUString getCustomizedUIRootDir()
 {
@@ -55,36 +56,60 @@ NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rU
                          const NotebookBarAddonsItem& aNotebookBarAddonsItem)
     : Control(pParent)
     , m_pEventListener(new NotebookBarContextChangeEventListener(this))
+    , m_bIsWelded(false)
+    , m_sUIXMLDescription(rUIXMLDescription)
 {
+    mxFrame = rFrame;
+
     SetStyle(GetStyle() | WB_DIALOGCONTROL);
     OUString sUIDir = getUIRootDir();
     bool doesCustomizedUIExist = doesFileExist(getCustomizedUIRootDir(), rUIXMLDescription);
     if ( doesCustomizedUIExist )
         sUIDir = getCustomizedUIRootDir();
-    m_pUIBuilder.reset(
-        new VclBuilder(this, sUIDir, rUIXMLDescription, rID, rFrame, true, &aNotebookBarAddonsItem));
-    mxFrame = rFrame;
-    // In the Notebookbar's .ui file must exist control handling context
-    // - implementing NotebookbarContextControl interface with id "ContextContainer"
-    // or "ContextContainerX" where X is a number >= 1
-    NotebookbarContextControl* pContextContainer = nullptr;
-    int i = 0;
-    do
+
+    bool bIsWelded = comphelper::LibreOfficeKit::isActive()
+                    && (rUIXMLDescription == "modules/swriter/ui/notebookbar.ui"
+                    || rUIXMLDescription == "modules/scalc/ui/notebookbar.ui"
+                    || rUIXMLDescription == "modules/simpress/ui/notebookbar.ui");
+    if (bIsWelded)
+    {
+        m_bIsWelded = true;
+        m_xVclContentArea = VclPtr<VclVBox>::Create(this);
+        m_xVclContentArea->Show();
+        // now access it using GetMainContainer and set dispose callback with SetDisposeCallback
+    }
+    else
     {
-        OUString aName = "ContextContainer";
-        if (i)
-            aName += OUString::number(i);
-
-        pContextContainer = dynamic_cast<NotebookbarContextControl*>(m_pUIBuilder->get<Window>(OUStringToOString(aName, RTL_TEXTENCODING_UTF8)));
-        if (pContextContainer)
-            m_pContextContainers.push_back(pContextContainer);
-        i++;
+        m_pUIBuilder.reset(
+            new VclBuilder(this, sUIDir, rUIXMLDescription, rID, rFrame, true, &aNotebookBarAddonsItem));
+
+        // In the Notebookbar's .ui file must exist control handling context
+        // - implementing NotebookbarContextControl interface with id "ContextContainer"
+        // or "ContextContainerX" where X is a number >= 1
+        NotebookbarContextControl* pContextContainer = nullptr;
+        int i = 0;
+        do
+        {
+            OUString aName = "ContextContainer";
+            if (i)
+                aName += OUString::number(i);
+
+            pContextContainer = dynamic_cast<NotebookbarContextControl*>(m_pUIBuilder->get<Window>(OUStringToOString(aName, RTL_TEXTENCODING_UTF8)));
+            if (pContextContainer)
+                m_pContextContainers.push_back(pContextContainer);
+            i++;
+        }
+        while( pContextContainer != nullptr );
     }
-    while( pContextContainer != nullptr );
 
     UpdateBackground();
 }
 
+void NotebookBar::SetDisposeCallback(const Link<const void*, void> rDisposeCallback)
+{
+    m_rDisposeLink = rDisposeCallback;
+}
+
 NotebookBar::~NotebookBar()
 {
     disposeOnce();
@@ -96,9 +121,18 @@ void NotebookBar::dispose()
     if (m_pSystemWindow && m_pSystemWindow->ImplIsInTaskPaneList(this))
         m_pSystemWindow->GetTaskPaneList()->RemoveWindow(this);
     m_pSystemWindow.clear();
-    disposeBuilder();
+
+    if (m_rDisposeLink.IsSet())
+        m_rDisposeLink.Call(nullptr);
+
+    if (m_bIsWelded)
+        m_xVclContentArea.disposeAndClear();
+    else
+        disposeBuilder();
+
     assert(m_alisteningControllers.empty());
     m_pEventListener.clear();
+
     Control::dispose();
 }
 
@@ -162,6 +196,13 @@ void NotebookBar::Resize()
             pWindow->SetSizePixel(aSize);
         }
     }
+    if(m_bIsWelded)
+    {
+        vcl::Window* pChild = GetWindow(GetWindowType::FirstChild);
+        assert(pChild);
+        VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel());
+        Control::Resize();
+    }
     Control::Resize();
 }
 


More information about the Libreoffice-commits mailing list