LibreOffice Module svl (master) 1
zformat.hxx
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#ifndef INCLUDED_SVL_ZFORMAT_HXX
20#define INCLUDED_SVL_ZFORMAT_HXX
21
22#include <svl/svldllapi.h>
23#include <svl/zforlist.hxx>
24#include <svl/nfkeytab.hxx>
25#include <vector>
26
27namespace utl {
28 class DigitGroupingIterator;
29}
30
31namespace com::sun::star::i18n { struct NativeNumberXmlAttributes2; }
32
33class Color;
34
35class ImpSvNumberformatScan; // format code string scanner
36class ImpSvNumberInputScan; // input string scanner
38
40{
41 NUMBERFORMAT_OP_NO = 0, // Undefined, no OP
42 NUMBERFORMAT_OP_EQ = 1, // Operator =
43 NUMBERFORMAT_OP_NE = 2, // Operator <>
44 NUMBERFORMAT_OP_LT = 3, // Operator <
45 NUMBERFORMAT_OP_LE = 4, // Operator <=
46 NUMBERFORMAT_OP_GT = 5, // Operator >
47 NUMBERFORMAT_OP_GE = 6 // Operator >=
48};
49
50struct ImpSvNumberformatInfo // Struct for FormatInfo
51{
52 std::vector<OUString> sStrArray; // Array of symbols
53 std::vector<short> nTypeArray; // Array of infos
54 sal_uInt16 nThousand; // Count of group separator sequences
55 sal_uInt16 nCntPre; // Count of digits before decimal point
56 sal_uInt16 nCntPost; // Count of digits after decimal point
57 sal_uInt16 nCntExp; // Count of exponent digits, or AM/PM
58 SvNumFormatType eScannedType; // Type determined by scan
59 bool bThousand; // Has group (AKA thousand) separator
60
61 void Copy( const ImpSvNumberformatInfo& rNumFor, sal_uInt16 nCount );
62};
63
64// NativeNumber, represent numbers using CJK or other digits if nNum>0,
65// eLang specifies the Locale to use.
67{
68 OUString sParams; // For [NatNum12 ordinal-number]-like syntax
71 bool bDBNum :1; // DBNum, to be converted to NatNum
72 bool bDate :1; // Used in date? (needed for DBNum/NatNum mapping)
73 bool bSet :1; // If set, since NatNum0 is possible
74
75public:
76
79
81 bDBNum(false), bDate(false), bSet(false) {}
82 bool IsComplete() const { return bSet && eLang != LANGUAGE_DONTKNOW; }
85 LanguageType GetLang() const { return eLang; }
86 void SetLang( LanguageType e ) { eLang = e; }
87 void SetNum( sal_uInt8 nNumber, bool bDBNumber )
88 {
89 nNum = nNumber;
90 bDBNum = bDBNumber;
91 bSet = true;
92 }
93 bool IsSet() const { return bSet; }
94 void SetDate( bool bDateP ) { bDate = bDateP; }
95 void SetParams(const OUString& s) { sParams = s; }
96 OUString const & GetParams() const { return sParams; }
97};
98
99class CharClass;
100
101class ImpSvNumFor // One of four subformats of the format code string
102{
103public:
104 ImpSvNumFor(); // Ctor without filling the Info
105 ~ImpSvNumFor();
106
107 void Enlarge(sal_uInt16 nCount); // Init of arrays to the right size
108
109 // if pSc is set, it is used to get the Color pointer
110 void Copy( const ImpSvNumFor& rNumFor, const ImpSvNumberformatScan* pSc );
111
112 // Access to Info; call Enlarge before!
114 const ImpSvNumberformatInfo& Info() const { return aI; }
115
116 // Get count of substrings (symbols)
117 sal_uInt16 GetCount() const { return nStringsCnt;}
118
119 const Color* GetColor() const { return pColor; }
120 void SetColor(const Color* pCol, OUString const& rName)
121 { pColor = pCol; sColorName = rName; }
122 const OUString& GetColorName() const { return sColorName; }
123
124 // new SYMBOLTYPE_CURRENCY in subformat?
125 bool HasNewCurrency() const;
126 bool GetNewCurrencySymbol( OUString& rSymbol, OUString& rExtension ) const;
127
128 // [NatNum1], [NatNum2], ...
129 void SetNatNumNum( sal_uInt8 nNum, bool bDBNum ) { aNatNum.SetNum( nNum, bDBNum ); }
130 void SetNatNumLang( LanguageType eLang ) { aNatNum.SetLang( eLang ); }
131 void SetNatNumDate( bool bDate ) { aNatNum.SetDate( bDate ); }
132 void SetNatNumParams(const OUString& sParams) { aNatNum.SetParams(sParams); }
133 const SvNumberNatNum& GetNatNum() const { return aNatNum; }
134
135private:
136 ImpSvNumberformatInfo aI; // helper struct for remaining information
137 OUString sColorName; // color name
138 const Color* pColor; // pointer to color of subformat
139 sal_uInt16 nStringsCnt; // count of symbols
140 SvNumberNatNum aNatNum; // DoubleByteNumber
141
142};
143
145{
146 struct SAL_DLLPRIVATE LocaleType
147 {
149 {
150 NONE,
151 TIME,
152 LONGDATE
153 };
154
160
161 OUString generateCode() const;
162
163 LocaleType();
164 LocaleType(sal_uInt32 nRawCode);
165
166 bool isPlainLocale() const;
167 };
168
169public:
170 // Normal ctor
171 SvNumberformat( OUString& rString,
174 sal_Int32& nCheckPos,
175 LanguageType& eLan,
176 bool bReplaceBooleanEquivalent = true );
177
178 // Copy ctor
179 SvNumberformat( SvNumberformat const & rFormat );
180
181 // Copy ctor with exchange of format code string scanner (used in merge)
182 SvNumberformat( SvNumberformat const & rFormat, ImpSvNumberformatScan& rSc );
183
185
187 SvNumFormatType GetType() const { return eType; }
188
191
192 void SetType(SvNumFormatType eSetType) { eType = eSetType; }
193 // Standard means the I18N defined standard format of this type
194 void SetStandard() { bStandard = true; }
195 bool IsStandard() const { return bStandard; }
196
197 // If this format is an additional built-in format defined by i18n.
198 void SetAdditionalBuiltin() { bAdditionalBuiltin = true; }
199 bool IsAdditionalBuiltin() const { return bAdditionalBuiltin; }
200
201 LanguageType GetLanguage() const { return maLocale.meLanguage;}
202
204 bool IsSubstituted() const
205 {
206 return maLocale.meSubstitute != LocaleType::Substitute::NONE;
207 }
208
213 {
214 return maLocale.meSubstitute == LocaleType::Substitute::TIME && maLocale.meLanguage == LANGUAGE_SYSTEM;
215 }
216
221 {
222 return maLocale.meSubstitute == LocaleType::Substitute::LONGDATE && maLocale.meLanguage == LANGUAGE_SYSTEM;
223 }
224
228 bool IsMinuteSecondFormat() const;
229
230 const OUString& GetFormatstring() const { return sFormatstring; }
231
232 // Build a format string of application defined keywords
233 OUString GetMappedFormatstring( const NfKeywordTable& rKeywords,
234 const LocaleDataWrapper& rLoc,
235 LanguageType nOriginalLang = LANGUAGE_DONTKNOW,
236 bool bSystemLanguage = false ) const;
237
238 void SetStarFormatSupport( bool b ) { bStarFlag = b; }
239
244 bool GetOutputString( double fNumber, sal_uInt16 nCharCount, OUString& rOutString ) const;
245
246 bool GetOutputString( double fNumber, OUString& OutString, const Color** ppColor );
247 void GetOutputString( std::u16string_view sString, OUString& OutString, const Color** ppColor );
248
249 // True if type text
250 bool IsTextFormat() const { return bool(eType & SvNumFormatType::TEXT); }
251 // True if 4th subformat present
252 bool HasTextFormat() const
253 {
254 return (NumFor[3].GetCount() > 0) ||
255 (NumFor[3].Info().eScannedType == SvNumFormatType::TEXT);
256 }
257
258 void GetFormatSpecialInfo(bool& bThousand,
259 bool& IsRed,
260 sal_uInt16& nPrecision,
261 sal_uInt16& nLeadingCnt) const;
262
264 sal_uInt16 GetSubformatIndex( double fNumber ) const;
265
267 sal_uInt16 GetFormatPrecision( sal_uInt16 nIx = 0 ) const
268 { return NumFor[nIx].Info().nCntPost; }
269
271 sal_uInt16 GetFormatIntegerDigits( sal_uInt16 nIx = 0 ) const
272 { return NumFor[nIx].Info().nCntPre; }
273
283 sal_uInt16 GetThousandDivisorPrecision( sal_uInt16 nIx = 0 ) const;
284
288 sal_uInt16 GetLastInsertKey( const FormatterPrivateAccess& ) const
289 { return NumFor[0].Info().nThousand; }
290 void SetLastInsertKey( sal_uInt16 nKey, const FormatterPrivateAccess& )
291 { NumFor[0].Info().nThousand = nKey; }
292
294 void ConvertLanguage( SvNumberFormatter& rConverter,
295 LanguageType eConvertFrom, LanguageType eConvertTo );
296
297 // Substring of a subformat code nNumFor (0..3)
298 // nPos == 0xFFFF => last substring
299 // bString==true: first/last SYMBOLTYPE_STRING or SYMBOLTYPE_CURRENCY
300 const OUString* GetNumForString( sal_uInt16 nNumFor, sal_uInt16 nPos,
301 bool bString = false ) const;
302
303 // Subtype of a subformat code nNumFor (0..3)
304 // nPos == 0xFFFF => last substring
305 short GetNumForType( sal_uInt16 nNumFor, sal_uInt16 nPos ) const;
306
307 OUString GetPercentString( sal_uInt16 nNumFor = 0 ) const;
308
309 OUString GetDenominatorString( sal_uInt16 nNumFor ) const;
310 OUString GetNumeratorString( sal_uInt16 nNumFor ) const;
311 OUString GetIntegerFractionDelimiterString( sal_uInt16 nNumFor ) const;
313 double GetRoundFractionValue ( double fNumber ) const;
314
316 OUString GetFormatStringForTimePrecision( int nPrecision ) const;
317
318
323 bool IsNumForStringElementCountEqual( sal_uInt16 nNumFor, sal_uInt16 nAllCount,
324 sal_uInt16 nNumCount ) const
325 {
326 if ( nNumFor < 4 )
327 {
328 // First try a simple approach. Note that this is called only
329 // if all MidStrings did match so far, to verify that all
330 // strings of the format were matched and not just the starting
331 // sequence, so we don't have to check if GetCount() includes
332 // [modifiers] or anything else if both counts are equal.
333 sal_uInt16 nCnt = NumFor[nNumFor].GetCount();
334 if ( nAllCount == nCnt )
335 return true;
336 if ( nAllCount < nCnt ) // check ignoring [modifiers] and so on
337 return ImpGetNumForStringElementCount( nNumFor ) ==
338 (nAllCount - nNumCount);
339 }
340 return false;
341 }
343 sal_uInt16 GetNumForNumberElementCount( sal_uInt16 nNumFor ) const;
344
346 SvNumFormatType GetNumForInfoScannedType( sal_uInt16 nNumFor ) const
347 {
348 return (nNumFor < 4) ? NumFor[nNumFor].Info().eScannedType : SvNumFormatType::UNDEFINED;
349 }
350
351 // Whether the second subformat code is really for negative numbers
352 // or another limit set.
354 {
355 return fLimit1 == 0.0 && fLimit2 == 0.0 &&
356 ( (eOp1 == NUMBERFORMAT_OP_GE && eOp2 == NUMBERFORMAT_OP_NO) ||
357 (eOp1 == NUMBERFORMAT_OP_GT && eOp2 == NUMBERFORMAT_OP_LT) ||
358 (eOp1 == NUMBERFORMAT_OP_NO && eOp2 == NUMBERFORMAT_OP_NO) );
359 }
360
361 // Whether the first subformat code is really for negative numbers
362 // or another limit set.
364 {
365 return fLimit1 == 0.0 && fLimit2 == 0.0 &&
366 ((eOp1 == NUMBERFORMAT_OP_LT &&
367 (eOp2 == NUMBERFORMAT_OP_GT || eOp2 == NUMBERFORMAT_OP_EQ ||
368 eOp2 == NUMBERFORMAT_OP_GE || eOp2 == NUMBERFORMAT_OP_NO)) ||
369 (eOp1 == NUMBERFORMAT_OP_LE &&
370 (eOp2 == NUMBERFORMAT_OP_NO || eOp2 == NUMBERFORMAT_OP_GT)));
371 }
372
373 // Whether the negative format is without a sign or not
374 bool IsNegativeWithoutSign() const;
375
376 bool IsNegativeInBracket() const;
377
378 bool HasPositiveBracketPlaceholder() const;
379
380 // Whether a new SYMBOLTYPE_CURRENCY is contained in the format
381 bool HasNewCurrency() const;
382
383 // strip [$-yyy] from all [$xxx-yyy] leaving only xxx's,
384 static OUString StripNewCurrencyDelimiters( const OUString& rStr );
385
386 // If a new SYMBOLTYPE_CURRENCY is contained if the format is of type
387 // css::util::NumberFormat::CURRENCY, and if so the symbol xxx and the extension nnn
388 // of [$xxx-nnn] are returned
389 bool GetNewCurrencySymbol( OUString& rSymbol, OUString& rExtension ) const;
390
391 static bool HasStringNegativeSign( const OUString& rStr );
392
403 static bool IsInQuote( const OUString& rString, sal_Int32 nPos,
404 sal_Unicode cQuote = '"',
405 sal_Unicode cEscIn = '\0', sal_Unicode cEscOut = '\\' );
406
418 static sal_Int32 GetQuoteEnd( const OUString& rString, sal_Int32 nPos,
419 sal_Unicode cQuote = '"',
420 sal_Unicode cEscIn = '\0' );
421
422 void SetComment( const OUString& rStr )
423 { sComment = rStr; }
424 const OUString& GetComment() const { return sComment; }
425
428 static sal_Int32 InsertBlanks( OUString& r, sal_Int32 nPos, sal_Unicode c )
429 {
430 sal_Int32 result;
431 OUStringBuffer sBuff(r);
432
433 result = InsertBlanks(sBuff, nPos, c);
434 r = sBuff.makeStringAndClear();
435
436 return result;
437 }
438
441 static sal_Int32 InsertBlanks( OUStringBuffer& r, sal_Int32 nPos, sal_Unicode c );
442
444 DateOrder GetDateOrder() const;
445
449 sal_uInt32 GetExactDateOrder() const;
450
451 // used in XML export
452 void GetConditions( SvNumberformatLimitOps& rOper1, double& rVal1,
453 SvNumberformatLimitOps& rOper2, double& rVal2 ) const;
454 const Color* GetColor( sal_uInt16 nNumFor ) const;
455 void GetNumForInfo( sal_uInt16 nNumFor, SvNumFormatType& rScannedType,
456 bool& bThousand, sal_uInt16& nPrecision, sal_uInt16& nLeadingCnt ) const;
457
458 // rAttr.Number not empty if NatNum attributes are to be stored
459 void GetNatNumXml(
460 css::i18n::NativeNumberXmlAttributes2& rAttr,
461 sal_uInt16 nNumFor ) const;
464 OUString GetNatNumModifierString( sal_uInt16 nNumFor = 0 ) const;
465
469 void SwitchToOtherCalendar( OUString& rOrgCalendar, double& fOrgDateTime ) const;
470
475 void SwitchToGregorianCalendar( std::u16string_view rOrgCalendar, double fOrgDateTime ) const;
476
477#ifdef THE_FUTURE
486 bool SwitchToSpecifiedCalendar( OUString& rOrgCalendar, double& fOrgDateTime,
487 sal_uInt16 nNumFor ) const
488 {
489 if ( nNumFor < 4 )
490 return ImpSwitchToSpecifiedCalendar( rOrgCalendar,
491 fOrgDateTime, NumFor[nNumFor] );
492 return false;
493 }
494#endif
495
497 bool IsIso8601( sal_uInt16 nNumFor ) const
498 {
499 if ( nNumFor < 4 )
500 return ImpIsIso8601( NumFor[nNumFor]);
501 return false;
502 }
503
504private:
505 ImpSvNumFor NumFor[4]; // Array for the 4 subformats
506 OUString sFormatstring; // The format code string
507 OUString sComment; // Comment, since number formatter version 6
508 double fLimit1; // Value for first condition
509 double fLimit2; // Value for second condition
510 ImpSvNumberformatScan& rScan; // Format code scanner
511 LocaleType maLocale; // Language/country of the format, numeral shape and calendar type from Excel.
512 SvNumberformatLimitOps eOp1; // Operator for first condition
513 SvNumberformatLimitOps eOp2; // Operator for second condition
514 SvNumFormatType eType; // Type of format
515 bool bAdditionalBuiltin; // If this is an additional built-in format defined by i18n
516 bool bStarFlag; // Take *n format as ESC n
517 bool bStandard; // If this is a default standard format
518 bool bIsUsed; // Flag as used for storing
519
520 SVL_DLLPRIVATE sal_uInt16 ImpGetNumForStringElementCount( sal_uInt16 nNumFor ) const;
521
522 SVL_DLLPRIVATE bool ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const;
523
524#ifdef THE_FUTURE
525 SVL_DLLPRIVATE bool ImpSwitchToSpecifiedCalendar( OUString& rOrgCalendar,
526 double& fOrgDateTime,
527 const ImpSvNumFor& rNumFor ) const;
528#endif
529
548 SVL_DLLPRIVATE static sal_Int32 ImpUseMonthCase( int & io_nState, const ImpSvNumFor& rNumFor, NfKeywordIndex eCodeType );
549
551 SVL_DLLPRIVATE bool ImpIsIso8601( const ImpSvNumFor& rNumFor ) const;
552
553 const CharClass& rChrCls() const;
554 const LocaleDataWrapper& rLoc() const;
555 CalendarWrapper& GetCal() const;
556 const SvNumberFormatter& GetFormatter() const;
557
558 // divide in substrings and color conditions
559 SVL_DLLPRIVATE short ImpNextSymbol( OUStringBuffer& rString,
560 sal_Int32& nPos,
561 OUString& sSymbol ) const;
562
563 // read string until ']' and strip blanks (after condition)
564 SVL_DLLPRIVATE static sal_Int32 ImpGetNumber( OUStringBuffer& rString,
565 sal_Int32& nPos,
566 OUString& sSymbol );
567
590 SVL_DLLPRIVATE static LocaleType ImpGetLocaleType( std::u16string_view rString, sal_Int32& nPos );
591
605 SVL_DLLPRIVATE OUString ImpObtainCalendarAndNumerals( OUStringBuffer & rString,
606 sal_Int32 nPos,
607 LanguageType & nLang,
608 const LocaleType & aTmpLocale );
609
610 // standard number output
611 SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUString& OutString ) const;
612 SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUStringBuffer& OutString ) const;
613 SVL_DLLPRIVATE void ImpGetOutputStdToPrecision( double& rNumber, OUString& rOutString, sal_uInt16 nPrecision ) const;
614 // numbers in input line
615 SVL_DLLPRIVATE void ImpGetOutputInputLine( double fNumber, OUString& OutString ) const;
616
617 // check subcondition
618 // OP undefined => -1
619 // else 0 or 1
620 SVL_DLLPRIVATE static short ImpCheckCondition(double fNumber,
621 double fLimit,
623
624 // Helper function for number strings
625 // append string symbols, insert leading 0 or ' ', or ...
626 SVL_DLLPRIVATE bool ImpNumberFill( OUStringBuffer& sStr,
627 double& rNumber,
628 sal_Int32& k,
629 sal_uInt16& j,
630 sal_uInt16 nIx,
631 short eSymbolType,
632 bool bInsertRightBlank = false );
633
634 // Helper function to fill in the integer part and the group (AKA thousand) separators
635 SVL_DLLPRIVATE bool ImpNumberFillWithThousands( OUStringBuffer& sStr,
636 double& rNumber,
637 sal_Int32 k,
638 sal_uInt16 j,
639 sal_uInt16 nIx,
640 sal_Int32 nDigCnt,
641 bool bAddDecSep = true );
642
643 // Helper function to fill in the group (AKA thousand) separators
644 // or to skip additional digits
645 SVL_DLLPRIVATE void ImpDigitFill( OUStringBuffer& sStr,
646 sal_Int32 nStart,
647 sal_Int32& k,
648 sal_uInt16 nIx,
649 sal_Int32 & nDigitCount,
651
652 SVL_DLLPRIVATE bool ImpDecimalFill( OUStringBuffer& sStr,
653 double& rNumber,
654 sal_Int32 nDecPos,
655 sal_uInt16 j,
656 sal_uInt16 nIx,
657 bool bInteger );
658
667 SVL_DLLPRIVATE void ImpGetFractionElements( double& fNumber,
668 sal_uInt16 nIx,
669 double& fIntPart,
670 sal_Int64& nFrac,
671 sal_Int64& nDiv ) const;
672 SVL_DLLPRIVATE bool ImpGetFractionOutput(double fNumber,
673 sal_uInt16 nIx,
674 OUStringBuffer& OutString);
675 SVL_DLLPRIVATE bool ImpGetScientificOutput(double fNumber,
676 sal_uInt16 nIx,
677 OUStringBuffer& OutString);
678
679 SVL_DLLPRIVATE bool ImpGetDateOutput( double fNumber,
680 sal_uInt16 nIx,
681 OUStringBuffer& OutString );
682 SVL_DLLPRIVATE bool ImpGetTimeOutput( double fNumber,
683 sal_uInt16 nIx,
684 OUStringBuffer& OutString );
685 SVL_DLLPRIVATE bool ImpGetDateTimeOutput( double fNumber,
686 sal_uInt16 nIx,
687 OUStringBuffer& OutString );
688
689 // Switches to the "gregorian" calendar if the current calendar is
690 // non-"gregorian" and the era is a "Dummy" era of a calendar which doesn't
691 // know a "before" era (like zh_TW ROC or ja_JP Gengou). If switched and
692 // rOrgCalendar was "gregorian" the string is emptied. If rOrgCalendar was
693 // empty the previous calendar name and date/time are returned.
694 SVL_DLLPRIVATE bool ImpFallBackToGregorianCalendar( OUString& rOrgCalendar, double& fOrgDateTime );
695
696 // Append a "G" short era string of the given calendar. In the case of a
697 // Gengou calendar this is a one character abbreviation, for other
698 // calendars the XExtendedCalendar::getDisplayString() method is called.
699 SVL_DLLPRIVATE static void ImpAppendEraG( OUStringBuffer& OutStringBuffer, const CalendarWrapper& rCal,
700 sal_Int16 nNatNum );
701
702 SVL_DLLPRIVATE bool ImpGetLogicalOutput( double fNumber,
703 sal_uInt16 nIx,
704 OUStringBuffer& OutString );
705
706 SVL_DLLPRIVATE bool ImpGetNumberOutput( double fNumber,
707 sal_uInt16 nIx,
708 OUStringBuffer& OutString );
709
710 SVL_DLLPRIVATE void ImpCopyNumberformat( const SvNumberformat& rFormat );
711
712 // normal digits or other digits, depending on ImpSvNumFor.aNatNum,
713 // [NatNum1], [NatNum2], ...
714 SVL_DLLPRIVATE OUString ImpGetNatNumString( const SvNumberNatNum& rNum, sal_Int64 nVal,
715 sal_uInt16 nMinDigits ) const;
716
717 OUString ImpIntToString( sal_uInt16 nIx, sal_Int64 nVal, sal_uInt16 nMinDigits = 0 ) const
718 {
719 const SvNumberNatNum& rNum = NumFor[nIx].GetNatNum();
720 if ( nMinDigits || rNum.IsComplete() )
721 {
722 return ImpGetNatNumString( rNum, nVal, nMinDigits );
723 }
724 return OUString::number(nVal);
725 }
726
727 // Obtain the string of the fraction of second, without leading "0.",
728 // rounded to nFractionDecimals (or nFractionDecimals+1 if
729 // bAddOneRoundingDecimal==true but then truncated at nFractionDecimals,
730 // for use with the result of tools::Time::GetClock()) with the length of
731 // nFractionDecimals, unless nMinimumInputLineDecimals>0 is given for input
732 // line string where extra trailing "0" are discarded.
733 SVL_DLLPRIVATE sal_uInt16 ImpGetFractionOfSecondString( OUStringBuffer& rBuf, double fFractionOfSecond,
734 int nFractionDecimals, bool bAddOneRoundingDecimal, sal_uInt16 nIx, sal_uInt16 nMinimumInputLineDecimals );
735
736 // transliterate according to NativeNumber
737 SVL_DLLPRIVATE OUString impTransliterateImpl(const OUString& rStr, const SvNumberNatNum& rNum) const;
738 SVL_DLLPRIVATE void impTransliterateImpl(OUStringBuffer& rStr, const SvNumberNatNum& rNum) const;
739 SVL_DLLPRIVATE OUString impTransliterateImpl(const OUString& rStr, const SvNumberNatNum& rNum, sal_uInt16 nDateKey) const;
740
741 OUString impTransliterate(const OUString& rStr, const SvNumberNatNum& rNum) const
742 {
743 return rNum.IsComplete() ? impTransliterateImpl(rStr, rNum) : rStr;
744 }
745
746 SVL_DLLPRIVATE void impTransliterate(OUStringBuffer& rStr, const SvNumberNatNum& rNum) const
747 {
748 if(rNum.IsComplete())
749 {
750 impTransliterateImpl(rStr, rNum);
751 }
752 }
753
754 OUString impTransliterate(const OUString& rStr, const SvNumberNatNum& rNum, sal_uInt16 nDateKey) const
755 {
756 return rNum.IsComplete() ? impTransliterateImpl(rStr, rNum, nDateKey) : rStr;
757 }
758
759};
760
761#endif // INCLUDED_SVL_ZFORMAT_HXX
762
763/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetColor(const Color *pCol, OUString const &rName)
Definition: zformat.hxx:120
const SvNumberNatNum & GetNatNum() const
Definition: zformat.hxx:133
const Color * pColor
Definition: zformat.hxx:138
ImpSvNumberformatInfo aI
Definition: zformat.hxx:136
bool HasNewCurrency() const
Definition: zformat.cxx:261
void SetNatNumParams(const OUString &sParams)
Definition: zformat.hxx:132
const OUString & GetColorName() const
Definition: zformat.hxx:122
const ImpSvNumberformatInfo & Info() const
Definition: zformat.hxx:114
void SetNatNumDate(bool bDate)
Definition: zformat.hxx:131
OUString sColorName
Definition: zformat.hxx:137
const Color * GetColor() const
Definition: zformat.hxx:119
ImpSvNumberformatInfo & Info()
Definition: zformat.hxx:113
void Copy(const ImpSvNumFor &rNumFor, const ImpSvNumberformatScan *pSc)
Definition: zformat.cxx:245
ImpSvNumFor()
SvNumFor.
Definition: zformat.cxx:219
void Enlarge(sal_uInt16 nCount)
Definition: zformat.cxx:235
SvNumberNatNum aNatNum
Definition: zformat.hxx:140
bool GetNewCurrencySymbol(OUString &rSymbol, OUString &rExtension) const
Definition: zformat.cxx:273
void SetNatNumNum(sal_uInt8 nNum, bool bDBNum)
Definition: zformat.hxx:129
sal_uInt16 nStringsCnt
Definition: zformat.hxx:139
sal_uInt16 GetCount() const
Definition: zformat.hxx:117
void SetNatNumLang(LanguageType eLang)
Definition: zformat.hxx:130
void SetDate(bool bDateP)
Definition: zformat.hxx:94
bool IsComplete() const
Definition: zformat.hxx:82
void SetLang(LanguageType e)
Definition: zformat.hxx:86
LanguageType eLang
Definition: zformat.hxx:69
sal_uInt8 GetNatNum() const
Definition: zformat.hxx:83
OUString sParams
Definition: zformat.hxx:68
void SetNum(sal_uInt8 nNumber, bool bDBNumber)
Definition: zformat.hxx:87
sal_uInt8 nNum
Definition: zformat.hxx:70
void SetParams(const OUString &s)
Definition: zformat.hxx:95
sal_uInt8 GetDBNum() const
Definition: zformat.hxx:84
static sal_uInt8 MapNatNumToDBNum(sal_uInt8 nNatNum, LanguageType eLang, bool bDate)
Definition: zformat.cxx:187
OUString const & GetParams() const
Definition: zformat.hxx:96
bool IsSet() const
Definition: zformat.hxx:93
LanguageType GetLang() const
Definition: zformat.hxx:85
static sal_uInt8 MapDBNumToNatNum(sal_uInt8 nDBNum, LanguageType eLang, bool bDate)
Definition: zformat.cxx:152
SvNumFormatType GetMaskedType() const
Get type of format, does not include css::util::NumberFormat::DEFINED.
Definition: zformat.hxx:190
void SetStarFormatSupport(bool b)
Definition: zformat.hxx:238
void SetType(SvNumFormatType eSetType)
Definition: zformat.hxx:192
bool IsNumForStringElementCountEqual(sal_uInt16 nNumFor, sal_uInt16 nAllCount, sal_uInt16 nNumCount) const
If the count of string elements (substrings, ignoring [modifiers] and so on) in a subformat code nNum...
Definition: zformat.hxx:323
void SetAdditionalBuiltin()
Definition: zformat.hxx:198
sal_uInt16 GetFormatIntegerDigits(sal_uInt16 nIx=0) const
Count of integer digits.
Definition: zformat.hxx:271
LanguageType GetLanguage() const
Definition: zformat.hxx:201
bool IsIso8601(sal_uInt16 nNumFor) const
Whether it's a (YY)YY-M(M)-D(D) format.
Definition: zformat.hxx:497
void SetComment(const OUString &rStr)
Definition: zformat.hxx:422
ImpSvNumberformatScan & rScan
Definition: zformat.hxx:510
void SetLastInsertKey(sal_uInt16 nKey, const FormatterPrivateAccess &)
Definition: zformat.hxx:290
SvNumFormatType eType
Definition: zformat.hxx:514
bool IsAdditionalBuiltin() const
Definition: zformat.hxx:199
sal_uInt16 GetFormatPrecision(sal_uInt16 nIx=0) const
Count of decimal precision.
Definition: zformat.hxx:267
bool IsStandard() const
Definition: zformat.hxx:195
SvNumberformatLimitOps eOp2
Definition: zformat.hxx:513
double fLimit1
Definition: zformat.hxx:508
bool IsTextFormat() const
Definition: zformat.hxx:250
bool IsSystemLongDateFormat() const
If the format is a placeholder for the system long date format and needs to be substituted during for...
Definition: zformat.hxx:220
SVL_DLLPRIVATE void impTransliterate(OUStringBuffer &rStr, const SvNumberNatNum &rNum) const
Definition: zformat.hxx:746
OUString ImpIntToString(sal_uInt16 nIx, sal_Int64 nVal, sal_uInt16 nMinDigits=0) const
Definition: zformat.hxx:717
bool IsFirstSubformatRealNegative() const
Definition: zformat.hxx:363
bool HasTextFormat() const
Definition: zformat.hxx:252
OUString sFormatstring
Definition: zformat.hxx:506
const OUString & GetComment() const
Definition: zformat.hxx:424
LocaleType maLocale
Definition: zformat.hxx:511
SvNumberformatLimitOps eOp1
Definition: zformat.hxx:512
double fLimit2
Definition: zformat.hxx:509
SvNumFormatType GetNumForInfoScannedType(sal_uInt16 nNumFor) const
Get the scanned type of the specified subformat.
Definition: zformat.hxx:346
const OUString & GetFormatstring() const
Definition: zformat.hxx:230
bool IsSystemTimeFormat() const
If the format is a placeholder for the system time format and needs to be substituted during formatti...
Definition: zformat.hxx:212
OUString sComment
Definition: zformat.hxx:507
OUString impTransliterate(const OUString &rStr, const SvNumberNatNum &rNum, sal_uInt16 nDateKey) const
Definition: zformat.hxx:754
void SetStandard()
Definition: zformat.hxx:194
SvNumFormatType GetType() const
Get type of format, may include css::util::NumberFormat::DEFINED bit.
Definition: zformat.hxx:187
OUString impTransliterate(const OUString &rStr, const SvNumberNatNum &rNum) const
Definition: zformat.hxx:741
bool IsSubstituted() const
If the format is a placeholder and needs to be substituted.
Definition: zformat.hxx:204
sal_uInt16 GetLastInsertKey(const FormatterPrivateAccess &) const
Definition: zformat.hxx:288
bool bAdditionalBuiltin
Definition: zformat.hxx:515
static sal_Int32 InsertBlanks(OUString &r, sal_Int32 nPos, sal_Unicode c)
Insert the number of blanks into the string that is needed to simulate the width of character c for u...
Definition: zformat.hxx:428
bool IsSecondSubformatRealNegative() const
Definition: zformat.hxx:353
int nCount
DocumentType eType
#define LANGUAGE_SYSTEM
#define LANGUAGE_DONTKNOW
sal_uInt16 nPos
DateOrder
NONE
::std::array< OUString, NF_KEYWORD_ENTRIES_COUNT > NfKeywordTable
Definition: nfkeytab.hxx:98
NfKeywordIndex
For ImpSvNumberformatScan: first the short symbols, then the long symbols! e.g.
Definition: nfkeytab.hxx:35
std::vector< OUString > sStrArray
Definition: zformat.hxx:52
void Copy(const ImpSvNumberformatInfo &rNumFor, sal_uInt16 nCount)
SvNumberformatInfo.
Definition: zformat.cxx:131
SvNumFormatType eScannedType
Definition: zformat.hxx:58
sal_uInt16 nCntExp
Definition: zformat.hxx:57
std::vector< short > nTypeArray
Definition: zformat.hxx:53
sal_uInt16 nThousand
Definition: zformat.hxx:54
sal_uInt16 nCntPost
Definition: zformat.hxx:56
sal_uInt16 nCntPre
Definition: zformat.hxx:55
Read/write access on a special sal_uInt16 component, may only be used on the standard format 0,...
Definition: zformat.hxx:287
LanguageType meLanguageWithoutLocaleData
Definition: zformat.hxx:156
#define SVL_DLLPRIVATE
Definition: svldllapi.h:30
#define SVL_DLLPUBLIC
Definition: svldllapi.h:28
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
Any result
SvNumFormatType
MAX_ULONG.
Definition: zforlist.hxx:50
@ UNDEFINED
is used as a return value if no format exists.
@ TEXT
selects text number formats.
@ DEFINED
selects only user-defined number formats.
SvNumberformatLimitOps
Definition: zformat.hxx:40
@ NUMBERFORMAT_OP_LT
Definition: zformat.hxx:44
@ NUMBERFORMAT_OP_NO
Definition: zformat.hxx:41
@ NUMBERFORMAT_OP_GE
Definition: zformat.hxx:47
@ NUMBERFORMAT_OP_GT
Definition: zformat.hxx:46
@ NUMBERFORMAT_OP_LE
Definition: zformat.hxx:45
@ NUMBERFORMAT_OP_EQ
Definition: zformat.hxx:42
@ NUMBERFORMAT_OP_NE
Definition: zformat.hxx:43