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