1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <com/sun/star/beans/PropertyValue.hpp>
23 #include <com/sun/star/frame/theUICommandDescription.hpp>
24 #include <com/sun/star/uno/Sequence.hxx>
26 #include <comphelper/dispatchcommand.hxx>
27 #include <comphelper/processfactory.hxx>
28 #include <comphelper/sequenceashashmap.hxx>
30 #include "SmPropertiesPanel.hxx"
35 std::unique_ptr
<PanelLayout
>
36 SmPropertiesPanel::Create(weld::Widget
& rParent
,
37 const css::uno::Reference
<css::frame::XFrame
>& xFrame
)
39 return std::make_unique
<SmPropertiesPanel
>(rParent
, xFrame
);
42 SmPropertiesPanel::SmPropertiesPanel(weld::Widget
& rParent
,
43 const css::uno::Reference
<css::frame::XFrame
>& xFrame
)
44 : PanelLayout(&rParent
, "MathPropertiesPanel", "modules/smath/ui/sidebarproperties_math.ui")
46 , mpFormatFontsButton(m_xBuilder
->weld_button("btnFormatFonts"))
47 , mpFormatFontSizeButton(m_xBuilder
->weld_button("btnFormatFontSize"))
48 , mpFormatSpacingButton(m_xBuilder
->weld_button("btnFormatSpacing"))
49 , mpFormatAlignmentButton(m_xBuilder
->weld_button("btnFormatAlignment"))
50 , maButtonCommands
{ { mpFormatFontsButton
.get(), ".uno:ChangeFont" },
51 { mpFormatFontSizeButton
.get(), ".uno:ChangeFontSize" },
52 { mpFormatSpacingButton
.get(), ".uno:ChangeDistance" },
53 { mpFormatAlignmentButton
.get(), ".uno:ChangeAlignment" } }
55 // Set localized labels to the buttons
57 = css::frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
58 if (css::uno::Reference
<css::container::XNameAccess
> xConf
{
59 xConfs
->getByName("com.sun.star.formula.FormulaProperties"), css::uno::UNO_QUERY
})
61 for (const auto & [ button
, command
] : maButtonCommands
)
63 comphelper::SequenceAsHashMap
props(xConf
->getByName(command
));
64 button
->set_label(props
.getUnpackedValueOrDefault("Name", button
->get_label()));
68 mpFormatFontsButton
->connect_clicked(LINK(this, SmPropertiesPanel
, ButtonClickHandler
));
69 mpFormatFontSizeButton
->connect_clicked(LINK(this, SmPropertiesPanel
, ButtonClickHandler
));
70 mpFormatSpacingButton
->connect_clicked(LINK(this, SmPropertiesPanel
, ButtonClickHandler
));
71 mpFormatAlignmentButton
->connect_clicked(LINK(this, SmPropertiesPanel
, ButtonClickHandler
));
74 SmPropertiesPanel::~SmPropertiesPanel()
76 maButtonCommands
.clear();
78 mpFormatFontsButton
.reset();
79 mpFormatFontSizeButton
.reset();
80 mpFormatSpacingButton
.reset();
81 mpFormatAlignmentButton
.reset();
84 IMPL_LINK(SmPropertiesPanel
, ButtonClickHandler
, weld::Button
&, rButton
, void)
86 if (OUString command
= maButtonCommands
[&rButton
]; !command
.isEmpty())
87 comphelper::dispatchCommand(command
, mxFrame
, {});
90 } // end of namespace sm::sidebar
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */