desktop/source/lib/init.cxx          |    2 
 sc/source/ui/app/inputwin.cxx        |   86 -----------------------------------
 sc/source/ui/inc/inputwin.hxx        |    3 -
 vcl/inc/jsdialog/jsdialogbuilder.hxx |    7 ++
 vcl/jsdialog/jsdialogbuilder.cxx     |   34 +++++++++++++
 vcl/source/window/builder.cxx        |   11 +++-
 6 files changed, 52 insertions(+), 91 deletions(-)

New commits:
commit a62325fd06777b188b84d8e6df94a79a1fbbbade
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Sat Apr 9 22:51:49 2022 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Sat Apr 23 08:30:48 2022 +0200

    jsdialog: used for formulabar
    
    - do not block painting
    - use welded wrappers to send JSON
    - don't send tunneled dialog
    
    Change-Id: I54c3cd02ab63bad4a50a3623a32f13b0c94a3595
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132757
    Reviewed-by: Mert Tumer <mert.tu...@collabora.com>
    Tested-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index df5f67ad3c2b..c891bd2b0b4f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4072,6 +4072,8 @@ static void lcl_sendDialogEvent(unsigned long long int 
nWindowId, const char* pA
             bFoundWeldedControl = 
jsdialog::ExecuteAction(std::to_string(nCurrentShellId) + "sidebar", 
sControlId, aMap);
         if (!bFoundWeldedControl)
             bFoundWeldedControl = 
jsdialog::ExecuteAction(std::to_string(nCurrentShellId) + "notebookbar", 
sControlId, aMap);
+        if (!bFoundWeldedControl)
+            bFoundWeldedControl = 
jsdialog::ExecuteAction(std::to_string(nCurrentShellId) + "formulabar", 
sControlId, aMap);
         if (!bFoundWeldedControl && !SfxViewShell::Current())
         {
             // this is needed for dialogs shown before document is loaded: 
MacroWarning dialog, etc...
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index def5e37791d9..10af93751631 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -309,11 +309,8 @@ void ScInputWindow::dispose()
 
     if (comphelper::LibreOfficeKit::isActive())
     {
-        if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-        {
-            pNotifier->notifyWindow(GetLOKWindowId(), "close");
+        if (GetLOKNotifier())
             ReleaseLOKNotifier();
-        }
     }
 
     mxTextWindow.disposeAndClear();
@@ -420,24 +417,6 @@ void ScInputWindow::Select()
     }
 }
 
-void ScInputWindow::Paint(vcl::RenderContext& rRenderContext, const 
tools::Rectangle& rRect)
-{
-    if (comphelper::LibreOfficeKit::isActive() && 
!comphelper::LibreOfficeKit::isDialogPainting())
-        return;
-
-    ToolBox::Paint(rRenderContext, rRect);
-
-    if (!comphelper::LibreOfficeKit::isActive())
-    {
-        // draw a line at the bottom to distinguish that from the grid
-        // const StyleSettings& rStyleSettings = 
rRenderContext.GetSettings().GetStyleSettings();
-        // rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
-        // Size aSize = GetSizePixel();
-        // rRenderContext.DrawLine(Point(0, aSize.Height() - 1),
-        //                        Point(aSize.Width() - 1, aSize.Height() - 
1));
-    }
-}
-
 void ScInputWindow::PixelInvalidate(const tools::Rectangle* pRectangle)
 {
     if (comphelper::LibreOfficeKit::isDialogPainting() || 
!comphelper::LibreOfficeKit::isActive())
@@ -477,20 +456,6 @@ void ScInputWindow::SetSizePixel( const Size& rNewSize )
     ToolBox::SetSizePixel(rNewSize);
 }
 
-void ScInputWindow::setPosSizePixel(tools::Long nX, tools::Long nY, 
tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags)
-{
-    ToolBox::setPosSizePixel(nX, nY, nWidth, nHeight, nFlags);
-    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-    {
-        std::vector<vcl::LOKPayloadItem> aItems;
-        aItems.emplace_back(std::make_pair("position", 
Point(GetOutOffXPixel(), GetOutOffYPixel()).toString()));
-        aItems.emplace_back("size", GetSizePixel().toString());
-        aItems.emplace_back("lines", 
OString::number(mxTextWindow->GetNumLines()));
-        pNotifier->notifyWindow(GetLOKWindowId(), "size_changed", aItems);
-        Invalidate();
-    }
-}
-
 void ScInputWindow::Resize()
 {
     ToolBox::Resize();
@@ -521,15 +486,6 @@ void ScInputWindow::Resize()
     }
     SetSizePixel(aSize);
 
-    if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
-    {
-        std::vector<vcl::LOKPayloadItem> aItems;
-        aItems.emplace_back(std::make_pair("position", 
Point(GetOutOffXPixel(), GetOutOffYPixel()).toString()));
-        aItems.emplace_back("size", GetSizePixel().toString());
-        aItems.emplace_back("lines", 
OString::number(mxTextWindow->GetNumLines()));
-        pNotifier->notifyWindow(GetLOKWindowId(), "size_changed", aItems);
-    }
-
     Invalidate();
 }
 
