27 #include <com/sun/star/lang/IllegalArgumentException.hpp>
34 NumberFormatPropertyPanel::NumberFormatPropertyPanel(
36 const css::uno::Reference<css::frame::XFrame>& rxFrame,
38 :
PanelLayout(pParent,
"NumberFormatPropertyPanel",
"modules/scalc/ui/sidebarnumberformat.ui")
39 , mxLbCategory(m_xBuilder->weld_combo_box(
"numberformatcombobox"))
40 , mxTBCategory(m_xBuilder->weld_toolbar(
"numberformat"))
42 , mxFtDecimals(m_xBuilder->weld_label(
"decimalplaceslabel"))
43 , mxEdDecimals(m_xBuilder->weld_spin_button(
"decimalplaces"))
44 , mxFtDenominator(m_xBuilder->weld_label(
"denominatorplaceslabel"))
45 , mxEdDenominator(m_xBuilder->weld_spin_button(
"denominatorplaces"))
46 , mxFtLeadZeroes(m_xBuilder->weld_label(
"leadingzeroeslabel"))
47 , mxEdLeadZeroes(m_xBuilder->weld_spin_button(
"leadingzeroes"))
48 , mxBtnNegRed(m_xBuilder->weld_check_button(
"negativenumbersred"))
49 , mxBtnThousand(m_xBuilder->weld_check_button(
"thousandseparator"))
50 , mxBtnEngineering(m_xBuilder->weld_check_button(
"engineeringnotation"))
51 , maNumFormatControl(SID_NUMBER_TYPE_FORMAT, *pBindings, *this)
52 , maFormatControl(SID_NUMBER_FORMAT, *pBindings, *this)
53 , mnCategorySelected(0)
54 , mpBindings(pBindings)
96 const sal_Int32 nVal = rBox.get_active();
97 if( nVal != mnCategorySelected )
101 SfxCallMode::RECORD, { &aItem });
102 mnCategorySelected = nVal;
108 NumFormatValueHdl(*mxEdDecimals);
114 OUString sBreak =
",";
115 bool bThousand = ( mxBtnThousand->get_visible() && mxBtnThousand->get_sensitive() && mxBtnThousand->get_active() )
116 || ( mxBtnEngineering->get_visible() && mxBtnEngineering->get_sensitive() && mxBtnEngineering->get_active() );
117 bool bNegRed = mxBtnNegRed->get_sensitive() && mxBtnNegRed->get_active();
118 sal_uInt16 nPrecision = (mxEdDecimals->get_sensitive() && mxEdDecimals->get_visible())
119 ? static_cast<sal_uInt16>(mxEdDecimals->get_value())
120 : (mxEdDenominator->get_sensitive() && mxEdDenominator->get_visible())
121 ? static_cast<sal_uInt16>(mxEdDenominator->get_value())
123 sal_uInt16 nLeadZeroes = (mxEdLeadZeroes->get_sensitive())
124 ? static_cast<sal_uInt16>(mxEdLeadZeroes->get_value())
127 OUString sThousand = OUString::number(static_cast<sal_Int32>(bThousand));
128 OUString sNegRed = OUString::number(static_cast<sal_Int32>(bNegRed));
129 OUString sPrecision = OUString::number(nPrecision);
130 OUString sLeadZeroes = OUString::number(nLeadZeroes);
132 aFormat += sThousand +
143 SfxCallMode::RECORD, { &aItem });
148 const css::uno::Reference<css::frame::XFrame>& rxFrame,
151 if (pParent ==
nullptr)
152 throw lang::IllegalArgumentException(
"no parent Window given to NumberFormatPropertyPanel::Create",
nullptr, 0);
154 throw lang::IllegalArgumentException(
"no XFrame given to NumberFormatPropertyPanel::Create",
nullptr, 1);
155 if (pBindings ==
nullptr)
156 throw lang::IllegalArgumentException(
"no SfxBindings given to NumberFormatPropertyPanel::Create",
nullptr, 2);
158 return std::make_unique<NumberFormatPropertyPanel>(pParent, rxFrame, pBindings);
180 case SID_NUMBER_TYPE_FORMAT:
182 if( eState >= SfxItemState::DEFAULT)
185 sal_uInt16 nVal = pItem->
GetValue();
191 bool bIsScientific ( nVal == 6 );
192 bool bIsFraction ( nVal == 7 );
193 bool bIsTime ( nVal == 5 );
223 case SID_NUMBER_FORMAT:
225 bool bThousand =
false;
226 bool bNegRed =
false;
227 sal_uInt16 nPrecision = 0;
228 sal_uInt16 nLeadZeroes = 0;
229 if( eState >= SfxItemState::DEFAULT)
232 const OUString& aCode = pItem->
GetValue();
234 sal_Int32 aFormat[4] = {0};
235 for (sal_Int32 & rn : aFormat)
241 bThousand =
static_cast<bool>(aFormat[0]);
242 bNegRed =
static_cast<bool>(aFormat[1]);
243 nPrecision =
static_cast<sal_uInt16
>(aFormat[2]);
244 nLeadZeroes =
static_cast<sal_uInt16
>(aFormat[3]);
#define LINK(Instance, Class, Member)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
virtual SfxBindings & GetBindings() override
sal_Int16 GetValue() const
const OUString & GetValue() const
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
SfxDispatcher * GetDispatcher() const