include/vcl/EnumContext.hxx                                    |    1 
 officecfg/registry/data/org/openoffice/Office/UI/Factories.xcu |   14 
 officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu   |   49 +++
 officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs |    4 
 sfx2/source/sidebar/ResourceManager.cxx                        |    2 
 starmath/Library_sm.mk                                         |    2 
 starmath/UIConfig_smath.mk                                     |    1 
 starmath/source/SmElementsPanel.cxx                            |  105 ++++++
 starmath/source/SmElementsPanel.hxx                            |   59 +++
 starmath/source/SmPanelFactory.cxx                             |  131 ++++++++
 starmath/source/smdll.cxx                                      |    3 
 starmath/source/view.cxx                                       |   36 ++
 starmath/uiconfig/smath/menubar/menubar.xml                    |    1 
 starmath/uiconfig/smath/ui/sidebarelements_math.ui             |  154 
++++++++++
 starmath/util/sm.component                                     |    4 
 vcl/source/window/EnumContext.cxx                              |    1 
 16 files changed, 566 insertions(+), 1 deletion(-)

New commits:
commit 3524e4f7352993517ebdd514435378f6de0ca713
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Apr 25 18:24:43 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Apr 26 17:01:56 2022 +0200

    tdf#125931: Add Elements deck and Elements panel to Math's sidebar
    
    Change-Id: Ie04a5dc48de38f318f0ddb42efc42cea022dc62c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133393
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Factories.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/Factories.xcu
index c26b96ec287b..20cb7d0b52ac 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Factories.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Factories.xcu
@@ -146,6 +146,20 @@
           <value>org.libreoffice.comp.chart2.sidebar.ChartPanelFactory</value>
         </prop>
       </node>
+      <node oor:name="SmPanelFactory" oor:op="replace">
+        <prop oor:name="Type">
+          <value>toolpanel</value>
+        </prop>
+        <prop oor:name="Name">
+          <value>SmPanelFactory</value>
+        </prop>
+        <prop oor:name="Module">
+          <value></value>
+        </prop>
+        <prop oor:name="FactoryImplementation">
+          <value>org.libreoffice.comp.Math.sidebar.SmPanelFactory</value>
+        </prop>
+      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
index 9fc17ad9418f..41e11f78c61a 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Sidebar.xcu
@@ -295,6 +295,26 @@
         </prop>
       </node>
 
+      <node oor:name="ElementsDeck" oor:op="replace">
+        <prop oor:name="Title" oor:type="xs:string">
+          <value xml:lang="en-US">Elements</value>
+        </prop>
+        <prop oor:name="Id" oor:type="xs:string">
+          <value>ElementsDeck</value>
+        </prop>
+        <prop oor:name="IconURL" oor:type="xs:string">
+          
<value>private:graphicrepository/sfx2/res/symphony/sidebar-gallery-large.png</value>
+        </prop>
+        <prop oor:name="ContextList">
+          <value oor:separator=";">
+            Math, any, visible;
+          </value>
+        </prop>
+        <prop oor:name="OrderIndex" oor:type="xs:int">
+          <value>300</value>
+        </prop>
+      </node>
+
     </node>
     <node oor:name="PanelList">
 
@@ -739,6 +759,35 @@
         </prop>
       </node>
 
