LibreOffice Module i18npool (master) 1
LocaleNode.hxx
Go to the documentation of this file.
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
22#include <string>
23#include <string_view>
24#include <vector>
25#include <memory>
26
27#include <com/sun/star/uno/Sequence.hxx>
28
29namespace com::sun::star::xml::sax { class XAttributeList; }
30
31using namespace ::cppu;
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::xml::sax;
34
36{
37public:
38 OFileWriter(const char *pcFile, const char *locale );
40 void writeStringCharacters(std::u16string_view 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, std::u16string_view 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, std::u16string_view 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, std::u16string_view 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, std::u16string_view useLocale) const;
51 void writeIntParameter(const char* pAsciiStr, const sal_Int16 count, sal_Int16 val) const;
52 bool writeDefaultParameter(const char* pAsciiStr, std::u16string_view str, sal_Int16 count) const;
53 void writeParameter(const char* pAsciiStr, std::u16string_view aChars) const;
54 void writeParameter(const char* pAsciiStr, std::u16string_view aChars, sal_Int16 count) const;
55 void writeParameter(const char* pAsciiStr, std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) const;
56 void writeParameter(const char* pTagStr, const char* pAsciiStr, std::u16string_view aChars, const sal_Int16 count) const;
57 void writeParameter(const char* pTagStr, const char* pAsciiStr, std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) const;
58 void closeOutput() const;
60 const char * getLocale() const { return theLocale.c_str(); }
61private:
62 std::string theLocale;
64};
65
66class Attr {
67 Sequence <OUString> name;
68 Sequence <OUString> value;
69
70public:
71 explicit Attr (const Reference< XAttributeList > & attr);
72 OUString getValueByName (const char *str) const;
73 const OUString& getValueByIndex (sal_Int32 idx) const ;
74};
75
77{
78 OUString aName;
79 OUString aValue;
82 std::vector<std::unique_ptr<LocaleNode>> children;
83
84protected:
85 mutable int nError;
86
87public:
88 LocaleNode (OUString name, const Reference< XAttributeList > & attr);
89 void setValue(std::u16string_view 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 char *name) const;
96 virtual ~LocaleNode();
97 void addChild ( LocaleNode * node);
98 const LocaleNode* getRoot() const;
99 int getError() const;
100 virtual void generateCode (const OFileWriter &of) const;
101 // MUST >= nMinLen
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( std::u16string_view 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, std::u16string_view rVal ) const;
117 // ++nError with output to stderr, pStr should contain "%s %s"
118 void incErrorStrStr( const char* pStr, std::u16string_view rVal1, std::u16string_view rVal2 )
119 const;
120 static LocaleNode* createNode (const OUString& name,const Reference< XAttributeList > & attr);
121};
122
123class LCInfoNode : public LocaleNode {
124public:
125 LCInfoNode (const OUString& name,
126 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
127 virtual void generateCode (const OFileWriter &of) const override;
128};
129
130
131class LCCTYPENode : public LocaleNode {
132public:
133 LCCTYPENode (const OUString& name,
134 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
135
136 virtual void generateCode (const OFileWriter &of) const override;
137};
138
139class LCFormatNode : public LocaleNode {
140 static sal_Int16 mnSection;
141 static sal_Int16 mnFormats;
142public:
143 LCFormatNode (const OUString& name,
144 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
145
146 virtual void generateCode (const OFileWriter &of) const override;
147};
148
150public:
151 LCCollationNode (const OUString& name,
152 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
153
154 virtual void generateCode (const OFileWriter &of) const override;
155};
156
157class LCIndexNode : public LocaleNode {
158public:
159 LCIndexNode (const OUString& name,
160 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
161
162 virtual void generateCode (const OFileWriter &of) const override;
163};
164
165class LCSearchNode : public LocaleNode {
166public:
167 LCSearchNode (const OUString& name,
168 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
169
170 virtual void generateCode (const OFileWriter &of) const override;
171};
172
174public:
175 LCCalendarNode (const OUString& name,
176 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
177
178 virtual void generateCode (const OFileWriter &of) const override;
179
180 bool expectedCalendarElement( std::u16string_view rName,
181 const LocaleNode* pNode, sal_Int16 nChild, std::u16string_view rCalendarID ) const;
182};
183
185public:
186 LCCurrencyNode (const OUString& name,
187 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
188
189 virtual void generateCode (const OFileWriter &of) const override;
190};
191
193public:
194 LCTransliterationNode (const OUString& name,
195 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
196
197 virtual void generateCode (const OFileWriter &of) const override;
198};
199
200class LCMiscNode : public LocaleNode {
201public:
202 LCMiscNode (const OUString& name,
203 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
204
205 virtual void generateCode (const OFileWriter &of) const override;
206};
207
209public:
210 LCNumberingLevelNode (const OUString& name,
211 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
212
213 virtual void generateCode (const OFileWriter &of) const override;
214};
215
217public:
218 LCOutlineNumberingLevelNode (const OUString& name,
219 const Reference< XAttributeList > & attr) : LocaleNode (name, attr) { ; };
220
221 virtual void generateCode (const OFileWriter &of) const override;
222};
223
224#endif
225
226/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
UBlockCode from
UBlockCode to
Sequence< OUString > name
Definition: LocaleNode.hxx:67
const OUString & getValueByIndex(sal_Int32 idx) const
OUString getValueByName(const char *str) const
Sequence< OUString > value
Definition: LocaleNode.hxx:68
Attr(const Reference< XAttributeList > &attr)
LCCTYPENode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:133
virtual void generateCode(const OFileWriter &of) const override
Definition: LocaleNode.cxx:285
bool expectedCalendarElement(std::u16string_view rName, const LocaleNode *pNode, sal_Int16 nChild, std::u16string_view rCalendarID) const
virtual void generateCode(const OFileWriter &of) const override
LCCalendarNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:175
LCCollationNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:151
virtual void generateCode(const OFileWriter &of) const override
LCCurrencyNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:186
virtual void generateCode(const OFileWriter &of) const override
virtual void generateCode(const OFileWriter &of) const override
Definition: LocaleNode.cxx:518
LCFormatNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:143
static sal_Int16 mnFormats
Definition: LocaleNode.hxx:141
static sal_Int16 mnSection
Definition: LocaleNode.hxx:140
virtual void generateCode(const OFileWriter &of) const override
LCIndexNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:159
virtual void generateCode(const OFileWriter &of) const override
Definition: LocaleNode.cxx:230
LCInfoNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:125
virtual void generateCode(const OFileWriter &of) const override
LCMiscNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:202
LCNumberingLevelNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:210
virtual void generateCode(const OFileWriter &of) const override
virtual void generateCode(const OFileWriter &of) const override
LCOutlineNumberingLevelNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:218
virtual void generateCode(const OFileWriter &of) const override
LCSearchNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:167
virtual void generateCode(const OFileWriter &of) const override
LCTransliterationNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.hxx:194
void incErrorStrStr(const char *pStr, std::u16string_view rVal1, std::u16string_view rVal2) const
Definition: LocaleNode.cxx:224
void addChild(LocaleNode *node)
Definition: LocaleNode.cxx:62
const OUString & getName() const
Definition: LocaleNode.hxx:90
void incErrorInt(const char *pStr, int nVal) const
Definition: LocaleNode.cxx:212
const OUString & getValue() const
Definition: LocaleNode.hxx:91
sal_Int32 getNumberOfChildren() const
Definition: LocaleNode.hxx:93
const LocaleNode * getRoot() const
Definition: LocaleNode.cxx:67
static LocaleNode * createNode(const OUString &name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.cxx:92
int getError() const
Definition: LocaleNode.cxx:54
const Attr & getAttr() const
Definition: LocaleNode.hxx:92
virtual ~LocaleNode()
Definition: LocaleNode.cxx:88
const LocaleNode * findNode(const char *name) const
Definition: LocaleNode.cxx:76
void setValue(std::u16string_view oValue)
Definition: LocaleNode.hxx:89
OUString aName
Definition: LocaleNode.hxx:78
Attr aAttribs
Definition: LocaleNode.hxx:80
LocaleNode * getChildAt(sal_Int32 idx) const
Definition: LocaleNode.hxx:94
LocaleNode * parent
Definition: LocaleNode.hxx:81
void incError(const char *pStr) const
Definition: LocaleNode.cxx:201
LocaleNode(OUString name, const Reference< XAttributeList > &attr)
Definition: LocaleNode.cxx:46
virtual void generateCode(const OFileWriter &of) const
Definition: LocaleNode.cxx:130
std::vector< std::unique_ptr< LocaleNode > > children
Definition: LocaleNode.hxx:82
OUString aValue
Definition: LocaleNode.hxx:79
OUString writeParameterCheckLen(const OFileWriter &of, const char *pParameterName, const LocaleNode *pNode, sal_Int32 nMinLen, sal_Int32 nMaxLen) const
Definition: LocaleNode.cxx:144
void incErrorStr(const char *pStr, std::u16string_view rVal) const
Definition: LocaleNode.cxx:218
std::string theLocale
Definition: LocaleNode.hxx:62
FILE * m_f
Definition: LocaleNode.hxx:63
const char * getLocale() const
Return the locale string, something like en_US or de_DE.
Definition: LocaleNode.hxx:60
void writeStringCharacters(std::u16string_view str) const
Definition: filewriter.cxx:47
void writeAsciiString(const char *str) const
Definition: filewriter.cxx:42
void writeInt(sal_Int16 nb) const
Definition: filewriter.cxx:37
void writeFunction2(const char *func, const char *style, const char *attr, const char *array) const
Definition: filewriter.cxx:89
void writeParameter(const char *pAsciiStr, std::u16string_view aChars) const
Definition: filewriter.cxx:136
OFileWriter(const char *pcFile, const char *locale)
Definition: filewriter.cxx:26
void writeRefFunction2(const char *func, std::u16string_view useLocale) const
Definition: filewriter.cxx:97
void writeRefFunction3(const char *func, std::u16string_view useLocale) const
Definition: filewriter.cxx:115
void writeFunction3(const char *func, const char *style, const char *levels, const char *attr, const char *array) const
Definition: filewriter.cxx:106
bool writeDefaultParameter(const char *pAsciiStr, std::u16string_view str, sal_Int16 count) const
Definition: filewriter.cxx:129
void writeFunction(const char *func, const char *count, const char *array) const
Definition: filewriter.cxx:53
void closeOutput() const
Definition: filewriter.cxx:171
void writeIntParameter(const char *pAsciiStr, const sal_Int16 count, sal_Int16 val) const
Definition: filewriter.cxx:124
void writeRefFunction(const char *func, std::u16string_view useLocale) const
Definition: filewriter.cxx:60
const char * name
const sal_uInt16 idx[]