@@ -537,21 +493,6 @@ void ScInputWindow::NotifyLOKClient()
 {
     if (comphelper::LibreOfficeKit::isActive() && !GetLOKNotifier() && 
mpViewShell)
         SetLOKNotifier(mpViewShell);
-
-    const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier();
-    if (!pNotifier)
-        return;
-
-    Size aSize = GetSizePixel();
-    if (!aSize.IsEmpty())
-    {
-        std::vector<vcl::LOKPayloadItem> aItems;
-        aItems.emplace_back("type", "calc-input-win");
-        aItems.emplace_back(std::make_pair("position", 
Point(GetOutOffXPixel(), GetOutOffYPixel()).toString()));
-        aItems.emplace_back(std::make_pair("size", aSize.toString()));
-        aItems.emplace_back("lines", 
OString::number(mxTextWindow->GetNumLines()));
-        pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
-    }
 }
 
 void ScInputWindow::SetFuncString( const OUString& rString, bool bDoEdit )
@@ -882,7 +823,7 @@ void ScInputWindow::AutoSum( bool& bRangeFinder, bool& 
bSubTotal, OpCode eCode )
 }
 
 ScInputBarGroup::ScInputBarGroup(vcl::Window* pParent, ScTabViewShell* pViewSh)
-    : InterimItemWindow(pParent, "modules/scalc/ui/inputbar.ui", "InputBar")
+    : InterimItemWindow(pParent, "modules/scalc/ui/inputbar.ui", "InputBar", 
true, reinterpret_cast<sal_uInt64>(pViewSh))
     , mxBackground(m_xBuilder->weld_container("background"))
     , mxTextWndGroup(new ScTextWndGroup(*this, pViewSh))
     , mxButtonUp(m_xBuilder->weld_button("up"))
@@ -1277,9 +1218,6 @@ IMPL_LINK_NOARG(ScTextWndGroup, Impl_ScrollHdl, 
weld::ScrolledWindow&, void)
 
 void ScTextWnd::Paint( vcl::RenderContext& rRenderContext, const 
tools::Rectangle& rRect )
 {
-    if (comphelper::LibreOfficeKit::isActive() && 
!comphelper::LibreOfficeKit::isDialogPainting())
-        return;
-
     const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
     Color aBgColor = rStyleSettings.GetWindowColor();
     rRenderContext.SetBackground(aBgColor);
@@ -1308,26 +1246,6 @@ void ScTextWnd::Paint( vcl::RenderContext& 
rRenderContext, const tools::Rectangl
     }
     else
         WeldEditView::Paint(rRenderContext, rRect);
-
-    if (!comphelper::LibreOfficeKit::isActive())
-        return;
-
-    bool bIsFocused = false;
-    if (HasFocus())
-    {
-        vcl::Cursor* pCursor = m_xEditView->GetCursor();
-        if (pCursor)
-            bIsFocused = true;
-    }
-
-    VclPtr<vcl::Window> pParent = 
mrGroupBar.GetVclParent().GetParentWithLOKNotifier();
-    if (!pParent)
-        return;
-
-    const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier();
-    std::vector<vcl::LOKPayloadItem> aItems;
-    aItems.emplace_back("visible", bIsFocused ? "true" : "false");
-    pNotifier->notifyWindow(pParent->GetLOKWindowId(), "cursor_visible", 
aItems);
 }
 
 EditView* ScTextWnd::GetEditView() const
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 0e056fa22c29..507d91ce5c4a 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -288,10 +288,7 @@ public:
     virtual         ~ScInputWindow() override;
     virtual void    dispose() override;
 
-    virtual void    Paint( vcl::RenderContext& rRenderContext, const 
tools::Rectangle& rRect ) override;
     virtual void    PixelInvalidate(const tools::Rectangle* pRectangle) 
override;
-    virtual void    setPosSizePixel( tools::Long nX, tools::Long nY, 
tools::Long nWidth, tools::Long nHeight,
-                                     PosSizeFlags nFlags = PosSizeFlags::All ) 
override;
     virtual void    SetSizePixel( const Size& rNewSize ) override;
     virtual void    Resize() override;
     virtual void    Select() override;
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx 
b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 077e49235168..403b08a99b42 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -243,6 +243,9 @@ public:
     JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const 
OUString& rUIFile,
                       const css::uno::Reference<css::frame::XFrame>& rFrame,
                       sal_uInt64 nWindowId = 0);
+    /// used for formulabar
+    JSInstanceBuilder(vcl::Window* pParent, const OUString& rUIRoot, const 
OUString& rUIFile,
+                      sal_uInt64 nLOKWindowId);
 
     static std::unique_ptr<JSInstanceBuilder>
     CreateDialogBuilder(weld::Widget* pParent, const OUString& rUIRoot, const 
OUString& rUIFile);
@@ -256,6 +259,10 @@ public:
                                                                    sal_uInt64 
