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