summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2022-07-29 09:56:51 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2022-08-30 13:08:39 +0200
commitdbeb697d62250e9429462c7f61b859893262a651 (patch)
treecda0cb7a6d7179971e2da8e174da3712d53a1767 /sfx2
parent4fb8c0d14cb2468f7336438004f699b9eb7e7e4a (diff)
tdf#149956 Rework toolbar image flipping
An unified code, covering both vcl and weld cases. For SidebarToolBox, the controller is created before items are inserted, so we listen for item insert event to set initially correct state. Change-Id: I3841f21883104b4d3f8541c97ec7fa5fc0bec575 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139022 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sidebar/ControllerFactory.hxx4
-rw-r--r--sfx2/inc/sidebar/SidebarToolBox.hxx1
-rw-r--r--sfx2/source/sidebar/ControllerFactory.cxx12
-rw-r--r--sfx2/source/sidebar/SidebarToolBox.cxx9
-rw-r--r--sfx2/source/toolbox/weldutils.cxx5
5 files changed, 30 insertions, 1 deletions
diff --git a/sfx2/inc/sidebar/ControllerFactory.hxx b/sfx2/inc/sidebar/ControllerFactory.hxx
index 8d45a2e3b1ed..c30cec61425b 100644
--- a/sfx2/inc/sidebar/ControllerFactory.hxx
+++ b/sfx2/inc/sidebar/ControllerFactory.hxx
@@ -40,6 +40,10 @@ namespace sfx2::sidebar {
class ControllerFactory
{
public:
+ static css::uno::Reference<css::lang::XComponent> CreateImageController(
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ const css::uno::Reference<css::awt::XWindow>& rxParentWindow);
+
static css::uno::Reference<css::frame::XToolbarController> CreateToolBoxController(
ToolBox* pToolBox,
const ToolBoxItemId nItemId,
diff --git a/sfx2/inc/sidebar/SidebarToolBox.hxx b/sfx2/inc/sidebar/SidebarToolBox.hxx
index acae7475e69a..f3c18c531455 100644
--- a/sfx2/inc/sidebar/SidebarToolBox.hxx
+++ b/sfx2/inc/sidebar/SidebarToolBox.hxx
@@ -54,6 +54,7 @@ public:
void InitToolBox(VclBuilder::stringmap& rMap);
protected:
+ css::uno::Reference<css::lang::XComponent> mxImageController;
typedef std::map<ToolBoxItemId, css::uno::Reference<css::frame::XToolbarController>> ControllerContainer;
ControllerContainer maControllers;
bool mbAreHandlersRegistered;
diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx
index d904b5260420..cc453c53cd7e 100644
--- a/sfx2/source/sidebar/ControllerFactory.cxx
+++ b/sfx2/source/sidebar/ControllerFactory.cxx
@@ -38,6 +38,18 @@ using namespace css::uno;
namespace sfx2::sidebar {
+Reference<lang::XComponent> ControllerFactory::CreateImageController(
+ const Reference<frame::XFrame>& rxFrame,
+ const Reference<awt::XWindow>& rxParentWindow)
+{
+ rtl::Reference xController(new framework::ImageOrientationController(
+ comphelper::getProcessComponentContext(), rxFrame, rxParentWindow,
+ vcl::CommandInfoProvider::GetModuleIdentifier(rxFrame)));
+
+ xController->update();
+ return xController;
+}
+
Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
ToolBox* pToolBox,
const ToolBoxItemId nItemId,
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx
index bb89d007bbb0..936fdbdd4ddc 100644
--- a/sfx2/source/sidebar/SidebarToolBox.cxx
+++ b/sfx2/source/sidebar/SidebarToolBox.cxx
@@ -67,6 +67,12 @@ SidebarToolBox::SidebarToolBox (vcl::Window* pParentWindow)
SetToolboxButtonSize(GetDefaultButtonSize());
SvtMiscOptions().AddListenerLink(LINK(this, SidebarToolBox, ChangedIconSizeHandler));
+ if (SfxViewFrame::Current())
+ {
+ auto xFrame(SfxViewFrame::Current()->GetFrame().GetFrameInterface());
+ auto xWidget(VCLUnoHelper::GetInterface(this));
+ mxImageController = sfx2::sidebar::ControllerFactory::CreateImageController(xFrame, xWidget);
+ }
#ifdef DEBUG
SetText(OUString("SidebarToolBox"));
@@ -91,6 +97,9 @@ void SidebarToolBox::dispose()
xComponent->dispose();
}
+ if (mxImageController)
+ mxImageController->dispose();
+
if (mbAreHandlersRegistered)
{
SetDropdownClickHdl(Link<ToolBox *, void>());
diff --git a/sfx2/source/toolbox/weldutils.cxx b/sfx2/source/toolbox/weldutils.cxx
index 25b173de633f..eff86b0b857f 100644
--- a/sfx2/source/toolbox/weldutils.cxx
+++ b/sfx2/source/toolbox/weldutils.cxx
@@ -13,7 +13,7 @@
#include <sfx2/weldutils.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/settings.hxx>
-#include <vcl/weld.hxx>
+#include <vcl/weldutils.hxx>
namespace
{
@@ -110,6 +110,8 @@ ToolbarUnoDispatcher::ToolbarUnoDispatcher(weld::Toolbar& rToolbar, weld::Builde
CreateController(sCommand);
}
+ rtl::Reference xWidget(new weld::TransportAsXWindow(m_pToolbar, m_pBuilder));
+ m_xImageController = sfx2::sidebar::ControllerFactory::CreateImageController(m_xFrame, xWidget);
m_aToolbarOptions.AddListenerLink(LINK(this, ToolbarUnoDispatcher, ChangedIconSizeHandler));
}
@@ -194,6 +196,7 @@ void ToolbarUnoDispatcher::dispose()
xComponent->dispose();
}
+ m_xImageController->dispose();
m_pToolbar->connect_clicked(Link<const OString&, void>());
m_pToolbar = nullptr;
m_pBuilder = nullptr;