+      <node oor:name="MathElementsPanel" oor:op="replace">
+        <prop oor:name="Title" oor:type="xs:string">
+          <value xml:lang="en-US">Elements</value>
+        </prop>
+        <prop oor:name="TitleBarIsOptional" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
+        <prop oor:name="Id" oor:type="xs:string">
+          <value>MathElementsPanel</value>
+        </prop>
+        <prop oor:name="DeckId" oor:type="xs:string">
+          <value>ElementsDeck</value>
+        </prop>
+        <prop oor:name="ContextList">
+          <value oor:separator=";">
+            Math, any, visible;
+          </value>
+        </prop>
+        <prop oor:name="ImplementationURL" oor:type="xs:string">
+          
<value>private:resource/toolpanel/SmPanelFactory/MathElementsPanel</value>
+        </prop>
+        <prop oor:name="OrderIndex" oor:type="xs:int">
+          <value>100</value>
+        </prop>
+        <prop oor:name="WantsAWT" oor:type="xs:boolean">
+          <value>false</value>
+        </prop>
+      </node>
+
       <node oor:name="PosSizePropertyPanel" oor:op="replace">
         <prop oor:name="Title" oor:type="xs:string">
           <value xml:lang="en-US">Position and Size</value>
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk
index 2a7aeffcfb40..ba4c59fdfd75 100644
--- a/starmath/Library_sm.mk
+++ b/starmath/Library_sm.mk
@@ -67,6 +67,8 @@ $(eval $(call gb_Library_add_exception_objects,sm,\
         starmath/source/AccessibleSmElement \
         starmath/source/AccessibleSmElementsControl \
         starmath/source/ElementsDockingWindow \
+        starmath/source/SmElementsPanel \
+        starmath/source/SmPanelFactory \
         starmath/source/accessibility \
         starmath/source/action \
         starmath/source/caret \
diff --git a/starmath/UIConfig_smath.mk b/starmath/UIConfig_smath.mk
index 2a39af9e4a6d..45b12819731a 100644
--- a/starmath/UIConfig_smath.mk
+++ b/starmath/UIConfig_smath.mk
@@ -39,6 +39,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/smath,\
        starmath/uiconfig/smath/ui/mathwindow \
        starmath/uiconfig/smath/ui/printeroptions \
        starmath/uiconfig/smath/ui/savedefaultsdialog \
+       starmath/uiconfig/smath/ui/sidebarelements_math \
        starmath/uiconfig/smath/ui/smathsettings \
        starmath/uiconfig/smath/ui/spacingdialog \
        starmath/uiconfig/smath/ui/symdefinedialog \
diff --git a/starmath/source/SmElementsPanel.cxx 
b/starmath/source/SmElementsPanel.cxx
new file mode 100644
index 000000000000..a4c8d7c6d883
--- /dev/null
+++ b/starmath/source/SmElementsPanel.cxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+
+#include "SmElementsPanel.hxx"
+#include <starmath.hrc>
+#include <smmod.hxx>
+#include <strings.hrc>
+#include <view.hxx>
+
+namespace sm::sidebar
+{
+// static
+std::unique_ptr<PanelLayout> SmElementsPanel::Create(weld::Widget& rParent,
+                                                     const SfxBindings& 
rBindings)
+{
+    return std::make_unique<SmElementsPanel>(rParent, rBindings);
+}
+
+SmElementsPanel::SmElementsPanel(weld::Widget& rParent, const SfxBindings& 
rBindings)
+    : PanelLayout(&rParent, "MathElementsPanel", 
"modules/smath/ui/sidebarelements_math.ui")
+    , mrBindings(rBindings)
+    , mxCategoryList(m_xBuilder->weld_tree_view("categorylist"))
+    , mxElementsControl(std::make_unique<SmElementsControl>(
+          m_xBuilder->weld_scrolled_window("scrolledwindow", true)))
+    , mxElementsControlWin(
+          std::make_unique<weld::CustomWeld>(*m_xBuilder, "element_selector", 
*mxElementsControl))
+{
+    for (size_t i = 0; i < SmElementsControl::categoriesSize(); ++i)
+        
mxCategoryList->append_text(SmResId(std::get<0>(SmElementsControl::categories()[i])));
+
+    mxCategoryList->set_size_request(-1, mxCategoryList->get_height_rows(6));
+
+    mxCategoryList->connect_changed(LINK(this, SmElementsPanel, 
CategorySelectedHandle));
+    mxCategoryList->select_text(SmResId(RID_CATEGORY_UNARY_BINARY_OPERATORS));
+
+    mxElementsControl->setVerticalMode(false); // Sidebar currently can only 
dock to a side
+    mxElementsControl->setElementSetId(RID_CATEGORY_UNARY_BINARY_OPERATORS);
+    mxElementsControl->SetSelectHdl(LINK(this, SmElementsPanel, 
ElementClickHandler));
+}
+
+SmElementsPanel::~SmElementsPanel()
+{
+    mxElementsControlWin.reset();
+    mxElementsControl.reset();
+    mxCategoryList.reset();
+}
+
+IMPL_LINK(SmElementsPanel, CategorySelectedHandle, weld::TreeView&, rList, 
void)
+{
+    const OUString sSelected = rList.get_selected_text();
+    for (size_t i = 0; i < SmElementsControl::categoriesSize(); ++i)
+    {
+        const TranslateId& rCategoryId = 
std::get<0>(SmElementsControl::categories()[i]);
+        OUString aCurrentCategoryString = SmResId(rCategoryId);
+        if (aCurrentCategoryString == sSelected)
+        {
+            mxElementsControl->setElementSetId(rCategoryId);
+            if (SmViewShell* pViewSh = GetView())
+                
mxElementsControl->setSmSyntaxVersion(pViewSh->GetDoc()->GetSmSyntaxVersion());
+            return;
+        }
+    }
+}
+
+IMPL_LINK(SmElementsPanel, ElementClickHandler, SmElement&, rElement, void)
+{
+    if (SmViewShell* pViewSh = GetView())
+    {
+        std::unique_ptr<SfxStringItem> pInsertCommand
+            = std::make_unique<SfxStringItem>(SID_INSERTCOMMANDTEXT, 
rElement.getText());
+        pViewSh->GetViewFrame()->GetDispatcher()->ExecuteList(
+            SID_INSERTCOMMANDTEXT, SfxCallMode::RECORD, { pInsertCommand.get() 
});
+    }
+}
+
+SmViewShell* SmElementsPanel::GetView() const
+{
+    SfxViewShell* pView = 
mrBindings.GetDispatcher()->GetFrame()->GetViewShell();
+    return dynamic_cast<SmViewShell*>(pView);
+}
+
+} // end of namespace sm::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/starmath/source/SmElementsPanel.hxx 
b/starmath/source/SmElementsPanel.hxx
new file mode 100644
index 000000000000..4629b33af409
--- /dev/null
+++ b/starmath/source/SmElementsPanel.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <sal/config.h>
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/sidebar/SidebarModelUpdate.hxx>
+#include <sfx2/sidebar/PanelLayout.hxx>
+#include <vcl/customweld.hxx>
+#include <vcl/EnumContext.hxx>
+
+#include <ElementsDockingWindow.hxx>
+
+#include <memory>
+
+namespace sm::sidebar
+{
+class SmElementsPanel : public PanelLayout
+{
+public:
+    static std::unique_ptr<PanelLayout> Create(weld::Widget& rParent, const 
SfxBindings& rBindings);
+    SmElementsPanel(weld::Widget& rParent, const SfxBindings& rBindings);
+    ~SmElementsPanel();
+
+private:
+    DECL_LINK(CategorySelectedHandle, weld::TreeView&, void);
+    DECL_LINK(ElementClickHandler, SmElement&, void);
+
+    SmViewShell* GetView() const;
+
+    const SfxBindings& mrBindings;
+
+    std::unique_ptr<weld::TreeView> mxCategoryList;
+    std::unique_ptr<SmElementsControl> mxElementsControl;
+    std::unique_ptr<weld::CustomWeld> mxElementsControlWin;
+};
+
+} // end of namespace sm::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/starmath/source/SmPanelFactory.cxx 
b/starmath/source/SmPanelFactory.cxx
new file mode 100644
index 000000000000..593b2e4a14d6
--- /dev/null
+++ b/starmath/source/SmPanelFactory.cxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/ui/XUIElementFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <sfx2/sidebar/SidebarPanelBase.hxx>
+#include <vcl/weldutils.hxx>
+
+#include "SmElementsPanel.hxx"
+
+namespace
+{
+typedef comphelper::WeakComponentImplHelper<css::ui::XUIElementFactory, 
css::lang::XServiceInfo>
+    PanelFactoryInterfaceBase;
+
+class SmPanelFactory final : public PanelFactoryInterfaceBase
+{
+public:
+    SmPanelFactory() = default;
+
+    SmPanelFactory(const SmPanelFactory&) = delete;
+    const SmPanelFactory& operator=(const SmPanelFactory&) = delete;
+
+    // XUIElementFactory
+    css::uno::Reference<css::ui::XUIElement> SAL_CALL
+    createUIElement(const OUString& ResourceURL,
+                    const css::uno::Sequence<css::beans::PropertyValue>& 
Arguments) override;
+
+    // XServiceInfo
+    OUString SAL_CALL getImplementationName() override;
+    sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
+    css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+};
+
+css::uno::Reference<css::ui::XUIElement> SAL_CALL 
SmPanelFactory::createUIElement(
+    const OUString& ResourceURL, const 
css::uno::Sequence<css::beans::PropertyValue>& Arguments)
+{
+    try
+    {
+        const comphelper::NamedValueCollection aArguments(Arguments);
+        auto xFrame(aArguments.getOrDefault("Frame", 
css::uno::Reference<css::frame::XFrame>()));
+        auto xParentWindow(
+            aArguments.getOrDefault("ParentWindow", 
css::uno::Reference<css::awt::XWindow>()));
+        const sal_uInt64 nBindingsValue(aArguments.getOrDefault("SfxBindings", 
sal_uInt64(0)));
+        SfxBindings* pBindings = 
reinterpret_cast<SfxBindings*>(nBindingsValue);
+
+        weld::Widget* pParent(nullptr);
+        if (auto pTunnel = 
dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
+            pParent = pTunnel->getWidget();
+
+        if (!pParent)
+            throw css::uno::RuntimeException("SmPanelFactory::createUIElement: 
no ParentWindow");
+        if (!xFrame)
+            throw css::uno::RuntimeException("SmPanelFactory::createUIElement: 
no Frame");
+        if (!pBindings)
+            throw css::uno::RuntimeException("SmPanelFactory::createUIElement: 
no SfxBindings");
+
+        std::unique_ptr<PanelLayout> pPanel;
+        css::ui::LayoutSize aLayoutSize{ -1, -1, -1 };
+        if (ResourceURL.endsWith("/MathElementsPanel"))
+        {
+            pPanel = sm::sidebar::SmElementsPanel::Create(*pParent, 
*pBindings);
+            aLayoutSize = { 300, -1, -1 };
+        }
+
+        if (pPanel)
+            return sfx2::sidebar::SidebarPanelBase::Create(ResourceURL, 
xFrame, std::move(pPanel),
+                                                           aLayoutSize);
+    }
+    catch (const css::uno::RuntimeException&)
+    {
+        throw;
+    }
+    catch (const css::uno::Exception&)
+    {
+        css::uno::Any anyEx = cppu::getCaughtException();
+        throw 
css::lang::WrappedTargetRuntimeException("SmPanelFactory::createUIElement 
exception",
+                                                       nullptr, anyEx);
+    }
+
+    return {};
+}
+
+OUString SmPanelFactory::getImplementationName()
+{
+    return "org.libreoffice.comp.Math.sidebar.SmPanelFactory";
+}
+
+sal_Bool SmPanelFactory::supportsService(OUString const& ServiceName)
+{
+    return cppu::supportsService(this, ServiceName);
+}
+
+css::uno::Sequence<OUString> SmPanelFactory::getSupportedServiceNames()
+{
+    return { "com.sun.star.ui.UIElementFactory" };
+}
+
+} // end of unnamed namespace
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+org_libreoffice_comp_Math_sidebar_SmPanelFactory(css::uno::XComponentContext*,
+                                                 
css::uno::Sequence<css::uno::Any> const&)
+{
+    return cppu::acquire(new SmPanelFactory);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/starmath/uiconfig/smath/ui/sidebarelements_math.ui 
b/starmath/uiconfig/smath/ui/sidebarelements_math.ui
new file mode 100644
index 000000000000..c645e7f8d349
--- /dev/null
+++ b/starmath/uiconfig/smath/ui/sidebarelements_math.ui
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.1 -->
+<interface domain="svx">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <!-- n-columns=1 n-rows=1 -->
+  <object class="GtkGrid" id="MathElementsPanel">
+    <property name="visible">True</property>
+    <property name="can-focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <property name="border-width">6</property>
+    <child>
+      <!-- n-columns=1 n-rows=1 -->
+      <object class="GtkGrid" id="container">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="row-spacing">3</property>
+        <property name="column-spacing">6</property>
+        <child>
+          <object class="GtkPaned" id="splitter">
+            <property name="visible">True</property>
+            <property name="can-focus">True</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="orientation">vertical</property>
+            <property name="wide-handle">True</property>
+            <child>
+              <!-- n-columns=1 n-rows=1 -->
+              <object class="GtkGrid">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <child>
+                  <object class="GtkScrolledWindow">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="shadow-type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="categorylist">
+                        <property name="visible">True</property>
+                        <property name="can-focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="model">liststore1</property>
+                        <property name="headers-visible">False</property>
+                        <property name="search-column">0</property>
+                        <property name="show-expanders">False</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" 
id="treeview-selection2"/>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" 
id="treeviewcolumn0">
+                            <child>
+                              <object class="GtkCellRendererText" 
id="cellrenderertext1"/>
+                              <attributes>
+                                <attribute name="text">1</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="resize">False</property>
+                <property name="shrink">True</property>
+              </packing>
+            </child>
+            <child>
+              <!-- n-columns=1 n-rows=1 -->
+              <object class="GtkGrid">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="row-spacing">6</property>
+                <child>
+                  <!-- n-columns=1 n-rows=1 -->
+                  <object class="GtkGrid">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <child>
+                      <object class="GtkScrolledWindow" id="scrolledwindow">
+                        <property name="visible">True</property>
+                        <property name="can-focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="shadow-type">in</property>
+                        <child>
+                          <object class="GtkViewport">
+                            <property name="visible">True</property>
+                            <property name="can-focus">False</property>
+                            <child>
+                              <object class="GtkDrawingArea" 
id="element_selector">
+                                <property name="visible">True</property>
+                                <property name="can-focus">True</property>
+                                <property name="events">GDK_BUTTON_MOTION_MASK 
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | 
GDK_KEY_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | 
GDK_STRUCTURE_MASK | GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK</property>
+                                <property name="hexpand">True</property>
+                                <property name="vexpand">True</property>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left-attach">0</property>
+                        <property name="top-attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="resize">True</property>
+                <property name="shrink">True</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left-attach">0</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="left-attach">0</property>
+        <property name="top-attach">0</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/starmath/util/sm.component b/starmath/util/sm.component
index 4f354df4acb0..2b84a17c429c 100644
--- a/starmath/util/sm.component
+++ b/starmath/util/sm.component
@@ -63,4 +63,8 @@
         constructor="com_sun_star_comp_Math_MathTypeFilter_get_implementation">
     <service name="com.sun.star.document.ImportFilter"/>
   </implementation>
+  <implementation name="org.libreoffice.comp.Math.sidebar.SmPanelFactory"
+        constructor="org_libreoffice_comp_Math_sidebar_SmPanelFactory">
+    <service name="com.sun.star.ui.UIElementFactory"/>
+  </implementation>
 </component>
commit 9098d5a2e43b156648f187559790547d1b536896
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Apr 22 20:25:43 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Apr 26 17:01:41 2022 +0200

    tdf#125931: Enable sidebar in Math
    
    No panels yet, only one default deck (PropertyDeck). It is needed
    to have the uniform default deck like in all other modules (see
    commit c09f59eb6173a4a53a2d40ed80aebed18e3882ac); the panels for
    formula properties might appear later.
    
    Change-Id: If1785dc780111fe496638418f43e7b90a250ffce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133334
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/include/vcl/EnumContext.hxx b/include/vcl/EnumContext.hxx
index dec5711b6ba5..9d82e72adc9d 100644
--- a/include/vcl/EnumContext.hxx
+++ b/include/vcl/EnumContext.hxx
@@ -83,6 +83,7 @@ public:
         Grid,
         HandoutPage,
         MasterPage,
+        Math,
         Media,
         MultiObject,
         NotesPage,
diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs 
b/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
index 10e57ac4fb64..4b5d13b63c5f 100644
--- a/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/UI/Sidebar.xcs
@@ -87,6 +87,7 @@
                  com.sun.star.presentation.PresentationDocument
                  com.sun.star.drawing.DrawingDocument
                  com.sun.star.chart2.ChartDocument
+                 com.sun.star.formula.FormulaProperties
 
              Recognized shortcuts:
                  Writer
@@ -94,6 +95,7 @@
                  Impress
                  Draw
                  Chart
+                 Math
 
              Shortcuts for multiple applications:
                  DrawImpress
@@ -109,7 +111,7 @@
           2  Context name
               Know context names are 3DObject, Annotation, Auditing, Axis, 
Cell, Chart, ChartElements, Draw,
               DrawFontwork, DrawLine, DrawPage, DrawText, EditCell, ErrorBar, 
Form, Frame, Graphic, Grid,
-              HandoutPage, MasterPage, Media, MultiObject, NotesPage, OLE, 
OutlineText, Pivot, Printpreview,
+              HandoutPage, MasterPage, Math, Media, MultiObject, NotesPage, 
OLE, OutlineText, Pivot, Printpreview,
               Series, SlidesorterPage, Table, Text, TextObject, Trendline, 
Sparkline
 
              Special values:
diff --git a/sfx2/source/sidebar/ResourceManager.cxx 
b/sfx2/source/sidebar/ResourceManager.cxx
index 320faf48fe5e..1906e733db01 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -557,6 +557,8 @@ void ResourceManager::ReadContextList (
                 
aApplications.push_back(vcl::EnumContext::Application::Impress);
             else if (sApplicationName == "Chart")
                 aApplications.push_back(vcl::EnumContext::Application::Chart);
+            else if (sApplicationName == "Math")
+                
aApplications.push_back(vcl::EnumContext::Application::Formula);
             else if (sApplicationName == "DrawImpress")
             {
                 // A special case among the special names:  it is
diff --git a/starmath/source/smdll.cxx b/starmath/source/smdll.cxx
index 7ef93bfa0f3c..f10e9d9db3f0 100644
--- a/starmath/source/smdll.cxx
+++ b/starmath/source/smdll.cxx
@@ -25,6 +25,7 @@
 #include <svx/zoomsliderctrl.hxx>
 #include <sfx2/docfac.hxx>
 #include <sfx2/app.hxx>
+#include <sfx2/sidebar/SidebarChildWindow.hxx>
 
 #include <smdll.hxx>
 #include <smmod.hxx>
@@ -69,6 +70,8 @@ namespace
         SvxModifyControl::RegisterControl(SID_TEXTSTATUS, pModule);
         XmlSecStatusBarControl::RegisterControl(SID_SIGNATURE, pModule);
 
+        sfx2::sidebar::SidebarChildWindow::RegisterChildWindow(false, pModule);
+
         SmCmdBoxWrapper::RegisterChildWindow(true);
         SmElementsDockingWindowWrapper::RegisterChildWindow(true);
     }
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index cea8a3fd8abf..360c96390f95 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -42,6 +42,8 @@
 #include <sfx2/objface.hxx>
 #include <sfx2/printer.hxx>
 #include <sfx2/request.hxx>
+#include <sfx2/sfxbasecontroller.hxx>
+#include <sfx2/sidebar/SidebarChildWindow.hxx>
 #include <sfx2/viewfac.hxx>
 #include <svl/eitem.hxx>
 #include <svl/itemset.hxx>
@@ -50,6 +52,7 @@
 #include <vcl/transfer.hxx>
 #include <svtools/colorcfg.hxx>
 #include <svl/whiter.hxx>
+#include <svx/sidebar/SelectionChangeHandler.hxx>
 #include <svx/zoomslideritem.hxx>
 #include <editeng/editeng.hxx>
 #include <editeng/editview.hxx>
@@ -1079,6 +1082,8 @@ void SmViewShell::InitInterface_Impl()
     
GetStaticInterface()->RegisterChildWindow(SmCmdBoxWrapper::GetChildWindowId());
     
GetStaticInterface()->RegisterChildWindow(SmElementsDockingWindowWrapper::GetChildWindowId());
     
GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
+
+    
GetStaticInterface()->RegisterChildWindow(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
 }
 
 SFX_IMPL_NAMED_VIEWFACTORY(SmViewShell, "Default")
@@ -2089,6 +2094,36 @@ void SmViewShell::GetState(SfxItemSet &rSet)
     }
 }
 
+namespace
+{
+class SmController : public SfxBaseController
+{
+public:
+    SmController(SfxViewShell& rViewShell)
+        : SfxBaseController(&rViewShell)
+        , mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler(
+              GetContextName, this, vcl::EnumContext::Context::Math))
+    {
+        mpSelectionChangeHandler->Connect();
+        rViewShell.SetContextName(GetContextName());
+    }
+    ~SmController() { mpSelectionChangeHandler->Disconnect(); }
+
+    // css::frame::XController
+    void SAL_CALL attachFrame(const css::uno::Reference<css::frame::XFrame>& 
xFrame) override
+    {
+        SfxBaseController::attachFrame(xFrame);
+
+        mpSelectionChangeHandler->selectionChanged({}); // Installs the 
correct context
+    }
+
+private:
+    static OUString GetContextName() { return "Math"; } // Static constant for 
now
+
+    rtl::Reference<svx::sidebar::SelectionChangeHandler> 
mpSelectionChangeHandler;
+};
+}
+
 SmViewShell::SmViewShell(SfxViewFrame *pFrame_, SfxViewShell *)
     : SfxViewShell(pFrame_, SfxViewShellFlags::HAS_PRINTOPTIONS)
     , mxGraphicWindow(VclPtr<SmGraphicWindow>::Create(*this))
@@ -2100,6 +2135,7 @@ SmViewShell::SmViewShell(SfxViewFrame *pFrame_, 
SfxViewShell *)
     SetWindow(mxGraphicWindow.get());
     SfxShell::SetName("SmView");
     SfxShell::SetUndoManager( &GetDoc()->GetEditEngine().GetUndoManager() );
+    SetController(new SmController(*this));
 }
 
 SmViewShell::~SmViewShell()
diff --git a/starmath/uiconfig/smath/menubar/menubar.xml 
b/starmath/uiconfig/smath/menubar/menubar.xml
index 04ca77df844b..434d4deeb970 100644
--- a/starmath/uiconfig/smath/menubar/menubar.xml
+++ b/starmath/uiconfig/smath/menubar/menubar.xml
@@ -87,6 +87,7 @@
       <menu:menuitem menu:id=".uno:AvailableToolbars"/>
       <menu:menuitem menu:id=".uno:StatusBarVisible"/>
       <menu:menuseparator/>
+      <menu:menuitem menu:id=".uno:Sidebar"/>
       <menu:menuitem menu:id=".uno:ElementsDockingWindow"/>
       <menu:menuseparator/>
       <menu:menuitem menu:id=".uno:FullScreen"/>
diff --git a/vcl/source/window/EnumContext.cxx 
b/vcl/source/window/EnumContext.cxx
index 2eb23e591a5a..6ca075eb6943 100644
--- a/vcl/source/window/EnumContext.cxx
+++ b/vcl/source/window/EnumContext.cxx
@@ -171,6 +171,7 @@ void EnumContext::ProvideContextContainers()
     AddEntry("Grid", Context::Grid);
     AddEntry("HandoutPage", Context::HandoutPage);
     AddEntry("MasterPage", Context::MasterPage);
+    AddEntry("Math", Context::Math);
     AddEntry("Media", Context::Media);
     AddEntry("MultiObject", Context::MultiObject);
     AddEntry("NotesPage", Context::NotesPage);

Reply via email to