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