tdf#150940: Store frame reference in the panel

It is needed to properly dispatch the commands in case of embedded
objects, otherwise they are dispatched to the top-level frame.

Change-Id: Ia5fadf7c35bded75f1ca20a682dc6c9f14548990
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143693
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2022-12-06 11:22:47 +03:00
parent e0066326f7
commit 834f49b7e3
3 changed files with 14 additions and 7 deletions

View File

@@ -83,7 +83,7 @@ css::uno::Reference<css::ui::XUIElement> SAL_CALL SmPanelFactory::createUIElemen
css::ui::LayoutSize aLayoutSize{ -1, -1, -1 }; css::ui::LayoutSize aLayoutSize{ -1, -1, -1 };
if (ResourceURL.endsWith("/MathPropertiesPanel")) if (ResourceURL.endsWith("/MathPropertiesPanel"))
{ {
pPanel = sm::sidebar::SmPropertiesPanel::Create(*pParent); pPanel = sm::sidebar::SmPropertiesPanel::Create(*pParent, xFrame);
} }
else if (ResourceURL.endsWith("/MathElementsPanel")) else if (ResourceURL.endsWith("/MathElementsPanel"))
{ {

View File

@@ -32,13 +32,17 @@
namespace sm::sidebar namespace sm::sidebar
{ {
// static // static
std::unique_ptr<PanelLayout> SmPropertiesPanel::Create(weld::Widget& rParent) std::unique_ptr<PanelLayout>
SmPropertiesPanel::Create(weld::Widget& rParent,
const css::uno::Reference<css::frame::XFrame>& xFrame)
{ {
return std::make_unique<SmPropertiesPanel>(rParent); return std::make_unique<SmPropertiesPanel>(rParent, xFrame);
} }
SmPropertiesPanel::SmPropertiesPanel(weld::Widget& rParent) SmPropertiesPanel::SmPropertiesPanel(weld::Widget& rParent,
const css::uno::Reference<css::frame::XFrame>& xFrame)
: PanelLayout(&rParent, "MathPropertiesPanel", "modules/smath/ui/sidebarproperties_math.ui") : PanelLayout(&rParent, "MathPropertiesPanel", "modules/smath/ui/sidebarproperties_math.ui")
, mxFrame(xFrame)
, mpFormatFontsButton(m_xBuilder->weld_button("btnFormatFonts")) , mpFormatFontsButton(m_xBuilder->weld_button("btnFormatFonts"))
, mpFormatFontSizeButton(m_xBuilder->weld_button("btnFormatFontSize")) , mpFormatFontSizeButton(m_xBuilder->weld_button("btnFormatFontSize"))
, mpFormatSpacingButton(m_xBuilder->weld_button("btnFormatSpacing")) , mpFormatSpacingButton(m_xBuilder->weld_button("btnFormatSpacing"))
@@ -80,7 +84,7 @@ SmPropertiesPanel::~SmPropertiesPanel()
IMPL_LINK(SmPropertiesPanel, ButtonClickHandler, weld::Button&, rButton, void) IMPL_LINK(SmPropertiesPanel, ButtonClickHandler, weld::Button&, rButton, void)
{ {
if (OUString command = maButtonCommands[&rButton]; !command.isEmpty()) if (OUString command = maButtonCommands[&rButton]; !command.isEmpty())
comphelper::dispatchCommand(command, {}); comphelper::dispatchCommand(command, mxFrame, {});
} }
} // end of namespace sm::sidebar } // end of namespace sm::sidebar

View File

@@ -31,13 +31,16 @@ namespace sm::sidebar
class SmPropertiesPanel : public PanelLayout class SmPropertiesPanel : public PanelLayout
{ {
public: public:
static std::unique_ptr<PanelLayout> Create(weld::Widget& rParent); static std::unique_ptr<PanelLayout>
SmPropertiesPanel(weld::Widget& rParent); Create(weld::Widget& rParent, const css::uno::Reference<css::frame::XFrame>& xFrame);
SmPropertiesPanel(weld::Widget& rParent, const css::uno::Reference<css::frame::XFrame>& xFrame);
~SmPropertiesPanel(); ~SmPropertiesPanel();
private: private:
DECL_LINK(ButtonClickHandler, weld::Button&, void); DECL_LINK(ButtonClickHandler, weld::Button&, void);
css::uno::Reference<css::frame::XFrame> mxFrame;
std::unique_ptr<weld::Button> mpFormatFontsButton; std::unique_ptr<weld::Button> mpFormatFontsButton;
std::unique_ptr<weld::Button> mpFormatFontSizeButton; std::unique_ptr<weld::Button> mpFormatFontSizeButton;
std::unique_ptr<weld::Button> mpFormatSpacingButton; std::unique_ptr<weld::Button> mpFormatSpacingButton;