LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpnumericfmt.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 78 81 96.3 %
Date: 2014-11-03 Functions: 16 19 84.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  *  The Contents of this file are made available subject to the terms of
       5             :  *  either of the following licenses
       6             :  *
       7             :  *         - GNU Lesser General Public License Version 2.1
       8             :  *         - Sun Industry Standards Source License Version 1.1
       9             :  *
      10             :  *  Sun Microsystems Inc., October, 2000
      11             :  *
      12             :  *  GNU Lesser General Public License Version 2.1
      13             :  *  =============================================
      14             :  *  Copyright 2000 by Sun Microsystems, Inc.
      15             :  *  901 San Antonio Road, Palo Alto, CA 94303, USA
      16             :  *
      17             :  *  This library is free software; you can redistribute it and/or
      18             :  *  modify it under the terms of the GNU Lesser General Public
      19             :  *  License version 2.1, as published by the Free Software Foundation.
      20             :  *
      21             :  *  This library is distributed in the hope that it will be useful,
      22             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      23             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24             :  *  Lesser General Public License for more details.
      25             :  *
      26             :  *  You should have received a copy of the GNU Lesser General Public
      27             :  *  License along with this library; if not, write to the Free Software
      28             :  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      29             :  *  MA  02111-1307  USA
      30             :  *
      31             :  *
      32             :  *  Sun Industry Standards Source License Version 1.1
      33             :  *  =================================================
      34             :  *  The contents of this file are subject to the Sun Industry Standards
      35             :  *  Source License Version 1.1 (the "License"); You may not use this file
      36             :  *  except in compliance with the License. You may obtain a copy of the
      37             :  *  License at http://www.openoffice.org/license.html.
      38             :  *
      39             :  *  Software provided under this License is provided on an "AS IS" basis,
      40             :  *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
      41             :  *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
      42             :  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
      43             :  *  See the License for the specific provisions governing your rights and
      44             :  *  obligations concerning the Software.
      45             :  *
      46             :  *  The Initial Developer of the Original Code is: IBM Corporation
      47             :  *
      48             :  *  Copyright: 2008 by IBM Corporation
      49             :  *
      50             :  *  All Rights Reserved.
      51             :  *
      52             :  *  Contributor(s): _______________________________________
      53             :  *
      54             :  *
      55             :  ************************************************************************/
      56             : /**
      57             :  * @file
      58             :  *  For LWP filter architecture prototype - table object
      59             :  */
      60             : 
      61             : #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
      62             : #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPNUMERICFMT_HXX
      63             : 
      64             : #include "lwpatomholder.hxx"
      65             : #include "lwptblcell.hxx"
      66             : #include "lwpcolor.hxx"
      67             : 
      68             : //For converting to xml
      69             : #include "xfilter/xfnumberstyle.hxx"
      70             : 
      71             : class LwpObjectStream;
      72             : 
      73           0 : class LwpNumericFormatSubset
      74             : {
      75             : public:
      76             :     LwpNumericFormatSubset();
      77             :     ~LwpNumericFormatSubset();
      78             :     void QuickRead(LwpObjectStream* pStrm);
      79          48 :     OUString GetPrefix(){ return cPrefix.str();}
      80          48 :     OUString GetSuffix(){ return cSuffix.str();}
      81             :     bool IsBlack(){ return (cColor.GetBlue()==0 && cColor.GetGreen()==0 && cColor.GetRed()==0);}
      82           0 :     bool IsDefaultPrefix(){ return !(cSubFlags&SF_OVER_PREFIX); }
      83           0 :     bool IsDefaultSuffix(){ return !(cSubFlags&SF_OVER_SUFFIX); }
      84             :     LwpColor GetColor();
      85             : 
      86             : protected:
      87             :     LwpColor cColor;
      88             :     LwpAtomHolder cPrefix;
      89             :     LwpAtomHolder cSuffix;
      90             :     sal_uInt16 cSubFlags;
      91             : 
      92             :     enum // for cSubFlags
      93             :     {
      94             :         SF_OVER_PREFIX      = 0x0001,
      95             :         SF_OVER_SUFFIX      = 0x0002,
      96             :         SF_OVER_COLOR       = 0x0004
      97             :     };
      98             : };
      99             : 
     100         270 : struct LwpCurrencyInfo
     101             : {
     102             :     OUString sSymbol;
     103             :     bool bPost;
     104             :     bool bShowSpace;
     105          30 :     LwpCurrencyInfo(const OUString& sSym)
     106          30 :     {
     107          30 :         sSymbol = sSym;
     108          30 :         bPost = false;
     109          30 :         bShowSpace = false;
     110          30 :     }
     111          90 :     LwpCurrencyInfo()
     112          90 :     {
     113          90 :         bPost = false;
     114          90 :         bShowSpace = false;
     115          90 :     }
     116          60 :     LwpCurrencyInfo(const OUString& sSym, bool bPost_, bool bShowSpace_)
     117          60 :     {
     118          60 :         sSymbol = sSym;
     119          60 :         bPost = bPost_;
     120          60 :         bShowSpace = bShowSpace_;
     121          60 :     }
     122             : };
     123             : 
     124             : enum
     125             : {
     126             :     /* These are types of formats.  They are mutually exclusive.
     127             :     */
     128             :     FMT_NONE                = 0,
     129             :     FMT_ARGENTINEANPESO     = 1,
     130             :     FMT_AUSTRALIANDOLLAR    = 2,
     131             :     FMT_AUSTRIANSCHILLING   = 3,
     132             :     FMT_BELGIANFRANC        = 4,
     133             :     FMT_BRAZILIANCRUZEIRO   = 5,
     134             :     FMT_BRITISHPOUND        = 6,
     135             :     FMT_CANADIANDOLLAR      = 7,
     136             :     FMT_CHINESEYUAN         = 8,
     137             :     FMT_CZECHKORUNA         = 9,
     138             :     FMT_DANISHKRONE         = 10,
     139             :     FMT_ECU                 = 11,
     140             :     FMT_FINNISHMARKKA       = 12,
     141             :     FMT_FRENCHFRANC         = 13,
     142             :     FMT_GERMANMARK          = 14,
     143             :     FMT_GREEKDRACHMA        = 15,
     144             :     FMT_HONGKONGDOLLAR      = 16,
     145             :     FMT_HUNGARIANFORINT     = 17,
     146             :     FMT_INDIANRUPEE         = 18,
     147             :     FMT_INDONESIANRUPIAH    = 19,
     148             :     FMT_IRISHPUNT           = 20,
     149             :     FMT_ITALIANLIRA         = 21,
     150             :     FMT_JAPANESEYEN         = 22,
     151             :     FMT_LUXEMBOURGFRANC     = 23,
     152             :     FMT_MALAYSIANRINGGIT    = 24,
     153             :     FMT_MEXICANPESO         = 25,
     154             :     FMT_NETHERLANDSGUILDER  = 26,
     155             :     FMT_NEWZEALANDDOLLAR    = 27,
     156             :     FMT_NORWEGIANKRONE      = 28,
     157             :     FMT_POLISHZLOTY         = 29,
     158             :     FMT_PORTUGUESEESCUDO    = 30,
     159             :     FMT_ROMANIANLEI         = 31,
     160             :     FMT_RUSSIANRUBLE        = 32,
     161             :     FMT_SINGAPOREDOLLAR     = 33,
     162             :     FMT_SLOVAKIANKORUNA     = 34,
     163             :     FMT_SLOVENIANTHOLAR     = 35,
     164             :     FMT_SOUTHAFRICANRAND    = 36,
     165             :     FMT_SOUTHKOREANWON      = 37,
     166             :     FMT_SPANISHPESETA       = 38,
     167             :     FMT_SWEDISHKRONA        = 39,
     168             :     FMT_SWISSFRANC          = 40,
     169             :     FMT_TAIWANDOLLAR        = 41,
     170             :     FMT_THAIBAHT            = 42,
     171             :     FMT_USDOLLAR            = 43,
     172             :     FMT_OTHERCURRENCY       = 44,
     173             :     FMT_DEFAULT             = 45,
     174             :     FMT_GENERAL             = 46,
     175             :     FMT_FIXED               = 47,
     176             :     FMT_COMMA               = 48,
     177             :     FMT_PERCENT             = 49,
     178             :     FMT_SCIENTIFIC          = 50,
     179             :     FMT_LABEL               = 51,
     180             :     FMT_EURO                = 52
     181             : };
     182             : 
     183             : #define RTL_CONSTUTF8_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
     184             :     ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_UTF8
     185             : 
     186           2 : class LwpCurrencyPool
     187             : {
     188             : public:
     189           2 :     LwpCurrencyPool(){InitCurrencySymbol();}
     190             :     OUString GetCurrencySymbol(sal_uInt16 nFormat);
     191             :     bool IsShowSpace(sal_uInt16 nFormat);
     192             :     bool IsSymbolPost(sal_uInt16 nFormat);
     193             : 
     194             : private:
     195             :     std::map<sal_uInt16,LwpCurrencyInfo> m_aCurrencyInfo;
     196           2 :     void InitCurrencySymbol()
     197             :     {
     198           2 :         sal_uInt16 nC=FMT_ARGENTINEANPESO;
     199           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("A");                    //FMT_ARGENTINEANPESO       = 1,
     200           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("A$");                   //FMT_AUSTRALIANDOLLAR  = 2,
     201           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("oS",true, true);//FMT_AUSTRIANSCHILLING = 3,
     202           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("BF",true, true);//FMT_BELGIANFRANC      = 4,
     203           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R$",false, true);//FMT_BRAZILIANCRUZEIRO    = 5,
     204           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("\357\277\241")));                 //FMT_BRITISHPOUND      = 6,
     205           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("C$");                   //FMT_CANADIANDOLLAR        = 7,
     206           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("PRC\357\277\245")),false,true);   //FMT_CHINESEYUAN           = 8,
     207           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Kc",true, true);//FMT_CZECHKORUNA           = 9,
     208           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Dkr",false, true);//FMT_DANISHKRONE         = 10,
     209           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("ECU",true, true);//FMT_ECU                  = 11,
     210           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("mk",true, true);//FMT_FINNISHMARKKA     = 12,
     211           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("F",true, true);//FMT_FRENCHFRANC            = 13,
     212           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("DM",true, true);//FMT_GERMANMARK            = 14,
     213           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Dr",true, true);//FMT_GREEKDRACHMA      = 15,
     214           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("HK$");                  //FMT_HONGKONGDOLLAR        = 16,
     215           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Ft",true, true);//FMT_HUNGARIANFORINT       = 17,
     216           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rs",false, true);//FMT_INDIANRUPEE          = 18,
     217           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rp",false, true);//FMT_INDONESIANRUPIAH = 19,
     218           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("IR\357\277\241")));                   //FMT_IRISHPUNT         = 20,
     219           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("L.",false, true);//FMT_ITALIANLIRA          = 21,
     220           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("\357\277\245")));             //FMT_JAPANESEYEN           = 22,
     221           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("LF",true, true);//FMT_LUXEMBOURGFRANC       = 23,
     222           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Rm",false, true);//FMT_MALAYSIANRINGGIT = 24,
     223           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Mex$");                 //FMT_MEXICANPESO           = 25,
     224           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("F",false, true);//FMT_NETHERLANDSGUILDER    = 26,
     225           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("NZ$");                  //FMT_NEWZEALANDDOLLAR  = 27,
     226           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Nkr",false, true);//FMT_NORWEGIANKRONE      = 28,
     227           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Zl",true, true);//FMT_POLISHZLOTY           = 29,
     228           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Esc.",true, true);//FMT_PORTUGUESEESCUDO    = 30,
     229           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Leu",true, true);//FMT_ROMANIANLEI          = 31,
     230           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R",true, true);//FMT_RUSSIANRUBLE       = 32,
     231           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("S$");                   //FMT_SINGAPOREDOLLAR       = 33,
     232           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Sk",true, true);//FMT_SLOVAKIANKORUNA       = 34,
     233           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("SIT",false, true);//FMT_SLOVENIANTHOLAR     = 35,
     234           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("R");                    //FMT_SOUTHAFRICANRAND  = 36,
     235           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("W");                    //FMT_SOUTHKOREANWON        = 37,
     236           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Pts",true, true);//FMT_SPANISHPESETA        = 38,
     237           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Skr",true, true);//FMT_SWEDISHKRONA     = 39,
     238           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("SFr",false, true);//FMT_SWISSFRANC          = 40,
     239           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("NT$");                  //FMT_TAIWANDOLLAR      = 41,
     240           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("Bt",true, true);//FMT_THAIBAHT          = 42,
     241           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("$");                    //FMT_USDOLLAR          = 43,
     242           2 :         m_aCurrencyInfo[nC++]=LwpCurrencyInfo("OTH",false, true);//FMT_OTHERCURRENCY       = 44,
     243             : 
     244           2 :         m_aCurrencyInfo[FMT_EURO]=LwpCurrencyInfo(OUString(RTL_CONSTUTF8_USTRINGPARAM("\342\202\254")));             //FMT_EURO              = 52
     245           2 :     }
     246             : };
     247             : 
     248             : class LwpNumericFormat
     249             : {
     250             : public:
     251             :     LwpNumericFormat(LwpObjectStream * pStrm);
     252          12 :     ~LwpNumericFormat(){}
     253             :     void Read();
     254             :     static bool IsCurrencyFormat(sal_uInt16 Format);
     255             :     sal_uInt16 GetDecimalPlaces(void);
     256             :     bool IsDecimalPlacesOverridden(void);
     257             :     bool IsNegativeOverridden(void);
     258             :     bool IsZeroOverridden(void);
     259             :     XFStyle* Convert();
     260             : 
     261             : private:
     262             :     LwpObjectStream * m_pObjStrm;
     263             : 
     264             :     sal_uInt16 cFlags;
     265             :     enum // for cFlags
     266             :     {
     267             :         NF_OVER_ZERO            = 0x0001,
     268             :         NF_OVER_NEGATIVE        = 0x0002,
     269             :         NF_OVER_DECIMAL_PLACES  = 0x0004
     270             :     };
     271             : 
     272             :     sal_uInt16 cFormat;
     273             : 
     274             :     LwpNumericFormatSubset cAnyNumber;
     275             :     LwpNumericFormatSubset cZero;
     276             :     LwpNumericFormatSubset cNegative;
     277             : 
     278             :     sal_uInt16 cDecimalPlaces;
     279             : 
     280             :     static sal_uInt16 GetDefaultDecimalPlaces(sal_uInt16 Format);
     281             :     static LwpCurrencyPool m_aCurrencyInfo;
     282             : 
     283             :     void GetCurrencyStr(LwpNumericFormatSubset aNumber, OUString& aPrefix, OUString& aSuffix, bool bNegtive=false);
     284             :     void SetNumberType(XFNumberStyle* pStyle);
     285             :     OUString    reencode(const OUString& sCode);
     286             : };
     287             : 
     288             : inline bool
     289          48 : LwpNumericFormat::IsDecimalPlacesOverridden(void)
     290             : {
     291          48 :     return (cFlags & NF_OVER_DECIMAL_PLACES) != 0;
     292             : }
     293             : 
     294             : inline bool
     295          48 : LwpNumericFormat::IsNegativeOverridden(void)
     296             : {
     297          48 :     return (cFlags & NF_OVER_NEGATIVE) != 0;
     298             : }
     299             : 
     300             : inline bool
     301             : LwpNumericFormat::IsZeroOverridden(void)
     302             : {
     303             :     return (cFlags & NF_OVER_ZERO) != 0;
     304             : }
     305             : 
     306             : #include "lwppiece.hxx"
     307             : class LwpLayoutNumerics : public LwpVirtualPiece
     308             : {
     309             : public:
     310          12 :     LwpLayoutNumerics(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
     311          12 :     :LwpVirtualPiece(objHdr, pStrm),cNumerics(m_pObjStrm){}
     312             :     XFStyle* Convert();
     313             :     virtual void Read() SAL_OVERRIDE;
     314             : 
     315             : protected:
     316             :     LwpNumericFormat cNumerics;
     317             : 
     318             : private:
     319          24 :     virtual ~LwpLayoutNumerics(){}
     320             : };
     321             : 
     322             : #endif
     323             : 
     324             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10