From 8ae17abbcce62dab714e8e36ef5225e6fef75334 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 27 Apr 2022 15:06:03 +0300 Subject: 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 --- starmath/Library_sm.mk | 1 + starmath/UIConfig_smath.mk | 1 + starmath/source/SmPanelFactory.cxx | 7 +- starmath/source/SmPropertiesPanel.cxx | 88 ++++++++++++++++++++++ starmath/source/SmPropertiesPanel.hxx | 51 +++++++++++++ .../uiconfig/smath/ui/sidebarproperties_math.ui | 81 ++++++++++++++++++++ 6 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 starmath/source/SmPropertiesPanel.cxx create mode 100644 starmath/source/SmPropertiesPanel.hxx create mode 100644 starmath/uiconfig/smath/ui/sidebarproperties_math.ui (limited to 'starmath') diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk index ba4c59fdfd75..e4eca13440d7 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 593b2e4a14d6..8e9f146a1959 100644 --- a/starmath/source/SmPanelFactory.cxx +++ b/starmath/source/SmPanelFactory.cxx @@ -30,6 +30,7 @@ #include #include "SmElementsPanel.hxx" +#include "SmPropertiesPanel.hxx" namespace { @@ -80,7 +81,11 @@ css::uno::Reference SAL_CALL SmPanelFactory::createUIElemen std::unique_ptr 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 + +#include +#include +#include + +#include +#include +#include + +#include "SmPropertiesPanel.hxx" + +namespace sm::sidebar +{ +// static +std::unique_ptr SmPropertiesPanel::Create(weld::Widget& rParent) +{ + return std::make_unique(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 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 + +#include + +#include +#include + +namespace sm::sidebar +{ +class SmPropertiesPanel : public PanelLayout +{ +public: + static std::unique_ptr Create(weld::Widget& rParent); + SmPropertiesPanel(weld::Widget& rParent); + ~SmPropertiesPanel(); + +private: + DECL_LINK(ButtonClickHandler, weld::Button&, void); + + std::unique_ptr mpFormatFontsButton; + std::unique_ptr mpFormatFontSizeButton; + std::unique_ptr mpFormatSpacingButton; + std::unique_ptr mpFormatAlignmentButton; + + std::map 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 @@ + + + + + + + True + False + True + True + 6 + + + + True + False + vertical + + + Fonts + True + True + start + True + + + True + True + 0 + + + + + Font Size + True + True + start + True + + + True + True + 1 + + + + + Spacing + True + True + start + True + + + True + True + 2 + + + + + Alignment + True + True + start + True + + + True + True + 3 + + + + + 0 + 0 + + + + -- cgit