28#include <svx/svxids.hrc>
31#include <numcategories.hrc>
42#include <com/sun/star/frame/XModel.hpp>
43#include <com/sun/star/lang/XServiceInfo.hpp>
47using ::com::sun::star::uno::Reference;
48using ::com::sun::star::lang::XServiceInfo;
49using ::com::sun::star::uno::UNO_QUERY;
51#define NUMKEY_UNDEFINED SAL_MAX_UINT32
57 SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO,
58 SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA,
59 SID_ATTR_NUMBERFORMAT_NOLANGUAGE, SID_ATTR_NUMBERFORMAT_NOLANGUAGE,
60 SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE>);
152 rRenderContext.
Erase();
161 rRenderContext.
SetFont(aDrawFont);
167 int nNumCharsToInsert = 0;
169 nNumCharsToInsert = nLeadSpace / nCharWidth;
171 if (nNumCharsToInsert > 0)
173 for (
int i = 0;
i < nNumCharsToInsert; ++
i)
174 aTmpStr = aTmpStr.replaceAt(
mnPos, 0, rtl::OUStringChar(
mnChar));
179 if (
mnPos == -1 && nLeadSpace > 0)
185 rRenderContext.
DrawText(aPosText, aTmpStr);
186 rRenderContext.
Pop();
191#define REMOVE_DONTKNOW() \
192 if (!m_xFtLanguage->get_sensitive()) \
194 m_xFtLanguage->set_sensitive(true); \
195 m_xLbLanguage->set_sensitive(true); \
196 m_xLbLanguage->set_active_id(pNumFmtShell->GetCurLanguage()); \
201 :
SfxTabPage(pPage, pController,
"cui/ui/numberingformatpage.ui",
"NumberingFormatPage", &rCoreAttrs)
202 , nInitFormat(
std::numeric_limits<sal_uInt32>::
max())
204 , bLegacyAutomaticCurrency(false)
205 , sAutomaticLangEntry(
CuiResId(RID_CUISTR_AUTO_ENTRY))
206 , m_xFtCategory(m_xBuilder->weld_label(
"categoryft"))
207 , m_xLbCategory(m_xBuilder->weld_tree_view(
"categorylb"))
208 , m_xFtFormat(m_xBuilder->weld_label(
"formatft"))
209 , m_xLbCurrency(m_xBuilder->weld_combo_box(
"currencylb"))
210 , m_xLbFormat(m_xBuilder->weld_tree_view(
"formatlb"))
211 , m_xFtLanguage(m_xBuilder->weld_label(
"languageft"))
212 , m_xCbSourceFormat(m_xBuilder->weld_check_button(
"sourceformat"))
213 , m_xFtOptions(m_xBuilder->weld_label(
"optionsft"))
214 , m_xFtDecimals(m_xBuilder->weld_label(
"decimalsft"))
215 , m_xEdDecimals(m_xBuilder->weld_spin_button(
"decimalsed"))
216 , m_xFtDenominator(m_xBuilder->weld_label(
"denominatorft"))
217 , m_xEdDenominator(m_xBuilder->weld_spin_button(
"denominatored"))
218 , m_xBtnNegRed(m_xBuilder->weld_check_button(
"negnumred"))
219 , m_xFtLeadZeroes(m_xBuilder->weld_label(
"leadzerosft"))
220 , m_xEdLeadZeroes(m_xBuilder->weld_spin_button(
"leadzerosed"))
221 , m_xBtnThousand(m_xBuilder->weld_check_button(
"thousands"))
222 , m_xBtnEngineering(m_xBuilder->weld_check_button(
"engineering"))
223 , m_xFormatCodeFrame(m_xBuilder->weld_widget(
"formatcode"))
224 , m_xEdFormat(m_xBuilder->weld_entry(
"formatted"))
225 , m_xIbAdd(m_xBuilder->weld_button(
"add"))
226 , m_xIbInfo(m_xBuilder->weld_button(
"edit"))
227 , m_xIbRemove(m_xBuilder->weld_button(
"delete"))
228 , m_xFtComment(m_xBuilder->weld_label(
"commentft"))
229 , m_xEdComment(m_xBuilder->weld_entry(
"commented"))
230 , m_xLbLanguage(new
SvxLanguageBox(m_xBuilder->weld_combo_box(
"languagelb")))
231 , m_xWndPreview(new
weld::CustomWeld(*m_xBuilder,
"preview", m_aWndPreview))
233 for (
size_t i = 0;
i < std::size(NUM_CATEGORIES); ++
i)
236 auto nWidth =
m_xLbCategory->get_approximate_digit_width() * 22;
317 m_xLbLanguage->SetLanguageList(SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN,
319 css::i18n::ScriptType::WEAK);
325 return std::make_unique<SvxNumberFormatTabPage>(pPage, pController, *rAttrSet);
343 static_assert(
SELPOS_NONE == -1,
"SELPOS_NONE was -1 at time of writing");
357 static_assert(
SELPOS_NONE == -1,
"SELPOS_NONE was -1 at time of writing");
370 sal_uInt16 nCatLbSelPos = 0;
371 sal_uInt16 nFmtLbSelPos = 0;
373 std::vector<OUString> aFmtEntryList;
375 double nValDouble = 0;
380 if(pBoolLangItem->GetValue())
393 if(eState==SfxItemState::SET)
413 if(eState==SfxItemState::SET)
417 if(pBoolItem!=
nullptr)
425 if ( eState == SfxItemState::SET )
449 if ( SfxItemState::DONTCARE != eState )
450 pValFmtAttr =
GetItem( *
rSet, SID_ATTR_NUMBERFORMAT_VALUE );
452 eValType =
pNumItem->GetValueType();
456 case SvxNumberValueType::String:
457 aValString =
pNumItem->GetValueString();
459 case SvxNumberValueType::Number:
461 aValString =
pNumItem->GetValueString();
462 nValDouble =
pNumItem->GetValueDouble();
464 case SvxNumberValueType::Undefined:
473 : std::numeric_limits<sal_uInt32>::max();
476 if ( eValType == SvxNumberValueType::String )
491 bool bUseStarFormat =
false;
495 Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY );
497 bUseStarFormat = xSI->supportsService(
"com.sun.star.sheet.SpreadsheetDocument");
503 OUString aPrevString;
504 const Color* pDummy =
nullptr;
505 pNumFmtShell->GetInitSettings( nCatLbSelPos, eLangType, nFmtLbSelPos,
506 aFmtEntryList, aPrevString, pDummy );
524 if(SfxItemState::SET == eState)
525 pAutoEntryAttr =
GetItem( *
rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO );
707 else if(SfxItemState::DEFAULT == eItemState)
716 std::vector<sal_uInt32>
const & aDelFormats =
pNumFmtShell->GetUpdateData();
718 if ( !aDelFormats.empty() )
721 pNumItem->SetDelFormats( std::vector(aDelFormats) );
743 GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE );
744 bool bOld = pBoolItem && pBoolItem->
GetValue();
748 _eItemState != SfxItemState::SET);
768 return DeactivateRC::LeavePage;
779 if (rEntries.empty())
811 for ( ;
i < rEntries.size(); ++
i )
813 aEntry = rEntries[
i];
814 short aPrivCat =
pNumFmtShell->GetCategory4Entry(
static_cast<short>(
i) );
817 const Color* pPreviewColor =
nullptr;
848 sal_Int32 nCurCategory =
m_xLbCategory->get_selected_index();
849 sal_uInt16 nCategory =
static_cast<sal_uInt16
>(nCurCategory);
850 sal_uInt16 nDecimals = 0;
851 sal_uInt16 nZeroes = 0;
852 bool bNegRed =
false;
853 bool bThousand =
false;
867 sal_uInt16 nTstPos=
pNumFmtShell->FindCurrencyFormat(theFormat);
868 if(nCurrencyPos!=
static_cast<sal_Int32
>(nTstPos) && nTstPos!=sal_uInt16(-1))
876 if ( nCategory != nCurCategory || bDoIt)
878 if ( bCheckCatChange )
907 sal_uInt16 nIntDigits =
pNumFmtShell->GetFormatIntegerDigits(theFormat);
908 bThousand = (nIntDigits > 0) && (nIntDigits % 3 == 0);
994 std::vector<OUString> aEntryList;
995 short nFmtLbSelPos = 0;
1015 pNumFmtShell->CategoryChanged(nTmpCatPos,nFmtLbSelPos, aEntryList);
1019 nFmtLbSelPos,aEntryList);
1024 if ( (!aEntryList.empty()) && (nFmtLbSelPos !=
SELPOS_NONE) )
1028 OUString aFormat=aEntryList[nFmtLbSelPos];
1041 if(
pNumFmtShell->GetComment4Entry(nFmtLbSelPos).isEmpty())
1055 m_xLbFormat->select(
static_cast<sal_uInt16
>(nFmtLbSelPos));
1060 if(
pNumFmtShell->GetComment4Entry(nFmtLbSelPos).isEmpty())
1125 SelFormatHdl_Impl(&rLb);
1128 assert(pController);
1149 SelFormatHdl_Impl(&rLb);
1154 SelFormatHdl_Impl(&rLb);
1159 SelFormatHdl_Impl(&rLb);
1173 LostFocusHdl_Impl(*pLb);
1191 sal_Int32 nTmpCatPos;
1209 short nFmtLbSelPos =
static_cast<short>(nSelPos);
1211 OUString aFormat =
pNumFmtShell->GetFormat4Entry(nFmtLbSelPos);
1212 OUString aComment =
pNumFmtShell->GetComment4Entry(nFmtLbSelPos);
1216 if(aComment.isEmpty())
1222 if ( !aFormat.isEmpty() )
1235 bool bIsUserDef=
pNumFmtShell->IsUserDefined( aFormat );
1296 constexpr sal_uInt8 nReturnChanged = 0x1;
1298 constexpr sal_uInt8 nReturnOneArea = 0x4;
1304 std::vector<OUString> aEntryList;
1305 std::vector<OUString> a2EntryList;
1306 sal_uInt16 nCatLbSelPos = 0;
1308 sal_Int32 nErrPos=0;
1311 bool bAdded =
pNumFmtShell->AddFormat( aFormat, nErrPos,
1312 nCatLbSelPos, nFmtLbSelPos,
1315 nReturn |= nReturnChanged | nReturnAdded;
1336 if(bAdded) aEntryList.clear();
1341 a2EntryList.clear();
1344 nReturn |= nReturnOneArea;
1367 m_xLbFormat->select(
static_cast<sal_uInt16
>(nFmtLbSelPos));
1382 nReturn = ((nReturn & nReturnOneArea) ? 0 : (nReturn & nReturnChanged));
1385 a2EntryList.clear();
1390 std::vector<OUString> aEntryList;
1391 sal_uInt16 nCatLbSelPos = 0;
1403 aFormat = aEntryList[nFmtLbSelPos];
1415 m_xLbFormat->select(
static_cast<sal_uInt16
>(nFmtLbSelPos));
1470 EditHdl_Impl(&rEdit);
1499 sal_uInt16 nTmpCurPos=
pNumFmtShell->FindCurrencyFormat(aFormat );
1500 if (nTmpCurPos != sal_uInt16(-1))
1503 short nPosi=
pNumFmtShell->GetListPos4Entry( nCurKey, aFormat);
1505 m_xLbFormat->select(
static_cast<sal_uInt16
>(nPosi));
1541 OptHdl_Impl(&rOptCtrl);
1546 OptHdl_Impl(&rEdit);
1578 nPrecision, nLeadZeroes,
1579 static_cast<sal_uInt16
>(
m_xLbFormat->get_selected_index()) );
1616 const bool bAddSensitive = m_xIbAdd->get_sensitive();
1617 if (bAddSensitive || m_nLbFormatSelPosEdComment !=
SELPOS_NONE)
1619 m_xFtComment->set_label(m_xEdComment->get_text());
1621 m_xEdComment->hide();
1622 m_xFtComment->show();
1626 pNumFmtShell->SetComment4Entry( m_nLbFormatSelPosEdComment, m_xEdComment->get_text());
1632 OUString sEntry = m_xLbCategory->n_children() > 1 ? m_xLbCategory->get_text(1) : OUString();
1633 m_xEdComment->set_text(sEntry);
1649 const Color*& rpPreviewColor,
const OUString& rFormatStr,
short nTmpCatPos)
1654 case CAT_ALL:
i=SvxNumValCategory::Standard;
break;
1656 case CAT_NUMBER:
i=SvxNumValCategory::Standard;
break;
1662 case CAT_DATE:
i=SvxNumValCategory::Date;
break;
1664 case CAT_TIME:
i=SvxNumValCategory::Time;
break;
1675 default:
i=SvxNumValCategory::NoValue;
break;
1681 rFormatStr.indexOf(
"NatNum12") >= 0 )
1689 OUString aPreviewString;
1690 pNumFmtShell->MakePrevStringFromVal( rFormatStr, aPreviewString, rpPreviewColor, fVal );
1691 return aPreviewString;
1696 OUString aPreviewString;
1697 const Color* pPreviewColor =
nullptr;
1698 pNumFmtShell->MakePreviewString( rFormat, aPreviewString, pPreviewColor );
1704 OUString aPreviewString;
1705 const Color* pPreviewColor =
nullptr;
1712 std::vector<OUString> aList;
1714 sal_uInt16 nSelPos=0;
1720 for (std::vector<OUString>::iterator
i = aList.begin() + 1;
i != aList.end(); ++
i)
1730 sal_uInt16 nTmpCatPos;
sal_uInt32 GetValue() const
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetTextColor(const Color &rColor)
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
virtual weld::Button & GetOKButton() const=0
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
void PutItem(const SfxPoolItem &rItem)
const SfxItemSet & GetItemSet() const
void SetExchangeSupport()
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void UpdateFormatListBox_Impl(bool bCat, bool bUpdateEdit)
std::unique_ptr< weld::CheckButton > m_xCbSourceFormat
void AddAutomaticLanguage_Impl(LanguageType eAutoLang, bool bSelect)
std::unique_ptr< weld::CheckButton > m_xBtnNegRed
virtual void PageCreated(const SfxAllItemSet &aSet) override
void FillFormatListBox_Impl(std::vector< OUString > &rEntries)
OUString sAutomaticLangEntry
std::unique_ptr< weld::TreeView > m_xLbCategory
std::unique_ptr< weld::CustomWeld > m_xWndPreview
std::unique_ptr< weld::CheckButton > m_xBtnThousand
std::unique_ptr< SvxLanguageBox > m_xLbLanguage
void UpdateOptions_Impl(bool bCheckCatChange)
std::unique_ptr< weld::Label > m_xFtComment
std::unique_ptr< weld::Button > m_xIbRemove
virtual void Reset(const SfxItemSet *rSet) override
void ChangePreviewText(sal_uInt16 nPos)
std::unique_ptr< weld::Widget > m_xFormatCodeFrame
void SelFormatHdl_Impl(weld::Widget *)
SvxNumberPreview m_aWndPreview
void set_active_currency(sal_Int32 nCurCurrencyEntryPos)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
std::unique_ptr< SvxNumberInfoItem > pNumItem
void EnableBySourceFormat_Impl()
std::unique_ptr< weld::SpinButton > m_xEdDecimals
sal_uInt32 get_active_currency() const
static const WhichRangesContainer pRanges
std::unique_ptr< SvxNumberFormatShell > pNumFmtShell
std::unique_ptr< weld::TreeView > m_xLbFormat
short m_nLbFormatSelPosEdComment
SvxNumberFormatTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreAttrs)
void UpdateDecimalsDenominatorEditBox()
Change visible Edit box and Fixed text according to category format if fraction format "Denominator p...
virtual ~SvxNumberFormatTabPage() override
bool Click_Impl(const weld::Button &rIB)
void EditHdl_Impl(const weld::Entry *)
std::unique_ptr< weld::Entry > m_xEdFormat
void HideLanguage(bool bFlag=true)
std::unique_ptr< weld::SpinButton > m_xEdLeadZeroes
std::unique_ptr< weld::Button > m_xIbAdd
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
std::unique_ptr< weld::ComboBox > m_xLbCurrency
std::unique_ptr< weld::Label > m_xFtCategory
void UpdateThousandEngineeringCheckBox()
Change visible checkbox according to category format if scientific format "Engineering notation" else...
virtual bool FillItemSet(SfxItemSet *rSet) override
void SetCategory(sal_uInt16 nPos)
std::unique_ptr< weld::Label > m_xFtDecimals
std::unique_ptr< weld::Entry > m_xEdComment
std::unique_ptr< weld::Label > m_xFtDenominator
std::unique_ptr< weld::Label > m_xFtLeadZeroes
bool bLegacyAutomaticCurrency
std::unique_ptr< weld::Label > m_xFtLanguage
std::unique_ptr< weld::CheckButton > m_xBtnEngineering
void OptHdl_Impl(const weld::Widget *)
OUString sAutomaticCurrencyEntry
std::unique_ptr< weld::Label > m_xFtFormat
std::unique_ptr< weld::SpinButton > m_xEdDenominator
void MakePreviewText(const OUString &rFormat)
std::unique_ptr< weld::Button > m_xIbInfo
std::unique_ptr< weld::Label > m_xFtOptions
OUString GetExpColorString(const Color *&rpPreviewColor, const OUString &aFormatStr, short nTmpCatPos)
bool bNumItemFlag
for handling with DocShell
virtual SvxNumberInfoItem * Clone(SfxItemPool *pPool=nullptr) const override
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override
void NotifyChange(const OUString &rPrevStr, const Color *pColor=nullptr)
void SetTransparent(bool bTransparent)
void SetColor(const Color &)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
const o3tl::enumarray< SvxNumValCategory, double > fSvxNumValConst
#define LANGUAGE_DONTKNOW
#define LANGUAGE_NORWEGIAN
#define LINK(Instance, Class, Member)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
static constexpr auto Items
IMPL_LINK(SvxNumberFormatTabPage, DoubleClickHdl_Impl, weld::TreeView &, rLb, bool)
#define REMOVE_DONTKNOW()
IMPL_LINK_NOARG(SvxNumberFormatTabPage, LostFocusHdl_Impl, weld::Widget &, void)