Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / svl / zformat.hxx
blob916a0d3004c8f1bdde61d76a3d245d254bc497d6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVL_ZFORMAT_HXX
20 #define INCLUDED_SVL_ZFORMAT_HXX
22 #include <svl/svldllapi.h>
23 #include <i18nlangtag/mslangid.hxx>
24 #include <svl/zforlist.hxx>
25 #include <svl/nfkeytab.hxx>
27 namespace utl {
28 class DigitGroupingIterator;
31 class Color;
33 class ImpSvNumberformatScan; // format code string scanner
34 class ImpSvNumberInputScan; // input string scanner
35 class SvNumberFormatter;
37 enum SvNumberformatLimitOps
39 NUMBERFORMAT_OP_NO = 0, // Undefined, no OP
40 NUMBERFORMAT_OP_EQ = 1, // Operator =
41 NUMBERFORMAT_OP_NE = 2, // Operator <>
42 NUMBERFORMAT_OP_LT = 3, // Operator <
43 NUMBERFORMAT_OP_LE = 4, // Operator <=
44 NUMBERFORMAT_OP_GT = 5, // Operator >
45 NUMBERFORMAT_OP_GE = 6 // Operator >=
48 // SYSTEM-german to SYSTEM-xxx and vice versa conversion hack onLoad
49 enum NfHackConversion
51 NF_CONVERT_NONE,
52 NF_CONVERT_GERMAN_ENGLISH,
53 NF_CONVERT_ENGLISH_GERMAN
56 struct ImpSvNumberformatInfo // Struct for FormatInfo
58 OUString* sStrArray; // Array of symbols
59 short* nTypeArray; // Array of infos
60 sal_uInt16 nThousand; // Count of group separator sequences
61 sal_uInt16 nCntPre; // Count of digits before decimal point
62 sal_uInt16 nCntPost; // Count of digits after decimal point
63 sal_uInt16 nCntExp; // Count of exponent digits, or AM/PM
64 short eScannedType; // Type determined by scan
65 bool bThousand; // Has group (AKA thousand) separator
67 void Copy( const ImpSvNumberformatInfo& rNumFor, sal_uInt16 nAnz );
70 // NativeNumber, represent numbers using CJK or other digits if nNum>0,
71 // eLang specifies the Locale to use.
72 class SvNumberNatNum
74 LanguageType eLang;
75 sal_uInt8 nNum;
76 bool bDBNum :1; // DBNum, to be converted to NatNum
77 bool bDate :1; // Used in date? (needed for DBNum/NatNum mapping)
78 bool bSet :1; // If set, since NatNum0 is possible
80 public:
82 static sal_uInt8 MapDBNumToNatNum( sal_uInt8 nDBNum, LanguageType eLang, bool bDate );
83 #ifdef THE_FUTURE
84 static sal_uInt8 MapNatNumToDBNum( sal_uInt8 nNatNum, LanguageType eLang, bool bDate );
85 #endif
87 SvNumberNatNum() : eLang( LANGUAGE_DONTKNOW ), nNum(0),
88 bDBNum(false), bDate(false), bSet(false) {}
89 bool IsComplete() const { return bSet && eLang != LANGUAGE_DONTKNOW; }
90 sal_uInt8 GetNatNum() const { return bDBNum ? MapDBNumToNatNum( nNum, eLang, bDate ) : nNum; }
91 #ifdef THE_FUTURE
92 sal_uInt8 GetDBNum() const { return bDBNum ? nNum : MapNatNumToDBNum( nNum, eLang, bDate ); }
93 #endif
94 LanguageType GetLang() const { return eLang; }
95 void SetLang( LanguageType e ) { eLang = e; }
96 void SetNum( sal_uInt8 nNumber, bool bDBNumber )
98 nNum = nNumber;
99 bDBNum = bDBNumber;
100 bSet = true;
102 bool IsSet() const { return bSet; }
103 void SetDate( bool bDateP ) { bDate = bDateP; }
106 class CharClass;
108 class ImpSvNumFor // One of four subformats of the format code string
110 public:
111 ImpSvNumFor(); // Ctor without filling the Info
112 ~ImpSvNumFor();
114 void Enlarge(sal_uInt16 nAnz); // Init of arrays to the right size
116 // if pSc is set, it is used to get the Color pointer
117 void Copy( const ImpSvNumFor& rNumFor, ImpSvNumberformatScan* pSc );
119 // Access to Info; call Enlarge before!
120 ImpSvNumberformatInfo& Info() { return aI;}
121 const ImpSvNumberformatInfo& Info() const { return aI; }
123 // Get count of substrings (symbols)
124 sal_uInt16 GetCount() const { return nAnzStrings;}
126 Color* GetColor() const { return pColor; }
127 void SetColor( Color* pCol, OUString& rName )
128 { pColor = pCol; sColorName = rName; }
129 const OUString& GetColorName() const { return sColorName; }
131 // new SYMBOLTYPE_CURRENCY in subformat?
132 bool HasNewCurrency() const;
133 bool GetNewCurrencySymbol( OUString& rSymbol, OUString& rExtension ) const;
135 // [NatNum1], [NatNum2], ...
136 void SetNatNumNum( sal_uInt8 nNum, bool bDBNum ) { aNatNum.SetNum( nNum, bDBNum ); }
137 void SetNatNumLang( LanguageType eLang ) { aNatNum.SetLang( eLang ); }
138 void SetNatNumDate( bool bDate ) { aNatNum.SetDate( bDate ); }
139 const SvNumberNatNum& GetNatNum() const { return aNatNum; }
141 private:
142 ImpSvNumberformatInfo aI; // helper struct for remaining information
143 OUString sColorName; // color name
144 Color* pColor; // pointer to color of subformat
145 sal_uInt16 nAnzStrings; // count of symbols
146 SvNumberNatNum aNatNum; // DoubleByteNumber
150 class SVL_DLLPUBLIC SvNumberformat
152 struct LocaleType
154 sal_uInt8 mnNumeralShape;
155 sal_uInt8 mnCalendarType;
156 LanguageType meLanguage;
158 OUString generateCode() const;
160 LocaleType();
161 LocaleType(sal_uInt32 nRawCode);
164 public:
165 // Normal ctor
166 SvNumberformat( OUString& rString,
167 ImpSvNumberformatScan* pSc,
168 ImpSvNumberInputScan* pISc,
169 sal_Int32& nCheckPos,
170 LanguageType& eLan );
172 // Copy ctor
173 SvNumberformat( SvNumberformat& rFormat );
175 // Copy ctor with exchange of format code string scanner (used in merge)
176 SvNumberformat( SvNumberformat& rFormat, ImpSvNumberformatScan& rSc );
178 ~SvNumberformat();
180 /// Get type of format, may include css::util::NumberFormat::DEFINED bit
181 short GetType() const { return eType; }
183 void SetType(const short eSetType) { eType = eSetType; }
184 // Standard means the I18N defined standard format of this type
185 void SetStandard() { bStandard = true; }
186 bool IsStandard() const { return bStandard; }
188 // If this format is an additional built-in format defined by i18n.
189 void SetAdditionalBuiltin() { bAdditionalBuiltin = true; }
190 bool IsAdditionalBuiltin() const { return bAdditionalBuiltin; }
192 LanguageType GetLanguage() const { return maLocale.meLanguage;}
194 const OUString& GetFormatstring() const { return sFormatstring; }
196 // Build a format string of application defined keywords
197 OUString GetMappedFormatstring( const NfKeywordTable& rKeywords,
198 const LocaleDataWrapper& rLoc ) const;
200 void SetStarFormatSupport( bool b ) { bStarFlag = b; }
203 * Get output string from a numeric value that fits the number of
204 * characters specified.
206 bool GetOutputString( double fNumber, sal_uInt16 nCharCount, OUString& rOutString ) const;
208 bool GetOutputString( double fNumber, OUString& OutString, Color** ppColor );
209 void GetOutputString( const OUString& sString, OUString& OutString, Color** ppColor );
211 // True if type text
212 bool IsTextFormat() const { return (eType & css::util::NumberFormat::TEXT) != 0; }
213 // True if 4th subformat present
214 bool HasTextFormat() const
216 return (NumFor[3].GetCount() > 0) ||
217 (NumFor[3].Info().eScannedType == css::util::NumberFormat::TEXT);
220 void GetFormatSpecialInfo(bool& bThousand,
221 bool& IsRed,
222 sal_uInt16& nPrecision,
223 sal_uInt16& nAnzLeading) const;
225 /// Count of decimal precision
226 sal_uInt16 GetFormatPrecision() const { return NumFor[0].Info().nCntPost; }
228 /// Count of integer digits
229 sal_uInt16 GetFormatIntegerDigits() const { return NumFor[0].Info().nCntPre; }
231 //! Read/write access on a special sal_uInt16 component, may only be used on the
232 //! standard format 0, 5000, ... and only by the number formatter!
233 sal_uInt16 GetLastInsertKey() const
234 { return NumFor[0].Info().nThousand; }
235 void SetLastInsertKey(sal_uInt16 nKey)
236 { NumFor[0].Info().nThousand = nKey; }
238 //! Only onLoad: convert from stored to current system language/country
239 void ConvertLanguage( SvNumberFormatter& rConverter,
240 LanguageType eConvertFrom, LanguageType eConvertTo );
242 // Substring of a subformat code nNumFor (0..3)
243 // nPos == 0xFFFF => last substring
244 // bString==true: first/last SYMBOLTYPE_STRING or SYMBOLTYPE_CURRENCY
245 const OUString* GetNumForString( sal_uInt16 nNumFor, sal_uInt16 nPos,
246 bool bString = false ) const;
248 // Subtype of a subformat code nNumFor (0..3)
249 // nPos == 0xFFFF => last substring
250 short GetNumForType( sal_uInt16 nNumFor, sal_uInt16 nPos ) const;
252 OUString GetDenominatorString( sal_uInt16 nNumFor ) const;
253 /** If the count of string elements (substrings, ignoring [modifiers] and
254 so on) in a subformat code nNumFor (0..3) is equal to the given number.
255 Used by ImpSvNumberInputScan::IsNumberFormatMain() to detect a matched
256 format. */
257 bool IsNumForStringElementCountEqual( sal_uInt16 nNumFor, sal_uInt16 nAllCount,
258 sal_uInt16 nNumCount ) const
260 if ( nNumFor < 4 )
262 // First try a simple approach. Note that this is called only
263 // if all MidStrings did match so far, to verify that all
264 // strings of the format were matched and not just the starting
265 // sequence, so we don't have to check if GetnAnz() includes
266 // [modifiers] or anything else if both counts are equal.
267 sal_uInt16 nCnt = NumFor[nNumFor].GetCount();
268 if ( nAllCount == nCnt )
269 return true;
270 if ( nAllCount < nCnt ) // check ignoring [modifiers] and so on
271 return ImpGetNumForStringElementCount( nNumFor ) ==
272 (nAllCount - nNumCount);
274 return false;
276 /** Get the count of numbers among string elements **/
277 sal_uInt16 GetNumForNumberElementCount( sal_uInt16 nNumFor ) const;
279 /** Get the scanned type of the specified subformat. */
280 short GetNumForInfoScannedType( sal_uInt16 nNumFor ) const
282 return (nNumFor < 4) ? NumFor[nNumFor].Info().eScannedType : css::util::NumberFormat::UNDEFINED;
285 // Whether the second subformat code is really for negative numbers
286 // or another limit set.
287 bool IsSecondSubformatRealNegative() const
289 return fLimit1 == 0.0 && fLimit2 == 0.0 &&
290 ( (eOp1 == NUMBERFORMAT_OP_GE && eOp2 == NUMBERFORMAT_OP_NO) ||
291 (eOp1 == NUMBERFORMAT_OP_GT && eOp2 == NUMBERFORMAT_OP_LT) ||
292 (eOp1 == NUMBERFORMAT_OP_NO && eOp2 == NUMBERFORMAT_OP_NO) );
295 // Whether the first subformat code is really for negative numbers
296 // or another limit set.
297 bool IsFirstSubformatRealNegative() const
299 return fLimit1 == 0.0 && fLimit2 == 0.0 &&
300 ((eOp1 == NUMBERFORMAT_OP_LT &&
301 (eOp2 == NUMBERFORMAT_OP_GT || eOp2 == NUMBERFORMAT_OP_EQ ||
302 eOp2 == NUMBERFORMAT_OP_GE || eOp2 == NUMBERFORMAT_OP_NO)) ||
303 (eOp1 == NUMBERFORMAT_OP_LE &&
304 (eOp2 == NUMBERFORMAT_OP_NO || eOp2 == NUMBERFORMAT_OP_GT)));
307 // Whether the negative format is without a sign or not
308 bool IsNegativeWithoutSign() const;
310 bool IsNegativeInBracket() const;
312 bool HasPositiveBracketPlaceholder() const;
314 // Whether a new SYMBOLTYPE_CURRENCY is contained in the format
315 bool HasNewCurrency() const;
317 // strip [$-yyy] from all [$xxx-yyy] leaving only xxx's,
318 // if bQuoteSymbol==true the xxx will become "xxx"
319 static OUString StripNewCurrencyDelimiters( const OUString& rStr,
320 bool bQuoteSymbol );
322 // If a new SYMBOLTYPE_CURRENCY is contained if the format is of type
323 // css::util::NumberFormat::CURRENCY, and if so the symbol xxx and the extension nnn
324 // of [$xxx-nnn] are returned
325 bool GetNewCurrencySymbol( OUString& rSymbol, OUString& rExtension ) const;
327 static bool HasStringNegativeSign( const OUString& rStr );
330 Whether a character at position nPos is somewhere between two matching
331 cQuote or not.
332 If nPos points to a cQuote, a true is returned on an opening cQuote,
333 a false is returned on a closing cQuote.
334 A cQuote between quotes may be escaped by a cEscIn, a cQuote outside of
335 quotes may be escaped by a cEscOut.
336 The default '\0' results in no escapement possible.
337 Defaults are set right according to the "unlogic" of the Numberformatter
339 static bool IsInQuote( const OUString& rString, sal_Int32 nPos,
340 sal_Unicode cQuote = '"',
341 sal_Unicode cEscIn = '\0', sal_Unicode cEscOut = '\\' );
344 Return the position of a matching closing cQuote if the character at
345 position nPos is between two matching cQuote, otherwise return -1.
346 If nPos points to an opening cQuote the position of the matching
347 closing cQuote is returned.
348 If nPos points to a closing cQuote nPos is returned.
349 If nPos points into a part which starts with an opening cQuote but has
350 no closing cQuote, rString.Len() is returned.
351 Uses <method>IsInQuote</method> internally, so you don't have to call
352 that prior to a call of this method.
354 static sal_Int32 GetQuoteEnd( const OUString& rString, sal_Int32 nPos,
355 sal_Unicode cQuote = '"',
356 sal_Unicode cEscIn = '\0' );
358 void SetComment( const OUString& rStr )
359 { sComment = rStr; }
360 const OUString& GetComment() const { return sComment; }
362 /** Insert the number of blanks into the string that is needed to simulate
363 the width of character c for underscore formats */
364 static sal_Int32 InsertBlanks( OUString& r, sal_Int32 nPos, sal_Unicode c )
366 sal_Int32 result;
367 OUStringBuffer sBuff(r);
369 result = InsertBlanks(sBuff, nPos, c);
370 r = sBuff.makeStringAndClear();
372 return result;
375 /** Insert the number of blanks into the string that is needed to simulate
376 the width of character c for underscore formats */
377 static sal_Int32 InsertBlanks( OUStringBuffer& r, sal_Int32 nPos, sal_Unicode c );
379 /// One of YMD,DMY,MDY if date format
380 DateFormat GetDateOrder() const;
382 /** A coded value of the exact YMD combination used, if date format.
383 For example: YYYY-MM-DD => ('Y' << 16) | ('M' << 8) | 'D'
384 or: MM/YY => ('M' << 8) | 'Y' */
385 sal_uInt32 GetExactDateOrder() const;
387 // used in XML export
388 void GetConditions( SvNumberformatLimitOps& rOper1, double& rVal1,
389 SvNumberformatLimitOps& rOper2, double& rVal2 ) const;
390 Color* GetColor( sal_uInt16 nNumFor ) const;
391 void GetNumForInfo( sal_uInt16 nNumFor, short& rScannedType,
392 bool& bThousand, sal_uInt16& nPrecision, sal_uInt16& nAnzLeading ) const;
394 // rAttr.Number not empty if NatNum attributes are to be stored
395 void GetNatNumXml(
396 css::i18n::NativeNumberXmlAttributes& rAttr,
397 sal_uInt16 nNumFor ) const;
399 /** Switches to the first non-"gregorian" calendar, but only if the current
400 calendar is "gregorian"; original calendar name and date/time returned,
401 but only if calendar switched and rOrgCalendar was empty. */
402 void SwitchToOtherCalendar( OUString& rOrgCalendar, double& fOrgDateTime ) const;
404 /** Switches to the "gregorian" calendar, but only if the current calendar
405 is non-"gregorian" and rOrgCalendar is not empty. Thus a preceding
406 ImpSwitchToOtherCalendar() call should have been placed prior to
407 calling this method. */
408 void SwitchToGregorianCalendar( const OUString& rOrgCalendar, double fOrgDateTime ) const;
410 #ifdef THE_FUTURE
411 /** Switches to the first specified calendar, if any, in subformat nNumFor
412 (0..3). Original calendar name and date/time returned, but only if
413 calendar switched and rOrgCalendar was empty.
415 @return
416 <TRUE/> if a calendar was specified and switched to,
417 <FALSE/> else.
419 bool SwitchToSpecifiedCalendar( OUString& rOrgCalendar, double& fOrgDateTime,
420 sal_uInt16 nNumFor ) const
422 if ( nNumFor < 4 )
423 return ImpSwitchToSpecifiedCalendar( rOrgCalendar,
424 fOrgDateTime, NumFor[nNumFor] );
425 return false;
427 #endif
429 /// Whether it's a (YY)YY-M(M)-D(D) format.
430 bool IsIso8601( sal_uInt16 nNumFor )
432 if ( nNumFor < 4 )
433 return ImpIsIso8601( NumFor[nNumFor]);
434 return false;
437 private:
438 ImpSvNumFor NumFor[4]; // Array for the 4 subformats
439 OUString sFormatstring; // The format code string
440 OUString sComment; // Comment, since number formatter version 6
441 double fLimit1; // Value for first condition
442 double fLimit2; // Value for second condition
443 ImpSvNumberformatScan& rScan; // Format code scanner
444 LocaleType maLocale; // Language/country of the format, numeral shape and calendar type from Excel.
445 SvNumberformatLimitOps eOp1; // Operator for first condition
446 SvNumberformatLimitOps eOp2; // Operator for second condition
447 short eType; // Type of format
448 bool bAdditionalBuiltin; // If this is an additional built-in format defined by i18n
449 bool bStarFlag; // Take *n format as ESC n
450 bool bStandard; // If this is a default standard format
451 bool bIsUsed; // Flag as used for storing
453 SVL_DLLPRIVATE sal_uInt16 ImpGetNumForStringElementCount( sal_uInt16 nNumFor ) const;
455 SVL_DLLPRIVATE bool ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const;
457 #ifdef THE_FUTURE
458 SVL_DLLPRIVATE bool ImpSwitchToSpecifiedCalendar( OUString& rOrgCalendar,
459 double& fOrgDateTime,
460 const ImpSvNumFor& rNumFor ) const;
461 #endif
463 /** Whether to use possessive genitive case month name, or partitive case
464 month name, instead of nominative name (noun).
466 @param io_nState
467 0: execute check <br>
468 set to 1 if nominative case is returned, <br>
469 set to 2 if genitive case is returned, <br>
470 set to 3 if partitive case is returned <br>
471 1: don't execute check, return nominative case <br>
472 2: don't execute check, return genitive case <br>
473 3: don't execute check, return partitive case <br>
475 @param eCodeType
476 a NfKeywordIndex, must designate a month type code
478 @returns one of css::i18n::CalendarDisplayCode values
479 according to eCodeType and the check executed (or passed).
481 SVL_DLLPRIVATE sal_Int32 ImpUseMonthCase( int & io_nState, const ImpSvNumFor& rNumFor, NfKeywordIndex eCodeType ) const;
483 /// Whether it's a (YY)YY-M(M)-D(D) format.
484 SVL_DLLPRIVATE bool ImpIsIso8601( const ImpSvNumFor& rNumFor );
486 const CharClass& rChrCls() const;
487 const LocaleDataWrapper& rLoc() const;
488 CalendarWrapper& GetCal() const;
489 const SvNumberFormatter& GetFormatter() const;
491 // divide in substrings and color conditions
492 SVL_DLLPRIVATE short ImpNextSymbol( OUStringBuffer& rString,
493 sal_Int32& nPos,
494 OUString& sSymbol );
496 // read string until ']' and strip blanks (after condition)
497 SVL_DLLPRIVATE static sal_Int32 ImpGetNumber( OUStringBuffer& rString,
498 sal_Int32& nPos,
499 OUString& sSymbol );
502 * Parse the content of '[$-xxx] or '[$-xxxxxxxx]' and extract the locale
503 * type from it. Given the string, start parsing at position specified by
504 * nPos, and store the end position with nPos when the parsing is
505 * complete. The nPos should point to the '$' before the parsing, and to
506 * the closing bracket after the parsing. When the content is [$-xxx],
507 * the xxx part represents the language type (aka LCID) in hex numerals.
508 * When the content is [$-xxxxxxxx] the last 4 digits represent the LCID
509 * (again in hex), the next 2 digits represent the calendar type, and the
510 * 2 highest digits (if exists) is the numeral shape.
512 * @reference
513 * http://office.microsoft.com/en-us/excel-help/creating-international-number-formats-HA001034635.aspx
515 * @param rString input string
516 * @param nPos position (see above).
518 * @return struct containing numeral shape, calendar type, and LCID that
519 * specifies language type. See i18nlangtag/lang.h for a complete
520 * list of language types. These numbers also correspond with the
521 * numbers used by Microsoft Office.
523 SVL_DLLPRIVATE static LocaleType ImpGetLocaleType( const OUString& rString, sal_Int32& nPos );
525 /** Obtain calendar and numerals from a LocaleType that was parsed from a
526 LCID with ImpGetLocaleType().
528 Inserts a NatNum modifier to rString at nPos if needed as determined
529 from the numeral code.
531 @ATTENTION: may modify <member>maLocale</member> to make it follow
532 aTmpLocale, in which case also nLang is adapted.
534 @returns a string with the calendar if one was determined from the
535 calendar code, else an empty string. The calendar string needs to be
536 inserted at a proper position to rString after all bracketed prefixes.
538 SVL_DLLPRIVATE OUString ImpObtainCalendarAndNumerals( OUStringBuffer & rString,
539 sal_Int32 & nPos,
540 LanguageType & nLang,
541 const LocaleType & aTmpLocale );
543 // standard number output
544 SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUString& OutString );
545 SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUStringBuffer& OutString );
546 SVL_DLLPRIVATE void ImpGetOutputStdToPrecision( double& rNumber, OUString& rOutString, sal_uInt16 nPrecision ) const;
547 // numbers in input line
548 SVL_DLLPRIVATE void ImpGetOutputInputLine( double fNumber, OUString& OutString );
550 // check subcondition
551 // OP undefined => -1
552 // else 0 or 1
553 SVL_DLLPRIVATE short ImpCheckCondition(double& fNumber,
554 double& fLimit,
555 SvNumberformatLimitOps eOp);
557 SVL_DLLPRIVATE sal_uLong ImpGGT(sal_uLong x, sal_uLong y);
558 SVL_DLLPRIVATE sal_uLong ImpGGTRound(sal_uLong x, sal_uLong y);
560 // Helper function for number strings
561 // append string symbols, insert leading 0 or ' ', or ...
562 SVL_DLLPRIVATE bool ImpNumberFill( OUStringBuffer& sStr,
563 double& rNumber,
564 sal_Int32& k,
565 sal_uInt16& j,
566 sal_uInt16 nIx,
567 short eSymbolType );
569 // Helper function to fill in the integer part and the group (AKA thousand) separators
570 SVL_DLLPRIVATE bool ImpNumberFillWithThousands( OUStringBuffer& sStr,
571 double& rNumber,
572 sal_Int32 k,
573 sal_uInt16 j,
574 sal_uInt16 nIx,
575 sal_Int32 nDigCnt,
576 bool bAddDecSep = true );
578 // Helper function to fill in the group (AKA thousand) separators
579 // or to skip additional digits
580 SVL_DLLPRIVATE void ImpDigitFill( OUStringBuffer& sStr,
581 sal_Int32 nStart,
582 sal_Int32& k,
583 sal_uInt16 nIx,
584 sal_Int32 & nDigitCount,
585 utl::DigitGroupingIterator & );
587 SVL_DLLPRIVATE bool ImpDecimalFill( OUStringBuffer& sStr,
588 double& rNumber,
589 sal_uInt16 j,
590 sal_uInt16 nIx,
591 bool bInteger );
593 SVL_DLLPRIVATE bool ImpGetFractionOutput(double fNumber,
594 sal_uInt16 nIx,
595 OUStringBuffer& OutString);
596 SVL_DLLPRIVATE bool ImpGetScientificOutput(double fNumber,
597 sal_uInt16 nIx,
598 OUStringBuffer& OutString);
600 SVL_DLLPRIVATE bool ImpGetDateOutput( double fNumber,
601 sal_uInt16 nIx,
602 OUStringBuffer& OutString );
603 SVL_DLLPRIVATE bool ImpGetTimeOutput( double fNumber,
604 sal_uInt16 nIx,
605 OUStringBuffer& OutString );
606 SVL_DLLPRIVATE bool ImpGetDateTimeOutput( double fNumber,
607 sal_uInt16 nIx,
608 OUStringBuffer& OutString );
610 // Switches to the "gregorian" calendar if the current calendar is
611 // non-"gregorian" and the era is a "Dummy" era of a calendar which doesn't
612 // know a "before" era (like zh_TW ROC or ja_JP Gengou). If switched and
613 // rOrgCalendar was "gregorian" the string is emptied. If rOrgCalendar was
614 // empty the previous calendar name and date/time are returned.
615 SVL_DLLPRIVATE bool ImpFallBackToGregorianCalendar( OUString& rOrgCalendar, double& fOrgDateTime );
617 // Append a "G" short era string of the given calendar. In the case of a
618 // Gengou calendar this is a one character abbreviation, for other
619 // calendars the XExtendedCalendar::getDisplayString() method is called.
620 SVL_DLLPRIVATE static void ImpAppendEraG( OUStringBuffer& OutStringBuffer, const CalendarWrapper& rCal,
621 sal_Int16 nNatNum );
623 SVL_DLLPRIVATE bool ImpGetNumberOutput( double fNumber,
624 sal_uInt16 nIx,
625 OUStringBuffer& OutString );
627 SVL_DLLPRIVATE void ImpCopyNumberformat( const SvNumberformat& rFormat );
629 // normal digits or other digits, depending on ImpSvNumFor.aNatNum,
630 // [NatNum1], [NatNum2], ...
631 SVL_DLLPRIVATE OUString ImpGetNatNumString( const SvNumberNatNum& rNum, sal_Int32 nVal,
632 sal_uInt16 nMinDigits = 0 ) const;
634 OUString ImpIntToString( sal_uInt16 nIx, sal_Int32 nVal, sal_uInt16 nMinDigits = 0 ) const
636 const SvNumberNatNum& rNum = NumFor[nIx].GetNatNum();
637 if ( nMinDigits || rNum.IsComplete() )
639 return ImpGetNatNumString( rNum, nVal, nMinDigits );
641 return OUString::number(nVal);
644 // transliterate according to NativeNumber
645 SVL_DLLPRIVATE OUString impTransliterateImpl(const OUString& rStr, const SvNumberNatNum& rNum) const;
646 SVL_DLLPRIVATE void impTransliterateImpl(OUStringBuffer& rStr, const SvNumberNatNum& rNum) const;
648 OUString impTransliterate(const OUString& rStr, const SvNumberNatNum& rNum) const
650 return rNum.IsComplete() ? impTransliterateImpl(rStr, rNum) : rStr;
653 SVL_DLLPRIVATE void impTransliterate(OUStringBuffer& rStr, const SvNumberNatNum& rNum) const
655 if(rNum.IsComplete())
657 impTransliterateImpl(rStr, rNum);
662 #endif // INCLUDED_SVL_ZFORMAT_HXX
664 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */