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 .
21 #include <com/sun/star/xml/sax/XParser.hpp>
22 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
26 #include <com/sun/star/registry/XImplementationRegistration.hpp>
27 #include <com/sun/star/lang/XComponent.hpp>
29 #include <com/sun/star/xml/sax/SAXParseException.hpp>
31 #include <com/sun/star/io/XOutputStream.hpp>
32 #include <com/sun/star/io/XActiveDataSource.hpp>
34 #include <cppuhelper/servicefactory.hxx>
35 #include <cppuhelper/implbase1.hxx>
36 #include <cppuhelper/implbase3.hxx>
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
;
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 const char * getLocale() const { return theLocale
; }
85 Sequence
<OUString
> name
;
86 Sequence
<OUString
> value
;
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 ;
102 LocaleNode
* * children
;
104 sal_Int32 childArrSize
;
106 void setParent ( LocaleNode
* node
);
112 LocaleNode (const OUString
& name
, const Reference
< XAttributeList
> & attr
);
113 inline void setValue(const OUString
&oValue
) { aValue
+= oValue
; };
114 inline const OUString
& getName() const { return aName
; };
115 inline const OUString
& getValue() const { return aValue
; };
116 inline const Attr
& getAttr() const { return aAttribs
; };
117 inline sal_Int32
getNumberOfChildren () const { return nChildren
; };
118 inline LocaleNode
* getChildAt (sal_Int32 idx
) const { return children
[idx
] ; };
119 const LocaleNode
* findNode ( const sal_Char
*name
) const;
121 void printR () const;
122 virtual ~LocaleNode();
123 void addChild ( LocaleNode
* node
);
124 const LocaleNode
* getParent() const { return parent
; };
125 const LocaleNode
* getRoot() const;
126 int getError() const;
127 virtual void generateCode (const OFileWriter
&of
) const;
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
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
);
154 class LCInfoNode
: public LocaleNode
{
156 inline LCInfoNode (const OUString
& name
,
157 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
158 virtual void generateCode (const OFileWriter
&of
) const;
162 class LCCTYPENode
: public LocaleNode
{
164 inline LCCTYPENode (const OUString
& name
,
165 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
167 virtual void generateCode (const OFileWriter
&of
) const;
170 class LCFormatNode
: public LocaleNode
{
171 static sal_Int16 mnSection
;
172 static sal_Int16 mnFormats
;
174 inline LCFormatNode (const OUString
& name
,
175 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
177 virtual void generateCode (const OFileWriter
&of
) const;
180 class LCCollationNode
: public LocaleNode
{
182 inline LCCollationNode (const OUString
& name
,
183 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
185 virtual void generateCode (const OFileWriter
&of
) const;
188 class LCIndexNode
: public LocaleNode
{
190 inline LCIndexNode (const OUString
& name
,
191 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
193 virtual void generateCode (const OFileWriter
&of
) const;
196 class LCSearchNode
: public LocaleNode
{
198 inline LCSearchNode (const OUString
& name
,
199 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
201 virtual void generateCode (const OFileWriter
&of
) const;
204 class LCCalendarNode
: public LocaleNode
{
206 inline LCCalendarNode (const OUString
& name
,
207 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
209 virtual void generateCode (const OFileWriter
&of
) const;
212 class LCCurrencyNode
: public LocaleNode
{
214 inline LCCurrencyNode (const OUString
& name
,
215 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
217 virtual void generateCode (const OFileWriter
&of
) const;
220 class LCTransliterationNode
: public LocaleNode
{
222 inline LCTransliterationNode (const OUString
& name
,
223 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
225 virtual void generateCode (const OFileWriter
&of
) const;
228 class LCMiscNode
: public LocaleNode
{
230 inline LCMiscNode (const OUString
& name
,
231 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
233 virtual void generateCode (const OFileWriter
&of
) const;
236 class LCNumberingLevelNode
: public LocaleNode
{
238 inline LCNumberingLevelNode (const OUString
& name
,
239 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
241 virtual void generateCode (const OFileWriter
&of
) const;
244 class LCOutlineNumberingLevelNode
: public LocaleNode
{
246 inline LCOutlineNumberingLevelNode (const OUString
& name
,
247 const Reference
< XAttributeList
> & attr
) : LocaleNode (name
, attr
) { ; };
249 virtual void generateCode (const OFileWriter
&of
) const;
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */