LibreOffice Module sw (master)  1
SwStyleNameMapper.cxx
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 #include <numeric>
21 #include <tuple>
22 
23 #include <SwStyleNameMapper.hxx>
24 #include <poolfmt.hxx>
25 #include <strings.hrc>
26 #include <swtypes.hxx>
27 
28 #ifdef _NEED_TO_DEBUG_MAPPING
29 #include <stdlib.h>
30 #endif
31 
32 // Initialise programmatic names to 0
33 std::vector<OUString>
47 
55 
63 
64 // SwTableEntry so we can pass the length to the String CTOR
66 {
68  const sal_Char *pChar;
69 };
70 
71 namespace
72 {
73 
74 #define ENTRY( s ) { sizeof (s)-1, s }
75 
76 // Hard coded Programmatic Name tables
77 const struct SwTableEntry TextProgNameTable [] =
78 {
79  ENTRY( "Standard" ), // RES_POOLCOLL_STANDARD
80  ENTRY( "Text body" ),
81  ENTRY( "First line indent" ),
82  ENTRY( "Hanging indent" ),
83  ENTRY( "Text body indent" ),
84  ENTRY( "Salutation" ),
85  ENTRY( "Signature" ),
86  ENTRY( "List Indent" ), // RES_POOLCOLL_CONFRONTATION
87  ENTRY( "Marginalia" ),
88  ENTRY( "Heading" ),
89  ENTRY( "Heading 1" ),
90  ENTRY( "Heading 2" ),
91  ENTRY( "Heading 3" ),
92  ENTRY( "Heading 4" ),
93  ENTRY( "Heading 5" ),
94  ENTRY( "Heading 6" ),
95  ENTRY( "Heading 7" ),
96  ENTRY( "Heading 8" ),
97  ENTRY( "Heading 9" ),
98  ENTRY( "Heading 10" ), // RES_POOLCOLL_TEXT_END
99  { 0, nullptr }
100 };
101 
102 const struct SwTableEntry ListsProgNameTable [] =
103 {
104  ENTRY( "List" ), // STR_POCO_PRGM_NUMBUL_BASE
105  ENTRY( "Numbering 1 Start" ), // STR_POCO_PRGM_NUM_LEVEL1S
106  ENTRY( "Numbering 1" ),
107  ENTRY( "Numbering 1 End" ),
108  ENTRY( "Numbering 1 Cont." ),
109  ENTRY( "Numbering 2 Start" ),
110  ENTRY( "Numbering 2" ),
111  ENTRY( "Numbering 2 End" ),
112  ENTRY( "Numbering 2 Cont." ),
113  ENTRY( "Numbering 3 Start" ),
114  ENTRY( "Numbering 3" ),
115  ENTRY( "Numbering 3 End" ),
116  ENTRY( "Numbering 3 Cont." ),
117  ENTRY( "Numbering 4 Start" ),
118  ENTRY( "Numbering 4" ),
119  ENTRY( "Numbering 4 End" ),
120  ENTRY( "Numbering 4 Cont." ),
121  ENTRY( "Numbering 5 Start" ),
122  ENTRY( "Numbering 5" ),
123  ENTRY( "Numbering 5 End" ),
124  ENTRY( "Numbering 5 Cont." ),
125  ENTRY( "List 1 Start" ),
126  ENTRY( "List 1" ),
127  ENTRY( "List 1 End" ),
128  ENTRY( "List 1 Cont." ),
129  ENTRY( "List 2 Start" ),
130  ENTRY( "List 2" ),
131  ENTRY( "List 2 End" ),
132  ENTRY( "List 2 Cont." ),
133  ENTRY( "List 3 Start" ),
134  ENTRY( "List 3" ),
135  ENTRY( "List 3 End" ),
136  ENTRY( "List 3 Cont." ),
137  ENTRY( "List 4 Start" ),
138  ENTRY( "List 4" ),
139  ENTRY( "List 4 End" ),
140  ENTRY( "List 4 Cont." ),
141  ENTRY( "List 5 Start" ),
142  ENTRY( "List 5" ),
143  ENTRY( "List 5 End" ),
144  ENTRY( "List 5 Cont." ), // STR_POCO_PRGM_BUL_NONUM5
145  { 0, nullptr }
146 };
147 
148 const struct SwTableEntry ExtraProgNameTable [] =
149 {
150  ENTRY( "Header and Footer" ), // RES_POOLCOLL_EXTRA_BEGIN
151  ENTRY( "Header" ),
152  ENTRY( "Header left" ),
153  ENTRY( "Header right" ),
154  ENTRY( "Footer" ),
155  ENTRY( "Footer left" ),
156  ENTRY( "Footer right" ),
157  ENTRY( "Table Contents" ),
158  ENTRY( "Table Heading" ),
159  ENTRY( "Caption" ),
160  ENTRY( "Illustration" ),
161  ENTRY( "Table" ),
162  ENTRY( "Text" ),
163  ENTRY( "Figure" ),//RES_POOLCOLL_LABEL_FIGURE
164  ENTRY( "Frame contents" ),
165  ENTRY( "Footnote" ),
166  ENTRY( "Addressee" ),
167  ENTRY( "Sender" ),
168  ENTRY( "Endnote" ),
169  ENTRY( "Drawing" ), // RES_POOLCOLL_LABEL_DRAWING
170  { 0, nullptr }
171 };
172 
173 const struct SwTableEntry RegisterProgNameTable [] =
174 {
175  ENTRY( "Index" ), // STR_POCO_PRGM_REGISTER_BASE
176  ENTRY( "Index Heading" ), // STR_POCO_PRGM_TOX_IDXH
177  ENTRY( "Index 1" ),
178  ENTRY( "Index 2" ),
179  ENTRY( "Index 3" ),
180  ENTRY( "Index Separator" ),
181  ENTRY( "Contents Heading" ),
182  ENTRY( "Contents 1" ),
183  ENTRY( "Contents 2" ),
184  ENTRY( "Contents 3" ),
185  ENTRY( "Contents 4" ),
186  ENTRY( "Contents 5" ),
187  ENTRY( "User Index Heading" ),
188  ENTRY( "User Index 1" ),
189  ENTRY( "User Index 2" ),
190  ENTRY( "User Index 3" ),
191  ENTRY( "User Index 4" ),
192  ENTRY( "User Index 5" ),
193  ENTRY( "Contents 6" ),
194  ENTRY( "Contents 7" ),
195  ENTRY( "Contents 8" ),
196  ENTRY( "Contents 9" ),
197  ENTRY( "Contents 10" ),
198  ENTRY( "Figure Index Heading" ),
199  ENTRY( "Figure Index 1" ),
200  ENTRY( "Object index heading" ),
201  ENTRY( "Object index 1" ),
202  ENTRY( "Table index heading" ),
203  ENTRY( "Table index 1" ),
204  ENTRY( "Bibliography Heading" ),
205  ENTRY( "Bibliography 1" ),
206  ENTRY( "User Index 6" ),
207  ENTRY( "User Index 7" ),
208  ENTRY( "User Index 8" ),
209  ENTRY( "User Index 9" ),
210  ENTRY( "User Index 10" ), // STR_POCO_PRGM_TOX_USER10
211  { 0, nullptr }
212 };
213 
214 const struct SwTableEntry DocProgNameTable [] =
215 {
216  ENTRY( "Title" ), // STR_POCO_PRGM_DOC_TITEL
217  ENTRY( "Subtitle" ),
218  { 0, nullptr }
219 };
220 
221 const struct SwTableEntry HTMLProgNameTable [] =
222 {
223  ENTRY( "Quotations" ),
224  ENTRY( "Preformatted Text" ),
225  ENTRY( "Horizontal Line" ),
226  ENTRY( "List Contents" ),
227  ENTRY( "List Heading" ), // STR_POCO_PRGM_HTML_DT
228  { 0, nullptr }
229 };
230 
231 const struct SwTableEntry FrameFormatProgNameTable [] =
232 {
233  ENTRY( "Frame" ), // RES_POOLFRM_FRAME
234  ENTRY( "Graphics" ),
235  ENTRY( "OLE" ),
236  ENTRY( "Formula" ),
237  ENTRY( "Marginalia" ),
238  ENTRY( "Watermark" ),
239  ENTRY( "Labels" ), // RES_POOLFRM_LABEL
240  { 0, nullptr }
241 };
242 
243 const struct SwTableEntry ChrFormatProgNameTable [] =
244 {
245  ENTRY( "Footnote Symbol" ), // RES_POOLCHR_FOOTNOTE
246  ENTRY( "Page Number" ),
247  ENTRY( "Caption characters" ),
248  ENTRY( "Drop Caps" ),
249  ENTRY( "Numbering Symbols" ),
250  ENTRY( "Bullet Symbols" ),
251  ENTRY( "Internet link" ),
252  ENTRY( "Visited Internet Link" ),
253  ENTRY( "Placeholder" ),
254  ENTRY( "Index Link" ),
255  ENTRY( "Endnote Symbol" ),
256  ENTRY( "Line numbering" ),
257  ENTRY( "Main index entry" ),
258  ENTRY( "Footnote anchor" ),
259  ENTRY( "Endnote anchor" ),
260  ENTRY( "Rubies" ), // RES_POOLCHR_RUBYTEXT
261  ENTRY( "Vertical Numbering Symbols" ), // RES_POOLCHR_VERT_NUMBER
262  { 0, nullptr }
263 };
264 
265 const struct SwTableEntry HTMLChrFormatProgNameTable [] =
266 {
267  ENTRY( "Emphasis" ), // RES_POOLCHR_HTML_EMPHASIS
268  ENTRY( "Citation" ),
269  ENTRY( "Strong Emphasis" ),
270  ENTRY( "Source Text" ),
271  ENTRY( "Example" ),
272  ENTRY( "User Entry" ),
273  ENTRY( "Variable" ),
274  ENTRY( "Definition" ),
275  ENTRY( "Teletype" ), // RES_POOLCHR_HTML_TELETYPE
276  { 0, nullptr }
277 };
278 
279 const struct SwTableEntry PageDescProgNameTable [] =
280 {
281  ENTRY( "Standard" ), // STR_POOLPAGE_PRGM_STANDARD
282  ENTRY( "First Page" ),
283  ENTRY( "Left Page" ),
284  ENTRY( "Right Page" ),
285  ENTRY( "Envelope" ),
286  ENTRY( "Index" ),
287  ENTRY( "HTML" ),
288  ENTRY( "Footnote" ),
289  ENTRY( "Endnote" ), // STR_POOLPAGE_PRGM_ENDNOTE
290  ENTRY( "Landscape" ),
291  { 0, nullptr }
292 };
293 
294 const struct SwTableEntry NumRuleProgNameTable [] =
295 {
296  ENTRY( "Numbering 123" ), // STR_POOLNUMRULE_PRGM_NUM1
297  ENTRY( "Numbering ABC" ),
298  ENTRY( "Numbering abc" ),
299  ENTRY( "Numbering IVX" ),
300  ENTRY( "Numbering ivx" ),
301  ENTRY( "List 1" ),
302  ENTRY( "List 2" ),
303  ENTRY( "List 3" ),
304  ENTRY( "List 4" ),
305  ENTRY( "List 5" ), // STR_POOLNUMRULE_PRGM_BUL5
306  { 0, nullptr }
307 };
308 
309 // XXX MUST match the entries of STR_TABSTYLE_ARY in
310 // sw/source/core/doc/DocumentStylePoolManager.cxx and MUST match the order of
311 // RES_POOL_TABSTYLE_TYPE in sw/inc/poolfmt.hxx
312 const struct SwTableEntry TableStyleProgNameTable [] =
313 {
314  ENTRY( "Default Style" ), // RES_POOLTABLESTYLE_DEFAULT
315  ENTRY( "3D" ), // RES_POOLTABLESTYLE_3D
316  ENTRY( "Black 1" ), // RES_POOLTABLESTYLE_BLACK1
317  ENTRY( "Black 2" ), // RES_POOLTABLESTYLE_BLACK2
318  ENTRY( "Blue" ), // RES_POOLTABLESTYLE_BLUE
319  ENTRY( "Brown" ), // RES_POOLTABLESTYLE_BROWN
320  ENTRY( "Currency" ), // RES_POOLTABLESTYLE_CURRENCY
321  ENTRY( "Currency 3D" ), // RES_POOLTABLESTYLE_CURRENCY_3D
322  ENTRY( "Currency Gray" ), // RES_POOLTABLESTYLE_CURRENCY_GRAY
323  ENTRY( "Currency Lavender" ), // RES_POOLTABLESTYLE_CURRENCY_LAVENDER
324  ENTRY( "Currency Turquoise" ),// RES_POOLTABLESTYLE_CURRENCY_TURQUOISE
325  ENTRY( "Gray" ), // RES_POOLTABLESTYLE_GRAY
326  ENTRY( "Green" ), // RES_POOLTABLESTYLE_GREEN
327  ENTRY( "Lavender" ), // RES_POOLTABLESTYLE_LAVENDER
328  ENTRY( "Red" ), // RES_POOLTABLESTYLE_RED
329  ENTRY( "Turquoise" ), // RES_POOLTABLESTYLE_TURQUOISE
330  ENTRY( "Yellow" ), // RES_POOLTABLESTYLE_YELLOW
331  ENTRY( "Academic" ), // RES_POOLTABLESTYLE_LO6_ACADEMIC
332  ENTRY( "Box List Blue" ), // RES_POOLTABLESTYLE_LO6_BOX_LIST_BLUE
333  ENTRY( "Box List Green" ), // RES_POOLTABLESTYLE_LO6_BOX_LIST_GREEN
334  ENTRY( "Box List Red" ), // RES_POOLTABLESTYLE_LO6_BOX_LIST_RED
335  ENTRY( "Box List Yellow" ), // RES_POOLTABLESTYLE_LO6_BOX_LIST_YELLOW
336  ENTRY( "Elegant" ), // RES_POOLTABLESTYLE_LO6_ELEGANT
337  ENTRY( "Financial" ), // RES_POOLTABLESTYLE_LO6_FINANCIAL
338  ENTRY( "Simple Grid Columns" ), // RES_POOLTABLESTYLE_LO6_SIMPLE_GRID_COLUMNS
339  ENTRY( "Simple Grid Rows" ), // RES_POOLTABLESTYLE_LO6_SIMPLE_GRID_ROWS
340  ENTRY( "Simple List Shaded" ),// RES_POOLTABLESTYLE_LO6_SIMPLE_LIST_SHADED
341  { 0, nullptr }
342 };
343 #undef ENTRY
344 
345 std::vector<OUString>*
346 lcl_NewProgNameArray(const SwTableEntry *pTable, sal_uInt8 const nCount)
347 {
348  std::vector<OUString> *const pProgNameArray = new std::vector<OUString>;
349  pProgNameArray->reserve(nCount);
350  while (pTable->nLength)
351  {
352  pProgNameArray->push_back(OUString(
353  pTable->pChar, pTable->nLength, RTL_TEXTENCODING_ASCII_US));
354  pTable++;
355  }
356  return pProgNameArray;
357 }
358 
359 OUString
360 lcl_GetSpecialExtraName(const OUString& rExtraName, const bool bIsUIName )
361 {
362  const std::vector<OUString>& rExtraArr = bIsUIName
364  : SwStyleNameMapper::GetExtraProgNameArray();
365  static const sal_uInt16 nIds[] =
366  {
372  0
373  };
374  const sal_uInt16 * pIds;
375  for ( pIds = nIds; *pIds; ++pIds)
376  {
377  if (rExtraName == rExtraArr[ *pIds ])
378  {
379  return bIsUIName
382  }
383  }
384  return rExtraName;
385 }
386 
387 bool lcl_SuffixIsUser(const OUString & rString)
388 {
389  const sal_Unicode *pChar = rString.getStr();
390  sal_Int32 nLen = rString.getLength();
391  bool bRet = false;
392  if( nLen > 8 &&
393  pChar[nLen-7] == ' ' &&
394  pChar[nLen-6] == '(' &&
395  pChar[nLen-5] == 'u' &&
396  pChar[nLen-4] == 's' &&
397  pChar[nLen-3] == 'e' &&
398  pChar[nLen-2] == 'r' &&
399  pChar[nLen-1] == ')' )
400  bRet = true;
401  return bRet;
402 }
403 
404 void lcl_CheckSuffixAndDelete(OUString & rString)
405 {
406  if (lcl_SuffixIsUser(rString))
407  {
408  rString = rString.copy(0, rString.getLength() - 7);
409  }
410 }
411 
412 typedef std::tuple<sal_uInt16, sal_uInt16, const std::vector<OUString>& (*)() > NameArrayIndexTuple_t;
413 
414 sal_uInt16 lcl_AccumulateIndexCount( sal_uInt16 nSum, const NameArrayIndexTuple_t& tuple ){
415  // Return running sum + (index end) - (index start)
416  return nSum + std::get<1>( tuple ) - std::get<0>( tuple );
417 }
418 }
419 
420 #ifdef _NEED_TO_DEBUG_MAPPING
421 void SwStyleNameMapper::testNameTable( SwGetPoolIdFromName const nFamily, sal_uInt16 const nStartIndex, sal_uInt16 const nEndIndex )
422 {
423  sal_uInt16 nIndex;
424  sal_uInt16 nId;
425 
426  for ( nIndex = 0, nId = nStartIndex ; nId < nEndIndex ; nId++,nIndex++ )
427  {
428  OUString aString, bString;
429  FillUIName ( nId, aString );
430  bString = GetProgName ( nFamily, aString );
431  sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nFamily );
432  FillProgName ( nNewId, aString );
433  bString = GetUIName ( aString, nFamily );
434  nNewId = GetPoolIdFromUIName ( aString, nFamily );
435  if ( nNewId != nId )
436  abort();
437  }
438 }
439 #endif
440 
442 {
443  // pHashPointer is a pointer to a pointer which stores the UI/prog name array
444  NameToIdHash **pHashPointer = nullptr;
445  // Stores tuples representing (index start, index end, pointer to function which returns ref to name array)
446  std::vector<NameArrayIndexTuple_t> vIndexes;
447 
448  switch ( eFlags )
449  {
451  {
452  pHashPointer = bProgName ? &s_pParaProgMap : &s_pParaUIMap;
457  vIndexes.emplace_back(RES_POOLCOLL_DOC_BEGIN, RES_POOLCOLL_DOC_END, bProgName ? &GetDocProgNameArray : &GetDocUINameArray );
459  }
460  break;
462  {
463  pHashPointer = bProgName ? &s_pCharProgMap : &s_pCharUIMap;
466  }
467  break;
469  {
470  pHashPointer = bProgName ? &s_pFrameProgMap : &s_pFrameUIMap;
472  }
473  break;
475  {
476  pHashPointer = bProgName ? &s_pPageProgMap : &s_pPageUIMap;
478  }
479  break;
481  {
482  pHashPointer = bProgName ? &s_pNumRuleProgMap : &s_pNumRuleUIMap;
484  }
485  break;
487  {
488  pHashPointer = bProgName ? &s_pTableStyleProgMap : &s_pTableStyleUIMap;
490  }
491  break;
493  {
494  pHashPointer = bProgName ? &s_pCellStyleProgMap : &s_pCellStyleUIMap;
496  }
497  break;
498  default:
499  assert(false && "unknown pool family");
500  }
501 
502  // Proceed if we have a pointer to a hash, and the hash hasn't already been populated
503  assert(pHashPointer && "null hash pointer");
504  if (!*pHashPointer )
505  {
506  // Compute the size of the hash we need to build
507  sal_uInt16 nSize = std::accumulate( vIndexes.begin(), vIndexes.end(), 0, lcl_AccumulateIndexCount );
508 
509  NameToIdHash *pHash = new NameToIdHash( nSize );
510  for ( const auto& rEntry : vIndexes )
511  {
512  // Get a pointer to the function which will populate pStrings
513  const std::vector<OUString>& (*pStringsFetchFunc)() = std::get<2>( rEntry );
514  if ( pStringsFetchFunc )
515  {
516  const std::vector<OUString>& rStrings = pStringsFetchFunc();
517  sal_uInt16 nIndex, nId;
518  for ( nIndex = 0, nId = std::get<0>( rEntry ) ; nId < std::get<1>( rEntry ) ; nId++, nIndex++ )
519  (*pHash)[rStrings[nIndex]] = nId;
520  }
521  }
522 
523  *pHashPointer = pHash;
524  }
525 
526 #ifdef _NEED_TO_DEBUG_MAPPING
527  static bool bTested = false;
528  if ( !bTested )
529  {
530  bTested = true;
531 
543  }
544 #endif
545  return **pHashPointer;
546 }
547 
548 // This gets the UI name from the programmatic name
549 const OUString& SwStyleNameMapper::GetUIName(const OUString& rName,
550  SwGetPoolIdFromName const eFlags)
551 {
552  sal_uInt16 nId = GetPoolIdFromProgName ( rName, eFlags );
553  return nId != USHRT_MAX ? GetUIName( nId, rName ) : rName;
554 }
555 
556 // Get the programmatic name from the UI name
558  const OUString& rName, SwGetPoolIdFromName const eFlags)
559 {
560  sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags );
561  return nId != USHRT_MAX ? GetProgName( nId, rName ) : rName;
562 }
563 
564 // Get the programmatic name from the UI name in rName and put it into rFillName
566  const OUString& rName, OUString& rFillName,
567  SwGetPoolIdFromName const eFlags)
568 {
569  sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags );
570  if ( nId == USHRT_MAX )
571  {
572  // rName isn't in our UI name table...check if it's in the programmatic one
573  nId = GetPoolIdFromProgName ( rName, eFlags );
574 
575  rFillName = rName;
576  if (nId == USHRT_MAX )
577  {
578  // It isn't ...make sure the suffix isn't already " (user)"...if it is,
579  // we need to add another one
580  if (lcl_SuffixIsUser(rFillName))
581  rFillName += " (user)";
582  }
583  else
584  {
585  // It's in the programmatic name table...append suffix
586  rFillName += " (user)";
587  }
588  }
589  else
590  {
591  // If we aren't trying to disambiguate, then just do a normal fill
592  fillNameFromId(nId, rFillName, true);
593  }
594 
595  if (eFlags == SwGetPoolIdFromName::ChrFmt && rName == SwResId(STR_POOLCOLL_STANDARD))
596  rFillName = "Standard";
597 }
598 
599 // Get the UI name from the programmatic name in rName and put it into rFillName
601  const OUString& rName, OUString& rFillName,
602  SwGetPoolIdFromName const eFlags)
603 {
604  OUString aName = rName;
605  if (eFlags == SwGetPoolIdFromName::ChrFmt && rName == "Standard")
606  aName = SwResId(STR_POOLCOLL_STANDARD);
607 
608  sal_uInt16 nId = GetPoolIdFromProgName ( aName, eFlags );
609  if ( nId == USHRT_MAX )
610  {
611  rFillName = aName;
612  // aName isn't in our Prog name table...check if it has a " (user)" suffix, if so remove it
613  lcl_CheckSuffixAndDelete ( rFillName );
614  }
615  else
616  {
617  // If we aren't trying to disambiguate, then just do a normal fill
618  fillNameFromId(nId, rFillName, false);
619  }
620 }
621 
623  sal_uInt16 const nId, const OUString& rFillName, bool const bProgName)
624 {
625  sal_uInt16 nStt = 0;
626  const std::vector<OUString>* pStrArr = nullptr;
627 
628  switch( (USER_FMT | COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID) & nId )
629  {
630  case COLL_TEXT_BITS:
631  if( RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END )
632  {
633  pStrArr = bProgName ? &GetTextProgNameArray() : &GetTextUINameArray();
635  }
636  break;
637  case COLL_LISTS_BITS:
639  {
640  pStrArr = bProgName ? &GetListsProgNameArray() : &GetListsUINameArray();
642  }
643  break;
644  case COLL_EXTRA_BITS:
646  {
647  pStrArr = bProgName ? &GetExtraProgNameArray() : &GetExtraUINameArray();
649  }
650  break;
651  case COLL_REGISTER_BITS:
653  {
654  pStrArr = bProgName ? &GetRegisterProgNameArray() : &GetRegisterUINameArray();
656  }
657  break;
658  case COLL_DOC_BITS:
659  if( RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END )
660  {
661  pStrArr = bProgName ? &GetDocProgNameArray() : &GetDocUINameArray();
662  nStt = RES_POOLCOLL_DOC_BEGIN;
663  }
664  break;
665  case COLL_HTML_BITS:
666  if( RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END )
667  {
668  pStrArr = bProgName ? &GetHTMLProgNameArray() : &GetHTMLUINameArray();
670  }
671  break;
672  case POOLGRP_CHARFMT:
674  {
675  pStrArr = bProgName ? &GetChrFormatProgNameArray() : &GetChrFormatUINameArray();
677  }
678  else if( RES_POOLCHR_HTML_BEGIN <= nId && nId < RES_POOLCHR_HTML_END )
679  {
680  pStrArr = bProgName ? &GetHTMLChrFormatProgNameArray() : &GetHTMLChrFormatUINameArray();
681  nStt = RES_POOLCHR_HTML_BEGIN;
682  }
683  break;
684  case POOLGRP_FRAMEFMT:
685  if( RES_POOLFRM_BEGIN <= nId && nId < RES_POOLFRM_END )
686  {
687  pStrArr = bProgName ? &GetFrameFormatProgNameArray() : &GetFrameFormatUINameArray();
688  nStt = RES_POOLFRM_BEGIN;
689  }
690  break;
691  case POOLGRP_PAGEDESC:
692  if( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END )
693  {
694  pStrArr = bProgName ? &GetPageDescProgNameArray() : &GetPageDescUINameArray();
695  nStt = RES_POOLPAGE_BEGIN;
696  }
697  break;
698  case POOLGRP_NUMRULE:
699  if( RES_POOLNUMRULE_BEGIN <= nId && nId < RES_POOLNUMRULE_END )
700  {
701  pStrArr = bProgName ? &GetNumRuleProgNameArray() : &GetNumRuleUINameArray();
702  nStt = RES_POOLNUMRULE_BEGIN;
703  }
704  break;
705  case POOLGRP_TABSTYLE:
706  if( RES_POOLTABSTYLE_BEGIN <= nId && nId < RES_POOLTABSTYLE_END )
707  {
708  pStrArr = bProgName ? &GetTableStyleProgNameArray() : &GetTableStyleUINameArray();
709  nStt = RES_POOLTABSTYLE_BEGIN;
710  }
711  break;
712  }
713  return pStrArr ? pStrArr->operator[](nId - nStt) : rFillName;
714 }
715 
717  sal_uInt16 const nId, OUString& rFillName, bool bProgName)
718 {
719  rFillName = getNameFromId(nId, rFillName, bProgName);
720 }
721 
722 // Get the UI name from the pool ID
723 void SwStyleNameMapper::FillUIName(sal_uInt16 const nId, OUString& rFillName)
724 {
725  fillNameFromId(nId, rFillName, false);
726 }
727 
728 // Get the UI name from the pool ID
730  sal_uInt16 const nId, const OUString& rName)
731 {
732  return getNameFromId(nId, rName, false);
733 }
734 
735 // Get the programmatic name from the pool ID
736 void SwStyleNameMapper::FillProgName(sal_uInt16 nId, OUString& rFillName)
737 {
738  fillNameFromId(nId, rFillName, true);
739 }
740 
741 // Get the programmatic name from the pool ID
742 const OUString&
743 SwStyleNameMapper::GetProgName(sal_uInt16 const nId, const OUString& rName)
744 {
745  return getNameFromId(nId, rName, true);
746 }
747 
748 // This gets the PoolId from the UI Name
750  const OUString& rName, SwGetPoolIdFromName const eFlags)
751 {
752  const NameToIdHash & rHashMap = getHashTable ( eFlags, false );
753  NameToIdHash::const_iterator aIter = rHashMap.find(rName);
754  return aIter != rHashMap.end() ? (*aIter).second : USHRT_MAX;
755 }
756 
757 // Get the Pool ID from the programmatic name
759  const OUString& rName, SwGetPoolIdFromName const eFlags)
760 {
761  const NameToIdHash & rHashMap = getHashTable ( eFlags, true );
762  NameToIdHash::const_iterator aIter = rHashMap.find(rName);
763  return aIter != rHashMap.end() ? (*aIter).second : USHRT_MAX;
764 }
765 
767 const std::vector<OUString>& SwStyleNameMapper::GetCellStyleUINameArray()
768 {
770  s_pCellStyleUINameArray = new std::vector<OUString>;
771  return *s_pCellStyleUINameArray;
772 }
773 
774 const std::vector<OUString>& SwStyleNameMapper::GetTextProgNameArray()
775 {
777  s_pTextProgNameArray = lcl_NewProgNameArray(TextProgNameTable,
778  SAL_N_ELEMENTS ( TextProgNameTable ) );
779  return *s_pTextProgNameArray;
780 }
781 
782 const std::vector<OUString>& SwStyleNameMapper::GetListsProgNameArray()
783 {
785  s_pListsProgNameArray = lcl_NewProgNameArray( ListsProgNameTable,
786  SAL_N_ELEMENTS ( ListsProgNameTable ) );
787  return *s_pListsProgNameArray;
788 }
789 
790 const std::vector<OUString>& SwStyleNameMapper::GetExtraProgNameArray()
791 {
793  s_pExtraProgNameArray = lcl_NewProgNameArray( ExtraProgNameTable,
794  SAL_N_ELEMENTS ( ExtraProgNameTable ) );
795  return *s_pExtraProgNameArray;
796 }
797 
798 const std::vector<OUString>& SwStyleNameMapper::GetRegisterProgNameArray()
799 {
801  s_pRegisterProgNameArray = lcl_NewProgNameArray( RegisterProgNameTable,
802  SAL_N_ELEMENTS ( RegisterProgNameTable ) );
803  return *s_pRegisterProgNameArray;
804 }
805 
806 const std::vector<OUString>& SwStyleNameMapper::GetDocProgNameArray()
807 {
808  if (!s_pDocProgNameArray)
809  s_pDocProgNameArray = lcl_NewProgNameArray( DocProgNameTable,
810  SAL_N_ELEMENTS ( DocProgNameTable ) );
811  return *s_pDocProgNameArray;
812 }
813 
814 const std::vector<OUString>& SwStyleNameMapper::GetHTMLProgNameArray()
815 {
817  s_pHTMLProgNameArray = lcl_NewProgNameArray( HTMLProgNameTable,
818  SAL_N_ELEMENTS ( HTMLProgNameTable ) );
819  return *s_pHTMLProgNameArray;
820 }
821 
823 {
825  s_pFrameFormatProgNameArray = lcl_NewProgNameArray( FrameFormatProgNameTable,
826  SAL_N_ELEMENTS ( FrameFormatProgNameTable ) );
828 }
829 
830 const std::vector<OUString>& SwStyleNameMapper::GetChrFormatProgNameArray()
831 {
833  s_pChrFormatProgNameArray = lcl_NewProgNameArray( ChrFormatProgNameTable,
834  SAL_N_ELEMENTS ( ChrFormatProgNameTable ) );
836 }
837 
839 {
841  s_pHTMLChrFormatProgNameArray = lcl_NewProgNameArray( HTMLChrFormatProgNameTable,
842  SAL_N_ELEMENTS ( HTMLChrFormatProgNameTable ) );
844 }
845 
846 const std::vector<OUString>& SwStyleNameMapper::GetPageDescProgNameArray()
847 {
849  s_pPageDescProgNameArray = lcl_NewProgNameArray( PageDescProgNameTable,
850  SAL_N_ELEMENTS ( PageDescProgNameTable ) );
851  return *s_pPageDescProgNameArray;
852 }
853 
854 const std::vector<OUString>& SwStyleNameMapper::GetNumRuleProgNameArray()
855 {
857  s_pNumRuleProgNameArray = lcl_NewProgNameArray( NumRuleProgNameTable,
858  SAL_N_ELEMENTS ( NumRuleProgNameTable ) );
859  return *s_pNumRuleProgNameArray;
860 }
861 
862 const std::vector<OUString>& SwStyleNameMapper::GetTableStyleProgNameArray()
863 {
865  s_pTableStyleProgNameArray = lcl_NewProgNameArray( TableStyleProgNameTable,
866  SAL_N_ELEMENTS ( TableStyleProgNameTable ) );
868 }
869 
871 const std::vector<OUString>& SwStyleNameMapper::GetCellStyleProgNameArray()
872 {
874  s_pCellStyleProgNameArray = new std::vector<OUString>;
876 }
877 
878 const OUString
879 SwStyleNameMapper::GetSpecialExtraProgName(const OUString& rExtraUIName)
880 {
881  return lcl_GetSpecialExtraName( rExtraUIName, true );
882 }
883 
884 const OUString
885 SwStyleNameMapper::GetSpecialExtraUIName(const OUString& rExtraProgName)
886 {
887  return lcl_GetSpecialExtraName( rExtraProgName, false );
888 }
889 
890 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static NameToIdHash * s_pTableStyleProgMap
static NameToIdHash * s_pNumRuleUIMap
const sal_uInt16 COLL_LISTS_BITS
Definition: poolfmt.hxx:67
static NameToIdHash * s_pCharProgMap
const sal_uInt16 COLL_DOC_BITS
Definition: poolfmt.hxx:70
Group HTML-styles.
Definition: poolfmt.hxx:429
static const std::vector< OUString > & GetDocProgNameArray()
static NameToIdHash * s_pCellStyleProgMap
static const std::vector< OUString > & GetListsUINameArray()
static std::vector< OUString > * s_pTableStyleProgNameArray
static const std::vector< OUString > & GetTableStyleUINameArray()
Group chapter / document.
Definition: poolfmt.hxx:421
static const std::vector< OUString > & GetFrameFormatUINameArray()
const sal_uInt16 COLL_GET_RANGE_BITS
Definition: poolfmt.hxx:72
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
static const std::vector< OUString > & GetExtraProgNameArray()
static const std::vector< OUString > & GetTextProgNameArray()
static const NameToIdHash & getHashTable(SwGetPoolIdFromName, bool bProgName)
static const std::vector< OUString > & GetHTMLUINameArray()
End of text styles collection.
Definition: poolfmt.hxx:437
Special ranges.
Definition: poolfmt.hxx:327
const sal_uInt16 COLL_HTML_BITS
Definition: poolfmt.hxx:71
sal_Int16 nId
static const OUString GetSpecialExtraUIName(const OUString &rExtraProgName)
static std::vector< OUString > * s_pExtraProgNameArray
static NameToIdHash * s_pFrameUIMap
static NameToIdHash * s_pNumRuleProgMap
static std::vector< OUString > * s_pListsProgNameArray
static const std::vector< OUString > & GetChrFormatProgNameArray()
static const std::vector< OUString > & GetPageDescUINameArray()
static const std::vector< OUString > & GetDocUINameArray()
sal_uInt16 sal_Unicode
static const std::vector< OUString > & GetListsProgNameArray()
char sal_Char
static const std::vector< OUString > & GetRegisterProgNameArray()
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
const sal_uInt16 COLL_REGISTER_BITS
Definition: poolfmt.hxx:69
sal_uInt8 const nLength
const sal_uInt16 POOLGRP_NOCOLLID
POOLCOLL-IDs: +-—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+ !User! Range ! 0 ! Offset ! +-—+—+...
Definition: poolfmt.hxx:59
static SW_DLLPUBLIC const OUString GetSpecialExtraProgName(const OUString &rExtraUIName)
static const std::vector< OUString > & GetHTMLChrFormatProgNameArray()
#define SAL_N_ELEMENTS(arr)
static const OUString & getNameFromId(sal_uInt16 nId, const OUString &rName, bool bProgName)
static NameToIdHash * s_pCharUIMap
static const std::vector< OUString > & GetHTMLProgNameArray()
HTML-styles.
Definition: poolfmt.hxx:135
static std::vector< OUString > * s_pFrameFormatProgNameArray
static std::vector< OUString > * s_pTextProgNameArray
#define ENTRY(s)
const sal_uInt16 POOLGRP_PAGEDESC
Definition: poolfmt.hxx:78
std::unordered_map< OUString, sal_uInt16 > NameToIdHash
This class holds all data about the names of styles used in the user interface (UI names...
static void fillNameFromId(sal_uInt16 nId, OUString &rName, bool bProgName)
Label drawing objects.
Definition: poolfmt.hxx:358
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
static std::vector< OUString > * s_pHTMLProgNameArray
static NameToIdHash * s_pFrameProgMap
static const std::vector< OUString > & GetCellStyleProgNameArray()
returns an empty array because Cell Names aren't translated
static NameToIdHash * s_pParaProgMap
const sal_uInt16 POOLGRP_FRAMEFMT
Definition: poolfmt.hxx:77
static NameToIdHash * s_pTableStyleUIMap
static NameToIdHash * s_pPageProgMap
static const std::vector< OUString > & GetNumRuleUINameArray()
const sal_uInt16 USER_FMT
POLLCOLL-groups:
Definition: poolfmt.hxx:63
static std::vector< OUString > * s_pHTMLChrFormatProgNameArray
static const std::vector< OUString > & GetHTMLChrFormatUINameArray()
static std::vector< OUString > * s_pCellStyleProgNameArray
static const std::vector< OUString > & GetChrFormatUINameArray()
static const std::vector< OUString > & GetExtraUINameArray()
static std::vector< OUString > * s_pDocProgNameArray
unsigned char sal_uInt8
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:259
const sal_uInt16 POOLGRP_NUMRULE
Definition: poolfmt.hxx:79
static std::vector< OUString > * s_pRegisterProgNameArray
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
static std::vector< OUString > * s_pChrFormatProgNameArray
const sal_Char * pChar
static const std::vector< OUString > & GetRegisterUINameArray()
static std::vector< OUString > * s_pPageDescProgNameArray
static std::vector< OUString > * s_pCellStyleUINameArray
static const OUString & GetUIName(const OUString &rName, SwGetPoolIdFromName)
static const std::vector< OUString > & GetCellStyleUINameArray()
returns an empty array because Cell Names aren't translated
Label illustration.
Definition: poolfmt.hxx:346
static NameToIdHash * s_pPageUIMap
SwGetPoolIdFromName
const sal_uInt16 POOLGRP_TABSTYLE
Definition: poolfmt.hxx:80
OString const aName
static std::vector< OUString > * s_pNumRuleProgNameArray
static const std::vector< OUString > & GetNumRuleProgNameArray()
static const std::vector< OUString > & GetTableStyleProgNameArray()
static const std::vector< OUString > & GetPageDescProgNameArray()
static NameToIdHash * s_pParaUIMap
const sal_uInt16 COLL_TEXT_BITS
Definition: poolfmt.hxx:66
static NameToIdHash * s_pCellStyleUIMap
const sal_uInt16 POOLGRP_CHARFMT
Other groups:
Definition: poolfmt.hxx:76
static const std::vector< OUString > & GetTextUINameArray()
static const std::vector< OUString > & GetFrameFormatProgNameArray()
static sal_uInt16 GetPoolIdFromProgName(const OUString &rName, SwGetPoolIdFromName)
const sal_uInt16 COLL_EXTRA_BITS
Definition: poolfmt.hxx:68
static const OUString & GetProgName(const OUString &rName, SwGetPoolIdFromName)