CppunitTest_sc_tiledrendering2: move to tiledrendering folder
[LibreOffice.git] / l10ntools / inc / xrmmerge.hxx
blob65b19f7b9251aa00b6bbb812b632337b5aec3805
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_XRMMERGE_HXX
21 #define INCLUDED_L10NTOOLS_INC_XRMMERGE_HXX
23 #include <memory>
24 #include <sal/config.h>
26 #include <fstream>
27 #include <string_view>
29 #include <rtl/string.hxx>
31 #include "export.hxx"
32 #include "po.hxx"
34 /// Parser for *.xrm and description.xml files
35 class XRMResParser
37 private:
38 OString sGID;
40 bool bError;
41 bool bText;
43 OString sCurrentOpenTag;
44 OString sCurrentCloseTag;
45 OString sCurrentText;
46 protected:
47 static OString GetAttribute( const OString &rToken, std::string_view rAttribute );
48 static void Error( const OString &rError );
50 virtual void Output( const OString& rOutput )=0;
51 virtual void WorkOnDesc(
52 const OString &rOpenTag,
53 OString &rText
54 )=0;
55 virtual void WorkOnText(
56 const OString &rOpenTag,
57 OString &rText
58 )=0;
59 virtual void EndOfText(
60 const OString &rOpenTag,
61 const OString &rCloseTag
62 )=0;
64 const OString& GetGID() const { return sGID; }
66 public:
67 XRMResParser();
68 virtual ~XRMResParser();
70 void Execute( int nToken, char * pToken );
72 void SetError() { bError = true; }
73 bool GetError() const { return bError; }
77 /// Export strings from *.xrm and description.xml files
78 class XRMResExport final : public XRMResParser
80 private:
81 std::unique_ptr<ResData> pResData;
82 OString sPath;
83 PoOfstream pOutputStream;
85 void WorkOnDesc(
86 const OString &rOpenTag,
87 OString &rText
88 ) override;
89 void WorkOnText(
90 const OString &rOpenTag,
91 OString &rText
92 ) override;
93 void EndOfText(
94 const OString &rOpenTag,
95 const OString &rCloseTag
96 ) override;
97 void Output( const OString& rOutput ) override;
99 public:
100 XRMResExport(
101 const OString &rOutputFile,
102 OString sFilePath
104 virtual ~XRMResExport() override;
108 /// Merge strings to *.xrm and description.xml files
109 class XRMResMerge final : public XRMResParser
111 private:
112 std::unique_ptr<MergeDataFile> pMergeDataFile;
113 OString sFilename;
114 std::unique_ptr<ResData> pResData;
115 std::ofstream pOutputStream;
116 std::vector<OString> aLanguages;
118 void WorkOnDesc(
119 const OString &rOpenTag,
120 OString &rText
121 ) override;
122 void WorkOnText(
123 const OString &rOpenTag,
124 OString &rText
125 ) override;
126 void EndOfText(
127 const OString &rOpenTag,
128 const OString &rCloseTag
129 ) override;
130 void Output( const OString& rOutput ) override;
131 public:
132 XRMResMerge(
133 const OString &rMergeSource,
134 const OString &rOutputFile,
135 OString sFilename
137 virtual ~XRMResMerge() override;
140 #endif // INCLUDED_L10NTOOLS_INC_XRMMERGE_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */