fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / l10ntools / inc / cfgmerge.hxx
blobc61ff03ed2617249faa231b52a5a3158cb6c84ae
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 INCLUDED_L10NTOOLS_INC_CFGMERGE_HXX
21 #define INCLUDED_L10NTOOLS_INC_CFGMERGE_HXX
23 #include "sal/config.h"
25 #include <fstream>
26 #include <unordered_map>
27 #include <vector>
28 #include "po.hxx"
30 typedef std::unordered_map<OString, OString, OStringHash> OStringHashMap;
34 // class CfgStackData
37 class CfgStackData
39 friend class CfgParser;
40 friend class CfgExport;
41 friend class CfgMerge;
42 private:
43 OString sTagType;
44 OString sIdentifier;
46 OString sResTyp;
48 OString sTextTag;
49 OString sEndTextTag;
51 OStringHashMap sText;
52 public:
53 CfgStackData(const OString &rTag, const OString &rId)
54 : sTagType( rTag ), sIdentifier( rId )
57 const OString &GetTagType() { return sTagType; }
58 const OString &GetIdentifier() { return sIdentifier; }
63 // class CfgStack
66 class CfgStack
68 private:
69 std::vector< CfgStackData* > maList;
71 public:
72 CfgStack() {}
73 ~CfgStack();
75 CfgStackData *Push(const OString &rTag, const OString &rId);
76 void Pop()
78 if (!maList.empty())
80 delete maList.back();
81 maList.pop_back();
85 CfgStackData *GetStackData();
87 OString GetAccessPath( size_t nPos );
89 size_t size() const { return maList.size(); }
92 /// Parser for *.xcu files
93 class CfgParser
95 protected:
96 OString sCurrentResTyp;
97 OString sCurrentIsoLang;
98 OString sCurrentText;
100 OString sLastWhitespace;
102 CfgStack aStack;
103 CfgStackData *pStackData;
105 bool bLocalize;
107 virtual void WorkOnText(
108 OString &rText,
109 const OString &rLangIndex )=0;
111 virtual void WorkOnResourceEnd()=0;
113 virtual void Output(const OString & rOutput)=0;
115 static void Error(const OString &rError);
117 private:
118 int ExecuteAnalyzedToken( int nToken, char *pToken );
119 void AddText(
120 OString &rText,
121 const OString &rIsoLang,
122 const OString &rResTyp );
124 static bool IsTokenClosed(const OString &rToken);
126 public:
127 CfgParser();
128 virtual ~CfgParser();
130 int Execute( int nToken, char * pToken );
133 /// Export strings from *.xcu files
134 class CfgExport : public CfgParser
136 private:
137 OString sPath;
138 PoOfstream pOutputStream;
140 protected:
141 virtual void WorkOnText(
142 OString &rText,
143 const OString &rIsoLang
144 ) SAL_OVERRIDE;
146 void WorkOnResourceEnd() SAL_OVERRIDE;
147 void Output(const OString& rOutput) SAL_OVERRIDE;
148 public:
149 CfgExport(
150 const OString &rOutputFile,
151 const OString &rFilePath
153 virtual ~CfgExport();
156 /// Merge strings to *.xcu files
157 class CfgMerge : public CfgParser
159 private:
160 MergeDataFile *pMergeDataFile;
161 std::vector<OString> aLanguages;
162 ResData *pResData;
164 OString sFilename;
165 bool bEnglish;
167 std::ofstream pOutputStream;
169 protected:
170 virtual void WorkOnText(OString &rText, const OString &rLangIndex) SAL_OVERRIDE;
172 void WorkOnResourceEnd() SAL_OVERRIDE;
174 void Output(const OString& rOutput) SAL_OVERRIDE;
175 public:
176 CfgMerge(
177 const OString &rMergeSource, const OString &rOutputFile,
178 const OString &rFilename, const OString &rLanguage );
179 virtual ~CfgMerge();
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */