LCOV - code coverage report
Current view: top level - i18npool/source/localedata - LocaleNode.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 45 45 100.0 %
Date: 2015-06-13 12:38:46 Functions: 45 45 100.0 %
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             :  * 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_I18NPOOL_SOURCE_LOCALEDATA_LOCALENODE_HXX
      20             : #define INCLUDED_I18NPOOL_SOURCE_LOCALEDATA_LOCALENODE_HXX
      21             : #include <com/sun/star/xml/sax/XParser.hpp>
      22             : #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
      23             : 
      24             : #include <vector>
      25             : 
      26             : #include <com/sun/star/lang/XComponent.hpp>
      27             : #include <com/sun/star/xml/sax/SAXParseException.hpp>
      28             : #include <com/sun/star/io/XOutputStream.hpp>
      29             : #include <com/sun/star/io/XActiveDataSource.hpp>
      30             : 
      31             : #include <cppuhelper/implbase1.hxx>
      32             : #include <cppuhelper/implbase3.hxx>
      33             : 
      34             : using namespace ::std;
      35             : using namespace ::cppu;
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::lang;
      38             : using namespace ::com::sun::star::xml::sax;
      39             : using namespace ::com::sun::star::io;
      40             : 
      41             : class OFileWriter
      42             : {
      43             : public:
      44             :     OFileWriter(const char *pcFile, const char *locale );
      45             :     ~OFileWriter();
      46             :     void  writeStringCharacters(const OUString& str) const;
      47             :     void  writeAsciiString(const char *str)const ;
      48             :     void  writeInt(sal_Int16 nb) const;
      49             :     void  writeFunction(const char *func, const char *count, const char *array) const;
      50             :     void  writeRefFunction(const char *func, const OUString& useLocale) const;
      51             :     void  writeFunction(const char *func, const char *count, const char *array, const char *from, const char *to) const;
      52             :     void  writeRefFunction(const char *func, const OUString& useLocale, const char *to) const;
      53             :     void  writeFunction2(const char *func, const char *style, const char* attr, const char *array) const;
      54             :     void  writeRefFunction2(const char *func, const OUString& useLocale) const;
      55             :     void  writeFunction3(const char *func, const char *style, const char* levels, const char* attr, const char *array) const;
      56             :     void  writeRefFunction3(const char *func, const OUString& useLocale) const;
      57             :     void  writeIntParameter(const sal_Char* pAsciiStr, const sal_Int16 count, sal_Int16 val) const;
      58             :     bool  writeDefaultParameter(const sal_Char* pAsciiStr, const OUString& str, sal_Int16 count) const;
      59             :     void  writeParameter(const sal_Char* pAsciiStr, const OUString& aChars) const;
      60             :     void  writeParameter(const sal_Char* pAsciiStr, const OUString& aChars, sal_Int16 count) const;
      61             :     void  writeParameter(const sal_Char* pAsciiStr, const OUString& aChars, sal_Int16 count0, sal_Int16 count1) const;
      62             :     void  writeParameter(const sal_Char* pTagStr, const sal_Char* pAsciiStr, const OUString& aChars, const sal_Int16 count) const;
      63             :     void  writeParameter(const sal_Char* pTagStr, const sal_Char* pAsciiStr, const OUString& aChars, sal_Int16 count0, sal_Int16 count1) const;
      64             :     void  closeOutput() const;
      65             :     /// Return the locale string, something like en_US or de_DE
      66        1135 :     const char * getLocale() const { return theLocale; }
      67             : private:
      68             :     char theLocale[50];
      69             :     FILE *m_f;
      70             : };
      71             : 
      72       51550 : class Attr {
      73             :     Sequence <OUString> name;
      74             :     Sequence <OUString> value;
      75             : 
      76             : public:
      77             :     Attr (const Reference< XAttributeList > & attr);
      78             :     const OUString& getValueByName (const sal_Char *str) const;
      79             :     sal_Int32 getLength() const;
      80             :     const OUString& getTypeByIndex (sal_Int32 idx) const;
      81             :     const OUString& getValueByIndex (sal_Int32 idx) const ;
      82             : };
      83             : 
      84             : class LocaleNode
      85             : {
      86             :     OUString aName;
      87             :     OUString aValue;
      88             :     Attr aAttribs;
      89             :     LocaleNode * parent;
      90             :     LocaleNode* * children;
      91             :     sal_Int32 nChildren;
      92             :     sal_Int32 childArrSize;
      93             : 
      94             :     void setParent ( LocaleNode*  node);
      95             : 
      96             : protected:
      97             :     mutable int nError;
      98             : 
      99             : public:
     100             :     LocaleNode (const OUString& name, const Reference< XAttributeList > & attr);
     101      167581 :     inline void setValue(const OUString &oValue) { aValue += oValue; };
     102       19176 :     inline const OUString& getName() const { return aName; };
     103       49210 :     inline const OUString& getValue() const { return aValue; };
     104       17639 :     inline const Attr& getAttr() const { return aAttribs; };
     105       21239 :     inline sal_Int32 getNumberOfChildren () const { return nChildren; };
     106       53987 :     inline  LocaleNode * getChildAt (sal_Int32 idx) const { return children[idx] ; };
     107             :     const LocaleNode * findNode ( const sal_Char *name) const;
     108             :     void print () const;
     109             :     void printR () const;
     110             :     virtual ~LocaleNode();
     111             :     void addChild (  LocaleNode * node);
     112         966 :     const LocaleNode* getParent() const { return parent; };
     113             :     const LocaleNode* getRoot() const;
     114             :     int getError() const;
     115             :     virtual void generateCode (const OFileWriter &of) const;
     116             :     // MUST >= nMinLen
     117             :     // nMinLen <= 0 : no error
     118             :     // nMinLen >  0 : error if less than nMinLen characters
     119             :     // SHOULD NOT > nMaxLen
     120             :     // nMaxLen <  0 : any length
     121             :     // nMaxLen >= 0 : warning if more than nMaxLen characters
     122             :     OUString writeParameterCheckLen( const OFileWriter &of, const char* pParameterName, const LocaleNode* pNode, sal_Int32 nMinLen, sal_Int32 nMaxLen ) const;
     123             :     OUString writeParameterCheckLen( const OFileWriter &of, const char* pNodeName, const char* pParameterName, sal_Int32 nMinLen, sal_Int32 nMaxLen ) const;
     124             :     // ++nError with output to stderr
     125             :     void incError( const char* pStr ) const;
     126             :     // ++nError with output to stderr
     127             :     void incError( const OUString& rStr ) const;
     128             :     // ++nError with output to stderr, pStr should contain "%d"
     129             :     void incErrorInt( const char* pStr, int nVal ) const;
     130             :     // ++nError with output to stderr, pStr should contain "%s"
     131             :     void incErrorStr( const char* pStr, const OUString& rVal ) const;
     132             :     // ++nError with output to stderr, pStr should contain "%s %s"
     133             :     void incErrorStrStr( const char* pStr, const OUString& rVal1, const OUString& rVal2 ) const;
     134             :     static LocaleNode* createNode (const OUString& name,const Reference< XAttributeList > & attr);
     135             : };
     136             : 
     137         490 : class LCInfoNode : public LocaleNode {
     138             : public:
     139         245 :     inline LCInfoNode (const OUString& name,
     140         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     141             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     142             : };
     143             : 
     144             : 
     145         490 : class LCCTYPENode : public LocaleNode {
     146             : public:
     147         245 :     inline LCCTYPENode (const OUString& name,
     148         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     149             : 
     150             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     151             : };
     152             : 
     153         492 : class LCFormatNode : public LocaleNode {
     154             :     static sal_Int16 mnSection;
     155             :     static sal_Int16 mnFormats;
     156             : public:
     157         246 :     inline LCFormatNode (const OUString& name,
     158         246 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     159             : 
     160             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     161             : };
     162             : 
     163         490 : class LCCollationNode : public LocaleNode {
     164             : public:
     165         245 :     inline LCCollationNode (const OUString& name,
     166         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     167             : 
     168             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     169             : };
     170             : 
     171         490 : class LCIndexNode : public LocaleNode {
     172             : public:
     173         245 :     inline LCIndexNode (const OUString& name,
     174         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     175             : 
     176             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     177             : };
     178             : 
     179         490 : class LCSearchNode : public LocaleNode {
     180             : public:
     181         245 :     inline LCSearchNode (const OUString& name,
     182         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     183             : 
     184             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     185             : };
     186             : 
     187         490 : class LCCalendarNode : public LocaleNode {
     188             : public:
     189         245 :     inline LCCalendarNode (const OUString& name,
     190         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     191             : 
     192             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     193             : };
     194             : 
     195         490 : class LCCurrencyNode : public LocaleNode {
     196             : public:
     197         245 :     inline LCCurrencyNode (const OUString& name,
     198         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     199             : 
     200             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     201             : };
     202             : 
     203         490 : class LCTransliterationNode : public LocaleNode {
     204             : public:
     205         245 :     inline LCTransliterationNode (const OUString& name,
     206         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     207             : 
     208             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     209             : };
     210             : 
     211         490 : class LCMiscNode : public LocaleNode {
     212             : public:
     213         245 :     inline LCMiscNode (const OUString& name,
     214         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     215             : 
     216             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     217             : };
     218             : 
     219         490 : class LCNumberingLevelNode : public LocaleNode {
     220             : public:
     221         245 :     inline LCNumberingLevelNode (const OUString& name,
     222         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     223             : 
     224             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     225             : };
     226             : 
     227         490 : class LCOutlineNumberingLevelNode : public LocaleNode {
     228             : public:
     229         245 :     inline LCOutlineNumberingLevelNode (const OUString& name,
     230         245 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     231             : 
     232             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     233             : };
     234             : 
     235             : #endif
     236             : 
     237             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11