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

Generated by: LCOV version 1.10