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