28 #include <svx/svxids.hrc>
31 #include <numcategories.hrc>
32 #include <strings.hrc>
38 #include <dialmgr.hxx>
42 #include <com/sun/star/frame/XModel.hpp>
43 #include <com/sun/star/lang/XServiceInfo.hpp>
47 using ::com::sun::star::uno::Reference;
48 using ::com::sun::star::lang::XServiceInfo;
49 using ::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>);
116 aPrevCol = pColor ? *pColor : aWindowTextColor;
146 rRenderContext.
SetFont(aDrawFont);
152 int nNumCharsToInsert = 0;
154 nNumCharsToInsert = nLeadSpace / nCharWidth;
156 if (nNumCharsToInsert > 0)
158 for (
int i = 0;
i < nNumCharsToInsert; ++
i)
159 aTmpStr = aTmpStr.replaceAt(
mnPos, 0, rtl::OUStringChar(
mnChar));
164 if (
mnPos == -1 && nLeadSpace > 0)
170 rRenderContext.
DrawText(aPosText, aTmpStr);
171 rRenderContext.
Pop();
176 #define REMOVE_DONTKNOW() \
177 if (!m_xFtLanguage->get_sensitive()) \
179 m_xFtLanguage->set_sensitive(true); \
180 m_xLbLanguage->set_sensitive(true); \
181 m_xLbLanguage->set_active_id(pNumFmtShell->GetCurLanguage()); \
186 :
SfxTabPage(pPage, pController,
"cui/ui/numberingformatpage.ui",
"NumberingFormatPage", &rCoreAttrs)
187 , nInitFormat(
std::numeric_limits<sal_uInt32>::
max())
189 , bLegacyAutomaticCurrency(
false)
190 , sAutomaticLangEntry(
CuiResId(RID_CUISTR_AUTO_ENTRY))
191 , m_xFtCategory(m_xBuilder->weld_label(
"categoryft"))
192 , m_xLbCategory(m_xBuilder->weld_tree_view(
"categorylb"))
193 , m_xFtFormat(m_xBuilder->weld_label(
"formatft"))
194 , m_xLbCurrency(m_xBuilder->weld_combo_box(
"currencylb"))
195 , m_xLbFormat(m_xBuilder->weld_tree_view(
"formatlb"))
196 , m_xFtLanguage(m_xBuilder->weld_label(
"languageft"))
197 , m_xCbSourceFormat(m_xBuilder->weld_check_button(
"sourceformat"))
198 , m_xFtOptions(m_xBuilder->weld_label(
"optionsft"))
199 , m_xFtDecimals(m_xBuilder->weld_label(
"decimalsft"))
200 , m_xEdDecimals(m_xBuilder->weld_spin_button(
"decimalsed"))
201 , m_xFtDenominator(m_xBuilder->weld_label(
"denominatorft"))
202 , m_xEdDenominator(m_xBuilder->weld_spin_button(
"denominatored"))
203 , m_xBtnNegRed(m_xBuilder->weld_check_button(
"negnumred"))
204 , m_xFtLeadZeroes(m_xBuilder->weld_label(
"leadzerosft"))
205 , m_xEdLeadZeroes(m_xBuilder->weld_spin_button(
"leadzerosed"))
206 , m_xBtnThousand(m_xBuilder->weld_check_button(
"thousands"))
207 , m_xBtnEngineering(m_xBuilder->weld_check_button(
"engineering"))
208 , m_xFormatCodeFrame(m_xBuilder->weld_widget(
"formatcode"))
209 , m_xEdFormat(m_xBuilder->weld_entry(
"formatted"))
210 , m_xIbAdd(m_xBuilder->weld_button(
"add"))
211 , m_xIbInfo(m_xBuilder->weld_button(
"edit"))
212 , m_xIbRemove(m_xBuilder->weld_button(
"delete"))
213 , m_xFtComment(m_xBuilder->weld_label(
"commentft"))
214 , m_xEdComment(m_xBuilder->weld_entry(
"commented"))
215 , m_xLbLanguage(new
SvxLanguageBox(m_xBuilder->weld_combo_box(
"languagelb")))
216 , m_xWndPreview(new
weld::CustomWeld(*m_xBuilder,
"preview", m_aWndPreview))
218 for (
size_t i = 0;
i < std::size(NUM_CATEGORIES); ++
i)
221 auto nWidth =
m_xLbCategory->get_approximate_digit_width() * 22;
302 m_xLbLanguage->SetLanguageList(SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN,
304 css::i18n::ScriptType::WEAK);
310 return std::make_unique<SvxNumberFormatTabPage>(pPage, pController, *rAttrSet);
328 static_assert(
SELPOS_NONE == -1,
"SELPOS_NONE was -1 at time of writing");
342 static_assert(
SELPOS_NONE == -1,
"SELPOS_NONE was -1 at time of writing");
355 sal_uInt16 nCatLbSelPos = 0;
356 sal_uInt16 nFmtLbSelPos = 0;
358 std::vector<OUString> aFmtEntryList;
360 double nValDouble = 0;
365 if(pBoolLangItem->GetValue())
378 if(eState==SfxItemState::SET)
383 pNumItem.reset( static_cast<SvxNumberInfoItem *>(pItem->
Clone()) );
398 if(eState==SfxItemState::SET)
401 GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ONE_AREA));
403 if(pBoolItem!=
nullptr)
409 eState = rSet->
GetItemState( SID_ATTR_NUMBERFORMAT_SOURCE );
411 if ( eState == SfxItemState::SET )
414 GetItem( *rSet, SID_ATTR_NUMBERFORMAT_SOURCE );
435 if ( SfxItemState::DONTCARE != eState )
436 pValFmtAttr =
GetItem( *rSet, SID_ATTR_NUMBERFORMAT_VALUE );
438 eValType =
pNumItem->GetValueType();
442 case SvxNumberValueType::String:
443 aValString =
pNumItem->GetValueString();
445 case SvxNumberValueType::Number:
447 aValString =
pNumItem->GetValueString();
448 nValDouble =
pNumItem->GetValueDouble();
450 case SvxNumberValueType::Undefined:
459 : std::numeric_limits<sal_uInt32>::max();
462 if ( eValType == SvxNumberValueType::String )
477 bool bUseStarFormat =
false;
482 Reference< XServiceInfo > xSI( pDocSh->
GetModel(), UNO_QUERY );
484 bUseStarFormat = xSI->supportsService(
"com.sun.star.sheet.SpreadsheetDocument");
490 OUString aPrevString;
491 const Color* pDummy =
nullptr;
492 pNumFmtShell->GetInitSettings( nCatLbSelPos, eLangType, nFmtLbSelPos,
493 aFmtEntryList, aPrevString, pDummy );
501 OUString sFixedCategory =
m_xLbCategory->get_text(nFixedCategory);
510 eState = rSet->
GetItemState( SID_ATTR_NUMBERFORMAT_ADD_AUTO );
511 if(SfxItemState::SET == eState)
512 pAutoEntryAttr =
GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO );
662 sal_uInt16 nWhich =
GetWhich( SID_ATTR_NUMBERFORMAT_VALUE );
694 else if(SfxItemState::DEFAULT == eItemState)
703 std::vector<sal_uInt32>
const & aDelFormats =
pNumFmtShell->GetUpdateData();
705 if ( !aDelFormats.empty() )
708 pNumItem->SetDelFormats( std::vector(aDelFormats) );
733 GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE );
734 bool bOld = pBoolItem && pBoolItem->
GetValue();
738 _eItemState != SfxItemState::SET);
758 return DeactivateRC::LeavePage;
769 if (rEntries.empty())
801 for ( ; i < rEntries.size(); ++i )
803 aEntry = rEntries[i];
804 short aPrivCat =
pNumFmtShell->GetCategory4Entry( static_cast<short>(i) );
807 const Color* pPreviewColor =
nullptr;
838 sal_Int32 nCurCategory =
m_xLbCategory->get_selected_index();
839 sal_uInt16 nCategory =
static_cast<sal_uInt16
>(nCurCategory);
840 sal_uInt16 nDecimals = 0;
841 sal_uInt16 nZeroes = 0;
842 bool bNegRed =
false;
843 bool bThousand =
false;
857 sal_uInt16 nTstPos=
pNumFmtShell->FindCurrencyFormat(theFormat);
858 if(nCurrencyPos!=static_cast<sal_Int32>(nTstPos) && nTstPos!=sal_uInt16(-1))
866 if ( nCategory != nCurCategory || bDoIt)
868 if ( bCheckCatChange )
897 sal_uInt16 nIntDigits =
pNumFmtShell->GetFormatIntegerDigits(theFormat);
898 bThousand = (nIntDigits > 0) && (nIntDigits % 3 == 0);
983 std::vector<OUString> aEntryList;
984 short nFmtLbSelPos = 0;
989 nTmpCatPos=nFixedCategory;
993 nTmpCatPos=m_xLbCategory->get_selected_index();
1000 m_xLbCurrency->hide();
1002 m_xLbCurrency->show();
1004 pNumFmtShell->CategoryChanged(nTmpCatPos,nFmtLbSelPos, aEntryList);
1007 pNumFmtShell->LanguageChanged(m_xLbLanguage->get_active_id(),
1008 nFmtLbSelPos,aEntryList);
1013 if ( (!aEntryList.empty()) && (nFmtLbSelPos !=
SELPOS_NONE) )
1017 OUString aFormat=aEntryList[nFmtLbSelPos];
1018 m_xEdFormat->set_text(aFormat);
1019 m_xFtComment->set_label(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
1022 if(!bOneAreaFlag || !bCat)
1024 FillFormatListBox_Impl( aEntryList );
1025 m_xLbFormat->select(nFmtLbSelPos);
1027 m_xFtComment->set_label(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
1028 if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
1030 if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).isEmpty())
1032 m_xFtComment->set_label(m_xLbCategory->get_text(1));
1035 ChangePreviewText( static_cast<sal_uInt16>(nFmtLbSelPos) );
1041 FillFormatListBox_Impl( aEntryList );
1044 m_xLbFormat->select(static_cast<sal_uInt16>(nFmtLbSelPos));
1046 m_xFtComment->set_label(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
1047 if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
1049 if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).isEmpty())
1051 m_xFtComment->set_label(m_xLbCategory->get_text(1));
1057 m_xLbFormat->select(-1);
1062 m_xEdFormat->set_text( OUString() );
1063 m_aWndPreview.NotifyChange( OUString() );
1114 SelFormatHdl_Impl(&rLb);
1117 assert(pController);
1138 SelFormatHdl_Impl(&rLb);
1143 SelFormatHdl_Impl(&rLb);
1148 SelFormatHdl_Impl(&rLb);
1162 LostFocusHdl_Impl(*pLb);
1180 sal_Int32 nTmpCatPos;
1198 short nFmtLbSelPos =
static_cast<short>(nSelPos);
1200 OUString aFormat =
pNumFmtShell->GetFormat4Entry(nFmtLbSelPos);
1201 OUString aComment =
pNumFmtShell->GetComment4Entry(nFmtLbSelPos);
1205 if(aComment.isEmpty())
1211 if ( !aFormat.isEmpty() )
1224 bool bIsUserDef=
pNumFmtShell->IsUserDefined( aFormat );
1285 constexpr
sal_uInt8 nReturnChanged = 0x1;
1287 constexpr
sal_uInt8 nReturnOneArea = 0x4;
1293 std::vector<OUString> aEntryList;
1294 std::vector<OUString> a2EntryList;
1295 sal_uInt16 nCatLbSelPos = 0;
1297 sal_Int32 nErrPos=0;
1300 bool bAdded =
pNumFmtShell->AddFormat( aFormat, nErrPos,
1301 nCatLbSelPos, nFmtLbSelPos,
1304 nReturn |= nReturnChanged | nReturnAdded;
1325 if(bAdded) aEntryList.clear();
1330 a2EntryList.clear();
1333 nReturn |= nReturnOneArea;
1356 m_xLbFormat->select(static_cast<sal_uInt16>(nFmtLbSelPos));
1371 nReturn = ((nReturn & nReturnOneArea) ? 0 : (nReturn & nReturnChanged));
1374 a2EntryList.clear();
1379 std::vector<OUString> aEntryList;
1380 sal_uInt16 nCatLbSelPos = 0;
1392 aFormat = aEntryList[nFmtLbSelPos];
1404 m_xLbFormat->select(static_cast<sal_uInt16>(nFmtLbSelPos));
1459 EditHdl_Impl(&
rEdit);
1488 sal_uInt16 nTmpCurPos=
pNumFmtShell->FindCurrencyFormat(aFormat );
1489 if (nTmpCurPos != sal_uInt16(-1))
1492 short nPosi=
pNumFmtShell->GetListPos4Entry( nCurKey, aFormat);
1494 m_xLbFormat->select(static_cast<sal_uInt16>(nPosi));
1530 OptHdl_Impl(&rOptCtrl);
1535 OptHdl_Impl(&
rEdit);
1567 nPrecision, nLeadZeroes,
1568 static_cast<sal_uInt16>(
m_xLbFormat->get_selected_index()) );
1605 const bool bAddSensitive = m_xIbAdd->get_sensitive();
1606 if (bAddSensitive || m_nLbFormatSelPosEdComment !=
SELPOS_NONE)
1608 m_xFtComment->set_label(m_xEdComment->get_text());
1610 m_xEdComment->hide();
1611 m_xFtComment->show();
1615 pNumFmtShell->SetComment4Entry( m_nLbFormatSelPosEdComment, m_xEdComment->get_text());
1621 OUString sEntry = m_xLbCategory->n_children() > 1 ? m_xLbCategory->get_text(1) : OUString();
1622 m_xEdComment->set_text(sEntry);
1638 const Color*& rpPreviewColor,
const OUString& rFormatStr,
short nTmpCatPos)
1643 case CAT_ALL: i=SvxNumValCategory::Standard;
break;
1645 case CAT_NUMBER: i=SvxNumValCategory::Standard;
break;
1647 case CAT_PERCENT: i=SvxNumValCategory::Percent;
break;
1649 case CAT_CURRENCY: i=SvxNumValCategory::Currency;
break;
1651 case CAT_DATE: i=SvxNumValCategory::Date;
break;
1653 case CAT_TIME: i=SvxNumValCategory::Time;
break;
1657 case CAT_FRACTION: i=SvxNumValCategory::Fraction;
break;
1659 case CAT_BOOLEAN: i=SvxNumValCategory::Boolean;
break;
1664 default: i=SvxNumValCategory::NoValue;
break;
1668 OUString aPreviewString;
1669 pNumFmtShell->MakePrevStringFromVal( rFormatStr, aPreviewString, rpPreviewColor, fVal );
1670 return aPreviewString;
1675 OUString aPreviewString;
1676 const Color* pPreviewColor =
nullptr;
1677 pNumFmtShell->MakePreviewString( rFormat, aPreviewString, pPreviewColor );
1683 OUString aPreviewString;
1684 const Color* pPreviewColor =
nullptr;
1685 pNumFmtShell->FormatChanged( nPos, aPreviewString, pPreviewColor );
1691 std::vector<OUString> aList;
1693 sal_uInt16 nSelPos=0;
1699 for (std::vector<OUString>::iterator
i = aList.begin() + 1;
i != aList.end(); ++
i)
1709 sal_uInt16 nTmpCatPos;
static const WhichRangesContainer pRanges
#define LINK(Instance, Class, Member)
std::unique_ptr< weld::CustomWeld > m_xWndPreview
OUString GetExpColorString(const Color *&rpPreviewColor, const OUString &aFormatStr, short nTmpCatPos)
std::unique_ptr< SvxNumberFormatShell > pNumFmtShell
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
std::unique_ptr< weld::Label > m_xFtOptions
void HideLanguage(bool bFlag=true)
short m_nLbFormatSelPosEdComment
static constexpr auto Items
std::unique_ptr< weld::Label > m_xFtLanguage
OUString sAutomaticCurrencyEntry
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
std::unique_ptr< weld::Widget > m_xFormatCodeFrame
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
#define REMOVE_DONTKNOW()
bool Click_Impl(const weld::Button &rIB)
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
std::unique_ptr< weld::CheckButton > m_xBtnNegRed
virtual void PageCreated(const SfxAllItemSet &aSet) override
css::uno::Reference< css::frame::XModel3 > GetModel() const
void OptHdl_Impl(const weld::Widget *)
std::unique_ptr< weld::Button > m_xIbInfo
static SfxObjectShell * Current()
void EnableBySourceFormat_Impl()
void PutItem(const SfxPoolItem &rItem)
virtual bool FillItemSet(SfxItemSet *rSet) override
virtual SvxNumberInfoItem * Clone(SfxItemPool *pPool=nullptr) const override
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
void NotifyChange(const OUString &rPrevStr, const Color *pColor=nullptr)
constexpr tools::Long Width() const
void SelFormatHdl_Impl(weld::Widget *)
const vcl::Font & GetFont() const
std::unique_ptr< SvxNumberInfoItem > pNumItem
std::unique_ptr< weld::CheckButton > m_xBtnEngineering
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
virtual weld::Button & GetOKButton() const =0
void SetExchangeSupport()
std::unique_ptr< weld::TreeView > m_xLbCategory
const SfxItemSet & GetItemSet() const
#define LANGUAGE_NORWEGIAN
void FillFormatListBox_Impl(std::vector< OUString > &rEntries)
void UpdateThousandEngineeringCheckBox()
Change visible checkbox according to category format if scientific format "Engineering notation" else...
std::unique_ptr< weld::CheckButton > m_xCbSourceFormat
OUString CuiResId(TranslateId aKey)
bool bNumItemFlag
for handling with DocShell
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
std::unique_ptr< weld::Label > m_xFtComment
#define DBG_ASSERT(sCon, aError)
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
std::unique_ptr< SvxLanguageBox > m_xLbLanguage
std::unique_ptr< weld::ComboBox > m_xLbCurrency
std::unique_ptr< weld::Entry > m_xEdFormat
const o3tl::enumarray< SvxNumValCategory, double > fSvxNumValConst
void SetCategory(sal_uInt16 nPos)
std::unique_ptr< weld::Label > m_xFtDecimals
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void SetTextColor(const Color &rColor)
virtual void Reset(const SfxItemSet *rSet) override
#define LANGUAGE_DONTKNOW
std::unique_ptr< weld::Label > m_xFtFormat
std::unique_ptr< weld::Button > m_xIbRemove
std::unique_ptr< weld::Label > m_xFtCategory
void SetColor(const Color &)
void MakePreviewText(const OUString &rFormat)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void set_active_currency(sal_Int32 nCurCurrencyEntryPos)
void EditHdl_Impl(const weld::Entry *)
std::unique_ptr< weld::CheckButton > m_xBtnThousand
constexpr tools::Long Height() const
std::unique_ptr< weld::Button > m_xIbAdd
void SetFont(const vcl::Font &rNewFont)
IMPL_LINK_NOARG(SvxNumberFormatTabPage, LostFocusHdl_Impl, weld::Widget &, void)
void SetTransparent(bool bTransparent)
std::unique_ptr< weld::Entry > m_xEdComment
std::unique_ptr< weld::Label > m_xFtLeadZeroes
std::unique_ptr< weld::SpinButton > m_xEdLeadZeroes
std::unique_ptr< weld::SpinButton > m_xEdDecimals
IMPL_LINK(SvxNumberFormatTabPage, DoubleClickHdl_Impl, weld::TreeView &, rLb, bool)
bool bLegacyAutomaticCurrency
sal_uInt32 GetValue() const
std::unique_ptr< weld::TreeView > m_xLbFormat
void UpdateDecimalsDenominatorEditBox()
Change visible Edit box and Fixed text according to category format if fraction format "Denominator p...
sal_uInt32 get_active_currency() const
void UpdateFormatListBox_Impl(bool bCat, bool bUpdateEdit)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
void UpdateOptions_Impl(bool bCheckCatChange)
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)
SvxNumberFormatTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreAttrs)
virtual ~SvxNumberFormatTabPage() override
void AddAutomaticLanguage_Impl(LanguageType eAutoLang, bool bSelect)
OUString sAutomaticLangEntry
SvxNumberPreview m_aWndPreview
void ChangePreviewText(sal_uInt16 nPos)
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
std::unique_ptr< weld::Label > m_xFtDenominator
bool m_bDetectedRangeSegmentation false
std::unique_ptr< weld::SpinButton > m_xEdDenominator