LCOV - code coverage report
Current view: top level - i18npool/source/localedata - LocaleNode.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 45 45 100.0 %
Date: 2014-11-03 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(void) const;
      65             :     /// Return the locale string, something like en_US or de_DE
      66        1113 :     const char * getLocale() const { return theLocale; }
      67             : private:
      68             :     char m_pcFile[1024];
      69             :     char theLocale[50];
      70             :     FILE *m_f;
      71             : };
      72             : 
      73       50200 : class Attr {
      74             :     Sequence <OUString> name;
      75             :     Sequence <OUString> value;
      76             : 
      77             : public:
      78             :     Attr (const Reference< XAttributeList > & attr);
      79             :     const OUString& getValueByName (const sal_Char *str) const;
      80             :     sal_Int32 getLength() const;
      81             :     const OUString& getTypeByIndex (sal_Int32 idx) const;
      82             :     const OUString& getValueByIndex (sal_Int32 idx) const ;
      83             : };
      84             : 
      85             : class LocaleNode
      86             : {
      87             :     OUString aName;
      88             :     OUString aValue;
      89             :     Attr aAttribs;
      90             :     LocaleNode * parent;
      91             :     LocaleNode* * children;
      92             :     sal_Int32 nChildren;
      93             :     sal_Int32 childArrSize;
      94             : 
      95             :     void setParent ( LocaleNode*  node);
      96             : 
      97             : protected:
      98             :     mutable int nError;
      99             : 
     100             : public:
     101             :     LocaleNode (const OUString& name, const Reference< XAttributeList > & attr);
     102      163078 :     inline void setValue(const OUString &oValue) { aValue += oValue; };
     103       18477 :     inline const OUString& getName() const { return aName; };
     104       47608 :     inline const OUString& getValue() const { return aValue; };
     105       17156 :     inline const Attr& getAttr() const { return aAttribs; };
     106       20658 :     inline sal_Int32 getNumberOfChildren () const { return nChildren; };
     107       52782 :     inline  LocaleNode * getChildAt (sal_Int32 idx) const { return children[idx] ; };
     108             :     const LocaleNode * findNode ( const sal_Char *name) const;
     109             :     void print () const;
     110             :     void printR () const;
     111             :     virtual ~LocaleNode();
     112             :     void addChild (  LocaleNode * node);
     113         948 :     const LocaleNode* getParent() const { return parent; };
     114             :     const LocaleNode* getRoot() const;
     115             :     int getError() const;
     116             :     virtual void generateCode (const OFileWriter &of) const;
     117             :     // MUST >= nMinLen
     118             :     // nMinLen <= 0 : no error
     119             :     // nMinLen >  0 : error if less than nMinLen characters
     120             :     // SHOULD NOT > nMaxLen
     121             :     // nMaxLen <  0 : any length
     122             :     // nMaxLen >= 0 : warning if more than nMaxLen characters
     123             :     OUString writeParameterCheckLen( const OFileWriter &of, const char* pParameterName, const LocaleNode* pNode, sal_Int32 nMinLen, sal_Int32 nMaxLen ) const;
     124             :     OUString writeParameterCheckLen( const OFileWriter &of, const char* pNodeName, const char* pParameterName, sal_Int32 nMinLen, sal_Int32 nMaxLen ) const;
     125             :     // ++nError with output to stderr
     126             :     void incError( const char* pStr ) const;
     127             :     // ++nError with output to stderr
     128             :     void incError( const OUString& rStr ) const;
     129             :     // ++nError with output to stderr, pStr should contain "%d"
     130             :     void incErrorInt( const char* pStr, int nVal ) const;
     131             :     // ++nError with output to stderr, pStr should contain "%s"
     132             :     void incErrorStr( const char* pStr, const OUString& rVal ) const;
     133             :     // ++nError with output to stderr, pStr should contain "%s %s"
     134             :     void incErrorStrStr( const char* pStr, const OUString& rVal1, const OUString& rVal2 ) const;
     135             :     static LocaleNode* createNode (const OUString& name,const Reference< XAttributeList > & attr);
     136             : };
     137             : 
     138         482 : class LCInfoNode : public LocaleNode {
     139             : public:
     140         241 :     inline LCInfoNode (const OUString& name,
     141         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     142             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     143             : };
     144             : 
     145             : 
     146         482 : class LCCTYPENode : public LocaleNode {
     147             : public:
     148         241 :     inline LCCTYPENode (const OUString& name,
     149         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     150             : 
     151             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     152             : };
     153             : 
     154         484 : class LCFormatNode : public LocaleNode {
     155             :     static sal_Int16 mnSection;
     156             :     static sal_Int16 mnFormats;
     157             : public:
     158         242 :     inline LCFormatNode (const OUString& name,
     159         242 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     160             : 
     161             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     162             : };
     163             : 
     164         482 : class LCCollationNode : public LocaleNode {
     165             : public:
     166         241 :     inline LCCollationNode (const OUString& name,
     167         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     168             : 
     169             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     170             : };
     171             : 
     172         482 : class LCIndexNode : public LocaleNode {
     173             : public:
     174         241 :     inline LCIndexNode (const OUString& name,
     175         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     176             : 
     177             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     178             : };
     179             : 
     180         482 : class LCSearchNode : public LocaleNode {
     181             : public:
     182         241 :     inline LCSearchNode (const OUString& name,
     183         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     184             : 
     185             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     186             : };
     187             : 
     188         482 : class LCCalendarNode : public LocaleNode {
     189             : public:
     190         241 :     inline LCCalendarNode (const OUString& name,
     191         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     192             : 
     193             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     194             : };
     195             : 
     196         482 : class LCCurrencyNode : public LocaleNode {
     197             : public:
     198         241 :     inline LCCurrencyNode (const OUString& name,
     199         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     200             : 
     201             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     202             : };
     203             : 
     204         482 : class LCTransliterationNode : public LocaleNode {
     205             : public:
     206         241 :     inline LCTransliterationNode (const OUString& name,
     207         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     208             : 
     209             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     210             : };
     211             : 
     212         482 : class LCMiscNode : public LocaleNode {
     213             : public:
     214         241 :     inline LCMiscNode (const OUString& name,
     215         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     216             : 
     217             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     218             : };
     219             : 
     220         482 : class LCNumberingLevelNode : public LocaleNode {
     221             : public:
     222         241 :     inline LCNumberingLevelNode (const OUString& name,
     223         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     224             : 
     225             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     226             : };
     227             : 
     228         482 : class LCOutlineNumberingLevelNode : public LocaleNode {
     229             : public:
     230         241 :     inline LCOutlineNumberingLevelNode (const OUString& name,
     231         241 :                 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
     232             : 
     233             :     virtual void generateCode (const OFileWriter &of) const SAL_OVERRIDE;
     234             : };
     235             : 
     236             : #endif
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10