LCOV - code coverage report
Current view: top level - xmloff/inc/xmloff - xmlnumfi.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 7 71.4 %
Date: 2012-08-25 Functions: 7 9 77.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _XMLOFF_XMLNUMFI_HXX
      30                 :            : #define _XMLOFF_XMLNUMFI_HXX
      31                 :            : 
      32                 :            : #include "sal/config.h"
      33                 :            : #include "xmloff/dllapi.h"
      34                 :            : #include "sal/types.h"
      35                 :            : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      36                 :            : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      37                 :            : #include <xmloff/xmlstyle.hxx>
      38                 :            : #include <rtl/ustrbuf.hxx>
      39                 :            : #include <i18npool/lang.h>
      40                 :            : #include <vector>
      41                 :            : #include <unotools/localedatawrapper.hxx>
      42                 :            : 
      43                 :            : #define XML_NUMBERSTYLES "NumberStyles"
      44                 :            : 
      45                 :            : enum SvXMLStylesTokens
      46                 :            : {
      47                 :            :     XML_TOK_STYLES_NUMBER_STYLE,
      48                 :            :     XML_TOK_STYLES_CURRENCY_STYLE,
      49                 :            :     XML_TOK_STYLES_PERCENTAGE_STYLE,
      50                 :            :     XML_TOK_STYLES_DATE_STYLE,
      51                 :            :     XML_TOK_STYLES_TIME_STYLE,
      52                 :            :     XML_TOK_STYLES_BOOLEAN_STYLE,
      53                 :            :     XML_TOK_STYLES_TEXT_STYLE
      54                 :            : };
      55                 :            : 
      56                 :            : enum SvXMLDateElementAttributes
      57                 :            : {
      58                 :            :     XML_DEA_NONE,
      59                 :            :     XML_DEA_ANY,
      60                 :            :     XML_DEA_SHORT,
      61                 :            :     XML_DEA_LONG,
      62                 :            :     XML_DEA_TEXTSHORT,
      63                 :            :     XML_DEA_TEXTLONG
      64                 :            : };
      65                 :            : 
      66                 :            : class Color;
      67                 :            : class SvXMLNumImpData;
      68                 :            : class SvXMLImport;
      69                 :            : class SvXMLStyleContext;
      70                 :            : class SvXMLStylesContext;
      71                 :            : struct SvXMLNumberInfo;
      72                 :            : class SvNumberFormatter;
      73                 :            : class SvtSysLocale;
      74                 :            : 
      75                 :            : //  use SvXMLNumFmtHelper in the context for <office:styles> to create
      76                 :            : //  child contexts for data styles
      77                 :            : 
      78                 :            : class SvXMLNumFmtHelper
      79                 :            : {
      80                 :            :     SvXMLNumImpData* pData;
      81                 :            : 
      82                 :            :     // #110680#
      83                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxServiceFactory;
      84                 :            : 
      85                 :            : public:
      86                 :            :     // #110680#
      87                 :            :     //SvXMLNumFmtHelper( const ::com::sun::star::uno::Reference<
      88                 :            :     //      ::com::sun::star::util::XNumberFormatsSupplier >& rSupp );
      89                 :            :     //SvXMLNumFmtHelper( SvNumberFormatter* pNumberFormatter );
      90                 :            :     SvXMLNumFmtHelper(
      91                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& rSupp,
      92                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory );
      93                 :            : 
      94                 :            :     SvXMLNumFmtHelper(
      95                 :            :         SvNumberFormatter* pNumberFormatter,
      96                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory );
      97                 :            : 
      98                 :            :     ~SvXMLNumFmtHelper();
      99                 :            : 
     100                 :            :     SvXMLStyleContext*  CreateChildContext( SvXMLImport& rImport,
     101                 :            :                 sal_uInt16 nPrefix, const rtl::OUString& rLocalName,
     102                 :            :                 const ::com::sun::star::uno::Reference<
     103                 :            :                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     104                 :            :                     SvXMLStylesContext& rStyles);
     105                 :            : 
     106                 :          0 :     SvXMLNumImpData* getData() { return pData; }
     107                 :            : 
     108                 :            :     const SvXMLTokenMap&    GetStylesElemTokenMap();
     109                 :            : 
     110                 :            : //  sal_uInt32  GetKeyForName( const rtl::OUString& rName );
     111                 :            : };
     112                 :            : 
     113                 :            : //  SvXMLNumFmtDefaults is used in import and export
     114                 :            : 
     115                 :            : class SvXMLNumFmtDefaults
     116                 :            : {
     117                 :            : public:
     118                 :            :     // return value is NfIndexTableOffset
     119                 :            :     static sal_uInt16 GetDefaultDateFormat( SvXMLDateElementAttributes eDOW,
     120                 :            :                 SvXMLDateElementAttributes eDay, SvXMLDateElementAttributes eMonth,
     121                 :            :                 SvXMLDateElementAttributes eYear, SvXMLDateElementAttributes eHours,
     122                 :            :                 SvXMLDateElementAttributes eMins, SvXMLDateElementAttributes eSecs,
     123                 :            :                 sal_Bool bSystem );
     124                 :            : };
     125                 :            : 
     126                 :       1184 : struct MyCondition
     127                 :            : {
     128                 :            :     rtl::OUString   sCondition;
     129                 :            :     rtl::OUString   sMapName;
     130                 :            : };
     131                 :            : 
     132                 :            : class XMLOFF_DLLPUBLIC SvXMLNumFormatContext : public SvXMLStyleContext
     133                 :            : {
     134                 :            :     SvXMLNumImpData*    pData;
     135                 :            :     SvXMLStylesContext*             pStyles;
     136                 :            :     std::vector <MyCondition>   aMyConditions;
     137                 :            :     sal_uInt16          nType;
     138                 :            :     sal_Int32           nKey;
     139                 :            : //  rtl::OUString       sFormatName;
     140                 :            :     rtl::OUString       sFormatTitle;
     141                 :            : //  rtl::OUString       sMapName;
     142                 :            :     rtl::OUString       sCalendar;
     143                 :            :     rtl::OUString       sFormatString;
     144                 :            :     LanguageType        nFormatLang;
     145                 :            :     com::sun::star::lang::Locale    aLocale;
     146                 :            :     sal_Bool            bAutoOrder;
     147                 :            :     sal_Bool            bFromSystem;
     148                 :            :     sal_Bool            bTruncate;
     149                 :            :     sal_Bool            bAutoDec;       // set in AddNumber
     150                 :            :     sal_Bool            bAutoInt;       // set in AddNumber
     151                 :            :     sal_Bool            bHasExtraText;
     152                 :            :     rtl::OUStringBuffer aFormatCode;
     153                 :            :     rtl::OUStringBuffer aConditions;
     154                 :            :     sal_Bool            bHasLongDoW;
     155                 :            :     sal_Bool            bHasEra;
     156                 :            :     sal_Bool            bHasDateTime;
     157                 :            :     sal_Bool            bRemoveAfterUse;
     158                 :            : 
     159                 :            :     //  contained date elements, used to recognize default date formats
     160                 :            :     SvXMLDateElementAttributes  eDateDOW;
     161                 :            :     SvXMLDateElementAttributes  eDateDay;
     162                 :            :     SvXMLDateElementAttributes  eDateMonth;
     163                 :            :     SvXMLDateElementAttributes  eDateYear;
     164                 :            :     SvXMLDateElementAttributes  eDateHours;
     165                 :            :     SvXMLDateElementAttributes  eDateMins;
     166                 :            :     SvXMLDateElementAttributes  eDateSecs;
     167                 :            :     sal_Bool                    bDateNoDefault;
     168                 :            : 
     169                 :            :     SAL_DLLPRIVATE sal_Int32 PrivateGetKey();
     170                 :            : 
     171                 :            : public:
     172                 :            :                 SvXMLNumFormatContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     173                 :            :                                     const rtl::OUString& rLName,
     174                 :            :                                     SvXMLNumImpData* pNewData, sal_uInt16 nNewType,
     175                 :            :                                     const ::com::sun::star::uno::Reference<
     176                 :            :                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     177                 :            :                                     SvXMLStylesContext& rStyles );
     178                 :            :                 SvXMLNumFormatContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     179                 :            :                                     const rtl::OUString& rLName,
     180                 :            :                                     const ::com::sun::star::uno::Reference<
     181                 :            :                                         ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     182                 :            :                                     const sal_Int32 nKey,
     183                 :            :                                     SvXMLStylesContext& rStyles );
     184                 :            :     virtual     ~SvXMLNumFormatContext();
     185                 :            : 
     186                 :            :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
     187                 :            :                                     const rtl::OUString& rLocalName,
     188                 :            :                                     const ::com::sun::star::uno::Reference<
     189                 :            :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
     190                 :            :     virtual void CreateAndInsert(sal_Bool bOverwrite);
     191                 :            :     virtual void Finish(sal_Bool bOverwrite);
     192                 :            : 
     193                 :       2124 :     SvXMLNumImpData* GetData() const                { return pData; }
     194                 :            :     sal_Int32 GetKey();
     195                 :            :     sal_Int32 CreateAndInsert( SvNumberFormatter* pFormatter );
     196                 :            :     sal_Int32 CreateAndInsert( com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >& xFormatsSupplier );
     197                 :        795 :     sal_uInt16 GetType() const                      { return nType; }   // SvXMLStylesTokens
     198                 :            : 
     199                 :            :     sal_Bool IsFromSystem() const                   { return bFromSystem; }
     200                 :        732 :     sal_Bool HasLongDoW() const                     { return bHasLongDoW; }
     201                 :          0 :     void SetHasLongDoW(sal_Bool bSet)               { bHasLongDoW = bSet; }
     202                 :         37 :     sal_Bool HasEra() const                         { return bHasEra; }
     203                 :            :     void SetHasEra(sal_Bool bSet)                   { bHasEra = bSet; }
     204                 :            : 
     205                 :            :     void UpdateCalendar( const rtl::OUString& rNewCalendar );
     206                 :            : 
     207                 :            :     const LocaleDataWrapper& GetLocaleData() const;
     208                 :            : 
     209                 :            :     void AddToCode( const rtl::OUString& rString );
     210                 :            :     void AddNumber( const SvXMLNumberInfo& rInfo );
     211                 :            :     void AddCurrency( const rtl::OUString& rContent, LanguageType nLang );
     212                 :            : 
     213                 :            :     void AddNfKeyword( sal_uInt16 nIndex );
     214                 :            :     sal_Bool ReplaceNfKeyword( sal_uInt16 nOld, sal_uInt16 nNew );
     215                 :            :     void AddCondition( const sal_Int32 nIndex );
     216                 :            :     void AddCondition( const rtl::OUString& rCondition, const rtl::OUString& rApplyName );
     217                 :            :     void AddColor( sal_uInt32 const nColor );
     218                 :            : 
     219                 :            :     /// determine whether number format uses the system language
     220                 :            :     sal_Bool IsSystemLanguage();
     221                 :            : };
     222                 :            : 
     223                 :            : #endif
     224                 :            : 
     225                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10