1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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>
31 using namespace ::std
;
32 using namespace ::cppu
;
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star::lang
;
35 using namespace ::com::sun::star::xml::sax
;
36 using namespace ::com::sun::star::io
;
41 OFileWriter(const char *pcFile
, const char *locale
);
43 void writeStringCharacters(const OUString
& str
) const;
44 void writeAsciiString(const char *str
)const ;
45 void writeInt(sal_Int16 nb
) const;
46 void writeFunction(const char *func
, const char *count
, const char *array
) const;
47 void writeRefFunction(const char *func
, const OUString
& useLocale
) const;
48 void writeFunction(const char *func
, const char *count
, const char *array
, const char *from
, const char *to
) const;
49 void writeRefFunction(const char *func
, const OUString
& useLocale
, const char *to
) const;
50 void writeFunction2(const char *func
, const char *style
, const char* attr
, const char *array
) const;
51 void writeRefFunction2(const char *func
, const OUString
& useLocale
) const;
52 void writeFunction3(const char *func
, const char *style
, const char* levels
, const char* attr
, const char *array
) const;
53 void writeRefFunction3(const char *func
, const OUString
& useLocale
) const;
54 void writeIntParameter(const sal_Char
* pAsciiStr
, const sal_Int16 count
, sal_Int16 val
) const;
55 bool writeDefaultParameter(const sal_Char
* pAsciiStr
, const OUString
& str
, sal_Int16 count
) const;
56 void writeParameter(const sal_Char
* pAsciiStr
, const OUString
& aChars
) const;
57 void writeParameter(const sal_Char
* pAsciiStr
, const OUString
& aChars
, sal_Int16 count
) const;
58 void writeParameter(const sal_Char
* pAsciiStr
, const OUString
& aChars
, sal_Int16 count0
, sal_Int16 count1
) const;
59 void writeParameter(const sal_Char
* pTagStr
, const sal_Char
* pAsciiStr
, const OUString
& aChars
, const sal_Int16 count
) const;
60 void writeParameter(const sal_Char
* pTagStr
, const sal_Char
* pAsciiStr
, const OUString
& aChars
, sal_Int16 count0
, sal_Int16 count1
) const;
61 void closeOutput() const;
62 /// Return the locale string, something like en_US or de_DE
63 const char * getLocale() const { return theLocale
; }
70 Sequence
<OUString
> name
;
71 Sequence
<OUString
> value
;
74 explicit Attr (const Reference
< XAttributeList
> & attr
);
75 const OUString
& getValueByName (const sal_Char
*str
) const;
76 sal_Int32
getLength() const;
77 const OUString
& getTypeByIndex (sal_Int32 idx
) const;
78 const OUString
& getValueByIndex (sal_Int32 idx
) const ;
87 LocaleNode
* * children
;
89 sal_Int32 childArrSize
;
91 void setParent ( LocaleNode
* node
);
97 LocaleNode (const OUString
& name
, const Reference
< XAttributeList
> & attr
);
98 inline void setValue(const OUString
&oValue
) { aValue
+= oValue
; };
99 inline const OUString
& getName() const { return aName
; };
100 inline const OUString
& getValue() const { return aValue
; };
101 inline const Attr
& getAttr() const { return aAttribs
; };
102 inline sal_Int32
getNumberOfChildren () const { return nChildren
; };
103 inline LocaleNode
* getChildAt (sal_Int32 idx
) const { return children
[idx
] ; };
104 const LocaleNode
* findNode ( const sal_Char
*name
) const;
106 void printR () const;
107 virtual ~LocaleNode();
108 void addChild ( LocaleNode
* node
);
109 const LocaleNode
* getParent() const { return parent
; };
110 const LocaleNode
* getRoot() const;
111 int getError() const;
112 virtual void generateCode (const OFileWriter
&of
) const;
114 // nMinLen <= 0 : no error
115 // nMinLen > 0 : error if less than nMinLen characters
116 // SHOULD NOT > nMaxLen
117 // nMaxLen < 0 : any length
118 // nMaxLen >= 0 : warning if more than nMaxLen characters
119 OUString
writeParameterCheckLen( const OFileWriter
&of
, const char* pParameterName
, const LocaleNode
* pNode
, sal_Int32 nMinLen
, sal_Int32 nMaxLen
) const;
120 OUString
writeParameterCheckLen( const OFileWriter
&of
, const char* pNodeName
, const char* pParameterName
, sal_Int32 nMinLen
, sal_Int32 nMaxLen
) const;
121 // ++nError with output to stderr
122 void incError( const char* pStr
) const;
123 // ++nError with output to stderr
124 void incError( const OUString
& rStr
) const;
125 // ++nError with output to stderr, pStr should contain "%d"
126 void incErrorInt( const char* pStr
, int nVal
) const;
127 // ++nError with output to stderr, pStr should contain "%s"
128 void incErrorStr( const char* pStr
, const OUString
& rVal
) const;
129 // ++nError with output to stderr, pStr should contain "%s %s"
130 void incErrorStrStr( const char* pStr
, const OUString
& rVal1
, const OUString
& rVal2
) const;
131 static LocaleNode
* createNode (const OUString
& name
,const Reference
< XAttributeList
> & attr
);
134 class LCInfoNode
: public LocaleNode
{
136 inline LCInfoNode (const OUString
& name
,
137 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
138 virtual void generateCode (const OFileWriter
&of
) const override
;
142 class LCCTYPENode
: public LocaleNode
{
144 inline LCCTYPENode (const OUString
& name
,
145 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
147 virtual void generateCode (const OFileWriter
&of
) const override
;
150 class LCFormatNode
: public LocaleNode
{
151 static sal_Int16 mnSection
;
152 static sal_Int16 mnFormats
;
154 inline LCFormatNode (const OUString
& name
,
155 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
157 virtual void generateCode (const OFileWriter
&of
) const override
;
160 class LCCollationNode
: public LocaleNode
{
162 inline LCCollationNode (const OUString
& name
,
163 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
165 virtual void generateCode (const OFileWriter
&of
) const override
;
168 class LCIndexNode
: public LocaleNode
{
170 inline LCIndexNode (const OUString
& name
,
171 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
173 virtual void generateCode (const OFileWriter
&of
) const override
;
176 class LCSearchNode
: public LocaleNode
{
178 inline LCSearchNode (const OUString
& name
,
179 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
181 virtual void generateCode (const OFileWriter
&of
) const override
;
184 class LCCalendarNode
: public LocaleNode
{
186 inline LCCalendarNode (const OUString
& name
,
187 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
189 virtual void generateCode (const OFileWriter
&of
) const override
;
192 class LCCurrencyNode
: public LocaleNode
{
194 inline LCCurrencyNode (const OUString
& name
,
195 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
197 virtual void generateCode (const OFileWriter
&of
) const override
;
200 class LCTransliterationNode
: public LocaleNode
{
202 inline LCTransliterationNode (const OUString
& name
,
203 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
205 virtual void generateCode (const OFileWriter
&of
) const override
;
208 class LCMiscNode
: public LocaleNode
{
210 inline LCMiscNode (const OUString
& name
,
211 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
213 virtual void generateCode (const OFileWriter
&of
) const override
;
216 class LCNumberingLevelNode
: public LocaleNode
{
218 inline LCNumberingLevelNode (const OUString
& name
,
219 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
221 virtual void generateCode (const OFileWriter
&of
) const override
;
224 class LCOutlineNumberingLevelNode
: public LocaleNode
{
226 inline LCOutlineNumberingLevelNode (const OUString
& name
,
227 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
229 virtual void generateCode (const OFileWriter
&of
) const override
;
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */