28#include <com/sun/star/lang/IllegalArgumentException.hpp>
31using namespace css::uno;
37 const css::uno::Reference<css::frame::XFrame>& rxFrame,
39 :
PanelLayout(pParent,
"NumberFormatPropertyPanel",
"modules/scalc/ui/sidebarnumberformat.ui")
40 , mxLbCategory(m_xBuilder->weld_combo_box(
"numberformatcombobox"))
41 , mxTBCategory(m_xBuilder->weld_toolbar(
"numberformat"))
43 , mxFtDecimals(m_xBuilder->weld_label(
"decimalplaceslabel"))
44 , mxEdDecimals(m_xBuilder->weld_spin_button(
"decimalplaces"))
45 , mxFtDenominator(m_xBuilder->weld_label(
"denominatorplaceslabel"))
46 , mxEdDenominator(m_xBuilder->weld_spin_button(
"denominatorplaces"))
47 , mxFtLeadZeroes(m_xBuilder->weld_label(
"leadingzeroeslabel"))
48 , mxEdLeadZeroes(m_xBuilder->weld_spin_button(
"leadingzeroes"))
49 , mxBtnNegRed(m_xBuilder->weld_check_button(
"negativenumbersred"))
50 , mxBtnThousand(m_xBuilder->weld_check_button(
"thousandseparator"))
51 , mxBtnEngineering(m_xBuilder->weld_check_button(
"engineeringnotation"))
52 , maNumFormatControl(SID_NUMBER_TYPE_FORMAT, *pBindings, *this)
53 , maFormatControl(SID_NUMBER_FORMAT, *pBindings, *this)
54 , mnCategorySelected(0)
55 , mpBindings(pBindings)
97 const sal_Int32 nVal = rBox.get_active();
98 if( nVal != mnCategorySelected )
102 SfxCallMode::RECORD, { &aItem });
103 mnCategorySelected = nVal;
109 NumFormatValueHdl(*mxEdDecimals);
115 OUString sBreak =
",";
116 bool bThousand = ( mxBtnThousand->get_visible() && mxBtnThousand->get_sensitive() && mxBtnThousand->get_active() )
117 || ( mxBtnEngineering->get_visible() && mxBtnEngineering->get_sensitive() && mxBtnEngineering->get_active() );
118 bool bNegRed = mxBtnNegRed->get_sensitive() && mxBtnNegRed->get_active();
119 sal_uInt16 nPrecision = (mxEdDecimals->get_sensitive() && mxEdDecimals->get_visible())
120 ?
static_cast<sal_uInt16
>(mxEdDecimals->get_value())
121 : (mxEdDenominator->get_sensitive() && mxEdDenominator->get_visible())
122 ?
static_cast<sal_uInt16
>(mxEdDenominator->get_value())
124 sal_uInt16 nLeadZeroes = (mxEdLeadZeroes->get_sensitive())
125 ?
static_cast<sal_uInt16
>(mxEdLeadZeroes->get_value())
128 OUString sThousand = OUString::number(
static_cast<sal_Int32
>(bThousand));
129 OUString sNegRed = OUString::number(
static_cast<sal_Int32
>(bNegRed));
130 OUString sPrecision = OUString::number(nPrecision);
131 OUString sLeadZeroes = OUString::number(nLeadZeroes);
133 aFormat += sThousand +
144 SfxCallMode::RECORD, { &aItem });
149 const css::uno::Reference<css::frame::XFrame>& rxFrame,
152 if (pParent ==
nullptr)
153 throw lang::IllegalArgumentException(
"no parent Window given to NumberFormatPropertyPanel::Create",
nullptr, 0);
155 throw lang::IllegalArgumentException(
"no XFrame given to NumberFormatPropertyPanel::Create",
nullptr, 1);
156 if (pBindings ==
nullptr)
157 throw lang::IllegalArgumentException(
"no SfxBindings given to NumberFormatPropertyPanel::Create",
nullptr, 2);
159 return std::make_unique<NumberFormatPropertyPanel>(pParent, rxFrame, pBindings);
181 case SID_NUMBER_TYPE_FORMAT:
183 if( eState >= SfxItemState::DEFAULT)
186 sal_uInt16 nVal = pItem->
GetValue();
199 bool bIsTime ( nCategory ==
CAT_TIME );
229 case SID_NUMBER_FORMAT:
231 bool bThousand =
false;
232 bool bNegRed =
false;
233 sal_uInt16 nPrecision = 0;
234 sal_uInt16 nLeadZeroes = 0;
235 bool bNatNum12 =
false;
237 if( eState >= SfxItemState::DEFAULT)
240 const OUString& aCode = pItem->
GetValue();
242 sal_Int32 aFormat[5] = {0};
243 for (sal_Int32 & rn : aFormat)
249 bThousand =
static_cast<bool>(aFormat[0]);
250 bNegRed =
static_cast<bool>(aFormat[1]);
251 nPrecision =
static_cast<sal_uInt16
>(aFormat[2]);
252 nLeadZeroes =
static_cast<sal_uInt16
>(aFormat[3]);
253 bNatNum12 =
static_cast< bool >( aFormat[4] );
sal_uInt16 GetValue() const
const OUString & GetValue() const
SfxDispatcher * GetDispatcher() const
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 * >())
virtual SfxBindings & GetBindings() override
#define LINK(Instance, Class, Member)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)