LibreOffice Module l10ntools (master) 1
export.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_L10NTOOLS_INC_EXPORT_HXX
21#define INCLUDED_L10NTOOLS_INC_EXPORT_HXX
22
23#include <sal/config.h>
24
25#include <rtl/string.hxx>
26
27#include <set>
28#include <unordered_map>
29#include <memory>
30#include <vector>
31#include <string_view>
32
33#ifdef _WIN32
34#include <direct.h>
35#endif
36
37#define NO_TRANSLATE_ISO "x-no-translate"
38
39class MergeEntrys;
40
41typedef std::unordered_map<OString, OString>
43
44typedef std::unordered_map<OString, bool>
46
47#define SOURCE_LANGUAGE "en-US"
48#define X_COMMENT "x-comment"
49
50
51
52
55{
56public:
57 ResData( OString rGId );
58 ResData( OString sGId , OString sFilename );
59
60 OString sResTyp;
61 OString sId;
62 OString sGId;
63 OString sFilename;
64
66};
67
68
69
70
71class ParserQueue;
72
73
74
77{
78friend class MergeDataFile;
79private:
86
87public:
89 void InsertEntry(const OString &rId, const OString &rText,
90 const OString &rQuickHelpText, const OString &rTitle)
91 {
92
93 sText[ rId ] = rText;
94 bTextFirst[ rId ] = true;
95 sQuickHelpText[ rId ] = rQuickHelpText;
96 bQuickHelpTextFirst[ rId ] = true;
97 sTitle[ rId ] = rTitle;
98 bTitleFirst[ rId ] = true;
99 }
100 bool GetText( OString &rReturn, const OString &nLangIndex, bool bDel = false );
101
106 static OString GetQTZText(const ResData& rResData, std::string_view rOrigText);
107
108};
109
110
111
114{
115 private:
116 std::unordered_map<OString, std::unique_ptr<MergeEntrys>> aMap;
117 std::set<OString> aLanguageSet;
118
119 MergeEntrys *GetMergeData( ResData *pResData , bool bCaseSensitive = false );
120 void InsertEntry(std::string_view rTYP, std::string_view rGID,
121 std::string_view rLID, const OString &nLang,
122 const OString &rTEXT, const OString &rQHTEXT,
123 const OString &rTITLE, std::string_view sFilename,
124 bool bFirstLang, bool bCaseSensitive);
125 public:
126 explicit MergeDataFile(
127 const OString &rFileName, std::string_view rFile,
128 bool bCaseSensitive, bool bWithQtz = true );
130
131
132 std::vector<OString> GetLanguages() const;
133
134 MergeEntrys *GetMergeEntrys( ResData *pResData );
136
137 static OString CreateKey(std::string_view rTYP, std::string_view rGID,
138 std::string_view rLID, std::string_view rFilename, bool bCaseSensitive);
139};
140
141
142#endif // INCLUDED_L10NTOOLS_INC_EXPORT_HXX
143
144/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unordered_map< OString, OString > OStringHashMap
Definition: cfgmerge.hxx:33
Purpose: holds information of data to merge, read from PO file.
Definition: export.hxx:114
MergeDataFile(const OString &rFileName, std::string_view rFile, bool bCaseSensitive, bool bWithQtz=true)
Definition: merge.cxx:119
~MergeDataFile()
Definition: merge.cxx:238
static OString CreateKey(std::string_view rTYP, std::string_view rGID, std::string_view rLID, std::string_view rFilename, bool bCaseSensitive)
Definition: merge.cxx:333
std::unordered_map< OString, std::unique_ptr< MergeEntrys > > aMap
Definition: export.hxx:116
std::set< OString > aLanguageSet
Definition: export.hxx:117
void InsertEntry(std::string_view rTYP, std::string_view rGID, std::string_view rLID, const OString &nLang, const OString &rTEXT, const OString &rQHTEXT, const OString &rTITLE, std::string_view sFilename, bool bFirstLang, bool bCaseSensitive)
Definition: merge.cxx:286
MergeEntrys * GetMergeData(ResData *pResData, bool bCaseSensitive=false)
Definition: merge.cxx:247
MergeEntrys * GetMergeEntrys(ResData *pResData)
Definition: merge.cxx:274
MergeEntrys * GetMergeEntrysCaseSensitive(ResData *pResData)
Definition: merge.cxx:280
std::vector< OString > GetLanguages() const
Definition: merge.cxx:242
Purpose: holds information of data to merge.
Definition: export.hxx:77
OStringBoolHashMap bQuickHelpTextFirst
Definition: export.hxx:83
OStringBoolHashMap bTextFirst
Definition: export.hxx:81
OStringHashMap sText
Definition: export.hxx:80
void InsertEntry(const OString &rId, const OString &rText, const OString &rQuickHelpText, const OString &rTitle)
Definition: export.hxx:89
OStringBoolHashMap bTitleFirst
Definition: export.hxx:85
static OString GetQTZText(const ResData &rResData, std::string_view rOrigText)
Generate QTZ string with ResData For executable which works one language and without PO files.
Definition: merge.cxx:109
MergeEntrys()
Definition: export.hxx:88
OStringHashMap sTitle
Definition: export.hxx:84
bool GetText(OString &rReturn, const OString &nLangIndex, bool bDel=false)
Definition: merge.cxx:87
OStringHashMap sQuickHelpText
Definition: export.hxx:82
Purpose: holds mandatory data to export a single res.
Definition: export.hxx:55
OStringHashMap sText
Definition: export.hxx:65
OString sGId
Definition: export.hxx:62
OString sFilename
Definition: export.hxx:63
OString sId
Definition: export.hxx:61
ResData(OString rGId)
Definition: merge.cxx:69
OString sResTyp
Definition: export.hxx:60
std::unordered_map< OString, OString > OStringHashMap
Definition: export.hxx:39
std::unordered_map< OString, bool > OStringBoolHashMap
Definition: export.hxx:45