Line data Source code
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 :
20 : #include "sal/config.h"
21 :
22 : #include <fstream>
23 :
24 : //
25 : // XRMResParser
26 : //
27 :
28 : class XRMResParser
29 : {
30 : private:
31 : rtl::OString sGID;
32 : rtl::OString sLID;
33 :
34 : sal_Bool bError;
35 : sal_Bool bText;
36 :
37 : rtl::OString sCurrentOpenTag;
38 : rtl::OString sCurrentCloseTag;
39 : rtl::OString sCurrentText;
40 : std::vector<rtl::OString> aLanguages;
41 :
42 : protected:
43 : rtl::OString GetAttribute( const rtl::OString &rToken, const rtl::OString &rAttribute );
44 : void Error( const rtl::OString &rError );
45 :
46 : virtual void Output( const rtl::OString& rOutput )=0;
47 : virtual void WorkOnDesc(
48 : const rtl::OString &rOpenTag,
49 : rtl::OString &rText
50 : )=0;
51 : virtual void WorkOnText(
52 : const rtl::OString &rOpenTag,
53 : rtl::OString &rText
54 : )=0;
55 : virtual void EndOfText(
56 : const rtl::OString &rOpenTag,
57 : const rtl::OString &rCloseTag
58 : )=0;
59 :
60 0 : rtl::OString GetGID() { return sGID; }
61 : rtl::OString GetLID() { return sLID; }
62 :
63 : void ConvertStringToDBFormat( rtl::OString &rString );
64 : void ConvertStringToXMLFormat( rtl::OString &rString );
65 :
66 : public:
67 : XRMResParser();
68 : virtual ~XRMResParser();
69 :
70 : int Execute( int nToken, char * pToken );
71 :
72 0 : void SetError( sal_Bool bErr = sal_True ) { bError = bErr; }
73 0 : sal_Bool GetError() { return bError; }
74 : };
75 :
76 : //
77 : // class XRMResOutputParser
78 : //
79 :
80 : class XRMResOutputParser : public XRMResParser
81 : {
82 : private:
83 : std::vector<rtl::OString> aLanguages;
84 : protected:
85 : std::ofstream pOutputStream;
86 : public:
87 : XRMResOutputParser ( const rtl::OString &rOutputFile );
88 : virtual ~XRMResOutputParser();
89 : };
90 :
91 : //
92 : // XRMResExport
93 : //
94 :
95 : class XRMResExport : public XRMResOutputParser
96 : {
97 : private:
98 : ResData *pResData;
99 : rtl::OString sPrj;
100 : rtl::OString sPath;
101 : std::vector<rtl::OString> aLanguages;
102 :
103 : protected:
104 : void WorkOnDesc(
105 : const rtl::OString &rOpenTag,
106 : rtl::OString &rText
107 : );
108 : void WorkOnText(
109 : const rtl::OString &rOpenTag,
110 : rtl::OString &rText
111 : );
112 : void EndOfText(
113 : const rtl::OString &rOpenTag,
114 : const rtl::OString &rCloseTag
115 : );
116 : void Output( const rtl::OString& rOutput );
117 :
118 : public:
119 : XRMResExport(
120 : const rtl::OString &rOutputFile,
121 : const rtl::OString &rProject,
122 : const rtl::OString &rFilePath
123 : );
124 : virtual ~XRMResExport();
125 : };
126 :
127 : //
128 : // class XRMResMerge
129 : //
130 :
131 : class XRMResMerge : public XRMResOutputParser
132 : {
133 : private:
134 : MergeDataFile *pMergeDataFile;
135 : rtl::OString sFilename;
136 : ResData *pResData;
137 : std::vector<rtl::OString> aLanguages;
138 :
139 : protected:
140 : void WorkOnDesc(
141 : const rtl::OString &rOpenTag,
142 : rtl::OString &rText
143 : );
144 : void WorkOnText(
145 : const rtl::OString &rOpenTag,
146 : rtl::OString &rText
147 : );
148 : void EndOfText(
149 : const rtl::OString &rOpenTag,
150 : const rtl::OString &rCloseTag
151 : );
152 : void Output( const rtl::OString& rOutput );
153 : public:
154 : XRMResMerge(
155 : const rtl::OString &rMergeSource,
156 : const rtl::OString &rOutputFile,
157 : const rtl::OString &rFilename
158 : );
159 : virtual ~XRMResMerge();
160 : };
161 :
162 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|