Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <hintids.hxx>
30 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 : : #include <comphelper/processfactory.hxx>
32 : : #include <editeng/unolingu.hxx>
33 : : #include <unotools/localedatawrapper.hxx>
34 : : #include <i18npool/lang.h>
35 : : #include <svl/zformat.hxx>
36 : : #include <svl/eitem.hxx>
37 : : #include <svx/svxids.hrc>
38 : : #include <svx/numinf.hxx>
39 : : #include <vcl/msgbox.hxx>
40 : : #include <svx/flagsdef.hxx>
41 : : #include <svl/itemset.hxx>
42 : : #include <docsh.hxx>
43 : : #include <swtypes.hxx>
44 : : #include <swmodule.hxx>
45 : : #include <view.hxx>
46 : : #include <wrtsh.hxx>
47 : : #include <numfmtlb.hxx>
48 : : #include <utlui.hrc>
49 : : #include "swabstdlg.hxx"
50 : : #include "dialog.hrc"
51 : : #include <unomid.h>
52 : : #include <sfx2/viewfrm.hxx>
53 : :
54 : : using namespace ::com::sun::star::uno;
55 : : using namespace ::com::sun::star::lang;
56 : :
57 : :
58 : : // STATIC DATA -----------------------------------------------------------
59 : :
60 : : /*--------------------------------------------------------------------
61 : : Beschreibung:
62 : : nFormatType: Formate dieses Typs anzeigen
63 : : nDefFmt: Dieses Format selektieren und ggf vorher
64 : : einfuegen
65 : : --------------------------------------------------------------------*/
66 : :
67 : 0 : NumFormatListBox::NumFormatListBox( Window* pWin, const ResId& rResId,
68 : : short nFormatType, sal_uLong nDefFmt,
69 : : sal_Bool bUsrFmts ) :
70 : : ListBox ( pWin, rResId ),
71 : : nCurrFormatType (-1),
72 : : nStdEntry (0),
73 : : bOneArea (sal_False),
74 : : nDefFormat (nDefFmt),
75 : : pVw (0),
76 : : pOwnFormatter (0),
77 : : bShowLanguageControl(sal_False),
78 : 0 : bUseAutomaticLanguage(sal_True)
79 : : {
80 [ # # ]: 0 : Init(nFormatType, bUsrFmts);
81 : 0 : }
82 : :
83 : 0 : NumFormatListBox::NumFormatListBox( Window* pWin, SwView* pView,
84 : : const ResId& rResId, short nFormatType,
85 : : sal_uLong nDefFmt, sal_Bool bUsrFmts ) :
86 : : ListBox ( pWin, rResId ),
87 : : nCurrFormatType (-1),
88 : : nStdEntry (0),
89 : : bOneArea (sal_False),
90 : : nDefFormat (nDefFmt),
91 : : pVw (pView),
92 : : pOwnFormatter (0),
93 : : bShowLanguageControl(sal_False),
94 : 0 : bUseAutomaticLanguage(sal_True)
95 : : {
96 [ # # ]: 0 : Init(nFormatType, bUsrFmts);
97 : 0 : }
98 : :
99 : 0 : void NumFormatListBox::Init(short nFormatType, sal_Bool bUsrFmts)
100 : : {
101 : 0 : SwView *pView = GetView();
102 : :
103 [ # # ]: 0 : if (pView)
104 : 0 : eCurLanguage = pView->GetWrtShell().GetCurLang();
105 : : else
106 [ # # ][ # # ]: 0 : eCurLanguage = SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() );
[ # # ]
107 : :
108 [ # # ]: 0 : if (bUsrFmts == sal_False)
109 : : {
110 [ # # ]: 0 : Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
111 [ # # ][ # # ]: 0 : pOwnFormatter = new SvNumberFormatter(xMSF, eCurLanguage);
112 : : }
113 : :
114 : 0 : SetFormatType(nFormatType);
115 : 0 : SetDefFormat(nDefFormat);
116 : :
117 : 0 : SetSelectHdl(LINK(this, NumFormatListBox, SelectHdl));
118 : 0 : }
119 : :
120 : 0 : NumFormatListBox::~NumFormatListBox()
121 : : {
122 [ # # ][ # # ]: 0 : delete pOwnFormatter;
123 [ # # ]: 0 : }
124 : :
125 : 0 : SwView* NumFormatListBox::GetView()
126 : : {
127 [ # # ]: 0 : if( pVw )
128 : 0 : return pVw;
129 : 0 : return ::GetActiveView();
130 : : }
131 : :
132 : 0 : void NumFormatListBox::SetFormatType(const short nFormatType)
133 : : {
134 [ # # ][ # # ]: 0 : if (nCurrFormatType == -1 ||
135 : : (nCurrFormatType & nFormatType) == 0) // Es gibt Mischformate, wie z.B. DateTime
136 : : {
137 : : SvNumberFormatter* pFormatter;
138 : :
139 [ # # ]: 0 : if( pOwnFormatter )
140 : 0 : pFormatter = pOwnFormatter;
141 : : else
142 : : {
143 [ # # ]: 0 : SwView *pView = GetView();
144 : : OSL_ENSURE(pView, "no view found");
145 [ # # ]: 0 : if(!pView)
146 : 0 : return;
147 : 0 : SwWrtShell &rSh = pView->GetWrtShell();
148 [ # # ]: 0 : pFormatter = rSh.GetNumberFormatter();
149 : : }
150 : :
151 [ # # ]: 0 : Clear(); // Alle Eintraege in der Listbox entfernen
152 : :
153 : 0 : NfIndexTableOffset eOffsetStart = NF_NUMBER_START;
154 : 0 : NfIndexTableOffset eOffsetEnd = NF_NUMBER_START;
155 : :
156 [ # # # # : 0 : switch( nFormatType )
# # # # #
# # # ]
157 : : {
158 : : case NUMBERFORMAT_NUMBER:
159 : 0 : eOffsetStart=NF_NUMBER_START;
160 : 0 : eOffsetEnd=NF_NUMBER_END;
161 : 0 : break;
162 : :
163 : : case NUMBERFORMAT_PERCENT:
164 : 0 : eOffsetStart=NF_PERCENT_START;
165 : 0 : eOffsetEnd=NF_PERCENT_END;
166 : 0 : break;
167 : :
168 : : case NUMBERFORMAT_CURRENCY:
169 : 0 : eOffsetStart=NF_CURRENCY_START;
170 : 0 : eOffsetEnd=NF_CURRENCY_END;
171 : 0 : break;
172 : :
173 : : case NUMBERFORMAT_DATETIME:
174 : 0 : eOffsetStart=NF_DATE_START;
175 : 0 : eOffsetEnd=NF_TIME_END;
176 : 0 : break;
177 : :
178 : : case NUMBERFORMAT_DATE:
179 : 0 : eOffsetStart=NF_DATE_START;
180 : 0 : eOffsetEnd=NF_DATE_END;
181 : 0 : break;
182 : :
183 : : case NUMBERFORMAT_TIME:
184 : 0 : eOffsetStart=NF_TIME_START;
185 : 0 : eOffsetEnd=NF_TIME_END;
186 : 0 : break;
187 : :
188 : : case NUMBERFORMAT_SCIENTIFIC:
189 : 0 : eOffsetStart=NF_SCIENTIFIC_START;
190 : 0 : eOffsetEnd=NF_SCIENTIFIC_END;
191 : 0 : break;
192 : :
193 : : case NUMBERFORMAT_FRACTION:
194 : 0 : eOffsetStart=NF_FRACTION_START;
195 : 0 : eOffsetEnd=NF_FRACTION_END;
196 : 0 : break;
197 : :
198 : : case NUMBERFORMAT_LOGICAL:
199 : 0 : eOffsetStart=NF_BOOLEAN;
200 : 0 : eOffsetEnd=NF_BOOLEAN;
201 : 0 : break;
202 : :
203 : : case NUMBERFORMAT_TEXT:
204 : 0 : eOffsetStart=NF_TEXT;
205 : 0 : eOffsetEnd=NF_TEXT;
206 : 0 : break;
207 : :
208 : : case NUMBERFORMAT_ALL:
209 : 0 : eOffsetStart=NF_NUMERIC_START;
210 : 0 : eOffsetEnd = NfIndexTableOffset( NF_INDEX_TABLE_ENTRIES - 1 );
211 : 0 : break;
212 : :
213 : : default:
214 : : OSL_FAIL("what a format?");
215 : 0 : break;
216 : : }
217 : :
218 : : const SvNumberformat* pFmt;
219 : 0 : sal_uInt16 nPos, i = 0;
220 : : sal_uLong nFormat;
221 : : Color* pCol;
222 : 0 : double fVal = GetDefValue( nFormatType );
223 [ # # ]: 0 : String sValue;
224 : :
225 : : sal_uLong nSysNumFmt = pFormatter->GetFormatIndex(
226 [ # # ]: 0 : NF_NUMBER_SYSTEM, eCurLanguage );
227 : : sal_uLong nSysShortDateFmt = pFormatter->GetFormatIndex(
228 [ # # ]: 0 : NF_DATE_SYSTEM_SHORT, eCurLanguage );
229 : : sal_uLong nSysLongDateFmt = pFormatter->GetFormatIndex(
230 [ # # ]: 0 : NF_DATE_SYSTEM_LONG, eCurLanguage );
231 : :
232 [ # # ]: 0 : for( long nIndex = eOffsetStart; nIndex <= eOffsetEnd; ++nIndex )
233 : : {
234 : : nFormat = pFormatter->GetFormatIndex(
235 [ # # ]: 0 : (NfIndexTableOffset)nIndex, eCurLanguage );
236 [ # # ]: 0 : pFmt = pFormatter->GetEntry( nFormat );
237 : :
238 [ # # ][ # # ]: 0 : if( nFormat == pFormatter->GetFormatIndex( NF_NUMBER_STANDARD,
[ # # ][ # # ]
239 [ # # ]: 0 : eCurLanguage )
240 [ # # ]: 0 : || ((SvNumberformat*)pFmt)->GetOutputString( fVal, sValue, &pCol )
241 : : || nFormatType == NUMBERFORMAT_UNDEFINED )
242 [ # # ]: 0 : sValue = pFmt->GetFormatstring();
243 [ # # ]: 0 : else if( nFormatType == NUMBERFORMAT_TEXT )
244 : : {
245 [ # # ]: 0 : String sTxt(rtl::OUString("\"ABC\""));
246 [ # # ][ # # ]: 0 : pFormatter->GetOutputString( sTxt, nFormat, sValue, &pCol);
247 : : }
248 : :
249 [ # # ][ # # ]: 0 : if (nFormat != nSysNumFmt &&
[ # # ]
250 : : nFormat != nSysShortDateFmt &&
251 : : nFormat != nSysLongDateFmt)
252 : : {
253 [ # # ]: 0 : nPos = InsertEntry( sValue );
254 [ # # ]: 0 : SetEntryData( nPos, (void*)nFormat );
255 : :
256 [ # # ]: 0 : if( nFormat == pFormatter->GetStandardFormat(
257 [ # # ]: 0 : nFormatType, eCurLanguage ) )
258 : 0 : nStdEntry = i;
259 : 0 : ++i;
260 : : }
261 : : }
262 : :
263 [ # # ]: 0 : if (!pOwnFormatter)
264 : : {
265 [ # # ][ # # ]: 0 : nPos = InsertEntry(SW_RESSTR( STR_DEFINE_NUMBERFORMAT ));
[ # # ][ # # ]
266 [ # # ]: 0 : SetEntryData( nPos, NULL );
267 : : }
268 : :
269 [ # # ]: 0 : SelectEntryPos( nStdEntry );
270 : :
271 [ # # ]: 0 : nCurrFormatType = nFormatType;
272 : : }
273 : : }
274 : :
275 : 0 : void NumFormatListBox::SetDefFormat(const sal_uLong nDefFmt)
276 : : {
277 [ # # ]: 0 : if (nDefFmt == ULONG_MAX)
278 : : {
279 : 0 : nDefFormat = nDefFmt;
280 : : return;
281 : : }
282 : :
283 : : SvNumberFormatter* pFormatter;
284 [ # # ]: 0 : if (pOwnFormatter)
285 : 0 : pFormatter = pOwnFormatter;
286 : : else
287 : : {
288 [ # # ]: 0 : SwView *pView = GetView();
289 : : OSL_ENSURE(pView, "no view found");
290 [ # # ]: 0 : if(!pView)
291 : : return;
292 : 0 : SwWrtShell &rSh = pView->GetWrtShell();
293 [ # # ]: 0 : pFormatter = rSh.GetNumberFormatter();
294 : : }
295 : :
296 [ # # ]: 0 : short nType = pFormatter->GetType(nDefFmt);
297 : :
298 [ # # ]: 0 : SetFormatType(nType);
299 : :
300 [ # # ]: 0 : sal_uLong nFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nDefFmt, eCurLanguage);
301 : :
302 [ # # ][ # # ]: 0 : for (sal_uInt16 i = 0; i < GetEntryCount(); i++)
303 : : {
304 [ # # ][ # # ]: 0 : if (nFormat == (sal_uLong)GetEntryData(i))
305 : : {
306 [ # # ]: 0 : SelectEntryPos(i);
307 : 0 : nStdEntry = i;
308 [ # # ]: 0 : nDefFormat = GetFormat();
309 : : return;
310 : : }
311 : : }
312 : :
313 : : // Kein Eintrag gefunden:
314 : 0 : double fValue = GetDefValue(nType);
315 [ # # ]: 0 : String sValue;
316 : 0 : Color* pCol = 0;
317 : :
318 [ # # ]: 0 : if (nType == NUMBERFORMAT_TEXT)
319 : : {
320 [ # # ]: 0 : String sTxt(rtl::OUString("\"ABC\""));
321 [ # # ][ # # ]: 0 : pFormatter->GetOutputString(sTxt, nDefFmt, sValue, &pCol);
322 : : }
323 : : else
324 [ # # ]: 0 : pFormatter->GetOutputString(fValue, nDefFmt, sValue, &pCol);
325 : :
326 : 0 : sal_uInt16 nPos = 0;
327 [ # # ][ # # ]: 0 : while ((sal_uLong)GetEntryData(nPos) == ULONG_MAX)
328 : 0 : nPos++;
329 : :
330 [ # # ]: 0 : sal_uLong nSysNumFmt = pFormatter->GetFormatIndex( NF_NUMBER_SYSTEM, eCurLanguage);
331 [ # # ]: 0 : sal_uLong nSysShortDateFmt = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_SHORT, eCurLanguage);
332 [ # # ]: 0 : sal_uLong nSysLongDateFmt = pFormatter->GetFormatIndex( NF_DATE_SYSTEM_LONG, eCurLanguage);
333 : 0 : sal_Bool bSysLang = sal_False;
334 [ # # ][ # # ]: 0 : if( eCurLanguage == GetAppLanguage() )
335 : 0 : bSysLang = sal_True;
336 [ # # ]: 0 : sal_uLong nNumFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysNumFmt, LANGUAGE_SYSTEM );
337 [ # # ]: 0 : sal_uLong nShortDateFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysShortDateFmt, LANGUAGE_SYSTEM );
338 [ # # ]: 0 : sal_uLong nLongDateFormatForLanguage = pFormatter->GetFormatForLanguageIfBuiltIn(nSysLongDateFmt, LANGUAGE_SYSTEM );
339 : :
340 [ # # ][ # # ]: 0 : if (
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
341 : : nDefFmt == nSysNumFmt ||
342 : : nDefFmt == nSysShortDateFmt ||
343 : : nDefFmt == nSysLongDateFmt ||
344 : : (
345 : : bSysLang &&
346 : : (
347 : : nDefFmt == nNumFormatForLanguage ||
348 : : nDefFmt == nShortDateFormatForLanguage ||
349 : : nDefFmt == nLongDateFormatForLanguage
350 : : )
351 : : )
352 : : )
353 : : {
354 [ # # ][ # # ]: 0 : sValue += String(SW_RES(RID_STR_SYSTEM));
[ # # ]
355 : : }
356 : :
357 [ # # ]: 0 : nPos = InsertEntry(sValue, nPos); // Als ersten numerischen Eintrag einfuegen
358 [ # # ]: 0 : SetEntryData(nPos, (void*)nDefFmt);
359 [ # # ]: 0 : SelectEntryPos(nPos);
360 [ # # ][ # # ]: 0 : nDefFormat = GetFormat();
361 : : }
362 : :
363 : 0 : sal_uLong NumFormatListBox::GetFormat() const
364 : : {
365 : 0 : sal_uInt16 nPos = GetSelectEntryPos();
366 : :
367 : 0 : return (sal_uLong)GetEntryData(nPos);
368 : : }
369 : :
370 : 0 : IMPL_LINK( NumFormatListBox, SelectHdl, ListBox *, pBox )
371 : : {
372 [ # # ]: 0 : sal_uInt16 nPos = pBox->GetSelectEntryPos();
373 [ # # ]: 0 : String sDefine(SW_RES( STR_DEFINE_NUMBERFORMAT ));
374 [ # # ]: 0 : SwView *pView = GetView();
375 : :
376 [ # # ][ # # ]: 0 : if( pView && nPos == pBox->GetEntryCount() - 1 &&
[ # # ][ # # ]
[ # # ]
377 [ # # ][ # # ]: 0 : pBox->GetEntry( nPos ) == sDefine )
[ # # ][ # # ]
[ # # ]
378 : : {
379 : 0 : SwWrtShell &rSh = pView->GetWrtShell();
380 [ # # ]: 0 : SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
381 : :
382 [ # # ]: 0 : SfxItemSet aCoreSet( rSh.GetAttrPool(),
383 : : SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
384 : : SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
385 : : SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA,
386 : : SID_ATTR_NUMBERFORMAT_NOLANGUAGE, SID_ATTR_NUMBERFORMAT_NOLANGUAGE,
387 : : SID_ATTR_NUMBERFORMAT_ADD_AUTO, SID_ATTR_NUMBERFORMAT_ADD_AUTO,
388 [ # # ]: 0 : 0 );
389 : :
390 : 0 : double fValue = GetDefValue( nCurrFormatType);
391 : :
392 [ # # ]: 0 : sal_uLong nFormat = pFormatter->GetStandardFormat( nCurrFormatType, eCurLanguage);
393 [ # # ][ # # ]: 0 : aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, nFormat ));
[ # # ]
394 : :
395 : : aCoreSet.Put( SvxNumberInfoItem( pFormatter, fValue,
396 [ # # ][ # # ]: 0 : SID_ATTR_NUMBERFORMAT_INFO ) );
[ # # ]
397 : :
398 [ # # ]: 0 : if( (NUMBERFORMAT_DATE | NUMBERFORMAT_TIME) & nCurrFormatType )
399 [ # # ][ # # ]: 0 : aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, bOneArea));
[ # # ]
400 : :
401 [ # # ][ # # ]: 0 : aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_NOLANGUAGE, !bShowLanguageControl));
[ # # ]
402 [ # # ][ # # ]: 0 : aCoreSet.Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ADD_AUTO, bUseAutomaticLanguage));
[ # # ]
403 : :
404 [ # # ]: 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
405 : : OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
406 : :
407 : : SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( this, aCoreSet,
408 [ # # ][ # # ]: 0 : GetView()->GetViewFrame()->GetFrame().GetFrameInterface(),
409 [ # # ][ # # ]: 0 : RC_DLG_SWNUMFMTDLG );
410 : : OSL_ENSURE(pDlg, "Dialogdiet fail!");
411 : :
412 [ # # ][ # # ]: 0 : if (RET_OK == pDlg->Execute())
413 : : {
414 [ # # ]: 0 : const SfxPoolItem* pItem = pView->GetDocShell()->
415 [ # # ]: 0 : GetItem( SID_ATTR_NUMBERFORMAT_INFO );
416 : :
417 [ # # ][ # # ]: 0 : if( pItem && 0 != ((SvxNumberInfoItem*)pItem)->GetDelCount() )
[ # # ]
418 : : {
419 : 0 : const sal_uInt32* pDelArr = ((SvxNumberInfoItem*)pItem)->GetDelArray();
420 : :
421 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < ((SvxNumberInfoItem*)pItem)->GetDelCount(); i++ )
422 [ # # ]: 0 : pFormatter->DeleteEntry( pDelArr[i] );
423 : : }
424 : :
425 [ # # ]: 0 : const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
426 [ # # ]: 0 : if( SFX_ITEM_SET == pOutSet->GetItemState(
427 [ # # ]: 0 : SID_ATTR_NUMBERFORMAT_VALUE, sal_False, &pItem ))
428 : : {
429 : 0 : sal_uInt32 nNumberFormat = ((SfxUInt32Item*)pItem)->GetValue();
430 : : // oj #105473# change order of calls
431 [ # # ]: 0 : const SvNumberformat* pFmt = pFormatter->GetEntry(nNumberFormat);
432 [ # # ]: 0 : if( pFmt )
433 : 0 : eCurLanguage = pFmt->GetLanguage();
434 : : // SetDefFormat uses eCurLanguage to look for if this format already in the list
435 [ # # ]: 0 : SetDefFormat(nNumberFormat);
436 : : }
437 [ # # ][ # # ]: 0 : if( bShowLanguageControl && SFX_ITEM_SET == pOutSet->GetItemState(
[ # # ]
438 [ # # ]: 0 : SID_ATTR_NUMBERFORMAT_ADD_AUTO, sal_False, &pItem ))
439 : : {
440 : 0 : bUseAutomaticLanguage = ((const SfxBoolItem*)pItem)->GetValue();
441 : : }
442 : : }
443 : : else
444 [ # # ]: 0 : SetDefFormat(nFormat);
445 : :
446 [ # # ][ # # ]: 0 : delete pDlg;
[ # # ]
447 : : }
448 [ # # ]: 0 : return 0;
449 : : }
450 : :
451 : 0 : double NumFormatListBox::GetDefValue(const short nFormatType) const
452 : : {
453 : 0 : double fDefValue = 0.0;
454 : :
455 [ # # # # : 0 : switch (nFormatType)
# # # ]
456 : : {
457 : : case NUMBERFORMAT_DATE:
458 : : case NUMBERFORMAT_DATE|NUMBERFORMAT_TIME:
459 : 0 : fDefValue = SVX_NUMVAL_DATE;
460 : 0 : break;
461 : :
462 : : case NUMBERFORMAT_TIME:
463 : 0 : fDefValue = SVX_NUMVAL_TIME;
464 : 0 : break;
465 : :
466 : : case NUMBERFORMAT_TEXT:
467 : : case NUMBERFORMAT_UNDEFINED:
468 : 0 : fDefValue = 0;
469 : 0 : break;
470 : :
471 : : case NUMBERFORMAT_CURRENCY:
472 : 0 : fDefValue = SVX_NUMVAL_CURRENCY;
473 : 0 : break;
474 : :
475 : : case NUMBERFORMAT_PERCENT:
476 : 0 : fDefValue = SVX_NUMVAL_PERCENT;
477 : 0 : break;
478 : :
479 : : case NUMBERFORMAT_LOGICAL:
480 : 0 : fDefValue = SVX_NUMVAL_BOOLEAN;
481 : 0 : break;
482 : :
483 : : default:
484 : 0 : fDefValue = SVX_NUMVAL_STANDARD;
485 : 0 : break;
486 : : }
487 : :
488 : 0 : return fDefValue;
489 : : }
490 : :
491 : 0 : void NumFormatListBox::Clear()
492 : : {
493 : 0 : ListBox::Clear();
494 : 0 : nCurrFormatType = -1;
495 : 0 : }
496 : :
497 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|