1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
28 class DigitGroupingIterator
;
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 >=
49 struct ImpSvNumberformatInfo
// Struct for FormatInfo
51 OUString
* sStrArray
; // Array of symbols
52 short* nTypeArray
; // Array of infos
53 sal_uInt16 nThousand
; // Count of group separator sequences
54 sal_uInt16 nCntPre
; // Count of digits before decimal point
55 sal_uInt16 nCntPost
; // Count of digits after decimal point
56 sal_uInt16 nCntExp
; // Count of exponent digits, or AM/PM
57 short eScannedType
; // Type determined by scan
58 bool bThousand
; // Has group (AKA thousand) separator
60 void Copy( const ImpSvNumberformatInfo
& rNumFor
, sal_uInt16 nAnz
);
63 // NativeNumber, represent numbers using CJK or other digits if nNum>0,
64 // eLang specifies the Locale to use.
69 bool bDBNum
:1; // DBNum, to be converted to NatNum
70 bool bDate
:1; // Used in date? (needed for DBNum/NatNum mapping)
71 bool bSet
:1; // If set, since NatNum0 is possible
75 static sal_uInt8
MapDBNumToNatNum( sal_uInt8 nDBNum
, LanguageType eLang
, bool bDate
);
76 static sal_uInt8
MapNatNumToDBNum( sal_uInt8 nNatNum
, LanguageType eLang
, bool bDate
);
78 SvNumberNatNum() : eLang( LANGUAGE_DONTKNOW
), nNum(0),
79 bDBNum(false), bDate(false), bSet(false) {}
80 bool IsComplete() const { return bSet
&& eLang
!= LANGUAGE_DONTKNOW
; }
81 sal_uInt8
GetNatNum() const { return bDBNum
? MapDBNumToNatNum( nNum
, eLang
, bDate
) : nNum
; }
82 sal_uInt8
GetDBNum() const { return bDBNum
? nNum
: MapNatNumToDBNum( nNum
, eLang
, bDate
); }
83 LanguageType
GetLang() const { return eLang
; }
84 void SetLang( LanguageType e
) { eLang
= e
; }
85 void SetNum( sal_uInt8 nNumber
, bool bDBNumber
)
91 bool IsSet() const { return bSet
; }
92 void SetDate( bool bDateP
) { bDate
= bDateP
; }
97 class ImpSvNumFor
// One of four subformats of the format code string
100 ImpSvNumFor(); // Ctor without filling the Info
103 void Enlarge(sal_uInt16 nAnz
); // Init of arrays to the right size
105 // if pSc is set, it is used to get the Color pointer
106 void Copy( const ImpSvNumFor
& rNumFor
, ImpSvNumberformatScan
* pSc
);
108 // Access to Info; call Enlarge before!
109 ImpSvNumberformatInfo
& Info() { return aI
;}
110 const ImpSvNumberformatInfo
& Info() const { return aI
; }
112 // Get count of substrings (symbols)
113 sal_uInt16
GetCount() const { return nAnzStrings
;}
115 Color
* GetColor() const { return pColor
; }
116 void SetColor( Color
* pCol
, OUString
& rName
)
117 { pColor
= pCol
; sColorName
= rName
; }
118 const OUString
& GetColorName() const { return sColorName
; }
120 // new SYMBOLTYPE_CURRENCY in subformat?
121 bool HasNewCurrency() const;
122 bool GetNewCurrencySymbol( OUString
& rSymbol
, OUString
& rExtension
) const;
124 // [NatNum1], [NatNum2], ...
125 void SetNatNumNum( sal_uInt8 nNum
, bool bDBNum
) { aNatNum
.SetNum( nNum
, bDBNum
); }
126 void SetNatNumLang( LanguageType eLang
) { aNatNum
.SetLang( eLang
); }
127 void SetNatNumDate( bool bDate
) { aNatNum
.SetDate( bDate
); }
128 const SvNumberNatNum
& GetNatNum() const { return aNatNum
; }
131 ImpSvNumberformatInfo aI
; // helper struct for remaining information
132 OUString sColorName
; // color name
133 Color
* pColor
; // pointer to color of subformat
134 sal_uInt16 nAnzStrings
; // count of symbols
135 SvNumberNatNum aNatNum
; // DoubleByteNumber
139 class SVL_DLLPUBLIC SvNumberformat
143 sal_uInt8 mnNumeralShape
;
144 sal_uInt8 mnCalendarType
;
145 LanguageType meLanguage
;
147 OUString
generateCode() const;
150 LocaleType(sal_uInt32 nRawCode
);
155 SvNumberformat( OUString
& rString
,
156 ImpSvNumberformatScan
* pSc
,
157 ImpSvNumberInputScan
* pISc
,
158 sal_Int32
& nCheckPos
,
159 LanguageType
& eLan
);
162 SvNumberformat( SvNumberformat
& rFormat
);
164 // Copy ctor with exchange of format code string scanner (used in merge)
165 SvNumberformat( SvNumberformat
& rFormat
, ImpSvNumberformatScan
& rSc
);
169 /// Get type of format, may include css::util::NumberFormat::DEFINED bit
170 short GetType() const { return eType
; }
172 /// Get type of format, does not include css::util::NumberFormat::DEFINED
173 short GetMaskedType() const { return eType
& ~css::util::NumberFormat::DEFINED
; }
175 void SetType(const short eSetType
) { eType
= eSetType
; }
176 // Standard means the I18N defined standard format of this type
177 void SetStandard() { bStandard
= true; }
178 bool IsStandard() const { return bStandard
; }
180 // If this format is an additional built-in format defined by i18n.
181 void SetAdditionalBuiltin() { bAdditionalBuiltin
= true; }
182 bool IsAdditionalBuiltin() const { return bAdditionalBuiltin
; }
184 LanguageType
GetLanguage() const { return maLocale
.meLanguage
;}
186 const OUString
& GetFormatstring() const { return sFormatstring
; }
188 // Build a format string of application defined keywords
189 OUString
GetMappedFormatstring( const NfKeywordTable
& rKeywords
,
190 const LocaleDataWrapper
& rLoc
,
191 LanguageType nOriginalLang
= LANGUAGE_DONTKNOW
) const;
193 void SetStarFormatSupport( bool b
) { bStarFlag
= b
; }
196 * Get output string from a numeric value that fits the number of
197 * characters specified.
199 bool GetOutputString( double fNumber
, sal_uInt16 nCharCount
, OUString
& rOutString
) const;
201 bool GetOutputString( double fNumber
, OUString
& OutString
, Color
** ppColor
);
202 void GetOutputString( const OUString
& sString
, OUString
& OutString
, Color
** ppColor
);
205 bool IsTextFormat() const { return (eType
& css::util::NumberFormat::TEXT
) != 0; }
206 // True if 4th subformat present
207 bool HasTextFormat() const
209 return (NumFor
[3].GetCount() > 0) ||
210 (NumFor
[3].Info().eScannedType
== css::util::NumberFormat::TEXT
);
213 void GetFormatSpecialInfo(bool& bThousand
,
215 sal_uInt16
& nPrecision
,
216 sal_uInt16
& nAnzLeading
) const;
218 /// Get index of subformat (0..3) according to conditions and fNumber value
219 sal_uInt16
GetSubformatIndex( double fNumber
) const;
221 /// Count of decimal precision
222 sal_uInt16
GetFormatPrecision( sal_uInt16 nIx
= 0 ) const
223 { return NumFor
[nIx
].Info().nCntPost
; }
225 /// Count of integer digits
226 sal_uInt16
GetFormatIntegerDigits( sal_uInt16 nIx
= 0 ) const
227 { return NumFor
[nIx
].Info().nCntPre
; }
229 /** Count of hidden integer digits with thousands divisor:
230 * formats like "0," to show only thousands
232 sal_uInt16
GetThousandDivisorPrecision( sal_uInt16 nIx
= 0 ) const
233 { return NumFor
[nIx
].Info().nThousand
* 3; }
235 //! Read/write access on a special sal_uInt16 component, may only be used on the
236 //! standard format 0, 10000, ... and only by the number formatter!
237 struct FormatterPrivateAccess
{ friend SvNumberFormatter
; private: FormatterPrivateAccess() {} };
238 sal_uInt16
GetLastInsertKey( const FormatterPrivateAccess
& ) const
239 { return NumFor
[0].Info().nThousand
; }
240 void SetLastInsertKey( sal_uInt16 nKey
, const FormatterPrivateAccess
& )
241 { NumFor
[0].Info().nThousand
= nKey
; }
243 //! Only onLoad: convert from stored to current system language/country
244 void ConvertLanguage( SvNumberFormatter
& rConverter
,
245 LanguageType eConvertFrom
, LanguageType eConvertTo
);
247 // Substring of a subformat code nNumFor (0..3)
248 // nPos == 0xFFFF => last substring
249 // bString==true: first/last SYMBOLTYPE_STRING or SYMBOLTYPE_CURRENCY
250 const OUString
* GetNumForString( sal_uInt16 nNumFor
, sal_uInt16 nPos
,
251 bool bString
= false ) const;
253 // Subtype of a subformat code nNumFor (0..3)
254 // nPos == 0xFFFF => last substring
255 short GetNumForType( sal_uInt16 nNumFor
, sal_uInt16 nPos
) const;
257 OUString
GetDenominatorString( sal_uInt16 nNumFor
) const;
258 OUString
GetNumeratorString( sal_uInt16 nNumFor
) const;
259 OUString
GetIntegerFractionDelimiterString( sal_uInt16 nNumFor
) const;
260 /// Round fNumber to its fraction representation
261 double GetRoundFractionValue ( double fNumber
) const;
263 /** If the count of string elements (substrings, ignoring [modifiers] and
264 so on) in a subformat code nNumFor (0..3) is equal to the given number.
265 Used by ImpSvNumberInputScan::IsNumberFormatMain() to detect a matched
267 bool IsNumForStringElementCountEqual( sal_uInt16 nNumFor
, sal_uInt16 nAllCount
,
268 sal_uInt16 nNumCount
) const
272 // First try a simple approach. Note that this is called only
273 // if all MidStrings did match so far, to verify that all
274 // strings of the format were matched and not just the starting
275 // sequence, so we don't have to check if GetnAnz() includes
276 // [modifiers] or anything else if both counts are equal.
277 sal_uInt16 nCnt
= NumFor
[nNumFor
].GetCount();
278 if ( nAllCount
== nCnt
)
280 if ( nAllCount
< nCnt
) // check ignoring [modifiers] and so on
281 return ImpGetNumForStringElementCount( nNumFor
) ==
282 (nAllCount
- nNumCount
);
286 /** Get the count of numbers among string elements **/
287 sal_uInt16
GetNumForNumberElementCount( sal_uInt16 nNumFor
) const;
289 /** Get the scanned type of the specified subformat. */
290 short GetNumForInfoScannedType( sal_uInt16 nNumFor
) const
292 return (nNumFor
< 4) ? NumFor
[nNumFor
].Info().eScannedType
: css::util::NumberFormat::UNDEFINED
;
295 // Whether the second subformat code is really for negative numbers
296 // or another limit set.
297 bool IsSecondSubformatRealNegative() const
299 return fLimit1
== 0.0 && fLimit2
== 0.0 &&
300 ( (eOp1
== NUMBERFORMAT_OP_GE
&& eOp2
== NUMBERFORMAT_OP_NO
) ||
301 (eOp1
== NUMBERFORMAT_OP_GT
&& eOp2
== NUMBERFORMAT_OP_LT
) ||
302 (eOp1
== NUMBERFORMAT_OP_NO
&& eOp2
== NUMBERFORMAT_OP_NO
) );
305 // Whether the first subformat code is really for negative numbers
306 // or another limit set.
307 bool IsFirstSubformatRealNegative() const
309 return fLimit1
== 0.0 && fLimit2
== 0.0 &&
310 ((eOp1
== NUMBERFORMAT_OP_LT
&&
311 (eOp2
== NUMBERFORMAT_OP_GT
|| eOp2
== NUMBERFORMAT_OP_EQ
||
312 eOp2
== NUMBERFORMAT_OP_GE
|| eOp2
== NUMBERFORMAT_OP_NO
)) ||
313 (eOp1
== NUMBERFORMAT_OP_LE
&&
314 (eOp2
== NUMBERFORMAT_OP_NO
|| eOp2
== NUMBERFORMAT_OP_GT
)));
317 // Whether the negative format is without a sign or not
318 bool IsNegativeWithoutSign() const;
320 bool IsNegativeInBracket() const;
322 bool HasPositiveBracketPlaceholder() const;
324 // Whether a new SYMBOLTYPE_CURRENCY is contained in the format
325 bool HasNewCurrency() const;
327 // strip [$-yyy] from all [$xxx-yyy] leaving only xxx's,
328 // if bQuoteSymbol==true the xxx will become "xxx"
329 static OUString
StripNewCurrencyDelimiters( const OUString
& rStr
,
332 // If a new SYMBOLTYPE_CURRENCY is contained if the format is of type
333 // css::util::NumberFormat::CURRENCY, and if so the symbol xxx and the extension nnn
334 // of [$xxx-nnn] are returned
335 bool GetNewCurrencySymbol( OUString
& rSymbol
, OUString
& rExtension
) const;
337 static bool HasStringNegativeSign( const OUString
& rStr
);
340 Whether a character at position nPos is somewhere between two matching
342 If nPos points to a cQuote, a true is returned on an opening cQuote,
343 a false is returned on a closing cQuote.
344 A cQuote between quotes may be escaped by a cEscIn, a cQuote outside of
345 quotes may be escaped by a cEscOut.
346 The default '\0' results in no escapement possible.
347 Defaults are set right according to the "unlogic" of the Numberformatter
349 static bool IsInQuote( const OUString
& rString
, sal_Int32 nPos
,
350 sal_Unicode cQuote
= '"',
351 sal_Unicode cEscIn
= '\0', sal_Unicode cEscOut
= '\\' );
354 Return the position of a matching closing cQuote if the character at
355 position nPos is between two matching cQuote, otherwise return -1.
356 If nPos points to an opening cQuote the position of the matching
357 closing cQuote is returned.
358 If nPos points to a closing cQuote nPos is returned.
359 If nPos points into a part which starts with an opening cQuote but has
360 no closing cQuote, rString.Len() is returned.
361 Uses <method>IsInQuote</method> internally, so you don't have to call
362 that prior to a call of this method.
364 static sal_Int32
GetQuoteEnd( const OUString
& rString
, sal_Int32 nPos
,
365 sal_Unicode cQuote
= '"',
366 sal_Unicode cEscIn
= '\0' );
368 void SetComment( const OUString
& rStr
)
370 const OUString
& GetComment() const { return sComment
; }
372 /** Insert the number of blanks into the string that is needed to simulate
373 the width of character c for underscore formats */
374 static sal_Int32
InsertBlanks( OUString
& r
, sal_Int32 nPos
, sal_Unicode c
)
377 OUStringBuffer
sBuff(r
);
379 result
= InsertBlanks(sBuff
, nPos
, c
);
380 r
= sBuff
.makeStringAndClear();
385 /** Insert the number of blanks into the string that is needed to simulate
386 the width of character c for underscore formats */
387 static sal_Int32
InsertBlanks( OUStringBuffer
& r
, sal_Int32 nPos
, sal_Unicode c
);
389 /// One of YMD,DMY,MDY if date format
390 DateOrder
GetDateOrder() const;
392 /** A coded value of the exact YMD combination used, if date format.
393 For example: YYYY-MM-DD => ('Y' << 16) | ('M' << 8) | 'D'
394 or: MM/YY => ('M' << 8) | 'Y' */
395 sal_uInt32
GetExactDateOrder() const;
397 // used in XML export
398 void GetConditions( SvNumberformatLimitOps
& rOper1
, double& rVal1
,
399 SvNumberformatLimitOps
& rOper2
, double& rVal2
) const;
400 Color
* GetColor( sal_uInt16 nNumFor
) const;
401 void GetNumForInfo( sal_uInt16 nNumFor
, short& rScannedType
,
402 bool& bThousand
, sal_uInt16
& nPrecision
, sal_uInt16
& nAnzLeading
) const;
404 // rAttr.Number not empty if NatNum attributes are to be stored
406 css::i18n::NativeNumberXmlAttributes
& rAttr
,
407 sal_uInt16 nNumFor
) const;
409 /** Switches to the first non-"gregorian" calendar, but only if the current
410 calendar is "gregorian"; original calendar name and date/time returned,
411 but only if calendar switched and rOrgCalendar was empty. */
412 void SwitchToOtherCalendar( OUString
& rOrgCalendar
, double& fOrgDateTime
) const;
414 /** Switches to the "gregorian" calendar, but only if the current calendar
415 is non-"gregorian" and rOrgCalendar is not empty. Thus a preceding
416 ImpSwitchToOtherCalendar() call should have been placed prior to
417 calling this method. */
418 void SwitchToGregorianCalendar( const OUString
& rOrgCalendar
, double fOrgDateTime
) const;
421 /** Switches to the first specified calendar, if any, in subformat nNumFor
422 (0..3). Original calendar name and date/time returned, but only if
423 calendar switched and rOrgCalendar was empty.
426 <TRUE/> if a calendar was specified and switched to,
429 bool SwitchToSpecifiedCalendar( OUString
& rOrgCalendar
, double& fOrgDateTime
,
430 sal_uInt16 nNumFor
) const
433 return ImpSwitchToSpecifiedCalendar( rOrgCalendar
,
434 fOrgDateTime
, NumFor
[nNumFor
] );
439 /// Whether it's a (YY)YY-M(M)-D(D) format.
440 bool IsIso8601( sal_uInt16 nNumFor
)
443 return ImpIsIso8601( NumFor
[nNumFor
]);
448 ImpSvNumFor NumFor
[4]; // Array for the 4 subformats
449 OUString sFormatstring
; // The format code string
450 OUString sComment
; // Comment, since number formatter version 6
451 double fLimit1
; // Value for first condition
452 double fLimit2
; // Value for second condition
453 ImpSvNumberformatScan
& rScan
; // Format code scanner
454 LocaleType maLocale
; // Language/country of the format, numeral shape and calendar type from Excel.
455 SvNumberformatLimitOps eOp1
; // Operator for first condition
456 SvNumberformatLimitOps eOp2
; // Operator for second condition
457 short eType
; // Type of format
458 bool bAdditionalBuiltin
; // If this is an additional built-in format defined by i18n
459 bool bStarFlag
; // Take *n format as ESC n
460 bool bStandard
; // If this is a default standard format
461 bool bIsUsed
; // Flag as used for storing
463 SVL_DLLPRIVATE sal_uInt16
ImpGetNumForStringElementCount( sal_uInt16 nNumFor
) const;
465 SVL_DLLPRIVATE
bool ImpIsOtherCalendar( const ImpSvNumFor
& rNumFor
) const;
468 SVL_DLLPRIVATE
bool ImpSwitchToSpecifiedCalendar( OUString
& rOrgCalendar
,
469 double& fOrgDateTime
,
470 const ImpSvNumFor
& rNumFor
) const;
473 /** Whether to use possessive genitive case month name, or partitive case
474 month name, instead of nominative name (noun).
477 0: execute check <br>
478 set to 1 if nominative case is returned, <br>
479 set to 2 if genitive case is returned, <br>
480 set to 3 if partitive case is returned <br>
481 1: don't execute check, return nominative case <br>
482 2: don't execute check, return genitive case <br>
483 3: don't execute check, return partitive case <br>
486 a NfKeywordIndex, must designate a month type code
488 @returns one of css::i18n::CalendarDisplayCode values
489 according to eCodeType and the check executed (or passed).
491 SVL_DLLPRIVATE
static sal_Int32
ImpUseMonthCase( int & io_nState
, const ImpSvNumFor
& rNumFor
, NfKeywordIndex eCodeType
);
493 /// Whether it's a (YY)YY-M(M)-D(D) format.
494 SVL_DLLPRIVATE
bool ImpIsIso8601( const ImpSvNumFor
& rNumFor
) const;
496 const CharClass
& rChrCls() const;
497 const LocaleDataWrapper
& rLoc() const;
498 CalendarWrapper
& GetCal() const;
499 const SvNumberFormatter
& GetFormatter() const;
501 // divide in substrings and color conditions
502 SVL_DLLPRIVATE
short ImpNextSymbol( OUStringBuffer
& rString
,
506 // read string until ']' and strip blanks (after condition)
507 SVL_DLLPRIVATE
static sal_Int32
ImpGetNumber( OUStringBuffer
& rString
,
512 * Parse the content of '[$-xxx] or '[$-xxxxxxxx]' and extract the locale
513 * type from it. Given the string, start parsing at position specified by
514 * nPos, and store the end position with nPos when the parsing is
515 * complete. The nPos should point to the '$' before the parsing, and to
516 * the closing bracket after the parsing. When the content is [$-xxx],
517 * the xxx part represents the language type (aka LCID) in hex numerals.
518 * When the content is [$-xxxxxxxx] the last 4 digits represent the LCID
519 * (again in hex), the next 2 digits represent the calendar type, and the
520 * 2 highest digits (if exists) is the numeral shape.
523 * http://office.microsoft.com/en-us/excel-help/creating-international-number-formats-HA001034635.aspx
525 * @param rString input string
526 * @param nPos position (see above).
528 * @return struct containing numeral shape, calendar type, and LCID that
529 * specifies language type. See i18nlangtag/lang.h for a complete
530 * list of language types. These numbers also correspond with the
531 * numbers used by Microsoft Office.
533 SVL_DLLPRIVATE
static LocaleType
ImpGetLocaleType( const OUString
& rString
, sal_Int32
& nPos
);
535 /** Obtain calendar and numerals from a LocaleType that was parsed from a
536 LCID with ImpGetLocaleType().
538 Inserts a NatNum modifier to rString at nPos if needed as determined
539 from the numeral code.
541 @ATTENTION: may modify <member>maLocale</member> to make it follow
542 aTmpLocale, in which case also nLang is adapted.
544 @returns a string with the calendar if one was determined from the
545 calendar code, else an empty string. The calendar string needs to be
546 inserted at a proper position to rString after all bracketed prefixes.
548 SVL_DLLPRIVATE OUString
ImpObtainCalendarAndNumerals( OUStringBuffer
& rString
,
550 LanguageType
& nLang
,
551 const LocaleType
& aTmpLocale
);
553 // standard number output
554 SVL_DLLPRIVATE
void ImpGetOutputStandard( double& fNumber
, OUString
& OutString
);
555 SVL_DLLPRIVATE
void ImpGetOutputStandard( double& fNumber
, OUStringBuffer
& OutString
);
556 SVL_DLLPRIVATE
void ImpGetOutputStdToPrecision( double& rNumber
, OUString
& rOutString
, sal_uInt16 nPrecision
) const;
557 // numbers in input line
558 SVL_DLLPRIVATE
void ImpGetOutputInputLine( double fNumber
, OUString
& OutString
);
560 // check subcondition
561 // OP undefined => -1
563 SVL_DLLPRIVATE
static short ImpCheckCondition(double& fNumber
,
565 SvNumberformatLimitOps eOp
);
567 // Helper function for number strings
568 // append string symbols, insert leading 0 or ' ', or ...
569 SVL_DLLPRIVATE
bool ImpNumberFill( OUStringBuffer
& sStr
,
575 bool bInsertRightBlank
= false );
577 // Helper function to fill in the integer part and the group (AKA thousand) separators
578 SVL_DLLPRIVATE
bool ImpNumberFillWithThousands( OUStringBuffer
& sStr
,
584 bool bAddDecSep
= true );
586 // Helper function to fill in the group (AKA thousand) separators
587 // or to skip additional digits
588 SVL_DLLPRIVATE
void ImpDigitFill( OUStringBuffer
& sStr
,
592 sal_Int32
& nDigitCount
,
593 utl::DigitGroupingIterator
& );
595 SVL_DLLPRIVATE
bool ImpDecimalFill( OUStringBuffer
& sStr
,
601 /** Calculate each element of fraction:
602 * integer part, numerator part, denominator part
603 * @param fNumber value to be represented as fraction. Will contain absolute fractional part
604 * @param nIx subformat number 0..3
605 * @param fIntPart integral part of fraction
606 * @param nFrac numerator of fraction
607 * @param nDic denominator of fraction
609 SVL_DLLPRIVATE
void ImpGetFractionElements( double& fNumber
,
613 sal_uInt64
& nDiv
) const;
614 SVL_DLLPRIVATE
bool ImpGetFractionOutput(double fNumber
,
616 OUStringBuffer
& OutString
);
617 SVL_DLLPRIVATE
bool ImpGetScientificOutput(double fNumber
,
619 OUStringBuffer
& OutString
);
621 SVL_DLLPRIVATE
bool ImpGetDateOutput( double fNumber
,
623 OUStringBuffer
& OutString
);
624 SVL_DLLPRIVATE
bool ImpGetTimeOutput( double fNumber
,
626 OUStringBuffer
& OutString
);
627 SVL_DLLPRIVATE
bool ImpGetDateTimeOutput( double fNumber
,
629 OUStringBuffer
& OutString
);
631 // Switches to the "gregorian" calendar if the current calendar is
632 // non-"gregorian" and the era is a "Dummy" era of a calendar which doesn't
633 // know a "before" era (like zh_TW ROC or ja_JP Gengou). If switched and
634 // rOrgCalendar was "gregorian" the string is emptied. If rOrgCalendar was
635 // empty the previous calendar name and date/time are returned.
636 SVL_DLLPRIVATE
bool ImpFallBackToGregorianCalendar( OUString
& rOrgCalendar
, double& fOrgDateTime
);
638 // Append a "G" short era string of the given calendar. In the case of a
639 // Gengou calendar this is a one character abbreviation, for other
640 // calendars the XExtendedCalendar::getDisplayString() method is called.
641 SVL_DLLPRIVATE
static void ImpAppendEraG( OUStringBuffer
& OutStringBuffer
, const CalendarWrapper
& rCal
,
644 SVL_DLLPRIVATE
bool ImpGetNumberOutput( double fNumber
,
646 OUStringBuffer
& OutString
);
648 SVL_DLLPRIVATE
void ImpCopyNumberformat( const SvNumberformat
& rFormat
);
650 // normal digits or other digits, depending on ImpSvNumFor.aNatNum,
651 // [NatNum1], [NatNum2], ...
652 SVL_DLLPRIVATE OUString
ImpGetNatNumString( const SvNumberNatNum
& rNum
, sal_Int32 nVal
,
653 sal_uInt16 nMinDigits
) const;
655 OUString
ImpIntToString( sal_uInt16 nIx
, sal_Int32 nVal
, sal_uInt16 nMinDigits
= 0 ) const
657 const SvNumberNatNum
& rNum
= NumFor
[nIx
].GetNatNum();
658 if ( nMinDigits
|| rNum
.IsComplete() )
660 return ImpGetNatNumString( rNum
, nVal
, nMinDigits
);
662 return OUString::number(nVal
);
665 // transliterate according to NativeNumber
666 SVL_DLLPRIVATE OUString
impTransliterateImpl(const OUString
& rStr
, const SvNumberNatNum
& rNum
) const;
667 SVL_DLLPRIVATE
void impTransliterateImpl(OUStringBuffer
& rStr
, const SvNumberNatNum
& rNum
) const;
669 OUString
impTransliterate(const OUString
& rStr
, const SvNumberNatNum
& rNum
) const
671 return rNum
.IsComplete() ? impTransliterateImpl(rStr
, rNum
) : rStr
;
674 SVL_DLLPRIVATE
void impTransliterate(OUStringBuffer
& rStr
, const SvNumberNatNum
& rNum
) const
676 if(rNum
.IsComplete())
678 impTransliterateImpl(rStr
, rNum
);
683 #endif // INCLUDED_SVL_ZFORMAT_HXX
685 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */