bump product version to 6.4.0.3
[LibreOffice.git] / l10ntools / inc / export.hxx
blobb6d958695b8dc9bf289c441d30fbc267491272ba
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_EXPORT_HXX
21 #define INCLUDED_L10NTOOLS_INC_EXPORT_HXX
23 #include <sal/config.h>
24 #include "po.hxx"
26 #include <cstddef>
27 #include <fstream>
29 #include <osl/file.hxx>
30 #include <osl/file.h>
32 #include <iterator>
33 #include <set>
34 #include <unordered_map>
35 #include <memory>
36 #include <vector>
37 #include <queue>
38 #include <string>
40 #ifdef _WIN32
41 #include <direct.h>
42 #else
43 #include <unistd.h>
44 #endif
46 #define NO_TRANSLATE_ISO "x-no-translate"
48 class MergeEntrys;
50 typedef std::unordered_map<OString, OString>
51 OStringHashMap;
53 typedef std::unordered_map<OString, bool>
54 OStringBoolHashMap;
56 #define SOURCE_LANGUAGE "en-US"
57 #define X_COMMENT "x-comment"
60 // class ResData
63 /// Purpose: holds mandatory data to export a single res
64 class ResData
66 public:
67 ResData( const OString &rGId );
68 ResData( const OString &rGId , const OString &rFilename );
70 OString sResTyp;
71 OString sId;
72 OString sGId;
73 OString sFilename;
75 OStringHashMap sText;
79 // class Export
82 class ParserQueue;
84 // class MergeEntrys
87 /// Purpose: holds information of data to merge
88 class MergeEntrys
90 friend class MergeDataFile;
91 private:
92 OStringHashMap sText;
93 OStringBoolHashMap bTextFirst;
94 OStringHashMap sQuickHelpText;
95 OStringBoolHashMap bQuickHelpTextFirst;
96 OStringHashMap sTitle;
97 OStringBoolHashMap bTitleFirst;
99 public:
100 MergeEntrys(){};
101 void InsertEntry(const OString &rId, const OString &rText,
102 const OString &rQuickHelpText, const OString &rTitle)
105 sText[ rId ] = rText;
106 bTextFirst[ rId ] = true;
107 sQuickHelpText[ rId ] = rQuickHelpText;
108 bQuickHelpTextFirst[ rId ] = true;
109 sTitle[ rId ] = rTitle;
110 bTitleFirst[ rId ] = true;
112 bool GetText( OString &rReturn, const OString &nLangIndex, bool bDel = false );
115 Generate QTZ string with ResData
116 For executable which works one language and without PO files.
118 static OString GetQTZText(const ResData& rResData, const OString& rOrigText);
122 // class MergeDataFile
125 /// Purpose: holds information of data to merge, read from PO file
126 class MergeDataFile
128 private:
129 std::unordered_map<OString, std::unique_ptr<MergeEntrys>> aMap;
130 std::set<OString> aLanguageSet;
132 MergeEntrys *GetMergeData( ResData *pResData , bool bCaseSensitive = false );
133 void InsertEntry(const OString &rTYP, const OString &rGID,
134 const OString &rLID, const OString &nLang,
135 const OString &rTEXT, const OString &rQHTEXT,
136 const OString &rTITLE, const OString &sFilename,
137 bool bFirstLang, bool bCaseSensitive);
138 public:
139 explicit MergeDataFile(
140 const OString &rFileName, const OString& rFile,
141 bool bCaseSensitive, bool bWithQtz = true );
142 ~MergeDataFile();
145 std::vector<OString> GetLanguages() const;
147 MergeEntrys *GetMergeEntrys( ResData *pResData );
148 MergeEntrys *GetMergeEntrysCaseSensitive( ResData *pResData );
150 static OString CreateKey(const OString& rTYP, const OString& rGID,
151 const OString& rLID, const OString& rFilename, bool bCaseSensitive);
155 #endif // INCLUDED_L10NTOOLS_INC_EXPORT_HXX
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */