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
26 #include <com/sun/star/uno/Sequence.hxx>
28 namespace com::sun::star::xml::sax
{ class XAttributeList
; }
30 using namespace ::std
;
31 using namespace ::cppu
;
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::xml::sax
;
38 OFileWriter(const char *pcFile
, const char *locale
);
40 void writeStringCharacters(const OUString
& str
) const;
41 void writeAsciiString(const char *str
)const ;
42 void writeInt(sal_Int16 nb
) const;
43 void writeFunction(const char *func
, const char *count
, const char *array
) const;
44 void writeRefFunction(const char *func
, const OUString
& useLocale
) const;
45 void writeFunction(const char *func
, const char *count
, const char *array
, const char *from
, const char *to
) const;
46 void writeRefFunction(const char *func
, const OUString
& useLocale
, const char *to
) const;
47 void writeFunction2(const char *func
, const char *style
, const char* attr
, const char *array
) const;
48 void writeRefFunction2(const char *func
, const OUString
& useLocale
) const;
49 void writeFunction3(const char *func
, const char *style
, const char* levels
, const char* attr
, const char *array
) const;
50 void writeRefFunction3(const char *func
, const OUString
& useLocale
) const;
51 void writeIntParameter(const sal_Char
* pAsciiStr
, const sal_Int16 count
, sal_Int16 val
) const;
52 bool writeDefaultParameter(const sal_Char
* pAsciiStr
, const OUString
& str
, sal_Int16 count
) const;
53 void writeParameter(const sal_Char
* pAsciiStr
, const OUString
& aChars
) const;
54 void writeParameter(const sal_Char
* pAsciiStr
, const OUString
& aChars
, sal_Int16 count
) const;
55 void writeParameter(const sal_Char
* pAsciiStr
, const OUString
& aChars
, sal_Int16 count0
, sal_Int16 count1
) const;
56 void writeParameter(const sal_Char
* pTagStr
, const sal_Char
* pAsciiStr
, const OUString
& aChars
, const sal_Int16 count
) const;
57 void writeParameter(const sal_Char
* pTagStr
, const sal_Char
* pAsciiStr
, const OUString
& aChars
, sal_Int16 count0
, sal_Int16 count1
) const;
58 void closeOutput() const;
59 /// Return the locale string, something like en_US or de_DE
60 const char * getLocale() const { return theLocale
.c_str(); }
62 std::string theLocale
;
67 Sequence
<OUString
> name
;
68 Sequence
<OUString
> value
;
71 explicit Attr (const Reference
< XAttributeList
> & attr
);
72 OUString
getValueByName (const sal_Char
*str
) const;
73 const OUString
& getValueByIndex (sal_Int32 idx
) const ;
82 std::vector
<std::unique_ptr
<LocaleNode
>> children
;
88 LocaleNode (const OUString
& name
, const Reference
< XAttributeList
> & attr
);
89 void setValue(const OUString
&oValue
) { aValue
+= oValue
; };
90 const OUString
& getName() const { return aName
; };
91 const OUString
& getValue() const { return aValue
; };
92 const Attr
& getAttr() const { return aAttribs
; };
93 sal_Int32
getNumberOfChildren () const { return sal_Int32(children
.size()); };
94 LocaleNode
* getChildAt (sal_Int32 idx
) const { return children
[idx
].get(); };
95 const LocaleNode
* findNode ( const sal_Char
*name
) const;
96 virtual ~LocaleNode();
97 void addChild ( LocaleNode
* node
);
98 const LocaleNode
* getRoot() const;
100 virtual void generateCode (const OFileWriter
&of
) const;
102 // nMinLen <= 0 : no error
103 // nMinLen > 0 : error if less than nMinLen characters
104 // SHOULD NOT > nMaxLen
105 // nMaxLen < 0 : any length
106 // nMaxLen >= 0 : warning if more than nMaxLen characters
107 OUString
writeParameterCheckLen( const OFileWriter
&of
, const char* pParameterName
, const LocaleNode
* pNode
, sal_Int32 nMinLen
, sal_Int32 nMaxLen
) const;
108 OUString
writeParameterCheckLen( const OFileWriter
&of
, const char* pNodeName
, const char* pParameterName
, sal_Int32 nMinLen
, sal_Int32 nMaxLen
) const;
109 // ++nError with output to stderr
110 void incError( const char* pStr
) const;
111 // ++nError with output to stderr
112 void incError( const OUString
& rStr
) const;
113 // ++nError with output to stderr, pStr should contain "%d"
114 void incErrorInt( const char* pStr
, int nVal
) const;
115 // ++nError with output to stderr, pStr should contain "%s"
116 void incErrorStr( const char* pStr
, const OUString
& rVal
) const;
117 // ++nError with output to stderr, pStr should contain "%s %s"
118 void incErrorStrStr( const char* pStr
, const OUString
& rVal1
, const OUString
& rVal2
) const;
119 static LocaleNode
* createNode (const OUString
& name
,const Reference
< XAttributeList
> & attr
);
122 class LCInfoNode
: public LocaleNode
{
124 LCInfoNode (const OUString
& name
,
125 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
126 virtual void generateCode (const OFileWriter
&of
) const override
;
130 class LCCTYPENode
: public LocaleNode
{
132 LCCTYPENode (const OUString
& name
,
133 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
135 virtual void generateCode (const OFileWriter
&of
) const override
;
138 class LCFormatNode
: public LocaleNode
{
139 static sal_Int16 mnSection
;
140 static sal_Int16 mnFormats
;
142 LCFormatNode (const OUString
& name
,
143 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
145 virtual void generateCode (const OFileWriter
&of
) const override
;
148 class LCCollationNode
: public LocaleNode
{
150 LCCollationNode (const OUString
& name
,
151 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
153 virtual void generateCode (const OFileWriter
&of
) const override
;
156 class LCIndexNode
: public LocaleNode
{
158 LCIndexNode (const OUString
& name
,
159 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
161 virtual void generateCode (const OFileWriter
&of
) const override
;
164 class LCSearchNode
: public LocaleNode
{
166 LCSearchNode (const OUString
& name
,
167 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
169 virtual void generateCode (const OFileWriter
&of
) const override
;
172 class LCCalendarNode
: public LocaleNode
{
174 LCCalendarNode (const OUString
& name
,
175 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
177 virtual void generateCode (const OFileWriter
&of
) const override
;
180 class LCCurrencyNode
: public LocaleNode
{
182 LCCurrencyNode (const OUString
& name
,
183 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
185 virtual void generateCode (const OFileWriter
&of
) const override
;
188 class LCTransliterationNode
: public LocaleNode
{
190 LCTransliterationNode (const OUString
& name
,
191 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
193 virtual void generateCode (const OFileWriter
&of
) const override
;
196 class LCMiscNode
: public LocaleNode
{
198 LCMiscNode (const OUString
& name
,
199 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
201 virtual void generateCode (const OFileWriter
&of
) const override
;
204 class LCNumberingLevelNode
: public LocaleNode
{
206 LCNumberingLevelNode (const OUString
& name
,
207 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
209 virtual void generateCode (const OFileWriter
&of
) const override
;
212 class LCOutlineNumberingLevelNode
: public LocaleNode
{
214 LCOutlineNumberingLevelNode (const OUString
& name
,
215 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
217 virtual void generateCode (const OFileWriter
&of
) const override
;
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */