xref: /aoo42x/main/l10ntools/inc/xrmmerge.hxx (revision 983d4c8a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // global includes
25 #include <tools/string.hxx>
26 
27 //
28 // XRMResParser
29 //
30 
31 class XRMResParser
32 {
33 private:
34 	ByteString sGID;
35 	ByteString sLID;
36 
37 	sal_Bool bError;
38 	sal_Bool bText;
39 
40 	bool sLocalized;
41 
42 	ByteString sCurrentOpenTag;
43 	ByteString sCurrentCloseTag;
44 	ByteString sCurrentText;
45     std::vector<ByteString> aLanguages;
46 
47 protected:
48 	ByteString GetAttribute( const ByteString &rToken, const ByteString &rAttribute );
49 	void Error( const ByteString &rError );
50 
51 	virtual void Output( const ByteString& rOutput )=0;
52 	virtual void WorkOnText(
53 		const ByteString &rOpenTag,
54 		ByteString &rText
55 	)=0;
56 	virtual void EndOfText(
57 		const ByteString &rOpenTag,
58 		const ByteString &rCloseTag
59 	)=0;
60 
GetGID()61 	ByteString GetGID() { return sGID; }
GetLID()62 	ByteString GetLID() { return sLID; }
63 
64 	void ConvertStringToDBFormat( ByteString &rString );
65 	void ConvertStringToXMLFormat( ByteString &rString );
66 
67 public:
68 	XRMResParser();
69 	virtual ~XRMResParser();
70 
71 	int Execute( int nToken, char * pToken );
72 
SetError(sal_Bool bErr=sal_True)73 	void SetError( sal_Bool bErr = sal_True ) { bError = bErr; }
GetError()74 	sal_Bool GetError() { return bError; }
75 };
76 
77 //
78 // class XRMResOutputParser
79 //
80 
81 class XRMResOutputParser : public XRMResParser
82 {
83 private:
84     std::vector<ByteString> aLanguages;
85 protected:
86 	SvFileStream *pOutputStream;
87 public:
88 	XRMResOutputParser ( const ByteString &rOutputFile );
89 	virtual ~XRMResOutputParser();
90 };
91 
92 //
93 // XRMResExport
94 //
95 
96 class XRMResExport : public XRMResOutputParser
97 {
98 private:
99 	ResData *pResData;
100 	ByteString sPrj;
101 	ByteString sPath;
102     std::vector<ByteString> aLanguages;
103 
104 protected:
105 	void WorkOnText(
106 		const ByteString &rOpenTag,
107 		ByteString &rText
108 	);
109 	void EndOfText(
110 		const ByteString &rOpenTag,
111 		const ByteString &rCloseTag
112 	);
113 	void Output( const ByteString& rOutput );
114 
115 public:
116 	XRMResExport(
117 		const ByteString &rOutputFile,
118 		const ByteString &rProject,
119 		const ByteString &rFilePath
120 	);
121 	virtual ~XRMResExport();
122 };
123 
124 //
125 // class XRMResMerge
126 //
127 
128 class XRMResMerge : public XRMResOutputParser
129 {
130 private:
131 	MergeDataFile *pMergeDataFile;
132 	ByteString sFilename;
133     ResData *pResData;
134     std::vector<ByteString> aLanguages;
135 
136 protected:
137 	void WorkOnText(
138 		const ByteString &rOpenTag,
139 		ByteString &rText
140 	);
141 	void EndOfText(
142 		const ByteString &rOpenTag,
143 		const ByteString &rCloseTag
144 	);
145 	void Output( const ByteString& rOutput );
146 public:
147 	XRMResMerge(
148 		const ByteString &rMergeSource,
149 		const ByteString &rOutputFile,
150 		ByteString &rFilename
151 	);
152 	virtual ~XRMResMerge();
153 };
154 
155