nLOKWindowId = 0);
     static std::unique_ptr<JSInstanceBuilder>
     CreatePopupBuilder(weld::Widget* pParent, const OUString& rUIRoot, const 
OUString& rUIFile);
+    static std::unique_ptr<JSInstanceBuilder> 
CreateFormulabarBuilder(vcl::Window* pParent,
+                                                                      const 
OUString& rUIRoot,
+                                                                      const 
OUString& rUIFile,
+                                                                      
sal_uInt64 nLOKWindowId);
 
     virtual ~JSInstanceBuilder() override;
     virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const 
OString& id) override;
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 408e7a9e53da..43fa054b3fd6 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -482,7 +482,8 @@ void JSDropTarget::fire_dragEnter(const 
css::datatransfer::dnd::DropTargetDragEn
 
 std::string JSInstanceBuilder::getMapIdFromWindowId() const
 {
-    if (m_sTypeOfJSON == "sidebar" || m_sTypeOfJSON == "notebookbar")
+    if (m_sTypeOfJSON == "sidebar" || m_sTypeOfJSON == "notebookbar"
+        || m_sTypeOfJSON == "formulabar")
         return std::to_string(m_nWindowId) + m_sTypeOfJSON;
     else
         return std::to_string(m_nWindowId);
@@ -588,6 +589,30 @@ JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, 
const OUString& rUIRo
     initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
 }
 
+// used for formulabar
+JSInstanceBuilder::JSInstanceBuilder(vcl::Window* pParent, const OUString& 
rUIRoot,
+                                     const OUString& rUIFile, sal_uInt64 
nLOKWindowId)
+    : SalInstanceBuilder(pParent, rUIRoot, rUIFile)
+    , m_nWindowId(nLOKWindowId)
+    , m_aParentDialog(nullptr)
+    , m_aContentWindow(nullptr)
+    , m_sTypeOfJSON("formulabar")
+    , m_bHasTopLevelDialog(false)
+    , m_bIsNotebookbar(false)
+    , m_aWindowToRelease(nullptr)
+{
+    vcl::Window* pRoot = m_xBuilder->get_widget_root();
+    m_aContentWindow = pParent;
+    if (pRoot && pRoot->GetParent())
+    {
+        m_aParentDialog = pRoot->GetParent()->GetParentWithLOKNotifier();
+        InsertWindowToMap(getMapIdFromWindowId());
+    }
+
+    initializeSender(GetNotifierWindow(), GetContentWindow(), GetTypeOfJSON());
+    sendFullUpdate();
+}
+
 std::unique_ptr<JSInstanceBuilder> 
JSInstanceBuilder::CreateDialogBuilder(weld::Widget* pParent,
                                                                           
const OUString& rUIRoot,
                                                                           
const OUString& rUIFile)
@@ -617,6 +642,13 @@ std::unique_ptr<JSInstanceBuilder> 
JSInstanceBuilder::CreatePopupBuilder(weld::W
     return std::make_unique<JSInstanceBuilder>(pParent, rUIRoot, rUIFile, 
true);
 }
 
+std::unique_ptr<JSInstanceBuilder>
+JSInstanceBuilder::CreateFormulabarBuilder(vcl::Window* pParent, const 
OUString& rUIRoot,
+                                           const OUString& rUIFile, sal_uInt64 
nLOKWindowId)
+{
+    return std::make_unique<JSInstanceBuilder>(pParent, rUIRoot, rUIFile, 
nLOKWindowId);
+}
+
 JSInstanceBuilder::~JSInstanceBuilder()
 {
     if (m_aWindowToRelease)
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 12c602160709..813939b12222 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -195,9 +195,14 @@ std::unique_ptr<weld::Builder> 
Application::CreateBuilder(weld::Widget* pParent,
 
 std::unique_ptr<weld::Builder> Application::CreateInterimBuilder(vcl::Window* 
pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 
nLOKWindowId)
 {
-    // Notebookbar sub controls
-    if (comphelper::LibreOfficeKit::isActive() && 
jsdialog::isInterimBuilderEnabledForNotebookbar(rUIFile))
-        return JSInstanceBuilder::CreateNotebookbarBuilder(pParent, 
AllSettings::GetUIRootDir(), rUIFile, 
css::uno::Reference<css::frame::XFrame>(), nLOKWindowId);
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        // Notebookbar sub controls
+        if (jsdialog::isInterimBuilderEnabledForNotebookbar(rUIFile))
+            return JSInstanceBuilder::CreateNotebookbarBuilder(pParent, 
AllSettings::GetUIRootDir(), rUIFile, 
css::uno::Reference<css::frame::XFrame>(), nLOKWindowId);
+        else if (rUIFile == u"modules/scalc/ui/inputbar.ui")
+            return JSInstanceBuilder::CreateFormulabarBuilder(pParent, 
AllSettings::GetUIRootDir(), rUIFile, nLOKWindowId);
+    }
 
     return ImplGetSVData()->mpDefInst->CreateInterimBuilder(pParent, 
AllSettings::GetUIRootDir(), rUIFile, bAllowCycleFocusOut, nLOKWindowId);
 }

Reply via email to