update credits
[LibreOffice.git] / sw / source / core / doc / poolfmt.cxx
blobb6494f558c086bb01fbe1d81f304d48e1172cbb7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <hintids.hxx>
22 #include <i18nlangtag/mslangid.hxx>
23 #include <unotools/localedatawrapper.hxx>
24 #include <editeng/paperinf.hxx>
25 #include <editeng/wghtitem.hxx>
26 #include <editeng/fontitem.hxx>
27 #include <editeng/fhgtitem.hxx>
28 #include <editeng/tstpitem.hxx>
29 #include <editeng/lrspitem.hxx>
30 #include <editeng/ulspitem.hxx>
31 #include <editeng/adjustitem.hxx>
32 #include <editeng/postitem.hxx>
33 #include <editeng/keepitem.hxx>
34 #include <editeng/opaqitem.hxx>
35 #include <editeng/boxitem.hxx>
36 #include <editeng/cmapitem.hxx>
37 #include <editeng/udlnitem.hxx>
38 #include <editeng/colritem.hxx>
39 #include <editeng/protitem.hxx>
40 #include <editeng/escapementitem.hxx>
41 #include <editeng/langitem.hxx>
42 #include <editeng/charrotateitem.hxx>
43 #include <editeng/frmdiritem.hxx>
44 #include <editeng/emphasismarkitem.hxx>
45 #include <editeng/scriptspaceitem.hxx>
46 #include <viewopt.hxx>
47 #include <doc.hxx>
48 #include <IDocumentUndoRedo.hxx>
49 #include <fmtanchr.hxx>
50 #include <fmtornt.hxx>
51 #include <fmtsrnd.hxx>
52 #include <fmtfsize.hxx>
53 #include <poolfmt.hxx>
54 #include <paratr.hxx>
55 #include <pagedesc.hxx>
56 #include <frmtool.hxx>
57 #include <charfmt.hxx>
58 #include <docary.hxx>
59 #include <fmtcol.hxx>
60 #include <ndtxt.hxx>
61 #include <fmtline.hxx>
62 #include <poolfmt.hrc>
63 #include <GetMetricVal.hxx>
64 #include <numrule.hxx>
67 using namespace ::editeng;
68 using namespace ::com::sun::star;
70 const sal_uInt16 PT_3 = 3 * 20; // 3 pt
71 const sal_uInt16 PT_6 = 6 * 20; // 6 pt
72 const sal_uInt16 PT_7 = 7 * 20; // 6 pt
73 const sal_uInt16 PT_8 = 8 * 20; // 8 pt
74 const sal_uInt16 PT_9 = 9 * 20; // 9 pt
75 const sal_uInt16 PT_10 = 10 * 20; // 10 pt
76 const sal_uInt16 PT_11 = 11 * 20; // 11 pt
77 const sal_uInt16 PT_12 = 12 * 20; // 12 pt
78 const sal_uInt16 PT_14 = 14 * 20; // 14 pt
79 const sal_uInt16 PT_16 = 16 * 20; // 16 pt
80 const sal_uInt16 PT_18 = 18 * 20; // 18 pt
81 const sal_uInt16 PT_22 = 22 * 20; // 22 pt
82 const sal_uInt16 PT_24 = 24 * 20; // 22 pt
85 #define HTML_PARSPACE GetMetricVal( CM_05 )
87 static const sal_uInt16 aHeadlineSizes[ 2 * MAXLEVEL ] = {
88 // PT_16, PT_14, PT_14, PT_12, PT_12, // normal
89 // we do everything procentual now:
90 115, 100, 100, 85, 85,
91 75, 75, 75, 75, 75, // normal
92 // PT_22, PT_16, PT_12, PT_11, PT_9 // HTML mode
93 PT_24, PT_18, PT_14, PT_12, PT_10,
94 PT_7, PT_7, PT_7, PT_7, PT_7 // HTML mode
97 static long lcl_GetRightMargin( SwDoc& rDoc )
99 // Make sure that the printer settings are taken over to the standard
100 // page style
101 const SwFrmFmt& rPgDscFmt = rDoc.GetPageDesc( 0 ).GetMaster();
102 const SvxLRSpaceItem& rLR = rPgDscFmt.GetLRSpace();
103 const long nLeft = rLR.GetLeft();
104 const long nRight = rLR.GetRight();
105 const long nWidth = rPgDscFmt.GetFrmSize().GetWidth();
106 return nWidth - nLeft - nRight;
109 void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem )
111 rSet.Put( rItem );
112 sal_uInt16 nWhCJK = 0, nWhCTL = 0;
113 switch( rItem.Which() )
115 case RES_CHRATR_FONTSIZE:
116 nWhCJK = RES_CHRATR_CJK_FONTSIZE, nWhCTL = RES_CHRATR_CTL_FONTSIZE;
117 break;
118 case RES_CHRATR_FONT:
119 nWhCJK = RES_CHRATR_CJK_FONT, nWhCTL = RES_CHRATR_CTL_FONT;
120 break;
121 case RES_CHRATR_LANGUAGE:
122 nWhCJK = RES_CHRATR_CJK_LANGUAGE, nWhCTL = RES_CHRATR_CTL_LANGUAGE;
123 break;
124 case RES_CHRATR_POSTURE:
125 nWhCJK = RES_CHRATR_CJK_POSTURE, nWhCTL = RES_CHRATR_CTL_POSTURE;
126 break;
127 case RES_CHRATR_WEIGHT:
128 nWhCJK = RES_CHRATR_CJK_WEIGHT, nWhCTL = RES_CHRATR_CTL_WEIGHT;
129 break;
132 if( nWhCJK )
133 rSet.Put( rItem, nWhCJK );
134 if( nWhCTL )
135 rSet.Put( rItem, nWhCTL );
138 static void lcl_SetDfltFont( sal_uInt16 nFntType, SfxItemSet& rSet )
140 static struct {
141 sal_uInt16 nResLngId;
142 sal_uInt16 nResFntId;
143 } aArr[ 3 ] = {
144 { RES_CHRATR_LANGUAGE, RES_CHRATR_FONT },
145 { RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_FONT },
146 { RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_FONT }
148 for( sal_uInt16 n = 0; n < 3; ++n )
150 sal_uInt16 nLng = ((SvxLanguageItem&)rSet.GetPool()->GetDefaultItem(
151 aArr[n].nResLngId )).GetLanguage();
152 Font aFnt( OutputDevice::GetDefaultFont( nFntType,
153 nLng, DEFAULTFONT_FLAGS_ONLYONE ) );
155 rSet.Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(),
156 aEmptyStr, aFnt.GetPitch(),
157 aFnt.GetCharSet(), aArr[n].nResFntId ));
161 static void lcl_SetDfltFont( sal_uInt16 nLatinFntType, sal_uInt16 nCJKFntType,
162 sal_uInt16 nCTLFntType, SfxItemSet& rSet )
164 static struct {
165 sal_uInt16 nResLngId;
166 sal_uInt16 nResFntId;
167 sal_uInt16 nFntType;
168 } aArr[ 3 ] = {
169 { RES_CHRATR_LANGUAGE, RES_CHRATR_FONT, 0 },
170 { RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_FONT, 0 },
171 { RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_FONT, 0 }
173 aArr[0].nFntType = nLatinFntType;
174 aArr[1].nFntType = nCJKFntType;
175 aArr[2].nFntType = nCTLFntType;
177 for( sal_uInt16 n = 0; n < 3; ++n )
179 sal_uInt16 nLng = ((SvxLanguageItem&)rSet.GetPool()->GetDefaultItem(
180 aArr[n].nResLngId )).GetLanguage();
181 Font aFnt( OutputDevice::GetDefaultFont( aArr[n].nFntType,
182 nLng, DEFAULTFONT_FLAGS_ONLYONE ) );
184 rSet.Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(),
185 aEmptyStr, aFnt.GetPitch(),
186 aFnt.GetCharSet(), aArr[n].nResFntId ));
190 static void lcl_SetHeadline( SwDoc* pDoc, SwTxtFmtColl* pColl,
191 SfxItemSet& rSet,
192 sal_uInt16 nOutLvlBits, sal_uInt8 nLevel, bool bItalic )
194 SetAllScriptItem( rSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
195 SvxFontHeightItem aHItem(240, 100, RES_CHRATR_FONTSIZE);
196 const bool bHTMLMode = pDoc->get(IDocumentSettingAccess::HTML_MODE);
197 if( bHTMLMode )
198 aHItem.SetHeight( aHeadlineSizes[ MAXLEVEL + nLevel ] );
199 else
200 aHItem.SetHeight( PT_14, aHeadlineSizes[ nLevel ] );
201 SetAllScriptItem( rSet, aHItem );
203 if( bItalic && !bHTMLMode )
204 SetAllScriptItem( rSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE ) );
206 if( bHTMLMode )
208 ::lcl_SetDfltFont( DEFAULTFONT_LATIN_TEXT, DEFAULTFONT_CJK_TEXT,
209 DEFAULTFONT_CTL_TEXT, rSet );
212 if( pColl )
214 if( !( nOutLvlBits & ( 1 << nLevel )) )
216 pColl->AssignToListLevelOfOutlineStyle(nLevel);//<-end,zhaojianwei
217 if( !bHTMLMode )
219 SwNumRule * pOutlineRule = pDoc->GetOutlineNumRule();
220 const SwNumFmt& rNFmt = pOutlineRule->Get( nLevel );
222 if ( rNFmt.GetPositionAndSpaceMode() ==
223 SvxNumberFormat::LABEL_WIDTH_AND_POSITION &&
224 ( rNFmt.GetAbsLSpace() || rNFmt.GetFirstLineOffset() ) )
226 SvxLRSpaceItem aLR( (SvxLRSpaceItem&)pColl->GetFmtAttr( RES_LR_SPACE ) );
227 aLR.SetTxtFirstLineOfstValue( rNFmt.GetFirstLineOffset() );
228 aLR.SetTxtLeft( rNFmt.GetAbsLSpace() );
229 pColl->SetFmtAttr( aLR );
232 // #i71764#
233 // Check on document setting OUTLINE_LEVEL_YIELDS_OUTLINE_RULE no longer needed.
234 // All paragraph styles, which are assigned to a level of the
235 // outline style has to have the outline style set as its list style.
237 SwNumRuleItem aItem(pOutlineRule->GetName());
239 pColl->SetFmtAttr(aItem);
243 pColl->SetNextTxtFmtColl( *pDoc->GetTxtCollFromPool(
244 RES_POOLCOLL_TEXT ));
250 static void lcl_SetRegister( SwDoc* pDoc, SfxItemSet& rSet, sal_uInt16 nFact,
251 bool bHeader, bool bTab )
253 SvxLRSpaceItem aLR( RES_LR_SPACE );
254 sal_uInt16 nLeft = nFact ? GetMetricVal( CM_05 ) * nFact : 0;
255 aLR.SetTxtLeft( nLeft );
257 rSet.Put( aLR );
258 if( bHeader )
260 SetAllScriptItem( rSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
261 SetAllScriptItem( rSet, SvxFontHeightItem( PT_16, 100, RES_CHRATR_FONTSIZE ) );
263 if( bTab )
265 long nRightMargin = lcl_GetRightMargin( *pDoc );
266 SvxTabStopItem aTStops( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
267 aTStops.Insert( SvxTabStop( nRightMargin - nLeft,
268 SVX_TAB_ADJUST_RIGHT,
269 cDfltDecimalChar, '.' ));
270 rSet.Put( aTStops );
276 static void lcl_SetNumBul( SwDoc* pDoc, SwTxtFmtColl* pColl,
277 SfxItemSet& rSet,
278 sal_uInt16 nNxt, SwTwips nEZ, SwTwips nLeft,
279 SwTwips nUpper, SwTwips nLower )
282 SvxLRSpaceItem aLR( RES_LR_SPACE ); SvxULSpaceItem aUL( RES_UL_SPACE );
283 aLR.SetTxtFirstLineOfst( sal_uInt16(nEZ) ); aLR.SetTxtLeft( sal_uInt16(nLeft) );
284 aUL.SetUpper( sal_uInt16(nUpper) ); aUL.SetLower( sal_uInt16(nLower) );
285 rSet.Put( aLR );
286 rSet.Put( aUL );
288 if( pColl )
289 pColl->SetNextTxtFmtColl( *pDoc->GetTxtCollFromPool( nNxt ));
292 /// Return the AutoCollection by it's Id. If it doesn't
293 /// exist yet, create it.
294 /// If the String pointer is defined, then only query for
295 /// the Attribute descriptions. It doesn't create a style!
296 SvxFrameDirection GetDefaultFrameDirection(sal_uLong nLanguage)
298 SvxFrameDirection eResult = (MsLangId::isRightToLeft( static_cast<LanguageType>(nLanguage)) ?
299 FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP);
300 return eResult;
303 SwTxtFmtColl* SwDoc::GetTxtCollFromPool( sal_uInt16 nId, bool bRegardLanguage )
305 OSL_ENSURE(
306 (RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END) ||
307 (RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END) ||
308 (RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END) ||
309 (RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END) ||
310 (RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END) ||
311 (RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END),
312 "Wrong AutoFormat Id" );
314 SwTxtFmtColl* pNewColl;
315 sal_uInt16 nOutLvlBits = 0;
316 for( sal_uInt16 n = 0; n < mpTxtFmtCollTbl->size(); ++n )
318 if( nId == ( pNewColl = (*mpTxtFmtCollTbl)[ n ] )->GetPoolFmtId() )
320 return pNewColl;
323 if( pNewColl->IsAssignedToListLevelOfOutlineStyle())
324 nOutLvlBits |= ( 1 << pNewColl->GetAssignedOutlineStyleLevel() );//<-end,zhaojianwei
327 // Didn't find it until here -> create anew
328 sal_uInt16 nResId = 0;
329 if( RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END )
330 nResId = RC_POOLCOLL_TEXT_BEGIN - RES_POOLCOLL_TEXT_BEGIN;
331 else if (RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END)
332 nResId = RC_POOLCOLL_LISTS_BEGIN - RES_POOLCOLL_LISTS_BEGIN;
333 else if (RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END)
334 nResId = RC_POOLCOLL_EXTRA_BEGIN - RES_POOLCOLL_EXTRA_BEGIN;
335 else if (RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END)
336 nResId = RC_POOLCOLL_REGISTER_BEGIN - RES_POOLCOLL_REGISTER_BEGIN;
337 else if (RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END)
338 nResId = RC_POOLCOLL_DOC_BEGIN - RES_POOLCOLL_DOC_BEGIN;
339 else if (RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END)
340 nResId = RC_POOLCOLL_HTML_BEGIN - RES_POOLCOLL_HTML_BEGIN;
342 OSL_ENSURE( nResId, "Invalid Pool ID" );
343 if( !nResId )
344 return GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
346 ResId aResId( nResId + nId, *pSwResMgr );
347 String aNm( aResId );
349 // A Set for all to-be-set Attributes
350 SwAttrSet aSet( GetAttrPool(), aTxtFmtCollSetRange );
351 sal_uInt16 nParent = GetPoolParent( nId );
355 //FEATURE::CONDCOLL
356 if(::IsConditionalByPoolId( nId ))
357 pNewColl = new SwConditionTxtFmtColl( GetAttrPool(), aNm, !nParent
358 ? mpDfltTxtFmtColl
359 : GetTxtCollFromPool( nParent ));
360 else
361 //FEATURE::CONDCOLL
362 pNewColl = new SwTxtFmtColl( GetAttrPool(), aNm, !nParent
363 ? mpDfltTxtFmtColl
364 : GetTxtCollFromPool( nParent ));
365 pNewColl->SetPoolFmtId( nId );
366 mpTxtFmtCollTbl->push_back( pNewColl );
369 bool bNoDefault = get( IDocumentSettingAccess::STYLES_NODEFAULT );
370 if ( !bNoDefault )
372 switch( nId )
374 // General content forms
375 case RES_POOLCOLL_STANDARD:
376 /* koreans do not like SvxScriptItem(TRUE) */
377 if (bRegardLanguage)
379 sal_uLong nAppLanguage = GetAppLanguage();
380 if (GetDefaultFrameDirection(nAppLanguage) ==
381 FRMDIR_HORI_RIGHT_TOP)
383 SvxAdjustItem aAdjust(SVX_ADJUST_RIGHT, RES_PARATR_ADJUST );
384 aSet.Put(aAdjust);
386 if (nAppLanguage == LANGUAGE_KOREAN)
388 SvxScriptSpaceItem aScriptSpace(sal_False, RES_PARATR_SCRIPTSPACE);
389 aSet.Put(aScriptSpace);
392 break;
394 case RES_POOLCOLL_TEXT: // Text body
396 SvxULSpaceItem aUL( 0, PT_6, RES_UL_SPACE );
397 if( get(IDocumentSettingAccess::HTML_MODE) ) aUL.SetLower( HTML_PARSPACE );
398 aSet.Put( aUL );
400 break;
401 case RES_POOLCOLL_TEXT_IDENT: // Text body indentation
403 SvxLRSpaceItem aLR( RES_LR_SPACE );
404 aLR.SetTxtFirstLineOfst( GetMetricVal( CM_05 ));
405 aSet.Put( aLR );
407 break;
408 case RES_POOLCOLL_TEXT_NEGIDENT: // Text body neg. indentation
410 SvxLRSpaceItem aLR( RES_LR_SPACE );
411 aLR.SetTxtFirstLineOfst( -(short)GetMetricVal( CM_05 ));
412 aLR.SetTxtLeft( GetMetricVal( CM_1 ));
413 SvxTabStopItem aTStops(RES_PARATR_TABSTOP); aTStops.Insert( SvxTabStop( 0 ));
415 aSet.Put( aLR );
416 aSet.Put( aTStops );
418 break;
419 case RES_POOLCOLL_TEXT_MOVE: // Text body move
421 SvxLRSpaceItem aLR( RES_LR_SPACE );
422 aLR.SetTxtLeft( GetMetricVal( CM_05 ));
423 aSet.Put( aLR );
425 break;
427 case RES_POOLCOLL_CONFRONTATION: // Text body confrontation
429 SvxLRSpaceItem aLR( RES_LR_SPACE );
430 aLR.SetTxtFirstLineOfst( - short( GetMetricVal( CM_1 ) * 4 +
431 GetMetricVal( CM_05)) );
432 aLR.SetTxtLeft( GetMetricVal( CM_1 ) * 5 );
433 SvxTabStopItem aTStops( RES_PARATR_TABSTOP ); aTStops.Insert( SvxTabStop( 0 ));
435 aSet.Put( aLR );
436 aSet.Put( aTStops );
438 break;
439 case RES_POOLCOLL_MARGINAL: // Text body marginal
441 SvxLRSpaceItem aLR( RES_LR_SPACE );
442 aLR.SetTxtLeft( GetMetricVal( CM_1 ) * 4 );
443 aSet.Put( aLR );
445 break;
447 case RES_POOLCOLL_HEADLINE_BASE: // Base headline
449 static const sal_uInt16 aFntInit[] = {
450 DEFAULTFONT_LATIN_HEADING, RES_CHRATR_FONT,
451 RES_CHRATR_LANGUAGE, LANGUAGE_ENGLISH_US,
452 DEFAULTFONT_CJK_HEADING, RES_CHRATR_CJK_FONT,
453 RES_CHRATR_CJK_LANGUAGE, LANGUAGE_ENGLISH_US,
454 DEFAULTFONT_CTL_HEADING, RES_CHRATR_CTL_FONT,
455 RES_CHRATR_CTL_LANGUAGE, LANGUAGE_ARABIC_SAUDI_ARABIA,
459 for( const sal_uInt16* pArr = aFntInit; *pArr; pArr += 4 )
461 sal_uInt16 nLng = ((SvxLanguageItem&)GetDefault( *(pArr+2) )).GetLanguage();
462 if( LANGUAGE_DONTKNOW == nLng )
463 nLng = *(pArr+3);
465 Font aFnt( OutputDevice::GetDefaultFont( *pArr,
466 nLng, DEFAULTFONT_FLAGS_ONLYONE ) );
468 aSet.Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(),
469 aEmptyStr, aFnt.GetPitch(),
470 aFnt.GetCharSet(), *(pArr+1) ));
473 SvxFontHeightItem aFntSize( PT_14, 100, RES_CHRATR_FONTSIZE );
474 SvxULSpaceItem aUL( PT_12, PT_6, RES_UL_SPACE );
475 if( get(IDocumentSettingAccess::HTML_MODE) )
476 aUL.SetLower( HTML_PARSPACE );
477 aSet.Put( SvxFmtKeepItem( sal_True, RES_KEEP ));
479 pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
481 aSet.Put( aUL );
482 SetAllScriptItem( aSet, aFntSize );
484 break;
486 case RES_POOLCOLL_NUMBUL_BASE: // Base Numbering
487 break;
489 case RES_POOLCOLL_GREETING: // Greeting
490 case RES_POOLCOLL_REGISTER_BASE: // Base indexes
491 case RES_POOLCOLL_SIGNATURE: // Signatures
492 case RES_POOLCOLL_TABLE: // Tabele content
494 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
495 aSet.Put( aLN );
497 break;
499 case RES_POOLCOLL_HEADLINE1: // Headinline 1
500 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 0, false );
501 break;
502 case RES_POOLCOLL_HEADLINE2: // Headinline 2
503 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 1, true );
504 break;
505 case RES_POOLCOLL_HEADLINE3: // Headinline 3
506 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 2, false );
507 break;
508 case RES_POOLCOLL_HEADLINE4: // Headinline 4
509 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 3, true );
510 break;
511 case RES_POOLCOLL_HEADLINE5: // Headinline 5
512 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 4, false );
513 break;
514 case RES_POOLCOLL_HEADLINE6: // Headinline 6
515 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 5, false );
516 break;
517 case RES_POOLCOLL_HEADLINE7: // Headinline 7
518 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 6, false );
519 break;
520 case RES_POOLCOLL_HEADLINE8: // Headinline 8
521 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 7, false );
522 break;
523 case RES_POOLCOLL_HEADLINE9: // Headinline 9
524 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 8, false );
525 break;
526 case RES_POOLCOLL_HEADLINE10: // Headinline 10
527 lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 9, false );
528 break;
531 // Special sections:
532 // Header
533 case RES_POOLCOLL_HEADER:
534 case RES_POOLCOLL_HEADERL:
535 case RES_POOLCOLL_HEADERR:
536 // Footer
537 case RES_POOLCOLL_FOOTER:
538 case RES_POOLCOLL_FOOTERL:
539 case RES_POOLCOLL_FOOTERR:
541 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
542 aSet.Put( aLN );
544 long nRightMargin = lcl_GetRightMargin( *this );
546 SvxTabStopItem aTStops( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
547 aTStops.Insert( SvxTabStop( nRightMargin / 2, SVX_TAB_ADJUST_CENTER ) );
548 aTStops.Insert( SvxTabStop( nRightMargin, SVX_TAB_ADJUST_RIGHT ) );
550 aSet.Put( aTStops );
552 break;
554 case RES_POOLCOLL_TABLE_HDLN:
556 SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
557 aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ) );
558 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
559 aSet.Put( aLN );
561 break;
563 case RES_POOLCOLL_FOOTNOTE: // paragraph style Footnote
564 case RES_POOLCOLL_ENDNOTE: // paragraph style Endnote
566 SvxLRSpaceItem aLR( RES_LR_SPACE );
567 aLR.SetTxtFirstLineOfst( -(short)( GetMetricVal( CM_05 ) + GetMetricVal( CM_01 ) ) );
568 aLR.SetTxtLeft( GetMetricVal( CM_05 ) + GetMetricVal( CM_01 ) );
569 SetAllScriptItem( aSet, SvxFontHeightItem( PT_10, 100, RES_CHRATR_FONTSIZE ) );
570 aSet.Put( aLR );
571 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
572 aSet.Put( aLN );
574 break;
576 case RES_POOLCOLL_LABEL: // basic caption
578 SvxULSpaceItem aUL( RES_UL_SPACE ); aUL.SetUpper( PT_6 ); aUL.SetLower( PT_6 );
579 aSet.Put( aUL );
580 SetAllScriptItem( aSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE ) );
581 SetAllScriptItem( aSet, SvxFontHeightItem( PT_10, 100, RES_CHRATR_FONTSIZE ) );
582 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
583 aSet.Put( aLN );
585 break;
587 case RES_POOLCOLL_FRAME: // Frame content
588 case RES_POOLCOLL_LABEL_ABB: // caption image
589 case RES_POOLCOLL_LABEL_TABLE: // caption table
590 case RES_POOLCOLL_LABEL_FRAME: // caption frame
591 case RES_POOLCOLL_LABEL_DRAWING: // caption drawing
592 break;
594 case RES_POOLCOLL_JAKETADRESS: // envelope address
596 SvxULSpaceItem aUL( RES_UL_SPACE ); aUL.SetLower( PT_3 );
597 aSet.Put( aUL );
598 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
599 aSet.Put( aLN );
601 break;
603 case RES_POOLCOLL_SENDADRESS: // Sender address
605 if( get(IDocumentSettingAccess::HTML_MODE) )
606 SetAllScriptItem( aSet, SvxPostureItem(ITALIC_NORMAL, RES_CHRATR_POSTURE) );
607 else
609 SvxULSpaceItem aUL( RES_UL_SPACE ); aUL.SetLower( PT_3 );
610 aSet.Put( aUL );
612 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
613 aSet.Put( aLN );
615 break;
617 // User defined indexes:
618 case RES_POOLCOLL_TOX_USERH: // Header
619 lcl_SetRegister( this, aSet, 0, true, false );
621 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
622 aSet.Put( aLN );
624 break;
625 case RES_POOLCOLL_TOX_USER1: // 1. Level
626 lcl_SetRegister( this, aSet, 0, false, true );
627 break;
628 case RES_POOLCOLL_TOX_USER2: // 2. Level
629 lcl_SetRegister( this, aSet, 1, false, true );
630 break;
631 case RES_POOLCOLL_TOX_USER3: // 3. Level
632 lcl_SetRegister( this, aSet, 2, false, true );
633 break;
634 case RES_POOLCOLL_TOX_USER4: // 4. Level
635 lcl_SetRegister( this, aSet, 3, false, true );
636 break;
637 case RES_POOLCOLL_TOX_USER5: // 5. Level
638 lcl_SetRegister( this, aSet, 4, false, true );
639 break;
640 case RES_POOLCOLL_TOX_USER6: // 6. Level
641 lcl_SetRegister( this, aSet, 5, false, true );
642 break;
643 case RES_POOLCOLL_TOX_USER7: // 7. Level
644 lcl_SetRegister( this, aSet, 6, false, true );
645 break;
646 case RES_POOLCOLL_TOX_USER8: // 8. Level
647 lcl_SetRegister( this, aSet, 7, false, true );
648 break;
649 case RES_POOLCOLL_TOX_USER9: // 9. Level
650 lcl_SetRegister( this, aSet, 8, false, true );
651 break;
652 case RES_POOLCOLL_TOX_USER10: // 10. Level
653 lcl_SetRegister( this, aSet, 9, false, true );
654 break;
656 // Index
657 case RES_POOLCOLL_TOX_IDXH: // Header
658 lcl_SetRegister( this, aSet, 0, true, false );
660 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
661 aSet.Put( aLN );
663 break;
664 case RES_POOLCOLL_TOX_IDX1: // 1. Level
665 lcl_SetRegister( this, aSet, 0, false, false );
666 break;
667 case RES_POOLCOLL_TOX_IDX2: // 2. Level
668 lcl_SetRegister( this, aSet, 1, false, false );
669 break;
670 case RES_POOLCOLL_TOX_IDX3: // 3. Level
671 lcl_SetRegister( this, aSet, 2, false, false );
672 break;
673 case RES_POOLCOLL_TOX_IDXBREAK: // Trenner
674 lcl_SetRegister( this, aSet, 0, false, false );
675 break;
677 // Table of Content
678 case RES_POOLCOLL_TOX_CNTNTH: // Header
679 lcl_SetRegister( this, aSet, 0, true, false );
681 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
682 aSet.Put( aLN );
684 break;
685 case RES_POOLCOLL_TOX_CNTNT1: // 1. Level
686 lcl_SetRegister( this, aSet, 0, false, true );
687 break;
688 case RES_POOLCOLL_TOX_CNTNT2: // 2. Level
689 lcl_SetRegister( this, aSet, 1, false, true );
690 break;
691 case RES_POOLCOLL_TOX_CNTNT3: // 3. Level
692 lcl_SetRegister( this, aSet, 2, false, true );
693 break;
694 case RES_POOLCOLL_TOX_CNTNT4: // 4. Level
695 lcl_SetRegister( this, aSet, 3, false, true );
696 break;
697 case RES_POOLCOLL_TOX_CNTNT5: // 5. Level
698 lcl_SetRegister( this, aSet, 4, false, true );
699 break;
700 case RES_POOLCOLL_TOX_CNTNT6: // 6. Level
701 lcl_SetRegister( this, aSet, 5, false, true );
702 break;
703 case RES_POOLCOLL_TOX_CNTNT7: // 7. Level
704 lcl_SetRegister( this, aSet, 6, false, true );
705 break;
706 case RES_POOLCOLL_TOX_CNTNT8: // 8. Level
707 lcl_SetRegister( this, aSet, 7, false, true );
708 break;
709 case RES_POOLCOLL_TOX_CNTNT9: // 9. Level
710 lcl_SetRegister( this, aSet, 8, false, true );
711 break;
712 case RES_POOLCOLL_TOX_CNTNT10: // 10. Level
713 lcl_SetRegister( this, aSet, 9, false, true );
714 break;
716 case RES_POOLCOLL_TOX_ILLUSH:
717 case RES_POOLCOLL_TOX_OBJECTH:
718 case RES_POOLCOLL_TOX_TABLESH:
719 case RES_POOLCOLL_TOX_AUTHORITIESH:
720 lcl_SetRegister( this, aSet, 0, true, false );
722 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
723 aSet.Put( aLN );
725 break;
726 case RES_POOLCOLL_TOX_ILLUS1:
727 case RES_POOLCOLL_TOX_OBJECT1:
728 case RES_POOLCOLL_TOX_TABLES1:
729 case RES_POOLCOLL_TOX_AUTHORITIES1:
730 lcl_SetRegister( this, aSet, 0, false, true );
731 break;
735 case RES_POOLCOLL_NUM_LEVEL1S:
736 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
737 lNumFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
738 PT_12, PT_6 );
739 break;
740 case RES_POOLCOLL_NUM_LEVEL1:
741 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
742 lNumFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
743 0, PT_6 );
744 break;
745 case RES_POOLCOLL_NUM_LEVEL1E:
746 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
747 lNumFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
748 0, PT_12 );
749 break;
750 case RES_POOLCOLL_NUM_NONUM1:
751 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM1,
752 0, SwNumRule::GetNumIndent( 0 ), 0, PT_6 );
753 break;
754 case RES_POOLCOLL_NUM_LEVEL2S:
755 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
756 lNumFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
757 PT_12, PT_6 );
758 break;
759 case RES_POOLCOLL_NUM_LEVEL2:
760 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
761 lNumFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
762 0, PT_6 );
763 break;
764 case RES_POOLCOLL_NUM_LEVEL2E:
765 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
766 lNumFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
767 0, PT_12 );
768 break;
769 case RES_POOLCOLL_NUM_NONUM2:
770 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM2,
771 0, SwNumRule::GetNumIndent( 1 ), 0, PT_6 );
772 break;
773 case RES_POOLCOLL_NUM_LEVEL3S:
774 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
775 lNumFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
776 PT_12, PT_6 );
777 break;
778 case RES_POOLCOLL_NUM_LEVEL3:
779 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
780 lNumFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
781 0, PT_6 );
782 break;
783 case RES_POOLCOLL_NUM_LEVEL3E:
784 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
785 lNumFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
786 0, PT_12 );
787 break;
788 case RES_POOLCOLL_NUM_NONUM3:
789 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM3,
790 0, SwNumRule::GetNumIndent( 2 ), 0, PT_6 );
791 break;
792 case RES_POOLCOLL_NUM_LEVEL4S:
793 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
794 lNumFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
795 PT_12, PT_6 );
796 break;
797 case RES_POOLCOLL_NUM_LEVEL4:
798 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
799 lNumFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
800 0, PT_6 );
801 break;
802 case RES_POOLCOLL_NUM_LEVEL4E:
803 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
804 lNumFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
805 0, PT_12 );
806 break;
807 case RES_POOLCOLL_NUM_NONUM4:
808 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM4,
809 0, SwNumRule::GetNumIndent( 3 ), 0, PT_6 );
810 break;
811 case RES_POOLCOLL_NUM_LEVEL5S:
812 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
813 lNumFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
814 PT_12, PT_6 );
815 break;
816 case RES_POOLCOLL_NUM_LEVEL5:
817 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
818 lNumFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
819 0, PT_6 );
820 break;
821 case RES_POOLCOLL_NUM_LEVEL5E:
822 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
823 lNumFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
824 0, PT_12 );
825 break;
826 case RES_POOLCOLL_NUM_NONUM5:
827 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM5,
828 0, SwNumRule::GetNumIndent( 4 ), 0, PT_6 );
829 break;
831 case RES_POOLCOLL_BUL_LEVEL1S:
832 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL1,
833 lBullFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
834 PT_12, PT_6 );
835 break;
836 case RES_POOLCOLL_BUL_LEVEL1:
837 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL1,
838 lBullFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
839 0, PT_6 );
840 break;
841 case RES_POOLCOLL_BUL_LEVEL1E:
842 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL1,
843 lBullFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
844 0, PT_12 );
845 break;
846 case RES_POOLCOLL_BUL_NONUM1:
847 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM1,
848 0, SwNumRule::GetBullIndent( 0 ), 0, PT_6 );
849 break;
850 case RES_POOLCOLL_BUL_LEVEL2S:
851 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL2,
852 lBullFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
853 PT_12, PT_6 );
854 break;
855 case RES_POOLCOLL_BUL_LEVEL2:
856 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL2,
857 lBullFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
858 0, PT_6 );
859 break;
860 case RES_POOLCOLL_BUL_LEVEL2E:
861 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL2,
862 lBullFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
863 0, PT_12 );
864 break;
865 case RES_POOLCOLL_BUL_NONUM2:
866 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM2,
867 0, SwNumRule::GetBullIndent( 1 ), 0, PT_6 );
868 break;
869 case RES_POOLCOLL_BUL_LEVEL3S:
870 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL3,
871 lBullFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
872 PT_12, PT_6 );
873 break;
874 case RES_POOLCOLL_BUL_LEVEL3:
875 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL3,
876 lBullFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
877 0, PT_6 );
878 break;
879 case RES_POOLCOLL_BUL_LEVEL3E:
880 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL3,
881 lBullFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
882 0, PT_12 );
883 break;
884 case RES_POOLCOLL_BUL_NONUM3:
885 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM3,
886 0, SwNumRule::GetBullIndent( 2 ), 0, PT_6 );
887 break;
888 case RES_POOLCOLL_BUL_LEVEL4S:
889 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL4,
890 lBullFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
891 PT_12, PT_6 );
892 break;
893 case RES_POOLCOLL_BUL_LEVEL4:
894 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL4,
895 lBullFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
896 0, PT_6 );
897 break;
898 case RES_POOLCOLL_BUL_LEVEL4E:
899 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL4,
900 lBullFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
901 0, PT_12 );
902 break;
903 case RES_POOLCOLL_BUL_NONUM4:
904 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM4,
905 0, SwNumRule::GetBullIndent( 3 ), 0, PT_6 );
906 break;
907 case RES_POOLCOLL_BUL_LEVEL5S:
908 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL5,
909 lBullFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
910 PT_12, PT_6 );
911 break;
912 case RES_POOLCOLL_BUL_LEVEL5:
913 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL5,
914 lBullFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
915 0, PT_6 );
916 break;
917 case RES_POOLCOLL_BUL_LEVEL5E:
918 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL5,
919 lBullFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
920 0, PT_12 );
921 break;
922 case RES_POOLCOLL_BUL_NONUM5:
923 lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM5,
924 0, SwNumRule::GetBullIndent( 4 ), 0, PT_6 );
925 break;
927 case RES_POOLCOLL_DOC_TITEL: // Document Title
929 SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
930 SetAllScriptItem( aSet, SvxFontHeightItem( PT_18, 100, RES_CHRATR_FONTSIZE ) );
932 aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ) );
934 pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
936 break;
938 case RES_POOLCOLL_DOC_SUBTITEL: // Document subtitle
940 SetAllScriptItem( aSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE ));
941 SetAllScriptItem( aSet, SvxFontHeightItem( PT_14, 100, RES_CHRATR_FONTSIZE ));
943 aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ));
945 pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool(
946 RES_POOLCOLL_TEXT ));
948 break;
950 case RES_POOLCOLL_HTML_BLOCKQUOTE:
952 SvxLRSpaceItem aLR( RES_LR_SPACE );
953 aLR.SetLeft( GetMetricVal( CM_1 ));
954 aLR.SetRight( GetMetricVal( CM_1 ));
955 aSet.Put( aLR );
956 SvxULSpaceItem aUL( RES_UL_SPACE );
957 aUL = pNewColl->GetULSpace();
958 aUL.SetLower( HTML_PARSPACE );
959 aSet.Put( aUL);
961 break;
963 case RES_POOLCOLL_HTML_PRE:
965 ::lcl_SetDfltFont( DEFAULTFONT_FIXED, aSet );
967 // WORKAROUND: Set PRE to 10pt
968 SetAllScriptItem( aSet, SvxFontHeightItem(PT_10, 100, RES_CHRATR_FONTSIZE) );
970 // The lower paragraph distance is set explicitly (makes
971 // assigning hard attributes easier)
972 SvxULSpaceItem aULSpaceItem( RES_UL_SPACE );
973 aULSpaceItem = pNewColl->GetULSpace();
974 aULSpaceItem.SetLower( 0 );
975 aSet.Put( aULSpaceItem );
977 break;
979 case RES_POOLCOLL_HTML_HR:
981 SvxBoxItem aBox( RES_BOX );
982 Color aColor( COL_GRAY );
983 SvxBorderLine aNew(&aColor, 1, table::BorderLineStyle::DOUBLE);
984 aBox.SetLine( &aNew, BOX_LINE_BOTTOM );
986 aSet.Put( aBox );
987 aSet.Put( SwParaConnectBorderItem( sal_False ) );
988 SetAllScriptItem( aSet, SvxFontHeightItem(120, 100, RES_CHRATR_FONTSIZE) );
990 SvxULSpaceItem aUL( RES_UL_SPACE );
992 pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool(
993 RES_POOLCOLL_TEXT ));
994 aUL = pNewColl->GetULSpace();
996 aUL.SetLower( HTML_PARSPACE );
997 aSet.Put( aUL);
998 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
999 aSet.Put( aLN );
1001 break;
1003 case RES_POOLCOLL_HTML_DD:
1005 SvxLRSpaceItem aLR( RES_LR_SPACE );
1006 aLR = pNewColl->GetLRSpace();
1007 // We indent by 1 cm. The IDs are always 2 away from each other!
1008 aLR.SetLeft( GetMetricVal( CM_1 ));
1009 aSet.Put( aLR );
1011 break;
1012 case RES_POOLCOLL_HTML_DT:
1014 SvxLRSpaceItem aLR( RES_LR_SPACE );
1016 pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool(
1017 RES_POOLCOLL_HTML_DD ));
1018 aLR = pNewColl->GetLRSpace();
1020 // We indent by 0 cm. The IDs are always 2 away from each other!
1021 aLR.SetLeft( 0 );
1022 aSet.Put( aLR );
1024 break;
1028 if( aSet.Count() )
1031 pNewColl->SetFmtAttr( aSet );
1034 return pNewColl;
1037 /// Check if this AutoCollection is already/still in use in this Document
1038 bool SwDoc::IsPoolTxtCollUsed( sal_uInt16 nId ) const
1040 OSL_ENSURE(
1041 (RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END) ||
1042 (RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END) ||
1043 (RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END) ||
1044 (RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END) ||
1045 (RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END) ||
1046 (RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END),
1047 "Wrong AutoFormat Id" );
1049 SwTxtFmtColl* pNewColl = 0;
1050 bool bFnd = false;
1051 for( sal_uInt16 n = 0; !bFnd && n < mpTxtFmtCollTbl->size(); ++n )
1053 pNewColl = (*mpTxtFmtCollTbl)[ n ];
1054 if( nId == pNewColl->GetPoolFmtId() )
1055 bFnd = true;
1058 if( !bFnd || !pNewColl->GetDepends() )
1059 return false;
1061 SwAutoFmtGetDocNode aGetHt( &GetNodes() );
1062 return !pNewColl->GetInfo( aGetHt );
1065 /// Return the AutomaticFormat with the supplied Id. If it doesn't
1066 /// exist, create it.
1067 SwFmt* SwDoc::GetFmtFromPool( sal_uInt16 nId )
1069 SwFmt *pNewFmt = 0;
1070 SwFmt *pDeriveFmt = 0;
1072 SwFmtsBase* pArray[ 2 ];
1073 sal_uInt16 nArrCnt = 1, nRCId = 0;
1074 sal_uInt16* pWhichRange = 0;
1076 switch( nId & (COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID) )
1078 case POOLGRP_CHARFMT:
1080 pArray[0] = mpCharFmtTbl;
1081 pDeriveFmt = mpDfltCharFmt;
1083 if( nId > RES_POOLCHR_NORMAL_END )
1084 nRCId = RC_POOLCHRFMT_HTML_BEGIN - RES_POOLCHR_HTML_BEGIN;
1085 else
1086 nRCId = RC_POOLCHRFMT_BEGIN - RES_POOLCHR_BEGIN;
1087 pWhichRange = aCharFmtSetRange;
1089 // Fault: unknown Format, but a CharFormat
1090 // -> return the first one
1091 if( RES_POOLCHR_BEGIN > nId || nId >= RES_POOLCHR_END )
1093 OSL_ENSURE( !this, "invalid Id" );
1094 nId = RES_POOLCHR_BEGIN;
1097 break;
1098 case POOLGRP_FRAMEFMT:
1100 pArray[0] = mpFrmFmtTbl;
1101 pArray[1] = mpSpzFrmFmtTbl;
1102 pDeriveFmt = mpDfltFrmFmt;
1103 nArrCnt = 2;
1104 nRCId = RC_POOLFRMFMT_BEGIN - RES_POOLFRM_BEGIN;
1105 pWhichRange = aFrmFmtSetRange;
1107 // Fault: unknown Format, but a FrameFormat
1108 // -> return the first one
1109 if( RES_POOLFRM_BEGIN > nId || nId >= RES_POOLFRM_END )
1111 OSL_ENSURE( !this, "invalid Id" );
1112 nId = RES_POOLFRM_BEGIN;
1115 break;
1117 default:
1118 // Fault, unknown Format
1119 OSL_ENSURE( nId, "invalid Id" );
1120 return 0;
1122 OSL_ENSURE( nRCId, "invalid Id" );
1124 while( nArrCnt-- )
1125 for( sal_uInt16 n = 0; n < (*pArray[nArrCnt]).GetFmtCount(); ++n )
1126 if( nId == ( pNewFmt = (*pArray[ nArrCnt ] ).GetFmt( n ) )->
1127 GetPoolFmtId() )
1129 return pNewFmt;
1132 ResId aResId( nRCId + nId, *pSwResMgr );
1133 String aNm( aResId );
1134 SwAttrSet aSet( GetAttrPool(), pWhichRange );
1137 bool bIsModified = IsModified();
1140 ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
1141 switch (nId & (COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID) )
1143 case POOLGRP_CHARFMT:
1144 pNewFmt = _MakeCharFmt(aNm, pDeriveFmt, false, true);
1145 break;
1146 case POOLGRP_FRAMEFMT:
1147 pNewFmt = _MakeFrmFmt(aNm, pDeriveFmt, false, true);
1148 break;
1149 default:
1150 break;
1154 if( !bIsModified )
1155 ResetModified();
1156 pNewFmt->SetPoolFmtId( nId );
1157 pNewFmt->SetAuto( false ); // no AutoFormat
1160 switch( nId )
1162 case RES_POOLCHR_FOOTNOTE: // Footnote
1163 case RES_POOLCHR_PAGENO: // Page/Field
1164 case RES_POOLCHR_LABEL: // Label
1165 case RES_POOLCHR_DROPCAPS: // Dropcaps
1166 case RES_POOLCHR_NUM_LEVEL: // Numbering level
1167 case RES_POOLCHR_TOXJUMP: // Table of contents jump
1168 case RES_POOLCHR_ENDNOTE: // Endnote
1169 case RES_POOLCHR_LINENUM: // Line numbering
1170 break;
1172 case RES_POOLCHR_ENDNOTE_ANCHOR: // Endnote anchor
1173 case RES_POOLCHR_FOOTNOTE_ANCHOR: // Footnote anchor
1175 aSet.Put( SvxEscapementItem( DFLT_ESC_AUTO_SUPER, 58, RES_CHRATR_ESCAPEMENT ) );
1177 break;
1180 case RES_POOLCHR_BUL_LEVEL: // Bullet character
1182 const Font& rBulletFont = numfunc::GetDefBulletFont();
1183 SetAllScriptItem( aSet, SvxFontItem( rBulletFont.GetFamily(),
1184 rBulletFont.GetName(), rBulletFont.GetStyleName(),
1185 rBulletFont.GetPitch(), rBulletFont.GetCharSet(), RES_CHRATR_FONT ));
1187 break;
1189 case RES_POOLCHR_INET_NORMAL:
1191 Color aCol( COL_BLUE );
1192 aSet.Put( SvxColorItem( aCol, RES_CHRATR_COLOR ) );
1193 aSet.Put( SvxUnderlineItem( UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE ) );
1194 // i40133: patch submitted by rail: set language to 'none' to prevent spell checking:
1195 aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_LANGUAGE ) );
1196 aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_CJK_LANGUAGE ) );
1197 aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_CTL_LANGUAGE ) );
1199 break;
1200 case RES_POOLCHR_INET_VISIT:
1202 Color aCol( COL_RED );
1203 aSet.Put( SvxColorItem( aCol, RES_CHRATR_COLOR ) );
1204 aSet.Put( SvxUnderlineItem( UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE ) );
1205 aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_LANGUAGE ) );
1206 aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_CJK_LANGUAGE ) );
1207 aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_CTL_LANGUAGE ) );
1209 break;
1210 case RES_POOLCHR_JUMPEDIT:
1212 Color aCol( COL_CYAN );
1213 aSet.Put( SvxColorItem( aCol, RES_CHRATR_COLOR ) );
1214 aSet.Put( SvxUnderlineItem( UNDERLINE_DOTTED, RES_CHRATR_UNDERLINE ) );
1215 aSet.Put( SvxCaseMapItem( SVX_CASEMAP_KAPITAELCHEN, RES_CHRATR_CASEMAP ) );
1217 break;
1219 case RES_POOLCHR_RUBYTEXT:
1221 long nH = ((SvxFontHeightItem*)GetDfltAttr(
1222 RES_CHRATR_CJK_FONTSIZE ))->GetHeight() / 2;
1223 SetAllScriptItem( aSet, SvxFontHeightItem( nH, 100, RES_CHRATR_FONTSIZE));
1224 aSet.Put(SvxUnderlineItem( UNDERLINE_NONE, RES_CHRATR_UNDERLINE ));
1225 aSet.Put(SvxEmphasisMarkItem( EMPHASISMARK_NONE, RES_CHRATR_EMPHASIS_MARK) );
1227 break;
1229 case RES_POOLCHR_HTML_EMPHASIS:
1230 case RES_POOLCHR_HTML_CITIATION:
1231 case RES_POOLCHR_HTML_VARIABLE:
1233 SetAllScriptItem( aSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE) );
1235 break;
1237 case RES_POOLCHR_IDX_MAIN_ENTRY:
1238 case RES_POOLCHR_HTML_STRONG:
1240 SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ));
1242 break;
1244 case RES_POOLCHR_HTML_CODE:
1245 case RES_POOLCHR_HTML_SAMPLE:
1246 case RES_POOLCHR_HTML_KEYBOARD:
1247 case RES_POOLCHR_HTML_TELETYPE:
1249 ::lcl_SetDfltFont( DEFAULTFONT_FIXED, aSet );
1251 break;
1252 case RES_POOLCHR_VERT_NUM:
1253 aSet.Put( SvxCharRotateItem( 900, sal_False, RES_CHRATR_ROTATE ) );
1254 break;
1256 case RES_POOLFRM_FRAME:
1258 if ( get(IDocumentSettingAccess::HTML_MODE) )
1260 aSet.Put( SwFmtAnchor( FLY_AS_CHAR ));
1261 aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::LINE_CENTER, text::RelOrientation::PRINT_AREA ) );
1262 aSet.Put( SwFmtSurround( SURROUND_NONE ) );
1264 else
1266 aSet.Put( SwFmtAnchor( FLY_AT_PARA ));
1267 aSet.Put( SwFmtSurround( SURROUND_PARALLEL ) );
1268 aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::PRINT_AREA ) );
1269 aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
1270 Color aCol( COL_BLACK );
1271 SvxBorderLine aLine( &aCol, DEF_LINE_WIDTH_0 );
1272 SvxBoxItem aBox( RES_BOX );
1273 aBox.SetLine( &aLine, BOX_LINE_TOP );
1274 aBox.SetLine( &aLine, BOX_LINE_BOTTOM );
1275 aBox.SetLine( &aLine, BOX_LINE_LEFT );
1276 aBox.SetLine( &aLine, BOX_LINE_RIGHT );
1277 aBox.SetDistance( 85 );
1278 aSet.Put( aBox );
1279 aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) );
1280 aSet.Put( SvxULSpaceItem( 114, 114, RES_UL_SPACE ) );
1283 break;
1284 case RES_POOLFRM_GRAPHIC:
1285 case RES_POOLFRM_OLE:
1287 aSet.Put( SwFmtAnchor( FLY_AT_PARA ));
1288 aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ));
1289 aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
1290 aSet.Put( SwFmtSurround( SURROUND_IDEAL ));
1292 break;
1293 case RES_POOLFRM_FORMEL:
1295 aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) );
1296 aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) );
1297 aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) );
1299 break;
1300 case RES_POOLFRM_MARGINAL:
1302 aSet.Put( SwFmtAnchor( FLY_AT_PARA ));
1303 aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME ));
1304 aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
1305 aSet.Put( SwFmtSurround( SURROUND_PARALLEL ));
1306 // Set the default width to 3.5 cm, use the minimum value for the height
1307 aSet.Put( SwFmtFrmSize( ATT_MIN_SIZE,
1308 GetMetricVal( CM_1 ) * 3 + GetMetricVal( CM_05 ),
1309 MM50 ));
1311 break;
1312 case RES_POOLFRM_WATERSIGN:
1314 aSet.Put( SwFmtAnchor( FLY_AT_PAGE ));
1315 aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ));
1316 aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ));
1317 aSet.Put( SvxOpaqueItem( sal_False ));
1318 aSet.Put( SwFmtSurround( SURROUND_THROUGHT ));
1320 break;
1322 case RES_POOLFRM_LABEL:
1324 aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) );
1325 aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ) );
1326 aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) );
1328 SvxProtectItem aProtect( RES_PROTECT );
1329 aProtect.SetSizeProtect( sal_True );
1330 aProtect.SetPosProtect( sal_True );
1331 aSet.Put( aProtect );
1333 pNewFmt->SetAutoUpdateFmt( sal_True );
1335 break;
1337 if( aSet.Count() )
1340 pNewFmt->SetFmtAttr( aSet );
1343 return pNewFmt;
1346 SwFrmFmt* SwDoc::GetFrmFmtFromPool( sal_uInt16 nId )
1348 return (SwFrmFmt*)GetFmtFromPool( nId );
1351 SwCharFmt* SwDoc::GetCharFmtFromPool( sal_uInt16 nId )
1353 return (SwCharFmt*)GetFmtFromPool( nId );
1356 /// Check if this AutoCollection is already/still in use
1357 bool SwDoc::IsPoolFmtUsed( sal_uInt16 nId ) const
1359 SwFmt *pNewFmt = 0;
1360 const SwFmtsBase* pArray[ 2 ];
1361 sal_uInt16 nArrCnt = 1;
1362 bool bFnd = true;
1364 if (RES_POOLCHR_BEGIN <= nId && nId < RES_POOLCHR_END)
1366 pArray[0] = mpCharFmtTbl;
1368 else if (RES_POOLFRM_BEGIN <= nId && nId < RES_POOLFRM_END)
1370 pArray[0] = mpFrmFmtTbl;
1371 pArray[1] = mpSpzFrmFmtTbl;
1372 nArrCnt = 2;
1374 else
1376 SAL_WARN("sw.core", "Invalid Pool Id: " << nId << " should be within " <<
1377 "[" << int(RES_POOLCHR_BEGIN) << "," << int(RES_POOLCHR_END) << ") or " <<
1378 "[" << int(RES_POOLFRM_BEGIN) << "," << int(RES_POOLFRM_END) << ")");
1379 bFnd = false;
1382 if( bFnd )
1384 bFnd = false;
1385 while( nArrCnt-- && !bFnd )
1386 for( sal_uInt16 n = 0; !bFnd && n < (*pArray[nArrCnt]).GetFmtCount(); ++n )
1387 if( nId == ( pNewFmt = (*pArray[ nArrCnt ] ).GetFmt( n ) )->
1388 GetPoolFmtId() )
1389 bFnd = true;
1392 // Not found or no dependecies?
1393 if( bFnd && pNewFmt->GetDepends() )
1395 // Check if we have dependent ContentNodes in the Nodes array
1396 // (also indirect ones for derived Formats)
1397 SwAutoFmtGetDocNode aGetHt( &GetNodes() );
1398 bFnd = !pNewFmt->GetInfo( aGetHt );
1400 else
1401 bFnd = false;
1403 return bFnd;
1408 static void lcl_GetStdPgSize( SwDoc* pDoc, SfxItemSet& rSet )
1410 SwPageDesc* pStdPgDsc = pDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
1411 SwFmtFrmSize aFrmSz( pStdPgDsc->GetMaster().GetFrmSize() );
1412 if( pStdPgDsc->GetLandscape() )
1414 SwTwips nTmp = aFrmSz.GetHeight();
1415 aFrmSz.SetHeight( aFrmSz.GetWidth() );
1416 aFrmSz.SetWidth( nTmp );
1418 rSet.Put( aFrmSz );
1421 SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
1423 OSL_ENSURE( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END,
1424 "Wrong AutoFormat Id" );
1426 SwPageDesc *pNewPgDsc;
1427 sal_uInt16 n;
1429 for( n = 0; n < maPageDescs.size(); ++n )
1430 if( nId == ( pNewPgDsc = maPageDescs[ n ] )->GetPoolFmtId() )
1432 return pNewPgDsc;
1435 // error: unknown Pool style
1436 if( RES_POOLPAGE_BEGIN > nId || nId >= RES_POOLPAGE_END )
1438 OSL_ENSURE( !this, "invalid Id" );
1439 nId = RES_POOLPAGE_BEGIN;
1442 ResId aResId( sal_uInt32(RC_POOLPAGEDESC_BEGIN + nId - RES_POOLPAGE_BEGIN), *pSwResMgr );
1443 String aNm( aResId );
1445 bool bIsModified = IsModified();
1448 ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
1449 n = MakePageDesc( aNm, 0, bRegardLanguage );
1452 pNewPgDsc = maPageDescs[ n ];
1453 pNewPgDsc->SetPoolFmtId( nId );
1454 if( !bIsModified )
1455 ResetModified();
1459 SvxLRSpaceItem aLR( RES_LR_SPACE );
1460 aLR.SetLeft( GetMetricVal( CM_1 ) * 2 );
1461 aLR.SetRight( aLR.GetLeft() );
1462 SvxULSpaceItem aUL( RES_UL_SPACE );
1463 aUL.SetUpper( (sal_uInt16)aLR.GetLeft() );
1464 aUL.SetLower( (sal_uInt16)aLR.GetLeft() );
1466 SwAttrSet aSet( GetAttrPool(), aPgFrmFmtSetRange );
1467 bool bSetLeft = true;
1469 switch( nId )
1471 case RES_POOLPAGE_STANDARD: // Standard page
1473 aSet.Put( aLR );
1474 aSet.Put( aUL );
1475 if( pNewPgDsc )
1476 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL | nsUseOnPage::PD_FIRSTSHARE );
1478 break;
1480 case RES_POOLPAGE_FIRST: // First page
1481 case RES_POOLPAGE_REGISTER: // ToX
1483 lcl_GetStdPgSize( this, aSet );
1484 aSet.Put( aLR );
1485 aSet.Put( aUL );
1486 if( pNewPgDsc )
1488 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
1489 if( RES_POOLPAGE_FIRST == nId )
1490 pNewPgDsc->SetFollow( GetPageDescFromPool( RES_POOLPAGE_STANDARD ));
1493 break;
1495 case RES_POOLPAGE_LEFT: // Left page
1497 lcl_GetStdPgSize( this, aSet );
1498 aSet.Put( aLR );
1499 aSet.Put( aUL );
1500 bSetLeft = false;
1501 if( pNewPgDsc )
1503 pNewPgDsc->SetUseOn( nsUseOnPage::PD_LEFT );
1504 // this relies on GetPageDescFromPool() not going into infinite recursion
1505 // (by this point RES_POOLPAGE_LEFT will not reach this place again)
1506 pNewPgDsc->SetFollow( GetPageDescFromPool( RES_POOLPAGE_RIGHT ));
1509 break;
1510 case RES_POOLPAGE_RIGHT: // Right page
1512 lcl_GetStdPgSize( this, aSet );
1513 aSet.Put( aLR );
1514 aSet.Put( aUL );
1515 bSetLeft = false;
1516 if( pNewPgDsc )
1518 pNewPgDsc->SetUseOn( nsUseOnPage::PD_RIGHT );
1519 pNewPgDsc->SetFollow( GetPageDescFromPool( RES_POOLPAGE_LEFT ));
1522 break;
1524 case RES_POOLPAGE_JAKET: // envelope
1526 aLR.SetLeft( 0 ); aLR.SetRight( 0 );
1527 aUL.SetUpper( 0 ); aUL.SetLower( 0 );
1528 Size aPSize( SvxPaperInfo::GetPaperSize( PAPER_ENV_C65 ) );
1529 LandscapeSwap( aPSize );
1530 aSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, aPSize.Width(), aPSize.Height() ));
1531 aSet.Put( aLR );
1532 aSet.Put( aUL );
1534 if( pNewPgDsc )
1536 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
1537 pNewPgDsc->SetLandscape( sal_True );
1540 break;
1542 case RES_POOLPAGE_HTML: // HTML
1544 lcl_GetStdPgSize( this, aSet );
1545 aLR.SetRight( GetMetricVal( CM_1 ));
1546 aUL.SetUpper( (sal_uInt16)aLR.GetRight() );
1547 aUL.SetLower( (sal_uInt16)aLR.GetRight() );
1548 aSet.Put( aLR );
1549 aSet.Put( aUL );
1551 if( pNewPgDsc )
1552 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
1554 break;
1555 case RES_POOLPAGE_FOOTNOTE:
1556 case RES_POOLPAGE_ENDNOTE:
1558 lcl_GetStdPgSize( this, aSet );
1559 aSet.Put( aLR );
1560 aSet.Put( aUL );
1561 if( pNewPgDsc )
1562 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
1563 SwPageFtnInfo aInf( pNewPgDsc->GetFtnInfo() );
1564 aInf.SetLineWidth( 0 );
1565 aInf.SetTopDist( 0 );
1566 aInf.SetBottomDist( 0 );
1567 pNewPgDsc->SetFtnInfo( aInf );
1569 break;
1570 case RES_POOLPAGE_LANDSCAPE:
1572 SwPageDesc* pStdPgDsc = this->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
1573 SwFmtFrmSize aFrmSz( pStdPgDsc->GetMaster().GetFrmSize() );
1574 SwTwips nTmp = aFrmSz.GetHeight();
1575 aFrmSz.SetHeight( aFrmSz.GetWidth() );
1576 aFrmSz.SetWidth( nTmp );
1577 aSet.Put( aFrmSz );
1578 aSet.Put( aLR );
1579 aSet.Put( aUL );
1580 if( pNewPgDsc )
1582 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
1583 pNewPgDsc->SetLandscape( sal_True );
1586 break;
1590 if( aSet.Count() )
1593 if( bSetLeft )
1595 pNewPgDsc->GetLeft().SetFmtAttr( aSet );
1596 pNewPgDsc->GetFirstLeft().SetFmtAttr( aSet );
1598 pNewPgDsc->GetMaster().SetFmtAttr( aSet );
1599 pNewPgDsc->GetFirstMaster().SetFmtAttr( aSet );
1602 return pNewPgDsc;
1605 SwNumRule* SwDoc::GetNumRuleFromPool( sal_uInt16 nId )
1607 OSL_ENSURE( RES_POOLNUMRULE_BEGIN <= nId && nId < RES_POOLNUMRULE_END,
1608 "Wrong AutoFormat Id" );
1610 SwNumRule* pNewRule;
1611 sal_uInt16 n;
1613 for( n = 0; n < GetNumRuleTbl().size(); ++n )
1614 if( nId == ( pNewRule = GetNumRuleTbl()[ n ] )->GetPoolFmtId() )
1616 return pNewRule;
1619 // error: unknown Pool style
1620 if( RES_POOLNUMRULE_BEGIN > nId || nId >= RES_POOLNUMRULE_END )
1622 OSL_ENSURE( !this, "invalid Id" );
1623 nId = RES_POOLNUMRULE_BEGIN;
1626 ResId aResId( sal_uInt32(RC_POOLNUMRULE_BEGIN + nId - RES_POOLNUMRULE_BEGIN), *pSwResMgr );
1627 String aNm( aResId );
1629 SwCharFmt *pNumCFmt = 0, *pBullCFmt = 0;
1631 const SvxNumberFormat::SvxNumPositionAndSpaceMode eNumberFormatPositionAndSpaceMode
1632 = numfunc::GetDefaultPositionAndSpaceMode(); //#i89178#
1634 bool bIsModified = IsModified();
1636 n = MakeNumRule( aNm, 0, false, eNumberFormatPositionAndSpaceMode );
1638 pNewRule = GetNumRuleTbl()[ n ];
1639 pNewRule->SetPoolFmtId( nId );
1640 pNewRule->SetAutoRule( sal_False );
1642 if( RES_POOLNUMRULE_NUM1 <= nId && nId <= RES_POOLNUMRULE_NUM5 )
1643 pNumCFmt = GetCharFmtFromPool( RES_POOLCHR_NUM_LEVEL );
1645 if( ( RES_POOLNUMRULE_BUL1 <= nId && nId <= RES_POOLNUMRULE_BUL5 ) ||
1646 RES_POOLNUMRULE_NUM5 == nId )
1647 pBullCFmt = GetCharFmtFromPool( RES_POOLCHR_NUM_LEVEL );
1649 if( !bIsModified )
1650 ResetModified();
1653 switch( nId )
1655 case RES_POOLNUMRULE_NUM1:
1657 SwNumFmt aFmt;
1658 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
1659 aFmt.SetNumberingType(SVX_NUM_ARABIC);
1660 aFmt.SetCharFmt( pNumCFmt );
1661 aFmt.SetStart( 1 );
1662 aFmt.SetIncludeUpperLevels( 1 );
1663 aFmt.SetSuffix( aDotStr );
1665 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
1667 // cm: 0,5 1,0 1,5 2,0 2,5 3,0 3,5 4,0 4,5 5,0
1668 283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835
1670 #ifdef USE_MEASUREMENT
1671 static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
1673 283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835
1675 const sal_uInt16* pArr = MEASURE_METRIC ==
1676 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
1677 ? aAbsSpace
1678 : aAbsSpaceInch;
1679 #else
1680 const sal_uInt16* pArr = aAbsSpace;
1681 #endif
1683 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1685 aFmt.SetFirstLineOffset( - (*pArr) );
1687 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1689 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
1690 aFmt.SetFirstLineIndent( - (*pArr) );
1693 for( n = 0; n < MAXLEVEL; ++n, ++pArr )
1695 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1697 aFmt.SetAbsLSpace( *pArr );
1699 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1701 aFmt.SetListtabPos( *pArr );
1702 aFmt.SetIndentAt( *pArr );
1705 pNewRule->Set( n, aFmt );
1708 break;
1710 case RES_POOLNUMRULE_NUM2:
1712 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
1714 283, 283, 567, 709, // 0.50, 0.50, 1.00, 1.25
1715 850, 1021, 1304, 1474, // 1.50, 1.80, 2.30, 2.60
1716 1588, 1758 // 2.80, 3.10
1719 #ifdef USE_MEASUREMENT
1720 static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
1722 385, 385, 770, 963,
1723 1155, 1386, 1771, 2002,
1724 2156, 2387
1727 const sal_uInt16* pArr = MEASURE_METRIC ==
1728 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
1729 ? aAbsSpace
1730 : aAbsSpaceInch;
1731 #else
1732 const sal_uInt16* pArr = aAbsSpace;
1733 #endif
1734 SwNumFmt aFmt;
1736 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
1737 aFmt.SetNumberingType(SVX_NUM_ARABIC);
1738 aFmt.SetCharFmt( pNumCFmt );
1739 aFmt.SetIncludeUpperLevels( 1 );
1741 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1743 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
1746 sal_uInt16 nSpace = 0;
1747 for( n = 0; n < MAXLEVEL; ++n )
1749 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1751 aFmt.SetAbsLSpace( nSpace = nSpace + pArr[ n ] );
1752 aFmt.SetFirstLineOffset( - pArr[ n ] );
1754 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1756 aFmt.SetListtabPos( nSpace = nSpace + pArr[ n ] );
1757 aFmt.SetIndentAt( nSpace );
1758 aFmt.SetFirstLineIndent( - pArr[ n ] );
1761 aFmt.SetStart( n+1 );
1762 pNewRule->Set( n, aFmt );
1765 break;
1766 case RES_POOLNUMRULE_NUM3:
1768 SwNumFmt aFmt;
1770 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
1771 aFmt.SetNumberingType(SVX_NUM_ARABIC);
1772 aFmt.SetCharFmt( pNumCFmt );
1773 aFmt.SetIncludeUpperLevels( 1 );
1775 sal_uInt16 nOffs = GetMetricVal( CM_1 ) * 3;
1777 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1779 aFmt.SetFirstLineOffset( - nOffs );
1781 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1783 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
1784 aFmt.SetFirstLineIndent( - nOffs );
1787 for( n = 0; n < MAXLEVEL; ++n )
1789 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1791 aFmt.SetAbsLSpace( (n+1) * nOffs );
1793 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1795 aFmt.SetListtabPos( (n+1) * nOffs );
1796 aFmt.SetIndentAt( (n+1) * nOffs );
1799 aFmt.SetStart( n+1 );
1800 pNewRule->Set( n, aFmt );
1803 break;
1804 case RES_POOLNUMRULE_NUM4:
1806 SwNumFmt aFmt;
1808 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
1809 aFmt.SetNumberingType(SVX_NUM_ROMAN_UPPER);
1810 aFmt.SetCharFmt( pNumCFmt );
1811 aFmt.SetIncludeUpperLevels( 1 );
1812 aFmt.SetSuffix( aDotStr );
1814 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
1816 // cm: 0,5 1,0 1,5 2,0 2,5 3,0 3,5 4,0 4,5 5,0
1817 283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835
1819 #ifdef USE_MEASUREMENT
1820 static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
1822 283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835
1824 const sal_uInt16* pArr = MEASURE_METRIC ==
1825 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
1826 ? aAbsSpace
1827 : aAbsSpaceInch;
1828 #else
1829 const sal_uInt16* pArr = aAbsSpace;
1830 #endif
1832 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1834 aFmt.SetFirstLineOffset( - (*pArr) );
1836 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1838 aFmt.SetLabelFollowedBy( SvxNumberFormat::SPACE );
1839 aFmt.SetFirstLineIndent( - (*pArr) );
1842 for( n = 0; n < MAXLEVEL; ++n, ++pArr )
1844 aFmt.SetStart( n + 1 );
1846 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1848 aFmt.SetAbsLSpace( *pArr );
1850 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1852 aFmt.SetListtabPos( *pArr );
1853 aFmt.SetIndentAt( *pArr );
1856 pNewRule->Set( n, aFmt );
1859 break;
1860 case RES_POOLNUMRULE_NUM5:
1862 // [ First, LSpace ]
1863 static const sal_uInt16 aAbsSpace0to2[] =
1865 227, 227, // 0.40, 0.40,
1866 369, 624, // 0.65, 1.10,
1867 255, 879 // 0.45, 1.55
1870 #ifdef USE_MEASUREMENT
1871 static const sal_uInt16 aAbsSpaceInch0to2[] =
1873 308, 308,
1874 501, 847,
1875 347, 1194
1877 const sal_uInt16* pArr0to2 = MEASURE_METRIC ==
1878 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
1879 ? aAbsSpace0to2
1880 : aAbsSpaceInch0to2;
1881 #else
1882 const sal_uInt16* pArr0to2 = aAbsSpace0to2;
1883 #endif
1884 SwNumFmt aFmt;
1886 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
1887 aFmt.SetNumberingType(SVX_NUM_ARABIC);
1888 aFmt.SetStart( 1 );
1889 aFmt.SetIncludeUpperLevels( 1 );
1890 aFmt.SetSuffix( aDotStr );
1892 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1894 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
1897 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1899 aFmt.SetFirstLineOffset( -pArr0to2[0] ); // == 0.40 cm
1900 aFmt.SetAbsLSpace( pArr0to2[1] ); // == 0.40 cm
1902 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1904 aFmt.SetFirstLineIndent( -pArr0to2[0] );
1905 aFmt.SetListtabPos( pArr0to2[1] );
1906 aFmt.SetIndentAt( pArr0to2[1] );
1909 aFmt.SetCharFmt( pNumCFmt );
1910 pNewRule->Set( 0, aFmt );
1912 aFmt.SetIncludeUpperLevels( 2 );
1913 aFmt.SetStart( 2 );
1915 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1917 aFmt.SetFirstLineOffset( -pArr0to2[2] ); // == 0.65 cm
1918 aFmt.SetAbsLSpace( pArr0to2[3] ); // == 1.10 cm
1920 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1922 aFmt.SetFirstLineIndent( -pArr0to2[2] );
1923 aFmt.SetListtabPos( pArr0to2[3] );
1924 aFmt.SetIndentAt( pArr0to2[3] );
1927 pNewRule->Set( 1, aFmt );
1929 aFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER);
1930 aFmt.SetSuffix(OUString(static_cast<sal_Unicode>(')')));
1931 aFmt.SetIncludeUpperLevels( 1 );
1932 aFmt.SetStart( 3 );
1934 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1936 aFmt.SetFirstLineOffset( - pArr0to2[4] ); // == 0.45cm
1937 aFmt.SetAbsLSpace( pArr0to2[5] ); // == 1.55 cm
1939 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1941 aFmt.SetFirstLineIndent( -pArr0to2[4] );
1942 aFmt.SetListtabPos( pArr0to2[5] );
1943 aFmt.SetIndentAt( pArr0to2[5] );
1946 pNewRule->Set( 2, aFmt );
1949 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1950 aFmt.SetCharFmt( pBullCFmt );
1951 aFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
1952 aFmt.SetBulletChar( cBulletChar );
1953 sal_uInt16 nOffs = GetMetricVal( CM_01 ) * 4,
1954 nOffs2 = GetMetricVal( CM_1 ) * 2;
1956 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1958 aFmt.SetFirstLineOffset( - nOffs );
1960 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1962 aFmt.SetFirstLineIndent( - nOffs );
1965 aFmt.SetSuffix( aEmptyStr );
1966 for( n = 3; n < MAXLEVEL; ++n )
1968 aFmt.SetStart( n+1 );
1970 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1972 aFmt.SetAbsLSpace( nOffs2 + ((n-3) * nOffs) );
1974 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1976 aFmt.SetListtabPos( nOffs2 + ((n-3) * nOffs) );
1977 aFmt.SetIndentAt( nOffs2 + ((n-3) * nOffs) );
1980 pNewRule->Set( n, aFmt );
1983 break;
1985 case RES_POOLNUMRULE_BUL1:
1987 SwNumFmt aFmt;
1989 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
1990 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1991 aFmt.SetCharFmt( pBullCFmt );
1992 aFmt.SetStart( 1 );
1993 aFmt.SetIncludeUpperLevels( 1 );
1994 aFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
1995 aFmt.SetBulletChar( cBulletChar );
1997 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
1999 // cm: 0,4 0,8 1,2 1,6 2,0 2,4 2,8 3,2 3,6 4,0
2000 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
2002 #ifdef USE_MEASUREMENT
2003 static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
2005 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
2007 const sal_uInt16* pArr = MEASURE_METRIC ==
2008 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
2009 ? aAbsSpace
2010 : aAbsSpaceInch;
2011 #else
2012 const sal_uInt16* pArr = aAbsSpace;
2013 #endif
2015 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2017 aFmt.SetFirstLineOffset( - (*pArr) );
2019 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2021 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2022 aFmt.SetFirstLineIndent( - (*pArr) );
2025 for( n = 0; n < MAXLEVEL; ++n, ++pArr )
2027 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2029 aFmt.SetAbsLSpace( *pArr );
2031 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2033 aFmt.SetListtabPos( *pArr );
2034 aFmt.SetIndentAt( *pArr );
2037 pNewRule->Set( n, aFmt );
2040 break;
2041 case RES_POOLNUMRULE_BUL2:
2043 SwNumFmt aFmt;
2045 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2046 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2047 aFmt.SetCharFmt( pBullCFmt );
2048 aFmt.SetStart( 1 );
2049 aFmt.SetIncludeUpperLevels( 1 );
2050 aFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
2051 aFmt.SetBulletChar( 0x2013 );
2053 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2055 // cm: 0,3 0,6 0,9 1,2 1,5 1,8 2,1 2,4 2,7 3,0
2056 170, 340, 510, 680, 850, 1020, 1191, 1361, 1531, 1701
2058 #ifdef USE_MEASUREMENT
2059 static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
2061 170, 340, 510, 680, 850, 1020, 1191, 1361, 1531, 1701
2063 const sal_uInt16* pArr = MEASURE_METRIC ==
2064 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
2065 ? aAbsSpace
2066 : aAbsSpaceInch;
2067 #else
2068 const sal_uInt16* pArr = aAbsSpace;
2069 #endif
2071 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2073 aFmt.SetFirstLineOffset( - (*pArr) );
2075 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2077 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2078 aFmt.SetFirstLineIndent( - (*pArr) );
2081 for( n = 0; n < MAXLEVEL; ++n, ++pArr )
2083 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2085 aFmt.SetAbsLSpace( *pArr );
2087 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2089 aFmt.SetListtabPos( *pArr );
2090 aFmt.SetIndentAt( *pArr );
2093 pNewRule->Set( n, aFmt );
2096 break;
2097 case RES_POOLNUMRULE_BUL3:
2099 SwNumFmt aFmt;
2101 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2103 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2104 aFmt.SetCharFmt( pBullCFmt );
2105 aFmt.SetStart( 1 );
2106 aFmt.SetIncludeUpperLevels( 1 );
2107 aFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
2109 sal_uInt16 nOffs = GetMetricVal( CM_01 ) * 4;
2111 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2113 aFmt.SetFirstLineOffset( - nOffs );
2115 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2117 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2118 aFmt.SetFirstLineIndent( - nOffs );
2121 for( n = 0; n < MAXLEVEL; ++n )
2123 aFmt.SetBulletChar( ( n & 1 ? 0x25a1 : 0x2611 ) );
2125 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2127 aFmt.SetAbsLSpace( ((n & 1) +1) * nOffs );
2129 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2131 aFmt.SetListtabPos( ((n & 1) +1) * nOffs );
2132 aFmt.SetIndentAt( ((n & 1) +1) * nOffs );
2135 pNewRule->Set( n, aFmt );
2138 break;
2139 case RES_POOLNUMRULE_BUL4:
2141 SwNumFmt aFmt;
2143 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2144 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2145 aFmt.SetCharFmt( pBullCFmt );
2146 aFmt.SetStart( 1 );
2147 aFmt.SetIncludeUpperLevels( 1 );
2148 aFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
2150 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2152 // cm: 0,4 0,8 1,2 1,6 2,0 2,4 2,8 3,2 3,6 4,0
2153 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
2155 #ifdef USE_MEASUREMENT
2156 static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
2158 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
2160 const sal_uInt16* pArr = MEASURE_METRIC ==
2161 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
2162 ? aAbsSpace
2163 : aAbsSpaceInch;
2164 #else
2165 const sal_uInt16* pArr = aAbsSpace;
2166 #endif
2168 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2170 aFmt.SetFirstLineOffset( - (*pArr) );
2172 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2174 aFmt.SetLabelFollowedBy( SvxNumberFormat::SPACE );
2175 aFmt.SetFirstLineIndent( - (*pArr) );
2178 for( n = 0; n < MAXLEVEL; ++n, ++pArr )
2180 switch( n )
2182 case 0: aFmt.SetBulletChar( 0x27a2 ); break;
2183 case 1: aFmt.SetBulletChar( 0xE006 ); break;
2184 default: aFmt.SetBulletChar( 0xE004 ); break;
2187 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2189 aFmt.SetAbsLSpace( *pArr );
2191 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2193 aFmt.SetListtabPos( *pArr );
2194 aFmt.SetIndentAt( *pArr );
2197 pNewRule->Set( n, aFmt );
2200 break;
2201 case RES_POOLNUMRULE_BUL5:
2203 SwNumFmt aFmt;
2205 aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
2206 aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
2207 aFmt.SetCharFmt( pBullCFmt );
2208 aFmt.SetStart( 1 );
2209 aFmt.SetIncludeUpperLevels( 1 );
2210 aFmt.SetBulletChar( 0x2717 );
2211 aFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
2213 static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
2215 // cm: 0,4 0,8 1,2 1,6 2,0 2,4 2,8 3,2 3,6 4,0
2216 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
2218 #ifdef USE_MEASUREMENT
2219 static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
2221 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
2223 const sal_uInt16* pArr = MEASURE_METRIC ==
2224 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
2225 ? aAbsSpace
2226 : aAbsSpaceInch;
2227 #else
2228 const sal_uInt16* pArr = aAbsSpace;
2229 #endif
2231 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2233 aFmt.SetFirstLineOffset( - (*pArr) );
2235 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2237 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
2238 aFmt.SetFirstLineIndent( - (*pArr) );
2241 for( n = 0; n < MAXLEVEL; ++n, ++pArr )
2243 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2245 aFmt.SetAbsLSpace( *pArr );
2247 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2249 aFmt.SetListtabPos( *pArr );
2250 aFmt.SetIndentAt( *pArr );
2253 pNewRule->Set( n, aFmt );
2256 break;
2259 return pNewRule;
2262 /// Check if this AutoCollection is already/still in use in this Document
2263 bool SwDoc::IsPoolPageDescUsed( sal_uInt16 nId ) const
2265 OSL_ENSURE( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END,
2266 "Wrong AutoFormat Id" );
2267 SwPageDesc *pNewPgDsc = 0;
2268 bool bFnd = false;
2269 for( sal_uInt16 n = 0; !bFnd && n < maPageDescs.size(); ++n )
2271 pNewPgDsc = maPageDescs[ n ];
2272 if( nId == pNewPgDsc->GetPoolFmtId() )
2273 bFnd = true;
2276 // Not found or no dependencies?
2277 if( !bFnd || !pNewPgDsc->GetDepends() ) // ??????
2278 return false;
2280 // Check if we have dependent ContentNodes in the Nodes array
2281 // (also indirect ones for derived Formats)
2282 SwAutoFmtGetDocNode aGetHt( &GetNodes() );
2283 return !pNewPgDsc->GetInfo( aGetHt );
2286 // See if the Paragraph/Character/Frame/Page style is in use
2287 bool SwDoc::IsUsed( const SwModify& rModify ) const
2289 // Check if we have dependent ContentNodes in the Nodes array
2290 // (also indirect ones for derived Formats)
2291 SwAutoFmtGetDocNode aGetHt( &GetNodes() );
2292 return !rModify.GetInfo( aGetHt );
2295 // See if the NumRule is used
2296 bool SwDoc::IsUsed( const SwNumRule& rRule ) const
2298 bool bUsed = rRule.GetTxtNodeListSize() > 0 ||
2299 rRule.GetParagraphStyleListSize() > 0;
2301 return bUsed;
2304 // Look for the style name's position. If it doesn't exist,
2305 // insert a anew
2306 sal_uInt16 SwDoc::SetDocPattern( const String& rPatternName )
2308 OSL_ENSURE( rPatternName.Len(), "no Document style name" );
2310 size_t nNewPos = maPatternNms.size();
2311 for(size_t n = 0; n < maPatternNms.size(); ++n)
2312 if( boost::is_null(maPatternNms.begin() + n) )
2314 if( nNewPos == maPatternNms.size() )
2315 nNewPos = n;
2317 else if( rPatternName == maPatternNms[n] )
2318 return n;
2320 if( nNewPos < maPatternNms.size() )
2321 maPatternNms.erase(maPatternNms.begin() + nNewPos); // Free space again
2323 maPatternNms.insert(maPatternNms.begin() + nNewPos, new String(rPatternName));
2324 SetModified();
2325 return nNewPos;
2328 sal_uInt16 GetPoolParent( sal_uInt16 nId )
2330 sal_uInt16 nRet = USHRT_MAX;
2331 if( POOLGRP_NOCOLLID & nId ) // 1 == Formats / 0 == Collections
2333 switch( ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID ) & nId )
2335 case POOLGRP_CHARFMT:
2336 case POOLGRP_FRAMEFMT:
2337 nRet = 0; // derived from the default
2338 break;
2339 case POOLGRP_PAGEDESC:
2340 case POOLGRP_NUMRULE:
2341 break; // there are no derivations
2344 else
2346 switch( COLL_GET_RANGE_BITS & nId )
2348 case COLL_TEXT_BITS:
2349 switch( nId )
2351 case RES_POOLCOLL_STANDARD:
2352 nRet = 0; break;
2353 case RES_POOLCOLL_TEXT_IDENT:
2354 case RES_POOLCOLL_TEXT_NEGIDENT:
2355 case RES_POOLCOLL_TEXT_MOVE:
2356 case RES_POOLCOLL_CONFRONTATION:
2357 case RES_POOLCOLL_MARGINAL:
2358 nRet = RES_POOLCOLL_TEXT; break;
2360 case RES_POOLCOLL_TEXT:
2361 case RES_POOLCOLL_GREETING:
2362 case RES_POOLCOLL_SIGNATURE:
2363 case RES_POOLCOLL_HEADLINE_BASE:
2364 nRet = RES_POOLCOLL_STANDARD; break;
2366 case RES_POOLCOLL_HEADLINE1:
2367 case RES_POOLCOLL_HEADLINE2:
2368 case RES_POOLCOLL_HEADLINE3:
2369 case RES_POOLCOLL_HEADLINE4:
2370 case RES_POOLCOLL_HEADLINE5:
2371 case RES_POOLCOLL_HEADLINE6:
2372 case RES_POOLCOLL_HEADLINE7:
2373 case RES_POOLCOLL_HEADLINE8:
2374 case RES_POOLCOLL_HEADLINE9:
2375 case RES_POOLCOLL_HEADLINE10:
2376 nRet = RES_POOLCOLL_HEADLINE_BASE; break;
2378 break;
2380 case COLL_LISTS_BITS:
2381 switch( nId )
2383 case RES_POOLCOLL_NUMBUL_BASE:
2384 nRet = RES_POOLCOLL_TEXT; break;
2386 default:
2387 nRet = RES_POOLCOLL_NUMBUL_BASE; break;
2389 break;
2391 case COLL_EXTRA_BITS:
2392 switch( nId )
2394 case RES_POOLCOLL_TABLE_HDLN:
2395 nRet = RES_POOLCOLL_TABLE; break;
2397 case RES_POOLCOLL_FRAME:
2398 case RES_POOLCOLL_TABLE:
2399 case RES_POOLCOLL_FOOTNOTE:
2400 case RES_POOLCOLL_ENDNOTE:
2401 case RES_POOLCOLL_JAKETADRESS:
2402 case RES_POOLCOLL_SENDADRESS:
2403 case RES_POOLCOLL_HEADER:
2404 case RES_POOLCOLL_HEADERL:
2405 case RES_POOLCOLL_HEADERR:
2406 case RES_POOLCOLL_FOOTER:
2407 case RES_POOLCOLL_FOOTERL:
2408 case RES_POOLCOLL_FOOTERR:
2409 case RES_POOLCOLL_LABEL:
2410 nRet = RES_POOLCOLL_STANDARD; break;
2412 case RES_POOLCOLL_LABEL_ABB:
2413 case RES_POOLCOLL_LABEL_TABLE:
2414 case RES_POOLCOLL_LABEL_FRAME:
2415 case RES_POOLCOLL_LABEL_DRAWING:
2416 nRet = RES_POOLCOLL_LABEL; break;
2418 break;
2420 case COLL_REGISTER_BITS:
2421 switch( nId )
2423 case RES_POOLCOLL_REGISTER_BASE:
2424 nRet = RES_POOLCOLL_STANDARD; break;
2426 case RES_POOLCOLL_TOX_USERH:
2427 case RES_POOLCOLL_TOX_CNTNTH:
2428 case RES_POOLCOLL_TOX_IDXH:
2429 case RES_POOLCOLL_TOX_ILLUSH:
2430 case RES_POOLCOLL_TOX_OBJECTH:
2431 case RES_POOLCOLL_TOX_TABLESH:
2432 case RES_POOLCOLL_TOX_AUTHORITIESH:
2433 nRet = RES_POOLCOLL_HEADLINE_BASE; break;
2435 default:
2436 nRet = RES_POOLCOLL_REGISTER_BASE; break;
2438 break;
2440 case COLL_DOC_BITS:
2441 nRet = RES_POOLCOLL_HEADLINE_BASE;
2442 break;
2444 case COLL_HTML_BITS:
2445 nRet = RES_POOLCOLL_STANDARD;
2446 break;
2450 return nRet;
2453 void SwDoc::RemoveAllFmtLanguageDependencies()
2455 /* Restore the language independ pool defaults and styles. */
2456 GetAttrPool().ResetPoolDefaultItem( RES_PARATR_ADJUST );
2458 SwTxtFmtColl * pTxtFmtColl = GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
2460 pTxtFmtColl->ResetFmtAttr( RES_PARATR_ADJUST );
2461 /* koreans do not like SvxScriptItem(TRUE) */
2462 pTxtFmtColl->ResetFmtAttr( RES_PARATR_SCRIPTSPACE );
2464 SvxFrameDirectionItem aFrameDir( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR );
2466 sal_uInt16 nCount = GetPageDescCnt();
2467 for( sal_uInt16 i=0; i<nCount; ++i )
2469 SwPageDesc& rDesc = GetPageDesc( i );
2470 rDesc.GetMaster().SetFmtAttr( aFrameDir );
2471 rDesc.GetLeft().SetFmtAttr( aFrameDir );
2474 //#i16874# AutoKerning as default for new documents
2475 GetAttrPool().ResetPoolDefaultItem( RES_CHRATR_AUTOKERN );
2478 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */