bump product version to 4.1.6.2
[LibreOffice.git] / l10ntools / inc / cfgmerge.hxx
blob03addd1ada04390edf6ea6851cb09607d3bf3d30
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef _CFG_MERGE_HXX
21 #define _CFG_MERGE_HXX
23 #include "sal/config.h"
25 #include <fstream>
26 #include <vector>
28 #include "boost/unordered_map.hpp"
29 #include "po.hxx"
31 typedef boost::unordered_map<OString, OString, OStringHash> OStringHashMap;
35 // class CfgStackData
38 class CfgStackData
40 friend class CfgParser;
41 friend class CfgExport;
42 friend class CfgMerge;
43 private:
44 OString sTagType;
45 OString sIdentifier;
47 OString sResTyp;
49 OString sTextTag;
50 OString sEndTextTag;
52 OStringHashMap sText;
53 public:
54 CfgStackData(const OString &rTag, const OString &rId)
55 : sTagType( rTag ), sIdentifier( rId )
58 const OString &GetTagType() { return sTagType; }
59 const OString &GetIdentifier() { return sIdentifier; }
64 // class CfgStack
67 class CfgStack
69 private:
70 std::vector< CfgStackData* > maList;
72 public:
73 CfgStack() {}
74 ~CfgStack();
76 CfgStackData *Push(const OString &rTag, const OString &rId);
77 CfgStackData *Pop()
79 if (maList.empty())
80 return NULL;
81 CfgStackData* temp = maList.back();
82 maList.pop_back();
83 return temp;
86 CfgStackData *GetStackData();
88 OString GetAccessPath( size_t nPos );
90 size_t size() const { return maList.size(); }
93 /// Parser for *.xcu files
94 class CfgParser
96 protected:
97 OString sCurrentResTyp;
98 OString sCurrentIsoLang;
99 OString sCurrentText;
101 OString sLastWhitespace;
103 CfgStack aStack;
104 CfgStackData *pStackData;
106 sal_Bool bLocalize;
108 virtual void WorkOnText(
109 OString &rText,
110 const OString &rLangIndex )=0;
112 virtual void WorkOnResourceEnd()=0;
114 virtual void Output(const OString & rOutput)=0;
116 void Error(const OString &rError);
118 private:
119 int ExecuteAnalyzedToken( int nToken, char *pToken );
120 void AddText(
121 OString &rText,
122 const OString &rIsoLang,
123 const OString &rResTyp );
125 sal_Bool IsTokenClosed(const OString &rToken);
127 public:
128 CfgParser();
129 virtual ~CfgParser();
131 int Execute( int nToken, char * pToken );
134 /// Export strings from *.xcu files
135 class CfgExport : public CfgParser
137 private:
138 OString sPath;
139 PoOfstream pOutputStream;
141 protected:
142 virtual void WorkOnText(
143 OString &rText,
144 const OString &rIsoLang
147 void WorkOnResourceEnd();
148 void Output(const OString& rOutput);
149 public:
150 CfgExport(
151 const OString &rOutputFile,
152 const OString &rFilePath
154 ~CfgExport();
157 /// Merge strings to *.xcu files
158 class CfgMerge : public CfgParser
160 private:
161 MergeDataFile *pMergeDataFile;
162 std::vector<OString> aLanguages;
163 ResData *pResData;
165 OString sFilename;
166 sal_Bool bEnglish;
168 std::ofstream pOutputStream;
170 protected:
171 virtual void WorkOnText(OString &rText, const OString &rLangIndex);
173 void WorkOnResourceEnd();
175 void Output(const OString& rOutput);
176 public:
177 CfgMerge(
178 const OString &rMergeSource, const OString &rOutputFile,
179 const OString &rFilename, const OString &rLanguage );
180 ~CfgMerge();
183 #endif
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */