1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <SwStyleNameMapper.hxx>
29 #define _SVSTDARR_STRINGSDTOR
30 #include <svl/svstdarr.hxx>
31 #include <tools/resmgr.hxx>
32 #include <poolfmt.hxx>
33 #ifndef _RDIC_HRC
34 #include <rcid.hrc>
35 #endif
36 #include <tools/debug.hxx>
37 extern ResMgr* pSwResMgr;
38 // Initialise UI names to 0
39 SvStringsDtor	*SwStyleNameMapper::pTextUINameArray = 0,
40 				*SwStyleNameMapper::pListsUINameArray = 0,
41 				*SwStyleNameMapper::pExtraUINameArray = 0,
42 				*SwStyleNameMapper::pRegisterUINameArray = 0,
43 				*SwStyleNameMapper::pDocUINameArray = 0,
44 				*SwStyleNameMapper::pHTMLUINameArray = 0,
45 				*SwStyleNameMapper::pFrmFmtUINameArray = 0,
46 				*SwStyleNameMapper::pChrFmtUINameArray = 0,
47 				*SwStyleNameMapper::pHTMLChrFmtUINameArray = 0,
48 				*SwStyleNameMapper::pPageDescUINameArray = 0,
49 				*SwStyleNameMapper::pNumRuleUINameArray = 0,
50 
51 // Initialise programmatic names to 0
52 				*SwStyleNameMapper::pTextProgNameArray = 0,
53 				*SwStyleNameMapper::pListsProgNameArray = 0,
54 				*SwStyleNameMapper::pExtraProgNameArray = 0,
55 				*SwStyleNameMapper::pRegisterProgNameArray = 0,
56 				*SwStyleNameMapper::pDocProgNameArray = 0,
57 				*SwStyleNameMapper::pHTMLProgNameArray = 0,
58 				*SwStyleNameMapper::pFrmFmtProgNameArray = 0,
59 				*SwStyleNameMapper::pChrFmtProgNameArray = 0,
60 				*SwStyleNameMapper::pHTMLChrFmtProgNameArray = 0,
61 				*SwStyleNameMapper::pPageDescProgNameArray = 0,
62 				*SwStyleNameMapper::pNumRuleProgNameArray = 0;
63 
64 NameToIdHash	*SwStyleNameMapper::pParaUIMap = 0,
65 				*SwStyleNameMapper::pCharUIMap = 0,
66 				*SwStyleNameMapper::pPageUIMap = 0,
67 				*SwStyleNameMapper::pFrameUIMap = 0,
68 				*SwStyleNameMapper::pNumRuleUIMap = 0,
69 
70 				*SwStyleNameMapper::pParaProgMap = 0,
71 				*SwStyleNameMapper::pCharProgMap = 0,
72 				*SwStyleNameMapper::pPageProgMap = 0,
73 				*SwStyleNameMapper::pFrameProgMap = 0,
74 				*SwStyleNameMapper::pNumRuleProgMap = 0;
75 
76 // SwTableEntry so we can pass the length to the String CTOR
77 struct SwTableEntry
78 {
79 	sal_uInt8 nLength;
80 	const sal_Char *pChar;
81 };
82 
83 #define ENTRY( s ) { sizeof (s)-1, s }
84 
85 // Hard coded Programmatic Name tables
86 const struct SwTableEntry TextProgNameTable [] =
87 {
88 	ENTRY( "Standard" ), // RES_POOLCOLL_STANDARD
89 	ENTRY( "Text body" ),
90 	ENTRY( "First line indent" ),
91 	ENTRY( "Hanging indent" ),
92 	ENTRY( "Text body indent" ),
93 	ENTRY( "Salutation" ),
94 	ENTRY( "Signature" ),
95 	ENTRY( "List Indent" ), // RES_POOLCOLL_CONFRONTATION
96 	ENTRY( "Marginalia" ),
97 	ENTRY( "Heading" ),
98 	ENTRY( "Heading 1" ),
99 	ENTRY( "Heading 2" ),
100 	ENTRY( "Heading 3" ),
101 	ENTRY( "Heading 4" ),
102 	ENTRY( "Heading 5" ),
103 	ENTRY( "Heading 6" ),
104 	ENTRY( "Heading 7" ),
105 	ENTRY( "Heading 8" ),
106 	ENTRY( "Heading 9" ),
107 	ENTRY( "Heading 10" ), // RES_POOLCOLL_TEXT_END
108 	{ 0, NULL }
109 };
110 
111 const struct SwTableEntry ListsProgNameTable [] =
112 {
113 	ENTRY( "List" ), // STR_POCO_PRGM_NUMBUL_BASE
114 	ENTRY( "Numbering 1 Start" ), // STR_POCO_PRGM_NUM_LEVEL1S
115 	ENTRY( "Numbering 1" ),
116 	ENTRY( "Numbering 1 End" ),
117 	ENTRY( "Numbering 1 Cont." ),
118 	ENTRY( "Numbering 2 Start" ),
119 	ENTRY( "Numbering 2" ),
120 	ENTRY( "Numbering 2 End" ),
121 	ENTRY( "Numbering 2 Cont." ),
122 	ENTRY( "Numbering 3 Start" ),
123 	ENTRY( "Numbering 3" ),
124 	ENTRY( "Numbering 3 End" ),
125 	ENTRY( "Numbering 3 Cont." ),
126 	ENTRY( "Numbering 4 Start" ),
127 	ENTRY( "Numbering 4" ),
128 	ENTRY( "Numbering 4 End" ),
129 	ENTRY( "Numbering 4 Cont." ),
130 	ENTRY( "Numbering 5 Start" ),
131 	ENTRY( "Numbering 5" ),
132 	ENTRY( "Numbering 5 End" ),
133 	ENTRY( "Numbering 5 Cont." ),
134 	ENTRY( "List 1 Start" ),
135 	ENTRY( "List 1" ),
136 	ENTRY( "List 1 End" ),
137 	ENTRY( "List 1 Cont." ),
138 	ENTRY( "List 2 Start" ),
139 	ENTRY( "List 2" ),
140 	ENTRY( "List 2 End" ),
141 	ENTRY( "List 2 Cont." ),
142 	ENTRY( "List 3 Start" ),
143 	ENTRY( "List 3" ),
144 	ENTRY( "List 3 End" ),
145 	ENTRY( "List 3 Cont." ),
146 	ENTRY( "List 4 Start" ),
147 	ENTRY( "List 4" ),
148 	ENTRY( "List 4 End" ),
149 	ENTRY( "List 4 Cont." ),
150 	ENTRY( "List 5 Start" ),
151 	ENTRY( "List 5" ),
152 	ENTRY( "List 5 End" ),
153 	ENTRY( "List 5 Cont." ), // STR_POCO_PRGM_BUL_NONUM5
154 	{ 0, NULL }
155 };
156 
157 const struct SwTableEntry ExtraProgNameTable [] =
158 {
159 	ENTRY( "Header" ), // RES_POOLCOLL_EXTRA_BEGIN
160 	ENTRY( "Header left" ),
161 	ENTRY( "Header right" ),
162 	ENTRY( "Footer" ),
163 	ENTRY( "Footer left" ),
164 	ENTRY( "Footer right" ),
165 	ENTRY( "Table Contents" ),
166 	ENTRY( "Table Heading" ),
167 	ENTRY( "Caption" ),
168 	ENTRY( "Illustration" ),
169 	ENTRY( "Table" ),
170 	ENTRY( "Text" ),
171 	ENTRY( "Frame contents" ),
172 	ENTRY( "Footnote" ),
173 	ENTRY( "Addressee" ),
174 	ENTRY( "Sender" ),
175 	ENTRY( "Endnote" ),
176 	ENTRY( "Drawing" ), // RES_POOLCOLL_LABEL_DRAWING
177 	{ 0, NULL }
178 };
179 
180 const struct SwTableEntry RegisterProgNameTable [] =
181 {
182 	ENTRY( "Index" ), // STR_POCO_PRGM_REGISTER_BASE
183 	ENTRY( "Index Heading" ), // STR_POCO_PRGM_TOX_IDXH
184 	ENTRY( "Index 1" ),
185 	ENTRY( "Index 2" ),
186 	ENTRY( "Index 3" ),
187 	ENTRY( "Index Separator" ),
188 	ENTRY( "Contents Heading" ),
189 	ENTRY( "Contents 1" ),
190 	ENTRY( "Contents 2" ),
191 	ENTRY( "Contents 3" ),
192 	ENTRY( "Contents 4" ),
193 	ENTRY( "Contents 5" ),
194 	ENTRY( "User Index Heading" ),
195 	ENTRY( "User Index 1" ),
196 	ENTRY( "User Index 2" ),
197 	ENTRY( "User Index 3" ),
198 	ENTRY( "User Index 4" ),
199 	ENTRY( "User Index 5" ),
200 	ENTRY( "Contents 6" ),
201 	ENTRY( "Contents 7" ),
202 	ENTRY( "Contents 8" ),
203 	ENTRY( "Contents 9" ),
204 	ENTRY( "Contents 10" ),
205 	ENTRY( "Illustration Index Heading" ),
206 	ENTRY( "Illustration Index 1" ),
207 	ENTRY( "Object index heading" ),
208 	ENTRY( "Object index 1" ),
209 	ENTRY( "Table index heading" ),
210 	ENTRY( "Table index 1" ),
211 	ENTRY( "Bibliography Heading" ),
212 	ENTRY( "Bibliography 1" ),
213 	ENTRY( "User Index 6" ),
214 	ENTRY( "User Index 7" ),
215 	ENTRY( "User Index 8" ),
216 	ENTRY( "User Index 9" ),
217 	ENTRY( "User Index 10" ), // STR_POCO_PRGM_TOX_USER10
218 	{ 0, NULL }
219 };
220 
221 const struct SwTableEntry DocProgNameTable [] =
222 {
223 	ENTRY( "Title" ), // STR_POCO_PRGM_DOC_TITEL
224 	ENTRY( "Subtitle" ),
225 	{ 0, NULL }
226 };
227 
228 const struct SwTableEntry HTMLProgNameTable [] =
229 {
230 	ENTRY( "Quotations" ),
231 	ENTRY( "Preformatted Text" ),
232 	ENTRY( "Horizontal Line" ),
233 	ENTRY( "List Contents" ),
234 	ENTRY( "List Heading" ), // STR_POCO_PRGM_HTML_DT
235 	{ 0, NULL }
236 };
237 
238 const struct SwTableEntry FrmFmtProgNameTable [] =
239 {
240 	ENTRY( "Frame" ), // RES_POOLFRM_FRAME
241 	ENTRY( "Graphics" ),
242 	ENTRY( "OLE" ),
243 	ENTRY( "Formula" ),
244 	ENTRY( "Marginalia" ),
245 	ENTRY( "Watermark" ),
246 	ENTRY( "Labels" ), // RES_POOLFRM_LABEL
247 	{ 0, NULL }
248 };
249 
250 const struct SwTableEntry ChrFmtProgNameTable [] =
251 {
252 	ENTRY( "Footnote Symbol" ), // RES_POOLCHR_FOOTNOTE
253 	ENTRY( "Page Number" ),
254 	ENTRY( "Caption characters" ),
255 	ENTRY( "Drop Caps" ),
256 	ENTRY( "Numbering Symbols" ),
257 	ENTRY( "Bullet Symbols" ),
258 	ENTRY( "Internet link" ),
259 	ENTRY( "Visited Internet Link" ),
260 	ENTRY( "Placeholder" ),
261 	ENTRY( "Index Link" ),
262 	ENTRY( "Endnote Symbol" ),
263 	ENTRY( "Line numbering" ),
264 	ENTRY( "Main index entry" ),
265 	ENTRY( "Footnote anchor" ),
266 	ENTRY( "Endnote anchor" ),
267 	ENTRY( "Rubies" ), // RES_POOLCHR_RUBYTEXT
268     ENTRY( "Vertical Numbering Symbols" ), // RES_POOLCHR_VERT_NUMBER
269     { 0, NULL }
270 };
271 
272 const struct SwTableEntry HTMLChrFmtProgNameTable [] =
273 {
274 	ENTRY( "Emphasis" ), // RES_POOLCHR_HTML_EMPHASIS
275 	ENTRY( "Citation" ),
276 	ENTRY( "Strong Emphasis" ),
277 	ENTRY( "Source Text" ),
278 	ENTRY( "Example" ),
279 	ENTRY( "User Entry" ),
280 	ENTRY( "Variable" ),
281 	ENTRY( "Definition" ),
282 	ENTRY( "Teletype" ), // RES_POOLCHR_HTML_TELETYPE
283 	{ 0, NULL }
284 };
285 
286 const struct SwTableEntry PageDescProgNameTable [] =
287 {
288 	ENTRY( "Standard" ), // STR_POOLPAGE_PRGM_STANDARD
289 	ENTRY( "First Page" ),
290 	ENTRY( "Left Page" ),
291 	ENTRY( "Right Page" ),
292 	ENTRY( "Envelope" ),
293 	ENTRY( "Index" ),
294 	ENTRY( "HTML" ),
295 	ENTRY( "Footnote" ),
296 	ENTRY( "Endnote" ), // STR_POOLPAGE_PRGM_ENDNOTE
297     ENTRY( "Landscape" ),
298     { 0, NULL }
299 };
300 
301 const struct SwTableEntry NumRuleProgNameTable [] =
302 {
303 	ENTRY( "Numbering 1" ), // STR_POOLNUMRULE_PRGM_NUM1
304 	ENTRY( "Numbering 2" ),
305 	ENTRY( "Numbering 3" ),
306 	ENTRY( "Numbering 4" ),
307 	ENTRY( "Numbering 5" ),
308 	ENTRY( "List 1" ),
309 	ENTRY( "List 2" ),
310 	ENTRY( "List 3" ),
311 	ENTRY( "List 4" ),
312 	ENTRY( "List 5" ), // STR_POOLNUMRULE_PRGM_BUL5
313 	{ 0, NULL }
314 };
315 #undef ENTRY
316 
SuffixIsUser(const String & rString)317 sal_Bool SwStyleNameMapper::SuffixIsUser ( const String & rString )
318 {
319 	const sal_Unicode *pChar = rString.GetBuffer();
320 	sal_Int32 nLen = rString.Len();
321     sal_Bool bRet = sal_False;
322 	if( nLen > 8 &&
323         pChar[nLen-7] == ' ' &&
324         pChar[nLen-6] == '(' &&
325         pChar[nLen-5] == 'u' &&
326         pChar[nLen-4] == 's' &&
327         pChar[nLen-3] == 'e' &&
328         pChar[nLen-2] == 'r' &&
329         pChar[nLen-1] == ')' )
330         bRet = sal_True;
331     return bRet;
332 }
CheckSuffixAndDelete(String & rString)333 void SwStyleNameMapper::CheckSuffixAndDelete ( String & rString )
334 {
335 	const sal_Unicode *pChar = rString.GetBuffer();
336 	xub_StrLen nLen = rString.Len();
337 	if (nLen > 8 &&
338 		pChar[nLen-7] == ' ' &&
339 		pChar[nLen-6] == '(' &&
340 		pChar[nLen-5] == 'u' &&
341 		pChar[nLen-4] == 's' &&
342 		pChar[nLen-3] == 'e' &&
343 		pChar[nLen-2] == 'r' &&
344 		pChar[nLen-1] == ')')
345 	{
346 		rString.Erase ( nLen - 7, 7 );
347 	}
348 }
getHashTable(SwGetPoolIdFromName eFlags,sal_Bool bProgName)349 const NameToIdHash & SwStyleNameMapper::getHashTable ( SwGetPoolIdFromName eFlags, sal_Bool bProgName )
350 {
351     NameToIdHash *pHash = 0;
352 	const SvStringsDtor *pStrings;
353 
354 	switch ( eFlags )
355 	{
356 		case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL:
357 		{
358 			sal_uInt16 nIndex;
359 			sal_uInt16 nId;
360 
361 			pHash = bProgName ? pParaProgMap : pParaUIMap;
362 			if ( !pHash )
363 			{
364 				pHash = new NameToIdHash ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN +
365 										   RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
366 										   RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
367 										   RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
368 										   RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
369 										   RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN );
370 				pStrings = bProgName ? &GetTextProgNameArray() : &GetTextUINameArray();
371 				for ( nIndex = 0, nId = RES_POOLCOLL_TEXT_BEGIN ; nId < RES_POOLCOLL_TEXT_END ; nId++,nIndex++ )
372 					(*pHash)[(*pStrings)[nIndex]] = nId;
373 				pStrings = bProgName ? &GetListsProgNameArray() : &GetListsUINameArray();
374 				for ( nIndex = 0, nId = RES_POOLCOLL_LISTS_BEGIN ; nId < RES_POOLCOLL_LISTS_END ; nId++,nIndex++ )
375 					(*pHash)[(*pStrings)[nIndex]] = nId;
376 				pStrings = bProgName ? &GetExtraProgNameArray() : &GetExtraUINameArray();
377 				for ( nIndex = 0, nId = RES_POOLCOLL_EXTRA_BEGIN ; nId < RES_POOLCOLL_EXTRA_END ; nId++,nIndex++ )
378 					(*pHash)[(*pStrings)[nIndex]] = nId;
379 				pStrings = bProgName ? &GetRegisterProgNameArray() : &GetRegisterUINameArray();
380 				for ( nIndex = 0, nId = RES_POOLCOLL_REGISTER_BEGIN ; nId < RES_POOLCOLL_REGISTER_END ; nId++,nIndex++ )
381 					(*pHash)[(*pStrings)[nIndex]] = nId;
382 				pStrings = bProgName ? &GetDocProgNameArray() : &GetDocUINameArray();
383 				for ( nIndex = 0, nId = RES_POOLCOLL_DOC_BEGIN ; nId < RES_POOLCOLL_DOC_END ; nId++,nIndex++ )
384 					(*pHash)[(*pStrings)[nIndex]] = nId;
385 				pStrings = bProgName ? &GetHTMLProgNameArray() : &GetHTMLUINameArray();
386 				for ( nIndex = 0, nId = RES_POOLCOLL_HTML_BEGIN ; nId < RES_POOLCOLL_HTML_END ; nId++,nIndex++ )
387 					(*pHash)[(*pStrings)[nIndex]] = nId;
388 
389 				if ( bProgName )
390 					pParaProgMap = pHash;
391 				else
392 					pParaUIMap = pHash;
393 			}
394 		}
395 		break;
396 		case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT:
397 		{
398 			pHash = bProgName ? pCharProgMap : pCharUIMap;
399 			if ( !pHash )
400 			{
401 				sal_uInt16 nIndex;
402 				sal_uInt16 nId;
403 
404 				pHash = new NameToIdHash ( RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN +
405 										   RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN );
406 				pStrings = bProgName ? &GetChrFmtProgNameArray() : &GetChrFmtUINameArray();
407 				for ( nIndex = 0, nId = RES_POOLCHR_NORMAL_BEGIN ; nId < RES_POOLCHR_NORMAL_END ; nId++,nIndex++ )
408 					(*pHash)[(*pStrings)[nIndex]] = nId;
409 				pStrings = bProgName ? &GetHTMLChrFmtProgNameArray() : &GetHTMLChrFmtUINameArray();
410 				for ( nIndex = 0, nId = RES_POOLCHR_HTML_BEGIN ; nId < RES_POOLCHR_HTML_END ; nId++,nIndex++ )
411 					(*pHash)[(*pStrings)[nIndex]] = nId;
412 				if (bProgName )
413 					pCharProgMap = pHash;
414 				else
415 					pCharUIMap = pHash;
416 			}
417 		}
418 		break;
419 		case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT:
420 		{
421 			pHash = bProgName ? pFrameProgMap : pFrameUIMap;
422 			if ( !pHash )
423 			{
424 				pHash = new NameToIdHash ( RES_POOLFRM_END - RES_POOLFRM_BEGIN );
425 				pStrings = bProgName ? &GetFrmFmtProgNameArray() : &GetFrmFmtUINameArray();
426 				for ( sal_uInt16 nIndex=0,nId = RES_POOLFRM_BEGIN ; nId < RES_POOLFRM_END ; nId++,nIndex++ )
427 					(*pHash)[(*pStrings)[nIndex]] = nId;
428 				if ( bProgName )
429 					pFrameProgMap = pHash;
430 				else
431 					pFrameUIMap = pHash;
432 			}
433 		}
434 		break;
435 		case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC:
436 		{
437 			pHash = bProgName ? pPageProgMap : pPageUIMap;
438 			if ( !pHash )
439 			{
440 				pHash = new NameToIdHash ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN );
441 				pStrings = bProgName ? &GetPageDescProgNameArray() : &GetPageDescUINameArray();
442 				for ( sal_uInt16 nIndex=0,nId = RES_POOLPAGE_BEGIN ; nId < RES_POOLPAGE_END ; nId++,nIndex++ )
443 					(*pHash)[(*pStrings)[nIndex]] = nId;
444 				if ( bProgName )
445 					pPageProgMap = pHash;
446 				else
447 					pPageUIMap = pHash;
448 			}
449 		}
450 		break;
451 		case nsSwGetPoolIdFromName::GET_POOLID_NUMRULE:
452 		{
453 			pHash = bProgName ? pNumRuleProgMap : pNumRuleUIMap;
454 			if ( !pHash )
455 			{
456 				pHash = new NameToIdHash ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN );
457 				pStrings = bProgName ? &GetNumRuleProgNameArray() : &GetNumRuleUINameArray();
458 				for ( sal_uInt16 nIndex=0,nId = RES_POOLNUMRULE_BEGIN ; nId < RES_POOLNUMRULE_END ; nId++,nIndex++ )
459 					(*pHash)[(*pStrings)[nIndex]] = nId;
460 				if ( bProgName )
461 					pNumRuleProgMap = pHash;
462 				else
463 					pNumRuleUIMap = pHash;
464 			}
465 		}
466 		break;
467 	}
468 #ifdef _NEED_TO_DEBUG_MAPPING
469 	static sal_Bool bTested = sal_False;
470 	if ( !bTested )
471 	{
472 		bTested = sal_True;
473 		{
474 			for ( sal_uInt16 nIndex = 0, nId = RES_POOLCOLL_TEXT_BEGIN ; nId < RES_POOLCOLL_TEXT_END ; nId++,nIndex++ )
475 			{
476 				String aString, bString;
477 				FillUIName ( nId, aString );
478 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
479 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
480 				FillProgName ( nNewId, aString );
481 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
482 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
483 				if ( nNewId != nId )
484 					*((sal_Int32*)0) = 42;
485 			}
486 			for ( nIndex = 0, nId = RES_POOLCOLL_LISTS_BEGIN ; nId < RES_POOLCOLL_LISTS_END ; nId++,nIndex++ )
487 			{
488 				String aString, bString;
489 				FillUIName ( nId, aString );
490 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
491 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
492 				FillProgName ( nNewId, aString );
493 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
494 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
495 				if ( nNewId != nId )
496 					*((sal_Int32*)0) = 42;
497 			}
498 			for ( nIndex = 0, nId = RES_POOLCOLL_EXTRA_BEGIN ; nId < RES_POOLCOLL_EXTRA_END ; nId++,nIndex++ )
499 			{
500 				String aString, bString;
501 				FillUIName ( nId, aString );
502 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
503 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
504 				FillProgName ( nNewId, aString );
505 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
506 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
507 				if ( nNewId != nId )
508 					*((sal_Int32*)0) = 42;
509 			}
510 			for ( nIndex = 0, nId = RES_POOLCOLL_REGISTER_BEGIN ; nId < RES_POOLCOLL_REGISTER_END ; nId++,nIndex++ )
511 			{
512 				String aString, bString;
513 				FillUIName ( nId, aString );
514 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
515 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
516 				FillProgName ( nNewId, aString );
517 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
518 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
519 				if ( nNewId != nId )
520 					*((sal_Int32*)0) = 42;
521 			}
522 			for ( nIndex = 0, nId = RES_POOLCOLL_DOC_BEGIN ; nId < RES_POOLCOLL_DOC_END ; nId++,nIndex++ )
523 			{
524 				String aString, bString;
525 				FillUIName ( nId, aString );
526 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
527 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
528 				FillProgName ( nNewId, aString );
529 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
530 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
531 				if ( nNewId != nId )
532 					*((sal_Int32*)0) = 42;
533 			}
534 			for ( nIndex = 0, nId = RES_POOLCOLL_HTML_BEGIN ; nId < RES_POOLCOLL_HTML_END ; nId++,nIndex++ )
535 			{
536 				String aString, bString;
537 				FillUIName ( nId, aString );
538 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
539 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
540 				FillProgName ( nNewId, aString );
541 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
542 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
543 				if ( nNewId != nId )
544 					*((sal_Int32*)0) = 42;
545 			}
546 		}
547 		{
548 			for ( sal_uInt16 nIndex = 0, nId = RES_POOLCHR_NORMAL_BEGIN ; nId < RES_POOLCHR_NORMAL_END ; nId++,nIndex++ )
549 			{
550 				String aString, bString;
551 				FillUIName ( nId, aString );
552 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
553 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
554 				FillProgName ( nNewId, aString );
555 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
556 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
557 				if ( nNewId != nId )
558 					*((sal_Int32*)0) = 42;
559 			}
560 			for ( nIndex = 0, nId = RES_POOLCHR_HTML_BEGIN ; nId < RES_POOLCHR_HTML_END ; nId++,nIndex++ )
561 			{
562 				String aString, bString;
563 				FillUIName ( nId, aString );
564 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
565 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
566 				FillProgName ( nNewId, aString );
567 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
568 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
569 				if ( nNewId != nId )
570 					*((sal_Int32*)0) = 42;
571 			}
572 		}
573 		{
574 			for ( sal_uInt16 nIndex=0,nId = RES_POOLFRM_BEGIN ; nId < RES_POOLFRM_END ; nId++,nIndex++ )
575 			{
576 				String aString, bString;
577 				FillUIName ( nId, aString );
578 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
579 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
580 				FillProgName ( nNewId, aString );
581 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
582 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
583 				if ( nNewId != nId )
584 					*((sal_Int32*)0) = 42;
585 			}
586 		}
587 		{
588 			for ( sal_uInt16 nIndex=0,nId = RES_POOLPAGE_BEGIN ; nId < RES_POOLPAGE_END ; nId++,nIndex++ )
589 			{
590 				String aString, bString;
591 				FillUIName ( nId, aString );
592 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
593 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
594 				FillProgName ( nNewId, aString );
595 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
596 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
597 				if ( nNewId != nId )
598 					*((sal_Int32*)0) = 42;
599 			}
600 		}
601 		{
602 			for ( sal_uInt16 nIndex=0,nId = RES_POOLNUMRULE_BEGIN ; nId < RES_POOLNUMRULE_END ; nId++,nIndex++ )
603 			{
604 				String aString, bString;
605 				FillUIName ( nId, aString );
606 				bString = GetProgName ( nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, aString );
607 				sal_uInt16 nNewId = GetPoolIdFromProgName ( bString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
608 				FillProgName ( nNewId, aString );
609 				bString = GetUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
610 				nNewId = GetPoolIdFromUIName ( aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
611 				if ( nNewId != nId )
612 					*((sal_Int32*)0) = 42;
613 			}
614 		}
615 	}
616 #endif
617 	return *pHash;
618 }
619 // This gets the UI Name from the programmatic name
GetUIName(const String & rName,SwGetPoolIdFromName eFlags)620 const String& SwStyleNameMapper::GetUIName ( const String& rName, SwGetPoolIdFromName eFlags )
621 {
622 	sal_uInt16 nId = GetPoolIdFromProgName ( rName, eFlags );
623 	return nId != USHRT_MAX ? GetUIName( nId, rName ) : rName;
624 }
625 
626 
627 // Get the programmatic Name from the UI name
GetProgName(const String & rName,SwGetPoolIdFromName eFlags)628 const String& SwStyleNameMapper::GetProgName( const String& rName, SwGetPoolIdFromName eFlags )
629 {
630 	sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags );
631 	return nId != USHRT_MAX ? GetProgName( nId, rName ) : rName;
632 }
633 
634 // Get the programmatic name from the UI name in rName and put it into rFillName
FillProgName(const String & rName,String & rFillName,SwGetPoolIdFromName eFlags,sal_Bool bDisambiguate)635 void SwStyleNameMapper::FillProgName ( const String& rName, String& rFillName, SwGetPoolIdFromName eFlags, sal_Bool bDisambiguate )
636 {
637 	sal_uInt16 nId = GetPoolIdFromUIName ( rName, eFlags );
638 	if ( bDisambiguate && nId == USHRT_MAX )
639 	{
640 		// rName isn't in our UI name table...check if it's in the programmatic one
641 		nId = GetPoolIdFromProgName ( rName, eFlags );
642 
643 		rFillName = rName;
644 		if (nId == USHRT_MAX )
645 		{
646 			// It isn't ...make sure the suffix isn't already " (user)"...if it is,
647 			// we need to add another one
648 			if ( SuffixIsUser ( rFillName ) )
649 				rFillName.AppendAscii ( RTL_CONSTASCII_STRINGPARAM ( " (user)" ) );
650 		}
651 		else
652 		{
653 			// It's in the programmatic name table...append suffix
654 			rFillName.AppendAscii ( RTL_CONSTASCII_STRINGPARAM ( " (user)" ) );
655 		}
656 	}
657 	else
658 	{
659 		// If we aren't trying to disambiguate, then just do a normal fill
660 		fillNameFromId ( nId, rFillName, sal_True);
661 	}
662 }
663 // Get the UI name from the programmatic name in rName and put it into rFillName
FillUIName(const String & rName,String & rFillName,SwGetPoolIdFromName eFlags,sal_Bool bDisambiguate)664 void SwStyleNameMapper::FillUIName ( const String& rName, String& rFillName, SwGetPoolIdFromName eFlags, sal_Bool bDisambiguate )
665 {
666 	sal_uInt16 nId = GetPoolIdFromProgName ( rName, eFlags );
667 	if ( bDisambiguate && nId == USHRT_MAX )
668 	{
669 		rFillName = rName;
670 		// rName isn't in our Prog name table...check if it has a " (user)" suffix, if so remove it
671 		CheckSuffixAndDelete ( rFillName );
672 	}
673 	else
674 	{
675 		// If we aren't trying to disambiguate, then just do a normal fill
676 		fillNameFromId ( nId, rFillName, sal_False);
677 	}
678 }
679 
getNameFromId(sal_uInt16 nId,const String & rFillName,sal_Bool bProgName)680 const String& SwStyleNameMapper::getNameFromId( sal_uInt16 nId, const String& rFillName, sal_Bool bProgName )
681 {
682 	sal_uInt16 nStt = 0;
683 	const SvStringsDtor* pStrArr = 0;
684 
685 	switch( (USER_FMT | COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID) & nId )
686 	{
687 	case COLL_TEXT_BITS:
688 		if( RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END )
689 		{
690 			pStrArr = bProgName ? &GetTextProgNameArray() : &GetTextUINameArray();
691 			nStt = RES_POOLCOLL_TEXT_BEGIN;
692 		}
693 		break;
694 	case COLL_LISTS_BITS:
695 		if( RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END )
696 		{
697 			pStrArr = bProgName ? &GetListsProgNameArray() : &GetListsUINameArray();
698 			nStt = RES_POOLCOLL_LISTS_BEGIN;
699 		}
700 		break;
701 	case COLL_EXTRA_BITS:
702 		if( RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END )
703 		{
704 			pStrArr = bProgName ? &GetExtraProgNameArray() : &GetExtraUINameArray();
705 			nStt = RES_POOLCOLL_EXTRA_BEGIN;
706 		}
707 		break;
708 	case COLL_REGISTER_BITS:
709 		if( RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END )
710 		{
711 			pStrArr = bProgName ? &GetRegisterProgNameArray() : &GetRegisterUINameArray();
712 			nStt = RES_POOLCOLL_REGISTER_BEGIN;
713 		}
714 		break;
715 	case COLL_DOC_BITS:
716 		if( RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END )
717 		{
718 			pStrArr = bProgName ? &GetDocProgNameArray() : &GetDocUINameArray();
719 			nStt = RES_POOLCOLL_DOC_BEGIN;
720 		}
721 		break;
722 	case COLL_HTML_BITS:
723 		if( RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END )
724 		{
725 			pStrArr = bProgName ? &GetHTMLProgNameArray() : &GetHTMLUINameArray();
726 			nStt = RES_POOLCOLL_HTML_BEGIN;
727 		}
728 		break;
729 	case POOLGRP_CHARFMT:
730 		if( RES_POOLCHR_NORMAL_BEGIN <= nId && nId < RES_POOLCHR_NORMAL_END )
731 		{
732 			pStrArr = bProgName ? &GetChrFmtProgNameArray() : &GetChrFmtUINameArray();
733 			nStt = RES_POOLCHR_NORMAL_BEGIN;
734 		}
735 		else if( RES_POOLCHR_HTML_BEGIN <= nId && nId < RES_POOLCHR_HTML_END )
736 		{
737 			pStrArr = bProgName ? &GetHTMLChrFmtProgNameArray() : &GetHTMLChrFmtUINameArray();
738 			nStt = RES_POOLCHR_HTML_BEGIN;
739 		}
740 		break;
741 	case POOLGRP_FRAMEFMT:
742 		if( RES_POOLFRM_BEGIN <= nId && nId < RES_POOLFRM_END )
743 		{
744 			pStrArr = bProgName ? &GetFrmFmtProgNameArray() : &GetFrmFmtUINameArray();
745 			nStt = RES_POOLFRM_BEGIN;
746 		}
747 		break;
748 	case POOLGRP_PAGEDESC:
749 		if( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END )
750 		{
751 			pStrArr = bProgName ? &GetPageDescProgNameArray() : &GetPageDescUINameArray();
752 			nStt = RES_POOLPAGE_BEGIN;
753 		}
754 		break;
755 	case POOLGRP_NUMRULE:
756 		if( RES_POOLNUMRULE_BEGIN <= nId && nId < RES_POOLNUMRULE_END )
757 		{
758 			pStrArr = bProgName ? &GetNumRuleProgNameArray() : &GetNumRuleUINameArray();
759 			nStt = RES_POOLNUMRULE_BEGIN;
760 		}
761 		break;
762 	}
763 	return pStrArr ? *(pStrArr->operator[] ( nId - nStt ) ) : rFillName;
764 }
fillNameFromId(sal_uInt16 nId,String & rFillName,sal_Bool bProgName)765 void SwStyleNameMapper::fillNameFromId( sal_uInt16 nId, String& rFillName, sal_Bool bProgName )
766 {
767 	sal_uInt16 nStt = 0;
768 	const SvStringsDtor* pStrArr = 0;
769 
770 	switch( (USER_FMT | COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID) & nId )
771 	{
772 	case COLL_TEXT_BITS:
773 		if( RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END )
774 		{
775 			pStrArr = bProgName ? &GetTextProgNameArray() : &GetTextUINameArray();
776 			nStt = RES_POOLCOLL_TEXT_BEGIN;
777 		}
778 		break;
779 	case COLL_LISTS_BITS:
780 		if( RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END )
781 		{
782 			pStrArr = bProgName ? &GetListsProgNameArray() : &GetListsUINameArray();
783 			nStt = RES_POOLCOLL_LISTS_BEGIN;
784 		}
785 		break;
786 	case COLL_EXTRA_BITS:
787 		if( RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END )
788 		{
789 			pStrArr = bProgName ? &GetExtraProgNameArray() : &GetExtraUINameArray();
790 			nStt = RES_POOLCOLL_EXTRA_BEGIN;
791 		}
792 		break;
793 	case COLL_REGISTER_BITS:
794 		if( RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END )
795 		{
796 			pStrArr = bProgName ? &GetRegisterProgNameArray() : &GetRegisterUINameArray();
797 			nStt = RES_POOLCOLL_REGISTER_BEGIN;
798 		}
799 		break;
800 	case COLL_DOC_BITS:
801 		if( RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END )
802 		{
803 			pStrArr = bProgName ? &GetDocProgNameArray() : &GetDocUINameArray();
804 			nStt = RES_POOLCOLL_DOC_BEGIN;
805 		}
806 		break;
807 	case COLL_HTML_BITS:
808 		if( RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END )
809 		{
810 			pStrArr = bProgName ? &GetHTMLProgNameArray() : &GetHTMLUINameArray();
811 			nStt = RES_POOLCOLL_HTML_BEGIN;
812 		}
813 		break;
814 	case POOLGRP_CHARFMT:
815 		if( RES_POOLCHR_NORMAL_BEGIN <= nId && nId < RES_POOLCHR_NORMAL_END )
816 		{
817 			pStrArr = bProgName ? &GetChrFmtProgNameArray() : &GetChrFmtUINameArray();
818 			nStt = RES_POOLCHR_NORMAL_BEGIN;
819 		}
820 		else if( RES_POOLCHR_HTML_BEGIN <= nId && nId < RES_POOLCHR_HTML_END )
821 		{
822 			pStrArr = bProgName ? &GetHTMLChrFmtProgNameArray() : &GetHTMLChrFmtUINameArray();
823 			nStt = RES_POOLCHR_HTML_BEGIN;
824 		}
825 		break;
826 	case POOLGRP_FRAMEFMT:
827 		if( RES_POOLFRM_BEGIN <= nId && nId < RES_POOLFRM_END )
828 		{
829 			pStrArr = bProgName ? &GetFrmFmtProgNameArray() : &GetFrmFmtUINameArray();
830 			nStt = RES_POOLFRM_BEGIN;
831 		}
832 		break;
833 	case POOLGRP_PAGEDESC:
834 		if( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END )
835 		{
836 			pStrArr = bProgName ? &GetPageDescProgNameArray() : &GetPageDescUINameArray();
837 			nStt = RES_POOLPAGE_BEGIN;
838 		}
839 		break;
840 	case POOLGRP_NUMRULE:
841 		if( RES_POOLNUMRULE_BEGIN <= nId && nId < RES_POOLNUMRULE_END )
842 		{
843 			pStrArr = bProgName ? &GetNumRuleProgNameArray() : &GetNumRuleUINameArray();
844 			nStt = RES_POOLNUMRULE_BEGIN;
845 		}
846 		break;
847 	}
848 	if (pStrArr)
849 		rFillName = *(pStrArr->operator[] ( nId - nStt ) );
850 }
851 // Get the UI Name from the pool ID
FillUIName(sal_uInt16 nId,String & rFillName)852 void SwStyleNameMapper::FillUIName ( sal_uInt16 nId, String& rFillName )
853 {
854 	fillNameFromId ( nId, rFillName, sal_False );
855 }
856 // Get the UI Name from the pool ID
GetUIName(sal_uInt16 nId,const String & rName)857 const String& SwStyleNameMapper::GetUIName ( sal_uInt16 nId, const String& rName )
858 {
859 	return getNameFromId ( nId, rName, sal_False );
860 }
861 
862 // Get the programmatic Name from the pool ID
FillProgName(sal_uInt16 nId,String & rFillName)863 void SwStyleNameMapper::FillProgName ( sal_uInt16 nId, String& rFillName )
864 {
865 	fillNameFromId ( nId, rFillName, sal_True );
866 }
867 // Get the programmatic Name from the pool ID
GetProgName(sal_uInt16 nId,const String & rName)868 const String& SwStyleNameMapper::GetProgName ( sal_uInt16 nId, const String& rName )
869 {
870 	return getNameFromId ( nId, rName, sal_True );
871 }
872 // This gets the PoolId from the UI Name
GetPoolIdFromUIName(const String & rName,SwGetPoolIdFromName eFlags)873 sal_uInt16 SwStyleNameMapper::GetPoolIdFromUIName( const String& rName, SwGetPoolIdFromName eFlags )
874 {
875 	const NameToIdHash & rHashMap = getHashTable ( eFlags, sal_False );
876 	NameToIdHash::const_iterator aIter = rHashMap.find ( &rName );
877 	return aIter != rHashMap.end() ? (*aIter).second : USHRT_MAX;
878 }
879 // Get the Pool ID from the programmatic name
GetPoolIdFromProgName(const String & rName,SwGetPoolIdFromName eFlags)880 sal_uInt16 SwStyleNameMapper::GetPoolIdFromProgName( const String& rName, SwGetPoolIdFromName eFlags )
881 {
882 	const NameToIdHash & rHashMap = getHashTable ( eFlags, sal_True );
883 	NameToIdHash::const_iterator aIter = rHashMap.find ( &rName );
884 	return aIter != rHashMap.end() ? (*aIter).second : USHRT_MAX;
885 }
886 
NewUINameArray(SvStringsDtor * & pNameArray,sal_uInt16 nStt,sal_uInt16 nEnd)887 SvStringsDtor* SwStyleNameMapper::NewUINameArray( SvStringsDtor*& pNameArray, sal_uInt16 nStt, sal_uInt16 nEnd )
888 {
889 	if( !pNameArray )
890 	{
891 		pNameArray = new SvStringsDtor( static_cast < sal_Int8 > (nEnd - nStt), 1 );
892 		while( nStt < nEnd )
893 		{
894 			const ResId rRId( nStt, *pSwResMgr );
895 			String* pStr = new String( rRId );
896 			pNameArray->Insert( pStr, pNameArray->Count() );
897 			++nStt;
898 		}
899 	}
900 	return pNameArray;
901 }
902 
GetTextUINameArray()903 const SvStringsDtor& SwStyleNameMapper::GetTextUINameArray()
904 {
905 	return pTextUINameArray ? *pTextUINameArray :
906 		   *NewUINameArray( pTextUINameArray, RC_POOLCOLL_TEXT_BEGIN,
907 			( RC_POOLCOLL_TEXT_BEGIN +
908 					(RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN )) );
909 }
910 
GetListsUINameArray()911 const SvStringsDtor& SwStyleNameMapper::GetListsUINameArray()
912 {
913 	return pListsUINameArray ? *pListsUINameArray :
914 		   *NewUINameArray( pListsUINameArray, RC_POOLCOLL_LISTS_BEGIN,
915 			( RC_POOLCOLL_LISTS_BEGIN +
916 					(RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN )) );
917 }
918 
GetExtraUINameArray()919 const SvStringsDtor& SwStyleNameMapper::GetExtraUINameArray()
920 {
921 	return pExtraUINameArray ? *pExtraUINameArray :
922 		   *NewUINameArray( pExtraUINameArray, RC_POOLCOLL_EXTRA_BEGIN,
923 				( RC_POOLCOLL_EXTRA_BEGIN +
924 					(RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN )) );
925 }
926 
GetRegisterUINameArray()927 const SvStringsDtor& SwStyleNameMapper::GetRegisterUINameArray()
928 {
929 	return pRegisterUINameArray ? *pRegisterUINameArray :
930 		   *NewUINameArray( pRegisterUINameArray, RC_POOLCOLL_REGISTER_BEGIN,
931 			( RC_POOLCOLL_REGISTER_BEGIN +
932 				(RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN )) );
933 }
934 
GetDocUINameArray()935 const SvStringsDtor& SwStyleNameMapper::GetDocUINameArray()
936 {
937 	return pDocUINameArray ? *pDocUINameArray :
938 		   *NewUINameArray( pDocUINameArray, RC_POOLCOLL_DOC_BEGIN,
939 					( RC_POOLCOLL_DOC_BEGIN +
940 						(RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN )) );
941 }
942 
GetHTMLUINameArray()943 const SvStringsDtor& SwStyleNameMapper::GetHTMLUINameArray()
944 {
945 	return pHTMLUINameArray ? *pHTMLUINameArray :
946 		   *NewUINameArray( pHTMLUINameArray, RC_POOLCOLL_HTML_BEGIN,
947 					( RC_POOLCOLL_HTML_BEGIN +
948 						(RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN )) );
949 }
950 
GetFrmFmtUINameArray()951 const SvStringsDtor& SwStyleNameMapper::GetFrmFmtUINameArray()
952 {
953 	return pFrmFmtUINameArray ? *pFrmFmtUINameArray :
954 		   *NewUINameArray( pFrmFmtUINameArray, RC_POOLFRMFMT_BEGIN,
955 					( RC_POOLFRMFMT_BEGIN +
956 						(RES_POOLFRM_END - RES_POOLFRM_BEGIN )) );
957 }
958 
GetChrFmtUINameArray()959 const SvStringsDtor& SwStyleNameMapper::GetChrFmtUINameArray()
960 {
961 	return pChrFmtUINameArray ? *pChrFmtUINameArray :
962 		   *NewUINameArray( pChrFmtUINameArray, RC_POOLCHRFMT_BEGIN,
963 			( RC_POOLCHRFMT_BEGIN +
964 					(RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN )) );
965 }
966 
GetHTMLChrFmtUINameArray()967 const SvStringsDtor& SwStyleNameMapper::GetHTMLChrFmtUINameArray()
968 {
969 	return pHTMLChrFmtUINameArray ? *pHTMLChrFmtUINameArray :
970 		   *NewUINameArray( pHTMLChrFmtUINameArray, RC_POOLCHRFMT_HTML_BEGIN,
971 			( RC_POOLCHRFMT_HTML_BEGIN +
972 					(RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN )) );
973 }
974 
GetPageDescUINameArray()975 const SvStringsDtor& SwStyleNameMapper::GetPageDescUINameArray()
976 {
977 	return pPageDescUINameArray ? *pPageDescUINameArray :
978 		   *NewUINameArray( pPageDescUINameArray, RC_POOLPAGEDESC_BEGIN,
979 			( RC_POOLPAGEDESC_BEGIN +
980 					(RES_POOLPAGE_END - RES_POOLPAGE_BEGIN )) );
981 }
982 
GetNumRuleUINameArray()983 const SvStringsDtor& SwStyleNameMapper::GetNumRuleUINameArray()
984 {
985 	return pNumRuleUINameArray ? *pNumRuleUINameArray :
986 	       *NewUINameArray( pNumRuleUINameArray, RC_POOLNUMRULE_BEGIN,
987 			( RC_POOLNUMRULE_BEGIN +
988 					(RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN )) );
989 }
990 
NewProgNameArray(SvStringsDtor * & pProgNameArray,const SwTableEntry * pTable,sal_uInt8 nCount)991 SvStringsDtor* SwStyleNameMapper::NewProgNameArray( SvStringsDtor*& pProgNameArray, const SwTableEntry *pTable, sal_uInt8 nCount )
992 {
993 	if( !pProgNameArray )
994 	{
995 		pProgNameArray = new SvStringsDtor( nCount, 1 );
996 		while (pTable->nLength)
997 		{
998 			String* pStr = new String( pTable->pChar, pTable->nLength, RTL_TEXTENCODING_ASCII_US );
999 			pProgNameArray->Insert( pStr, pProgNameArray->Count() );
1000 			pTable++;
1001 		}
1002 	}
1003 	return pProgNameArray;
1004 }
1005 
GetTextProgNameArray()1006 const SvStringsDtor& SwStyleNameMapper::GetTextProgNameArray()
1007 {
1008 	return pTextProgNameArray ? *pTextProgNameArray :
1009 		   *NewProgNameArray( pTextProgNameArray, TextProgNameTable,
1010 			sizeof ( TextProgNameTable ) / sizeof ( SwTableEntry ) );
1011 }
1012 
GetListsProgNameArray()1013 const SvStringsDtor& SwStyleNameMapper::GetListsProgNameArray()
1014 {
1015 	return pListsProgNameArray ? *pListsProgNameArray :
1016 		   *NewProgNameArray( pListsProgNameArray, ListsProgNameTable,
1017 			sizeof ( ListsProgNameTable ) / sizeof ( SwTableEntry ) );
1018 }
1019 
GetExtraProgNameArray()1020 const SvStringsDtor& SwStyleNameMapper::GetExtraProgNameArray()
1021 {
1022 	return pExtraProgNameArray ? *pExtraProgNameArray :
1023 		   *NewProgNameArray( pExtraProgNameArray, ExtraProgNameTable,
1024 			sizeof ( ExtraProgNameTable ) / sizeof ( SwTableEntry ) );
1025 }
1026 
GetRegisterProgNameArray()1027 const SvStringsDtor& SwStyleNameMapper::GetRegisterProgNameArray()
1028 {
1029 	return pRegisterProgNameArray ? *pRegisterProgNameArray :
1030 		   *NewProgNameArray( pRegisterProgNameArray, RegisterProgNameTable,
1031 			sizeof ( RegisterProgNameTable ) / sizeof ( SwTableEntry ) );
1032 }
1033 
GetDocProgNameArray()1034 const SvStringsDtor& SwStyleNameMapper::GetDocProgNameArray()
1035 {
1036 	return pDocProgNameArray ? *pDocProgNameArray :
1037 		   *NewProgNameArray( pDocProgNameArray, DocProgNameTable,
1038 			sizeof ( DocProgNameTable ) / sizeof ( SwTableEntry ) );
1039 }
1040 
GetHTMLProgNameArray()1041 const SvStringsDtor& SwStyleNameMapper::GetHTMLProgNameArray()
1042 {
1043 	return pHTMLProgNameArray ? *pHTMLProgNameArray :
1044 		   *NewProgNameArray( pHTMLProgNameArray, HTMLProgNameTable,
1045 			sizeof ( HTMLProgNameTable ) / sizeof ( SwTableEntry ) );
1046 }
1047 
GetFrmFmtProgNameArray()1048 const SvStringsDtor& SwStyleNameMapper::GetFrmFmtProgNameArray()
1049 {
1050 	return pFrmFmtProgNameArray ? *pFrmFmtProgNameArray :
1051 		   *NewProgNameArray( pFrmFmtProgNameArray, FrmFmtProgNameTable,
1052 			sizeof ( FrmFmtProgNameTable ) / sizeof ( SwTableEntry ) );
1053 }
1054 
GetChrFmtProgNameArray()1055 const SvStringsDtor& SwStyleNameMapper::GetChrFmtProgNameArray()
1056 {
1057 	return pChrFmtProgNameArray ? *pChrFmtProgNameArray :
1058 		   *NewProgNameArray( pChrFmtProgNameArray, ChrFmtProgNameTable,
1059 			sizeof ( ChrFmtProgNameTable ) / sizeof ( SwTableEntry ) );
1060 }
1061 
GetHTMLChrFmtProgNameArray()1062 const SvStringsDtor& SwStyleNameMapper::GetHTMLChrFmtProgNameArray()
1063 {
1064 	return pHTMLChrFmtProgNameArray ? *pHTMLChrFmtProgNameArray :
1065 		   *NewProgNameArray( pHTMLChrFmtProgNameArray, HTMLChrFmtProgNameTable,
1066 			sizeof ( HTMLChrFmtProgNameTable ) / sizeof ( SwTableEntry ) );
1067 }
1068 
GetPageDescProgNameArray()1069 const SvStringsDtor& SwStyleNameMapper::GetPageDescProgNameArray()
1070 {
1071 	return pPageDescProgNameArray ? *pPageDescProgNameArray :
1072 		   *NewProgNameArray( pPageDescProgNameArray, PageDescProgNameTable,
1073 			sizeof ( PageDescProgNameTable ) / sizeof ( SwTableEntry ) );
1074 }
1075 
GetNumRuleProgNameArray()1076 const SvStringsDtor& SwStyleNameMapper::GetNumRuleProgNameArray()
1077 {
1078 	return pNumRuleProgNameArray ? *pNumRuleProgNameArray :
1079 		   *NewProgNameArray( pNumRuleProgNameArray, NumRuleProgNameTable,
1080 			sizeof ( NumRuleProgNameTable ) / sizeof ( SwTableEntry ) );
1081 }
1082 
1083 
GetSpecialExtraProgName(const String & rExtraUIName)1084 const String SwStyleNameMapper::GetSpecialExtraProgName( const String& rExtraUIName )
1085 {
1086     String aRes = rExtraUIName;
1087     sal_Bool bChgName = sal_False;
1088     const SvStringsDtor& rExtraArr = GetExtraUINameArray();
1089     static sal_uInt16 nIds[] =
1090     {
1091         RES_POOLCOLL_LABEL_DRAWING - RES_POOLCOLL_EXTRA_BEGIN,
1092         RES_POOLCOLL_LABEL_ABB - RES_POOLCOLL_EXTRA_BEGIN,
1093         RES_POOLCOLL_LABEL_TABLE - RES_POOLCOLL_EXTRA_BEGIN,
1094         RES_POOLCOLL_LABEL_FRAME- RES_POOLCOLL_EXTRA_BEGIN,
1095         0
1096     };
1097     const sal_uInt16 * pIds;
1098     for ( pIds = nIds; *pIds; ++pIds)
1099     {
1100         if (aRes == *rExtraArr[ *pIds ])
1101         {
1102             bChgName = sal_True;
1103             break;
1104         }
1105     }
1106     if (bChgName)
1107         aRes = *GetExtraProgNameArray()[*pIds];
1108     return aRes;
1109 }
1110 
GetSpecialExtraUIName(const String & rExtraProgName)1111 const String SwStyleNameMapper::GetSpecialExtraUIName( const String& rExtraProgName )
1112 {
1113     String aRes = rExtraProgName;
1114     sal_Bool bChgName = sal_False;
1115     const SvStringsDtor& rExtraArr = GetExtraProgNameArray();
1116     static sal_uInt16 nIds[] =
1117     {
1118         RES_POOLCOLL_LABEL_DRAWING - RES_POOLCOLL_EXTRA_BEGIN,
1119         RES_POOLCOLL_LABEL_ABB - RES_POOLCOLL_EXTRA_BEGIN,
1120         RES_POOLCOLL_LABEL_TABLE - RES_POOLCOLL_EXTRA_BEGIN,
1121         RES_POOLCOLL_LABEL_FRAME- RES_POOLCOLL_EXTRA_BEGIN,
1122         0
1123     };
1124     const sal_uInt16 * pIds;
1125 
1126     for ( pIds = nIds; *pIds; ++pIds)
1127     {
1128         if (aRes == *rExtraArr[ *pIds ])
1129         {
1130             bChgName = sal_True;
1131             break;
1132         }
1133     }
1134     if (bChgName)
1135         aRes = *GetExtraUINameArray()[*pIds];
1136     return aRes;
1137 }
1138 
1139