diff --git a/chart2/source/controller/dialogs/res_DataLabel.hxx b/chart2/source/controller/dialogs/res_DataLabel.hxx index 66a062d2ca24..a50895731bd3 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.hxx +++ b/chart2/source/controller/dialogs/res_DataLabel.hxx @@ -20,6 +20,7 @@ #include #include +#include #include #include diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 431952248568..3fe92f971ac8 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx index e89378b60337..db0de7211734 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.hxx b/chart2/source/controller/dialogs/tp_AxisLabel.hxx index f3062163e28c..1bed8e05c231 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.hxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.hxx @@ -21,6 +21,7 @@ #include #include #include +#include #include namespace weld { diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.hxx b/chart2/source/controller/dialogs/tp_PolarOptions.hxx index 51ad7a809be0..656879f3c896 100644 --- a/chart2/source/controller/dialogs/tp_PolarOptions.hxx +++ b/chart2/source/controller/dialogs/tp_PolarOptions.hxx @@ -20,6 +20,7 @@ #include #include +#include namespace weld { class CheckButton; diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx index 48001d4fb7b8..9b8b46a1392f 100644 --- a/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx +++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx @@ -19,6 +19,7 @@ #pragma once #include +#include namespace weld { class CheckButton; diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.hxx b/chart2/source/controller/dialogs/tp_TitleRotation.hxx index 559212ddf293..ae34d8a4d0f1 100644 --- a/chart2/source/controller/dialogs/tp_TitleRotation.hxx +++ b/chart2/source/controller/dialogs/tp_TitleRotation.hxx @@ -20,6 +20,7 @@ #include #include +#include #include namespace weld { diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.hxx b/chart2/source/controller/sidebar/ChartAxisPanel.hxx index e5ed4b5ebcc6..1dddc8bce8c1 100644 --- a/chart2/source/controller/sidebar/ChartAxisPanel.hxx +++ b/chart2/source/controller/sidebar/ChartAxisPanel.hxx @@ -14,6 +14,7 @@ #include #include #include +#include #include "ChartSidebarModifyListener.hxx" #include "ChartSidebarSelectionListener.hxx" diff --git a/cui/source/inc/TextColumnsPage.hxx b/cui/source/inc/TextColumnsPage.hxx index 0aa6e2c9e800..c61fcd03c548 100644 --- a/cui/source/inc/TextColumnsPage.hxx +++ b/cui/source/inc/TextColumnsPage.hxx @@ -12,6 +12,7 @@ #include #include +#include #include diff --git a/cui/source/inc/align.hxx b/cui/source/inc/align.hxx index ca578ac955d6..7c99b1bf8ce6 100644 --- a/cui/source/inc/align.hxx +++ b/cui/source/inc/align.hxx @@ -42,6 +42,7 @@ enum VerticalAlign { #include #include #include +#include #include class SvxJustifyMethodItem; diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx index d929ba8fc1ff..30b0d2369d75 100644 --- a/cui/source/inc/border.hxx +++ b/cui/source/inc/border.hxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx index adede23d5029..ed69628c3d68 100644 --- a/cui/source/inc/chardlg.hxx +++ b/cui/source/inc/chardlg.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/cui/source/inc/connect.hxx b/cui/source/inc/connect.hxx index 218f1666c0c7..3b8b58f9eddf 100644 --- a/cui/source/inc/connect.hxx +++ b/cui/source/inc/connect.hxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include diff --git a/cui/source/inc/cuigrfflt.hxx b/cui/source/inc/cuigrfflt.hxx index 075c74c29f42..ffd62dd92f22 100644 --- a/cui/source/inc/cuigrfflt.hxx +++ b/cui/source/inc/cuigrfflt.hxx @@ -22,6 +22,7 @@ #include #include #include +#include class CuiGraphicPreviewWindow : public weld::CustomWidgetController { diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index c1acc7f2ce14..faf1c26374d3 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -27,6 +27,7 @@ #include #include #include +#include class ColorListBox; class SdrModel; diff --git a/cui/source/inc/grfpage.hxx b/cui/source/inc/grfpage.hxx index 12d44bc268a0..f0e5aa3492ef 100644 --- a/cui/source/inc/grfpage.hxx +++ b/cui/source/inc/grfpage.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include #include #include diff --git a/cui/source/inc/labdlg.hxx b/cui/source/inc/labdlg.hxx index b04c2a2b6d05..0ce3f7ff2c1c 100644 --- a/cui/source/inc/labdlg.hxx +++ b/cui/source/inc/labdlg.hxx @@ -24,6 +24,7 @@ #include #include #include +#include class SdrView; diff --git a/cui/source/inc/measure.hxx b/cui/source/inc/measure.hxx index c30e83ee1ed4..723d9fee0e1d 100644 --- a/cui/source/inc/measure.hxx +++ b/cui/source/inc/measure.hxx @@ -21,6 +21,7 @@ #include #include #include +#include class SdrView; diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx index 37de9822097e..ffe6292e9747 100644 --- a/cui/source/inc/numpages.hxx +++ b/cui/source/inc/numpages.hxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/cui/source/inc/page.hxx b/cui/source/inc/page.hxx index 81acdd58a7c8..fe4b2cfc8d97 100644 --- a/cui/source/inc/page.hxx +++ b/cui/source/inc/page.hxx @@ -26,6 +26,7 @@ #include #include #include +#include // class SvxPageDescPage ------------------------------------------------- /* diff --git a/cui/source/inc/paragrph.hxx b/cui/source/inc/paragrph.hxx index 9d95e1adfa9b..8ab678c83f6f 100644 --- a/cui/source/inc/paragrph.hxx +++ b/cui/source/inc/paragrph.hxx @@ -22,6 +22,7 @@ #include #include #include +#include class SvxLineSpacingItem; diff --git a/cui/source/inc/swpossizetabpage.hxx b/cui/source/inc/swpossizetabpage.hxx index 83edd4379572..c4fbdf112255 100644 --- a/cui/source/inc/swpossizetabpage.hxx +++ b/cui/source/inc/swpossizetabpage.hxx @@ -20,6 +20,7 @@ #include #include +#include #include #include diff --git a/cui/source/inc/tabstpge.hxx b/cui/source/inc/tabstpge.hxx index b9a556591a85..a6ae82a3dbfd 100644 --- a/cui/source/inc/tabstpge.hxx +++ b/cui/source/inc/tabstpge.hxx @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include #include diff --git a/cui/source/inc/textanim.hxx b/cui/source/inc/textanim.hxx index 9ac0e2f991c6..7d9b8a895ef5 100644 --- a/cui/source/inc/textanim.hxx +++ b/cui/source/inc/textanim.hxx @@ -21,6 +21,7 @@ #include #include #include +#include #include class SdrView; diff --git a/cui/source/inc/textattr.hxx b/cui/source/inc/textattr.hxx index 8ea2e4d8e43d..c1a13272edaa 100644 --- a/cui/source/inc/textattr.hxx +++ b/cui/source/inc/textattr.hxx @@ -20,6 +20,7 @@ #include #include +#include /************************************************************************* |* diff --git a/cui/source/inc/transfrm.hxx b/cui/source/inc/transfrm.hxx index 6ea12bb67a82..0edd62deaf18 100644 --- a/cui/source/inc/transfrm.hxx +++ b/cui/source/inc/transfrm.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include // predefines diff --git a/cui/source/inc/zoom.hxx b/cui/source/inc/zoom.hxx index 66bf0dcafa6f..4d4d6053e679 100644 --- a/cui/source/inc/zoom.hxx +++ b/cui/source/inc/zoom.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include class SvxZoomDialog : public SfxDialogController diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx index 4bebe067cd41..c6fbc2529dda 100644 --- a/cui/source/options/optgdlg.hxx +++ b/cui/source/options/optgdlg.hxx @@ -21,6 +21,7 @@ #include #include #include +#include class CanvasSettings; diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 132f2c903305..9ca743ed690f 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/dbaccess/source/ui/inc/dlgsize.hxx b/dbaccess/source/ui/inc/dlgsize.hxx index 34ae24ad49cc..b32c060ea4b3 100644 --- a/dbaccess/source/ui/inc/dlgsize.hxx +++ b/dbaccess/source/ui/inc/dlgsize.hxx @@ -18,6 +18,7 @@ */ #pragma once +#include #include namespace dbaui diff --git a/extensions/source/propctrlr/commoncontrol.hxx b/extensions/source/propctrlr/commoncontrol.hxx index a7bff865dd96..62fc99d856ae 100644 --- a/extensions/source/propctrlr/commoncontrol.hxx +++ b/extensions/source/propctrlr/commoncontrol.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/extensions/source/propctrlr/standardcontrol.hxx b/extensions/source/propctrlr/standardcontrol.hxx index 35888811b155..08147130de4f 100644 --- a/extensions/source/propctrlr/standardcontrol.hxx +++ b/extensions/source/propctrlr/standardcontrol.hxx @@ -28,6 +28,7 @@ #include #include #include +#include namespace pcr { diff --git a/extensions/source/scanner/sanedlg.hxx b/extensions/source/scanner/sanedlg.hxx index 8ed4ef9dd4cc..0266ce01707b 100644 --- a/extensions/source/scanner/sanedlg.hxx +++ b/extensions/source/scanner/sanedlg.hxx @@ -18,6 +18,7 @@ */ #pragma once +#include #include #include #include diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx index 4e3e088f053c..b8e78d92b343 100644 --- a/filter/source/pdf/impdialog.hxx +++ b/filter/source/pdf/impdialog.hxx @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/include/svx/bmpmask.hxx b/include/svx/bmpmask.hxx index bfd92f76f0f8..b9320ad902ec 100644 --- a/include/svx/bmpmask.hxx +++ b/include/svx/bmpmask.hxx @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace vcl { class Window; } diff --git a/include/svx/dialcontrol.hxx b/include/svx/dialcontrol.hxx index 3eef892613a0..529f0f978760 100644 --- a/include/svx/dialcontrol.hxx +++ b/include/svx/dialcontrol.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include diff --git a/include/svx/float3d.hxx b/include/svx/float3d.hxx index b092ff701bbb..299d55fddb2b 100644 --- a/include/svx/float3d.hxx +++ b/include/svx/float3d.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/include/svx/fontwork.hxx b/include/svx/fontwork.hxx index cf6ae5c60f76..1780e3a313d6 100644 --- a/include/svx/fontwork.hxx +++ b/include/svx/fontwork.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include class ColorListBox; diff --git a/include/svx/fontworkgallery.hxx b/include/svx/fontworkgallery.hxx index 4391ca1b8738..bb805be4b7a8 100644 --- a/include/svx/fontworkgallery.hxx +++ b/include/svx/fontworkgallery.hxx @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/include/svx/hdft.hxx b/include/svx/hdft.hxx index 2b9fe5f03f21..227958d0c1d9 100644 --- a/include/svx/hdft.hxx +++ b/include/svx/hdft.hxx @@ -21,6 +21,7 @@ #include +#include #include #include diff --git a/include/svx/relfld.hxx b/include/svx/relfld.hxx index de4ad875f417..dc9611a479f4 100644 --- a/include/svx/relfld.hxx +++ b/include/svx/relfld.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include diff --git a/include/svx/sidebar/AreaPropertyPanelBase.hxx b/include/svx/sidebar/AreaPropertyPanelBase.hxx index 131d53233eca..f1bff240466c 100644 --- a/include/svx/sidebar/AreaPropertyPanelBase.hxx +++ b/include/svx/sidebar/AreaPropertyPanelBase.hxx @@ -35,6 +35,7 @@ #include #include #include +#include class ToolbarUnoDispatcher; class XFillFloatTransparenceItem; diff --git a/include/svx/sidebar/AreaTransparencyGradientPopup.hxx b/include/svx/sidebar/AreaTransparencyGradientPopup.hxx index 3aa26b6e3fa1..96d9643a7a83 100644 --- a/include/svx/sidebar/AreaTransparencyGradientPopup.hxx +++ b/include/svx/sidebar/AreaTransparencyGradientPopup.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SVX_SOURCE_SIDEBAR_AREA_AREATRANSPARENCYGRADIENTPOPUP_HXX #include +#include #include #include diff --git a/include/svx/sidebar/LinePropertyPanelBase.hxx b/include/svx/sidebar/LinePropertyPanelBase.hxx index a063b955c414..ea1fc8475eee 100644 --- a/include/svx/sidebar/LinePropertyPanelBase.hxx +++ b/include/svx/sidebar/LinePropertyPanelBase.hxx @@ -19,6 +19,7 @@ #ifndef INCLUDED_SVX_SOURCE_SIDEBAR_LINE_LINEPROPERTYPANELBASE_HXX #define INCLUDED_SVX_SOURCE_SIDEBAR_LINE_LINEPROPERTYPANELBASE_HXX +#include #include #include #include diff --git a/include/svx/sidebar/LineWidthPopup.hxx b/include/svx/sidebar/LineWidthPopup.hxx index 193b04acb96e..b57674313fe4 100644 --- a/include/svx/sidebar/LineWidthPopup.hxx +++ b/include/svx/sidebar/LineWidthPopup.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/include/vcl/weld/MetricSpinButton.hxx b/include/vcl/weld/MetricSpinButton.hxx new file mode 100644 index 000000000000..2e247ba2f8d3 --- /dev/null +++ b/include/vcl/weld/MetricSpinButton.hxx @@ -0,0 +1,189 @@ +/* -*- 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/. + */ + +#pragma once + +#include +#include + +namespace weld +{ +class VCL_DLLPUBLIC MetricSpinButton final +{ + FieldUnit m_eSrcUnit; + std::unique_ptr m_xSpinButton; + Link m_aValueChangedHdl; + + DECL_LINK(spin_button_value_changed, weld::SpinButton&, void); + DECL_LINK(spin_button_output, sal_Int64, OUString); + DECL_LINK(spin_button_input, const OUString&, std::optional); + + void signal_value_changed() { m_aValueChangedHdl.Call(*this); } + + sal_Int64 ConvertValue(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit) const; + OUString format_number(sal_Int64 nValue) const; + void update_width_chars(); + +public: + MetricSpinButton(std::unique_ptr pSpinButton, FieldUnit eSrcUnit) + : m_eSrcUnit(eSrcUnit) + , m_xSpinButton(std::move(pSpinButton)) + { + update_width_chars(); + m_xSpinButton->set_value_formatter(LINK(this, MetricSpinButton, spin_button_output)); + m_xSpinButton->set_text_parser(LINK(this, MetricSpinButton, spin_button_input)); + m_xSpinButton->connect_value_changed( + LINK(this, MetricSpinButton, spin_button_value_changed)); + m_xSpinButton->set_text(format_number(m_xSpinButton->get_value())); + } + + static OUString MetricToString(FieldUnit rUnit); + + FieldUnit get_unit() const { return m_eSrcUnit; } + + void set_unit(FieldUnit eUnit); + + sal_Int64 convert_value_to(sal_Int64 nValue, FieldUnit eValueUnit) const + { + return ConvertValue(nValue, m_eSrcUnit, eValueUnit); + } + + sal_Int64 convert_value_from(sal_Int64 nValue, FieldUnit eValueUnit) const + { + return ConvertValue(nValue, eValueUnit, m_eSrcUnit); + } + + void set_value(sal_Int64 nValue, FieldUnit eValueUnit) + { + m_xSpinButton->set_value(convert_value_from(nValue, eValueUnit)); + } + + sal_Int64 get_value(FieldUnit eDestUnit) const + { + return convert_value_to(m_xSpinButton->get_value(), eDestUnit); + } + + // typically you only need to call this if set_text (e.g. with "") was + // previously called to display some arbitrary text instead of the + // formatted value and now you want to show it as formatted again + void reformat() + { + const OUString sText = format_number(m_xSpinButton->get_value()); + m_xSpinButton->set_text(sText); + } + + void set_range(sal_Int64 min, sal_Int64 max, FieldUnit eValueUnit) + { + min = convert_value_from(min, eValueUnit); + max = convert_value_from(max, eValueUnit); + m_xSpinButton->set_range(min, max); + update_width_chars(); + } + + void get_range(sal_Int64& min, sal_Int64& max, FieldUnit eDestUnit) const + { + m_xSpinButton->get_range(min, max); + min = convert_value_to(min, eDestUnit); + max = convert_value_to(max, eDestUnit); + } + + void set_min(sal_Int64 min, FieldUnit eValueUnit) + { + sal_Int64 dummy, max; + get_range(dummy, max, eValueUnit); + set_range(min, max, eValueUnit); + } + + void set_max(sal_Int64 max, FieldUnit eValueUnit) + { + sal_Int64 min, dummy; + get_range(min, dummy, eValueUnit); + set_range(min, max, eValueUnit); + } + + sal_Int64 get_min(FieldUnit eValueUnit) const + { + sal_Int64 min, dummy; + get_range(min, dummy, eValueUnit); + return min; + } + + sal_Int64 get_max(FieldUnit eValueUnit) const + { + sal_Int64 dummy, max; + get_range(dummy, max, eValueUnit); + return max; + } + + void set_increments(sal_Int64 step, sal_Int64 page, FieldUnit eValueUnit) + { + step = convert_value_from(step, eValueUnit); + page = convert_value_from(page, eValueUnit); + m_xSpinButton->set_increments(step, page); + } + + void get_increments(sal_Int64& step, sal_Int64& page, FieldUnit eDestUnit) const + { + m_xSpinButton->get_increments(step, page); + step = convert_value_to(step, eDestUnit); + page = convert_value_to(page, eDestUnit); + } + + void connect_value_changed(const Link& rLink) + { + m_aValueChangedHdl = rLink; + } + + sal_Int64 normalize(sal_Int64 nValue) const { return m_xSpinButton->normalize(nValue); } + sal_Int64 denormalize(sal_Int64 nValue) const { return m_xSpinButton->denormalize(nValue); } + void set_sensitive(bool sensitive) { m_xSpinButton->set_sensitive(sensitive); } + bool get_sensitive() const { return m_xSpinButton->get_sensitive(); } + bool get_visible() const { return m_xSpinButton->get_visible(); } + void grab_focus() { m_xSpinButton->grab_focus(); } + bool has_focus() const { return m_xSpinButton->has_focus(); } + void show() { m_xSpinButton->show(); } + void set_visible(bool bShow) { m_xSpinButton->set_visible(bShow); } + void hide() { m_xSpinButton->hide(); } + void set_digits(unsigned int digits); + void set_accessible_name(const OUString& rName) { m_xSpinButton->set_accessible_name(rName); } + unsigned int get_digits() const { return m_xSpinButton->get_digits(); } + void save_value() { m_xSpinButton->save_value(); } + bool get_value_changed_from_saved() const + { + return m_xSpinButton->get_value_changed_from_saved(); + } + void set_text(const OUString& rText) { m_xSpinButton->set_text(rText); } + OUString get_text() const { return m_xSpinButton->get_text(); } + void set_size_request(int nWidth, int nHeight) + { + m_xSpinButton->set_size_request(nWidth, nHeight); + } + Size get_size_request() const { return m_xSpinButton->get_size_request(); } + Size get_preferred_size() const { return m_xSpinButton->get_preferred_size(); } + void connect_focus_in(const Link& rLink) + { + m_xSpinButton->connect_focus_in(rLink); + } + void connect_focus_out(const Link& rLink) + { + m_xSpinButton->connect_focus_out(rLink); + } + OUString get_buildable_name() const { return m_xSpinButton->get_buildable_name(); } + void set_help_id(const OUString& rName) { m_xSpinButton->set_help_id(rName); } + void set_position(int nCursorPos) { m_xSpinButton->set_position(nCursorPos); } + // set the width of the underlying widget in characters, this setting is + // invalidated when changing the units, range or digits, so to have effect + // must come after changing those values + void set_width_chars(int nChars) { m_xSpinButton->set_width_chars(nChars); } + int get_width_chars() const { return m_xSpinButton->get_width_chars(); } + weld::SpinButton& get_widget() { return *m_xSpinButton; } +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/weld/weld.hxx b/include/vcl/weld/weld.hxx index 34cf4bf28f6c..70e24faaa4b7 100644 --- a/include/vcl/weld/weld.hxx +++ b/include/vcl/weld/weld.hxx @@ -81,6 +81,7 @@ class Container; class DialogController; class EntryTreeView; class IconView; +class MetricSpinButton; class TreeView; class VCL_DLLPUBLIC Widget @@ -1599,177 +1600,6 @@ public: virtual Date get_date() const = 0; }; -class VCL_DLLPUBLIC MetricSpinButton final -{ - FieldUnit m_eSrcUnit; - std::unique_ptr m_xSpinButton; - Link m_aValueChangedHdl; - - DECL_LINK(spin_button_value_changed, weld::SpinButton&, void); - DECL_LINK(spin_button_output, sal_Int64, OUString); - DECL_LINK(spin_button_input, const OUString&, std::optional); - - void signal_value_changed() { m_aValueChangedHdl.Call(*this); } - - sal_Int64 ConvertValue(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit) const; - OUString format_number(sal_Int64 nValue) const; - void update_width_chars(); - -public: - MetricSpinButton(std::unique_ptr pSpinButton, FieldUnit eSrcUnit) - : m_eSrcUnit(eSrcUnit) - , m_xSpinButton(std::move(pSpinButton)) - { - update_width_chars(); - m_xSpinButton->set_value_formatter(LINK(this, MetricSpinButton, spin_button_output)); - m_xSpinButton->set_text_parser(LINK(this, MetricSpinButton, spin_button_input)); - m_xSpinButton->connect_value_changed( - LINK(this, MetricSpinButton, spin_button_value_changed)); - m_xSpinButton->set_text(format_number(m_xSpinButton->get_value())); - } - - static OUString MetricToString(FieldUnit rUnit); - - FieldUnit get_unit() const { return m_eSrcUnit; } - - void set_unit(FieldUnit eUnit); - - sal_Int64 convert_value_to(sal_Int64 nValue, FieldUnit eValueUnit) const - { - return ConvertValue(nValue, m_eSrcUnit, eValueUnit); - } - - sal_Int64 convert_value_from(sal_Int64 nValue, FieldUnit eValueUnit) const - { - return ConvertValue(nValue, eValueUnit, m_eSrcUnit); - } - - void set_value(sal_Int64 nValue, FieldUnit eValueUnit) - { - m_xSpinButton->set_value(convert_value_from(nValue, eValueUnit)); - } - - sal_Int64 get_value(FieldUnit eDestUnit) const - { - return convert_value_to(m_xSpinButton->get_value(), eDestUnit); - } - - // typically you only need to call this if set_text (e.g. with "") was - // previously called to display some arbitrary text instead of the - // formatted value and now you want to show it as formatted again - void reformat() - { - const OUString sText = format_number(m_xSpinButton->get_value()); - m_xSpinButton->set_text(sText); - } - - void set_range(sal_Int64 min, sal_Int64 max, FieldUnit eValueUnit) - { - min = convert_value_from(min, eValueUnit); - max = convert_value_from(max, eValueUnit); - m_xSpinButton->set_range(min, max); - update_width_chars(); - } - - void get_range(sal_Int64& min, sal_Int64& max, FieldUnit eDestUnit) const - { - m_xSpinButton->get_range(min, max); - min = convert_value_to(min, eDestUnit); - max = convert_value_to(max, eDestUnit); - } - - void set_min(sal_Int64 min, FieldUnit eValueUnit) - { - sal_Int64 dummy, max; - get_range(dummy, max, eValueUnit); - set_range(min, max, eValueUnit); - } - - void set_max(sal_Int64 max, FieldUnit eValueUnit) - { - sal_Int64 min, dummy; - get_range(min, dummy, eValueUnit); - set_range(min, max, eValueUnit); - } - - sal_Int64 get_min(FieldUnit eValueUnit) const - { - sal_Int64 min, dummy; - get_range(min, dummy, eValueUnit); - return min; - } - - sal_Int64 get_max(FieldUnit eValueUnit) const - { - sal_Int64 dummy, max; - get_range(dummy, max, eValueUnit); - return max; - } - - void set_increments(sal_Int64 step, sal_Int64 page, FieldUnit eValueUnit) - { - step = convert_value_from(step, eValueUnit); - page = convert_value_from(page, eValueUnit); - m_xSpinButton->set_increments(step, page); - } - - void get_increments(sal_Int64& step, sal_Int64& page, FieldUnit eDestUnit) const - { - m_xSpinButton->get_increments(step, page); - step = convert_value_to(step, eDestUnit); - page = convert_value_to(page, eDestUnit); - } - - void connect_value_changed(const Link& rLink) - { - m_aValueChangedHdl = rLink; - } - - sal_Int64 normalize(sal_Int64 nValue) const { return m_xSpinButton->normalize(nValue); } - sal_Int64 denormalize(sal_Int64 nValue) const { return m_xSpinButton->denormalize(nValue); } - void set_sensitive(bool sensitive) { m_xSpinButton->set_sensitive(sensitive); } - bool get_sensitive() const { return m_xSpinButton->get_sensitive(); } - bool get_visible() const { return m_xSpinButton->get_visible(); } - void grab_focus() { m_xSpinButton->grab_focus(); } - bool has_focus() const { return m_xSpinButton->has_focus(); } - void show() { m_xSpinButton->show(); } - void set_visible(bool bShow) { m_xSpinButton->set_visible(bShow); } - void hide() { m_xSpinButton->hide(); } - void set_digits(unsigned int digits); - void set_accessible_name(const OUString& rName) { m_xSpinButton->set_accessible_name(rName); } - unsigned int get_digits() const { return m_xSpinButton->get_digits(); } - void save_value() { m_xSpinButton->save_value(); } - bool get_value_changed_from_saved() const - { - return m_xSpinButton->get_value_changed_from_saved(); - } - void set_text(const OUString& rText) { m_xSpinButton->set_text(rText); } - OUString get_text() const { return m_xSpinButton->get_text(); } - void set_size_request(int nWidth, int nHeight) - { - m_xSpinButton->set_size_request(nWidth, nHeight); - } - Size get_size_request() const { return m_xSpinButton->get_size_request(); } - Size get_preferred_size() const { return m_xSpinButton->get_preferred_size(); } - void connect_focus_in(const Link& rLink) - { - m_xSpinButton->connect_focus_in(rLink); - } - void connect_focus_out(const Link& rLink) - { - m_xSpinButton->connect_focus_out(rLink); - } - OUString get_buildable_name() const { return m_xSpinButton->get_buildable_name(); } - void set_help_id(const OUString& rName) { m_xSpinButton->set_help_id(rName); } - void set_position(int nCursorPos) { m_xSpinButton->set_position(nCursorPos); } - // set the width of the underlying widget in characters, this setting is - // invalidated when changing the units, range or digits, so to have effect - // must come after changing those values - void set_width_chars(int nChars) { m_xSpinButton->set_width_chars(nChars); } - int get_width_chars() const { return m_xSpinButton->get_width_chars(); } - weld::SpinButton& get_widget() { return *m_xSpinButton; } -}; - enum class LabelType { Normal, diff --git a/sc/source/ui/inc/mtrindlg.hxx b/sc/source/ui/inc/mtrindlg.hxx index 516a918b5e10..733965efe397 100644 --- a/sc/source/ui/inc/mtrindlg.hxx +++ b/sc/source/ui/inc/mtrindlg.hxx @@ -19,6 +19,7 @@ #pragma once +#include #include class ScMetricInputDlg : public weld::GenericDialogController diff --git a/sc/source/ui/inc/tptable.hxx b/sc/source/ui/inc/tptable.hxx index 9e98c050a20e..0052398045b4 100644 --- a/sc/source/ui/inc/tptable.hxx +++ b/sc/source/ui/inc/tptable.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include class ScTablePage : public SfxTabPage { diff --git a/sc/source/ui/inc/tpview.hxx b/sc/source/ui/inc/tpview.hxx index 3ed12e498982..6fbf3c773b8a 100644 --- a/sc/source/ui/inc/tpview.hxx +++ b/sc/source/ui/inc/tpview.hxx @@ -21,6 +21,7 @@ #include #include +#include class ScViewOptions; diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx index 7de9cc633049..5eedf7657b06 100644 --- a/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx +++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx @@ -23,6 +23,7 @@ #include #include #include +#include namespace sc::sidebar { diff --git a/sd/source/ui/inc/BulletAndPositionDlg.hxx b/sd/source/ui/inc/BulletAndPositionDlg.hxx index d39f554afa1a..e2cc8c2c97c5 100644 --- a/sd/source/ui/inc/BulletAndPositionDlg.hxx +++ b/sd/source/ui/inc/BulletAndPositionDlg.hxx @@ -24,6 +24,7 @@ #include #include +#include #include #include #include "View.hxx" diff --git a/sd/source/ui/inc/CustomAnimationPane.hxx b/sd/source/ui/inc/CustomAnimationPane.hxx index 7d833fa66f31..f2c34d506b04 100644 --- a/sd/source/ui/inc/CustomAnimationPane.hxx +++ b/sd/source/ui/inc/CustomAnimationPane.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include "CustomAnimationList.hxx" #include diff --git a/sd/source/ui/inc/SlideTransitionPane.hxx b/sd/source/ui/inc/SlideTransitionPane.hxx index 0fcb29cc7920..26ca96b0e48a 100644 --- a/sd/source/ui/inc/SlideTransitionPane.hxx +++ b/sd/source/ui/inc/SlideTransitionPane.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/sd/source/ui/inc/copydlg.hxx b/sd/source/ui/inc/copydlg.hxx index 9bd8a5a4c111..79ed5af43e44 100644 --- a/sd/source/ui/inc/copydlg.hxx +++ b/sd/source/ui/inc/copydlg.hxx @@ -21,6 +21,7 @@ #include #include +#include class ColorListBox; diff --git a/sd/source/ui/inc/dlgsnap.hxx b/sd/source/ui/inc/dlgsnap.hxx index 4999f5f8d12c..7085b72ccae1 100644 --- a/sd/source/ui/inc/dlgsnap.hxx +++ b/sd/source/ui/inc/dlgsnap.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include #include /************************************************************************/ diff --git a/sd/source/ui/inc/tpoption.hxx b/sd/source/ui/inc/tpoption.hxx index e1065eb28b1b..48b62a0ff113 100644 --- a/sd/source/ui/inc/tpoption.hxx +++ b/sd/source/ui/inc/tpoption.hxx @@ -21,6 +21,7 @@ #include #include +#include /** * Option-Tab-Page: Snap diff --git a/sd/source/ui/inc/vectdlg.hxx b/sd/source/ui/inc/vectdlg.hxx index 627a407c0fe7..bfc687394d66 100644 --- a/sd/source/ui/inc/vectdlg.hxx +++ b/sd/source/ui/inc/vectdlg.hxx @@ -19,6 +19,7 @@ #pragma once +#include #include #include diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx index af856ce005ec..37de19ba1638 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -59,6 +59,7 @@ #include #include #include +#include #include #include diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx index c4570bffa143..60640956c124 100644 --- a/starmath/inc/dialog.hxx +++ b/starmath/inc/dialog.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "symbol.hxx" diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index bc5dad9c78e6..1123fc96e079 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/svtools/source/misc/unitconv.cxx b/svtools/source/misc/unitconv.cxx index c7bbc561ce7e..3c80e5508618 100644 --- a/svtools/source/misc/unitconv.cxx +++ b/svtools/source/misc/unitconv.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include void SetFieldUnit(weld::MetricSpinButton& rField, FieldUnit eUnit, bool bAll) diff --git a/svx/inc/extrusiondepthdialog.hxx b/svx/inc/extrusiondepthdialog.hxx index 6e5b21add3b9..faaba48c8e32 100644 --- a/svx/inc/extrusiondepthdialog.hxx +++ b/svx/inc/extrusiondepthdialog.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SVX_INC_EXTRUSIONDEPTHDIALOG_HXX #define INCLUDED_SVX_INC_EXTRUSIONDEPTHDIALOG_HXX +#include #include namespace svx diff --git a/svx/source/dialog/contimp.hxx b/svx/source/dialog/contimp.hxx index 268e64695249..ab2e920f1d47 100644 --- a/svx/source/dialog/contimp.hxx +++ b/svx/source/dialog/contimp.hxx @@ -21,6 +21,7 @@ #include #include "contwnd.hxx" #include +#include class SvxSuperContourDlg; diff --git a/svx/source/dialog/optgrid.cxx b/svx/source/dialog/optgrid.cxx index 4bb23f2752ff..997fb7c421a5 100644 --- a/svx/source/dialog/optgrid.cxx +++ b/svx/source/dialog/optgrid.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/svx/source/dialog/spacinglistbox.cxx b/svx/source/dialog/spacinglistbox.cxx index 90cc689ccc6f..6b0310887b7a 100644 --- a/svx/source/dialog/spacinglistbox.cxx +++ b/svx/source/dialog/spacinglistbox.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include namespace SpacingListBox diff --git a/svx/source/sidebar/effect/EffectPropertyPanel.hxx b/svx/source/sidebar/effect/EffectPropertyPanel.hxx index 7edc219a47bd..7cb5422cef49 100644 --- a/svx/source/sidebar/effect/EffectPropertyPanel.hxx +++ b/svx/source/sidebar/effect/EffectPropertyPanel.hxx @@ -11,6 +11,7 @@ #include #include +#include class ColorListBox; diff --git a/svx/source/sidebar/effect/TextEffectPropertyPanel.hxx b/svx/source/sidebar/effect/TextEffectPropertyPanel.hxx index 5966d407b055..bfb6f85a0a2f 100644 --- a/svx/source/sidebar/effect/TextEffectPropertyPanel.hxx +++ b/svx/source/sidebar/effect/TextEffectPropertyPanel.hxx @@ -11,6 +11,7 @@ #include #include +#include class ColorListBox; diff --git a/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx b/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx index 4f4c1adf68b2..8a645d0dc416 100644 --- a/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx +++ b/svx/source/sidebar/graphic/GraphicPropertyPanel.hxx @@ -21,6 +21,7 @@ #include #include +#include #include namespace svx::sidebar { diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx b/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx index e49556f16c59..f8ff548dc421 100644 --- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx +++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx @@ -19,6 +19,7 @@ #pragma once #include +#include class SvxLineSpacingItem; diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx index aa43825c3f22..49928429b3f0 100644 --- a/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx +++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx @@ -30,6 +30,7 @@ #include #include #include +#include class ToolbarUnoDispatcher; diff --git a/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx b/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx index a5485272adbe..42841c6a27ab 100644 --- a/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx +++ b/svx/source/sidebar/paragraph/ParaSpacingWindow.hxx @@ -22,6 +22,7 @@ #include #include #include +#include namespace svx { diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx index 103a331a2379..de66876dc55d 100644 --- a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx +++ b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/svx/source/sidebar/shadow/ShadowPropertyPanel.hxx b/svx/source/sidebar/shadow/ShadowPropertyPanel.hxx index a68405eb0c1b..6a0883c2a182 100644 --- a/svx/source/sidebar/shadow/ShadowPropertyPanel.hxx +++ b/svx/source/sidebar/shadow/ShadowPropertyPanel.hxx @@ -11,6 +11,7 @@ #include #include +#include class ColorListBox; diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.hxx b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx index dc7312f0ea58..4f866aacb000 100644 --- a/svx/source/sidebar/text/TextCharacterSpacingControl.hxx +++ b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTCHARACTERSPACINGCONTROL_HXX #include +#include namespace svx { #define SPACING_NOCUSTOM 0 diff --git a/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.hxx b/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.hxx index 17ae0b55c45e..d93db7b13ca9 100644 --- a/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.hxx +++ b/svx/source/sidebar/textcolumns/TextColumnsPropertyPanel.hxx @@ -11,6 +11,7 @@ #include #include +#include namespace svx::sidebar { diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx index 2e866cbc59a9..e3b0b750564d 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/svx/source/tbxctrls/linemetricbox.hxx b/svx/source/tbxctrls/linemetricbox.hxx index 79be63904a13..653883f4aaf0 100644 --- a/svx/source/tbxctrls/linemetricbox.hxx +++ b/svx/source/tbxctrls/linemetricbox.hxx @@ -19,6 +19,7 @@ #pragma once #include +#include #include class XLineWidthItem; diff --git a/sw/inc/colwd.hxx b/sw/inc/colwd.hxx index 42992a14e8fa..2efafaf84964 100644 --- a/sw/inc/colwd.hxx +++ b/sw/inc/colwd.hxx @@ -18,6 +18,7 @@ */ #pragma once +#include #include #include diff --git a/sw/source/ui/dbui/mmlayoutpage.hxx b/sw/source/ui/dbui/mmlayoutpage.hxx index f891b287485d..2a047c2eea07 100644 --- a/sw/source/ui/dbui/mmlayoutpage.hxx +++ b/sw/source/ui/dbui/mmlayoutpage.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_SOURCE_UI_DBUI_MMLAYOUTPAGE_HXX #include +#include #include #include diff --git a/sw/source/ui/envelp/envprt.hxx b/sw/source/ui/envelp/envprt.hxx index 0321f7308664..b6530b0d1f06 100644 --- a/sw/source/ui/envelp/envprt.hxx +++ b/sw/source/ui/envelp/envprt.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include diff --git a/sw/source/ui/envelp/labfmt.hxx b/sw/source/ui/envelp/labfmt.hxx index 871f8fbbff3b..670ba94b4a1d 100644 --- a/sw/source/ui/envelp/labfmt.hxx +++ b/sw/source/ui/envelp/labfmt.hxx @@ -23,6 +23,7 @@ #include #include +#include #include #include diff --git a/sw/source/ui/inc/regionsw.hxx b/sw/source/ui/inc/regionsw.hxx index e21834fc7759..aacf7aab9098 100644 --- a/sw/source/ui/inc/regionsw.hxx +++ b/sw/source/ui/inc/regionsw.hxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/sw/source/uibase/inc/column.hxx b/sw/source/uibase/inc/column.hxx index 6eabca9db70c..9a2f5158caf9 100644 --- a/sw/source/uibase/inc/column.hxx +++ b/sw/source/uibase/inc/column.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "colex.hxx" #include "prcntfld.hxx" diff --git a/sw/source/uibase/inc/drpcps.hxx b/sw/source/uibase/inc/drpcps.hxx index 3a44fea10b30..f913dca62d4f 100644 --- a/sw/source/uibase/inc/drpcps.hxx +++ b/sw/source/uibase/inc/drpcps.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include /// Dedicated drop caps dialog, opened by the .uno:FormatDropcap UNO command, which is not in the diff --git a/sw/source/uibase/inc/envlop.hxx b/sw/source/uibase/inc/envlop.hxx index d1f3b1310c33..46e6467b8aa4 100644 --- a/sw/source/uibase/inc/envlop.hxx +++ b/sw/source/uibase/inc/envlop.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_ENVLOP_HXX #include +#include #include #include #include "envimg.hxx" diff --git a/sw/source/uibase/inc/frmpage.hxx b/sw/source/uibase/inc/frmpage.hxx index da0e4c215f03..eca60df1a271 100644 --- a/sw/source/uibase/inc/frmpage.hxx +++ b/sw/source/uibase/inc/frmpage.hxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "bmpwin.hxx" #include "prcntfld.hxx" diff --git a/sw/source/uibase/inc/labimp.hxx b/sw/source/uibase/inc/labimp.hxx index f39ac53cf9de..fef5f4d8907d 100644 --- a/sw/source/uibase/inc/labimp.hxx +++ b/sw/source/uibase/inc/labimp.hxx @@ -19,6 +19,7 @@ #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_LABIMP_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_LABIMP_HXX +#include #include inline int getfldval(const weld::MetricSpinButton& rField) diff --git a/sw/source/uibase/inc/linenum.hxx b/sw/source/uibase/inc/linenum.hxx index eaed16129626..48e516bcbf2c 100644 --- a/sw/source/uibase/inc/linenum.hxx +++ b/sw/source/uibase/inc/linenum.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_LINENUM_HXX #include +#include #include "numberingtypelistbox.hxx" class SwView; diff --git a/sw/source/uibase/inc/num.hxx b/sw/source/uibase/inc/num.hxx index 86fb9775a3e2..817f4d431e9c 100644 --- a/sw/source/uibase/inc/num.hxx +++ b/sw/source/uibase/inc/num.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_NUM_HXX #include +#include #include #include "numprevw.hxx" #include diff --git a/sw/source/uibase/inc/optload.hxx b/sw/source/uibase/inc/optload.hxx index b8966e01af9d..30c3fd6ae942 100644 --- a/sw/source/uibase/inc/optload.hxx +++ b/sw/source/uibase/inc/optload.hxx @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/sw/source/uibase/inc/optpage.hxx b/sw/source/uibase/inc/optpage.hxx index d6743aa7e7e8..7747ec808516 100644 --- a/sw/source/uibase/inc/optpage.hxx +++ b/sw/source/uibase/inc/optpage.hxx @@ -21,6 +21,7 @@ #include +#include #include #include #include diff --git a/sw/source/uibase/inc/pgfnote.hxx b/sw/source/uibase/inc/pgfnote.hxx index 77b367230c67..adacd7f5a3cd 100644 --- a/sw/source/uibase/inc/pgfnote.hxx +++ b/sw/source/uibase/inc/pgfnote.hxx @@ -22,6 +22,7 @@ #include #include +#include // footnote settings TabPage class SwFootNotePage final : public SfxTabPage diff --git a/sw/source/uibase/inc/pggrid.hxx b/sw/source/uibase/inc/pggrid.hxx index d3198fe4e9b6..989864a73c7d 100644 --- a/sw/source/uibase/inc/pggrid.hxx +++ b/sw/source/uibase/inc/pggrid.hxx @@ -20,6 +20,7 @@ #include #include "colex.hxx" +#include #include #include #include diff --git a/sw/source/uibase/inc/prcntfld.hxx b/sw/source/uibase/inc/prcntfld.hxx index 77ed9e8dd696..cd13bbb17c40 100644 --- a/sw/source/uibase/inc/prcntfld.hxx +++ b/sw/source/uibase/inc/prcntfld.hxx @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include diff --git a/sw/source/uibase/inc/rowht.hxx b/sw/source/uibase/inc/rowht.hxx index 9c76191dc99b..81c82dd6e26c 100644 --- a/sw/source/uibase/inc/rowht.hxx +++ b/sw/source/uibase/inc/rowht.hxx @@ -18,6 +18,7 @@ */ #pragma once +#include #include class SwWrtShell; diff --git a/sw/source/uibase/inc/swuicnttab.hxx b/sw/source/uibase/inc/swuicnttab.hxx index 47396b6926dd..cc05f12bdc98 100644 --- a/sw/source/uibase/inc/swuicnttab.hxx +++ b/sw/source/uibase/inc/swuicnttab.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/uibase/inc/watermarkdialog.hxx b/sw/source/uibase/inc/watermarkdialog.hxx index 8e42656cfeee..f25fd94278cf 100644 --- a/sw/source/uibase/inc/watermarkdialog.hxx +++ b/sw/source/uibase/inc/watermarkdialog.hxx @@ -10,6 +10,7 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_WATERMARKDIALOG_HXX #include +#include #include #include #include diff --git a/sw/source/uibase/inc/wrap.hxx b/sw/source/uibase/inc/wrap.hxx index f3c1e32a1580..70aeea6b56be 100644 --- a/sw/source/uibase/inc/wrap.hxx +++ b/sw/source/uibase/inc/wrap.hxx @@ -22,6 +22,7 @@ #include #include #include +#include class SwWrtShell; diff --git a/sw/source/uibase/sidebar/PageFormatPanel.hxx b/sw/source/uibase/sidebar/PageFormatPanel.hxx index a1eb2f109bca..27a119b69ead 100644 --- a/sw/source/uibase/sidebar/PageFormatPanel.hxx +++ b/sw/source/uibase/sidebar/PageFormatPanel.hxx @@ -28,6 +28,7 @@ #include #include #include +#include #include diff --git a/sw/source/uibase/sidebar/PageMarginControl.hxx b/sw/source/uibase/sidebar/PageMarginControl.hxx index 6cfb7b05bf7c..0ff3af4cbd91 100644 --- a/sw/source/uibase/sidebar/PageMarginControl.hxx +++ b/sw/source/uibase/sidebar/PageMarginControl.hxx @@ -23,6 +23,7 @@ #include #include +#include #define SWPAGE_NARROW_VALUE 720 #define SWPAGE_NORMAL_VALUE 1136 diff --git a/sw/source/uibase/sidebar/PageSizeControl.hxx b/sw/source/uibase/sidebar/PageSizeControl.hxx index b0e2189ea22c..8baf06ae0e48 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.hxx +++ b/sw/source/uibase/sidebar/PageSizeControl.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include diff --git a/sw/source/uibase/sidebar/TableEditPanel.hxx b/sw/source/uibase/sidebar/TableEditPanel.hxx index 8aee8b4cea6d..3c88a350bab1 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.hxx +++ b/sw/source/uibase/sidebar/TableEditPanel.hxx @@ -15,6 +15,7 @@ #include #include #include +#include namespace sw::sidebar { diff --git a/sw/source/uibase/table/tablepg.hxx b/sw/source/uibase/table/tablepg.hxx index 227f3942b2fe..03a977694e05 100644 --- a/sw/source/uibase/table/tablepg.hxx +++ b/sw/source/uibase/table/tablepg.hxx @@ -22,6 +22,7 @@ #include #include #include +#include class SwWrtShell; class SwTableRep; diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index a8365d08dad9..b9773a1ccb9b 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -585,6 +585,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/weld/EntryTreeView \ vcl/source/weld/IconView \ vcl/source/weld/ItemView \ + vcl/source/weld/MetricSpinButton \ vcl/source/weld/weldutils \ vcl/backendtest/outputdevice/bitmap \ vcl/backendtest/outputdevice/clip \ diff --git a/vcl/inc/colorpicker.hxx b/vcl/inc/colorpicker.hxx index a8a0bc7d4ace..d0c579774f07 100644 --- a/vcl/inc/colorpicker.hxx +++ b/vcl/inc/colorpicker.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index e7ddae417b9a..6e81b372fa00 100644 --- a/vcl/inc/printdlg.hxx +++ b/vcl/inc/printdlg.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx b/vcl/inc/qt5/QtInstanceBuilder.hxx index 5c8c933de107..dce62ebdb414 100644 --- a/vcl/inc/qt5/QtInstanceBuilder.hxx +++ b/vcl/inc/qt5/QtInstanceBuilder.hxx @@ -17,6 +17,7 @@ #include #include +#include #include #include diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index d2c9a283bcdd..814158c5c8dd 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -10,6 +10,7 @@ #include #include +#include #include #include #include diff --git a/vcl/source/weld/MetricSpinButton.cxx b/vcl/source/weld/MetricSpinButton.cxx new file mode 100644 index 000000000000..b51ea8ebe3f7 --- /dev/null +++ b/vcl/source/weld/MetricSpinButton.cxx @@ -0,0 +1,148 @@ +/* -*- 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/. + */ + +#include + +#include +#include +#include +#include + +namespace weld +{ +OUString MetricSpinButton::MetricToString(FieldUnit rUnit) +{ + const FieldUnitStringList& rList = ImplGetFieldUnits(); + // return unit's default string (ie, the first one ) + auto it = std::find_if( + rList.begin(), rList.end(), + [&rUnit](const std::pair& rItem) { return rItem.second == rUnit; }); + if (it != rList.end()) + return it->first; + + return OUString(); +} + +IMPL_LINK_NOARG(MetricSpinButton, spin_button_value_changed, SpinButton&, void) +{ + signal_value_changed(); +} + +IMPL_LINK(MetricSpinButton, spin_button_output, sal_Int64, nValue, OUString) +{ + return format_number(nValue); +} + +void MetricSpinButton::update_width_chars() +{ + sal_Int64 min, max; + m_xSpinButton->get_range(min, max); + auto width = std::max(m_xSpinButton->get_pixel_size(format_number(min)).Width(), + m_xSpinButton->get_pixel_size(format_number(max)).Width()); + int chars = ceil(width / m_xSpinButton->get_approximate_digit_width()); + m_xSpinButton->set_width_chars(chars); +} + +OUString MetricSpinButton::format_number(sal_Int64 nValue) const +{ + OUString aStr; + + const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); + + unsigned int nDecimalDigits = m_xSpinButton->get_digits(); + //pawn percent off to icu to decide whether percent is separated from its number for this locale + if (m_eSrcUnit == FieldUnit::PERCENT) + { + double fValue = nValue; + fValue /= SpinButton::Power10(nDecimalDigits); + aStr = unicode::formatPercent(fValue, rLocaleData.getLanguageTag()); + } + else + { + aStr = rLocaleData.getNum(nValue, nDecimalDigits, true, true); + OUString aSuffix = MetricToString(m_eSrcUnit); + if (m_eSrcUnit != FieldUnit::NONE && m_eSrcUnit != FieldUnit::DEGREE + && m_eSrcUnit != FieldUnit::INCH && m_eSrcUnit != FieldUnit::FOOT) + aStr += " "; + if (m_eSrcUnit == FieldUnit::INCH) + { + OUString sDoublePrime = u"\u2033"_ustr; + if (aSuffix != "\"" && aSuffix != sDoublePrime) + aStr += " "; + else + aSuffix = sDoublePrime; + } + else if (m_eSrcUnit == FieldUnit::FOOT) + { + OUString sPrime = u"\u2032"_ustr; + if (aSuffix != "'" && aSuffix != sPrime) + aStr += " "; + else + aSuffix = sPrime; + } + + assert(m_eSrcUnit != FieldUnit::PERCENT); + aStr += aSuffix; + } + + return aStr; +} + +void MetricSpinButton::set_digits(unsigned int digits) +{ + sal_Int64 step, page; + get_increments(step, page, m_eSrcUnit); + sal_Int64 value = get_value(m_eSrcUnit); + m_xSpinButton->set_digits(digits); + set_increments(step, page, m_eSrcUnit); + set_value(value, m_eSrcUnit); + update_width_chars(); +} + +void MetricSpinButton::set_unit(FieldUnit eUnit) +{ + if (eUnit != m_eSrcUnit) + { + sal_Int64 step, page; + get_increments(step, page, m_eSrcUnit); + sal_Int64 value = get_value(m_eSrcUnit); + m_eSrcUnit = eUnit; + set_increments(step, page, m_eSrcUnit); + set_value(value, m_eSrcUnit); + const OUString sText = format_number(m_xSpinButton->get_value()); + m_xSpinButton->set_text(sText); + update_width_chars(); + } +} + +sal_Int64 MetricSpinButton::ConvertValue(sal_Int64 nValue, FieldUnit eInUnit, + FieldUnit eOutUnit) const +{ + return vcl::ConvertValue(nValue, 0, m_xSpinButton->get_digits(), eInUnit, eOutUnit); +} + +IMPL_LINK(MetricSpinButton, spin_button_input, const OUString&, rText, std::optional) +{ + const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); + double fResult(0.0); + bool bRet + = vcl::TextToValue(rText, fResult, 0, m_xSpinButton->get_digits(), rLocaleData, m_eSrcUnit); + if (!bRet) + return {}; + + if (fResult > SAL_MAX_INT32) + fResult = SAL_MAX_INT32; + else if (fResult < SAL_MIN_INT32) + fResult = SAL_MIN_INT32; + + return std::optional(std::round(fResult)); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index fb2f0ad95b5e..5a6d0630fbb0 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -19,13 +19,11 @@ #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -281,39 +279,6 @@ weld::Window* Application::GetFrameWeld(const css::uno::Reference& rItem) { return rItem.second == rUnit; }); - if (it != rList.end()) - return it->first; - - return OUString(); - } - - IMPL_LINK_NOARG(MetricSpinButton, spin_button_value_changed, SpinButton&, void) - { - signal_value_changed(); - } - - IMPL_LINK(MetricSpinButton, spin_button_output, sal_Int64, nValue, OUString) - { - return format_number(nValue); - } - - void MetricSpinButton::update_width_chars() - { - sal_Int64 min, max; - m_xSpinButton->get_range(min, max); - auto width = std::max(m_xSpinButton->get_pixel_size(format_number(min)).Width(), - m_xSpinButton->get_pixel_size(format_number(max)).Width()); - int chars = ceil(width / m_xSpinButton->get_approximate_digit_width()); - m_xSpinButton->set_width_chars(chars); - } - unsigned int SpinButton::Power10(unsigned int n) { unsigned int nValue = 1; @@ -339,98 +304,6 @@ namespace weld return (nValue + nHalf) / nFactor; } - OUString MetricSpinButton::format_number(sal_Int64 nValue) const - { - OUString aStr; - - const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); - - unsigned int nDecimalDigits = m_xSpinButton->get_digits(); - //pawn percent off to icu to decide whether percent is separated from its number for this locale - if (m_eSrcUnit == FieldUnit::PERCENT) - { - double fValue = nValue; - fValue /= SpinButton::Power10(nDecimalDigits); - aStr = unicode::formatPercent(fValue, rLocaleData.getLanguageTag()); - } - else - { - aStr = rLocaleData.getNum(nValue, nDecimalDigits, true, true); - OUString aSuffix = MetricToString(m_eSrcUnit); - if (m_eSrcUnit != FieldUnit::NONE && m_eSrcUnit != FieldUnit::DEGREE && m_eSrcUnit != FieldUnit::INCH && m_eSrcUnit != FieldUnit::FOOT) - aStr += " "; - if (m_eSrcUnit == FieldUnit::INCH) - { - OUString sDoublePrime = u"\u2033"_ustr; - if (aSuffix != "\"" && aSuffix != sDoublePrime) - aStr += " "; - else - aSuffix = sDoublePrime; - } - else if (m_eSrcUnit == FieldUnit::FOOT) - { - OUString sPrime = u"\u2032"_ustr; - if (aSuffix != "'" && aSuffix != sPrime) - aStr += " "; - else - aSuffix = sPrime; - } - - assert(m_eSrcUnit != FieldUnit::PERCENT); - aStr += aSuffix; - } - - return aStr; - } - - void MetricSpinButton::set_digits(unsigned int digits) - { - sal_Int64 step, page; - get_increments(step, page, m_eSrcUnit); - sal_Int64 value = get_value(m_eSrcUnit); - m_xSpinButton->set_digits(digits); - set_increments(step, page, m_eSrcUnit); - set_value(value, m_eSrcUnit); - update_width_chars(); - } - - void MetricSpinButton::set_unit(FieldUnit eUnit) - { - if (eUnit != m_eSrcUnit) - { - sal_Int64 step, page; - get_increments(step, page, m_eSrcUnit); - sal_Int64 value = get_value(m_eSrcUnit); - m_eSrcUnit = eUnit; - set_increments(step, page, m_eSrcUnit); - set_value(value, m_eSrcUnit); - const OUString sText = format_number(m_xSpinButton->get_value()); - m_xSpinButton->set_text(sText); - update_width_chars(); - } - } - - sal_Int64 MetricSpinButton::ConvertValue(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit) const - { - return vcl::ConvertValue(nValue, 0, m_xSpinButton->get_digits(), eInUnit, eOutUnit); - } - - IMPL_LINK(MetricSpinButton, spin_button_input, const OUString&, rText, std::optional) - { - const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); - double fResult(0.0); - bool bRet = vcl::TextToValue(rText, fResult, 0, m_xSpinButton->get_digits(), rLocaleData, m_eSrcUnit); - if (!bRet) - return {}; - - if (fResult > SAL_MAX_INT32) - fResult = SAL_MAX_INT32; - else if (fResult < SAL_MIN_INT32) - fResult = SAL_MIN_INT32; - - return std::optional(std::round(fResult)); - } - size_t GetAbsPos(const weld::TreeView& rTreeView, const weld::TreeIter& rIter) { size_t nAbsPos = 0; diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index d010cfe46253..43b96034b50c 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include