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 #include <SwStyleNameMapper.hxx>
21 #include <poolfmt.hxx>
22 #include <strings.hrc>
23 #include <swtypes.hxx>
24 #include <unotools/syslocale.hxx>
25 #include <i18nlangtag/languagetag.hxx>
26 #include <o3tl/string_view.hxx>
27 #include <map>
28
29 #ifdef _NEED_TO_DEBUG_MAPPING
30 #include <stdlib.h>
31 #endif
32
33 namespace
34 {
35
36 const OUString &
lcl_GetSpecialExtraName(const OUString & rExtraName,const bool bIsUIName)37 lcl_GetSpecialExtraName(const OUString& rExtraName, const bool bIsUIName )
38 {
39 const std::vector<OUString>& rExtraArr = bIsUIName
40 ? SwStyleNameMapper::GetExtraUINameArray()
41 : SwStyleNameMapper::GetExtraProgNameArray();
42 static const sal_uInt16 nIds[] =
43 {
44 RES_POOLCOLL_LABEL_DRAWING - RES_POOLCOLL_EXTRA_BEGIN,
45 RES_POOLCOLL_LABEL_ABB - RES_POOLCOLL_EXTRA_BEGIN,
46 RES_POOLCOLL_LABEL_TABLE - RES_POOLCOLL_EXTRA_BEGIN,
47 RES_POOLCOLL_LABEL_FRAME- RES_POOLCOLL_EXTRA_BEGIN,
48 RES_POOLCOLL_LABEL_FIGURE-RES_POOLCOLL_EXTRA_BEGIN,
49 0
50 };
51 const sal_uInt16 * pIds;
52 for ( pIds = nIds; *pIds; ++pIds)
53 {
54 if (rExtraName == rExtraArr[ *pIds ])
55 {
56 return bIsUIName
57 ? SwStyleNameMapper::GetExtraProgNameArray()[*pIds]
58 : SwStyleNameMapper::GetExtraUINameArray()[*pIds];
59 }
60 }
61 return rExtraName;
62 }
63
lcl_SuffixIsUser(std::u16string_view rString)64 bool lcl_SuffixIsUser(std::u16string_view rString)
65 {
66 // Interesting, why the rest must be longer than 1 character? It is so
67 // since commit 4fbc9dd48b7cebb304010e7337b1bbc3936c7923 (2001-08-16)
68 return rString.size() > 8 && o3tl::ends_with(rString, u" (user)");
69 }
70
lcl_CheckSuffixAndDelete(OUString & rString)71 void lcl_CheckSuffixAndDelete(OUString & rString)
72 {
73 if (lcl_SuffixIsUser(rString))
74 {
75 rString = rString.copy(0, rString.getLength() - 7);
76 }
77 }
78
HashFromRange(sal_uInt16 nAcc)79 NameToIdHash HashFromRange(sal_uInt16 nAcc) { return NameToIdHash(nAcc); }
80 template <typename... Rest>
HashFromRange(sal_uInt16 nAcc,sal_uInt16 nBegin,sal_uInt16 nEnd,const std::vector<OUString> & (* pFunc)(),Rest...rest)81 NameToIdHash HashFromRange(sal_uInt16 nAcc, sal_uInt16 nBegin, sal_uInt16 nEnd,
82 const std::vector<OUString>& (*pFunc)(), Rest... rest)
83 {
84 NameToIdHash hash(HashFromRange(nAcc + nEnd - nBegin, rest...));
85 sal_uInt16 nIndex, nId;
86 const std::vector<OUString>& rStrings = pFunc();
87 for (nIndex = 0, nId = nBegin; nId < nEnd; nId++, nIndex++)
88 hash[rStrings[nIndex]] = nId;
89 return hash;
90 }
91
92 template <auto initFunc> struct TablePair
93 {
getMap__anon8c41fb6d0111::TablePair94 static const NameToIdHash& getMap(bool bProgName)
95 {
96 if (bProgName)
97 {
98 static const NameToIdHash s_aProgMap(initFunc(true));
99 return s_aProgMap;
100 }
101
102 SvtSysLocale aSysLocale;
103 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
104 static std::map<LanguageTag, NameToIdHash> s_aUIMap;
105
106 auto it = s_aUIMap.find(rCurrentLanguage);
107 if (it == s_aUIMap.end())
108 it = s_aUIMap.emplace(rCurrentLanguage, initFunc(false)).first;
109
110 return it->second;
111 }
112 };
113
GetParaMap(bool bProgName)114 NameToIdHash GetParaMap (bool bProgName)
115 {
116 return HashFromRange(0,
117 RES_POOLCOLL_TEXT_BEGIN, RES_POOLCOLL_TEXT_END, bProgName ? &SwStyleNameMapper::GetTextProgNameArray : &SwStyleNameMapper::GetTextUINameArray,
118 RES_POOLCOLL_LISTS_BEGIN, RES_POOLCOLL_LISTS_END, bProgName ? &SwStyleNameMapper::GetListsProgNameArray : &SwStyleNameMapper::GetListsUINameArray,
119 RES_POOLCOLL_EXTRA_BEGIN, RES_POOLCOLL_EXTRA_END, bProgName ? &SwStyleNameMapper::GetExtraProgNameArray : &SwStyleNameMapper::GetExtraUINameArray,
120 RES_POOLCOLL_REGISTER_BEGIN, RES_POOLCOLL_REGISTER_END, bProgName ? &SwStyleNameMapper::GetRegisterProgNameArray : &SwStyleNameMapper::GetRegisterUINameArray,
121 RES_POOLCOLL_DOC_BEGIN, RES_POOLCOLL_DOC_END, bProgName ? &SwStyleNameMapper::GetDocProgNameArray : &SwStyleNameMapper::GetDocUINameArray,
122 RES_POOLCOLL_HTML_BEGIN, RES_POOLCOLL_HTML_END, bProgName ? &SwStyleNameMapper::GetHTMLProgNameArray : &SwStyleNameMapper::GetHTMLUINameArray
123 );
124 };
125
GetCharMap(bool bProgName)126 NameToIdHash GetCharMap(bool bProgName)
127 {
128 return HashFromRange(0,
129 RES_POOLCHR_NORMAL_BEGIN, RES_POOLCHR_NORMAL_END, bProgName ? &SwStyleNameMapper::GetChrFormatProgNameArray : &SwStyleNameMapper::GetChrFormatUINameArray,
130 RES_POOLCHR_HTML_BEGIN, RES_POOLCHR_HTML_END, bProgName ? &SwStyleNameMapper::GetHTMLChrFormatProgNameArray : &SwStyleNameMapper::GetHTMLChrFormatUINameArray
131 );
132 };
133
GetFrameMap(bool bProgName)134 NameToIdHash GetFrameMap(bool bProgName)
135 {
136 return HashFromRange(0,
137 RES_POOLFRM_BEGIN, RES_POOLFRM_END, bProgName ? &SwStyleNameMapper::GetFrameFormatProgNameArray : &SwStyleNameMapper::GetFrameFormatUINameArray
138 );
139 };
140
GetPageMap(bool bProgName)141 NameToIdHash GetPageMap(bool bProgName)
142 {
143 return HashFromRange(0,
144 RES_POOLPAGE_BEGIN, RES_POOLPAGE_END, bProgName ? &SwStyleNameMapper::GetPageDescProgNameArray : &SwStyleNameMapper::GetPageDescUINameArray
145 );
146 };
147
GetNumRuleMap(bool bProgName)148 NameToIdHash GetNumRuleMap(bool bProgName)
149 {
150 return HashFromRange(0,
151 RES_POOLNUMRULE_BEGIN, RES_POOLNUMRULE_END, bProgName ? &SwStyleNameMapper::GetNumRuleProgNameArray : &SwStyleNameMapper::GetNumRuleUINameArray
152 );
153 };
154
GetTableStyleMap(bool bProgName)155 NameToIdHash GetTableStyleMap(bool bProgName)
156 {
157 return HashFromRange(0,
158 RES_POOLTABLESTYLE_BEGIN, RES_POOLTABLESTYLE_END, bProgName ? &SwStyleNameMapper::GetTableStyleProgNameArray : &SwStyleNameMapper::GetTableStyleUINameArray
159 );
160 };
161
GetCellStyleMap(bool bProgName)162 NameToIdHash GetCellStyleMap(bool bProgName)
163 {
164 return HashFromRange(0,
165 RES_POOLCELLSTYLE_BEGIN, RES_POOLCELLSTYLE_END, bProgName ? &SwStyleNameMapper::GetCellStyleProgNameArray : &SwStyleNameMapper::GetCellStyleUINameArray
166 );
167 };
168
169 } // namespace
170
171 #ifdef _NEED_TO_DEBUG_MAPPING
testNameTable(SwGetPoolIdFromName const nFamily,sal_uInt16 const nStartIndex,sal_uInt16 const nEndIndex)172 void SwStyleNameMapper::testNameTable( SwGetPoolIdFromName const nFamily, sal_uInt16 const nStartIndex, sal_uInt16 const nEndIndex )
173 {
174 sal_uInt16 nIndex;
175 sal_uInt16 nId;
176
177 for ( nIndex = 0, nId = nStartIndex ; nId < nEndIndex ; nId++,nIndex++ )
178 {
179 OUString aString, bString;
180 FillUIName ( nId, aString );
181 bString = GetProgName ( nFamily, aString );
182 sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nFamily );
183 FillProgName ( nNewId, aString );
184 bString = GetUIName ( aString, nFamily );
185 nNewId = GetPoolIdFromUIName ( aString, nFamily );
186 if ( nNewId != nId )
187 abort();
188 }
189 }
190 #endif
191
getHashTable(SwGetPoolIdFromName eFlags,bool bProgName)192 const NameToIdHash & SwStyleNameMapper::getHashTable ( SwGetPoolIdFromName eFlags, bool bProgName )
193 {
194 #ifdef _NEED_TO_DEBUG_MAPPING
195 static bool bTested = false;
196 if ( !bTested )
197 {
198 bTested = true;
199
200 testNameTable( SwGetPoolIdFromName::TxtColl, RES_POOLCOLL_TEXT_BEGIN, RES_POOLCOLL_TEXT_END );
201 testNameTable( SwGetPoolIdFromName::TxtColl, RES_POOLCOLL_LISTS_BEGIN, RES_POOLCOLL_LISTS_END );
202 testNameTable( SwGetPoolIdFromName::TxtColl, RES_POOLCOLL_EXTRA_BEGIN, RES_POOLCOLL_EXTRA_END );
203 testNameTable( SwGetPoolIdFromName::TxtColl, RES_POOLCOLL_REGISTER_BEGIN, RES_POOLCOLL_REGISTER_END );
204 testNameTable( SwGetPoolIdFromName::TxtColl, RES_POOLCOLL_DOC_BEGIN, RES_POOLCOLL_DOC_END );
205 testNameTable( SwGetPoolIdFromName::TxtColl, RES_POOLCOLL_HTML_BEGIN, RES_POOLCOLL_HTML_END );
206 testNameTable( SwGetPoolIdFromName::ChrFmt, RES_POOLCHR_NORMAL_BEGIN, RES_POOLCHR_NORMAL_END );
207 testNameTable( SwGetPoolIdFromName::ChrFmt, RES_POOLCHR_HTML_BEGIN, RES_POOLCHR_HTML_END );
208 testNameTable( SwGetPoolIdFromName::FrmFmt, RES_POOLFRM_BEGIN, RES_POOLFRM_END );
209 testNameTable( SwGetPoolIdFromName::PageDesc, RES_POOLPAGE_BEGIN, RES_POOLPAGE_END );
210 testNameTable( SwGetPoolIdFromName::NumRule, RES_POOLNUMRULE_BEGIN, RES_POOLNUMRULE_END );
211 }
212 #endif
213
214 switch ( eFlags )
215 {
216 case SwGetPoolIdFromName::TxtColl:
217 return TablePair<GetParaMap>::getMap(bProgName);
218 case SwGetPoolIdFromName::ChrFmt:
219 return TablePair<GetCharMap>::getMap(bProgName);
220 case SwGetPoolIdFromName::FrmFmt:
221 return TablePair<GetFrameMap>::getMap(bProgName);
222 case SwGetPoolIdFromName::PageDesc:
223 return TablePair<GetPageMap>::getMap(bProgName);
224 case SwGetPoolIdFromName::NumRule:
225 return TablePair<GetNumRuleMap>::getMap(bProgName);
226 case SwGetPoolIdFromName::TabStyle:
227 return TablePair<GetTableStyleMap>::getMap(bProgName);
228 case SwGetPoolIdFromName::CellStyle:
229 return TablePair<GetCellStyleMap>::getMap(bProgName);
230 }
231
232 assert(false); // must not reach here
233 abort();
234 }
235
236 // This gets the UI name from the programmatic name
GetUIName(const OUString & rName,SwGetPoolIdFromName const eFlags)237 const OUString& SwStyleNameMapper::GetUIName(const OUString& rName,
238 SwGetPoolIdFromName const eFlags)
239 {
240 sal_uInt16 nId = GetPoolIdFromProgName ( rName, eFlags );
241 return nId != USHRT_MAX ? GetUIName( nId, rName ) : rName;
242 }
243
244 // Get the programmatic name from the UI name
GetProgName(const OUString & rName,SwGetPoolIdFromName const eFlags)245 const OUString& SwStyleNameMapper::GetProgName(
246 const OUString& rName, SwGetPoolIdFromName const eFlags)
247 {
248 sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags );
249 return nId != USHRT_MAX ? GetProgName( nId, rName ) : rName;
250 }
251
252 // Get the programmatic name from the UI name in rName and put it into rFillName
FillProgName(const OUString & rName,OUString & rFillName,SwGetPoolIdFromName const eFlags)253 void SwStyleNameMapper::FillProgName(
254 const OUString& rName, OUString& rFillName,
255 SwGetPoolIdFromName const eFlags)
256 {
257 sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags );
258 if ( nId == USHRT_MAX )
259 {
260 // rName isn't in our UI name table...check if it's in the programmatic one
261 nId = GetPoolIdFromProgName ( rName, eFlags );
262
263 rFillName = rName;
264 if (nId == USHRT_MAX )
265 {
266 // It isn't ...make sure the suffix isn't already " (user)"...if it is,
267 // we need to add another one
268 if (lcl_SuffixIsUser(rFillName))
269 rFillName += " (user)";
270 }
271 else
272 {
273 // It's in the programmatic name table...append suffix
274 rFillName += " (user)";
275 }
276 }
277 else
278 {
279 // If we aren't trying to disambiguate, then just do a normal fill
280 fillNameFromId(nId, rFillName, true);
281 }
282
283 if (eFlags == SwGetPoolIdFromName::ChrFmt && rName == SwResId(STR_POOLCHR_STANDARD))
284 rFillName = "Standard";
285 }
286
287 // Get the UI name from the programmatic name in rName and put it into rFillName
FillUIName(const OUString & rName,OUString & rFillName,SwGetPoolIdFromName const eFlags)288 void SwStyleNameMapper::FillUIName(
289 const OUString& rName, OUString& rFillName,
290 SwGetPoolIdFromName const eFlags)
291 {
292 OUString aName = rName;
293 if (eFlags == SwGetPoolIdFromName::ChrFmt && rName == "Standard")
294 aName = SwResId(STR_POOLCHR_STANDARD);
295
296 sal_uInt16 nId = GetPoolIdFromProgName ( aName, eFlags );
297 if ( nId == USHRT_MAX )
298 {
299 rFillName = aName;
300 // aName isn't in our Prog name table...check if it has a " (user)" suffix, if so remove it
301 lcl_CheckSuffixAndDelete ( rFillName );
302 }
303 else
304 {
305 // If we aren't trying to disambiguate, then just do a normal fill
306 fillNameFromId(nId, rFillName, false);
307 }
308 }
309
getNameFromId(sal_uInt16 const nId,const OUString & rFillName,bool const bProgName)310 const OUString& SwStyleNameMapper::getNameFromId(
311 sal_uInt16 const nId, const OUString& rFillName, bool const bProgName)
312 {
313 sal_uInt16 nStt = 0;
314 const std::vector<OUString>* pStrArr = nullptr;
315
316 switch( (USER_FMT | COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID) & nId )
317 {
318 case COLL_TEXT_BITS:
319 if( RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END )
320 {
321 pStrArr = bProgName ? &GetTextProgNameArray() : &GetTextUINameArray();
322 nStt = RES_POOLCOLL_TEXT_BEGIN;
323 }
324 break;
325 case COLL_LISTS_BITS:
326 if( RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END )
327 {
328 pStrArr = bProgName ? &GetListsProgNameArray() : &GetListsUINameArray();
329 nStt = RES_POOLCOLL_LISTS_BEGIN;
330 }
331 break;
332 case COLL_EXTRA_BITS:
333 if( RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END )
334 {
335 pStrArr = bProgName ? &GetExtraProgNameArray() : &GetExtraUINameArray();
336 nStt = RES_POOLCOLL_EXTRA_BEGIN;
337 }
338 break;
339 case COLL_REGISTER_BITS:
340 if( RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END )
341 {
342 pStrArr = bProgName ? &GetRegisterProgNameArray() : &GetRegisterUINameArray();
343 nStt = RES_POOLCOLL_REGISTER_BEGIN;
344 }
345 break;
346 case COLL_DOC_BITS:
347 if( RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END )
348 {
349 pStrArr = bProgName ? &GetDocProgNameArray() : &GetDocUINameArray();
350 nStt = RES_POOLCOLL_DOC_BEGIN;
351 }
352 break;
353 case COLL_HTML_BITS:
354 if( RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END )
355 {
356 pStrArr = bProgName ? &GetHTMLProgNameArray() : &GetHTMLUINameArray();
357 nStt = RES_POOLCOLL_HTML_BEGIN;
358 }
359 break;
360 case POOLGRP_CHARFMT:
361 if( RES_POOLCHR_NORMAL_BEGIN <= nId && nId < RES_POOLCHR_NORMAL_END )
362 {
363 pStrArr = bProgName ? &GetChrFormatProgNameArray() : &GetChrFormatUINameArray();
364 nStt = RES_POOLCHR_NORMAL_BEGIN;
365 }
366 else if( RES_POOLCHR_HTML_BEGIN <= nId && nId < RES_POOLCHR_HTML_END )
367 {
368 pStrArr = bProgName ? &GetHTMLChrFormatProgNameArray() : &GetHTMLChrFormatUINameArray();
369 nStt = RES_POOLCHR_HTML_BEGIN;
370 }
371 break;
372 case POOLGRP_FRAMEFMT:
373 if( RES_POOLFRM_BEGIN <= nId && nId < RES_POOLFRM_END )
374 {
375 pStrArr = bProgName ? &GetFrameFormatProgNameArray() : &GetFrameFormatUINameArray();
376 nStt = RES_POOLFRM_BEGIN;
377 }
378 break;
379 case POOLGRP_PAGEDESC:
380 if( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END )
381 {
382 pStrArr = bProgName ? &GetPageDescProgNameArray() : &GetPageDescUINameArray();
383 nStt = RES_POOLPAGE_BEGIN;
384 }
385 break;
386 case POOLGRP_NUMRULE:
387 if( RES_POOLNUMRULE_BEGIN <= nId && nId < RES_POOLNUMRULE_END )
388 {
389 pStrArr = bProgName ? &GetNumRuleProgNameArray() : &GetNumRuleUINameArray();
390 nStt = RES_POOLNUMRULE_BEGIN;
391 }
392 break;
393 case POOLGRP_TABSTYLE:
394 if( RES_POOLTABLESTYLE_BEGIN <= nId && nId < RES_POOLTABLESTYLE_END )
395 {
396 pStrArr = bProgName ? &GetTableStyleProgNameArray() : &GetTableStyleUINameArray();
397 nStt = RES_POOLTABLESTYLE_BEGIN;
398 }
399 break;
400 }
401 return pStrArr ? pStrArr->operator[](nId - nStt) : rFillName;
402 }
403
fillNameFromId(sal_uInt16 const nId,OUString & rFillName,bool bProgName)404 void SwStyleNameMapper::fillNameFromId(
405 sal_uInt16 const nId, OUString& rFillName, bool bProgName)
406 {
407 rFillName = getNameFromId(nId, rFillName, bProgName);
408 }
409
410 // Get the UI name from the pool ID
FillUIName(sal_uInt16 const nId,OUString & rFillName)411 void SwStyleNameMapper::FillUIName(sal_uInt16 const nId, OUString& rFillName)
412 {
413 fillNameFromId(nId, rFillName, false);
414 }
415
416 // Get the UI name from the pool ID
GetUIName(sal_uInt16 const nId,const OUString & rName)417 const OUString& SwStyleNameMapper::GetUIName(
418 sal_uInt16 const nId, const OUString& rName)
419 {
420 return getNameFromId(nId, rName, false);
421 }
422
423 // Get the programmatic name from the pool ID
FillProgName(sal_uInt16 nId,OUString & rFillName)424 void SwStyleNameMapper::FillProgName(sal_uInt16 nId, OUString& rFillName)
425 {
426 fillNameFromId(nId, rFillName, true);
427 }
428
429 // Get the programmatic name from the pool ID
430 const OUString&
GetProgName(sal_uInt16 const nId,const OUString & rName)431 SwStyleNameMapper::GetProgName(sal_uInt16 const nId, const OUString& rName)
432 {
433 return getNameFromId(nId, rName, true);
434 }
435
436 // This gets the PoolId from the UI Name
GetPoolIdFromUIName(const OUString & rName,SwGetPoolIdFromName const eFlags)437 sal_uInt16 SwStyleNameMapper::GetPoolIdFromUIName(
438 const OUString& rName, SwGetPoolIdFromName const eFlags)
439 {
440 const NameToIdHash & rHashMap = getHashTable ( eFlags, false );
441 NameToIdHash::const_iterator aIter = rHashMap.find(rName);
442 return aIter != rHashMap.end() ? (*aIter).second : USHRT_MAX;
443 }
444
445 // Get the Pool ID from the programmatic name
GetPoolIdFromProgName(const OUString & rName,SwGetPoolIdFromName const eFlags)446 sal_uInt16 SwStyleNameMapper::GetPoolIdFromProgName(
447 const OUString& rName, SwGetPoolIdFromName const eFlags)
448 {
449 const NameToIdHash & rHashMap = getHashTable ( eFlags, true );
450 NameToIdHash::const_iterator aIter = rHashMap.find(rName);
451 return aIter != rHashMap.end() ? (*aIter).second : USHRT_MAX;
452 }
453
454 // Hard coded Programmatic Name tables
455
456 /// returns an empty array because Cell Names aren't translated
GetCellStyleUINameArray()457 const std::vector<OUString>& SwStyleNameMapper::GetCellStyleUINameArray()
458 {
459 static const std::vector<OUString> s_aCellStyleUINameArray;
460 return s_aCellStyleUINameArray;
461 }
462
GetTextProgNameArray()463 const std::vector<OUString>& SwStyleNameMapper::GetTextProgNameArray()
464 {
465 static const std::vector<OUString> s_aTextProgNameArray = {
466 u"Standard"_ustr, // RES_POOLCOLL_STANDARD
467 u"Text body"_ustr,
468 u"First line indent"_ustr,
469 u"Hanging indent"_ustr,
470 u"Text body indent"_ustr,
471 u"Salutation"_ustr,
472 u"Signature"_ustr,
473 u"List Indent"_ustr, // RES_POOLCOLL_CONFRONTATION
474 u"Marginalia"_ustr,
475 u"Heading"_ustr,
476 u"Heading 1"_ustr,
477 u"Heading 2"_ustr,
478 u"Heading 3"_ustr,
479 u"Heading 4"_ustr,
480 u"Heading 5"_ustr,
481 u"Heading 6"_ustr,
482 u"Heading 7"_ustr,
483 u"Heading 8"_ustr,
484 u"Heading 9"_ustr,
485 u"Heading 10"_ustr, // RES_POOLCOLL_TEXT_END
486 };
487 return s_aTextProgNameArray;
488 }
489
GetListsProgNameArray()490 const std::vector<OUString>& SwStyleNameMapper::GetListsProgNameArray()
491 {
492 static const std::vector<OUString> s_aListsProgNameArray = {
493 u"List"_ustr, // STR_POCO_PRGM_NUMBER_BULLET_BASE
494 u"Numbering 1 Start"_ustr, // STR_POCO_PRGM_NUM_LEVEL1S
495 u"Numbering 1"_ustr,
496 u"Numbering 1 End"_ustr,
497 u"Numbering 1 Cont."_ustr,
498 u"Numbering 2 Start"_ustr,
499 u"Numbering 2"_ustr,
500 u"Numbering 2 End"_ustr,
501 u"Numbering 2 Cont."_ustr,
502 u"Numbering 3 Start"_ustr,
503 u"Numbering 3"_ustr,
504 u"Numbering 3 End"_ustr,
505 u"Numbering 3 Cont."_ustr,
506 u"Numbering 4 Start"_ustr,
507 u"Numbering 4"_ustr,
508 u"Numbering 4 End"_ustr,
509 u"Numbering 4 Cont."_ustr,
510 u"Numbering 5 Start"_ustr,
511 u"Numbering 5"_ustr,
512 u"Numbering 5 End"_ustr,
513 u"Numbering 5 Cont."_ustr,
514 u"List 1 Start"_ustr,
515 u"List 1"_ustr,
516 u"List 1 End"_ustr,
517 u"List 1 Cont."_ustr,
518 u"List 2 Start"_ustr,
519 u"List 2"_ustr,
520 u"List 2 End"_ustr,
521 u"List 2 Cont."_ustr,
522 u"List 3 Start"_ustr,
523 u"List 3"_ustr,
524 u"List 3 End"_ustr,
525 u"List 3 Cont."_ustr,
526 u"List 4 Start"_ustr,
527 u"List 4"_ustr,
528 u"List 4 End"_ustr,
529 u"List 4 Cont."_ustr,
530 u"List 5 Start"_ustr,
531 u"List 5"_ustr,
532 u"List 5 End"_ustr,
533 u"List 5 Cont."_ustr, // STR_POCO_PRGM_BULLET_NONUM5
534 };
535 return s_aListsProgNameArray;
536 }
537
GetExtraProgNameArray()538 const std::vector<OUString>& SwStyleNameMapper::GetExtraProgNameArray()
539 {
540 static const std::vector<OUString> s_aExtraProgNameArray = {
541 u"Header and Footer"_ustr, // RES_POOLCOLL_EXTRA_BEGIN
542 u"Header"_ustr,
543 u"Header left"_ustr,
544 u"Header right"_ustr,
545 u"Footer"_ustr,
546 u"Footer left"_ustr,
547 u"Footer right"_ustr,
548 u"Table Contents"_ustr,
549 u"Table Heading"_ustr,
550 u"Caption"_ustr,
551 u"Illustration"_ustr,
552 u"Table"_ustr,
553 u"Text"_ustr,
554 u"Figure"_ustr, // RES_POOLCOLL_LABEL_FIGURE
555 u"Frame contents"_ustr,
556 u"Footnote"_ustr,
557 u"Addressee"_ustr,
558 u"Sender"_ustr,
559 u"Endnote"_ustr,
560 u"Drawing"_ustr,
561 u"Comment"_ustr, // RES_POOLCOLL_COMMENT
562 };
563 return s_aExtraProgNameArray;
564 }
565
GetRegisterProgNameArray()566 const std::vector<OUString>& SwStyleNameMapper::GetRegisterProgNameArray()
567 {
568 static const std::vector<OUString> s_aRegisterProgNameArray = {
569 u"Index"_ustr, // STR_POCO_PRGM_REGISTER_BASE
570 u"Index Heading"_ustr, // STR_POCO_PRGM_TOX_IDXH
571 u"Index 1"_ustr,
572 u"Index 2"_ustr,
573 u"Index 3"_ustr,
574 u"Index Separator"_ustr,
575 u"Contents Heading"_ustr,
576 u"Contents 1"_ustr,
577 u"Contents 2"_ustr,
578 u"Contents 3"_ustr,
579 u"Contents 4"_ustr,
580 u"Contents 5"_ustr,
581 u"User Index Heading"_ustr,
582 u"User Index 1"_ustr,
583 u"User Index 2"_ustr,
584 u"User Index 3"_ustr,
585 u"User Index 4"_ustr,
586 u"User Index 5"_ustr,
587 u"Contents 6"_ustr,
588 u"Contents 7"_ustr,
589 u"Contents 8"_ustr,
590 u"Contents 9"_ustr,
591 u"Contents 10"_ustr,
592 u"Figure Index Heading"_ustr,
593 u"Figure Index 1"_ustr,
594 u"Object index heading"_ustr,
595 u"Object index 1"_ustr,
596 u"Table index heading"_ustr,
597 u"Table index 1"_ustr,
598 u"Bibliography Heading"_ustr,
599 u"Bibliography 1"_ustr,
600 u"User Index 6"_ustr,
601 u"User Index 7"_ustr,
602 u"User Index 8"_ustr,
603 u"User Index 9"_ustr,
604 u"User Index 10"_ustr, // STR_POCO_PRGM_TOX_USER10
605 };
606 return s_aRegisterProgNameArray;
607 }
608
GetDocProgNameArray()609 const std::vector<OUString>& SwStyleNameMapper::GetDocProgNameArray()
610 {
611 static const std::vector<OUString> s_aDocProgNameArray = {
612 u"Title"_ustr, // STR_POCO_PRGM_DOC_TITLE
613 u"Subtitle"_ustr,
614 u"Appendix"_ustr,
615 };
616 return s_aDocProgNameArray;
617 }
618
GetHTMLProgNameArray()619 const std::vector<OUString>& SwStyleNameMapper::GetHTMLProgNameArray()
620 {
621 static const std::vector<OUString> s_aHTMLProgNameArray = {
622 u"Quotations"_ustr,
623 u"Preformatted Text"_ustr,
624 u"Horizontal Line"_ustr,
625 u"List Contents"_ustr,
626 u"List Heading"_ustr, // STR_POCO_PRGM_HTML_DT
627 };
628 return s_aHTMLProgNameArray;
629 }
630
GetFrameFormatProgNameArray()631 const std::vector<OUString>& SwStyleNameMapper::GetFrameFormatProgNameArray()
632 {
633 static const std::vector<OUString> s_aFrameFormatProgNameArray = {
634 u"Frame"_ustr, // RES_POOLFRM_FRAME
635 u"Graphics"_ustr,
636 u"OLE"_ustr,
637 u"Formula"_ustr,
638 u"Marginalia"_ustr,
639 u"Watermark"_ustr,
640 u"Labels"_ustr, // RES_POOLFRM_LABEL
641 };
642 return s_aFrameFormatProgNameArray;
643 }
644
GetChrFormatProgNameArray()645 const std::vector<OUString>& SwStyleNameMapper::GetChrFormatProgNameArray()
646 {
647 static const std::vector<OUString> s_aChrFormatProgNameArray = {
648 u"Footnote Symbol"_ustr, // RES_POOLCHR_FOOTNOTE
649 u"Page Number"_ustr,
650 u"Caption characters"_ustr,
651 u"Drop Caps"_ustr,
652 u"Numbering Symbols"_ustr,
653 u"Bullet Symbols"_ustr,
654 u"Internet link"_ustr,
655 u"Visited Internet Link"_ustr,
656 u"Placeholder"_ustr,
657 u"Index Link"_ustr,
658 u"Endnote Symbol"_ustr,
659 u"Line numbering"_ustr,
660 u"Main index entry"_ustr,
661 u"Footnote anchor"_ustr,
662 u"Endnote anchor"_ustr,
663 u"Rubies"_ustr, // RES_POOLCHR_RUBYTEXT
664 u"Vertical Numbering Symbols"_ustr, // RES_POOLCHR_VERT_NUMBER
665 };
666 return s_aChrFormatProgNameArray;
667 }
668
GetHTMLChrFormatProgNameArray()669 const std::vector<OUString>& SwStyleNameMapper::GetHTMLChrFormatProgNameArray()
670 {
671 static const std::vector<OUString> s_aHTMLChrFormatProgNameArray = {
672 u"Emphasis"_ustr, // RES_POOLCHR_HTML_EMPHASIS
673 u"Citation"_ustr,
674 u"Strong Emphasis"_ustr,
675 u"Source Text"_ustr,
676 u"Example"_ustr,
677 u"User Entry"_ustr,
678 u"Variable"_ustr,
679 u"Definition"_ustr,
680 u"Teletype"_ustr, // RES_POOLCHR_HTML_TELETYPE
681 };
682 return s_aHTMLChrFormatProgNameArray;
683 }
684
GetPageDescProgNameArray()685 const std::vector<OUString>& SwStyleNameMapper::GetPageDescProgNameArray()
686 {
687 static const std::vector<OUString> s_aPageDescProgNameArray = {
688 u"Standard"_ustr, // STR_POOLPAGE_PRGM_STANDARD
689 u"First Page"_ustr,
690 u"Left Page"_ustr,
691 u"Right Page"_ustr,
692 u"Envelope"_ustr,
693 u"Index"_ustr,
694 u"HTML"_ustr,
695 u"Footnote"_ustr,
696 u"Endnote"_ustr, // STR_POOLPAGE_PRGM_ENDNOTE
697 u"Landscape"_ustr,
698 };
699 return s_aPageDescProgNameArray;
700 }
701
GetNumRuleProgNameArray()702 const std::vector<OUString>& SwStyleNameMapper::GetNumRuleProgNameArray()
703 {
704 static const std::vector<OUString> s_aNumRuleProgNameArray = {
705 u"No List"_ustr,
706 u"Numbering 123"_ustr, // STR_POOLNUMRULE_PRGM_NUM1
707 u"Numbering ABC"_ustr,
708 u"Numbering abc"_ustr,
709 u"Numbering IVX"_ustr,
710 u"Numbering ivx"_ustr,
711 u"List 1"_ustr,
712 u"List 2"_ustr,
713 u"List 3"_ustr,
714 u"List 4"_ustr,
715 u"List 5"_ustr, // STR_POOLNUMRULE_PRGM_BUL5
716 };
717 return s_aNumRuleProgNameArray;
718 }
719
GetTableStyleProgNameArray()720 const std::vector<OUString>& SwStyleNameMapper::GetTableStyleProgNameArray()
721 {
722 // XXX MUST match the entries of STR_TABSTYLE_ARY in
723 // sw/source/core/doc/DocumentStylePoolManager.cxx and MUST match the order of
724 // RES_POOL_TABLESTYLE_TYPE in sw/inc/poolfmt.hxx
725 static const std::vector<OUString> s_aTableStyleProgNameArray = {
726 u"Default Style"_ustr, // RES_POOLTABLESTYLE_DEFAULT
727 u"3D"_ustr, // RES_POOLTABLESTYLE_3D
728 u"Black 1"_ustr, // RES_POOLTABLESTYLE_BLACK1
729 u"Black 2"_ustr, // RES_POOLTABLESTYLE_BLACK2
730 u"Blue"_ustr, // RES_POOLTABLESTYLE_BLUE
731 u"Brown"_ustr, // RES_POOLTABLESTYLE_BROWN
732 u"Currency"_ustr, // RES_POOLTABLESTYLE_CURRENCY
733 u"Currency 3D"_ustr, // RES_POOLTABLESTYLE_CURRENCY_3D
734 u"Currency Gray"_ustr, // RES_POOLTABLESTYLE_CURRENCY_GRAY
735 u"Currency Lavender"_ustr, // RES_POOLTABLESTYLE_CURRENCY_LAVENDER
736 u"Currency Turquoise"_ustr, // RES_POOLTABLESTYLE_CURRENCY_TURQUOISE
737 u"Gray"_ustr, // RES_POOLTABLESTYLE_GRAY
738 u"Green"_ustr, // RES_POOLTABLESTYLE_GREEN
739 u"Lavender"_ustr, // RES_POOLTABLESTYLE_LAVENDER
740 u"Red"_ustr, // RES_POOLTABLESTYLE_RED
741 u"Turquoise"_ustr, // RES_POOLTABLESTYLE_TURQUOISE
742 u"Yellow"_ustr, // RES_POOLTABLESTYLE_YELLOW
743 u"Academic"_ustr, // RES_POOLTABLESTYLE_LO6_ACADEMIC
744 u"Box List Blue"_ustr, // RES_POOLTABLESTYLE_LO6_BOX_LIST_BLUE
745 u"Box List Green"_ustr, // RES_POOLTABLESTYLE_LO6_BOX_LIST_GREEN
746 u"Box List Red"_ustr, // RES_POOLTABLESTYLE_LO6_BOX_LIST_RED
747 u"Box List Yellow"_ustr, // RES_POOLTABLESTYLE_LO6_BOX_LIST_YELLOW
748 u"Elegant"_ustr, // RES_POOLTABLESTYLE_LO6_ELEGANT
749 u"Financial"_ustr, // RES_POOLTABLESTYLE_LO6_FINANCIAL
750 u"Simple Grid Columns"_ustr, // RES_POOLTABLESTYLE_LO6_SIMPLE_GRID_COLUMNS
751 u"Simple Grid Rows"_ustr, // RES_POOLTABLESTYLE_LO6_SIMPLE_GRID_ROWS
752 u"Simple List Shaded"_ustr, // RES_POOLTABLESTYLE_LO6_SIMPLE_LIST_SHADED
753 };
754 return s_aTableStyleProgNameArray;
755 }
756
757 /// returns an empty array because Cell Names aren't translated
GetCellStyleProgNameArray()758 const std::vector<OUString>& SwStyleNameMapper::GetCellStyleProgNameArray()
759 {
760 static const std::vector<OUString> s_aCellStyleProgNameArray;
761 return s_aCellStyleProgNameArray;
762 }
763
764 const OUString &
GetSpecialExtraProgName(const OUString & rExtraUIName)765 SwStyleNameMapper::GetSpecialExtraProgName(const OUString& rExtraUIName)
766 {
767 return lcl_GetSpecialExtraName( rExtraUIName, true );
768 }
769
770 const OUString &
GetSpecialExtraUIName(const OUString & rExtraProgName)771 SwStyleNameMapper::GetSpecialExtraUIName(const OUString& rExtraProgName)
772 {
773 return lcl_GetSpecialExtraName( rExtraProgName, false );
774 }
775
776 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
777