tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / l10ntools / inc / cfgmerge.hxx
bloba2f59e1e6e8f6bdbf76558844126daedb190799d
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 <memory>
28 #include <utility>
29 #include <vector>
30 #include "po.hxx"
31 #include "export.hxx"
33 typedef std::unordered_map<OString, OString> OStringHashMap;
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(OString _sTag, OString _sId)
55 : sTagType(std::move( _sTag )), sIdentifier(std::move( _sId ))
58 const OString &GetTagType() const { return sTagType; }
59 const OString &GetIdentifier() const { return sIdentifier; }
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 private:
116 void ExecuteAnalyzedToken( int nToken, char *pToken );
117 void AddText(
118 OString &rText,
119 const OString &rIsoLang,
120 const OString &rResTyp );
122 static bool IsTokenClosed(std::string_view rToken);
124 public:
125 CfgParser();
126 virtual ~CfgParser();
128 void Execute( int nToken, char * pToken );
131 /// Export strings from *.xcu files
132 class CfgExport : public CfgParser
134 private:
135 OString sPath;
136 PoOfstream pOutputStream;
138 protected:
139 virtual void WorkOnText(
140 OString &rText,
141 const OString &rIsoLang
142 ) override;
144 void WorkOnResourceEnd() override;
145 void Output(const OString& rOutput) override;
146 public:
147 CfgExport(
148 const OString &rOutputFile,
149 OString sFilePath
151 virtual ~CfgExport() override;
154 /// Merge strings to *.xcu files
155 class CfgMerge : public CfgParser
157 private:
158 std::unique_ptr<MergeDataFile> pMergeDataFile;
159 std::vector<OString> aLanguages;
160 std::unique_ptr<ResData> pResData;
162 OString sFilename;
163 bool bEnglish;
165 std::ofstream pOutputStream;
167 protected:
168 virtual void WorkOnText(OString &rText, const OString &rLangIndex) override;
170 void WorkOnResourceEnd() override;
172 void Output(const OString& rOutput) override;
173 public:
174 CfgMerge(
175 const OString &rMergeSource, const OString &rOutputFile,
176 OString sFilename, const OString &rLanguage );
177 virtual ~CfgMerge() override;
180 #endif
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */