xref: /trunk/main/l10ntools/inc/xrmmerge.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // global includes
29 #include <tools/string.hxx>
30 
31 //
32 // XRMResParser
33 //
34 
35 class XRMResParser
36 {
37 private:
38 	ByteString sGID;
39 	ByteString sLID;
40 
41 	sal_Bool bError;
42 	sal_Bool bText;
43 
44 	bool sLocalized;
45 
46 	ByteString sCurrentOpenTag;
47 	ByteString sCurrentCloseTag;
48 	ByteString sCurrentText;
49     std::vector<ByteString> aLanguages;
50 
51 protected:
52 	ByteString GetAttribute( const ByteString &rToken, const ByteString &rAttribute );
53 	void Error( const ByteString &rError );
54 
55 	virtual void Output( const ByteString& rOutput )=0;
56 	virtual void WorkOnText(
57 		const ByteString &rOpenTag,
58 		ByteString &rText
59 	)=0;
60 	virtual void EndOfText(
61 		const ByteString &rOpenTag,
62 		const ByteString &rCloseTag
63 	)=0;
64 
65 	ByteString GetGID() { return sGID; }
66 	ByteString GetLID() { return sLID; }
67 
68 	void ConvertStringToDBFormat( ByteString &rString );
69 	void ConvertStringToXMLFormat( ByteString &rString );
70 
71 public:
72 	XRMResParser();
73 	virtual ~XRMResParser();
74 
75 	int Execute( int nToken, char * pToken );
76 
77 	void SetError( sal_Bool bErr = sal_True ) { bError = bErr; }
78 	sal_Bool GetError() { return bError; }
79 };
80 
81 //
82 // class XRMResOutputParser
83 //
84 
85 class XRMResOutputParser : public XRMResParser
86 {
87 private:
88     std::vector<ByteString> aLanguages;
89 protected:
90 	SvFileStream *pOutputStream;
91 public:
92 	XRMResOutputParser ( const ByteString &rOutputFile );
93 	virtual ~XRMResOutputParser();
94 };
95 
96 //
97 // XRMResExport
98 //
99 
100 class XRMResExport : public XRMResOutputParser
101 {
102 private:
103 	ResData *pResData;
104 	ByteString sPrj;
105 	ByteString sPath;
106     std::vector<ByteString> aLanguages;
107 
108 protected:
109 	void WorkOnText(
110 		const ByteString &rOpenTag,
111 		ByteString &rText
112 	);
113 	void EndOfText(
114 		const ByteString &rOpenTag,
115 		const ByteString &rCloseTag
116 	);
117 	void Output( const ByteString& rOutput );
118 
119 public:
120 	XRMResExport(
121 		const ByteString &rOutputFile,
122 		const ByteString &rProject,
123 		const ByteString &rFilePath
124 	);
125 	virtual ~XRMResExport();
126 };
127 
128 //
129 // class XRMResMerge
130 //
131 
132 class XRMResMerge : public XRMResOutputParser
133 {
134 private:
135 	MergeDataFile *pMergeDataFile;
136 	ByteString sFilename;
137     ResData *pResData;
138     std::vector<ByteString> aLanguages;
139 
140 protected:
141 	void WorkOnText(
142 		const ByteString &rOpenTag,
143 		ByteString &rText
144 	);
145 	void EndOfText(
146 		const ByteString &rOpenTag,
147 		const ByteString &rCloseTag
148 	);
149 	void Output( const ByteString& rOutput );
150 public:
151 	XRMResMerge(
152 		const ByteString &rMergeSource,
153 		const ByteString &rOutputFile,
154 		ByteString &rFilename
155 	);
156 	virtual ~XRMResMerge();
157 };
158 
159