diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-04-27 15:06:03 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-06-05 07:41:14 +0200 |
commit | 8672f95ab410a42667fc8655bfc42f583d62e492 (patch) | |
tree | 75e1643f8c571ec12ea0988bffdb814c764d4999 /starmath | |
parent | d5690e308acb1e2e194e6e96dfcb76d35fabca22 (diff) |
tdf#125931: add Properties panel to Math's Properties deck
For now, it only contains buttons opening the dialogs accessible
from Format menu. This is enough for the initial implementation,
and should later be changed to individual controls allowing to
set the formula properties directly.
Change-Id: Ia0e52915198ddb2648d13d577d55b367f178b1ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133508
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135401
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/Library_sm.mk | 1 | ||||
-rw-r--r-- | starmath/UIConfig_smath.mk | 1 | ||||
-rw-r--r-- | starmath/source/SmPanelFactory.cxx | 7 | ||||
-rw-r--r-- | starmath/source/SmPropertiesPanel.cxx | 88 | ||||
-rw-r--r-- | starmath/source/SmPropertiesPanel.hxx | 51 | ||||
-rw-r--r-- | starmath/uiconfig/smath/ui/sidebarproperties_math.ui | 81 |
6 files changed, 228 insertions, 1 deletions
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk index 91d62caed114..3eac10c29e85 100644 --- a/starmath/Library_sm.mk +++ b/starmath/Library_sm.mk @@ -69,6 +69,7 @@ $(eval $(call gb_Library_add_exception_objects,sm,\ starmath/source/ElementsDockingWindow \ starmath/source/SmElementsPanel \ starmath/source/SmPanelFactory \ + starmath/source/SmPropertiesPanel \ starmath/source/accessibility \ starmath/source/action \ starmath/source/caret \ diff --git a/starmath/UIConfig_smath.mk b/starmath/UIConfig_smath.mk index 45b12819731a..a54f2e4553c4 100644 --- a/starmath/UIConfig_smath.mk +++ b/starmath/UIConfig_smath.mk @@ -40,6 +40,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/smath,\ starmath/uiconfig/smath/ui/printeroptions \ starmath/uiconfig/smath/ui/savedefaultsdialog \ starmath/uiconfig/smath/ui/sidebarelements_math \ + starmath/uiconfig/smath/ui/sidebarproperties_math \ starmath/uiconfig/smath/ui/smathsettings \ starmath/uiconfig/smath/ui/spacingdialog \ starmath/uiconfig/smath/ui/symdefinedialog \ diff --git a/starmath/source/SmPanelFactory.cxx b/starmath/source/SmPanelFactory.cxx index 243c3d05a5f2..664adbcb3bcb 100644 --- a/starmath/source/SmPanelFactory.cxx +++ b/starmath/source/SmPanelFactory.cxx @@ -32,6 +32,7 @@ #include <vcl/weldutils.hxx> #include "SmElementsPanel.hxx" +#include "SmPropertiesPanel.hxx" namespace { @@ -85,7 +86,11 @@ css::uno::Reference<css::ui::XUIElement> SAL_CALL SmPanelFactory::createUIElemen std::unique_ptr<PanelLayout> pPanel; css::ui::LayoutSize aLayoutSize{ -1, -1, -1 }; - if (ResourceURL.endsWith("/MathElementsPanel")) + if (ResourceURL.endsWith("/MathPropertiesPanel")) + { + pPanel = sm::sidebar::SmPropertiesPanel::Create(*pParent); + } + else if (ResourceURL.endsWith("/MathElementsPanel")) { pPanel = sm::sidebar::SmElementsPanel::Create(*pParent, *pBindings); aLayoutSize = { 300, -1, -1 }; diff --git a/starmath/source/SmPropertiesPanel.cxx b/starmath/source/SmPropertiesPanel.cxx new file mode 100644 index 000000000000..3ffd25c40e79 --- /dev/null +++ b/starmath/source/SmPropertiesPanel.cxx @@ -0,0 +1,88 @@ +/* -*- 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/beans/PropertyValue.hpp> +#include <com/sun/star/frame/theUICommandDescription.hpp> +#include <com/sun/star/uno/Sequence.hxx> + +#include <comphelper/dispatchcommand.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/sequenceashashmap.hxx> + +#include "SmPropertiesPanel.hxx" + +namespace sm::sidebar +{ +// static +std::unique_ptr<PanelLayout> SmPropertiesPanel::Create(weld::Widget& rParent) +{ + return std::make_unique<SmPropertiesPanel>(rParent); +} + +SmPropertiesPanel::SmPropertiesPanel(weld::Widget& rParent) + : PanelLayout(&rParent, "MathPropertiesPanel", "modules/smath/ui/sidebarproperties_math.ui") + , mpFormatFontsButton(m_xBuilder->weld_button("btnFormatFonts")) + , mpFormatFontSizeButton(m_xBuilder->weld_button("btnFormatFontSize")) + , mpFormatSpacingButton(m_xBuilder->weld_button("btnFormatSpacing")) + , mpFormatAlignmentButton(m_xBuilder->weld_button("btnFormatAlignment")) + , maButtonCommands{ { mpFormatFontsButton.get(), ".uno:ChangeFont" }, + { mpFormatFontSizeButton.get(), ".uno:ChangeFontSize" }, + { mpFormatSpacingButton.get(), ".uno:ChangeDistance" }, + { mpFormatAlignmentButton.get(), ".uno:ChangeAlignment" } } +{ + // Set localized labels to the buttons + auto xConfs + = css::frame::theUICommandDescription::get(comphelper::getProcessComponentContext()); + if (css::uno::Reference<css::container::XNameAccess> xConf{ + xConfs->getByName("com.sun.star.formula.FormulaProperties"), css::uno::UNO_QUERY }) + { + for (const auto & [ button, command ] : maButtonCommands) + { + comphelper::SequenceAsHashMap props(xConf->getByName(command)); + button->set_label(props.getUnpackedValueOrDefault("Name", button->get_label())); + } + } + + mpFormatFontsButton->connect_clicked(LINK(this, SmPropertiesPanel, ButtonClickHandler)); + mpFormatFontSizeButton->connect_clicked(LINK(this, SmPropertiesPanel, ButtonClickHandler)); + mpFormatSpacingButton->connect_clicked(LINK(this, SmPropertiesPanel, ButtonClickHandler)); + mpFormatAlignmentButton->connect_clicked(LINK(this, SmPropertiesPanel, ButtonClickHandler)); +} + +SmPropertiesPanel::~SmPropertiesPanel() +{ + maButtonCommands.clear(); + + mpFormatFontsButton.reset(); + mpFormatFontSizeButton.reset(); + mpFormatSpacingButton.reset(); + mpFormatAlignmentButton.reset(); +} + +IMPL_LINK(SmPropertiesPanel, ButtonClickHandler, weld::Button&, rButton, void) +{ + if (OUString command = maButtonCommands[&rButton]; !command.isEmpty()) + comphelper::dispatchCommand(command, {}); +} + +} // 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/SmPropertiesPanel.hxx b/starmath/source/SmPropertiesPanel.hxx new file mode 100644 index 000000000000..e81463f37022 --- /dev/null +++ b/starmath/source/SmPropertiesPanel.hxx @@ -0,0 +1,51 @@ +/* -*- 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/sidebar/PanelLayout.hxx> + +#include <map> +#include <memory> + +namespace sm::sidebar +{ +class SmPropertiesPanel : public PanelLayout +{ +public: + static std::unique_ptr<PanelLayout> Create(weld::Widget& rParent); + SmPropertiesPanel(weld::Widget& rParent); + ~SmPropertiesPanel(); + +private: + DECL_LINK(ButtonClickHandler, weld::Button&, void); + + std::unique_ptr<weld::Button> mpFormatFontsButton; + std::unique_ptr<weld::Button> mpFormatFontSizeButton; + std::unique_ptr<weld::Button> mpFormatSpacingButton; + std::unique_ptr<weld::Button> mpFormatAlignmentButton; + + std::map<weld::Button*, OUString> maButtonCommands; +}; + +} // end of namespace sm::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/starmath/uiconfig/smath/ui/sidebarproperties_math.ui b/starmath/uiconfig/smath/ui/sidebarproperties_math.ui new file mode 100644 index 000000000000..b2d8b05eddf0 --- /dev/null +++ b/starmath/uiconfig/smath/ui/sidebarproperties_math.ui @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.1 --> +<interface domain="svx"> + <requires lib="gtk+" version="3.20"/> + <!-- n-columns=1 n-rows=1 --> + <object class="GtkGrid" id="MathPropertiesPanel"> + <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="GtkBox" id="container"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkButton" id="btnFormatFonts"> + <property name="label">Fonts</property> <!-- No need to translate - set in code --> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="valign">start</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="btnFormatFontSize"> + <property name="label">Font Size</property> <!-- No need to translate - set in code --> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="valign">start</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="btnFormatSpacing"> + <property name="label">Spacing</property> <!-- No need to translate - set in code --> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="valign">start</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="btnFormatAlignment"> + <property name="label">Alignment</property> <!-- No need to translate - set in code --> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="valign">start</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + </object> +</interface> |