LibreOffice Module cui (master)  1
numfmt.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sal/config.h>
21 
22 #include <o3tl/safeint.hxx>
23 #include <svl/eitem.hxx>
24 #include <svl/intitem.hxx>
25 #include <sfx2/objsh.hxx>
26 #include <vcl/outdev.hxx>
27 #include <i18nlangtag/lang.h>
28 #include <svx/svxids.hrc>
29 #include <svtools/colorcfg.hxx>
30 
31 #include <numcategories.hrc>
32 #include <strings.hrc>
33 
34 #include <svx/numinf.hxx>
35 
36 #include <numfmt.hxx>
37 #include <svx/numfmtsh.hxx>
38 #include <dialmgr.hxx>
39 #include <sfx2/basedlgs.hxx>
40 #include <svx/flagsdef.hxx>
41 #include <vector>
42 #include <com/sun/star/frame/XModel.hpp>
43 #include <com/sun/star/lang/XServiceInfo.hpp>
44 #include <limits>
45 #include <memory>
46 
47 using ::com::sun::star::uno::Reference;
48 using ::com::sun::star::lang::XServiceInfo;
49 using ::com::sun::star::uno::UNO_QUERY;
50 
51 #define NUMKEY_UNDEFINED SAL_MAX_UINT32
52 
53 // static ----------------------------------------------------------------
54 
56  svl::Items<
57  SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, // 10085 - 10086
58  SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA, // 10580 - 10580
59  SID_ATTR_NUMBERFORMAT_NOLANGUAGE, SID_ATTR_NUMBERFORMAT_NOLANGUAGE, // 10700 - 10700
60  SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE>); // 10932 - 10932
61 
62 /*************************************************************************
63 #* Method: SvxNumberPreview
64 #*------------------------------------------------------------------------
65 #*
66 #* Class: SvxNumberPreview
67 #* Function: Constructor of the class SvxNumberPreview
68 #* Input: Window, Resource-ID
69 #* Output: ---
70 #*
71 #************************************************************************/
72 
74  : mnPos(-1)
75  , mnChar(0x0)
76 {
77 }
78 
79 /*************************************************************************
80 #* Method: NotifyChange
81 #*------------------------------------------------------------------------
82 #*
83 #* Class: SvxNumberPreview
84 #* Function: Function for changing the preview string
85 #* Input: String, color
86 #* Output: ---
87 #*
88 #************************************************************************/
89 
90 void SvxNumberPreview::NotifyChange( const OUString& rPrevStr,
91  const Color* pColor )
92 {
93  // detect and strip out '*' related placeholders
94  aPrevStr = rPrevStr;
95  mnPos = aPrevStr.indexOf( 0x1B );
96  if ( mnPos != -1 )
97  {
98  // Right during user input the star symbol is the very
99  // last character before the user enters another one.
100  if (mnPos < aPrevStr.getLength() - 1)
101  {
102  mnChar = aPrevStr[ mnPos + 1 ];
103  // delete placeholder and char to repeat
104  aPrevStr = aPrevStr.replaceAt( mnPos, 2, u"" );
105  }
106  else
107  {
108  // delete placeholder
109  aPrevStr = aPrevStr.replaceAt( mnPos, 1, u"" );
110  // do not attempt to draw a 0 fill character
111  mnPos = -1;
112  }
113  }
114  svtools::ColorConfig aColorConfig;
115  Color aWindowTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
116  aPrevCol = pColor ? *pColor : aWindowTextColor;
117  Invalidate();
118 }
119 
120 /*************************************************************************
121 #* Method: Paint
122 #*------------------------------------------------------------------------
123 #*
124 #* Class: SvxNumberPreview
125 #* Function: Function for repainting the window.
126 #* Input: ---
127 #* Output: ---
128 #*
129 #************************************************************************/
130 
131 void SvxNumberPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle&)
132 {
133  rRenderContext.Push(vcl::PushFlags::ALL);
134 
135  svtools::ColorConfig aColorConfig;
136  rRenderContext.SetTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
137  rRenderContext.SetBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
138 
139  vcl::Font aDrawFont = rRenderContext.GetFont();
140  Size aSzWnd(GetOutputSizePixel());
141  OUString aTmpStr(aPrevStr);
142  tools::Long nLeadSpace = (aSzWnd.Width() - rRenderContext.GetTextWidth(aTmpStr)) / 2;
143 
144  aDrawFont.SetTransparent(true);
145  aDrawFont.SetColor(aPrevCol);
146  rRenderContext.SetFont(aDrawFont);
147 
148  if (mnPos != -1)
149  {
150  tools::Long nCharWidth = rRenderContext.GetTextWidth(OUString(mnChar));
151 
152  int nNumCharsToInsert = 0;
153  if (nCharWidth > 0)
154  nNumCharsToInsert = nLeadSpace / nCharWidth;
155 
156  if (nNumCharsToInsert > 0)
157  {
158  for (int i = 0; i < nNumCharsToInsert; ++i)
159  aTmpStr = aTmpStr.replaceAt(mnPos, 0, rtl::OUStringChar(mnChar));
160  }
161  }
162 
163  tools::Long nX = 0;
164  if (mnPos == -1 && nLeadSpace > 0) //tdf#122120 if it won't fit anyway, then left align it
165  {
166  nX = nLeadSpace;
167  }
168 
169  Point aPosText(nX, (aSzWnd.Height() - GetTextHeight()) / 2);
170  rRenderContext.DrawText(aPosText, aTmpStr);
171  rRenderContext.Pop();
172 }
173 
174 // class SvxNumberFormatTabPage ------------------------------------------
175 
176 #define REMOVE_DONTKNOW() \
177  if (!m_xFtLanguage->get_sensitive()) \
178  { \
179  m_xFtLanguage->set_sensitive(true); \
180  m_xLbLanguage->set_sensitive(true); \
181  m_xLbLanguage->set_active_id(pNumFmtShell->GetCurLanguage()); \
182  }
183 
185  const SfxItemSet& rCoreAttrs)
186  : SfxTabPage(pPage, pController, "cui/ui/numberingformatpage.ui", "NumberingFormatPage", &rCoreAttrs)
187  , nInitFormat(std::numeric_limits<sal_uInt32>::max())
188  , m_nLbFormatSelPosEdComment(SELPOS_NONE)
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))
217 {
218  for (size_t i = 0; i < std::size(NUM_CATEGORIES); ++i)
219  m_xLbCategory->append_text(CuiResId(NUM_CATEGORIES[i]));
220 
221  auto nWidth = m_xLbCategory->get_approximate_digit_width() * 22;
222  m_xLbCategory->set_size_request(nWidth, m_xLbCategory->get_height_rows(7));
223  m_xLbFormat->set_size_request(nWidth, m_xLbFormat->get_height_rows(5));
224  m_xLbCurrency->set_size_request(nWidth, -1); // force using (narrower) width of its LbFormat sibling
225 
226  // Initially remove the "Automatically" entry.
227  m_xLbCurrency->set_active(-1); // First ensure that nothing is selected.
228  sAutomaticCurrencyEntry = m_xLbCurrency->get_text(0);
229  m_xLbCurrency->remove(0);
230 
231  Init_Impl();
232  SetExchangeSupport(); // this page needs ExchangeSupport
233  nFixedCategory=-1;
234 }
235 
237 {
238  pNumFmtShell.reset();
239  pNumItem.reset();
240  m_xWndPreview.reset();
241  m_xLbLanguage.reset();
242 }
243 
245 {
246  bNumItemFlag=true;
247  bOneAreaFlag=false;
248 
249  m_xIbAdd->set_sensitive(false );
250  m_xIbRemove->set_sensitive(false );
251  m_xIbInfo->set_sensitive(false );
252 
253  m_xEdComment->set_text(m_xLbCategory->get_text(1)); // string for user defined
254 
255  m_xEdComment->hide();
256 
257  m_xCbSourceFormat->set_active( false );
258  m_xCbSourceFormat->set_sensitive(false);
259  m_xCbSourceFormat->hide();
260 
261  Link<weld::TreeView&,void> aLink2 = LINK(this, SvxNumberFormatTabPage, SelFormatTreeListBoxHdl_Impl);
262  Link<weld::ComboBox&,void> aLink3 = LINK(this, SvxNumberFormatTabPage, SelFormatListBoxHdl_Impl);
263  m_xLbCategory->connect_changed(aLink2);
264  m_xLbCategory->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
265  m_xLbFormat->connect_changed(aLink2);
266  m_xLbFormat->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
267  m_xLbLanguage->connect_changed(aLink3);
268  m_xLbLanguage->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
269  m_xLbCurrency->connect_changed(aLink3);
270  m_xLbCurrency->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
271  m_xCbSourceFormat->connect_toggled(LINK(this, SvxNumberFormatTabPage, SelFormatClickHdl_Impl));
272  m_xCbSourceFormat->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
273 
274  Link<weld::SpinButton&,void> aLink = LINK( this, SvxNumberFormatTabPage, OptEditHdl_Impl );
275 
276  m_xEdDecimals->connect_value_changed(aLink);
277  m_xEdDecimals->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
278  m_xEdDenominator->connect_value_changed(aLink);
279  m_xEdDenominator->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
280  m_xEdLeadZeroes->connect_value_changed(aLink);
281  m_xEdLeadZeroes->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
282 
283  m_xBtnNegRed->connect_toggled(LINK(this, SvxNumberFormatTabPage, OptClickHdl_Impl));
284  m_xBtnNegRed->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
285  m_xBtnThousand->connect_toggled(LINK(this, SvxNumberFormatTabPage, OptClickHdl_Impl));
286  m_xBtnThousand->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
287  m_xBtnEngineering->connect_toggled(LINK(this, SvxNumberFormatTabPage, OptClickHdl_Impl));
288  m_xBtnEngineering->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
289  m_xLbFormat->connect_row_activated(LINK(this, SvxNumberFormatTabPage, DoubleClickHdl_Impl));
290  m_xEdFormat->connect_changed(LINK(this, SvxNumberFormatTabPage, EditModifyHdl_Impl));
291  m_xEdFormat->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
292  m_xIbAdd->connect_clicked(LINK(this, SvxNumberFormatTabPage, ClickHdl_Impl));
293  m_xIbAdd->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
294  m_xIbRemove->connect_clicked(LINK(this, SvxNumberFormatTabPage, ClickHdl_Impl));
295  m_xIbRemove->connect_focus_in(LINK(this, SvxNumberFormatTabPage, LostFocusHdl_Impl));
296  m_xIbInfo->connect_clicked(LINK(this, SvxNumberFormatTabPage, ClickHdl_Impl));
299 
300  // initialize language ListBox
301 
302  m_xLbLanguage->SetLanguageList(SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN,
303  false, false, false, true, LANGUAGE_SYSTEM,
304  css::i18n::ScriptType::WEAK);
305 }
306 
307 std::unique_ptr<SfxTabPage> SvxNumberFormatTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
308  const SfxItemSet* rAttrSet )
309 {
310  return std::make_unique<SvxNumberFormatTabPage>(pPage, pController, *rAttrSet);
311 }
312 
313 
314 /*************************************************************************
315 #* Method: Reset
316 #*------------------------------------------------------------------------
317 #*
318 #* Class: SvxNumberFormatTabPage
319 #* Function: The dialog's attributes are reset
320 #* using the Itemset.
321 #* Input: SfxItemSet
322 #* Output: ---
323 #*
324 #************************************************************************/
325 
327 {
328  static_assert(SELPOS_NONE == -1, "SELPOS_NONE was -1 at time of writing");
329  if (nPos == 0 && !bLegacyAutomaticCurrency)
330  {
331  // Insert "Automatically" if currently used so it is selectable.
332  m_xLbCurrency->insert_text(0, sAutomaticCurrencyEntry);
334  }
335  if (nPos != -1 && !bLegacyAutomaticCurrency)
336  --nPos;
337  m_xLbCurrency->set_active(nPos);
338 }
339 
341 {
342  static_assert(SELPOS_NONE == -1, "SELPOS_NONE was -1 at time of writing");
343  sal_Int32 nCurrencyPos = m_xLbCurrency->get_active();
344  if (nCurrencyPos != -1 && !bLegacyAutomaticCurrency)
345  ++nCurrencyPos;
346  return nCurrencyPos;
347 }
348 
350 {
351  const SfxUInt32Item* pValFmtAttr = nullptr;
352  const SfxPoolItem* pItem = nullptr;
353  const SfxBoolItem* pAutoEntryAttr = nullptr;
354 
355  sal_uInt16 nCatLbSelPos = 0;
356  sal_uInt16 nFmtLbSelPos = 0;
357  LanguageType eLangType = LANGUAGE_DONTKNOW;
358  std::vector<OUString> aFmtEntryList;
359  SvxNumberValueType eValType = SvxNumberValueType::Undefined;
360  double nValDouble = 0;
361  OUString aValString;
362 
363  if(const SfxBoolItem* pBoolLangItem = rSet->GetItemIfSet( SID_ATTR_NUMBERFORMAT_NOLANGUAGE ))
364  {
365  if(pBoolLangItem->GetValue())
366  {
367  HideLanguage();
368  }
369  else
370  {
371  HideLanguage(false);
372  }
373 
374  }
375 
376  SfxItemState eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_INFO ),true,&pItem);
377 
378  if(eState==SfxItemState::SET)
379  {
380  if(pNumItem==nullptr)
381  {
382  bNumItemFlag=true;
383  pNumItem.reset( static_cast<SvxNumberInfoItem *>(pItem->Clone()) );
384  }
385  else
386  {
387  bNumItemFlag=false;
388  }
389  }
390  else
391  {
392  bNumItemFlag=false;
393  }
394 
395 
396  eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_ONE_AREA ));
397 
398  if(eState==SfxItemState::SET)
399  {
400  const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(
401  GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ONE_AREA));
402 
403  if(pBoolItem!=nullptr)
404  {
405  bOneAreaFlag= pBoolItem->GetValue();
406  }
407  }
408 
409  eState = rSet->GetItemState( SID_ATTR_NUMBERFORMAT_SOURCE );
410 
411  if ( eState == SfxItemState::SET )
412  {
413  const SfxBoolItem* pBoolItem =
414  GetItem( *rSet, SID_ATTR_NUMBERFORMAT_SOURCE );
415  if ( pBoolItem )
416  m_xCbSourceFormat->set_active(pBoolItem->GetValue());
417  else
418  m_xCbSourceFormat->set_active( false );
419  m_xCbSourceFormat->set_sensitive(true);
420  m_xCbSourceFormat->show();
421  }
422  else
423  {
424  bool bInit = false; // set to sal_True for debug test
425  m_xCbSourceFormat->set_active( bInit );
426  m_xCbSourceFormat->set_sensitive( bInit );
427  m_xCbSourceFormat->set_visible( bInit );
428  }
429 
430  // pNumItem must have been set from outside!
431  DBG_ASSERT( pNumItem, "No NumberInfo, no NumberFormatter, goodbye. CRASH. :-(" );
432 
433  eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ) );
434 
435  if ( SfxItemState::DONTCARE != eState )
436  pValFmtAttr = GetItem( *rSet, SID_ATTR_NUMBERFORMAT_VALUE );
437 
438  eValType = pNumItem->GetValueType();
439 
440  switch ( eValType )
441  {
442  case SvxNumberValueType::String:
443  aValString = pNumItem->GetValueString();
444  break;
445  case SvxNumberValueType::Number:
446  // #50441# string may be set in addition to the value
447  aValString = pNumItem->GetValueString();
448  nValDouble = pNumItem->GetValueDouble();
449  break;
450  case SvxNumberValueType::Undefined:
451  default:
452  break;
453  }
454 
455  pNumFmtShell.reset(); // delete old shell if applicable (== reset)
456 
457  nInitFormat = pValFmtAttr // memorize init key
458  ? pValFmtAttr->GetValue() // (for FillItemSet())
459  : std::numeric_limits<sal_uInt32>::max(); // == DONT_KNOW
460 
461 
462  if ( eValType == SvxNumberValueType::String )
464  pNumItem->GetNumberFormatter(),
465  pValFmtAttr ? nInitFormat : 0,
466  eValType,
467  aValString ) );
468  else
470  pNumItem->GetNumberFormatter(),
471  pValFmtAttr ? nInitFormat : 0,
472  eValType,
473  nValDouble,
474  &aValString ) );
475 
476 
477  bool bUseStarFormat = false;
479  if ( pDocSh )
480  {
481  // is this a calc document
482  Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY );
483  if ( xSI.is() )
484  bUseStarFormat = xSI->supportsService("com.sun.star.sheet.SpreadsheetDocument");
485  }
486  pNumFmtShell->SetUseStarFormat( bUseStarFormat );
487 
488  FillCurrencyBox();
489 
490  OUString aPrevString;
491  const Color* pDummy = nullptr;
492  pNumFmtShell->GetInitSettings( nCatLbSelPos, eLangType, nFmtLbSelPos,
493  aFmtEntryList, aPrevString, pDummy );
494 
495  if (nCatLbSelPos==CAT_CURRENCY)
496  set_active_currency(pNumFmtShell->GetCurrencySymbol());
497 
498  nFixedCategory=nCatLbSelPos;
499  if(bOneAreaFlag)
500  {
501  OUString sFixedCategory = m_xLbCategory->get_text(nFixedCategory);
502  m_xLbCategory->clear();
503  m_xLbCategory->append_text(sFixedCategory);
504  SetCategory(0);
505  }
506  else
507  {
508  SetCategory(nCatLbSelPos );
509  }
510  eState = rSet->GetItemState( SID_ATTR_NUMBERFORMAT_ADD_AUTO );
511  if(SfxItemState::SET == eState)
512  pAutoEntryAttr = GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO );
513  // no_NO is an alias for nb_NO and normally isn't listed, we need it for
514  // backwards compatibility, but only if the format passed is of
515  // LanguageType no_NO.
516  if ( eLangType == LANGUAGE_NORWEGIAN )
517  {
518  m_xLbLanguage->remove_id(eLangType); // in case we're already called
519  m_xLbLanguage->InsertLanguage( eLangType );
520  }
521  m_xLbLanguage->set_active_id(eLangType);
522  if(pAutoEntryAttr)
523  AddAutomaticLanguage_Impl(eLangType, pAutoEntryAttr->GetValue());
524  UpdateFormatListBox_Impl(false,true);
525 
529 // SelFormatHdl_Impl(m_xLbCategory.get());
530 
531  if ( pValFmtAttr )
532  {
533  EditHdl_Impl(m_xEdFormat.get()); // UpdateOptions_Impl() as a side effect
534  }
535  else // DONT_KNOW
536  {
537  // everything disabled except direct input or changing the category
538  Obstructing();
539  }
540 
541  if ( m_xCbSourceFormat->get_active() )
542  {
543  // everything disabled except SourceFormat checkbox
545  }
546 }
547 
548 /*************************************************************************
549 #* Method: Obstructing
550 #*------------------------------------------------------------------------
551 #*
552 #* Class: SvxNumberFormatTabPage
553 #* Function: Disable the controls except from changing the category
554 #* and direct input.
555 #* Input: ---
556 #* Output: ---
557 #*
558 #************************************************************************/
560 {
561  m_xLbFormat->select(-1);
562  m_xLbLanguage->set_active(-1);
563  m_xFtLanguage->set_sensitive(false);
564  m_xLbLanguage->set_sensitive(false);
565 
566  m_xIbAdd->set_sensitive(false );
567  m_xIbRemove->set_sensitive(false );
568  m_xIbInfo->set_sensitive(false );
569 
570  m_xBtnNegRed->set_sensitive(false);
571  m_xBtnThousand->set_sensitive(false);
572  m_xBtnEngineering->set_sensitive(false);
573  m_xFtLeadZeroes->set_sensitive(false);
574  m_xFtDecimals->set_sensitive(false);
575  m_xFtDenominator->set_sensitive(false);
576  m_xEdLeadZeroes->set_sensitive(false);
577  m_xEdDecimals->set_sensitive(false);
578  m_xEdDenominator->set_sensitive(false);
579  m_xFtOptions->set_sensitive(false);
580  m_xEdDecimals->set_text( OUString() );
581  m_xEdLeadZeroes->set_text( OUString() );
582  m_xBtnNegRed->set_active( false );
583  m_xBtnThousand->set_active( false );
584  m_xBtnEngineering->set_active( false );
585  m_aWndPreview.NotifyChange( OUString() );
586 
587  m_xLbCategory->select(0);
588  m_xEdFormat->set_text( OUString() );
589  m_xFtComment->set_label( OUString() );
590  m_xEdComment->set_text(m_xLbCategory->get_text(1)); // string for user defined
591 
592  m_xEdFormat->grab_focus();
593 }
594 
595 
596 /*************************************************************************
597 #* Enable/Disable dialog parts depending on the value of the SourceFormat
598 #* checkbox.
599 #************************************************************************/
601 {
602  bool bEnable = !m_xCbSourceFormat->get_active();
603  if ( !bEnable )
604  m_xCbSourceFormat->grab_focus();
605  m_xFtCategory->set_sensitive( bEnable );
606  m_xLbCategory->set_sensitive( bEnable );
607  m_xFtFormat->set_sensitive( bEnable );
608  m_xLbCurrency->set_sensitive( bEnable );
609  m_xLbFormat->set_sensitive( bEnable );
610  m_xFtLanguage->set_sensitive( bEnable );
611  m_xLbLanguage->set_sensitive( bEnable );
612  m_xFtDecimals->set_sensitive( bEnable );
613  m_xEdDecimals->set_sensitive( bEnable );
614  m_xFtDenominator->set_sensitive( bEnable );
615  m_xEdDenominator->set_sensitive( bEnable );
616  m_xFtLeadZeroes->set_sensitive( bEnable );
617  m_xEdLeadZeroes->set_sensitive( bEnable );
618  m_xBtnNegRed->set_sensitive( bEnable );
619  m_xBtnThousand->set_sensitive( bEnable );
620  m_xBtnEngineering->set_sensitive( bEnable );
621  m_xFtOptions->set_sensitive( bEnable );
622  m_xFormatCodeFrame->set_sensitive( bEnable );
623 }
624 
625 
626 /*************************************************************************
627 #* Method: HideLanguage
628 #*------------------------------------------------------------------------
629 #*
630 #* Class: SvxNumberFormatTabPage
631 #* Function: Hides the language settings:
632 #* Input: sal_Bool nFlag
633 #* Output: ---
634 #*
635 #************************************************************************/
636 
638 {
639  m_xFtLanguage->set_visible(!bFlag);
640  m_xLbLanguage->set_visible(!bFlag);
641 }
642 
643 /*************************************************************************
644 #* Method: FillItemSet
645 #*------------------------------------------------------------------------
646 #*
647 #* Class: SvxNumberFormatTabPage
648 #* Function: Adjusts the attributes in the ItemSet,
649 #* and - if bNumItemFlag is not set - the
650 #* numItem in the DocShell.
651 #* Input: SfxItemSet
652 #* Output: ---
653 #*
654 #************************************************************************/
655 
657 {
658  bool bDataChanged = m_xFtLanguage->get_sensitive() || m_xCbSourceFormat->get_sensitive();
659  if ( bDataChanged )
660  {
661  const SfxItemSet& rMyItemSet = GetItemSet();
662  sal_uInt16 nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_VALUE );
663  SfxItemState eItemState = rMyItemSet.GetItemState( nWhich, false );
664 
665  // OK chosen - Is format code input entered already taken over?
666  // If not, simulate Add. Upon syntax error ignore input and prevent Put.
667  OUString aFormat = m_xEdFormat->get_text();
668  sal_uInt32 nCurKey = pNumFmtShell->GetCurNumFmtKey();
669 
670  if ( m_xIbAdd->get_sensitive() || pNumFmtShell->IsTmpCurrencyFormat(aFormat) )
671  { // #79599# It is not sufficient to just add the format code (or
672  // delete it in case of bOneAreaFlag and resulting category change).
673  // Upon switching tab pages we need all settings to be consistent
674  // in case this page will be redisplayed later.
675  bDataChanged = Click_Impl(*m_xIbAdd);
676  nCurKey = pNumFmtShell->GetCurNumFmtKey();
677  }
678  else if(nCurKey == NUMKEY_UNDEFINED)
679  { // something went wrong, e.g. in Writer #70281#
680  pNumFmtShell->FindEntry(aFormat, &nCurKey);
681  }
682 
683 
684  // Chosen format:
685 
686  if ( bDataChanged )
687  {
688  bDataChanged = ( nInitFormat != nCurKey );
689 
690  if (bDataChanged)
691  {
692  rCoreAttrs->Put( SfxUInt32Item( nWhich, nCurKey ) );
693  }
694  else if(SfxItemState::DEFAULT == eItemState)
695  {
696  rCoreAttrs->ClearItem( nWhich );
697  }
698  }
699 
700 
701  // List of changed user defined formats:
702 
703  std::vector<sal_uInt32> const & aDelFormats = pNumFmtShell->GetUpdateData();
704 
705  if ( !aDelFormats.empty() )
706  {
707 
708  pNumItem->SetDelFormats( std::vector(aDelFormats) );
709 
710  if(bNumItemFlag)
711  {
712  rCoreAttrs->Put( *pNumItem );
713  }
714  else
715  {
717 
718  DBG_ASSERT( pDocSh, "DocShell not found!" );
719 
720 
721  if ( pDocSh )
722  pDocSh->PutItem( *pNumItem );
723  }
724  }
725 
726 
727  // Whether source format is to be taken or not:
728 
729  if ( m_xCbSourceFormat->get_sensitive() )
730  {
731  SfxItemState _eItemState = rMyItemSet.GetItemState( SID_ATTR_NUMBERFORMAT_SOURCE, false );
732  const SfxBoolItem* pBoolItem =
733  GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE );
734  bool bOld = pBoolItem && pBoolItem->GetValue();
735  rCoreAttrs->Put( SfxBoolItem( SID_ATTR_NUMBERFORMAT_SOURCE, m_xCbSourceFormat->get_active() ) );
736  if ( !bDataChanged )
737  bDataChanged = (bOld != m_xCbSourceFormat->get_active() ||
738  _eItemState != SfxItemState::SET);
739  }
740 
741  // FillItemSet is only called on OK, here we can notify the
742  // NumberFormatShell that all new user defined formats are valid.
743  pNumFmtShell->ValidateNewEntries();
744  if(m_xLbLanguage->get_visible() &&
745  m_xLbLanguage->find_text(sAutomaticLangEntry) != -1)
746  rCoreAttrs->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ADD_AUTO,
747  m_xLbLanguage->get_active_text() == sAutomaticLangEntry));
748  }
749 
750  return bDataChanged;
751 }
752 
753 
755 {
756  if ( _pSet )
757  FillItemSet( _pSet );
758  return DeactivateRC::LeavePage;
759 }
760 
761 void SvxNumberFormatTabPage::FillFormatListBox_Impl( std::vector<OUString>& rEntries )
762 {
763  OUString aEntry;
764  OUString aTmpString;
765  size_t i = 0;
766  short nTmpCatPos;
767 
768  m_xLbFormat->clear();
769  if (rEntries.empty())
770  return;
771 
772  m_xLbFormat->freeze();
773 
774  if(bOneAreaFlag)
775  {
776  nTmpCatPos=nFixedCategory;
777  }
778  else
779  {
780  nTmpCatPos=m_xLbCategory->get_selected_index();
781  }
782 
783  switch (nTmpCatPos)
784  {
785  case CAT_ALL:
786  case CAT_TEXT:
787  case CAT_NUMBER: i=1;
788  aEntry=rEntries[0];
789  if (nTmpCatPos == CAT_TEXT)
790  aTmpString=aEntry;
791  else
792  aTmpString = pNumFmtShell->GetStandardName();
793  m_xLbFormat->append_text(aTmpString);
794  break;
795 
796  default: break;
797  }
798 
799  if(pNumFmtShell!=nullptr)
800  {
801  for ( ; i < rEntries.size(); ++i )
802  {
803  aEntry = rEntries[i];
804  short aPrivCat = pNumFmtShell->GetCategory4Entry( static_cast<short>(i) );
805  if(aPrivCat!=CAT_TEXT)
806  {
807  const Color* pPreviewColor = nullptr;
808  OUString aPreviewString( GetExpColorString( pPreviewColor, aEntry, aPrivCat ) );
809  m_xLbFormat->append_text(aPreviewString);
810  if (pPreviewColor)
811  m_xLbFormat->set_font_color(m_xLbFormat->n_children() - 1, *pPreviewColor);
812  }
813  else
814  {
815  m_xLbFormat->append_text(aEntry);
816  }
817  }
818  }
819  m_xLbFormat->thaw();
820  rEntries.clear();
821 }
822 
823 /*************************************************************************
824 #* Method: UpdateOptions_Impl
825 #*------------------------------------------------------------------------
826 #*
827 #* Class: SvxNumberFormatTabPage
828 #* Function: Adjusts the options attributes
829 #* depending on the selected format.
830 #* Input: Flag, whether the category has changed.
831 #* Output: ---
832 #*
833 #************************************************************************/
834 
835 void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_False*/ )
836 {
837  OUString theFormat = m_xEdFormat->get_text();
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;
844  sal_Int32 nCurrencyPos = get_active_currency();
845 
846  if(bOneAreaFlag)
847  nCurCategory=nFixedCategory;
848 
849 
850  pNumFmtShell->GetOptions( theFormat,
851  bThousand, bNegRed,
852  nDecimals, nZeroes,
853  nCategory );
854  bool bDoIt=false;
855  if(nCategory==CAT_CURRENCY)
856  {
857  sal_uInt16 nTstPos=pNumFmtShell->FindCurrencyFormat(theFormat);
858  if(nCurrencyPos!=static_cast<sal_Int32>(nTstPos) && nTstPos!=sal_uInt16(-1))
859  {
860  set_active_currency(nTstPos);
861  pNumFmtShell->SetCurrencySymbol(nTstPos);
862  bDoIt=true;
863  }
864  }
865 
866  if ( nCategory != nCurCategory || bDoIt)
867  {
868  if ( bCheckCatChange )
869  {
870  if(bOneAreaFlag)
871  SetCategory(0);
872  else
873  SetCategory(nCategory );
874 
875  UpdateFormatListBox_Impl( true, false );
876  }
877  }
878  else if ( m_xLbFormat->n_children() > 0 )
879  {
880  sal_uInt32 nCurEntryKey=NUMKEY_UNDEFINED;
881  if(!pNumFmtShell->FindEntry( m_xEdFormat->get_text(),&nCurEntryKey))
882  {
883  m_xLbFormat->select(-1);
884  }
885  }
886  if(bOneAreaFlag)
887  {
888  nCategory=nFixedCategory;
889  }
890 
893  switch ( nCategory )
894  {
895  case CAT_SCIENTIFIC: // bThousand is for Engineering notation
896  {
897  sal_uInt16 nIntDigits = pNumFmtShell->GetFormatIntegerDigits(theFormat);
898  bThousand = (nIntDigits > 0) && (nIntDigits % 3 == 0);
899  m_xBtnEngineering->set_sensitive(true);
900  m_xBtnEngineering->set_active( bThousand );
901  }
902  [[fallthrough]];
903  case CAT_NUMBER:
904  case CAT_PERCENT:
905  case CAT_CURRENCY:
906  case CAT_FRACTION:
907  case CAT_TIME:
908  m_xFtOptions->set_sensitive(true);
909  if ( nCategory == CAT_FRACTION )
910  {
911  m_xFtDenominator->set_sensitive(true);
912  m_xEdDenominator->set_sensitive(true);
913  }
914  else
915  {
916  m_xFtDecimals->set_sensitive(true);
917  m_xEdDecimals->set_sensitive(true);
918  }
919  m_xFtLeadZeroes->set_sensitive( nCategory != CAT_TIME );
920  m_xEdLeadZeroes->set_sensitive( nCategory != CAT_TIME );
921  m_xBtnNegRed->set_sensitive(true);
922  if ( nCategory == CAT_NUMBER && m_xLbFormat->get_selected_index() == 0 )
923  m_xEdDecimals->set_text( "" ); //General format tdf#44399
924  else
925  if ( nCategory == CAT_FRACTION )
926  m_xEdDenominator->set_value( nDecimals );
927  else
928  m_xEdDecimals->set_value( nDecimals );
929  if ( nCategory != CAT_TIME )
930  m_xEdLeadZeroes->set_value( nZeroes );
931  m_xBtnNegRed->set_active( bNegRed );
932  if ( nCategory != CAT_SCIENTIFIC )
933  {
934  m_xBtnThousand->set_sensitive( nCategory != CAT_TIME );
935  m_xBtnThousand->set_active( bThousand && nCategory != CAT_TIME );
936  }
937  break;
938 
939  case CAT_ALL:
940  case CAT_USERDEFINED:
941  case CAT_TEXT:
942  case CAT_DATE:
943  case CAT_BOOLEAN:
944  default:
945  m_xFtOptions->set_sensitive(false);
946  m_xFtDecimals->set_sensitive(false);
947  m_xEdDecimals->set_sensitive(false);
948  m_xFtDenominator->set_sensitive(false);
949  m_xEdDenominator->set_sensitive(false);
950  m_xFtLeadZeroes->set_sensitive(false);
951  m_xEdLeadZeroes->set_sensitive(false);
952  m_xBtnNegRed->set_sensitive(false);
953  m_xBtnThousand->set_sensitive(false);
954  m_xBtnEngineering->set_sensitive(false);
955  m_xEdDecimals->set_text( OUString() );
956  m_xEdLeadZeroes->set_text( OUString() );
957  m_xBtnNegRed->set_active( false );
958  m_xBtnThousand->set_active( false );
959  m_xBtnEngineering->set_active( false );
960  }
961 }
962 
963 
964 /*************************************************************************
965 #* Method: UpdateFormatListBox_Impl
966 #*------------------------------------------------------------------------
967 #*
968 #* Class: SvxNumberFormatTabPage
969 #* Function: Updates the format listbox and additionally the
970 #* string in the editbox is changed depending on
971 #* the bUpdateEdit flag.
972 #* Input: Flags for category and editbox.
973 #* Output: ---
974 #*
975 #************************************************************************/
976 
978  (
979  bool bCat, // Category or country/language ListBox?
980  bool bUpdateEdit
981  )
982 {
983  std::vector<OUString> aEntryList;
984  short nFmtLbSelPos = 0;
985  short nTmpCatPos;
986 
987  if(bOneAreaFlag)
988  {
989  nTmpCatPos=nFixedCategory;
990  }
991  else
992  {
993  nTmpCatPos=m_xLbCategory->get_selected_index();
994  }
995 
996 
997  if ( bCat )
998  {
999  if(nTmpCatPos!=CAT_CURRENCY)
1000  m_xLbCurrency->hide();
1001  else
1002  m_xLbCurrency->show();
1003 
1004  pNumFmtShell->CategoryChanged(nTmpCatPos,nFmtLbSelPos, aEntryList);
1005  }
1006  else
1007  pNumFmtShell->LanguageChanged(m_xLbLanguage->get_active_id(),
1008  nFmtLbSelPos,aEntryList);
1009 
1010  REMOVE_DONTKNOW() // possibly UI-Enable
1011 
1012 
1013  if ( (!aEntryList.empty()) && (nFmtLbSelPos != SELPOS_NONE) )
1014  {
1015  if(bUpdateEdit)
1016  {
1017  OUString aFormat=aEntryList[nFmtLbSelPos];
1018  m_xEdFormat->set_text(aFormat);
1019  m_xFtComment->set_label(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
1020  }
1021 
1022  if(!bOneAreaFlag || !bCat)
1023  {
1024  FillFormatListBox_Impl( aEntryList );
1025  m_xLbFormat->select(nFmtLbSelPos);
1026 
1027  m_xFtComment->set_label(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
1028  if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
1029  {
1030  if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).isEmpty())
1031  {
1032  m_xFtComment->set_label(m_xLbCategory->get_text(1));
1033  }
1034  }
1035  ChangePreviewText( static_cast<sal_uInt16>(nFmtLbSelPos) );
1036  }
1037 
1038  }
1039  else
1040  {
1041  FillFormatListBox_Impl( aEntryList );
1042  if(nFmtLbSelPos != SELPOS_NONE)
1043  {
1044  m_xLbFormat->select(static_cast<sal_uInt16>(nFmtLbSelPos));
1045 
1046  m_xFtComment->set_label(pNumFmtShell->GetComment4Entry(nFmtLbSelPos));
1047  if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
1048  {
1049  if(pNumFmtShell->GetComment4Entry(nFmtLbSelPos).isEmpty())
1050  {
1051  m_xFtComment->set_label(m_xLbCategory->get_text(1));
1052  }
1053  }
1054  }
1055  else
1056  {
1057  m_xLbFormat->select(-1);
1058  }
1059 
1060  if ( bUpdateEdit )
1061  {
1062  m_xEdFormat->set_text( OUString() );
1063  m_aWndPreview.NotifyChange( OUString() );
1064  }
1065  }
1066 
1067  aEntryList.clear();
1068 }
1069 
1070 
1078 {
1079  bool bIsScientific = m_xLbCategory->get_selected_index() == CAT_SCIENTIFIC;
1080  m_xBtnThousand->set_visible( !bIsScientific );
1081  m_xBtnEngineering->set_visible( bIsScientific );
1082 }
1083 
1084 
1092 {
1093  bool bIsFraction = m_xLbCategory->get_selected_index() == CAT_FRACTION;
1094  m_xFtDecimals->set_visible( !bIsFraction );
1095  m_xEdDecimals->set_visible( !bIsFraction );
1096  m_xFtDenominator->set_visible( bIsFraction );
1097  m_xEdDenominator->set_visible( bIsFraction );
1098 }
1099 
1100 
1101 /*************************************************************************
1102 #* Handle: DoubleClickHdl_Impl
1103 #*------------------------------------------------------------------------
1104 #*
1105 #* Class: SvxNumberFormatTabPage
1106 #* Function: On a double click in the format listbox the
1107 #* value is adopted and the OK button pushed.
1108 #* Input: Pointer on the Listbox
1109 #* Output: ---
1110 #*
1111 #************************************************************************/
1112 IMPL_LINK(SvxNumberFormatTabPage, DoubleClickHdl_Impl, weld::TreeView&, rLb, bool)
1113 {
1114  SelFormatHdl_Impl(&rLb);
1115 
1116  SfxOkDialogController* pController = GetDialogController();
1117  assert(pController);
1118  weld::Button& rOkButton = pController->GetOKButton();
1119  rOkButton.clicked();
1120 
1121  return true;
1122 }
1123 
1124 /*************************************************************************
1125 #* Method: SelFormatHdl_Impl
1126 #*------------------------------------------------------------------------
1127 #*
1128 #* Class: SvxNumberFormatTabPage
1129 #* Function: Is called when the language, the category or the format
1130 #* is changed. Accordingly the settings are adjusted.
1131 #* Input: Pointer on the Listbox
1132 #* Output: ---
1133 #*
1134 #************************************************************************/
1135 
1136 IMPL_LINK(SvxNumberFormatTabPage, SelFormatClickHdl_Impl, weld::Toggleable&, rLb, void)
1137 {
1138  SelFormatHdl_Impl(&rLb);
1139 }
1140 
1141 IMPL_LINK(SvxNumberFormatTabPage, SelFormatTreeListBoxHdl_Impl, weld::TreeView&, rLb, void)
1142 {
1143  SelFormatHdl_Impl(&rLb);
1144 }
1145 
1146 IMPL_LINK(SvxNumberFormatTabPage, SelFormatListBoxHdl_Impl, weld::ComboBox&, rLb, void)
1147 {
1148  SelFormatHdl_Impl(&rLb);
1149 }
1150 
1152 {
1154  {
1155  // Click handler is called before focus change handler, so finish
1156  // comment editing of previous format, otherwise a new format will have
1157  // the old comment displayed after LostFocusHdl_Impl() is called
1158  // later. Also, clicking into another category invalidates the format
1159  // list and SvxNumberFormatShell::SetComment4Entry() could either
1160  // access a wrong format from aCurEntryList[nEntry] or crash there if
1161  // the new vector has less elements.
1162  LostFocusHdl_Impl(*pLb);
1163  }
1164 
1165  if (pLb == m_xCbSourceFormat.get())
1166  {
1167  EnableBySourceFormat_Impl(); // enable/disable everything else
1168  if ( m_xCbSourceFormat->get_active() )
1169  return; // just disabled everything else
1170 
1171  // Reinit options enable/disable for current selection.
1172 
1173  // Current category may be UserDefined with no format entries defined.
1174  if (m_xLbFormat->get_selected_index() == -1)
1175  pLb = m_xLbCategory.get(); // continue with the current category selected
1176  else
1177  pLb = m_xLbFormat.get(); // continue with the current format selected
1178  }
1179 
1180  sal_Int32 nTmpCatPos;
1181 
1182  if(bOneAreaFlag)
1183  {
1184  nTmpCatPos=nFixedCategory;
1185  }
1186  else
1187  {
1188  nTmpCatPos=m_xLbCategory->get_selected_index();
1189  }
1190 
1191  if (nTmpCatPos==CAT_CURRENCY && pLb == m_xLbCurrency.get())
1192  pNumFmtShell->SetCurrencySymbol(get_active_currency());
1193 
1194  // Format-ListBox ----------------------------------------------------
1195  if (pLb == m_xLbFormat.get())
1196  {
1197  int nSelPos = m_xLbFormat->get_selected_index();
1198  short nFmtLbSelPos = static_cast<short>(nSelPos);
1199 
1200  OUString aFormat = pNumFmtShell->GetFormat4Entry(nFmtLbSelPos);
1201  OUString aComment = pNumFmtShell->GetComment4Entry(nFmtLbSelPos);
1202 
1203  if(pNumFmtShell->GetUserDefined4Entry(nFmtLbSelPos))
1204  {
1205  if(aComment.isEmpty())
1206  {
1207  aComment = m_xLbCategory->get_text(1);
1208  }
1209  }
1210 
1211  if ( !aFormat.isEmpty() )
1212  {
1213  if (!m_xEdFormat->has_focus())
1214  m_xEdFormat->set_text( aFormat );
1215  m_xFtComment->set_label(aComment);
1216  ChangePreviewText( static_cast<sal_uInt16>(nSelPos) );
1217  }
1218 
1219  REMOVE_DONTKNOW() // possibly UI-Enable
1220 
1221  if ( pNumFmtShell->FindEntry( aFormat) )
1222  {
1223  m_xIbAdd->set_sensitive(false );
1224  bool bIsUserDef=pNumFmtShell->IsUserDefined( aFormat );
1225  m_xIbRemove->set_sensitive(bIsUserDef);
1226  m_xIbInfo->set_sensitive(bIsUserDef);
1227 
1228  }
1229  else
1230  {
1231  m_xIbAdd->set_sensitive(true);
1232  m_xIbInfo->set_sensitive(true);
1233  m_xIbRemove->set_sensitive(false );
1234  m_xFtComment->set_label(m_xEdComment->get_text());
1235 
1236  }
1237  UpdateOptions_Impl( false );
1238 
1239  return;
1240  }
1241 
1242 
1243  // category-ListBox -------------------------------------------------
1244  if (pLb == m_xLbCategory.get() || pLb == m_xLbCurrency.get())
1245  {
1246  UpdateFormatListBox_Impl( true, true );
1247  EditHdl_Impl( nullptr );
1248  UpdateOptions_Impl( false );
1249 
1250  return;
1251  }
1252 
1253 
1254  // language/country-ListBox ----------------------------------------------
1255  if (pLb == m_xLbLanguage->get_widget())
1256  {
1257  UpdateFormatListBox_Impl( false, true );
1258  EditHdl_Impl(m_xEdFormat.get());
1259 
1260  return;
1261  }
1262 }
1263 
1264 
1265 /*************************************************************************
1266 #* Method: ClickHdl_Impl, weld::Button& rIB
1267 #*------------------------------------------------------------------------
1268 #*
1269 #* Class: SvxNumberFormatTabPage
1270 #* Function: Called when the add or delete button is pushed,
1271 #* adjusts the number format list.
1272 #* Input: Toolbox- Button
1273 #* Output: ---
1274 #*
1275 #************************************************************************/
1276 
1277 IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, weld::Button&, rIB, void)
1278 {
1279  Click_Impl(rIB);
1280 }
1281 
1283 {
1284  sal_uInt8 nReturn = 0;
1285  constexpr sal_uInt8 nReturnChanged = 0x1; // THE boolean return value
1286  constexpr sal_uInt8 nReturnAdded = 0x2; // temp: format added
1287  constexpr sal_uInt8 nReturnOneArea = 0x4; // temp: one area but category changed => ignored
1288 
1289  if (&rIB == m_xIbAdd.get())
1290  { // Also called from FillItemSet() if a temporary currency format has
1291  // to be added, not only if the Add button is enabled.
1292  OUString aFormat = m_xEdFormat->get_text();
1293  std::vector<OUString> aEntryList;
1294  std::vector<OUString> a2EntryList;
1295  sal_uInt16 nCatLbSelPos = 0;
1296  short nFmtLbSelPos = SELPOS_NONE;
1297  sal_Int32 nErrPos=0;
1298 
1299  pNumFmtShell->SetCurCurrencyEntry(nullptr);
1300  bool bAdded = pNumFmtShell->AddFormat( aFormat, nErrPos,
1301  nCatLbSelPos, nFmtLbSelPos,
1302  aEntryList);
1303  if ( bAdded )
1304  nReturn |= nReturnChanged | nReturnAdded;
1305 
1306  if (m_xEdComment->get_visible())
1307  {
1308  m_xEdFormat->grab_focus();
1309  m_xEdComment->hide();
1310  m_xFtComment->show();
1311  m_xFtComment->set_label(m_xEdComment->get_text());
1312  }
1313 
1314  if ( !nErrPos ) // Syntax ok?
1315  {
1316  // May be sorted under a different locale if LCID was parsed.
1317  if (bAdded)
1318  m_xLbLanguage->set_active_id(pNumFmtShell->GetCurLanguage());
1319 
1320  if (nCatLbSelPos==CAT_CURRENCY)
1321  set_active_currency(pNumFmtShell->GetCurrencySymbol());
1322 
1323  if(bOneAreaFlag && (nFixedCategory!=nCatLbSelPos))
1324  {
1325  if(bAdded) aEntryList.clear();
1326  pNumFmtShell->RemoveFormat( aFormat,
1327  nCatLbSelPos,
1328  nFmtLbSelPos,
1329  a2EntryList);
1330  a2EntryList.clear();
1331  m_xEdFormat->grab_focus();
1332  m_xEdFormat->select_region(0, -1);
1333  nReturn |= nReturnOneArea;
1334  }
1335  else
1336  {
1337  if ( bAdded && (nFmtLbSelPos != SELPOS_NONE) )
1338  {
1339  // everything all right
1340  if(bOneAreaFlag) //@@ ???
1341  SetCategory(0);
1342  else
1343  SetCategory(nCatLbSelPos );
1344 
1345  FillFormatListBox_Impl( aEntryList );
1346  if (m_xEdComment->get_text()!=m_xLbCategory->get_text(1))
1347  {
1348  pNumFmtShell->SetComment4Entry(nFmtLbSelPos,
1349  m_xEdComment->get_text());
1350  }
1351  else
1352  {
1353  pNumFmtShell->SetComment4Entry(nFmtLbSelPos,
1354  OUString());
1355  }
1356  m_xLbFormat->select(static_cast<sal_uInt16>(nFmtLbSelPos));
1357  m_xEdFormat->set_text( aFormat );
1358 
1359  m_xEdComment->set_text(m_xLbCategory->get_text(1)); // String for user defined
1360 
1361  ChangePreviewText( static_cast<sal_uInt16>(nFmtLbSelPos) );
1362  }
1363  }
1364  }
1365  else // syntax error
1366  {
1367  m_xEdFormat->grab_focus();
1368  m_xEdFormat->select_region(nErrPos == -1 ? m_xEdFormat->get_text().getLength() : nErrPos, -1);
1369  }
1370  EditHdl_Impl(m_xEdFormat.get());
1371  nReturn = ((nReturn & nReturnOneArea) ? 0 : (nReturn & nReturnChanged));
1372 
1373  aEntryList.clear();
1374  a2EntryList.clear();
1375  }
1376  else if (&rIB == m_xIbRemove.get())
1377  {
1378  OUString aFormat = m_xEdFormat->get_text();
1379  std::vector<OUString> aEntryList;
1380  sal_uInt16 nCatLbSelPos = 0;
1381  short nFmtLbSelPos = SELPOS_NONE;
1382 
1383  pNumFmtShell->RemoveFormat( aFormat,
1384  nCatLbSelPos,
1385  nFmtLbSelPos,
1386  aEntryList );
1387 
1388  m_xEdComment->set_text(m_xLbCategory->get_text(1));
1389 
1390  if( nFmtLbSelPos>=0 && o3tl::make_unsigned(nFmtLbSelPos)<aEntryList.size() )
1391  {
1392  aFormat = aEntryList[nFmtLbSelPos];
1393  }
1394 
1395  FillFormatListBox_Impl( aEntryList );
1396 
1397  if ( nFmtLbSelPos != SELPOS_NONE )
1398  {
1399  if(bOneAreaFlag) //@@ ???
1400  SetCategory(0);
1401  else
1402  SetCategory(nCatLbSelPos );
1403 
1404  m_xLbFormat->select(static_cast<sal_uInt16>(nFmtLbSelPos));
1405  m_xEdFormat->set_text( aFormat );
1406  ChangePreviewText( static_cast<sal_uInt16>(nFmtLbSelPos) );
1407  }
1408  else
1409  {
1410  // set to "all/standard"
1411  SetCategory(0);
1413  }
1414 
1415  EditHdl_Impl(m_xEdFormat.get());
1416 
1417  aEntryList.clear();
1418  }
1419  else if (&rIB == m_xIbInfo.get())
1420  {
1421  if (!m_xEdComment->get_visible())
1422  {
1423  if (!m_xIbAdd->get_sensitive())
1424  // Editing for existing format.
1425  m_nLbFormatSelPosEdComment = m_xLbFormat->get_selected_index();
1426 
1427  m_xEdComment->set_text(m_xFtComment->get_label());
1428  m_xEdComment->show();
1429  m_xFtComment->hide();
1430  m_xEdComment->grab_focus();
1431  }
1432  else
1433  {
1434  m_xEdFormat->grab_focus();
1435  m_xFtComment->set_label( m_xEdComment->get_text());
1436  m_xEdComment->hide();
1437  m_xFtComment->show();
1438  }
1439  }
1440 
1441  return nReturn;
1442 }
1443 
1444 
1445 /*************************************************************************
1446 #* Method: EditHdl_Impl
1447 #*------------------------------------------------------------------------
1448 #*
1449 #* Class: SvxNumberFormatTabPage
1450 #* Function: When the entry in the edit field is changed
1451 #* the preview is updated and
1452 #* Input: Pointer on Editbox
1453 #* Output: ---
1454 #*
1455 #************************************************************************/
1456 
1457 IMPL_LINK(SvxNumberFormatTabPage, EditModifyHdl_Impl, weld::Entry&, rEdit, void)
1458 {
1459  EditHdl_Impl(&rEdit);
1460 }
1461 
1463 {
1464  sal_uInt32 nCurKey = NUMKEY_UNDEFINED;
1465 
1466  if ( m_xEdFormat->get_text().isEmpty() )
1467  {
1468  m_xIbAdd->set_sensitive(false );
1469  m_xIbRemove->set_sensitive(false );
1470  m_xIbInfo->set_sensitive(false );
1471  m_xFtComment->set_label(OUString());
1472  }
1473  else
1474  {
1475  OUString aFormat = m_xEdFormat->get_text();
1476  MakePreviewText( aFormat );
1477 
1478  if ( pNumFmtShell->FindEntry( aFormat, &nCurKey ) )
1479  {
1480  m_xIbAdd->set_sensitive(false );
1481  bool bUserDef=pNumFmtShell->IsUserDefined( aFormat );
1482 
1483  m_xIbRemove->set_sensitive(bUserDef);
1484  m_xIbInfo->set_sensitive(bUserDef);
1485 
1486  if(bUserDef)
1487  {
1488  sal_uInt16 nTmpCurPos=pNumFmtShell->FindCurrencyFormat(aFormat );
1489  if (nTmpCurPos != sal_uInt16(-1))
1490  set_active_currency(nTmpCurPos);
1491  }
1492  short nPosi=pNumFmtShell->GetListPos4Entry( nCurKey, aFormat);
1493  if(nPosi>=0)
1494  m_xLbFormat->select(static_cast<sal_uInt16>(nPosi));
1495 
1496  }
1497  else
1498  {
1499 
1500  m_xIbAdd->set_sensitive(true);
1501  m_xIbInfo->set_sensitive(true);
1502  m_xIbRemove->set_sensitive(false );
1503 
1504  m_xFtComment->set_label(m_xEdComment->get_text());
1505 
1506  }
1507  }
1508 
1509  if (pEdFormat)
1510  {
1511  pNumFmtShell->SetCurNumFmtKey( nCurKey );
1512  UpdateOptions_Impl( true );
1513  }
1514 }
1515 
1516 
1517 /*************************************************************************
1518 #* Method: NotifyChange
1519 #*------------------------------------------------------------------------
1520 #*
1521 #* Class: SvxNumberFormatTabPage
1522 #* Function: Does changes in the number attributes.
1523 #* Input: Options- Controls
1524 #* Output: ---
1525 #*
1526 #************************************************************************/
1527 
1528 IMPL_LINK(SvxNumberFormatTabPage, OptClickHdl_Impl, weld::Toggleable&, rOptCtrl, void)
1529 {
1530  OptHdl_Impl(&rOptCtrl);
1531 }
1532 
1533 IMPL_LINK(SvxNumberFormatTabPage, OptEditHdl_Impl, weld::SpinButton&, rEdit, void)
1534 {
1535  OptHdl_Impl(&rEdit);
1536 }
1537 
1539 {
1540  if ( !(pOptCtrl == m_xEdLeadZeroes.get()
1541  || pOptCtrl == m_xEdDecimals.get()
1542  || pOptCtrl == m_xEdDenominator.get()
1543  || pOptCtrl == m_xBtnNegRed.get()
1544  || pOptCtrl == m_xBtnThousand.get()
1545  || pOptCtrl == m_xBtnEngineering.get()))
1546  return;
1547 
1548  OUString aFormat;
1549  bool bThousand = ( m_xBtnThousand->get_visible() && m_xBtnThousand->get_sensitive() && m_xBtnThousand->get_active() )
1550  || ( m_xBtnEngineering->get_visible() && m_xBtnEngineering->get_sensitive() && m_xBtnEngineering->get_active() );
1551  bool bNegRed = m_xBtnNegRed->get_sensitive() && m_xBtnNegRed->get_active();
1552  sal_uInt16 nPrecision = (m_xEdDecimals->get_sensitive() && m_xEdDecimals->get_visible())
1553  ? static_cast<sal_uInt16>(m_xEdDecimals->get_value())
1554  : ( (m_xEdDenominator->get_sensitive() && m_xEdDenominator->get_visible())
1555  ? static_cast<sal_uInt16>(m_xEdDenominator->get_value())
1556  : sal_uInt16(0) );
1557  sal_uInt16 nLeadZeroes = (m_xEdLeadZeroes->get_sensitive())
1558  ? static_cast<sal_uInt16>(m_xEdLeadZeroes->get_value())
1559  : sal_uInt16(0);
1560  if ( pNumFmtShell->GetStandardName() == m_xEdFormat->get_text() )
1561  {
1562  m_xEdDecimals->set_value(nPrecision);
1563  }
1564 
1565  pNumFmtShell->MakeFormat( aFormat,
1566  bThousand, bNegRed,
1567  nPrecision, nLeadZeroes,
1568  static_cast<sal_uInt16>(m_xLbFormat->get_selected_index()) );
1569 
1570  m_xEdFormat->set_text( aFormat );
1571  MakePreviewText( aFormat );
1572 
1573  if ( pNumFmtShell->FindEntry( aFormat ) )
1574  {
1575  m_xIbAdd->set_sensitive(false );
1576  bool bUserDef=pNumFmtShell->IsUserDefined( aFormat );
1577  m_xIbRemove->set_sensitive(bUserDef);
1578  m_xIbInfo->set_sensitive(bUserDef);
1579  EditHdl_Impl(m_xEdFormat.get());
1580 
1581  }
1582  else
1583  {
1584  EditHdl_Impl( nullptr );
1585  m_xLbFormat->select(-1);
1586  }
1587 }
1588 
1589 /*************************************************************************
1590 #* Method: LostFocusHdl_Impl
1591 #*------------------------------------------------------------------------
1592 #*
1593 #* Class: SvxNumberFormatTabPage
1594 #* Function: Does changes in the number attributes.
1595 #* Input: Options- Controls
1596 #* Output: ---
1597 #*
1598 #************************************************************************/
1599 
1601 {
1602  if (!pNumFmtShell)
1603  return;
1604 
1605  const bool bAddSensitive = m_xIbAdd->get_sensitive();
1606  if (bAddSensitive || m_nLbFormatSelPosEdComment != SELPOS_NONE)
1607  // Comment editing was possible.
1608  m_xFtComment->set_label(m_xEdComment->get_text());
1609 
1610  m_xEdComment->hide();
1611  m_xFtComment->show();
1612  if (m_nLbFormatSelPosEdComment != SELPOS_NONE)
1613  {
1614  // Save edited comment of existing format.
1615  pNumFmtShell->SetComment4Entry( m_nLbFormatSelPosEdComment, m_xEdComment->get_text());
1616  m_nLbFormatSelPosEdComment = SELPOS_NONE;
1617  }
1618  if (!bAddSensitive)
1619  {
1620  // String for user defined, if present
1621  OUString sEntry = m_xLbCategory->n_children() > 1 ? m_xLbCategory->get_text(1) : OUString();
1622  m_xEdComment->set_text(sEntry);
1623  }
1624 }
1625 
1626 /*************************************************************************
1627 #* Method: NotifyChange
1628 #*------------------------------------------------------------------------
1629 #*
1630 #* Class: SvxNumberFormatTabPage
1631 #* Function: Does changes in the number attributes.
1632 #* Input: Options- Controls
1633 #* Output: ---
1634 #*
1635 #************************************************************************/
1636 
1638  const Color*& rpPreviewColor, const OUString& rFormatStr, short nTmpCatPos)
1639 {
1641  switch (nTmpCatPos)
1642  {
1643  case CAT_ALL: i=SvxNumValCategory::Standard; break;
1644 
1645  case CAT_NUMBER: i=SvxNumValCategory::Standard; break;
1646 
1647  case CAT_PERCENT: i=SvxNumValCategory::Percent; break;
1648 
1649  case CAT_CURRENCY: i=SvxNumValCategory::Currency; break;
1650 
1651  case CAT_DATE: i=SvxNumValCategory::Date; break;
1652 
1653  case CAT_TIME: i=SvxNumValCategory::Time; break;
1654 
1655  case CAT_SCIENTIFIC: i=SvxNumValCategory::Scientific; break;
1656 
1657  case CAT_FRACTION: i=SvxNumValCategory::Fraction; break;
1658 
1659  case CAT_BOOLEAN: i=SvxNumValCategory::Boolean; break;
1660 
1661  case CAT_USERDEFINED: i=SvxNumValCategory::Standard; break;
1662 
1663  case CAT_TEXT:
1664  default: i=SvxNumValCategory::NoValue;break;
1665  }
1666  double fVal = fSvxNumValConst[i];
1667 
1668  OUString aPreviewString;
1669  pNumFmtShell->MakePrevStringFromVal( rFormatStr, aPreviewString, rpPreviewColor, fVal );
1670  return aPreviewString;
1671 }
1672 
1673 void SvxNumberFormatTabPage::MakePreviewText( const OUString& rFormat )
1674 {
1675  OUString aPreviewString;
1676  const Color* pPreviewColor = nullptr;
1677  pNumFmtShell->MakePreviewString( rFormat, aPreviewString, pPreviewColor );
1678  m_aWndPreview.NotifyChange( aPreviewString, pPreviewColor );
1679 }
1680 
1682 {
1683  OUString aPreviewString;
1684  const Color* pPreviewColor = nullptr;
1685  pNumFmtShell->FormatChanged( nPos, aPreviewString, pPreviewColor );
1686  m_aWndPreview.NotifyChange( aPreviewString, pPreviewColor );
1687 }
1688 
1690 {
1691  std::vector<OUString> aList;
1692 
1693  sal_uInt16 nSelPos=0;
1694  pNumFmtShell->GetCurrencySymbols(aList, &nSelPos);
1695 
1696  m_xLbCurrency->freeze();
1697  m_xLbCurrency->clear();
1698  bLegacyAutomaticCurrency = false;
1699  for (std::vector<OUString>::iterator i = aList.begin() + 1;i != aList.end(); ++i)
1700  m_xLbCurrency->append_text(*i);
1701  m_xLbCurrency->thaw();
1702 
1703  set_active_currency(nSelPos);
1704 }
1705 
1707 {
1708  int nCurCategory = m_xLbCategory->get_selected_index();
1709  sal_uInt16 nTmpCatPos;
1710 
1711  if (bOneAreaFlag)
1712  {
1713  nTmpCatPos=nFixedCategory;
1714  }
1715  else
1716  {
1717  nTmpCatPos=nPos;
1718  }
1719 
1720  if(m_xLbCategory->n_children()==1 || nCurCategory!=nPos)
1721  {
1722  if(nTmpCatPos!=CAT_CURRENCY)
1723  m_xLbCurrency->hide();
1724  else
1725  m_xLbCurrency->show();
1726  }
1727  m_xLbCategory->select(nPos);
1728 }
1729 
1730 /* to support Writer text field language handling an
1731  additional entry needs to be inserted into the ListBox
1732  which marks a certain language as automatically detected
1733  Additionally the "Default" language is removed
1734 */
1736 {
1737  m_xLbLanguage->remove_id(LANGUAGE_SYSTEM);
1738  m_xLbLanguage->append(eAutoLang, sAutomaticLangEntry);
1739  if (bSelect)
1740  m_xLbLanguage->set_active_id(eAutoLang);
1741 }
1742 
1744 {
1745  const SvxNumberInfoItem* pNumberInfoItem = aSet.GetItem<SvxNumberInfoItem>(SID_ATTR_NUMBERFORMAT_INFO, false);
1746  if (pNumberInfoItem && !pNumItem)
1747  pNumItem.reset(pNumberInfoItem->Clone());
1748 }
1749 
1750 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static const WhichRangesContainer pRanges
Definition: numfmt.hxx:59
bool GetValue() const
std::unique_ptr< weld::CustomWeld > m_xWndPreview
Definition: numfmt.hxx:116
OUString GetExpColorString(const Color *&rpPreviewColor, const OUString &aFormatStr, short nTmpCatPos)
Definition: numfmt.cxx:1637
std::unique_ptr< SvxNumberFormatShell > pNumFmtShell
Definition: numfmt.hxx:78
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override
Definition: numfmt.cxx:131
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
std::unique_ptr< weld::Label > m_xFtOptions
Definition: numfmt.hxx:98
#define CAT_NUMBER
void HideLanguage(bool bFlag=true)
Definition: numfmt.cxx:637
short m_nLbFormatSelPosEdComment
Definition: numfmt.hxx:80
static constexpr auto Items
sal_uInt32 nInitFormat
Definition: numfmt.hxx:79
static SvxNumberFormatShell * Create(SvNumberFormatter *pNumFormatter, sal_uInt32 nFormatKey, SvxNumberValueType eNumValType, const OUString &rNumStr)
std::unique_ptr< weld::Label > m_xFtLanguage
Definition: numfmt.hxx:96
Color aPrevCol
Definition: numfmt.hxx:38
OUString aPrevStr
Definition: numfmt.hxx:37
OUString sAutomaticCurrencyEntry
Definition: numfmt.hxx:88
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
std::unique_ptr< weld::Widget > m_xFormatCodeFrame
Definition: numfmt.hxx:108
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: numfmt.cxx:754
#define REMOVE_DONTKNOW()
Definition: numfmt.cxx:176
long Long
bool Click_Impl(const weld::Button &rIB)
Definition: numfmt.cxx:1282
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
std::unique_ptr< weld::CheckButton > m_xBtnNegRed
Definition: numfmt.hxx:103
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: numfmt.cxx:1743
css::uno::Reference< css::frame::XModel3 > GetModel() const
#define max(a, b)
void OptHdl_Impl(const weld::Widget *)
Definition: numfmt.cxx:1538
SvxNumberValueType
std::unique_ptr< weld::Button > m_xIbInfo
Definition: numfmt.hxx:111
static SfxObjectShell * Current()
void EnableBySourceFormat_Impl()
Definition: numfmt.cxx:600
void PutItem(const SfxPoolItem &rItem)
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: numfmt.cxx:656
virtual SvxNumberInfoItem * Clone(SfxItemPool *pPool=nullptr) const override
#define CAT_FRACTION
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
Size const & GetOutputSizePixel() const
void NotifyChange(const OUString &rPrevStr, const Color *pColor=nullptr)
Definition: numfmt.cxx:90
constexpr tools::Long Width() const
void SelFormatHdl_Impl(weld::Widget *)
Definition: numfmt.cxx:1151
void SetBackground()
#define SELPOS_NONE
const vcl::Font & GetFont() const
std::unique_ptr< SvxNumberInfoItem > pNumItem
Definition: numfmt.hxx:77
std::unique_ptr< weld::CheckButton > m_xBtnEngineering
Definition: numfmt.hxx:107
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: numfmt.cxx:307
#define CAT_TEXT
virtual weld::Button & GetOKButton() const =0
void SetExchangeSupport()
#define CAT_PERCENT
std::unique_ptr< weld::TreeView > m_xLbCategory
Definition: numfmt.hxx:92
const SfxItemSet & GetItemSet() const
#define LANGUAGE_NORWEGIAN
void FillFormatListBox_Impl(std::vector< OUString > &rEntries)
Definition: numfmt.cxx:761
void UpdateThousandEngineeringCheckBox()
Change visible checkbox according to category format if scientific format "Engineering notation" else...
Definition: numfmt.cxx:1077
std::unique_ptr< weld::CheckButton > m_xCbSourceFormat
Definition: numfmt.hxx:97
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
bool bNumItemFlag
for handling with DocShell
Definition: numfmt.hxx:82
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
Definition: numfmt.hxx:113
#define DBG_ASSERT(sCon, aError)
int i
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
#define NUMKEY_UNDEFINED
Definition: numfmt.cxx:51
std::unique_ptr< SvxLanguageBox > m_xLbLanguage
Definition: numfmt.hxx:115
std::unique_ptr< weld::ComboBox > m_xLbCurrency
Definition: numfmt.hxx:94
std::unique_ptr< weld::Entry > m_xEdFormat
Definition: numfmt.hxx:109
#define LANGUAGE_SYSTEM
const o3tl::enumarray< SvxNumValCategory, double > fSvxNumValConst
#define CAT_DATE
void SetCategory(sal_uInt16 nPos)
Definition: numfmt.cxx:1706
std::unique_ptr< weld::Label > m_xFtDecimals
Definition: numfmt.hxx:99
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
float u
void SetTextColor(const Color &rColor)
virtual void Reset(const SfxItemSet *rSet) override
Definition: numfmt.cxx:349
#define LANGUAGE_DONTKNOW
sal_Int32 mnPos
Definition: numfmt.hxx:39
#define CAT_ALL
#define CAT_BOOLEAN
std::unique_ptr< weld::Label > m_xFtFormat
Definition: numfmt.hxx:93
#define CAT_CURRENCY
std::unique_ptr< weld::Button > m_xIbRemove
Definition: numfmt.hxx:112
std::unique_ptr< weld::Label > m_xFtCategory
Definition: numfmt.hxx:91
void SetColor(const Color &)
void MakePreviewText(const OUString &rFormat)
Definition: numfmt.cxx:1673
sal_Unicode mnChar
Definition: numfmt.hxx:40
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void set_active_currency(sal_Int32 nCurCurrencyEntryPos)
Definition: numfmt.cxx:326
SfxItemState
weld::Entry & rEdit
void EditHdl_Impl(const weld::Entry *)
Definition: numfmt.cxx:1462
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
std::unique_ptr< weld::CheckButton > m_xBtnThousand
Definition: numfmt.hxx:106
constexpr tools::Long Height() const
unsigned char sal_uInt8
std::unique_ptr< weld::Button > m_xIbAdd
Definition: numfmt.hxx:110
void SetFont(const vcl::Font &rNewFont)
IMPL_LINK_NOARG(SvxNumberFormatTabPage, LostFocusHdl_Impl, weld::Widget &, void)
Definition: numfmt.cxx:1600
void clicked()
void SetTransparent(bool bTransparent)
std::unique_ptr< weld::Entry > m_xEdComment
Definition: numfmt.hxx:114
std::unique_ptr< weld::Label > m_xFtLeadZeroes
Definition: numfmt.hxx:104
std::unique_ptr< weld::SpinButton > m_xEdLeadZeroes
Definition: numfmt.hxx:105
#define CAT_USERDEFINED
#define CAT_TIME
std::unique_ptr< weld::SpinButton > m_xEdDecimals
Definition: numfmt.hxx:100
IMPL_LINK(SvxNumberFormatTabPage, DoubleClickHdl_Impl, weld::TreeView &, rLb, bool)
Definition: numfmt.cxx:1112
DeactivateRC
bool bLegacyAutomaticCurrency
Definition: numfmt.hxx:84
sal_uInt32 GetValue() const
std::unique_ptr< weld::TreeView > m_xLbFormat
Definition: numfmt.hxx:95
void UpdateDecimalsDenominatorEditBox()
Change visible Edit box and Fixed text according to category format if fraction format "Denominator p...
Definition: numfmt.cxx:1091
SvxNumValCategory
sal_uInt32 get_active_currency() const
Definition: numfmt.cxx:340
void UpdateFormatListBox_Impl(bool bCat, bool bUpdateEdit)
Definition: numfmt.cxx:978
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
void UpdateOptions_Impl(bool bCheckCatChange)
Definition: numfmt.cxx:835
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)
Definition: numfmt.cxx:184
virtual ~SvxNumberFormatTabPage() override
Definition: numfmt.cxx:236
void AddAutomaticLanguage_Impl(LanguageType eAutoLang, bool bSelect)
Definition: numfmt.cxx:1735
OUString sAutomaticLangEntry
Definition: numfmt.hxx:87
#define CAT_SCIENTIFIC
SvxNumberPreview m_aWndPreview
Definition: numfmt.hxx:90
void ChangePreviewText(sal_uInt16 nPos)
Definition: numfmt.cxx:1681
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
std::unique_ptr< weld::Label > m_xFtDenominator
Definition: numfmt.hxx:101
bool m_bDetectedRangeSegmentation false
std::unique_ptr< weld::SpinButton > m_xEdDenominator
Definition: numfmt.hxx:102