starmath/source/view.cxx |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

New commits:
commit a0ab053c9f7645ff10a1ab69858a30bb3bb4857c
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Sep 27 10:48:21 2022 +0300
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Jul 6 14:21:00 2023 +0200

    lok: Register sidebar for frame explicitly
    
    For some reason, it is needed in 22.05 (unlike master). Without this,
    sidebar sometimes isn't shown in inline edit mode.
    
    Change-Id: Ie225ff0676786e9164e8640c6e159efb8aebf241
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140640
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154022
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    (cherry picked from commit 8a1f78dab16e3b27752b76e9013ec2249c894dbc)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154113
    Tested-by: Jenkins

diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index ea802231b6a5..d056e4c86ee7 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -2149,6 +2149,24 @@ void SmViewShell::GetState(SfxItemSet &rSet)
 
 namespace
 {
+css::uno::Reference<css::ui::XSidebar>
+getSidebarFromModel(const css::uno::Reference<css::frame::XModel>& xModel)
+{
+    css::uno::Reference<css::container::XChild> xChild(xModel, 
css::uno::UNO_QUERY);
+    if (!xChild.is())
+        return nullptr;
+    css::uno::Reference<css::frame::XModel> xParent(xChild->getParent(), 
css::uno::UNO_QUERY);
+    if (!xParent.is())
+        return nullptr;
+    css::uno::Reference<css::frame::XController2> 
xController(xParent->getCurrentController(),
+                                                              
css::uno::UNO_QUERY);
+    if (!xController.is())
+        return nullptr;
+    css::uno::Reference<css::ui::XSidebarProvider> xSidebarProvider = 
xController->getSidebar();
+    if (!xSidebarProvider.is())
+        return nullptr;
+    return xSidebarProvider->getSidebar();
+}
 class SmController : public SfxBaseController
 {
 public:
@@ -2168,7 +2186,19 @@ public:
         SfxBaseController::attachFrame(xFrame);
 
         if (comphelper::LibreOfficeKit::isActive())
+        {
             CopyLokViewCallbackFromFrameCreator();
+            // In lok mode, DocumentHolder::ShowUI is not called on OLE 
in-place activation,
+            // because respective code is skipped in 
OCommonEmbeddedObject::SwitchStateTo_Impl,
+            // so sidebar controller does not get registered properly; do it 
here
+            if (auto xSidebar = getSidebarFromModel(getModel()))
+            {
+                auto pSidebar = 
dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
+                assert(pSidebar);
+                pSidebar->registerSidebarForFrame(this);
+                pSidebar->updateModel(getModel());
+            }
+        }
 
         // No need to call mpSelectionChangeHandler->Connect() unless 
SmController implements XSelectionSupplier
         mpSelectionChangeHandler->selectionChanged({}); // Installs the 
correct context

Reply via email to