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 #include <DocumentStylePoolManager.hxx>
20 #include <SwStyleNameMapper.hxx>
21 #include <doc.hxx>
22 #include <DocumentSettingManager.hxx>
23 #include <IDocumentState.hxx>
24 #include <IDocumentUndoRedo.hxx>
25 #include <fmtanchr.hxx>
26 #include <fmtfsize.hxx>
27 #include <paratr.hxx>
28 #include <poolfmt.hxx>
29 #include <fmtornt.hxx>
30 #include <charfmt.hxx>
31 #include <fmtsrnd.hxx>
32 #include <docary.hxx>
33 #include <pagedesc.hxx>
34 #include <frmfmt.hxx>
35 #include <fmtline.hxx>
36 #include <numrule.hxx>
37 #include <hints.hxx>
38 #include <editeng/paperinf.hxx>
39 #include <editeng/wghtitem.hxx>
40 #include <editeng/fontitem.hxx>
41 #include <editeng/fhgtitem.hxx>
42 #include <editeng/tstpitem.hxx>
43 #include <editeng/lrspitem.hxx>
44 #include <editeng/ulspitem.hxx>
45 #include <editeng/lspcitem.hxx>
46 #include <editeng/adjustitem.hxx>
47 #include <editeng/postitem.hxx>
48 #include <editeng/keepitem.hxx>
49 #include <editeng/opaqitem.hxx>
50 #include <editeng/boxitem.hxx>
51 #include <editeng/cmapitem.hxx>
52 #include <editeng/udlnitem.hxx>
53 #include <editeng/colritem.hxx>
54 #include <editeng/protitem.hxx>
55 #include <editeng/escapementitem.hxx>
56 #include <editeng/langitem.hxx>
57 #include <editeng/charrotateitem.hxx>
58 #include <editeng/emphasismarkitem.hxx>
59 #include <editeng/scriptspaceitem.hxx>
60 #include <o3tl/unit_conversion.hxx>
61 #include <svx/strings.hrc>
62 #include <svx/dialmgr.hxx>
63 #include <sal/log.hxx>
64 #include <osl/diagnose.h>
65 #include <strings.hrc>
66 #include <frmatr.hxx>
67 #include <frameformats.hxx>
68 #include <com/sun/star/text/VertOrientation.hpp>
69 #include <com/sun/star/text/RelOrientation.hpp>
70 #include <com/sun/star/text/HoriOrientation.hpp>
71 #include <unotools/syslocale.hxx>
72 #include <i18nlangtag/languagetag.hxx>
73 #include <comphelper/lok.hxx>
74 #include <names.hxx>
75
76 using namespace ::editeng;
77 using namespace ::com::sun::star;
78
IsConditionalByPoolId(sal_uInt16 nId)79 bool IsConditionalByPoolId(sal_uInt16 nId)
80 {
81 // TODO: why is this style conditional?
82 // If it is changed to no longer be conditional, then a style "Text Body"
83 // will be imported without its conditions from ODF.
84 return RES_POOLCOLL_TEXT == nId;
85 }
86
87 namespace
88 {
89 const sal_uInt16 PT_3 = 3 * 20; // 3 pt
90 const sal_uInt16 PT_6 = 6 * 20; // 6 pt
91 const sal_uInt16 PT_7 = 7 * 20; // 7 pt
92 const sal_uInt16 PT_9 = 9 * 20; // 9 pt
93 const sal_uInt16 PT_10 = 10 * 20; // 10 pt
94 const sal_uInt16 PT_12 = 12 * 20; // 12 pt
95 const sal_uInt16 PT_13 = 13 * 20; // 13 pt
96 const sal_uInt16 PT_14 = 14 * 20; // 14 pt
97 const sal_uInt16 PT_16 = 16 * 20; // 16 pt
98 const sal_uInt16 PT_18 = 18 * 20; // 18 pt
99 const sal_uInt16 PT_24 = 24 * 20; // 24 pt
100 const sal_uInt16 PT_28 = 28 * 20; // 28 pt
101
102 const sal_uInt16 HTML_PARSPACE = o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip);
103
104 const sal_uInt16 aHeadlineSizes[ 2 * MAXLEVEL ] = {
105 // we do everything percentual now:
106 PT_18, PT_16, PT_14, PT_13, PT_12,
107 PT_12, PT_10, PT_10, PT_9, PT_9, // normal
108
109 PT_24, PT_18, PT_14, PT_12, PT_10,
110 PT_7, PT_7, PT_7, PT_7, PT_7 // HTML mode
111 };
112
lcl_GetRightMargin(SwDoc & rDoc)113 tools::Long lcl_GetRightMargin( SwDoc& rDoc )
114 {
115 // Make sure that the printer settings are taken over to the standard
116 // page style
117 const SwFrameFormat& rPgDscFormat = rDoc.GetPageDesc( 0 ).GetMaster();
118 const SvxLRSpaceItem& rLR = rPgDscFormat.GetLRSpace();
119 const tools::Long nLeft = rLR.ResolveLeft({});
120 const tools::Long nRight = rLR.ResolveRight({});
121 const tools::Long nWidth = rPgDscFormat.GetFrameSize().GetWidth();
122 return nWidth - nLeft - nRight;
123 }
124
lcl_SetDfltFont(DefaultFontType nFntType,SfxItemSet & rSet)125 void lcl_SetDfltFont( DefaultFontType nFntType, SfxItemSet& rSet )
126 {
127 static const struct {
128 sal_uInt16 nResLngId;
129 sal_uInt16 nResFntId;
130 } aArr[ 3 ] = {
131 { RES_CHRATR_LANGUAGE, RES_CHRATR_FONT },
132 { RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_FONT },
133 { RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_FONT }
134 };
135 for(const auto & n : aArr)
136 {
137 LanguageType nLng = static_cast<const SvxLanguageItem&>(rSet.GetPool()->GetUserOrPoolDefaultItem(
138 n.nResLngId )).GetLanguage();
139 vcl::Font aFnt( OutputDevice::GetDefaultFont( nFntType,
140 nLng, GetDefaultFontFlags::OnlyOne ) );
141
142 rSet.Put( SvxFontItem( aFnt.GetFamilyTypeMaybeAskConfig(), aFnt.GetFamilyName(),
143 OUString(), aFnt.GetPitchMaybeAskConfig(),
144 aFnt.GetCharSet(), n.nResFntId ));
145 }
146 }
147
lcl_SetDfltFont(DefaultFontType nLatinFntType,DefaultFontType nCJKFntType,DefaultFontType nCTLFntType,SfxItemSet & rSet)148 void lcl_SetDfltFont( DefaultFontType nLatinFntType, DefaultFontType nCJKFntType,
149 DefaultFontType nCTLFntType, SfxItemSet& rSet )
150 {
151 const struct {
152 sal_uInt16 nResLngId;
153 sal_uInt16 nResFntId;
154 DefaultFontType nFntType;
155 } aArr[ 3 ] = {
156 { RES_CHRATR_LANGUAGE, RES_CHRATR_FONT, nLatinFntType },
157 { RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_FONT, nCJKFntType },
158 { RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_FONT, nCTLFntType }
159 };
160
161 for(const auto & n : aArr)
162 {
163 LanguageType nLng = static_cast<const SvxLanguageItem&>(rSet.GetPool()->GetUserOrPoolDefaultItem(
164 n.nResLngId )).GetLanguage();
165 vcl::Font aFnt( OutputDevice::GetDefaultFont( n.nFntType,
166 nLng, GetDefaultFontFlags::OnlyOne ) );
167
168 rSet.Put( SvxFontItem( aFnt.GetFamilyTypeMaybeAskConfig(), aFnt.GetFamilyName(),
169 OUString(), aFnt.GetPitchMaybeAskConfig(),
170 aFnt.GetCharSet(), n.nResFntId ));
171 }
172 }
173
lcl_SetHeadline(SwDoc & rDoc,SwTextFormatColl * pColl,SfxItemSet & rSet,sal_uInt16 nOutLvlBits,sal_uInt8 nLevel,bool bItalic)174 void lcl_SetHeadline( SwDoc& rDoc, SwTextFormatColl* pColl,
175 SfxItemSet& rSet,
176 sal_uInt16 nOutLvlBits, sal_uInt8 nLevel, bool bItalic )
177 {
178 SetAllScriptItem( rSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
179 SvxFontHeightItem aHItem(240, 100, RES_CHRATR_FONTSIZE);
180 const bool bHTMLMode = rDoc.GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE);
181 if( bHTMLMode )
182 aHItem.SetHeight( aHeadlineSizes[ MAXLEVEL + nLevel ] );
183 else
184 aHItem.SetHeight( aHeadlineSizes[ nLevel ] );
185 SetAllScriptItem( rSet, aHItem );
186
187 if( bItalic && !bHTMLMode )
188 SetAllScriptItem( rSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE ) );
189
190 if( bHTMLMode )
191 {
192 lcl_SetDfltFont( DefaultFontType::LATIN_TEXT, DefaultFontType::CJK_TEXT,
193 DefaultFontType::CTL_TEXT, rSet );
194 }
195
196 if( !pColl )
197 return;
198
199 if( !( nOutLvlBits & ( 1 << nLevel )) )
200 {
201 pColl->AssignToListLevelOfOutlineStyle(nLevel);
202 if( !bHTMLMode )
203 {
204 SwNumRule * pOutlineRule = rDoc.GetOutlineNumRule();
205 const SwNumFormat& rNFormat = pOutlineRule->Get( nLevel );
206
207 if ( rNFormat.GetPositionAndSpaceMode() ==
208 SvxNumberFormat::LABEL_WIDTH_AND_POSITION &&
209 ( rNFormat.GetAbsLSpace() || rNFormat.GetFirstLineOffset() ) )
210 {
211 SvxFirstLineIndentItem firstLine(pColl->GetFormatAttr(RES_MARGIN_FIRSTLINE));
212 SvxTextLeftMarginItem leftMargin(pColl->GetFormatAttr(RES_MARGIN_TEXTLEFT));
213 firstLine.SetTextFirstLineOffset(
214 SvxIndentValue{ static_cast<double>(rNFormat.GetFirstLineOffset()),
215 rNFormat.GetFirstLineOffsetUnit() });
216 leftMargin.SetTextLeft(SvxIndentValue::twips(rNFormat.GetAbsLSpace()));
217 pColl->SetFormatAttr(firstLine);
218 pColl->SetFormatAttr(leftMargin);
219 }
220
221 // All paragraph styles, which are assigned to a level of the
222 // outline style has to have the outline style set as its list style.
223 SwNumRuleItem aItem(pOutlineRule->GetName());
224 pColl->SetFormatAttr(aItem);
225 }
226 }
227 pColl->SetNextTextFormatColl( *rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_TEXT ));
228 }
229
lcl_SetRegister(SwDoc & rDoc,SfxItemSet & rSet,sal_uInt16 nFact,bool bHeader,bool bTab)230 void lcl_SetRegister( SwDoc& rDoc, SfxItemSet& rSet, sal_uInt16 nFact,
231 bool bHeader, bool bTab )
232 {
233 sal_uInt16 nLeft = o3tl::convert(5 * nFact, o3tl::Length::mm, o3tl::Length::twip);
234 SvxFirstLineIndentItem const firstLine(RES_MARGIN_FIRSTLINE);
235 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(nLeft), RES_MARGIN_TEXTLEFT);
236 rSet.Put(firstLine);
237 rSet.Put(leftMargin);
238 if( bHeader )
239 {
240 SetAllScriptItem( rSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
241 SetAllScriptItem( rSet, SvxFontHeightItem( PT_16, 100, RES_CHRATR_FONTSIZE ) );
242 }
243 if( bTab )
244 {
245 tools::Long nRightMargin = lcl_GetRightMargin( rDoc );
246 SvxTabStopItem aTStops( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP );
247 aTStops.Insert( SvxTabStop( nRightMargin - nLeft,
248 SvxTabAdjust::Right,
249 cDfltDecimalChar, '.' ));
250 rSet.Put( aTStops );
251 }
252 }
253
lcl_SetNumBul(SwDoc & rDoc,SwTextFormatColl * pColl,SfxItemSet & rSet,sal_uInt16 nNxt,SwTwips nEZ,SwTwips nLeft,SwTwips nUpper,SwTwips nLower)254 void lcl_SetNumBul( SwDoc& rDoc, SwTextFormatColl* pColl,
255 SfxItemSet& rSet,
256 sal_uInt16 nNxt, SwTwips nEZ, SwTwips nLeft,
257 SwTwips nUpper, SwTwips nLower )
258 {
259 SvxFirstLineIndentItem firstLine(SvxIndentValue::twips(nEZ), RES_MARGIN_FIRSTLINE);
260
261 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(nLeft), RES_MARGIN_TEXTLEFT);
262 rSet.Put(firstLine);
263 rSet.Put(leftMargin);
264 SvxULSpaceItem aUL( RES_UL_SPACE );
265 aUL.SetUpper( sal_uInt16(nUpper) );
266 aUL.SetLower( sal_uInt16(nLower) );
267 rSet.Put( aUL );
268
269 if( pColl )
270 pColl->SetNextTextFormatColl( *rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( nNxt ));
271 }
272
lcl_PutStdPageSizeIntoItemSet(SwDoc & rDoc,SfxItemSet & rSet)273 void lcl_PutStdPageSizeIntoItemSet( SwDoc& rDoc, SfxItemSet& rSet )
274 {
275 SwPageDesc* pStdPgDsc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( RES_POOLPAGE_STANDARD );
276 SwFormatFrameSize aFrameSz( pStdPgDsc->GetMaster().GetFrameSize() );
277 if( pStdPgDsc->GetLandscape() )
278 {
279 SwTwips nTmp = aFrameSz.GetHeight();
280 aFrameSz.SetHeight( aFrameSz.GetWidth() );
281 aFrameSz.SetWidth( nTmp );
282 }
283 rSet.Put( aFrameSz );
284 }
285 }
286
287 const TranslateId STR_POOLCOLL_TEXT_ARY[] =
288 {
289 // Category Text
290 STR_POOLCOLL_STANDARD,
291 STR_POOLCOLL_TEXT,
292 STR_POOLCOLL_TEXT_IDENT,
293 STR_POOLCOLL_TEXT_NEGIDENT,
294 STR_POOLCOLL_TEXT_MOVE,
295 STR_POOLCOLL_GREETING,
296 STR_POOLCOLL_SIGNATURE,
297 STR_POOLCOLL_CONFRONTATION,
298 STR_POOLCOLL_MARGINAL
299 };
300
301 const TranslateId STR_POOLCOLL_LISTS_ARY[]
302 {
303 // Category Lists
304 STR_POOLCOLL_NUMBER_BULLET_BASE,
305 // Subcategory Numbering
306 STR_POOLCOLL_NUM_LEVEL1S,
307 STR_POOLCOLL_NUM_LEVEL1,
308 STR_POOLCOLL_NUM_LEVEL1E,
309 STR_POOLCOLL_NUM_NONUM1,
310 STR_POOLCOLL_NUM_LEVEL2S,
311 STR_POOLCOLL_NUM_LEVEL2,
312 STR_POOLCOLL_NUM_LEVEL2E,
313 STR_POOLCOLL_NUM_NONUM2,
314 STR_POOLCOLL_NUM_LEVEL3S,
315 STR_POOLCOLL_NUM_LEVEL3,
316 STR_POOLCOLL_NUM_LEVEL3E,
317 STR_POOLCOLL_NUM_NONUM3,
318 STR_POOLCOLL_NUM_LEVEL4S,
319 STR_POOLCOLL_NUM_LEVEL4,
320 STR_POOLCOLL_NUM_LEVEL4E,
321 STR_POOLCOLL_NUM_NONUM4,
322 STR_POOLCOLL_NUM_LEVEL5S,
323 STR_POOLCOLL_NUM_LEVEL5,
324 STR_POOLCOLL_NUM_LEVEL5E,
325 STR_POOLCOLL_NUM_NONUM5,
326
327 // Subcategory Enumeration
328 STR_POOLCOLL_BULLET_LEVEL1S,
329 STR_POOLCOLL_BULLET_LEVEL1,
330 STR_POOLCOLL_BULLET_LEVEL1E,
331 STR_POOLCOLL_BULLET_NONUM1,
332 STR_POOLCOLL_BULLET_LEVEL2S,
333 STR_POOLCOLL_BULLET_LEVEL2,
334 STR_POOLCOLL_BULLET_LEVEL2E,
335 STR_POOLCOLL_BULLET_NONUM2,
336 STR_POOLCOLL_BULLET_LEVEL3S,
337 STR_POOLCOLL_BULLET_LEVEL3,
338 STR_POOLCOLL_BULLET_LEVEL3E,
339 STR_POOLCOLL_BULLET_NONUM3,
340 STR_POOLCOLL_BULLET_LEVEL4S,
341 STR_POOLCOLL_BULLET_LEVEL4,
342 STR_POOLCOLL_BULLET_LEVEL4E,
343 STR_POOLCOLL_BULLET_NONUM4,
344 STR_POOLCOLL_BULLET_LEVEL5S,
345 STR_POOLCOLL_BULLET_LEVEL5,
346 STR_POOLCOLL_BULLET_LEVEL5E,
347 STR_POOLCOLL_BULLET_NONUM5
348 };
349
350 // Special Areas
351 const TranslateId STR_POOLCOLL_EXTRA_ARY[]
352 {
353 // Subcategory Header
354 STR_POOLCOLL_HEADERFOOTER,
355 STR_POOLCOLL_HEADER,
356 STR_POOLCOLL_HEADERL,
357 STR_POOLCOLL_HEADERR,
358 // Subcategory Footer
359 STR_POOLCOLL_FOOTER,
360 STR_POOLCOLL_FOOTERL,
361 STR_POOLCOLL_FOOTERR,
362 // Subcategory Table
363 STR_POOLCOLL_TABLE,
364 STR_POOLCOLL_TABLE_HDLN,
365 // Subcategory Labels
366 STR_POOLCOLL_LABEL,
367 STR_POOLCOLL_LABEL_ABB,
368 STR_POOLCOLL_LABEL_TABLE,
369 STR_POOLCOLL_LABEL_FRAME,
370 STR_POOLCOLL_LABEL_FIGURE,
371 // Miscellaneous
372 STR_POOLCOLL_FRAME,
373 STR_POOLCOLL_FOOTNOTE,
374 STR_POOLCOLL_ENVELOPE_ADDRESS,
375 STR_POOLCOLL_SEND_ADDRESS,
376 STR_POOLCOLL_ENDNOTE,
377 STR_POOLCOLL_LABEL_DRAWING,
378 STR_POOLCOLL_COMMENT
379 };
380
381 const TranslateId STR_POOLCOLL_REGISTER_ARY[] =
382 {
383 // Category Directories
384 STR_POOLCOLL_REGISTER_BASE,
385 // Subcategory Index-Directories
386 STR_POOLCOLL_TOX_IDXH,
387 STR_POOLCOLL_TOX_IDX1,
388 STR_POOLCOLL_TOX_IDX2,
389 STR_POOLCOLL_TOX_IDX3,
390 STR_POOLCOLL_TOX_IDXBREAK,
391 // Subcategory Tables of Contents
392 STR_POOLCOLL_TOX_CNTNTH,
393 STR_POOLCOLL_TOX_CNTNT1,
394 STR_POOLCOLL_TOX_CNTNT2,
395 STR_POOLCOLL_TOX_CNTNT3,
396 STR_POOLCOLL_TOX_CNTNT4,
397 STR_POOLCOLL_TOX_CNTNT5,
398 // Subcategory User-Directories:
399 STR_POOLCOLL_TOX_USERH,
400 STR_POOLCOLL_TOX_USER1,
401 STR_POOLCOLL_TOX_USER2,
402 STR_POOLCOLL_TOX_USER3,
403 STR_POOLCOLL_TOX_USER4,
404 STR_POOLCOLL_TOX_USER5,
405 // Subcategory Table of Contents more Levels 5 - 10
406 STR_POOLCOLL_TOX_CNTNT6,
407 STR_POOLCOLL_TOX_CNTNT7,
408 STR_POOLCOLL_TOX_CNTNT8,
409 STR_POOLCOLL_TOX_CNTNT9,
410 STR_POOLCOLL_TOX_CNTNT10,
411 // Illustrations Index
412 STR_POOLCOLL_TOX_ILLUSH,
413 STR_POOLCOLL_TOX_ILLUS1,
414 // Object Index
415 STR_POOLCOLL_TOX_OBJECTH,
416 STR_POOLCOLL_TOX_OBJECT1,
417 // Tables Index
418 STR_POOLCOLL_TOX_TABLESH,
419 STR_POOLCOLL_TOX_TABLES1,
420 // Index of Authorities
421 STR_POOLCOLL_TOX_AUTHORITIESH,
422 STR_POOLCOLL_TOX_AUTHORITIES1,
423 // Subcategory User-Directories more Levels 5 - 10
424 STR_POOLCOLL_TOX_USER6,
425 STR_POOLCOLL_TOX_USER7,
426 STR_POOLCOLL_TOX_USER8,
427 STR_POOLCOLL_TOX_USER9,
428 STR_POOLCOLL_TOX_USER10
429 };
430
431 const TranslateId STR_POOLCOLL_DOC_ARY[] =
432 {
433 // Category Chapter/Document
434 STR_POOLCOLL_DOC_TITLE,
435 STR_POOLCOLL_DOC_SUBTITLE,
436 STR_POOLCOLL_DOC_APPENDIX,
437 // Subcategory Headlines
438 STR_POOLCOLL_HEADLINE_BASE,
439 STR_POOLCOLL_HEADLINE1,
440 STR_POOLCOLL_HEADLINE2,
441 STR_POOLCOLL_HEADLINE3,
442 STR_POOLCOLL_HEADLINE4,
443 STR_POOLCOLL_HEADLINE5,
444 STR_POOLCOLL_HEADLINE6,
445 STR_POOLCOLL_HEADLINE7,
446 STR_POOLCOLL_HEADLINE8,
447 STR_POOLCOLL_HEADLINE9,
448 STR_POOLCOLL_HEADLINE10
449 };
450
451 const TranslateId STR_POOLCOLL_HTML_ARY[] =
452 {
453 // Category HTML-Templates
454 STR_POOLCOLL_HTML_BLOCKQUOTE,
455 STR_POOLCOLL_HTML_PRE,
456 STR_POOLCOLL_HTML_HR,
457 STR_POOLCOLL_HTML_DD,
458 STR_POOLCOLL_HTML_DT
459 };
460
461 const TranslateId STR_POOLCHR_ARY[] =
462 {
463 STR_POOLCHR_FOOTNOTE,
464 STR_POOLCHR_PAGENO,
465 STR_POOLCHR_LABEL,
466 STR_POOLCHR_DROPCAPS,
467 STR_POOLCHR_NUM_LEVEL,
468 STR_POOLCHR_BULLET_LEVEL,
469 STR_POOLCHR_INET_NORMAL,
470 STR_POOLCHR_INET_VISIT,
471 STR_POOLCHR_JUMPEDIT,
472 STR_POOLCHR_TOXJUMP,
473 STR_POOLCHR_ENDNOTE,
474 STR_POOLCHR_LINENUM,
475 STR_POOLCHR_IDX_MAIN_ENTRY,
476 STR_POOLCHR_FOOTNOTE_ANCHOR,
477 STR_POOLCHR_ENDNOTE_ANCHOR,
478 STR_POOLCHR_RUBYTEXT,
479 STR_POOLCHR_VERT_NUM
480 };
481
482 const TranslateId STR_POOLCHR_HTML_ARY[] =
483 {
484 STR_POOLCHR_HTML_EMPHASIS,
485 STR_POOLCHR_HTML_CITATION,
486 STR_POOLCHR_HTML_STRONG,
487 STR_POOLCHR_HTML_CODE,
488 STR_POOLCHR_HTML_SAMPLE,
489 STR_POOLCHR_HTML_KEYBOARD,
490 STR_POOLCHR_HTML_VARIABLE,
491 STR_POOLCHR_HTML_DEFINSTANCE,
492 STR_POOLCHR_HTML_TELETYPE
493 };
494
495 const TranslateId STR_POOLFRM_ARY[] =
496 {
497 STR_POOLFRM_FRAME,
498 STR_POOLFRM_GRAPHIC,
499 STR_POOLFRM_OLE,
500 STR_POOLFRM_FORMEL,
501 STR_POOLFRM_MARGINAL,
502 STR_POOLFRM_WATERSIGN,
503 STR_POOLFRM_LABEL,
504 STR_POOLFRM_INLINE_HEADING
505 };
506
507 const TranslateId STR_POOLPAGE_ARY[] =
508 {
509 // Page styles
510 STR_POOLPAGE_STANDARD,
511 STR_POOLPAGE_FIRST,
512 STR_POOLPAGE_LEFT,
513 STR_POOLPAGE_RIGHT,
514 STR_POOLPAGE_ENVELOPE,
515 STR_POOLPAGE_REGISTER,
516 STR_POOLPAGE_HTML,
517 STR_POOLPAGE_FOOTNOTE,
518 STR_POOLPAGE_ENDNOTE,
519 STR_POOLPAGE_LANDSCAPE
520 };
521
522 const TranslateId STR_POOLNUMRULE_NUM_ARY[] =
523 {
524 // Numbering styles
525 STR_POOLNUMRULE_NOLIST,
526 STR_POOLNUMRULE_NUM1,
527 STR_POOLNUMRULE_NUM2,
528 STR_POOLNUMRULE_NUM3,
529 STR_POOLNUMRULE_NUM4,
530 STR_POOLNUMRULE_NUM5,
531 STR_POOLNUMRULE_BUL1,
532 STR_POOLNUMRULE_BUL2,
533 STR_POOLNUMRULE_BUL3,
534 STR_POOLNUMRULE_BUL4,
535 STR_POOLNUMRULE_BUL5
536 };
537
538 // XXX MUST match the entries of TableStyleProgNameTable in
539 // sw/source/core/doc/SwStyleNameMapper.cxx and MUST match the order of
540 // RES_POOL_TABLESTYLE_TYPE in sw/inc/poolfmt.hxx
541 const TranslateId STR_TABSTYLE_ARY[] =
542 {
543 // XXX MUST be in order, Writer first, then Svx old, then Svx new
544 // 1 Writer resource string
545 STR_TABSTYLE_DEFAULT,
546 // 16 old styles Svx resource strings
547 RID_SVXSTR_TBLAFMT_3D,
548 RID_SVXSTR_TBLAFMT_BLACK1,
549 RID_SVXSTR_TBLAFMT_BLACK2,
550 RID_SVXSTR_TBLAFMT_BLUE,
551 RID_SVXSTR_TBLAFMT_BROWN,
552 RID_SVXSTR_TBLAFMT_CURRENCY,
553 RID_SVXSTR_TBLAFMT_CURRENCY_3D,
554 RID_SVXSTR_TBLAFMT_CURRENCY_GRAY,
555 RID_SVXSTR_TBLAFMT_CURRENCY_LAVENDER,
556 RID_SVXSTR_TBLAFMT_CURRENCY_TURQUOISE,
557 RID_SVXSTR_TBLAFMT_GRAY,
558 RID_SVXSTR_TBLAFMT_GREEN,
559 RID_SVXSTR_TBLAFMT_LAVENDER,
560 RID_SVXSTR_TBLAFMT_RED,
561 RID_SVXSTR_TBLAFMT_TURQUOISE,
562 RID_SVXSTR_TBLAFMT_YELLOW,
563 // 10 new styles since LibreOffice 6.0 Svx resource strings
564 RID_SVXSTR_TBLAFMT_LO6_ACADEMIC,
565 RID_SVXSTR_TBLAFMT_LO6_BOX_LIST_BLUE,
566 RID_SVXSTR_TBLAFMT_LO6_BOX_LIST_GREEN,
567 RID_SVXSTR_TBLAFMT_LO6_BOX_LIST_RED,
568 RID_SVXSTR_TBLAFMT_LO6_BOX_LIST_YELLOW,
569 RID_SVXSTR_TBLAFMT_LO6_ELEGANT,
570 RID_SVXSTR_TBLAFMT_LO6_FINANCIAL,
571 RID_SVXSTR_TBLAFMT_LO6_SIMPLE_GRID_COLUMNS,
572 RID_SVXSTR_TBLAFMT_LO6_SIMPLE_GRID_ROWS,
573 RID_SVXSTR_TBLAFMT_LO6_SIMPLE_LIST_SHADED
574 };
575
576 namespace sw
577 {
578
DocumentStylePoolManager(SwDoc & i_rSwdoc)579 DocumentStylePoolManager::DocumentStylePoolManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc )
580 {
581 }
582
GetTextCollFromPool(sal_uInt16 nId,bool bRegardLanguage)583 SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, bool bRegardLanguage )
584 {
585 OSL_ENSURE(
586 (RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END) ||
587 (RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END) ||
588 (RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END) ||
589 (RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END) ||
590 (RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END) ||
591 (RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END),
592 "Wrong AutoFormat Id" );
593
594 SwTextFormatColl* pNewColl;
595 sal_uInt16 nOutLvlBits = 0;
596
597 for (size_t n = 0, nSize = m_rDoc.GetTextFormatColls()->size(); n < nSize; ++n)
598 {
599 pNewColl = (*m_rDoc.GetTextFormatColls())[ n ];
600 if( nId == pNewColl->GetPoolFormatId() )
601 {
602 // in online we can have multiple languages, use translated name
603 if (comphelper::LibreOfficeKit::isActive())
604 {
605 UIName aName = SwStyleNameMapper::GetUIName(nId, ProgName());
606 if (!aName.isEmpty())
607 pNewColl->SetFormatName(aName);
608 }
609
610 return pNewColl;
611 }
612
613 if( pNewColl->IsAssignedToListLevelOfOutlineStyle())
614 nOutLvlBits |= ( 1 << pNewColl->GetAssignedOutlineStyleLevel() );
615 }
616
617 // Didn't find it until here -> create anew
618 TranslateId pResId;
619 if (RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END)
620 {
621 static_assert(std::ssize(STR_POOLCOLL_TEXT_ARY) == RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN, "### unexpected size!");
622 pResId = STR_POOLCOLL_TEXT_ARY[nId - RES_POOLCOLL_TEXT_BEGIN];
623 }
624 else if (RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END)
625 {
626 static_assert(std::ssize(STR_POOLCOLL_LISTS_ARY) == RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN, "### unexpected size!");
627 pResId = STR_POOLCOLL_LISTS_ARY[nId - RES_POOLCOLL_LISTS_BEGIN];
628 }
629 else if (RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END)
630 {
631 static_assert(std::ssize(STR_POOLCOLL_EXTRA_ARY) == RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN, "### unexpected size!");
632 pResId = STR_POOLCOLL_EXTRA_ARY[nId - RES_POOLCOLL_EXTRA_BEGIN];
633 }
634 else if (RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END)
635 {
636 static_assert(std::ssize(STR_POOLCOLL_REGISTER_ARY) == RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN, "### unexpected size!");
637 pResId = STR_POOLCOLL_REGISTER_ARY[nId - RES_POOLCOLL_REGISTER_BEGIN];
638 }
639 else if (RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END)
640 {
641 static_assert(std::ssize(STR_POOLCOLL_DOC_ARY) == RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN, "### unexpected size!");
642 pResId = STR_POOLCOLL_DOC_ARY[nId - RES_POOLCOLL_DOC_BEGIN];
643 }
644 else if (RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END)
645 {
646 static_assert(std::ssize(STR_POOLCOLL_HTML_ARY) == RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN, "### unexpected size!");
647 pResId = STR_POOLCOLL_HTML_ARY[nId - RES_POOLCOLL_HTML_BEGIN];
648 }
649
650 OSL_ENSURE(pResId, "Invalid Pool ID");
651 if (!pResId)
652 return GetTextCollFromPool(RES_POOLCOLL_STANDARD);
653
654 UIName aNm(SwResId(pResId));
655
656 // A Set for all to-be-set Attributes
657 SwAttrSet aSet( m_rDoc.GetAttrPool(), aTextFormatCollSetRange );
658 sal_uInt16 nParent = GetPoolParent( nId );
659
660 {
661
662 if(::IsConditionalByPoolId( nId ))
663 pNewColl = new SwConditionTextFormatColl( m_rDoc.GetAttrPool(), aNm, !nParent
664 ? m_rDoc.GetDfltTextFormatColl()
665 : GetTextCollFromPool( nParent ));
666 else
667 pNewColl = new SwTextFormatColl( m_rDoc.GetAttrPool(), aNm, !nParent
668 ? m_rDoc.GetDfltTextFormatColl()
669 : GetTextCollFromPool( nParent ));
670 pNewColl->SetPoolFormatId( nId );
671 m_rDoc.GetTextFormatColls()->push_back( pNewColl );
672 }
673
674 bool bNoDefault = m_rDoc.GetDocumentSettingManager().get( DocumentSettingId::STYLES_NODEFAULT );
675 if ( !bNoDefault )
676 {
677 switch( nId )
678 {
679 // General content forms
680 case RES_POOLCOLL_STANDARD:
681 /* koreans do not like SvxScriptItem(TRUE) */
682 if (bRegardLanguage)
683 {
684 LanguageType nAppLanguage = GetAppLanguage();
685 if (GetDefaultFrameDirection(nAppLanguage) ==
686 SvxFrameDirection::Horizontal_RL_TB)
687 {
688 SvxAdjustItem aAdjust(SvxAdjust::Right, RES_PARATR_ADJUST );
689 aSet.Put(aAdjust);
690 }
691 if (nAppLanguage == LANGUAGE_KOREAN)
692 {
693 SvxScriptSpaceItem aScriptSpace(false, RES_PARATR_SCRIPTSPACE);
694 aSet.Put(aScriptSpace);
695 }
696 }
697 break;
698
699 case RES_POOLCOLL_TEXT: // Text body
700 {
701 SvxLineSpacingItem aLSpc( LINE_SPACE_DEFAULT_HEIGHT, RES_PARATR_LINESPACING );
702 SvxULSpaceItem aUL( 0, PT_7, RES_UL_SPACE );
703 aLSpc.SetPropLineSpace( 115 );
704 if( m_rDoc.GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE) ) aUL.SetLower( HTML_PARSPACE );
705 aSet.Put( aUL );
706 aSet.Put( aLSpc );
707 }
708 break;
709 case RES_POOLCOLL_TEXT_IDENT: // Text body indentation
710 {
711 auto const first(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip));
712 SvxFirstLineIndentItem const firstLine(SvxIndentValue::twips(first),
713 RES_MARGIN_FIRSTLINE);
714 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::zero(), RES_MARGIN_TEXTLEFT);
715 aSet.Put(firstLine);
716 aSet.Put(leftMargin);
717 }
718 break;
719 case RES_POOLCOLL_TEXT_NEGIDENT: // Text body neg. indentation
720 {
721 auto const first(-o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip));
722 auto const left(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
723 SvxFirstLineIndentItem const firstLine(SvxIndentValue::twips(first),
724 RES_MARGIN_FIRSTLINE);
725 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left),
726 RES_MARGIN_TEXTLEFT);
727 aSet.Put(firstLine);
728 aSet.Put(leftMargin);
729
730 SvxTabStopItem aTStops(RES_PARATR_TABSTOP);
731 aTStops.Insert( SvxTabStop( 0 ));
732 aSet.Put( aTStops );
733 }
734 break;
735 case RES_POOLCOLL_TEXT_MOVE: // Text body move
736 {
737 auto const left(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip));
738 SvxFirstLineIndentItem const firstLine(RES_MARGIN_FIRSTLINE);
739 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left),
740 RES_MARGIN_TEXTLEFT);
741 aSet.Put(firstLine);
742 aSet.Put(leftMargin);
743 }
744 break;
745
746 case RES_POOLCOLL_CONFRONTATION: // Text body confrontation
747 {
748 auto const first(-o3tl::convert(45, o3tl::Length::mm, o3tl::Length::twip));
749 auto const left(o3tl::convert(5, o3tl::Length::cm, o3tl::Length::twip));
750 SvxFirstLineIndentItem const firstLine(SvxIndentValue::twips(first),
751 RES_MARGIN_FIRSTLINE);
752 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left),
753 RES_MARGIN_TEXTLEFT);
754 aSet.Put(firstLine);
755 aSet.Put(leftMargin);
756
757 SvxTabStopItem aTStops( RES_PARATR_TABSTOP );
758 aTStops.Insert( SvxTabStop( 0 ));
759 aSet.Put( aTStops );
760 }
761 break;
762 case RES_POOLCOLL_MARGINAL: // Text body marginal
763 {
764 auto const left(o3tl::convert(4, o3tl::Length::cm, o3tl::Length::twip));
765 SvxFirstLineIndentItem const firstLine(RES_MARGIN_FIRSTLINE);
766 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left),
767 RES_MARGIN_TEXTLEFT);
768 aSet.Put(firstLine);
769 aSet.Put(leftMargin);
770 }
771 break;
772
773 case RES_POOLCOLL_HEADLINE_BASE: // Base headline
774 {
775 static const sal_uInt16 aFontWhich[] =
776 { RES_CHRATR_FONT,
777 RES_CHRATR_CJK_FONT,
778 RES_CHRATR_CTL_FONT
779 };
780 static const sal_uInt16 aLangTypes[] =
781 {
782 RES_CHRATR_LANGUAGE,
783 RES_CHRATR_CJK_LANGUAGE,
784 RES_CHRATR_CTL_LANGUAGE
785 };
786 static const LanguageType aLangs[] =
787 {
788 LANGUAGE_ENGLISH_US,
789 LANGUAGE_ENGLISH_US,
790 LANGUAGE_ARABIC_SAUDI_ARABIA
791 };
792 static const DefaultFontType nFontTypes[] =
793 {
794 DefaultFontType::LATIN_HEADING,
795 DefaultFontType::CJK_HEADING,
796 DefaultFontType::CTL_HEADING
797 };
798
799 for( int i = 0; i < 3; ++i )
800 {
801 LanguageType nLng = static_cast<const SvxLanguageItem&>(m_rDoc.GetDefault( aLangTypes[i] )).GetLanguage();
802 if( LANGUAGE_DONTKNOW == nLng )
803 nLng = aLangs[i];
804
805 vcl::Font aFnt( OutputDevice::GetDefaultFont( nFontTypes[i],
806 nLng, GetDefaultFontFlags::OnlyOne ) );
807
808 aSet.Put( SvxFontItem( aFnt.GetFamilyTypeMaybeAskConfig(), aFnt.GetFamilyName(),
809 OUString(), aFnt.GetPitchMaybeAskConfig(),
810 aFnt.GetCharSet(), aFontWhich[i] ));
811 }
812
813 SvxFontHeightItem aFntSize( PT_14, 100, RES_CHRATR_FONTSIZE );
814 SvxULSpaceItem aUL( PT_12, PT_6, RES_UL_SPACE );
815 if( m_rDoc.GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE) )
816 aUL.SetLower( HTML_PARSPACE );
817 aSet.Put( SvxFormatKeepItem( true, RES_KEEP ));
818
819 pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_TEXT ));
820
821 aSet.Put( aUL );
822 SetAllScriptItem( aSet, aFntSize );
823 }
824 break;
825
826 case RES_POOLCOLL_NUMBER_BULLET_BASE: // Base Numbering
827 break;
828
829 case RES_POOLCOLL_GREETING: // Greeting
830 case RES_POOLCOLL_REGISTER_BASE: // Base indexes
831 case RES_POOLCOLL_SIGNATURE: // Signatures
832 case RES_POOLCOLL_TABLE: // Table content
833 {
834 SwFormatLineNumber aLN;
835 aLN.SetCountLines( false );
836 aSet.Put( aLN );
837 if (nId == RES_POOLCOLL_TABLE)
838 {
839 aSet.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
840 aSet.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
841 }
842 }
843 break;
844
845 case RES_POOLCOLL_HEADLINE1: // Heading 1
846 {
847 SvxULSpaceItem aUL( PT_12, PT_6, RES_UL_SPACE );
848 aSet.Put( aUL );
849 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 0, false );
850 }
851 break;
852 case RES_POOLCOLL_HEADLINE2: // Heading 2
853 {
854 SvxULSpaceItem aUL( PT_10, PT_6, RES_UL_SPACE );
855 aSet.Put( aUL );
856 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 1, false );
857 }
858 break;
859 case RES_POOLCOLL_HEADLINE3: // Heading 3
860 {
861 SvxULSpaceItem aUL( PT_7, PT_6, RES_UL_SPACE );
862 aSet.Put( aUL );
863 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 2, false );
864 }
865 break;
866 case RES_POOLCOLL_HEADLINE4: // Heading 4
867 {
868 SvxULSpaceItem aUL( PT_6, PT_6, RES_UL_SPACE );
869 aSet.Put( aUL );
870 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 3, true );
871 }
872 break;
873 case RES_POOLCOLL_HEADLINE5: // Heading 5
874 {
875 SvxULSpaceItem aUL( PT_6, PT_3, RES_UL_SPACE );
876 aSet.Put( aUL );
877 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 4, false );
878 }
879 break;
880 case RES_POOLCOLL_HEADLINE6: // Heading 6
881 {
882 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
883 aSet.Put( aUL );
884 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 5, true );
885 }
886 break;
887 case RES_POOLCOLL_HEADLINE7: // Heading 7
888 {
889 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
890 aSet.Put( aUL );
891 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 6, false );
892 }
893 break;
894 case RES_POOLCOLL_HEADLINE8: // Heading 8
895 {
896 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
897 aSet.Put( aUL );
898 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 7, true );
899 }
900 break;
901 case RES_POOLCOLL_HEADLINE9: // Heading 9
902 {
903 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
904 aSet.Put( aUL );
905 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 8, false );
906 }
907 break;
908 case RES_POOLCOLL_HEADLINE10: // Heading 10
909 {
910 SvxULSpaceItem aUL( PT_3, PT_3, RES_UL_SPACE );
911 aSet.Put( aUL );
912 lcl_SetHeadline( m_rDoc, pNewColl, aSet, nOutLvlBits, 9, false );
913 }
914 break;
915
916 // Special sections:
917 // Header
918 case RES_POOLCOLL_HEADERFOOTER:
919 case RES_POOLCOLL_HEADER:
920 case RES_POOLCOLL_HEADERL:
921 case RES_POOLCOLL_HEADERR:
922 // Footer
923 case RES_POOLCOLL_FOOTER:
924 case RES_POOLCOLL_FOOTERL:
925 case RES_POOLCOLL_FOOTERR:
926 {
927 SwFormatLineNumber aLN;
928 aLN.SetCountLines( false );
929 aSet.Put( aLN );
930
931 tools::Long nRightMargin = lcl_GetRightMargin( m_rDoc );
932
933 SvxTabStopItem aTStops( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP );
934 aTStops.Insert( SvxTabStop( nRightMargin / 2, SvxTabAdjust::Center ) );
935 aTStops.Insert( SvxTabStop( nRightMargin, SvxTabAdjust::Right ) );
936
937 aSet.Put( aTStops );
938
939 if ( (nId==RES_POOLCOLL_HEADERR) || (nId==RES_POOLCOLL_FOOTERR) ) {
940 SvxAdjustItem aAdjust(SvxAdjust::Right, RES_PARATR_ADJUST );
941 aSet.Put(aAdjust);
942 }
943 }
944 break;
945
946 case RES_POOLCOLL_TABLE_HDLN:
947 {
948 SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
949 aSet.Put( SvxAdjustItem( SvxAdjust::Center, RES_PARATR_ADJUST ) );
950 SwFormatLineNumber aLN;
951 aLN.SetCountLines( false );
952 aSet.Put( aLN );
953 }
954 break;
955
956 case RES_POOLCOLL_FOOTNOTE: // paragraph style Footnote
957 case RES_POOLCOLL_ENDNOTE: // paragraph style Endnote
958 {
959 auto const first(-o3tl::convert(6, o3tl::Length::mm, o3tl::Length::twip));
960 auto const left(o3tl::convert(6, o3tl::Length::mm, o3tl::Length::twip));
961 SvxFirstLineIndentItem const firstLine(SvxIndentValue::twips(first),
962 RES_MARGIN_FIRSTLINE);
963 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left),
964 RES_MARGIN_TEXTLEFT);
965 aSet.Put(firstLine);
966 aSet.Put(leftMargin);
967
968 SetAllScriptItem( aSet, SvxFontHeightItem( PT_10, 100, RES_CHRATR_FONTSIZE ) );
969 SwFormatLineNumber aLN;
970 aLN.SetCountLines( false );
971 aSet.Put( aLN );
972 }
973 break;
974
975 case RES_POOLCOLL_LABEL: // basic caption
976 {
977 SvxULSpaceItem aUL( RES_UL_SPACE );
978 aUL.SetUpper( PT_6 );
979 aUL.SetLower( PT_6 );
980 aSet.Put( aUL );
981 SetAllScriptItem( aSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE ) );
982 SetAllScriptItem( aSet, SvxFontHeightItem( PT_10, 100, RES_CHRATR_FONTSIZE ) );
983 SwFormatLineNumber aLN;
984 aLN.SetCountLines( false );
985 aSet.Put( aLN );
986 }
987 break;
988
989 case RES_POOLCOLL_FRAME: // Frame content
990 case RES_POOLCOLL_LABEL_ABB: // caption image
991 case RES_POOLCOLL_LABEL_TABLE: // caption table
992 case RES_POOLCOLL_LABEL_FRAME: // caption frame
993 case RES_POOLCOLL_LABEL_DRAWING: // caption drawing
994 case RES_POOLCOLL_LABEL_FIGURE:
995 break;
996
997 case RES_POOLCOLL_ENVELOPE_ADDRESS: // envelope address
998 {
999 SvxULSpaceItem aUL( RES_UL_SPACE );
1000 aUL.SetLower( PT_3 );
1001 aSet.Put( aUL );
1002 SwFormatLineNumber aLN;
1003 aLN.SetCountLines( false );
1004 aSet.Put( aLN );
1005 }
1006 break;
1007
1008 case RES_POOLCOLL_SEND_ADDRESS: // Sender address
1009 {
1010 if( m_rDoc.GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE) )
1011 SetAllScriptItem( aSet, SvxPostureItem(ITALIC_NORMAL, RES_CHRATR_POSTURE) );
1012 else
1013 {
1014 SvxULSpaceItem aUL( RES_UL_SPACE ); aUL.SetLower( PT_3 );
1015 aSet.Put( aUL );
1016 }
1017 SwFormatLineNumber aLN;
1018 aLN.SetCountLines( false );
1019 aSet.Put( aLN );
1020 }
1021 break;
1022
1023 case RES_POOLCOLL_COMMENT: // Comment
1024 {
1025 SetAllScriptItem(aSet, SvxFontHeightItem(PT_10, 100, RES_CHRATR_FONTSIZE));
1026
1027 // tdf#159531: Paddings added to ease readability on comments
1028 // Left and Right margin (i.e. Before and After text indent)
1029 auto const aIndent(o3tl::convert(0.1, o3tl::Length::cm, o3tl::Length::twip));
1030 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(aIndent),
1031 RES_MARGIN_TEXTLEFT);
1032 SvxRightMarginItem const rightMargin(SvxIndentValue::twips(aIndent),
1033 RES_MARGIN_RIGHT);
1034 aSet.Put(leftMargin);
1035 aSet.Put(rightMargin);
1036
1037 // First line indent
1038 aSet.Put(SvxFirstLineIndentItem(RES_MARGIN_FIRSTLINE));
1039
1040 // Added as part of tdf#159531
1041 // Top/bottom spacing (i.e. Above/Below paragraph spacing)
1042 auto const aSpacing(o3tl::convert(0.1, o3tl::Length::cm, o3tl::Length::twip));
1043 SvxULSpaceItem topSpacing(aSpacing, 0, RES_UL_SPACE);
1044 aSet.Put(topSpacing);
1045
1046 // Line spacing = SINGLE
1047 aSet.Put(SvxLineSpacingItem(0, RES_PARATR_LINESPACING));
1048
1049 // Font color
1050 aSet.Put(SvxColorItem(COL_AUTO, RES_CHRATR_COLOR));
1051
1052 // Highlight color = NONE
1053 aSet.Put(SvxBrushItem(COL_TRANSPARENT, RES_CHRATR_HIGHLIGHT));
1054 }
1055 break;
1056
1057 // User defined indexes:
1058 case RES_POOLCOLL_TOX_USERH: // Header
1059 lcl_SetRegister( m_rDoc, aSet, 0, true, false );
1060 {
1061 SwFormatLineNumber aLN;
1062 aLN.SetCountLines( false );
1063 aSet.Put( aLN );
1064 }
1065 break;
1066 case RES_POOLCOLL_TOX_USER1: // 1st level
1067 lcl_SetRegister( m_rDoc, aSet, 0, false, true );
1068 break;
1069 case RES_POOLCOLL_TOX_USER2: // 2nd level
1070 lcl_SetRegister( m_rDoc, aSet, 1, false, true );
1071 break;
1072 case RES_POOLCOLL_TOX_USER3: // 3rd level
1073 lcl_SetRegister( m_rDoc, aSet, 2, false, true );
1074 break;
1075 case RES_POOLCOLL_TOX_USER4: // 4th level
1076 lcl_SetRegister( m_rDoc, aSet, 3, false, true );
1077 break;
1078 case RES_POOLCOLL_TOX_USER5: // 5th level
1079 lcl_SetRegister( m_rDoc, aSet, 4, false, true );
1080 break;
1081 case RES_POOLCOLL_TOX_USER6: // 6th level
1082 lcl_SetRegister( m_rDoc, aSet, 5, false, true );
1083 break;
1084 case RES_POOLCOLL_TOX_USER7: // 7th level
1085 lcl_SetRegister( m_rDoc, aSet, 6, false, true );
1086 break;
1087 case RES_POOLCOLL_TOX_USER8: // 8th level
1088 lcl_SetRegister( m_rDoc, aSet, 7, false, true );
1089 break;
1090 case RES_POOLCOLL_TOX_USER9: // 9th level
1091 lcl_SetRegister( m_rDoc, aSet, 8, false, true );
1092 break;
1093 case RES_POOLCOLL_TOX_USER10: // 10th level
1094 lcl_SetRegister( m_rDoc, aSet, 9, false, true );
1095 break;
1096
1097 // Index
1098 case RES_POOLCOLL_TOX_IDXH: // Header
1099 lcl_SetRegister( m_rDoc, aSet, 0, true, false );
1100 {
1101 SwFormatLineNumber aLN;
1102 aLN.SetCountLines( false );
1103 aSet.Put( aLN );
1104 }
1105 break;
1106 case RES_POOLCOLL_TOX_IDX1: // 1st level
1107 lcl_SetRegister( m_rDoc, aSet, 0, false, false );
1108 break;
1109 case RES_POOLCOLL_TOX_IDX2: // 2nd level
1110 lcl_SetRegister( m_rDoc, aSet, 1, false, false );
1111 break;
1112 case RES_POOLCOLL_TOX_IDX3: // 3rd level
1113 lcl_SetRegister( m_rDoc, aSet, 2, false, false );
1114 break;
1115 case RES_POOLCOLL_TOX_IDXBREAK: // Separator
1116 lcl_SetRegister( m_rDoc, aSet, 0, false, false );
1117 break;
1118
1119 // Table of Content
1120 case RES_POOLCOLL_TOX_CNTNTH: // Header
1121 lcl_SetRegister( m_rDoc, aSet, 0, true, false );
1122 {
1123 SwFormatLineNumber aLN;
1124 aLN.SetCountLines( false );
1125 aSet.Put( aLN );
1126 }
1127 break;
1128 case RES_POOLCOLL_TOX_CNTNT1: // 1st level
1129 lcl_SetRegister( m_rDoc, aSet, 0, false, true );
1130 break;
1131 case RES_POOLCOLL_TOX_CNTNT2: // 2nd level
1132 lcl_SetRegister( m_rDoc, aSet, 1, false, true );
1133 break;
1134 case RES_POOLCOLL_TOX_CNTNT3: // 3rd level
1135 lcl_SetRegister( m_rDoc, aSet, 2, false, true );
1136 break;
1137 case RES_POOLCOLL_TOX_CNTNT4: // 4th level
1138 lcl_SetRegister( m_rDoc, aSet, 3, false, true );
1139 break;
1140 case RES_POOLCOLL_TOX_CNTNT5: // 5th level
1141 lcl_SetRegister( m_rDoc, aSet, 4, false, true );
1142 break;
1143 case RES_POOLCOLL_TOX_CNTNT6: // 6th level
1144 lcl_SetRegister( m_rDoc, aSet, 5, false, true );
1145 break;
1146 case RES_POOLCOLL_TOX_CNTNT7: // 7th level
1147 lcl_SetRegister( m_rDoc, aSet, 6, false, true );
1148 break;
1149 case RES_POOLCOLL_TOX_CNTNT8: // 8th level
1150 lcl_SetRegister( m_rDoc, aSet, 7, false, true );
1151 break;
1152 case RES_POOLCOLL_TOX_CNTNT9: // 9th level
1153 lcl_SetRegister( m_rDoc, aSet, 8, false, true );
1154 break;
1155 case RES_POOLCOLL_TOX_CNTNT10: // 10th level
1156 lcl_SetRegister( m_rDoc, aSet, 9, false, true );
1157 break;
1158
1159 case RES_POOLCOLL_TOX_ILLUSH:
1160 case RES_POOLCOLL_TOX_OBJECTH:
1161 case RES_POOLCOLL_TOX_TABLESH:
1162 case RES_POOLCOLL_TOX_AUTHORITIESH:
1163 lcl_SetRegister( m_rDoc, aSet, 0, true, false );
1164 {
1165 SwFormatLineNumber aLN;
1166 aLN.SetCountLines( false );
1167 aSet.Put( aLN );
1168 }
1169 break;
1170 case RES_POOLCOLL_TOX_ILLUS1:
1171 case RES_POOLCOLL_TOX_OBJECT1:
1172 case RES_POOLCOLL_TOX_TABLES1:
1173 case RES_POOLCOLL_TOX_AUTHORITIES1:
1174 lcl_SetRegister( m_rDoc, aSet, 0, false, true );
1175 break;
1176
1177 case RES_POOLCOLL_NUM_LEVEL1S:
1178 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
1179 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
1180 PT_12, PT_6 );
1181 break;
1182 case RES_POOLCOLL_NUM_LEVEL1:
1183 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
1184 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
1185 0, PT_6 );
1186 break;
1187 case RES_POOLCOLL_NUM_LEVEL1E:
1188 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
1189 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
1190 0, PT_12 );
1191 break;
1192 case RES_POOLCOLL_NUM_NONUM1:
1193 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM1,
1194 0, SwNumRule::GetNumIndent( 0 ), 0, PT_6 );
1195 break;
1196 case RES_POOLCOLL_NUM_LEVEL2S:
1197 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
1198 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
1199 PT_12, PT_6 );
1200 break;
1201 case RES_POOLCOLL_NUM_LEVEL2:
1202 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
1203 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
1204 0, PT_6 );
1205 break;
1206 case RES_POOLCOLL_NUM_LEVEL2E:
1207 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
1208 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
1209 0, PT_12 );
1210 break;
1211 case RES_POOLCOLL_NUM_NONUM2:
1212 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM2,
1213 0, SwNumRule::GetNumIndent( 1 ), 0, PT_6 );
1214 break;
1215 case RES_POOLCOLL_NUM_LEVEL3S:
1216 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
1217 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
1218 PT_12, PT_6 );
1219 break;
1220 case RES_POOLCOLL_NUM_LEVEL3:
1221 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
1222 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
1223 0, PT_6 );
1224 break;
1225 case RES_POOLCOLL_NUM_LEVEL3E:
1226 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
1227 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
1228 0, PT_12 );
1229 break;
1230 case RES_POOLCOLL_NUM_NONUM3:
1231 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM3,
1232 0, SwNumRule::GetNumIndent( 2 ), 0, PT_6 );
1233 break;
1234 case RES_POOLCOLL_NUM_LEVEL4S:
1235 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
1236 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
1237 PT_12, PT_6 );
1238 break;
1239 case RES_POOLCOLL_NUM_LEVEL4:
1240 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
1241 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
1242 0, PT_6 );
1243 break;
1244 case RES_POOLCOLL_NUM_LEVEL4E:
1245 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
1246 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
1247 0, PT_12 );
1248 break;
1249 case RES_POOLCOLL_NUM_NONUM4:
1250 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM4,
1251 0, SwNumRule::GetNumIndent( 3 ), 0, PT_6 );
1252 break;
1253 case RES_POOLCOLL_NUM_LEVEL5S:
1254 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
1255 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
1256 PT_12, PT_6 );
1257 break;
1258 case RES_POOLCOLL_NUM_LEVEL5:
1259 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
1260 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
1261 0, PT_6 );
1262 break;
1263 case RES_POOLCOLL_NUM_LEVEL5E:
1264 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
1265 lNumberFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
1266 0, PT_12 );
1267 break;
1268 case RES_POOLCOLL_NUM_NONUM5:
1269 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM5,
1270 0, SwNumRule::GetNumIndent( 4 ), 0, PT_6 );
1271 break;
1272
1273 case RES_POOLCOLL_BULLET_LEVEL1S:
1274 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL1,
1275 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
1276 PT_12, PT_6 );
1277 break;
1278 case RES_POOLCOLL_BULLET_LEVEL1:
1279 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL1,
1280 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
1281 0, PT_6 );
1282 break;
1283 case RES_POOLCOLL_BULLET_LEVEL1E:
1284 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL1,
1285 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
1286 0, PT_12 );
1287 break;
1288 case RES_POOLCOLL_BULLET_NONUM1:
1289 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM1,
1290 0, SwNumRule::GetBullIndent( 0 ), 0, PT_6 );
1291 break;
1292 case RES_POOLCOLL_BULLET_LEVEL2S:
1293 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL2,
1294 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
1295 PT_12, PT_6 );
1296 break;
1297 case RES_POOLCOLL_BULLET_LEVEL2:
1298 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL2,
1299 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
1300 0, PT_6 );
1301 break;
1302 case RES_POOLCOLL_BULLET_LEVEL2E:
1303 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL2,
1304 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
1305 0, PT_12 );
1306 break;
1307 case RES_POOLCOLL_BULLET_NONUM2:
1308 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM2,
1309 0, SwNumRule::GetBullIndent( 1 ), 0, PT_6 );
1310 break;
1311 case RES_POOLCOLL_BULLET_LEVEL3S:
1312 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL3,
1313 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
1314 PT_12, PT_6 );
1315 break;
1316 case RES_POOLCOLL_BULLET_LEVEL3:
1317 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL3,
1318 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
1319 0, PT_6 );
1320 break;
1321 case RES_POOLCOLL_BULLET_LEVEL3E:
1322 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL3,
1323 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
1324 0, PT_12 );
1325 break;
1326 case RES_POOLCOLL_BULLET_NONUM3:
1327 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM3,
1328 0, SwNumRule::GetBullIndent( 2 ), 0, PT_6 );
1329 break;
1330 case RES_POOLCOLL_BULLET_LEVEL4S:
1331 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL4,
1332 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
1333 PT_12, PT_6 );
1334 break;
1335 case RES_POOLCOLL_BULLET_LEVEL4:
1336 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL4,
1337 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
1338 0, PT_6 );
1339 break;
1340 case RES_POOLCOLL_BULLET_LEVEL4E:
1341 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL4,
1342 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
1343 0, PT_12 );
1344 break;
1345 case RES_POOLCOLL_BULLET_NONUM4:
1346 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM4,
1347 0, SwNumRule::GetBullIndent( 3 ), 0, PT_6 );
1348 break;
1349 case RES_POOLCOLL_BULLET_LEVEL5S:
1350 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL5,
1351 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
1352 PT_12, PT_6 );
1353 break;
1354 case RES_POOLCOLL_BULLET_LEVEL5:
1355 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL5,
1356 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
1357 0, PT_6 );
1358 break;
1359 case RES_POOLCOLL_BULLET_LEVEL5E:
1360 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_LEVEL5,
1361 lBulletFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
1362 0, PT_12 );
1363 break;
1364 case RES_POOLCOLL_BULLET_NONUM5:
1365 lcl_SetNumBul( m_rDoc, pNewColl, aSet, RES_POOLCOLL_BULLET_NONUM5,
1366 0, SwNumRule::GetBullIndent( 4 ), 0, PT_6 );
1367 break;
1368
1369 case RES_POOLCOLL_DOC_TITLE: // Document Title
1370 {
1371 SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
1372 SetAllScriptItem( aSet, SvxFontHeightItem( PT_28, 100, RES_CHRATR_FONTSIZE ) );
1373
1374 aSet.Put( SvxAdjustItem( SvxAdjust::Center, RES_PARATR_ADJUST ) );
1375
1376 pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_TEXT ));
1377 }
1378 break;
1379
1380 case RES_POOLCOLL_DOC_SUBTITLE: // Document subtitle
1381 {
1382 SvxULSpaceItem aUL( PT_3, PT_6, RES_UL_SPACE );
1383 aSet.Put( aUL );
1384 SetAllScriptItem( aSet, SvxFontHeightItem( PT_18, 100, RES_CHRATR_FONTSIZE ));
1385
1386 aSet.Put( SvxAdjustItem( SvxAdjust::Center, RES_PARATR_ADJUST ));
1387
1388 pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_TEXT ));
1389 }
1390 break;
1391
1392 case RES_POOLCOLL_DOC_APPENDIX: // Document Appendix tdf#114090
1393 {
1394 SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
1395 SetAllScriptItem( aSet, SvxFontHeightItem( PT_16, 100, RES_CHRATR_FONTSIZE ) );
1396
1397 aSet.Put( SvxAdjustItem( SvxAdjust::Center, RES_PARATR_ADJUST ) );
1398
1399 pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_TEXT ));
1400 }
1401 break;
1402
1403 case RES_POOLCOLL_HTML_BLOCKQUOTE:
1404 {
1405 auto const left(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
1406 auto const right(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
1407 SvxFirstLineIndentItem const firstLine(RES_MARGIN_FIRSTLINE);
1408 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left),
1409 RES_MARGIN_TEXTLEFT);
1410 SvxRightMarginItem const rightMargin(SvxIndentValue::twips(right),
1411 RES_MARGIN_RIGHT);
1412 aSet.Put(firstLine);
1413 aSet.Put(leftMargin);
1414 aSet.Put(rightMargin);
1415
1416 std::unique_ptr<SvxULSpaceItem> aUL(pNewColl->GetULSpace().Clone());
1417 aUL->SetLower( HTML_PARSPACE );
1418 aSet.Put(std::move(aUL));
1419 }
1420 break;
1421
1422 case RES_POOLCOLL_HTML_PRE:
1423 {
1424 ::lcl_SetDfltFont( DefaultFontType::FIXED, aSet );
1425
1426 // WORKAROUND: Set PRE to 10pt
1427 SetAllScriptItem( aSet, SvxFontHeightItem(PT_10, 100, RES_CHRATR_FONTSIZE) );
1428
1429 // The lower paragraph distance is set explicitly (makes
1430 // assigning hard attributes easier)
1431 std::unique_ptr<SvxULSpaceItem> aULSpaceItem(pNewColl->GetULSpace().Clone());
1432 aULSpaceItem->SetLower( 0 );
1433 aSet.Put(std::move(aULSpaceItem));
1434 }
1435 break;
1436
1437 case RES_POOLCOLL_HTML_HR:
1438 {
1439 SvxBoxItem aBox( RES_BOX );
1440 Color aColor( COL_GRAY );
1441 SvxBorderLine aNew(&aColor, 3, SvxBorderLineStyle::DOUBLE);
1442 aBox.SetLine( &aNew, SvxBoxItemLine::BOTTOM );
1443
1444 aSet.Put( aBox );
1445 aSet.Put( SwParaConnectBorderItem( false ) );
1446 SetAllScriptItem( aSet, SvxFontHeightItem(120, 100, RES_CHRATR_FONTSIZE) );
1447
1448 std::unique_ptr<SvxULSpaceItem> aUL;
1449 {
1450 pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_TEXT ));
1451 aUL.reset(pNewColl->GetULSpace().Clone());
1452 }
1453 aUL->SetLower( HTML_PARSPACE );
1454 aSet.Put(std::move(aUL));
1455 SwFormatLineNumber aLN;
1456 aLN.SetCountLines( false );
1457 aSet.Put( aLN );
1458 }
1459 break;
1460
1461 case RES_POOLCOLL_HTML_DD:
1462 {
1463 // We indent by 1 cm. The IDs are always 2 away from each other!
1464 auto const left(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip));
1465 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left),
1466 RES_MARGIN_TEXTLEFT);
1467 aSet.Put(leftMargin);
1468 }
1469 break;
1470 case RES_POOLCOLL_HTML_DT:
1471 {
1472 {
1473 pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_HTML_DD ));
1474 }
1475 // We indent by 0 cm. The IDs are always 2 away from each other!
1476 SvxTextLeftMarginItem const leftMargin(SvxIndentValue::zero(), RES_MARGIN_TEXTLEFT);
1477 aSet.Put(leftMargin);
1478 }
1479 break;
1480 }
1481 }
1482
1483 if( aSet.Count() )
1484 pNewColl->SetFormatAttr( aSet );
1485 return pNewColl;
1486 }
1487
1488 /// Return the AutomaticFormat with the supplied Id. If it doesn't
1489 /// exist, create it.
GetFormatFromPool(sal_uInt16 nId)1490 SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId )
1491 {
1492 SwFormat *pNewFormat = nullptr;
1493 SwFormat *pDeriveFormat = nullptr;
1494
1495 SwFormatsBase* pArray[ 2 ];
1496 sal_uInt16 nArrCnt = 1;
1497 TranslateId pRCId;
1498 WhichRangesContainer const* pWhichRange;
1499
1500 switch( nId & (COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID) )
1501 {
1502 case POOLGRP_CHARFMT:
1503 {
1504 pArray[0] = m_rDoc.GetCharFormats();
1505 pDeriveFormat = m_rDoc.GetDfltCharFormat();
1506 pWhichRange = &aCharFormatSetRange;
1507
1508 if (nId >= RES_POOLCHR_HTML_BEGIN && nId < RES_POOLCHR_HTML_END)
1509 pRCId = STR_POOLCHR_HTML_ARY[nId - RES_POOLCHR_HTML_BEGIN];
1510 else if (nId >= RES_POOLCHR_NORMAL_BEGIN && nId < RES_POOLCHR_NORMAL_END)
1511 pRCId = STR_POOLCHR_ARY[nId - RES_POOLCHR_BEGIN];
1512 else
1513 {
1514 // Fault: unknown Format, but a CharFormat -> return the first one
1515 OSL_ENSURE( false, "invalid Id" );
1516 pRCId = STR_POOLCHR_ARY[0];
1517 }
1518 }
1519 break;
1520 case POOLGRP_FRAMEFMT:
1521 {
1522 pArray[0] = m_rDoc.GetFrameFormats();
1523 pArray[1] = m_rDoc.GetSpzFrameFormats();
1524 pDeriveFormat = m_rDoc.GetDfltFrameFormat();
1525 nArrCnt = 2;
1526 pWhichRange = &aFrameFormatSetRange;
1527
1528 // Fault: unknown Format, but a FrameFormat
1529 // -> return the first one
1530 if( RES_POOLFRM_BEGIN > nId || nId >= RES_POOLFRM_END )
1531 {
1532 OSL_ENSURE( false, "invalid Id" );
1533 nId = RES_POOLFRM_BEGIN;
1534 }
1535
1536 pRCId = STR_POOLFRM_ARY[nId - RES_POOLFRM_BEGIN];
1537 }
1538 break;
1539
1540 default:
1541 // Fault, unknown Format
1542 OSL_ENSURE( nId, "invalid Id" );
1543 return nullptr;
1544 }
1545 OSL_ENSURE(pRCId, "invalid Id");
1546
1547 while (nArrCnt)
1548 {
1549 --nArrCnt;
1550 for( size_t n = 0; n < (*pArray[nArrCnt]).GetFormatCount(); ++n )
1551 {
1552 pNewFormat = (*pArray[ nArrCnt ] ).GetFormat( n );
1553 if( nId == pNewFormat->GetPoolFormatId() )
1554 {
1555 return pNewFormat;
1556 }
1557 }
1558 }
1559
1560 UIName aNm(SwResId(pRCId));
1561 SwAttrSet aSet(m_rDoc.GetAttrPool(), *pWhichRange);
1562
1563 {
1564 bool bIsModified = m_rDoc.getIDocumentState().IsModified();
1565
1566 {
1567 ::sw::UndoGuard const undoGuard(m_rDoc.GetIDocumentUndoRedo());
1568 switch (nId & (COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID) )
1569 {
1570 case POOLGRP_CHARFMT:
1571 pNewFormat = m_rDoc.MakeCharFormat_(aNm, pDeriveFormat, true);
1572 break;
1573 case POOLGRP_FRAMEFMT:
1574 pNewFormat = m_rDoc.MakeFrameFormat_(aNm, pDeriveFormat, true);
1575 break;
1576 default:
1577 break;
1578 }
1579 }
1580
1581 if( !bIsModified )
1582 m_rDoc.getIDocumentState().ResetModified();
1583 pNewFormat->SetPoolFormatId( nId );
1584 pNewFormat->SetAuto(false); // no AutoFormat
1585 }
1586
1587 switch( nId )
1588 {
1589 case RES_POOLCHR_FOOTNOTE: // Footnote
1590 case RES_POOLCHR_PAGENO: // Page/Field
1591 case RES_POOLCHR_LABEL: // Label
1592 case RES_POOLCHR_DROPCAPS: // Dropcaps
1593 case RES_POOLCHR_NUM_LEVEL: // Numbering level
1594 case RES_POOLCHR_TOXJUMP: // Table of contents jump
1595 case RES_POOLCHR_ENDNOTE: // Endnote
1596 case RES_POOLCHR_LINENUM: // Line numbering
1597 break;
1598
1599 case RES_POOLCHR_ENDNOTE_ANCHOR: // Endnote anchor
1600 case RES_POOLCHR_FOOTNOTE_ANCHOR: // Footnote anchor
1601 {
1602 aSet.Put( SvxEscapementItem( DFLT_ESC_AUTO_SUPER, DFLT_ESC_PROP, RES_CHRATR_ESCAPEMENT ) );
1603 }
1604 break;
1605
1606 case RES_POOLCHR_BULLET_LEVEL: // Bullet character
1607 {
1608 const vcl::Font& rBulletFont = numfunc::GetDefBulletFont();
1609 SetAllScriptItem( aSet, SvxFontItem( rBulletFont.GetFamilyType(),
1610 rBulletFont.GetFamilyName(), rBulletFont.GetStyleName(),
1611 rBulletFont.GetPitch(), rBulletFont.GetCharSet(), RES_CHRATR_FONT ));
1612 }
1613 break;
1614
1615 case RES_POOLCHR_INET_NORMAL:
1616 {
1617 aSet.Put( SvxColorItem( COL_BLUE, RES_CHRATR_COLOR ) );
1618 aSet.Put( SvxUnderlineItem( LINESTYLE_SINGLE, RES_CHRATR_UNDERLINE ) );
1619 }
1620 break;
1621 case RES_POOLCHR_INET_VISIT:
1622 {
1623 aSet.Put( SvxColorItem( COL_RED, RES_CHRATR_COLOR ) );
1624 aSet.Put( SvxUnderlineItem( LINESTYLE_SINGLE, RES_CHRATR_UNDERLINE ) );
1625 }
1626 break;
1627 case RES_POOLCHR_JUMPEDIT:
1628 {
1629 aSet.Put( SvxColorItem( COL_CYAN, RES_CHRATR_COLOR ) );
1630 aSet.Put( SvxUnderlineItem( LINESTYLE_DOTTED, RES_CHRATR_UNDERLINE ) );
1631 aSet.Put( SvxCaseMapItem( SvxCaseMap::SmallCaps, RES_CHRATR_CASEMAP ) );
1632 }
1633 break;
1634
1635 case RES_POOLCHR_RUBYTEXT:
1636 {
1637 tools::Long nH = GetDfltAttr( RES_CHRATR_CJK_FONTSIZE )->GetHeight() / 2;
1638 SetAllScriptItem( aSet, SvxFontHeightItem( nH, 100, RES_CHRATR_FONTSIZE));
1639 aSet.Put(SvxUnderlineItem( LINESTYLE_NONE, RES_CHRATR_UNDERLINE ));
1640 aSet.Put(SvxEmphasisMarkItem( FontEmphasisMark::NONE, RES_CHRATR_EMPHASIS_MARK) );
1641 }
1642 break;
1643
1644 case RES_POOLCHR_HTML_EMPHASIS:
1645 case RES_POOLCHR_HTML_CITATION:
1646 case RES_POOLCHR_HTML_VARIABLE:
1647 {
1648 SetAllScriptItem( aSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE) );
1649 }
1650 break;
1651
1652 case RES_POOLCHR_IDX_MAIN_ENTRY:
1653 case RES_POOLCHR_HTML_STRONG:
1654 {
1655 SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ));
1656 }
1657 break;
1658
1659 case RES_POOLCHR_HTML_CODE:
1660 case RES_POOLCHR_HTML_SAMPLE:
1661 case RES_POOLCHR_HTML_KEYBOARD:
1662 case RES_POOLCHR_HTML_TELETYPE:
1663 {
1664 ::lcl_SetDfltFont( DefaultFontType::FIXED, aSet );
1665 }
1666 break;
1667 case RES_POOLCHR_VERT_NUM:
1668 aSet.Put( SvxCharRotateItem( 900_deg10, false, RES_CHRATR_ROTATE ) );
1669 break;
1670
1671 case RES_POOLFRM_FRAME:
1672 {
1673 if ( m_rDoc.GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE) )
1674 {
1675 aSet.Put( SwFormatAnchor( RndStdIds::FLY_AS_CHAR ));
1676 aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::LINE_CENTER, text::RelOrientation::PRINT_AREA ) );
1677 aSet.Put( SwFormatSurround( css::text::WrapTextMode_NONE ) );
1678 }
1679 else
1680 {
1681 aSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PARA ));
1682 aSet.Put( SwFormatSurround( css::text::WrapTextMode_PARALLEL ) );
1683 aSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::PRINT_AREA ) );
1684 aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
1685 Color aCol( COL_BLACK );
1686 SvxBorderLine aLine( &aCol, SvxBorderLineWidth::Hairline );
1687 SvxBoxItem aBox( RES_BOX );
1688 aBox.SetLine( &aLine, SvxBoxItemLine::TOP );
1689 aBox.SetLine( &aLine, SvxBoxItemLine::BOTTOM );
1690 aBox.SetLine( &aLine, SvxBoxItemLine::LEFT );
1691 aBox.SetLine( &aLine, SvxBoxItemLine::RIGHT );
1692 aBox.SetAllDistances( 85 );
1693 aSet.Put( aBox );
1694 aSet.Put(SvxLRSpaceItem(SvxIndentValue::twips(114), SvxIndentValue::twips(114),
1695 SvxIndentValue::zero(), RES_LR_SPACE));
1696 aSet.Put( SvxULSpaceItem( 114, 114, RES_UL_SPACE ) );
1697 }
1698
1699 // for styles of FlyFrames do not set the FillStyle to make it a derived attribute
1700 aSet.ClearItem(XATTR_FILLSTYLE);
1701 }
1702 break;
1703 case RES_POOLFRM_GRAPHIC:
1704 case RES_POOLFRM_OLE:
1705 {
1706 aSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PARA ));
1707 aSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ));
1708 aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
1709 aSet.Put( SwFormatSurround( css::text::WrapTextMode_DYNAMIC ));
1710 }
1711 break;
1712 case RES_POOLFRM_FORMEL:
1713 case RES_POOLFRM_INLINE_HEADING:
1714 {
1715 aSet.Put( SwFormatAnchor( RndStdIds::FLY_AS_CHAR ) );
1716 aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) );
1717 aSet.Put(SvxLRSpaceItem(SvxIndentValue::zero(), SvxIndentValue::zero(),
1718 SvxIndentValue::zero(), RES_LR_SPACE));
1719
1720 if ( RES_POOLFRM_INLINE_HEADING == nId )
1721 {
1722 // Set the default width to 0.5 cm, use the minimum value for the height
1723 SwFormatFrameSize aSize(SwFrameSize::Variable,
1724 o3tl::toTwips(5, o3tl::Length::mm),
1725 o3tl::toTwips(1, o3tl::Length::mm));
1726 // variable width of the inline heading frame follows its text content
1727 aSize.SetWidthSizeType(SwFrameSize::Variable);
1728 aSet.Put(aSize);
1729 }
1730 else
1731 aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) );
1732 }
1733 break;
1734 case RES_POOLFRM_MARGINAL:
1735 {
1736 aSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PARA ));
1737 aSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME ));
1738 aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
1739 aSet.Put( SwFormatSurround( css::text::WrapTextMode_PARALLEL ));
1740 // Set the default width to 3.5 cm, use the minimum value for the height
1741 aSet.Put(SwFormatFrameSize(SwFrameSize::Minimum,
1742 o3tl::toTwips(35, o3tl::Length::mm),
1743 o3tl::toTwips(5, o3tl::Length::mm)));
1744 }
1745 break;
1746 case RES_POOLFRM_WATERSIGN:
1747 {
1748 aSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE ));
1749 aSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ));
1750 aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ));
1751 aSet.Put( SvxOpaqueItem( RES_OPAQUE, false ));
1752 aSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ));
1753 }
1754 break;
1755 case RES_POOLFRM_LABEL:
1756 {
1757 aSet.Put( SwFormatAnchor( RndStdIds::FLY_AS_CHAR ) );
1758 aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ) );
1759 aSet.Put(SvxLRSpaceItem(SvxIndentValue::twips(114), SvxIndentValue::twips(114),
1760 SvxIndentValue::zero(), RES_LR_SPACE));
1761
1762 SvxProtectItem aProtect( RES_PROTECT );
1763 aProtect.SetSizeProtect( true );
1764 aProtect.SetPosProtect( true );
1765 aSet.Put( aProtect );
1766
1767 pNewFormat->SetAutoUpdateOnDirectFormat();
1768 }
1769 break;
1770 }
1771 if( aSet.Count() )
1772 {
1773 pNewFormat->SetFormatAttr( aSet );
1774 }
1775 return pNewFormat;
1776 }
1777
GetFrameFormatFromPool(sal_uInt16 nId)1778 SwFrameFormat* DocumentStylePoolManager::GetFrameFormatFromPool( sal_uInt16 nId )
1779 {
1780 return static_cast<SwFrameFormat*>(GetFormatFromPool( nId ));
1781 }
1782
GetCharFormatFromPool(sal_uInt16 nId)1783 SwCharFormat* DocumentStylePoolManager::GetCharFormatFromPool( sal_uInt16 nId )
1784 {
1785 return static_cast<SwCharFormat*>(GetFormatFromPool( nId ));
1786 }
1787
GetPageDescFromPool(sal_uInt16 nId,bool bRegardLanguage)1788 SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
1789 {
1790 OSL_ENSURE( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END,
1791 "Wrong AutoFormat Id" );
1792
1793 for( size_t n = 0; n < m_rDoc.GetPageDescCnt(); ++n )
1794 {
1795 if ( nId == m_rDoc.GetPageDesc(n).GetPoolFormatId() )
1796 {
1797 return &m_rDoc.GetPageDesc(n);
1798 }
1799 }
1800
1801 if( RES_POOLPAGE_BEGIN > nId || nId >= RES_POOLPAGE_END )
1802 {
1803 // unknown page pool ID
1804 OSL_ENSURE( false, "<SwDoc::GetPageDescFromPool(..)> - unknown page pool ID" );
1805 nId = RES_POOLPAGE_BEGIN;
1806 }
1807
1808 SwPageDesc* pNewPgDsc = nullptr;
1809 {
1810 static_assert(std::ssize(STR_POOLPAGE_ARY) == RES_POOLPAGE_END - RES_POOLPAGE_BEGIN, "### unexpected size!");
1811 const UIName aNm(SwResId(STR_POOLPAGE_ARY[nId - RES_POOLPAGE_BEGIN]));
1812 const bool bIsModified = m_rDoc.getIDocumentState().IsModified();
1813
1814 {
1815 ::sw::UndoGuard const undoGuard(m_rDoc.GetIDocumentUndoRedo());
1816 pNewPgDsc = m_rDoc.MakePageDesc(aNm, nullptr, bRegardLanguage);
1817 }
1818
1819 pNewPgDsc->SetPoolFormatId( nId );
1820 if ( !bIsModified )
1821 {
1822 m_rDoc.getIDocumentState().ResetModified();
1823 }
1824 }
1825
1826 SvxLRSpaceItem aLR( RES_LR_SPACE );
1827 {
1828 aLR.SetLeft(SvxIndentValue::twips(o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip)));
1829 aLR.SetRight(aLR.GetLeft());
1830 }
1831 SvxULSpaceItem aUL( RES_UL_SPACE );
1832 {
1833 aUL.SetUpper(o3tl::narrowing<sal_uInt16>(aLR.ResolveLeft({})));
1834 aUL.SetLower(o3tl::narrowing<sal_uInt16>(aLR.ResolveLeft({})));
1835 }
1836
1837 SwAttrSet aSet( m_rDoc.GetAttrPool(), aPgFrameFormatSetRange );
1838 bool bSetLeft = true;
1839
1840 switch( nId )
1841 {
1842 case RES_POOLPAGE_STANDARD: // "Default"
1843 {
1844 aSet.Put( aLR );
1845 aSet.Put( aUL );
1846 pNewPgDsc->SetUseOn( UseOnPage::All | UseOnPage::FirstShare );
1847 }
1848 break;
1849
1850 case RES_POOLPAGE_FIRST: // "First Page"
1851 case RES_POOLPAGE_REGISTER: // "Index"
1852 {
1853 lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
1854 aSet.Put( aLR );
1855 aSet.Put( aUL );
1856 pNewPgDsc->SetUseOn( UseOnPage::All );
1857 if( RES_POOLPAGE_FIRST == nId )
1858 pNewPgDsc->SetFollow( GetPageDescFromPool( RES_POOLPAGE_STANDARD ));
1859 }
1860 break;
1861
1862 case RES_POOLPAGE_LEFT: // "Left Page"
1863 {
1864 lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
1865 aSet.Put( aLR );
1866 aSet.Put( aUL );
1867 bSetLeft = false;
1868 pNewPgDsc->SetUseOn( UseOnPage::Left );
1869 // this relies on GetPageDescFromPool() not going into infinite recursion
1870 // (by this point RES_POOLPAGE_LEFT will not reach this place again)
1871 pNewPgDsc->SetFollow( GetPageDescFromPool( RES_POOLPAGE_RIGHT ));
1872 }
1873 break;
1874 case RES_POOLPAGE_RIGHT: // "Right Page"
1875 {
1876 lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
1877 aSet.Put( aLR );
1878 aSet.Put( aUL );
1879 bSetLeft = false;
1880 pNewPgDsc->SetUseOn( UseOnPage::Right );
1881 pNewPgDsc->SetFollow( GetPageDescFromPool( RES_POOLPAGE_LEFT ));
1882 }
1883 break;
1884
1885 case RES_POOLPAGE_ENVELOPE: // "Envelope"
1886 {
1887 Size aPSize( SvxPaperInfo::GetPaperSize( PAPER_ENV_C65 ) );
1888 LandscapeSwap( aPSize );
1889 aSet.Put( SwFormatFrameSize( SwFrameSize::Fixed, aPSize.Width(), aPSize.Height() ));
1890 aLR.SetLeft(SvxIndentValue::zero());
1891 aLR.SetRight(SvxIndentValue::zero());
1892 aUL.SetUpper( 0 ); aUL.SetLower( 0 );
1893 aSet.Put( aLR );
1894 aSet.Put( aUL );
1895
1896 pNewPgDsc->SetUseOn( UseOnPage::All );
1897 pNewPgDsc->SetLandscape( true );
1898 }
1899 break;
1900
1901 case RES_POOLPAGE_HTML: // "HTML"
1902 {
1903 lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
1904 aLR.SetRight(
1905 SvxIndentValue::twips(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)));
1906 aUL.SetUpper(o3tl::narrowing<sal_uInt16>(aLR.ResolveRight({})));
1907 aUL.SetLower(o3tl::narrowing<sal_uInt16>(aLR.ResolveRight({})));
1908 aSet.Put( aLR );
1909 aSet.Put( aUL );
1910
1911 pNewPgDsc->SetUseOn( UseOnPage::All );
1912 }
1913 break;
1914
1915 case RES_POOLPAGE_FOOTNOTE: // "Footnote"
1916 case RES_POOLPAGE_ENDNOTE: // "Endnote"
1917 {
1918 lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet );
1919 aSet.Put( aLR );
1920 aSet.Put( aUL );
1921 pNewPgDsc->SetUseOn( UseOnPage::All );
1922 SwPageFootnoteInfo aInf( pNewPgDsc->GetFootnoteInfo() );
1923 aInf.SetLineWidth( 0 );
1924 aInf.SetTopDist( 0 );
1925 aInf.SetBottomDist( 0 );
1926 pNewPgDsc->SetFootnoteInfo( aInf );
1927 }
1928 break;
1929
1930 case RES_POOLPAGE_LANDSCAPE: // "Landscape"
1931 {
1932 SwPageDesc* pStdPgDsc = GetPageDescFromPool( RES_POOLPAGE_STANDARD );
1933 SwFormatFrameSize aFrameSz( pStdPgDsc->GetMaster().GetFrameSize() );
1934 if ( !pStdPgDsc->GetLandscape() )
1935 {
1936 const SwTwips nTmp = aFrameSz.GetHeight();
1937 aFrameSz.SetHeight( aFrameSz.GetWidth() );
1938 aFrameSz.SetWidth( nTmp );
1939 }
1940 aSet.Put( aFrameSz );
1941 aSet.Put( aLR );
1942 aSet.Put( aUL );
1943 pNewPgDsc->SetUseOn( UseOnPage::All );
1944 pNewPgDsc->SetLandscape( true );
1945 }
1946 break;
1947
1948 }
1949
1950 if( aSet.Count() )
1951 {
1952 if( bSetLeft )
1953 {
1954 pNewPgDsc->GetLeft().SetFormatAttr( aSet );
1955 pNewPgDsc->GetFirstLeft().SetFormatAttr( aSet );
1956 }
1957 pNewPgDsc->GetMaster().SetFormatAttr( aSet );
1958 pNewPgDsc->GetFirstMaster().SetFormatAttr( aSet );
1959 }
1960 return pNewPgDsc;
1961 }
1962
GetNumRuleFromPool(sal_uInt16 nId)1963 SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
1964 {
1965 OSL_ENSURE( RES_POOLNUMRULE_BEGIN <= nId && nId < RES_POOLNUMRULE_END,
1966 "Wrong AutoFormat Id" );
1967
1968 SwNumRule* pNewRule;
1969
1970 for (size_t n = 0; n < m_rDoc.GetNumRuleTable().size(); ++n )
1971 {
1972 pNewRule = m_rDoc.GetNumRuleTable()[ n ];
1973 if (nId == pNewRule->GetPoolFormatId())
1974 {
1975 return pNewRule;
1976 }
1977 }
1978
1979 // error: unknown Pool style
1980 if( RES_POOLNUMRULE_BEGIN > nId || nId >= RES_POOLNUMRULE_END )
1981 {
1982 OSL_ENSURE( false, "invalid Id" );
1983 nId = RES_POOLNUMRULE_BEGIN;
1984 }
1985
1986 static_assert(std::ssize(STR_POOLNUMRULE_NUM_ARY) == RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN, "### unexpected size!");
1987 UIName aNm(SwResId(STR_POOLNUMRULE_NUM_ARY[nId - RES_POOLNUMRULE_BEGIN]));
1988
1989 SwCharFormat *pNumCFormat = nullptr, *pBullCFormat = nullptr;
1990
1991 const SvxNumberFormat::SvxNumPositionAndSpaceMode eNumberFormatPositionAndSpaceMode
1992 = numfunc::GetDefaultPositionAndSpaceMode(); //#i89178#
1993 {
1994 bool bIsModified = m_rDoc.getIDocumentState().IsModified();
1995
1996 sal_uInt16 n = m_rDoc.MakeNumRule( aNm, nullptr, eNumberFormatPositionAndSpaceMode );
1997
1998 pNewRule = m_rDoc.GetNumRuleTable()[ n ];
1999 pNewRule->SetPoolFormatId( nId );
2000 pNewRule->SetAutoRule( false );
2001
2002 if( RES_POOLNUMRULE_NUM1 <= nId && nId <= RES_POOLNUMRULE_NUM5 )
2003 pNumCFormat = GetCharFormatFromPool( RES_POOLCHR_NUM_LEVEL );
2004
2005 if( ( RES_POOLNUMRULE_BUL1 <= nId && nId <= RES_POOLNUMRULE_BUL5 ) ||
2006 RES_POOLNUMRULE_NUM5 == nId )
2007 pBullCFormat = GetCharFormatFromPool( RES_POOLCHR_NUM_LEVEL );
2008
2009 if( !bIsModified )
2010 m_rDoc.getIDocumentState().ResetModified();
2011 }
2012
2013 switch( nId )
2014 {
2015 case RES_POOLNUMRULE_NUM1:
2016 {
2017 SwNumFormat aFormat;
2018 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2019 aFormat.SetNumberingType(SVX_NUM_ARABIC);
2020 aFormat.SetCharFormat( pNumCFormat );
2021 aFormat.SetStart( 1 );
2022 aFormat.SetIncludeUpperLevels( 1 );
2023
2024 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2025 {
2026 // cm: 0.7 cm intervals, with 1 cm = 567
2027 397, 794, 1191, 1588, 1985, 2381, 2778, 3175, 3572, 3969
2028 };
2029 const sal_uInt16* pArr = aAbsSpace;
2030
2031 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2032 {
2033 aFormat.SetFirstLineOffset( - (*pArr) );
2034 }
2035 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2036 {
2037 aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2038 aFormat.SetFirstLineIndent( - (*pArr) );
2039 }
2040
2041 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n, ++pArr)
2042 {
2043 aFormat.SetListFormat(u""_ustr, u"."_ustr, n);
2044 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2045 {
2046 aFormat.SetAbsLSpace( *pArr + 357 ); // 357 is indent of 0.63 cm
2047 }
2048 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2049 {
2050 aFormat.SetListtabPos( *pArr );
2051 aFormat.SetIndentAt( *pArr + 357 );
2052 }
2053
2054 pNewRule->Set( n, aFormat );
2055 }
2056 }
2057 break;
2058
2059 case RES_POOLNUMRULE_NUM2:
2060 {
2061 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2062 {
2063 397, 397, 397, 397, // 0.70 cm intervals
2064 397, 397, 397, 397,
2065 397, 397
2066 };
2067
2068 const sal_uInt16* pArr = aAbsSpace;
2069 SwNumFormat aFormat;
2070
2071 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2072 aFormat.SetNumberingType(SVX_NUM_CHARS_UPPER_LETTER);
2073 aFormat.SetCharFormat( pNumCFormat );
2074 aFormat.SetStart( 1 );
2075 aFormat.SetIncludeUpperLevels( 1 );
2076
2077 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2078 {
2079 aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2080 }
2081
2082 sal_uInt16 nSpace = 357; // indent of 0.63 cm
2083 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n)
2084 {
2085 aFormat.SetListFormat(u""_ustr, u"."_ustr, n);
2086 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2087 {
2088 nSpace += pArr[ n ];
2089 aFormat.SetAbsLSpace( nSpace );
2090 aFormat.SetFirstLineOffset( - pArr[ n ] );
2091 }
2092 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2093 {
2094 nSpace += pArr[ n ];
2095 aFormat.SetListtabPos( nSpace );
2096 aFormat.SetIndentAt( nSpace );
2097 aFormat.SetFirstLineIndent( - pArr[ n ] );
2098 }
2099
2100 pNewRule->Set( n, aFormat );
2101 }
2102 }
2103 break;
2104 case RES_POOLNUMRULE_NUM3:
2105 {
2106 SwNumFormat aFormat;
2107
2108 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2109 aFormat.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER);
2110 aFormat.SetCharFormat( pNumCFormat );
2111 aFormat.SetStart( 1 );
2112 aFormat.SetIncludeUpperLevels( 1 );
2113
2114 tools::Long const nOffs = 397; // 0.70 cm
2115
2116 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2117 {
2118 aFormat.SetFirstLineOffset( - nOffs );
2119 }
2120 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2121 {
2122 aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2123 aFormat.SetFirstLineIndent( - nOffs );
2124 }
2125
2126 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n)
2127 {
2128 aFormat.SetListFormat(u""_ustr, u"."_ustr, n);
2129 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2130 {
2131 aFormat.SetAbsLSpace( (n+1) * nOffs + 357 ); // 357 is indent of 0.63 cm
2132 }
2133 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2134 {
2135 tools::Long nPos = (n+1) * nOffs;
2136 aFormat.SetListtabPos(nPos + 357);
2137 aFormat.SetIndentAt(nPos + 357);
2138 }
2139
2140 pNewRule->Set( n, aFormat );
2141 }
2142 }
2143 break;
2144 case RES_POOLNUMRULE_NUM4:
2145 {
2146 SwNumFormat aFormat;
2147
2148 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2149 aFormat.SetNumberingType(SVX_NUM_ROMAN_UPPER);
2150 aFormat.SetCharFormat( pNumCFormat );
2151 aFormat.SetStart( 1 );
2152 aFormat.SetIncludeUpperLevels( 1 );
2153 aFormat.SetNumAdjust( SvxAdjust::Right );
2154
2155 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2156 {
2157 // cm: 1.33 cm intervals
2158 754, 1508, 2262, 3016, 3771, 4525, 5279, 6033, 6787, 7541
2159 };
2160 const sal_uInt16* pArr = aAbsSpace;
2161
2162 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2163 {
2164 aFormat.SetFirstLineOffset( 580 - (*pArr) ); // 1 cm space
2165 }
2166 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2167 {
2168 aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2169 aFormat.SetFirstLineIndent( 580 - (*pArr) );
2170 }
2171
2172 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n, ++pArr)
2173 {
2174 aFormat.SetListFormat(u""_ustr, u"."_ustr, n);
2175 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2176 {
2177 aFormat.SetAbsLSpace( *pArr );
2178 }
2179 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2180 {
2181 aFormat.SetListtabPos( *pArr );
2182 aFormat.SetIndentAt( *pArr );
2183 }
2184
2185 pNewRule->Set( n, aFormat );
2186 }
2187 }
2188 break;
2189 case RES_POOLNUMRULE_NUM5:
2190 {
2191 // [ First, LSpace ]
2192 static const sal_uInt16 aAbsSpace0to2[] =
2193 {
2194 174, 754, // 0.33, 1.33cm
2195 174, 1508, // 0.33, 2.66cm
2196 397, 2262 // 0.70, 4.00cm
2197 };
2198
2199 const sal_uInt16* pArr0to2 = aAbsSpace0to2;
2200 SwNumFormat aFormat;
2201
2202 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2203 aFormat.SetNumberingType(SVX_NUM_ROMAN_LOWER);
2204 aFormat.SetStart( 1 );
2205 aFormat.SetIncludeUpperLevels( 1 );
2206 aFormat.SetNumAdjust( SvxAdjust::Right );
2207 aFormat.SetListFormat(u""_ustr, u"."_ustr, 0);
2208
2209 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2210 {
2211 aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2212 }
2213
2214 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2215 {
2216 aFormat.SetFirstLineOffset(- pArr0to2[0]); // num ends at 1.00 cm
2217 aFormat.SetAbsLSpace(pArr0to2[1]); // text starts at 1.33 cm
2218 }
2219 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2220 {
2221 aFormat.SetFirstLineIndent( -pArr0to2[0] );
2222 aFormat.SetListtabPos( pArr0to2[1] );
2223 aFormat.SetIndentAt( pArr0to2[1] );
2224 }
2225
2226 aFormat.SetCharFormat( pNumCFormat );
2227 pNewRule->Set( 0, aFormat );
2228
2229 aFormat.SetNumberingType(SVX_NUM_ROMAN_UPPER);
2230 aFormat.SetIncludeUpperLevels( 1 );
2231 aFormat.SetListFormat(u""_ustr, u"."_ustr, 1);
2232
2233 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2234 {
2235 aFormat.SetFirstLineOffset(- pArr0to2[2]); // num ends at 2.33 cm
2236 aFormat.SetAbsLSpace(pArr0to2[3]); // text starts at 2.66 cm
2237 }
2238 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2239 {
2240 aFormat.SetFirstLineIndent( -pArr0to2[2] );
2241 aFormat.SetListtabPos( pArr0to2[3] );
2242 aFormat.SetIndentAt( pArr0to2[3] );
2243 }
2244
2245 pNewRule->Set( 1, aFormat );
2246
2247 aFormat.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER);
2248 aFormat.SetIncludeUpperLevels( 1 );
2249 aFormat.SetListFormat(u""_ustr, u")"_ustr, 2);
2250 aFormat.SetNumAdjust( SvxAdjust::Left );
2251
2252 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2253 {
2254 aFormat.SetFirstLineOffset(- pArr0to2[4]); // num starts at 3.30 cm
2255 aFormat.SetAbsLSpace(pArr0to2[5]); // text starts at 4.00 cm
2256 }
2257 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2258 {
2259 aFormat.SetFirstLineIndent( -pArr0to2[4] );
2260 aFormat.SetListtabPos( pArr0to2[5] );
2261 aFormat.SetIndentAt( pArr0to2[5] );
2262 }
2263
2264 pNewRule->Set( 2, aFormat );
2265
2266 aFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2267 aFormat.SetCharFormat( pBullCFormat );
2268 aFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
2269 aFormat.SetBulletChar( cBulletChar );
2270 sal_Int16 nOffs = o3tl::convert(660, o3tl::Length::mm100, o3tl::Length::twip),
2271 nOffs2 = o3tl::convert(4000, o3tl::Length::mm100, o3tl::Length::twip);
2272
2273 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2274 {
2275 aFormat.SetFirstLineOffset( - nOffs );
2276 }
2277 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2278 {
2279 aFormat.SetFirstLineIndent( - nOffs );
2280 }
2281
2282 for (sal_uInt16 n = 3; n < MAXLEVEL; ++n)
2283 {
2284 aFormat.SetStart( n+1 );
2285 aFormat.SetListFormat(u""_ustr, u""_ustr, n);
2286
2287 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2288 {
2289 aFormat.SetAbsLSpace(nOffs2 + ((n - 2) * static_cast<tools::Long>(nOffs)));
2290 }
2291 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2292 {
2293 tools::Long nPos = nOffs2 + ((n - 2) * static_cast<tools::Long>(nOffs));
2294 aFormat.SetListtabPos(nPos);
2295 aFormat.SetIndentAt(nPos);
2296 }
2297
2298 pNewRule->Set( n, aFormat );
2299 }
2300 }
2301 break;
2302
2303 case RES_POOLNUMRULE_BUL1:
2304 {
2305 SwNumFormat aFormat;
2306
2307 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2308 aFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2309 aFormat.SetCharFormat( pBullCFormat );
2310 aFormat.SetStart( 1 );
2311 aFormat.SetIncludeUpperLevels( 1 );
2312 aFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
2313 aFormat.SetBulletChar( cBulletChar );
2314
2315 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2316 {
2317 // cm: 0,4 0,8 1,2 1,6 2,0 2,4 2,8 3,2 3,6 4,0
2318 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
2319 };
2320 const sal_uInt16* pArr = aAbsSpace;
2321
2322 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2323 {
2324 aFormat.SetFirstLineOffset( - (*pArr) );
2325 }
2326 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2327 {
2328 aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2329 aFormat.SetFirstLineIndent( - (*pArr) );
2330 }
2331
2332 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n, ++pArr)
2333 {
2334 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2335 {
2336 aFormat.SetAbsLSpace( *pArr );
2337 }
2338 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2339 {
2340 aFormat.SetListtabPos( *pArr );
2341 aFormat.SetIndentAt( *pArr );
2342 }
2343
2344 pNewRule->Set( n, aFormat );
2345 }
2346 }
2347 break;
2348 case RES_POOLNUMRULE_BUL2:
2349 {
2350 SwNumFormat aFormat;
2351
2352 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2353 aFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2354 aFormat.SetCharFormat( pBullCFormat );
2355 aFormat.SetStart( 1 );
2356 aFormat.SetIncludeUpperLevels( 1 );
2357 aFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
2358 aFormat.SetBulletChar( 0x2013 );
2359
2360 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2361 {
2362 // cm: 0,3 0,6 0,9 1,2 1,5 1,8 2,1 2,4 2,7 3,0
2363 170, 340, 510, 680, 850, 1020, 1191, 1361, 1531, 1701
2364 };
2365 const sal_uInt16* pArr = aAbsSpace;
2366
2367 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2368 {
2369 aFormat.SetFirstLineOffset( - (*pArr) );
2370 }
2371 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2372 {
2373 aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2374 aFormat.SetFirstLineIndent( - (*pArr) );
2375 }
2376
2377 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n, ++pArr)
2378 {
2379 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2380 {
2381 aFormat.SetAbsLSpace( *pArr );
2382 }
2383 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2384 {
2385 aFormat.SetListtabPos( *pArr );
2386 aFormat.SetIndentAt( *pArr );
2387 }
2388
2389 pNewRule->Set( n, aFormat );
2390 }
2391 }
2392 break;
2393 case RES_POOLNUMRULE_BUL3:
2394 {
2395 SwNumFormat aFormat;
2396
2397 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2398
2399 aFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2400 aFormat.SetCharFormat( pBullCFormat );
2401 aFormat.SetStart( 1 );
2402 aFormat.SetIncludeUpperLevels( 1 );
2403 aFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
2404
2405 sal_uInt16 nOffs = o3tl::convert(4, o3tl::Length::mm, o3tl::Length::twip);
2406
2407 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2408 {
2409 aFormat.SetFirstLineOffset( - nOffs );
2410 }
2411 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2412 {
2413 aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2414 aFormat.SetFirstLineIndent( - nOffs );
2415 }
2416
2417 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n)
2418 {
2419 aFormat.SetBulletChar( (n & 1) ? 0x25a1 : 0x2611 );
2420
2421 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2422 {
2423 aFormat.SetAbsLSpace( ((n & 1) +1) * nOffs );
2424 }
2425 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2426 {
2427 tools::Long nPos = ((n & 1) +1) * static_cast<tools::Long>(nOffs);
2428 aFormat.SetListtabPos(nPos);
2429 aFormat.SetIndentAt(nPos);
2430 }
2431
2432 pNewRule->Set( n, aFormat );
2433 }
2434 }
2435 break;
2436 case RES_POOLNUMRULE_BUL4:
2437 {
2438 SwNumFormat aFormat;
2439
2440 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2441 aFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2442 aFormat.SetCharFormat( pBullCFormat );
2443 aFormat.SetStart( 1 );
2444 aFormat.SetIncludeUpperLevels( 1 );
2445 aFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
2446
2447 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2448 {
2449 // cm: 0,4 0,8 1,2 1,6 2,0 2,4 2,8 3,2 3,6 4,0
2450 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
2451 };
2452
2453 const sal_uInt16* pArr = aAbsSpace;
2454
2455 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2456 {
2457 aFormat.SetFirstLineOffset( - (*pArr) );
2458 }
2459 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2460 {
2461 aFormat.SetLabelFollowedBy( SvxNumberFormat::SPACE );
2462 aFormat.SetFirstLineIndent( - (*pArr) );
2463 }
2464
2465 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n, ++pArr)
2466 {
2467 switch( n )
2468 {
2469 case 0: aFormat.SetBulletChar( 0x27a2 ); break;
2470 case 1: aFormat.SetBulletChar( 0xE006 ); break;
2471 default: aFormat.SetBulletChar( 0xE004 ); break;
2472 }
2473
2474 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2475 {
2476 aFormat.SetAbsLSpace( *pArr );
2477 }
2478 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2479 {
2480 aFormat.SetListtabPos( *pArr );
2481 aFormat.SetIndentAt( *pArr );
2482 }
2483
2484 pNewRule->Set( n, aFormat );
2485 }
2486 }
2487 break;
2488 case RES_POOLNUMRULE_BUL5:
2489 {
2490 SwNumFormat aFormat;
2491
2492 aFormat.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2493 aFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2494 aFormat.SetCharFormat( pBullCFormat );
2495 aFormat.SetStart( 1 );
2496 aFormat.SetIncludeUpperLevels( 1 );
2497 aFormat.SetBulletChar( 0x2717 );
2498 aFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
2499
2500 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2501 {
2502 // cm: 0,4 0,8 1,2 1,6 2,0 2,4 2,8 3,2 3,6 4,0
2503 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
2504 };
2505 const sal_uInt16* pArr = aAbsSpace;
2506
2507 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2508 {
2509 aFormat.SetFirstLineOffset( - (*pArr) );
2510 }
2511 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2512 {
2513 aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2514 aFormat.SetFirstLineIndent( - (*pArr) );
2515 }
2516
2517 for (sal_uInt16 n = 0; n < MAXLEVEL; ++n, ++pArr)
2518 {
2519 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2520 {
2521 aFormat.SetAbsLSpace( *pArr );
2522 }
2523 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2524 {
2525 aFormat.SetListtabPos( *pArr );
2526 aFormat.SetIndentAt( *pArr );
2527 }
2528
2529 pNewRule->Set( n, aFormat );
2530 }
2531 }
2532 break;
2533 }
2534
2535 return pNewRule;
2536 }
2537
2538 /// Check if this AutoCollection is already/still in use in this Document
IsPoolTextCollUsed(sal_uInt16 nId) const2539 bool DocumentStylePoolManager::IsPoolTextCollUsed( sal_uInt16 nId ) const
2540 {
2541 OSL_ENSURE(
2542 (RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END) ||
2543 (RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END) ||
2544 (RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END) ||
2545 (RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END) ||
2546 (RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END) ||
2547 (RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END),
2548 "Wrong AutoFormat Id" );
2549
2550 SwTextFormatColl* pNewColl = nullptr;
2551 bool bFnd = false;
2552 for( SwTextFormatColls::size_type n = 0; !bFnd && n < m_rDoc.GetTextFormatColls()->size(); ++n )
2553 {
2554 pNewColl = (*m_rDoc.GetTextFormatColls())[ n ];
2555 if( nId == pNewColl->GetPoolFormatId() )
2556 bFnd = true;
2557 }
2558
2559 if( !bFnd || !pNewColl->HasWriterListeners() )
2560 return false;
2561
2562 bool isUsed = false;
2563 sw::AutoFormatUsedHint aHint(isUsed, m_rDoc.GetNodes());
2564 pNewColl->CallSwClientNotify(aHint);
2565 return isUsed;
2566 }
2567
2568 /// Check if this AutoCollection is already/still in use
IsPoolFormatUsed(sal_uInt16 nId) const2569 bool DocumentStylePoolManager::IsPoolFormatUsed( sal_uInt16 nId ) const
2570 {
2571 const SwFormat *pNewFormat = nullptr;
2572 const SwFormatsBase* pArray[ 2 ];
2573 sal_uInt16 nArrCnt = 1;
2574 bool bFnd = true;
2575
2576 if (RES_POOLCHR_BEGIN <= nId && nId < RES_POOLCHR_END)
2577 {
2578 pArray[0] = m_rDoc.GetCharFormats();
2579 }
2580 else if (RES_POOLFRM_BEGIN <= nId && nId < RES_POOLFRM_END)
2581 {
2582 pArray[0] = m_rDoc.GetFrameFormats();
2583 pArray[1] = m_rDoc.GetSpzFrameFormats();
2584 nArrCnt = 2;
2585 }
2586 else
2587 {
2588 SAL_WARN("sw.core", "Invalid Pool Id: " << nId << " should be within "
2589 "[" << int(RES_POOLCHR_BEGIN) << "," << int(RES_POOLCHR_END) << ") or "
2590 "[" << int(RES_POOLFRM_BEGIN) << "," << int(RES_POOLFRM_END) << ")");
2591 bFnd = false;
2592 }
2593
2594 if( bFnd )
2595 {
2596 bFnd = false;
2597 while (nArrCnt > 0 && !bFnd)
2598 {
2599 --nArrCnt;
2600 for( size_t n = 0; !bFnd && n < (*pArray[nArrCnt]).GetFormatCount(); ++n )
2601 {
2602 pNewFormat = (*pArray[ nArrCnt ] ).GetFormat( n );
2603 if( nId == pNewFormat->GetPoolFormatId() )
2604 bFnd = true;
2605 }
2606 }
2607 }
2608
2609 // Not found or no dependencies?
2610 if(!bFnd || !pNewFormat->HasWriterListeners() )
2611 return false;
2612 // Check if we have dependent ContentNodes in the Nodes array
2613 // (also indirect ones for derived Formats)
2614 return pNewFormat->IsUsed();
2615 }
2616
2617 /// Check if this AutoCollection is already/still in use in this Document
IsPoolPageDescUsed(sal_uInt16 nId) const2618 bool DocumentStylePoolManager::IsPoolPageDescUsed( sal_uInt16 nId ) const
2619 {
2620 OSL_ENSURE( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END,
2621 "Wrong AutoFormat Id" );
2622 SwPageDesc *pNewPgDsc = nullptr;
2623 bool bFnd = false;
2624 for( size_t n = 0; !bFnd && n < m_rDoc.GetPageDescCnt(); ++n )
2625 {
2626 pNewPgDsc = &m_rDoc.GetPageDesc(n);
2627 if( nId == pNewPgDsc->GetPoolFormatId() )
2628 bFnd = true;
2629 }
2630
2631 // Not found or no dependencies?
2632 if( !bFnd || !pNewPgDsc->HasWriterListeners() ) // ??????
2633 return false;
2634
2635 // Check if we have dependent ContentNodes in the Nodes array
2636 // (also indirect ones for derived Formats)
2637 bool isUsed = false;
2638 sw::AutoFormatUsedHint aHint(isUsed, m_rDoc.GetNodes());
2639 pNewPgDsc->CallSwClientNotify(aHint);
2640 return isUsed;
2641 }
2642
~DocumentStylePoolManager()2643 DocumentStylePoolManager::~DocumentStylePoolManager()
2644 {
2645 }
2646
2647 }
2648
2649 static std::vector<OUString>
lcl_NewUINameArray(const TranslateId * pIds,const size_t nLen,const size_t nSvxIds=0)2650 lcl_NewUINameArray(const TranslateId* pIds, const size_t nLen, const size_t nSvxIds = 0)
2651 {
2652 assert(nSvxIds <= nLen);
2653 const size_t nWriterIds = nLen - nSvxIds;
2654 std::vector<OUString> aNameArray;
2655 aNameArray.reserve(nLen);
2656 for (size_t i = 0; i < nWriterIds; ++i)
2657 aNameArray.push_back(SwResId(pIds[i]));
2658 for (size_t i = nWriterIds; i < nLen; ++i)
2659 aNameArray.push_back(SvxResId(pIds[i]));
2660 return aNameArray;
2661 }
2662
GetTextUINameArray()2663 const std::vector<OUString>& SwStyleNameMapper::GetTextUINameArray()
2664 {
2665 SvtSysLocale aSysLocale;
2666 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2667 static std::map<LanguageTag, std::vector<OUString>> s_aTextUINameArray;
2668
2669 auto it = s_aTextUINameArray.find(rCurrentLanguage);
2670 if (it == s_aTextUINameArray.end())
2671 it = s_aTextUINameArray.emplace(rCurrentLanguage,
2672 lcl_NewUINameArray(STR_POOLCOLL_TEXT_ARY, std::ssize(STR_POOLCOLL_TEXT_ARY))).first;
2673
2674 return it->second;
2675 }
2676
GetListsUINameArray()2677 const std::vector<OUString>& SwStyleNameMapper::GetListsUINameArray()
2678 {
2679 SvtSysLocale aSysLocale;
2680 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2681 static std::map<LanguageTag, std::vector<OUString>> s_aListsUINameArray;
2682
2683 auto it = s_aListsUINameArray.find(rCurrentLanguage);
2684 if (it == s_aListsUINameArray.end())
2685 it = s_aListsUINameArray.emplace(rCurrentLanguage,
2686 lcl_NewUINameArray(STR_POOLCOLL_LISTS_ARY, std::ssize(STR_POOLCOLL_LISTS_ARY))).first;
2687
2688 return it->second;
2689 }
2690
GetExtraUINameArray()2691 const std::vector<OUString>& SwStyleNameMapper::GetExtraUINameArray()
2692 {
2693 SvtSysLocale aSysLocale;
2694 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2695 static std::map<LanguageTag, std::vector<OUString>> s_aExtraUINameArray;
2696
2697 auto it = s_aExtraUINameArray.find(rCurrentLanguage);
2698 if (it == s_aExtraUINameArray.end())
2699 it = s_aExtraUINameArray.emplace(rCurrentLanguage,
2700 lcl_NewUINameArray(STR_POOLCOLL_EXTRA_ARY, std::ssize(STR_POOLCOLL_EXTRA_ARY))).first;
2701
2702 return it->second;
2703 }
2704
GetRegisterUINameArray()2705 const std::vector<OUString>& SwStyleNameMapper::GetRegisterUINameArray()
2706 {
2707 SvtSysLocale aSysLocale;
2708 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2709 static std::map<LanguageTag, std::vector<OUString>> s_aRegisterUINameArray;
2710
2711 auto it = s_aRegisterUINameArray.find(rCurrentLanguage);
2712 if (it == s_aRegisterUINameArray.end())
2713 it = s_aRegisterUINameArray.emplace(rCurrentLanguage,
2714 lcl_NewUINameArray(STR_POOLCOLL_REGISTER_ARY, std::ssize(STR_POOLCOLL_REGISTER_ARY))).first;
2715
2716 return it->second;
2717 }
2718
GetDocUINameArray()2719 const std::vector<OUString>& SwStyleNameMapper::GetDocUINameArray()
2720 {
2721 SvtSysLocale aSysLocale;
2722 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2723 static std::map<LanguageTag, std::vector<OUString>> s_aDocUINameArray;
2724
2725 auto it = s_aDocUINameArray.find(rCurrentLanguage);
2726 if (it == s_aDocUINameArray.end())
2727 it = s_aDocUINameArray.emplace(rCurrentLanguage,
2728 lcl_NewUINameArray(STR_POOLCOLL_DOC_ARY, std::ssize(STR_POOLCOLL_DOC_ARY))).first;
2729
2730 return it->second;
2731 }
2732
GetHTMLUINameArray()2733 const std::vector<OUString>& SwStyleNameMapper::GetHTMLUINameArray()
2734 {
2735 SvtSysLocale aSysLocale;
2736 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2737 static std::map<LanguageTag, std::vector<OUString>> s_aHTMLUINameArray;
2738
2739 auto it = s_aHTMLUINameArray.find(rCurrentLanguage);
2740 if (it == s_aHTMLUINameArray.end())
2741 it = s_aHTMLUINameArray.emplace(rCurrentLanguage,
2742 lcl_NewUINameArray(STR_POOLCOLL_HTML_ARY, std::ssize(STR_POOLCOLL_HTML_ARY))).first;
2743
2744 return it->second;
2745 }
2746
GetFrameFormatUINameArray()2747 const std::vector<OUString>& SwStyleNameMapper::GetFrameFormatUINameArray()
2748 {
2749 SvtSysLocale aSysLocale;
2750 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2751 static std::map<LanguageTag, std::vector<OUString>> s_aFrameFormatUINameArray;
2752
2753 auto it = s_aFrameFormatUINameArray.find(rCurrentLanguage);
2754 if (it == s_aFrameFormatUINameArray.end())
2755 it = s_aFrameFormatUINameArray.emplace(rCurrentLanguage,
2756 lcl_NewUINameArray(STR_POOLFRM_ARY, std::ssize(STR_POOLFRM_ARY))).first;
2757
2758 return it->second;
2759 }
2760
GetChrFormatUINameArray()2761 const std::vector<OUString>& SwStyleNameMapper::GetChrFormatUINameArray()
2762 {
2763 SvtSysLocale aSysLocale;
2764 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2765 static std::map<LanguageTag, std::vector<OUString>> s_aChrFormatUINameArray;
2766
2767 auto it = s_aChrFormatUINameArray.find(rCurrentLanguage);
2768 if (it == s_aChrFormatUINameArray.end())
2769 it = s_aChrFormatUINameArray.emplace(rCurrentLanguage,
2770 lcl_NewUINameArray(STR_POOLCHR_ARY, std::ssize(STR_POOLCHR_ARY))).first;
2771
2772 return it->second;
2773 }
2774
GetHTMLChrFormatUINameArray()2775 const std::vector<OUString>& SwStyleNameMapper::GetHTMLChrFormatUINameArray()
2776 {
2777 SvtSysLocale aSysLocale;
2778 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2779 static std::map<LanguageTag, std::vector<OUString>> s_aHTMLChrFormatUINameArray;
2780
2781 auto it = s_aHTMLChrFormatUINameArray.find(rCurrentLanguage);
2782 if (it == s_aHTMLChrFormatUINameArray.end())
2783 it = s_aHTMLChrFormatUINameArray.emplace(rCurrentLanguage,
2784 lcl_NewUINameArray(STR_POOLCHR_HTML_ARY, std::ssize(STR_POOLCHR_HTML_ARY))).first;
2785
2786 return it->second;
2787 }
2788
GetPageDescUINameArray()2789 const std::vector<OUString>& SwStyleNameMapper::GetPageDescUINameArray()
2790 {
2791 SvtSysLocale aSysLocale;
2792 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2793 static std::map<LanguageTag, std::vector<OUString>> s_aPageDescUINameArray;
2794
2795 auto it = s_aPageDescUINameArray.find(rCurrentLanguage);
2796 if (it == s_aPageDescUINameArray.end())
2797 it = s_aPageDescUINameArray.emplace(rCurrentLanguage,
2798 lcl_NewUINameArray(STR_POOLPAGE_ARY, std::ssize(STR_POOLPAGE_ARY))).first;
2799
2800 return it->second;
2801 }
2802
GetNumRuleUINameArray()2803 const std::vector<OUString>& SwStyleNameMapper::GetNumRuleUINameArray()
2804 {
2805 SvtSysLocale aSysLocale;
2806 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2807 static std::map<LanguageTag, std::vector<OUString>> s_aNumRuleUINameArray;
2808
2809 auto it = s_aNumRuleUINameArray.find(rCurrentLanguage);
2810 if (it == s_aNumRuleUINameArray.end())
2811 it = s_aNumRuleUINameArray.emplace(rCurrentLanguage,
2812 lcl_NewUINameArray(STR_POOLNUMRULE_NUM_ARY, std::ssize(STR_POOLNUMRULE_NUM_ARY))).first;
2813
2814 return it->second;
2815 }
2816
GetTableStyleUINameArray()2817 const std::vector<OUString>& SwStyleNameMapper::GetTableStyleUINameArray()
2818 {
2819 SvtSysLocale aSysLocale;
2820 const LanguageTag& rCurrentLanguage = aSysLocale.GetUILanguageTag();
2821 static std::map<LanguageTag, std::vector<OUString>> s_aTableStyleUINameArray;
2822
2823 auto it = s_aTableStyleUINameArray.find(rCurrentLanguage);
2824 if (it == s_aTableStyleUINameArray.end())
2825 it = s_aTableStyleUINameArray.emplace(rCurrentLanguage,
2826 // 1 Writer resource string (XXX if this ever changes rather use offset math)
2827 lcl_NewUINameArray(STR_TABSTYLE_ARY, std::ssize(STR_TABSTYLE_ARY),
2828 static_cast<size_t>(std::ssize(STR_TABSTYLE_ARY) - 1))).first;
2829
2830 return it->second;
2831 }
2832
2833 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
2834