summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-06-30 06:09:23 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-07-28 07:37:31 +0200
commit30e08c83e502562966351f4236e9dd9230ffa435 (patch)
treec30f96ce2290e404f10e186f0229334b287544a7
parent2fc16dc84d0b1b1bd7978a30e1b79ff3100fefdf (diff)
lok: Enable sidebar in Math
Change-Id: I1554a924eef0bfcaffa893057a37ef45321a0cf7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137246 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--desktop/source/lib/init.cxx8
-rw-r--r--include/sfx2/lokcomponenthelpers.hxx4
-rw-r--r--include/sfx2/sidebar/SidebarController.hxx2
-rw-r--r--sc/source/ui/drawfunc/chartsh.cxx12
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx6
-rw-r--r--sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx8
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx5
-rw-r--r--sfx2/source/view/lokstarmathhelper.cxx9
-rw-r--r--starmath/source/view.cxx39
-rw-r--r--sw/source/uibase/shells/olesh.cxx12
10 files changed, 79 insertions, 26 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 029e8b72c667..c0f129fef72f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4345,7 +4345,13 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
aChartDispatcher->dispatch(aCommandURL, comphelper::containerToSequence(aPropertyValuesVector));
return;
}
- else if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers.count(nView))
+ if (LokStarMathHelper aMathHelper(SfxViewShell::Current());
+ aMathHelper.GetGraphicWindow() && aCommand != ".uno:Save")
+ {
+ aMathHelper.Dispatch(aCommand, comphelper::containerToSequence(aPropertyValuesVector));
+ return;
+ }
+ if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers.count(nView))
{
bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector),
new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandlers[nView]));
diff --git a/include/sfx2/lokcomponenthelpers.hxx b/include/sfx2/lokcomponenthelpers.hxx
index 6a3d964689b4..02e8750ca381 100644
--- a/include/sfx2/lokcomponenthelpers.hxx
+++ b/include/sfx2/lokcomponenthelpers.hxx
@@ -15,8 +15,10 @@
#include <vcl/vclptr.hxx>
#include <vcl/window.hxx>
+namespace com::sun::star::beans { struct PropertyValue; }
namespace com::sun::star::frame { class XController; }
namespace com::sun::star::frame { class XDispatch; }
+namespace com::sun::star::uno { template<class E> class Sequence; }
class SfxViewShell;
class VirtualDevice;
@@ -72,6 +74,8 @@ public:
vcl::Window* GetGraphicWindow();
vcl::Window* GetWidgetWindow();
+ void Dispatch(const OUString& cmd, const css::uno::Sequence<css::beans::PropertyValue>& rArguments);
+
bool postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier,
double fScaleX = 1.0, double fScaleY = 1.0);
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index 8d8dcf215527..e996c853c5b0 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -170,7 +170,7 @@ public:
void SyncUpdate();
- bool hasChartContextCurrently() const;
+ bool hasChartOrMathContextCurrently() const;
static SidebarController* GetSidebarControllerForView(const SfxViewShell* pViewShell);
diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx
index ac54c435eeea..e6378a5fa9cb 100644
--- a/sc/source/ui/drawfunc/chartsh.cxx
+++ b/sc/source/ui/drawfunc/chartsh.cxx
@@ -42,11 +42,11 @@ namespace drawing = com::sun::star::drawing;
namespace {
-bool inChartContext(const ScTabViewShell* pViewShell)
+bool inChartOrMathContext(const ScTabViewShell* pViewShell)
{
SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(pViewShell);
if (pSidebar)
- return pSidebar->hasChartContextCurrently();
+ return pSidebar->hasChartOrMathContextCurrently();
return false;
}
@@ -66,11 +66,11 @@ void ScChartShell::InitInterface_Impl()
void ScChartShell::Activate(bool bMDI)
{
- if(!inChartContext(GetViewData().GetViewShell()))
+ if(!inChartOrMathContext(GetViewData().GetViewShell()))
ScDrawShell::Activate(bMDI);
else
{
- // Avoid context changes for chart during activation / deactivation.
+ // Avoid context changes for chart/math during activation / deactivation.
const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
SfxShell::Activate(bMDI);
@@ -81,11 +81,11 @@ void ScChartShell::Activate(bool bMDI)
void ScChartShell::Deactivate(bool bMDI)
{
- if(!inChartContext(GetViewData().GetViewShell()))
+ if(!inChartOrMathContext(GetViewData().GetViewShell()))
ScDrawShell::Deactivate(bMDI);
else
{
- // Avoid context changes for chart during activation / deactivation.
+ // Avoid context changes for chart/math during activation / deactivation.
const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
SfxShell::Deactivate(bMDI);
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 94db6ca12a13..9bd541a04d03 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -91,11 +91,11 @@ using namespace sfx2::sidebar;
namespace {
-bool inChartContext(const ScTabViewShell* pViewShell)
+bool inChartOrMathContext(const ScTabViewShell* pViewShell)
{
SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(pViewShell);
if (pSidebar)
- return pSidebar->hasChartContextCurrently();
+ return pSidebar->hasChartOrMathContextCurrently();
return false;
}
@@ -218,7 +218,7 @@ void ScTabViewShell::Activate(bool bMDI)
// don't call CheckSelectionTransfer here - activating a view should not change the
// primary selection (may be happening just because the mouse was moved over the window)
- if (!inChartContext(this))
+ if (!inChartOrMathContext(this))
{
ContextChangeEventMultiplexer::NotifyContextChange(
GetController(),
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
index af5bd5791ba4..4de3e6a1c095 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
@@ -74,7 +74,7 @@ namespace sd::slidesorter {
namespace {
-bool inChartContext(const sd::View* pView)
+bool inChartOrMathContext(const sd::View* pView)
{
if (!pView)
return false;
@@ -82,7 +82,7 @@ bool inChartContext(const sd::View* pView)
SfxViewShell* pViewShell = pView->GetSfxViewShell();
SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(pViewShell);
if (pSidebar)
- return pSidebar->hasChartContextCurrently();
+ return pSidebar->hasChartOrMathContextCurrently();
return false;
}
@@ -459,9 +459,9 @@ void SlideSorterViewShell::ArrangeGUIElements()
void SlideSorterViewShell::Activate (bool bIsMDIActivate)
{
- if(inChartContext(GetView()))
+ if(inChartOrMathContext(GetView()))
{
- // Avoid context changes for chart during activation / deactivation.
+ // Avoid context changes for chart/math during activation / deactivation.
const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
ViewShell::Activate(bIsMDIActivate);
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 0bd71db0240d..6909f5c19d62 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -1609,9 +1609,10 @@ void SidebarController::saveDeckState()
}
}
-bool SidebarController::hasChartContextCurrently() const
+bool SidebarController::hasChartOrMathContextCurrently() const
{
- return GetCurrentContext().msApplication == "com.sun.star.chart2.ChartDocument";
+ return GetCurrentContext().msApplication == "com.sun.star.chart2.ChartDocument"
+ || GetCurrentContext().msApplication == "com.sun.star.formula.FormulaProperties";
}
sfx2::sidebar::SidebarController* SidebarController::GetSidebarControllerForView(const SfxViewShell* pViewShell)
diff --git a/sfx2/source/view/lokstarmathhelper.cxx b/sfx2/source/view/lokstarmathhelper.cxx
index 9df48759528d..9a704683aaec 100644
--- a/sfx2/source/view/lokstarmathhelper.cxx
+++ b/sfx2/source/view/lokstarmathhelper.cxx
@@ -13,6 +13,7 @@
#include <sfx2/lokcomponenthelpers.hxx>
#include <sfx2/lokhelper.hxx>
+#include <comphelper/dispatchcommand.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/fract.hxx>
#include <vcl/layout.hxx>
@@ -43,6 +44,14 @@ css::uno::Reference<css::frame::XController>& LokStarMathHelper::GetXController(
return mxController;
}
+void LokStarMathHelper::Dispatch(const OUString& cmd,
+ const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
+{
+ if (const css::uno::Reference<css::frame::XController>& xController = GetXController())
+ if (const css::uno::Reference<css::frame::XFrame> xFrame = xController->getFrame())
+ comphelper::dispatchCommand(cmd, xFrame, rArguments);
+}
+
namespace
{
// Find a child SmGraphicWindow*
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index e2b60cb9c6bd..56896a030572 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <comphelper/lok.hxx>
@@ -44,6 +45,7 @@
#include <sfx2/request.hxx>
#include <sfx2/sfxbasecontroller.hxx>
#include <sfx2/sidebar/SidebarChildWindow.hxx>
+#include <sfx2/sidebar/SidebarController.hxx>
#include <sfx2/viewfac.hxx>
#include <svl/eitem.hxx>
#include <svl/itemset.hxx>
@@ -2097,6 +2099,29 @@ 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:
@@ -2105,17 +2130,25 @@ public:
, mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler(
GetContextName, this, vcl::EnumContext::Context::Math))
{
- mpSelectionChangeHandler->Connect();
rViewShell.SetContextName(GetContextName());
}
- ~SmController() { mpSelectionChangeHandler->Disconnect(); }
+ // No need to call mpSelectionChangeHandler->Disconnect() unless SmController implements XSelectionSupplier
+ // ~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
+ // No need to call mpSelectionChangeHandler->Connect() unless SmController implements XSelectionSupplier
+ if (auto xSidebar = getSidebarFromModel(getModel()))
+ {
+ auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
+ assert(pSidebar);
+ sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this);
+ pSidebar->updateModel(getModel());
+ mpSelectionChangeHandler->selectionChanged({}); // Installs the correct context
+ }
}
private:
diff --git a/sw/source/uibase/shells/olesh.cxx b/sw/source/uibase/shells/olesh.cxx
index acddd3eb6975..28e8e153eeb1 100644
--- a/sw/source/uibase/shells/olesh.cxx
+++ b/sw/source/uibase/shells/olesh.cxx
@@ -34,11 +34,11 @@ using namespace sfx2::sidebar;
namespace {
-bool inChartContext(const SwView& rViewShell)
+bool inChartOrMathContext(const SwView& rViewShell)
{
SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(&rViewShell);
if (pSidebar)
- return pSidebar->hasChartContextCurrently();
+ return pSidebar->hasChartOrMathContextCurrently();
return false;
}
@@ -56,11 +56,11 @@ void SwOleShell::InitInterface_Impl()
void SwOleShell::Activate(bool bMDI)
{
- if(!inChartContext(GetView()))
+ if(!inChartOrMathContext(GetView()))
SwFrameShell::Activate(bMDI);
else
{
- // Avoid context changes for chart during activation / deactivation.
+ // Avoid context changes for chart/math during activation / deactivation.
const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
SwFrameShell::Activate(bMDI);
@@ -71,11 +71,11 @@ void SwOleShell::Activate(bool bMDI)
void SwOleShell::Deactivate(bool bMDI)
{
- if(!inChartContext(GetView()))
+ if(!inChartOrMathContext(GetView()))
SwFrameShell::Deactivate(bMDI);
else
{
- // Avoid context changes for chart during activation / deactivation.
+ // Avoid context changes for chart/math during activation / deactivation.
const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
SwFrameShell::Deactivate(bMDI);