LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/doc - poolfmt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 540 1147 47.1 %
Date: 2012-12-27 Functions: 20 23 87.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <hintids.hxx>
      22             : #include <i18npool/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/adjitem.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/escpitem.hxx>
      41             : #include <editeng/langitem.hxx>
      42             : #include <editeng/charrotateitem.hxx>
      43             : #include <editeng/frmdiritem.hxx>
      44             : #include <editeng/emphitem.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>
      65             : 
      66             : 
      67             : using namespace ::editeng;
      68             : using namespace ::com::sun::star;
      69             : 
      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
      83             : 
      84             : 
      85             : #define HTML_PARSPACE   GetMetricVal( CM_05 )
      86             : 
      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
      95             : };
      96             : 
      97          41 : static long lcl_GetRightMargin( SwDoc& rDoc )
      98             : {
      99             :     // Make sure that the printer settings are taken over to the standard
     100             :     // page style
     101          41 :     const SwFrmFmt& rPgDscFmt = rDoc.GetPageDesc( 0 ).GetMaster();
     102          41 :     const SvxLRSpaceItem& rLR = rPgDscFmt.GetLRSpace();
     103          41 :     const long nLeft = rLR.GetLeft();
     104          41 :     const long nRight = rLR.GetRight();
     105          41 :     const long nWidth = rPgDscFmt.GetFrmSize().GetWidth();
     106          41 :     return nWidth - nLeft - nRight;
     107             : }
     108             : 
     109        1009 : void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem )
     110             : {
     111        1009 :     rSet.Put( rItem );
     112        1009 :     sal_uInt16 nWhCJK = 0, nWhCTL = 0;
     113        1009 :     switch( rItem.Which() )
     114             :     {
     115             :     case RES_CHRATR_FONTSIZE:
     116         628 :         nWhCJK = RES_CHRATR_CJK_FONTSIZE, nWhCTL = RES_CHRATR_CTL_FONTSIZE;
     117         628 :         break;
     118             :     case RES_CHRATR_FONT:
     119           1 :         nWhCJK = RES_CHRATR_CJK_FONT, nWhCTL = RES_CHRATR_CTL_FONT;
     120           1 :         break;
     121             :     case RES_CHRATR_LANGUAGE:
     122           0 :         nWhCJK = RES_CHRATR_CJK_LANGUAGE, nWhCTL = RES_CHRATR_CTL_LANGUAGE;
     123           0 :         break;
     124             :     case RES_CHRATR_POSTURE:
     125         294 :         nWhCJK = RES_CHRATR_CJK_POSTURE, nWhCTL = RES_CHRATR_CTL_POSTURE;
     126         294 :         break;
     127             :     case RES_CHRATR_WEIGHT:
     128          86 :         nWhCJK = RES_CHRATR_CJK_WEIGHT, nWhCTL = RES_CHRATR_CTL_WEIGHT;
     129          86 :         break;
     130             :     }
     131             : 
     132        1009 :     if( nWhCJK )
     133        1009 :         rSet.Put( rItem, nWhCJK );
     134        1009 :     if( nWhCTL )
     135        1009 :         rSet.Put( rItem, nWhCTL );
     136        1009 : }
     137             : 
     138           3 : static void lcl_SetDfltFont( sal_uInt16 nFntType, SfxItemSet& rSet )
     139             : {
     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 }
     147             :     };
     148          12 :     for( sal_uInt16 n = 0; n < 3; ++n )
     149             :     {
     150           9 :         sal_uInt16 nLng = ((SvxLanguageItem&)rSet.GetPool()->GetDefaultItem(
     151           9 :                             aArr[n].nResLngId )).GetLanguage();
     152             :         Font aFnt( OutputDevice::GetDefaultFont( nFntType,
     153           9 :                                 nLng, DEFAULTFONT_FLAGS_ONLYONE ) );
     154             : 
     155           9 :         rSet.Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(),
     156             :                             aEmptyStr, aFnt.GetPitch(),
     157          18 :                             aFnt.GetCharSet(), aArr[n].nResFntId ));
     158           9 :     }
     159           3 : }
     160             : 
     161           0 : static void lcl_SetDfltFont( sal_uInt16 nLatinFntType, sal_uInt16 nCJKFntType,
     162             :                         sal_uInt16 nCTLFntType, SfxItemSet& rSet )
     163             : {
     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 }
     172             :     };
     173           0 :     aArr[0].nFntType = nLatinFntType;
     174           0 :     aArr[1].nFntType = nCJKFntType;
     175           0 :     aArr[2].nFntType = nCTLFntType;
     176             : 
     177           0 :     for( sal_uInt16 n = 0; n < 3; ++n )
     178             :     {
     179           0 :         sal_uInt16 nLng = ((SvxLanguageItem&)rSet.GetPool()->GetDefaultItem(
     180           0 :                             aArr[n].nResLngId )).GetLanguage();
     181             :         Font aFnt( OutputDevice::GetDefaultFont( aArr[n].nFntType,
     182           0 :                                 nLng, DEFAULTFONT_FLAGS_ONLYONE ) );
     183             : 
     184           0 :         rSet.Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(),
     185             :                             aEmptyStr, aFnt.GetPitch(),
     186           0 :                             aFnt.GetCharSet(), aArr[n].nResFntId ));
     187           0 :     }
     188           0 : }
     189             : 
     190          68 : static void lcl_SetHeadline( SwDoc* pDoc, SwTxtFmtColl* pColl,
     191             :                         SfxItemSet& rSet,
     192             :                         sal_uInt16 nOutLvlBits, sal_uInt8 nLevel, bool bItalic )
     193             : {
     194          68 :     SetAllScriptItem( rSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
     195          68 :     SvxFontHeightItem aHItem(240, 100, RES_CHRATR_FONTSIZE);
     196          68 :     const bool bHTMLMode = pDoc->get(IDocumentSettingAccess::HTML_MODE);
     197          68 :     if( bHTMLMode )
     198           0 :         aHItem.SetHeight( aHeadlineSizes[ MAXLEVEL + nLevel ] );
     199             :     else
     200          68 :         aHItem.SetHeight( PT_14, aHeadlineSizes[ nLevel ] );
     201          68 :     SetAllScriptItem( rSet, aHItem );
     202             : 
     203          68 :     if( bItalic && !bHTMLMode )
     204          16 :         SetAllScriptItem( rSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE ) );
     205             : 
     206          68 :     if( bHTMLMode )
     207             :     {
     208             :         ::lcl_SetDfltFont( DEFAULTFONT_LATIN_TEXT, DEFAULTFONT_CJK_TEXT,
     209           0 :                             DEFAULTFONT_CTL_TEXT, rSet );
     210             :     }
     211             : 
     212          68 :     if( pColl )
     213             :     {
     214          68 :         if( !( nOutLvlBits & ( 1 << nLevel )) )
     215             :         {
     216          68 :             pColl->AssignToListLevelOfOutlineStyle(nLevel);//<-end,zhaojianwei
     217          68 :             if( !bHTMLMode )
     218             :             {
     219          68 :                 SwNumRule * pOutlineRule = pDoc->GetOutlineNumRule();
     220          68 :                 const SwNumFmt& rNFmt = pOutlineRule->Get( nLevel );
     221             : 
     222          68 :                 if ( rNFmt.GetPositionAndSpaceMode() ==
     223             :                                     SvxNumberFormat::LABEL_WIDTH_AND_POSITION &&
     224           0 :                      ( rNFmt.GetAbsLSpace() || rNFmt.GetFirstLineOffset() ) )
     225             :                 {
     226           0 :                     SvxLRSpaceItem aLR( (SvxLRSpaceItem&)pColl->GetFmtAttr( RES_LR_SPACE ) );
     227           0 :                     aLR.SetTxtFirstLineOfstValue( rNFmt.GetFirstLineOffset() );
     228           0 :                     aLR.SetTxtLeft( rNFmt.GetAbsLSpace() );
     229           0 :                     pColl->SetFmtAttr( aLR );
     230             :                 }
     231             : 
     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.
     236             :                 {
     237          68 :                     SwNumRuleItem aItem(pOutlineRule->GetName());
     238             : 
     239          68 :                     pColl->SetFmtAttr(aItem);
     240             :                 }
     241             :             }
     242             :         }
     243             :         pColl->SetNextTxtFmtColl( *pDoc->GetTxtCollFromPool(
     244          68 :                                         RES_POOLCOLL_TEXT ));
     245          68 :     }
     246          68 : }
     247             : 
     248             : 
     249             : 
     250           9 : static void lcl_SetRegister( SwDoc* pDoc, SfxItemSet& rSet, sal_uInt16 nFact,
     251             :                         bool bHeader, bool bTab )
     252             : {
     253           9 :     SvxLRSpaceItem aLR( RES_LR_SPACE );
     254           9 :     sal_uInt16 nLeft = nFact ? GetMetricVal( CM_05 ) * nFact : 0;
     255           9 :     aLR.SetTxtLeft( nLeft );
     256             : 
     257           9 :     rSet.Put( aLR );
     258           9 :     if( bHeader )
     259             :     {
     260           0 :         SetAllScriptItem( rSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
     261           0 :         SetAllScriptItem( rSet, SvxFontHeightItem( PT_16, 100, RES_CHRATR_FONTSIZE ) );
     262             :     }
     263           9 :     if( bTab )
     264             :     {
     265           9 :         long nRightMargin = lcl_GetRightMargin( *pDoc );
     266           9 :         SvxTabStopItem aTStops( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
     267             :         aTStops.Insert( SvxTabStop( nRightMargin - nLeft,
     268             :                                     SVX_TAB_ADJUST_RIGHT,
     269           9 :                                     cDfltDecimalChar, '.' ));
     270           9 :         rSet.Put( aTStops );
     271           9 :     }
     272           9 : }
     273             : 
     274             : 
     275             : 
     276           0 : static void lcl_SetNumBul( SwDoc* pDoc, SwTxtFmtColl* pColl,
     277             :                         SfxItemSet& rSet,
     278             :                         sal_uInt16 nNxt, SwTwips nEZ, SwTwips nLeft,
     279             :                         SwTwips nUpper, SwTwips nLower )
     280             : {
     281             : 
     282           0 :     SvxLRSpaceItem aLR( RES_LR_SPACE ); SvxULSpaceItem aUL( RES_UL_SPACE );
     283           0 :     aLR.SetTxtFirstLineOfst( sal_uInt16(nEZ) ); aLR.SetTxtLeft( sal_uInt16(nLeft) );
     284           0 :     aUL.SetUpper( sal_uInt16(nUpper) ); aUL.SetLower( sal_uInt16(nLower) );
     285           0 :     rSet.Put( aLR );
     286           0 :     rSet.Put( aUL );
     287             : 
     288           0 :     if( pColl )
     289           0 :         pColl->SetNextTxtFmtColl( *pDoc->GetTxtCollFromPool( nNxt ));
     290           0 : }
     291             : 
     292             : 
     293             : 
     294             : // Return the AutoCollection by it's Id. If it doesn't
     295             : // exist yet, create it.
     296             : // If the String pointer is defined, then only query for
     297             : // the Attribute descriptions. It doesn't create a style!
     298        1274 : SvxFrameDirection GetDefaultFrameDirection(sal_uLong nLanguage)
     299             : {
     300        1274 :     SvxFrameDirection eResult = (MsLangId::isRightToLeft( static_cast<LanguageType>(nLanguage)) ?
     301        1274 :             FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP);
     302        1274 :     return eResult;
     303             : }
     304             : 
     305        7616 : SwTxtFmtColl* SwDoc::GetTxtCollFromPool( sal_uInt16 nId, bool bRegardLanguage )
     306             : {
     307             :     OSL_ENSURE(
     308             :         (RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END) ||
     309             :         (RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END) ||
     310             :         (RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END) ||
     311             :         (RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END) ||
     312             :         (RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END) ||
     313             :         (RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END),
     314             :             "Wrong  AutoFormat Id" );
     315             : 
     316             :     SwTxtFmtColl* pNewColl;
     317        7616 :     sal_uInt16 nOutLvlBits = 0;
     318       31548 :     for( sal_uInt16 n = 0; n < pTxtFmtCollTbl->size(); ++n )
     319             :     {
     320       29635 :         if( nId == ( pNewColl = (*pTxtFmtCollTbl)[ n ] )->GetPoolFmtId() )
     321             :         {
     322        5703 :             return pNewColl;
     323             :         }
     324             : 
     325       23932 :         if( pNewColl->IsAssignedToListLevelOfOutlineStyle())
     326         602 :             nOutLvlBits |= ( 1 << pNewColl->GetAssignedOutlineStyleLevel() );//<-end,zhaojianwei
     327             :     }
     328             : 
     329             :     // Didn't find it until here -> create anew
     330        1913 :     sal_uInt16 nResId = 0;
     331        1913 :     if( RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END )
     332         940 :         nResId = RC_POOLCOLL_TEXT_BEGIN - RES_POOLCOLL_TEXT_BEGIN;
     333         973 :     else if (RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END)
     334         274 :         nResId = RC_POOLCOLL_LISTS_BEGIN - RES_POOLCOLL_LISTS_BEGIN;
     335         699 :     else if (RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END)
     336         387 :         nResId = RC_POOLCOLL_EXTRA_BEGIN - RES_POOLCOLL_EXTRA_BEGIN;
     337         312 :     else if (RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END)
     338         301 :         nResId = RC_POOLCOLL_REGISTER_BEGIN - RES_POOLCOLL_REGISTER_BEGIN;
     339          11 :     else if (RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END)
     340           8 :         nResId = RC_POOLCOLL_DOC_BEGIN - RES_POOLCOLL_DOC_BEGIN;
     341           3 :     else if (RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END)
     342           3 :         nResId = RC_POOLCOLL_HTML_BEGIN - RES_POOLCOLL_HTML_BEGIN;
     343             : 
     344             :     OSL_ENSURE( nResId, "Invalid Pool ID" );
     345        1913 :     if( !nResId )
     346           0 :         return GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
     347             : 
     348        1913 :     ResId aResId( nResId + nId, *pSwResMgr );
     349        1913 :     String aNm( aResId );
     350             : 
     351             :     // A Set for all to-be-set Attributes
     352        1913 :     SwAttrSet aSet( GetAttrPool(), aTxtFmtCollSetRange );
     353        1913 :     sal_uInt16 nParent = GetPoolParent( nId );
     354             : 
     355             :     {
     356             : 
     357             : //FEATURE::CONDCOLL
     358        1913 :         if(::IsConditionalByPoolId( nId ))
     359             :             pNewColl = new SwConditionTxtFmtColl( GetAttrPool(), aNm, !nParent
     360             :                                                 ? pDfltTxtFmtColl
     361         274 :                                                 : GetTxtCollFromPool( nParent ));
     362             :         else
     363             : //FEATURE::CONDCOLL
     364             :             pNewColl = new SwTxtFmtColl( GetAttrPool(), aNm, !nParent
     365             :                                             ? pDfltTxtFmtColl
     366        1639 :                                             : GetTxtCollFromPool( nParent ));
     367        1913 :         pNewColl->SetPoolFmtId( nId );
     368        1913 :         pTxtFmtCollTbl->push_back( pNewColl );
     369             :     }
     370             : 
     371        1913 :     bool bNoDefault = get( IDocumentSettingAccess::STYLES_NODEFAULT );
     372        1913 :     if ( !bNoDefault )
     373             :     {
     374        1826 :         switch( nId )
     375             :         {
     376             :         // General content forms
     377             :         case RES_POOLCOLL_STANDARD:
     378             :             /* koreans do not like SvxScriptItem(TRUE) */
     379         284 :             if (bRegardLanguage)
     380             :             {
     381         284 :                 sal_uLong nAppLanguage = GetAppLanguage();
     382         284 :                 if (GetDefaultFrameDirection(nAppLanguage) ==
     383             :                     FRMDIR_HORI_RIGHT_TOP)
     384             :                 {
     385           0 :                     SvxAdjustItem aAdjust(SVX_ADJUST_RIGHT, RES_PARATR_ADJUST );
     386           0 :                     aSet.Put(aAdjust);
     387             :                 }
     388         284 :                 if (nAppLanguage == LANGUAGE_KOREAN)
     389             :                 {
     390           0 :                     SvxScriptSpaceItem aScriptSpace(sal_False, RES_PARATR_SCRIPTSPACE);
     391           0 :                     aSet.Put(aScriptSpace);
     392             :                 }
     393             :             }
     394         284 :             break;
     395             : 
     396             :         case RES_POOLCOLL_TEXT:                 // Text body
     397             :             {
     398         274 :                 SvxULSpaceItem aUL( 0, PT_6, RES_UL_SPACE );
     399         274 :                 if( get(IDocumentSettingAccess::HTML_MODE) ) aUL.SetLower( HTML_PARSPACE );
     400         274 :                 aSet.Put( aUL );
     401             :             }
     402         274 :             break;
     403             :         case RES_POOLCOLL_TEXT_IDENT:           // Text body indentation
     404             :             {
     405           0 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
     406           0 :                 aLR.SetTxtFirstLineOfst( GetMetricVal( CM_05 ));
     407           0 :                 aSet.Put( aLR );
     408             :             }
     409           0 :             break;
     410             :         case RES_POOLCOLL_TEXT_NEGIDENT:        // Text body neg. indentation
     411             :             {
     412           0 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
     413           0 :                 aLR.SetTxtFirstLineOfst( -(short)GetMetricVal( CM_05 ));
     414           0 :                 aLR.SetTxtLeft( GetMetricVal( CM_1 ));
     415           0 :                 SvxTabStopItem aTStops(RES_PARATR_TABSTOP);    aTStops.Insert( SvxTabStop( 0 ));
     416             : 
     417           0 :                 aSet.Put( aLR );
     418           0 :                 aSet.Put( aTStops );
     419             :             }
     420           0 :             break;
     421             :         case RES_POOLCOLL_TEXT_MOVE:            // Text body move
     422             :             {
     423           4 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
     424           4 :                 aLR.SetTxtLeft( GetMetricVal( CM_05 ));
     425           4 :                 aSet.Put( aLR );
     426             :             }
     427           4 :             break;
     428             : 
     429             :         case RES_POOLCOLL_CONFRONTATION:    // Text body confrontation
     430             :             {
     431           0 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
     432           0 :                 aLR.SetTxtFirstLineOfst( - short( GetMetricVal( CM_1 ) * 4 +
     433           0 :                                                   GetMetricVal( CM_05)) );
     434           0 :                 aLR.SetTxtLeft( GetMetricVal( CM_1 ) * 5 );
     435           0 :                 SvxTabStopItem aTStops( RES_PARATR_TABSTOP );    aTStops.Insert( SvxTabStop( 0 ));
     436             : 
     437           0 :                 aSet.Put( aLR );
     438           0 :                 aSet.Put( aTStops );
     439             :             }
     440           0 :             break;
     441             :         case RES_POOLCOLL_MARGINAL:         // Text body marginal
     442             :             {
     443           0 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
     444           0 :                 aLR.SetTxtLeft( GetMetricVal( CM_1 ) * 4 );
     445           0 :                 aSet.Put( aLR );
     446             :             }
     447           0 :             break;
     448             : 
     449             :         case RES_POOLCOLL_HEADLINE_BASE:            // Base headline
     450             :             {
     451             :                 static const sal_uInt16 aFntInit[] = {
     452             :                     DEFAULTFONT_LATIN_HEADING,  RES_CHRATR_FONT,
     453             :                                     RES_CHRATR_LANGUAGE, LANGUAGE_ENGLISH_US,
     454             :                     DEFAULTFONT_CJK_HEADING,    RES_CHRATR_CJK_FONT,
     455             :                                     RES_CHRATR_CJK_LANGUAGE, LANGUAGE_ENGLISH_US,
     456             :                     DEFAULTFONT_CTL_HEADING,    RES_CHRATR_CTL_FONT,
     457             :                                     RES_CHRATR_CTL_LANGUAGE, LANGUAGE_ARABIC_SAUDI_ARABIA,
     458             :                     0
     459             :                 };
     460             : 
     461        1096 :                 for( const sal_uInt16* pArr = aFntInit; *pArr; pArr += 4 )
     462             :                 {
     463         822 :                     sal_uInt16 nLng = ((SvxLanguageItem&)GetDefault( *(pArr+2) )).GetLanguage();
     464         822 :                     if( LANGUAGE_DONTKNOW == nLng )
     465           0 :                         nLng = *(pArr+3);
     466             : 
     467             :                     Font aFnt( OutputDevice::GetDefaultFont( *pArr,
     468         822 :                                             nLng, DEFAULTFONT_FLAGS_ONLYONE ) );
     469             : 
     470         822 :                     aSet.Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(),
     471             :                                             aEmptyStr, aFnt.GetPitch(),
     472        1644 :                                             aFnt.GetCharSet(), *(pArr+1) ));
     473         822 :                 }
     474             : 
     475         274 :                 SvxFontHeightItem aFntSize( PT_14, 100, RES_CHRATR_FONTSIZE );
     476         274 :                 SvxULSpaceItem aUL( PT_12, PT_6, RES_UL_SPACE );
     477         274 :                 if( get(IDocumentSettingAccess::HTML_MODE) )
     478           0 :                     aUL.SetLower( HTML_PARSPACE );
     479         274 :                 aSet.Put( SvxFmtKeepItem( sal_True, RES_KEEP ));
     480             : 
     481         274 :                 pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
     482             : 
     483         274 :                 aSet.Put( aUL );
     484         274 :                 SetAllScriptItem( aSet, aFntSize );
     485             :             }
     486         274 :             break;
     487             : 
     488             :         case RES_POOLCOLL_NUMBUL_BASE:          // Base Numbering
     489         274 :             break;
     490             : 
     491             :         case RES_POOLCOLL_GREETING:             // Greeting
     492             :         case RES_POOLCOLL_REGISTER_BASE:        // Base indexes
     493             :         case RES_POOLCOLL_SIGNATURE:            // Signatures
     494             :         case RES_POOLCOLL_TABLE:                // Tabele content
     495             :             {
     496         288 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     497         288 :                 aSet.Put( aLN );
     498             :             }
     499         288 :             break;
     500             : 
     501             :         case RES_POOLCOLL_HEADLINE1:        // Headinline 1
     502          14 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 0, false );
     503          14 :             break;
     504             :         case RES_POOLCOLL_HEADLINE2:        // Headinline 2
     505          11 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 1, true );
     506          11 :             break;
     507             :         case RES_POOLCOLL_HEADLINE3:        // Headinline 3
     508          11 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 2, false );
     509          11 :             break;
     510             :         case RES_POOLCOLL_HEADLINE4:        // Headinline 4
     511           5 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 3, true );
     512           5 :             break;
     513             :         case RES_POOLCOLL_HEADLINE5:        // Headinline 5
     514           7 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 4, false );
     515           7 :             break;
     516             :         case RES_POOLCOLL_HEADLINE6:        // Headinline 6
     517           5 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 5, false );
     518           5 :             break;
     519             :         case RES_POOLCOLL_HEADLINE7:        // Headinline 7
     520           5 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 6, false );
     521           5 :             break;
     522             :         case RES_POOLCOLL_HEADLINE8:        // Headinline 8
     523           5 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 7, false );
     524           5 :             break;
     525             :         case RES_POOLCOLL_HEADLINE9:        // Headinline 9
     526           5 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 8, false );
     527           5 :             break;
     528             :         case RES_POOLCOLL_HEADLINE10:       // Headinline 10
     529           0 :             lcl_SetHeadline( this, pNewColl, aSet, nOutLvlBits, 9, false );
     530           0 :             break;
     531             : 
     532             : 
     533             :         // Special sections:
     534             :         // Header
     535             :         case RES_POOLCOLL_HEADER:
     536             :         case RES_POOLCOLL_HEADERL:
     537             :         case RES_POOLCOLL_HEADERR:
     538             :         // Footer
     539             :         case RES_POOLCOLL_FOOTER:
     540             :         case RES_POOLCOLL_FOOTERL:
     541             :         case RES_POOLCOLL_FOOTERR:
     542             :             {
     543          32 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     544          32 :                 aSet.Put( aLN );
     545             : 
     546          32 :                 long nRightMargin = lcl_GetRightMargin( *this );
     547             : 
     548          32 :                 SvxTabStopItem aTStops( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
     549          32 :                 aTStops.Insert( SvxTabStop( nRightMargin / 2, SVX_TAB_ADJUST_CENTER ) );
     550          32 :                 aTStops.Insert( SvxTabStop( nRightMargin, SVX_TAB_ADJUST_RIGHT ) );
     551             : 
     552          32 :                 aSet.Put( aTStops );
     553             :             }
     554          32 :             break;
     555             : 
     556             :         case RES_POOLCOLL_TABLE_HDLN:
     557             :             {
     558          14 :                 SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
     559          14 :                 aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ) );
     560          14 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     561          14 :                 aSet.Put( aLN );
     562             :             }
     563          14 :             break;
     564             : 
     565             :         case RES_POOLCOLL_FOOTNOTE:             // paragraph style Footnote
     566             :         case RES_POOLCOLL_ENDNOTE:              // paragraph style Endnote
     567             :             {
     568           8 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
     569           8 :                 aLR.SetTxtFirstLineOfst( -(short)( GetMetricVal( CM_05 ) + GetMetricVal( CM_01 ) ) );
     570           8 :                 aLR.SetTxtLeft( GetMetricVal( CM_05 ) + GetMetricVal( CM_01 ) );
     571           8 :                 SetAllScriptItem( aSet, SvxFontHeightItem( PT_10, 100, RES_CHRATR_FONTSIZE ) );
     572           8 :                 aSet.Put( aLR );
     573           8 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     574           8 :                 aSet.Put( aLN );
     575             :             }
     576           8 :             break;
     577             : 
     578             :         case RES_POOLCOLL_LABEL:                // basic caption
     579             :             {
     580         274 :                 SvxULSpaceItem aUL( RES_UL_SPACE ); aUL.SetUpper( PT_6 ); aUL.SetLower( PT_6 );
     581         274 :                 aSet.Put( aUL );
     582         274 :                 SetAllScriptItem( aSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE ) );
     583         274 :                 SetAllScriptItem( aSet, SvxFontHeightItem( PT_10, 100, RES_CHRATR_FONTSIZE ) );
     584         274 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     585         274 :                 aSet.Put( aLN );
     586             :             }
     587         274 :             break;
     588             : 
     589             :         case RES_POOLCOLL_FRAME:                // Frame content
     590             :         case RES_POOLCOLL_LABEL_ABB:            // caption image
     591             :         case RES_POOLCOLL_LABEL_TABLE:          // caption table
     592             :         case RES_POOLCOLL_LABEL_FRAME:          // caption frame
     593             :         case RES_POOLCOLL_LABEL_DRAWING:        // caption drawing
     594          15 :             break;
     595             : 
     596             :         case RES_POOLCOLL_JAKETADRESS:          // envelope address
     597             :             {
     598           2 :                 SvxULSpaceItem aUL( RES_UL_SPACE ); aUL.SetLower( PT_3 );
     599           2 :                 aSet.Put( aUL );
     600           2 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     601           2 :                 aSet.Put( aLN );
     602             :             }
     603           2 :             break;
     604             : 
     605             :         case RES_POOLCOLL_SENDADRESS:           // Sender address
     606             :             {
     607           2 :                 if( get(IDocumentSettingAccess::HTML_MODE) )
     608           0 :                     SetAllScriptItem( aSet, SvxPostureItem(ITALIC_NORMAL, RES_CHRATR_POSTURE) );
     609             :                 else
     610             :                 {
     611           2 :                     SvxULSpaceItem aUL( RES_UL_SPACE ); aUL.SetLower( PT_3 );
     612           2 :                     aSet.Put( aUL );
     613             :                 }
     614           2 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     615           2 :                 aSet.Put( aLN );
     616             :             }
     617           2 :             break;
     618             : 
     619             :         // User defined indexes:
     620             :         case RES_POOLCOLL_TOX_USERH:            // Header
     621           0 :             lcl_SetRegister( this, aSet, 0, true, false );
     622             :             {
     623           0 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     624           0 :                 aSet.Put( aLN );
     625             :             }
     626           0 :             break;
     627             :         case RES_POOLCOLL_TOX_USER1:            // 1. Level
     628           0 :             lcl_SetRegister( this, aSet, 0, false, true );
     629           0 :             break;
     630             :         case RES_POOLCOLL_TOX_USER2:            // 2. Level
     631           0 :             lcl_SetRegister( this, aSet, 1, false, true );
     632           0 :             break;
     633             :         case RES_POOLCOLL_TOX_USER3:            // 3. Level
     634           0 :             lcl_SetRegister( this, aSet, 2, false, true );
     635           0 :             break;
     636             :         case RES_POOLCOLL_TOX_USER4:            // 4. Level
     637           0 :             lcl_SetRegister( this, aSet, 3, false, true );
     638           0 :             break;
     639             :         case RES_POOLCOLL_TOX_USER5:            // 5. Level
     640           0 :             lcl_SetRegister( this, aSet, 4, false, true );
     641           0 :             break;
     642             :         case RES_POOLCOLL_TOX_USER6:            // 6. Level
     643           0 :             lcl_SetRegister( this, aSet, 5, false, true );
     644           0 :             break;
     645             :         case RES_POOLCOLL_TOX_USER7:            // 7. Level
     646           0 :             lcl_SetRegister( this, aSet, 6, false, true );
     647           0 :             break;
     648             :         case RES_POOLCOLL_TOX_USER8:            // 8. Level
     649           0 :             lcl_SetRegister( this, aSet, 7, false, true );
     650           0 :             break;
     651             :         case RES_POOLCOLL_TOX_USER9:            // 9. Level
     652           0 :             lcl_SetRegister( this, aSet, 8, false, true );
     653           0 :             break;
     654             :         case RES_POOLCOLL_TOX_USER10:           // 10. Level
     655           0 :             lcl_SetRegister( this, aSet, 9, false, true );
     656           0 :             break;
     657             : 
     658             :         // Index
     659             :         case RES_POOLCOLL_TOX_IDXH:         // Header
     660           0 :             lcl_SetRegister( this, aSet, 0, true, false );
     661             :             {
     662           0 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     663           0 :                 aSet.Put( aLN );
     664             :             }
     665           0 :             break;
     666             :         case RES_POOLCOLL_TOX_IDX1:         // 1. Level
     667           0 :             lcl_SetRegister( this, aSet, 0, false, false );
     668           0 :             break;
     669             :         case RES_POOLCOLL_TOX_IDX2:         // 2. Level
     670           0 :             lcl_SetRegister( this, aSet, 1, false, false );
     671           0 :             break;
     672             :         case RES_POOLCOLL_TOX_IDX3:         // 3. Level
     673           0 :             lcl_SetRegister( this, aSet, 2, false, false );
     674           0 :             break;
     675             :         case RES_POOLCOLL_TOX_IDXBREAK:     // Trenner
     676           0 :             lcl_SetRegister( this, aSet, 0, false, false );
     677           0 :             break;
     678             : 
     679             :         // Table of Content
     680             :         case RES_POOLCOLL_TOX_CNTNTH:       // Header
     681           0 :             lcl_SetRegister( this, aSet, 0, true, false );
     682             :             {
     683           0 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     684           0 :                 aSet.Put( aLN );
     685             :             }
     686           0 :             break;
     687             :         case RES_POOLCOLL_TOX_CNTNT1:       // 1. Level
     688           1 :             lcl_SetRegister( this, aSet, 0, false, true );
     689           1 :             break;
     690             :         case RES_POOLCOLL_TOX_CNTNT2:       // 2. Level
     691           1 :             lcl_SetRegister( this, aSet, 1, false, true );
     692           1 :             break;
     693             :         case RES_POOLCOLL_TOX_CNTNT3:       // 3. Level
     694           1 :             lcl_SetRegister( this, aSet, 2, false, true );
     695           1 :             break;
     696             :         case RES_POOLCOLL_TOX_CNTNT4:       // 4. Level
     697           1 :             lcl_SetRegister( this, aSet, 3, false, true );
     698           1 :             break;
     699             :         case RES_POOLCOLL_TOX_CNTNT5:       // 5. Level
     700           1 :             lcl_SetRegister( this, aSet, 4, false, true );
     701           1 :             break;
     702             :         case RES_POOLCOLL_TOX_CNTNT6:       // 6. Level
     703           1 :             lcl_SetRegister( this, aSet, 5, false, true );
     704           1 :             break;
     705             :         case RES_POOLCOLL_TOX_CNTNT7:       // 7. Level
     706           1 :             lcl_SetRegister( this, aSet, 6, false, true );
     707           1 :             break;
     708             :         case RES_POOLCOLL_TOX_CNTNT8:       // 8. Level
     709           1 :             lcl_SetRegister( this, aSet, 7, false, true );
     710           1 :             break;
     711             :         case RES_POOLCOLL_TOX_CNTNT9:       // 9. Level
     712           1 :             lcl_SetRegister( this, aSet, 8, false, true );
     713           1 :             break;
     714             :         case RES_POOLCOLL_TOX_CNTNT10:      // 10. Level
     715           0 :             lcl_SetRegister( this, aSet, 9, false, true );
     716           0 :             break;
     717             : 
     718             :         case RES_POOLCOLL_TOX_ILLUSH:
     719             :         case RES_POOLCOLL_TOX_OBJECTH:
     720             :         case RES_POOLCOLL_TOX_TABLESH:
     721             :         case RES_POOLCOLL_TOX_AUTHORITIESH:
     722           0 :             lcl_SetRegister( this, aSet, 0, true, false );
     723             :             {
     724           0 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
     725           0 :                 aSet.Put( aLN );
     726             :             }
     727           0 :             break;
     728             :         case RES_POOLCOLL_TOX_ILLUS1:
     729             :         case RES_POOLCOLL_TOX_OBJECT1:
     730             :         case RES_POOLCOLL_TOX_TABLES1:
     731             :         case RES_POOLCOLL_TOX_AUTHORITIES1:
     732           0 :             lcl_SetRegister( this, aSet, 0, false, true );
     733           0 :         break;
     734             : 
     735             : 
     736             : 
     737             :         case RES_POOLCOLL_NUM_LEVEL1S:
     738             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
     739           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
     740           0 :                             PT_12, PT_6 );
     741           0 :             break;
     742             :         case RES_POOLCOLL_NUM_LEVEL1:
     743             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
     744           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
     745           0 :                             0, PT_6 );
     746           0 :             break;
     747             :         case RES_POOLCOLL_NUM_LEVEL1E:
     748             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL1,
     749           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 0 ),
     750           0 :                             0, PT_12 );
     751           0 :             break;
     752             :         case RES_POOLCOLL_NUM_NONUM1:
     753             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM1,
     754           0 :                             0, SwNumRule::GetNumIndent( 0 ), 0, PT_6 );
     755           0 :             break;
     756             :         case RES_POOLCOLL_NUM_LEVEL2S:
     757             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
     758           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
     759           0 :                             PT_12, PT_6 );
     760           0 :             break;
     761             :         case RES_POOLCOLL_NUM_LEVEL2:
     762             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
     763           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
     764           0 :                             0, PT_6 );
     765           0 :             break;
     766             :         case RES_POOLCOLL_NUM_LEVEL2E:
     767             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL2,
     768           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 1 ),
     769           0 :                             0, PT_12 );
     770           0 :             break;
     771             :         case RES_POOLCOLL_NUM_NONUM2:
     772             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM2,
     773           0 :                             0, SwNumRule::GetNumIndent( 1 ), 0, PT_6 );
     774           0 :             break;
     775             :         case RES_POOLCOLL_NUM_LEVEL3S:
     776             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
     777           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
     778           0 :                             PT_12, PT_6 );
     779           0 :             break;
     780             :         case RES_POOLCOLL_NUM_LEVEL3:
     781             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
     782           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
     783           0 :                             0, PT_6 );
     784           0 :             break;
     785             :         case RES_POOLCOLL_NUM_LEVEL3E:
     786             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL3,
     787           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 2 ),
     788           0 :                             0, PT_12 );
     789           0 :             break;
     790             :         case RES_POOLCOLL_NUM_NONUM3:
     791             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM3,
     792           0 :                             0, SwNumRule::GetNumIndent( 2 ), 0, PT_6 );
     793           0 :             break;
     794             :         case RES_POOLCOLL_NUM_LEVEL4S:
     795             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
     796           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
     797           0 :                             PT_12, PT_6 );
     798           0 :             break;
     799             :         case RES_POOLCOLL_NUM_LEVEL4:
     800             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
     801           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
     802           0 :                             0, PT_6 );
     803           0 :             break;
     804             :         case RES_POOLCOLL_NUM_LEVEL4E:
     805             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL4,
     806           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 3 ),
     807           0 :                             0, PT_12 );
     808           0 :             break;
     809             :         case RES_POOLCOLL_NUM_NONUM4:
     810             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM4,
     811           0 :                             0, SwNumRule::GetNumIndent( 3 ), 0, PT_6 );
     812           0 :             break;
     813             :         case RES_POOLCOLL_NUM_LEVEL5S:
     814             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
     815           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
     816           0 :                             PT_12, PT_6 );
     817           0 :             break;
     818             :         case RES_POOLCOLL_NUM_LEVEL5:
     819             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
     820           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
     821           0 :                             0, PT_6 );
     822           0 :             break;
     823             :         case RES_POOLCOLL_NUM_LEVEL5E:
     824             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_LEVEL5,
     825           0 :                             lNumFirstLineOffset, SwNumRule::GetNumIndent( 4 ),
     826           0 :                             0, PT_12 );
     827           0 :             break;
     828             :         case RES_POOLCOLL_NUM_NONUM5:
     829             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_NUM_NONUM5,
     830           0 :                             0, SwNumRule::GetNumIndent( 4 ), 0, PT_6 );
     831           0 :             break;
     832             : 
     833             :         case RES_POOLCOLL_BUL_LEVEL1S:
     834             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL1,
     835           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
     836           0 :                             PT_12, PT_6 );
     837           0 :             break;
     838             :         case RES_POOLCOLL_BUL_LEVEL1:
     839             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL1,
     840           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
     841           0 :                             0, PT_6 );
     842           0 :             break;
     843             :         case RES_POOLCOLL_BUL_LEVEL1E:
     844             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL1,
     845           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 0 ),
     846           0 :                             0, PT_12 );
     847           0 :             break;
     848             :         case RES_POOLCOLL_BUL_NONUM1:
     849             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM1,
     850           0 :                             0, SwNumRule::GetBullIndent( 0 ), 0, PT_6 );
     851           0 :             break;
     852             :         case RES_POOLCOLL_BUL_LEVEL2S:
     853             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL2,
     854           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
     855           0 :                             PT_12, PT_6 );
     856           0 :             break;
     857             :         case RES_POOLCOLL_BUL_LEVEL2:
     858             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL2,
     859           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
     860           0 :                             0, PT_6 );
     861           0 :             break;
     862             :         case RES_POOLCOLL_BUL_LEVEL2E:
     863             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL2,
     864           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 1 ),
     865           0 :                             0, PT_12 );
     866           0 :             break;
     867             :         case RES_POOLCOLL_BUL_NONUM2:
     868             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM2,
     869           0 :                             0, SwNumRule::GetBullIndent( 1 ), 0, PT_6 );
     870           0 :             break;
     871             :         case RES_POOLCOLL_BUL_LEVEL3S:
     872             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL3,
     873           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
     874           0 :                             PT_12, PT_6 );
     875           0 :             break;
     876             :         case RES_POOLCOLL_BUL_LEVEL3:
     877             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL3,
     878           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
     879           0 :                             0, PT_6 );
     880           0 :             break;
     881             :         case RES_POOLCOLL_BUL_LEVEL3E:
     882             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL3,
     883           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 2 ),
     884           0 :                             0, PT_12 );
     885           0 :             break;
     886             :         case RES_POOLCOLL_BUL_NONUM3:
     887             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM3,
     888           0 :                             0, SwNumRule::GetBullIndent( 2 ), 0, PT_6 );
     889           0 :             break;
     890             :         case RES_POOLCOLL_BUL_LEVEL4S:
     891             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL4,
     892           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
     893           0 :                             PT_12, PT_6 );
     894           0 :             break;
     895             :         case RES_POOLCOLL_BUL_LEVEL4:
     896             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL4,
     897           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
     898           0 :                             0, PT_6 );
     899           0 :             break;
     900             :         case RES_POOLCOLL_BUL_LEVEL4E:
     901             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL4,
     902           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 3 ),
     903           0 :                             0, PT_12 );
     904           0 :             break;
     905             :         case RES_POOLCOLL_BUL_NONUM4:
     906             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM4,
     907           0 :                             0, SwNumRule::GetBullIndent( 3 ), 0, PT_6 );
     908           0 :             break;
     909             :         case RES_POOLCOLL_BUL_LEVEL5S:
     910             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL5,
     911           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
     912           0 :                             PT_12, PT_6 );
     913           0 :             break;
     914             :         case RES_POOLCOLL_BUL_LEVEL5:
     915             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL5,
     916           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
     917           0 :                             0, PT_6 );
     918           0 :             break;
     919             :         case RES_POOLCOLL_BUL_LEVEL5E:
     920             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_LEVEL5,
     921           0 :                             lBullFirstLineOffset, SwNumRule::GetBullIndent( 4 ),
     922           0 :                             0, PT_12 );
     923           0 :             break;
     924             :         case RES_POOLCOLL_BUL_NONUM5:
     925             :             lcl_SetNumBul( this, pNewColl, aSet, RES_POOLCOLL_BUL_NONUM5,
     926           0 :                             0, SwNumRule::GetBullIndent( 4 ), 0, PT_6 );
     927           0 :             break;
     928             : 
     929             :         case RES_POOLCOLL_DOC_TITEL:            // Document Title
     930             :             {
     931           0 :                 SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ) );
     932           0 :                 SetAllScriptItem( aSet, SvxFontHeightItem( PT_18, 100, RES_CHRATR_FONTSIZE ) );
     933             : 
     934           0 :                 aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ) );
     935             : 
     936           0 :                 pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
     937             :             }
     938           0 :             break;
     939             : 
     940             :         case RES_POOLCOLL_DOC_SUBTITEL:         // Document subtitle
     941             :             {
     942           1 :                 SetAllScriptItem( aSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE ));
     943           1 :                 SetAllScriptItem( aSet, SvxFontHeightItem( PT_14, 100, RES_CHRATR_FONTSIZE ));
     944             : 
     945           1 :                 aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ));
     946             : 
     947             :                 pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool(
     948           1 :                                                     RES_POOLCOLL_TEXT ));
     949             :             }
     950           1 :             break;
     951             : 
     952             :         case RES_POOLCOLL_HTML_BLOCKQUOTE:
     953             :             {
     954           0 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
     955           0 :                 aLR.SetLeft( GetMetricVal( CM_1 ));
     956           0 :                 aLR.SetRight( GetMetricVal( CM_1 ));
     957           0 :                 aSet.Put( aLR );
     958           0 :                 SvxULSpaceItem aUL( RES_UL_SPACE );
     959           0 :                 aUL = pNewColl->GetULSpace();
     960           0 :                 aUL.SetLower( HTML_PARSPACE );
     961           0 :                 aSet.Put( aUL);
     962             :             }
     963           0 :             break;
     964             : 
     965             :         case RES_POOLCOLL_HTML_PRE:
     966             :             {
     967           3 :                 ::lcl_SetDfltFont( DEFAULTFONT_FIXED, aSet );
     968             : 
     969             :                 // WORKAROUND: Set PRE to 10pt
     970           3 :                 SetAllScriptItem( aSet, SvxFontHeightItem(PT_10, 100, RES_CHRATR_FONTSIZE) );
     971             : 
     972             :                 // The lower paragraph distance is set explicitly (makes
     973             :                 // assigning hard attributes easier)
     974           3 :                 SvxULSpaceItem aULSpaceItem( RES_UL_SPACE );
     975           3 :                 aULSpaceItem = pNewColl->GetULSpace();
     976           3 :                 aULSpaceItem.SetLower( 0 );
     977           3 :                 aSet.Put( aULSpaceItem );
     978             :             }
     979           3 :             break;
     980             : 
     981             :         case RES_POOLCOLL_HTML_HR:
     982             :             {
     983           0 :                 SvxBoxItem aBox( RES_BOX );
     984           0 :                 Color aColor( COL_GRAY );
     985           0 :                 SvxBorderLine aNew(&aColor, 1, table::BorderLineStyle::DOUBLE);
     986           0 :                 aBox.SetLine( &aNew, BOX_LINE_BOTTOM );
     987             : 
     988           0 :                 aSet.Put( aBox );
     989           0 :                 aSet.Put( SwParaConnectBorderItem( sal_False ) );
     990           0 :                 SetAllScriptItem( aSet, SvxFontHeightItem(120, 100, RES_CHRATR_FONTSIZE) );
     991             : 
     992           0 :                 SvxULSpaceItem aUL( RES_UL_SPACE );
     993             :                 {
     994             :                     pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool(
     995           0 :                                                     RES_POOLCOLL_TEXT ));
     996           0 :                     aUL = pNewColl->GetULSpace();
     997             :                 }
     998           0 :                 aUL.SetLower( HTML_PARSPACE );
     999           0 :                 aSet.Put( aUL);
    1000           0 :                 SwFmtLineNumber aLN; aLN.SetCountLines( sal_False );
    1001           0 :                 aSet.Put( aLN );
    1002             :             }
    1003           0 :             break;
    1004             : 
    1005             :         case RES_POOLCOLL_HTML_DD:
    1006             :             {
    1007           0 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
    1008           0 :                 aLR = pNewColl->GetLRSpace();
    1009             :                 // We indent by 1 cm. The IDs are always 2 away from each other!
    1010           0 :                 aLR.SetLeft( GetMetricVal( CM_1 ));
    1011           0 :                 aSet.Put( aLR );
    1012             :             }
    1013           0 :             break;
    1014             :         case RES_POOLCOLL_HTML_DT:
    1015             :             {
    1016           0 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
    1017             :                 {
    1018             :                     pNewColl->SetNextTxtFmtColl( *GetTxtCollFromPool(
    1019           0 :                                                         RES_POOLCOLL_HTML_DD ));
    1020           0 :                     aLR = pNewColl->GetLRSpace();
    1021             :                 }
    1022             :                 // We indent by 0 cm. The IDs are always 2 away from each other!
    1023           0 :                 aLR.SetLeft( 0 );
    1024           0 :                 aSet.Put( aLR );
    1025             :             }
    1026           0 :             break;
    1027             :         }
    1028             :     }
    1029             : 
    1030        1913 :     if( aSet.Count() )
    1031             :     {
    1032             :         {
    1033        1253 :             pNewColl->SetFmtAttr( aSet );
    1034             :         }
    1035             :     }
    1036        1913 :     return pNewColl;
    1037             : }
    1038             : 
    1039             : 
    1040             : 
    1041             : // Check if this AutoCollection is already/still in use in this Document
    1042       18666 : bool SwDoc::IsPoolTxtCollUsed( sal_uInt16 nId ) const
    1043             : {
    1044             :     OSL_ENSURE(
    1045             :         (RES_POOLCOLL_TEXT_BEGIN <= nId && nId < RES_POOLCOLL_TEXT_END) ||
    1046             :         (RES_POOLCOLL_LISTS_BEGIN <= nId && nId < RES_POOLCOLL_LISTS_END) ||
    1047             :         (RES_POOLCOLL_EXTRA_BEGIN <= nId && nId < RES_POOLCOLL_EXTRA_END) ||
    1048             :         (RES_POOLCOLL_REGISTER_BEGIN <= nId && nId < RES_POOLCOLL_REGISTER_END) ||
    1049             :         (RES_POOLCOLL_DOC_BEGIN <= nId && nId < RES_POOLCOLL_DOC_END) ||
    1050             :         (RES_POOLCOLL_HTML_BEGIN <= nId && nId < RES_POOLCOLL_HTML_END),
    1051             :             "Wrong AutoFormat Id" );
    1052             : 
    1053       18666 :     SwTxtFmtColl* pNewColl = 0;
    1054       18666 :     bool bFnd = false;
    1055      260636 :     for( sal_uInt16 n = 0; !bFnd && n < pTxtFmtCollTbl->size(); ++n )
    1056             :     {
    1057      241970 :         pNewColl = (*pTxtFmtCollTbl)[ n ];
    1058      241970 :         if( nId == pNewColl->GetPoolFmtId() )
    1059        1253 :             bFnd = true;
    1060             :     }
    1061             : 
    1062       18666 :     if( !bFnd || !pNewColl->GetDepends() )
    1063       18353 :         return false;
    1064             : 
    1065         313 :     SwAutoFmtGetDocNode aGetHt( &GetNodes() );
    1066         313 :     return !pNewColl->GetInfo( aGetHt );
    1067             : }
    1068             : 
    1069             : // Return the AutomaticFormat with the supplied Id. If it doesn't
    1070             : // exist, create it.
    1071         684 : SwFmt* SwDoc::GetFmtFromPool( sal_uInt16 nId )
    1072             : {
    1073         684 :     SwFmt *pNewFmt = 0;
    1074         684 :     SwFmt *pDeriveFmt = 0;
    1075             : 
    1076             :     SwFmtsBase* pArray[ 2 ];
    1077         684 :     sal_uInt16 nArrCnt = 1, nRCId = 0;
    1078         684 :     sal_uInt16* pWhichRange = 0;
    1079             : 
    1080         684 :     switch( nId & (COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID) )
    1081             :     {
    1082             :     case POOLGRP_CHARFMT:
    1083             :         {
    1084         175 :             pArray[0] = pCharFmtTbl;
    1085         175 :             pDeriveFmt = pDfltCharFmt;
    1086             : 
    1087         175 :             if( nId > RES_POOLCHR_NORMAL_END )
    1088           7 :                 nRCId = RC_POOLCHRFMT_HTML_BEGIN - RES_POOLCHR_HTML_BEGIN;
    1089             :             else
    1090         168 :                 nRCId = RC_POOLCHRFMT_BEGIN - RES_POOLCHR_BEGIN;
    1091         175 :             pWhichRange =  aCharFmtSetRange;
    1092             : 
    1093             :             // Fault: unknown Format, but a CharFormat
    1094             :             //             -> return the first one
    1095         175 :             if( RES_POOLCHR_BEGIN > nId || nId >= RES_POOLCHR_END )
    1096             :             {
    1097             :                 OSL_ENSURE( !this, "invalid Id" );
    1098           0 :                 nId = RES_POOLCHR_BEGIN;
    1099             :             }
    1100             :         }
    1101         175 :         break;
    1102             :     case POOLGRP_FRAMEFMT:
    1103             :         {
    1104         509 :             pArray[0] = pFrmFmtTbl;
    1105         509 :             pArray[1] = pSpzFrmFmtTbl;
    1106         509 :             pDeriveFmt = pDfltFrmFmt;
    1107         509 :             nArrCnt = 2;
    1108         509 :             nRCId = RC_POOLFRMFMT_BEGIN - RES_POOLFRM_BEGIN;
    1109         509 :             pWhichRange = aFrmFmtSetRange;
    1110             : 
    1111             :             // Fault: unknown Format, but a FrameFormat
    1112             :             //             -> return the first one
    1113         509 :             if( RES_POOLFRM_BEGIN > nId || nId >= RES_POOLFRM_END )
    1114             :             {
    1115             :                 OSL_ENSURE( !this, "invalid Id" );
    1116           0 :                 nId = RES_POOLFRM_BEGIN;
    1117             :             }
    1118             :         }
    1119         509 :         break;
    1120             : 
    1121             :     default:
    1122             :         // Fault, unknown Format
    1123             :         OSL_ENSURE( nId, "invalid Id" );
    1124           0 :         return 0;
    1125             :     }
    1126             :     OSL_ENSURE( nRCId, "invalid Id" );
    1127             : 
    1128        2189 :     while( nArrCnt-- )
    1129        3148 :         for( sal_uInt16 n = 0; n < (*pArray[nArrCnt]).GetFmtCount(); ++n )
    1130        4654 :             if( nId == ( pNewFmt = (*pArray[ nArrCnt ] ).GetFmt( n ) )->
    1131        2327 :                     GetPoolFmtId() )
    1132             :             {
    1133         372 :                 return pNewFmt;
    1134             :             }
    1135             : 
    1136         312 :     ResId aResId( nRCId + nId, *pSwResMgr );
    1137         312 :     String aNm( aResId );
    1138         312 :     SwAttrSet aSet( GetAttrPool(), pWhichRange );
    1139             : 
    1140             :     {
    1141         312 :         bool bIsModified = IsModified();
    1142             : 
    1143             :         {
    1144         312 :             ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
    1145         312 :             switch (nId & (COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID) )
    1146             :             {
    1147             :                 case POOLGRP_CHARFMT:
    1148          53 :                     pNewFmt = _MakeCharFmt(aNm, pDeriveFmt, false, true);
    1149          53 :                 break;
    1150             :                 case POOLGRP_FRAMEFMT:
    1151         259 :                     pNewFmt = _MakeFrmFmt(aNm, pDeriveFmt, false, true);
    1152         259 :                 break;
    1153             :                 default:
    1154           0 :                 break;
    1155         312 :             }
    1156             :         }
    1157             : 
    1158         312 :         if( !bIsModified )
    1159         203 :             ResetModified();
    1160         312 :         pNewFmt->SetPoolFmtId( nId );
    1161         312 :         pNewFmt->SetAuto( false );      // no AutoFormat
    1162             :     }
    1163             : 
    1164         312 :     switch( nId )
    1165             :     {
    1166             :     case RES_POOLCHR_FOOTNOTE:              // Footnote
    1167             :     case RES_POOLCHR_PAGENO:                // Page/Field
    1168             :     case RES_POOLCHR_LABEL:                 // Label
    1169             :     case RES_POOLCHR_DROPCAPS:              // Dropcaps
    1170             :     case RES_POOLCHR_NUM_LEVEL:             // Numbering level
    1171             :     case RES_POOLCHR_TOXJUMP:               // Table of contents jump
    1172             :     case RES_POOLCHR_ENDNOTE:               // Endnote
    1173             :     case RES_POOLCHR_LINENUM:               // Line numbering
    1174          18 :         break;
    1175             : 
    1176             :     case RES_POOLCHR_ENDNOTE_ANCHOR:        // Endnote anchor
    1177             :     case RES_POOLCHR_FOOTNOTE_ANCHOR:       // Footnote anchor
    1178             :         {
    1179           7 :             aSet.Put( SvxEscapementItem( DFLT_ESC_AUTO_SUPER, 58, RES_CHRATR_ESCAPEMENT ) );
    1180             :         }
    1181           7 :         break;
    1182             : 
    1183             : 
    1184             :     case RES_POOLCHR_BUL_LEVEL:             // Bullet character
    1185             :         {
    1186           1 :             const Font& rBulletFont = numfunc::GetDefBulletFont();
    1187             :             SetAllScriptItem( aSet, SvxFontItem( rBulletFont.GetFamily(),
    1188           1 :                       rBulletFont.GetName(), rBulletFont.GetStyleName(),
    1189           2 :                         rBulletFont.GetPitch(), rBulletFont.GetCharSet(), RES_CHRATR_FONT ));
    1190             :         }
    1191           1 :         break;
    1192             : 
    1193             :     case RES_POOLCHR_INET_NORMAL:
    1194             :         {
    1195          19 :             Color aCol( COL_BLUE );
    1196          19 :             aSet.Put( SvxColorItem( aCol, RES_CHRATR_COLOR ) );
    1197          19 :             aSet.Put( SvxUnderlineItem( UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE ) );
    1198             :             // i40133: patch submitted by rail: set language to 'none' to prevent spell checking:
    1199          19 :             aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_LANGUAGE ) );
    1200          19 :             aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_CJK_LANGUAGE ) );
    1201          19 :             aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_CTL_LANGUAGE ) );
    1202             :         }
    1203          19 :         break;
    1204             :     case RES_POOLCHR_INET_VISIT:
    1205             :         {
    1206           1 :             Color aCol( COL_RED );
    1207           1 :             aSet.Put( SvxColorItem( aCol, RES_CHRATR_COLOR ) );
    1208           1 :             aSet.Put( SvxUnderlineItem( UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE ) );
    1209           1 :             aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_LANGUAGE ) );
    1210           1 :             aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_CJK_LANGUAGE ) );
    1211           1 :             aSet.Put( SvxLanguageItem( LANGUAGE_NONE, RES_CHRATR_CTL_LANGUAGE ) );
    1212             :         }
    1213           1 :         break;
    1214             :     case RES_POOLCHR_JUMPEDIT:
    1215             :         {
    1216           0 :             Color aCol( COL_CYAN );
    1217           0 :             aSet.Put( SvxColorItem( aCol, RES_CHRATR_COLOR ) );
    1218           0 :             aSet.Put( SvxUnderlineItem( UNDERLINE_DOTTED, RES_CHRATR_UNDERLINE ) );
    1219           0 :             aSet.Put( SvxCaseMapItem( SVX_CASEMAP_KAPITAELCHEN, RES_CHRATR_CASEMAP ) );
    1220             :         }
    1221           0 :         break;
    1222             : 
    1223             :     case RES_POOLCHR_RUBYTEXT:
    1224             :         {
    1225             :             long nH = ((SvxFontHeightItem*)GetDfltAttr(
    1226           0 :                                 RES_CHRATR_CJK_FONTSIZE ))->GetHeight() / 2;
    1227           0 :             SetAllScriptItem( aSet, SvxFontHeightItem( nH, 100, RES_CHRATR_FONTSIZE));
    1228           0 :             aSet.Put(SvxUnderlineItem( UNDERLINE_NONE, RES_CHRATR_UNDERLINE ));
    1229           0 :             aSet.Put(SvxEmphasisMarkItem( EMPHASISMARK_NONE, RES_CHRATR_EMPHASIS_MARK) );
    1230             :         }
    1231           0 :         break;
    1232             : 
    1233             :     case RES_POOLCHR_HTML_EMPHASIS:
    1234             :     case RES_POOLCHR_HTML_CITIATION:
    1235             :     case RES_POOLCHR_HTML_VARIABLE:
    1236             :         {
    1237           3 :             SetAllScriptItem( aSet, SvxPostureItem( ITALIC_NORMAL, RES_CHRATR_POSTURE) );
    1238             :         }
    1239           3 :         break;
    1240             : 
    1241             :     case RES_POOLCHR_IDX_MAIN_ENTRY:
    1242             :     case RES_POOLCHR_HTML_STRONG:
    1243             :         {
    1244           4 :             SetAllScriptItem( aSet, SvxWeightItem( WEIGHT_BOLD, RES_CHRATR_WEIGHT ));
    1245             :         }
    1246           4 :         break;
    1247             : 
    1248             :     case RES_POOLCHR_HTML_CODE:
    1249             :     case RES_POOLCHR_HTML_SAMPLE:
    1250             :     case RES_POOLCHR_HTML_KEYBOARD:
    1251             :     case RES_POOLCHR_HTML_TELETYPE:
    1252             :         {
    1253           0 :             ::lcl_SetDfltFont( DEFAULTFONT_FIXED, aSet );
    1254             :         }
    1255           0 :         break;
    1256             :    case RES_POOLCHR_VERT_NUM:
    1257           0 :             aSet.Put( SvxCharRotateItem( 900, sal_False, RES_CHRATR_ROTATE ) );
    1258           0 :     break;
    1259             : 
    1260             :     case RES_POOLFRM_FRAME:
    1261             :         {
    1262         113 :             if ( get(IDocumentSettingAccess::HTML_MODE) )
    1263             :             {
    1264           0 :                 aSet.Put( SwFmtAnchor( FLY_AS_CHAR ));
    1265           0 :                 aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::LINE_CENTER, text::RelOrientation::PRINT_AREA ) );
    1266           0 :                 aSet.Put( SwFmtSurround( SURROUND_NONE ) );
    1267             :             }
    1268             :             else
    1269             :             {
    1270         113 :                 aSet.Put( SwFmtAnchor( FLY_AT_PARA ));
    1271         113 :                 aSet.Put( SwFmtSurround( SURROUND_PARALLEL ) );
    1272         113 :                 aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::PRINT_AREA ) );
    1273         113 :                 aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
    1274         113 :                 Color aCol( COL_BLACK );
    1275         113 :                 SvxBorderLine aLine( &aCol, DEF_LINE_WIDTH_0 );
    1276         113 :                 SvxBoxItem aBox( RES_BOX );
    1277         113 :                 aBox.SetLine( &aLine, BOX_LINE_TOP );
    1278         113 :                 aBox.SetLine( &aLine, BOX_LINE_BOTTOM );
    1279         113 :                 aBox.SetLine( &aLine, BOX_LINE_LEFT );
    1280         113 :                 aBox.SetLine( &aLine, BOX_LINE_RIGHT );
    1281         113 :                 aBox.SetDistance( 85 );
    1282         113 :                 aSet.Put( aBox );
    1283         113 :                 aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) );
    1284         113 :                 aSet.Put( SvxULSpaceItem( 114, 114, RES_UL_SPACE ) );
    1285             :             }
    1286             :         }
    1287         113 :         break;
    1288             :     case RES_POOLFRM_GRAPHIC:
    1289             :     case RES_POOLFRM_OLE:
    1290             :         {
    1291          83 :             aSet.Put( SwFmtAnchor( FLY_AT_PARA ));
    1292          83 :             aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ));
    1293          83 :             aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
    1294          83 :             aSet.Put( SwFmtSurround( SURROUND_IDEAL ));
    1295             :         }
    1296          83 :         break;
    1297             :     case RES_POOLFRM_FORMEL:
    1298             :         {
    1299          63 :             aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) );
    1300          63 :             aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) );
    1301          63 :             aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) );
    1302             :         }
    1303          63 :         break;
    1304             :     case RES_POOLFRM_MARGINAL:
    1305             :         {
    1306           0 :             aSet.Put( SwFmtAnchor( FLY_AT_PARA ));
    1307           0 :             aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME ));
    1308           0 :             aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
    1309           0 :             aSet.Put( SwFmtSurround( SURROUND_PARALLEL ));
    1310             :             // Set the default width to 3.5 cm, use the minimum value for the height
    1311             :             aSet.Put( SwFmtFrmSize( ATT_MIN_SIZE,
    1312           0 :                     GetMetricVal( CM_1 ) * 3 + GetMetricVal( CM_05 ),
    1313           0 :                     MM50 ));
    1314             :         }
    1315           0 :         break;
    1316             :     case RES_POOLFRM_WATERSIGN:
    1317             :         {
    1318           0 :             aSet.Put( SwFmtAnchor( FLY_AT_PAGE ));
    1319           0 :             aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ));
    1320           0 :             aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ));
    1321           0 :             aSet.Put( SvxOpaqueItem( sal_False ));
    1322           0 :             aSet.Put( SwFmtSurround( SURROUND_THROUGHT ));
    1323             :         }
    1324           0 :         break;
    1325             : 
    1326             :     case RES_POOLFRM_LABEL:
    1327             :         {
    1328           0 :             aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) );
    1329           0 :             aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ) );
    1330           0 :             aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) );
    1331             : 
    1332           0 :             SvxProtectItem aProtect( RES_PROTECT );
    1333           0 :             aProtect.SetSizeProtect( sal_True );
    1334           0 :             aProtect.SetPosProtect( sal_True );
    1335           0 :             aSet.Put( aProtect );
    1336             : 
    1337           0 :             pNewFmt->SetAutoUpdateFmt( sal_True );
    1338             :         }
    1339           0 :         break;
    1340             :     }
    1341         312 :     if( aSet.Count() )
    1342             :     {
    1343             :         {
    1344         294 :             pNewFmt->SetFmtAttr( aSet );
    1345             :         }
    1346             :     }
    1347         312 :     return pNewFmt;
    1348             : }
    1349             : 
    1350         509 : SwFrmFmt* SwDoc::GetFrmFmtFromPool( sal_uInt16 nId )
    1351             : {
    1352         509 :     return (SwFrmFmt*)GetFmtFromPool( nId );
    1353             : }
    1354             : 
    1355         175 : SwCharFmt* SwDoc::GetCharFmtFromPool( sal_uInt16 nId )
    1356             : {
    1357         175 :     return (SwCharFmt*)GetFmtFromPool( nId );
    1358             : }
    1359             : 
    1360             : // Check if this AutoCollection is already/still in use
    1361        1283 : bool SwDoc::IsPoolFmtUsed( sal_uInt16 nId ) const
    1362             : {
    1363        1283 :     SwFmt *pNewFmt = 0;
    1364             :     const SwFmtsBase* pArray[ 2 ];
    1365        1283 :     sal_uInt16 nArrCnt = 1;
    1366        1283 :     bool bFnd = true;
    1367             : 
    1368        1283 :     if (RES_POOLCHR_BEGIN <= nId && nId < RES_POOLCHR_END)
    1369             :     {
    1370        1248 :         pArray[0] = pCharFmtTbl;
    1371             :     }
    1372          35 :     else if (RES_POOLFRM_BEGIN <= nId && nId < RES_POOLFRM_END)
    1373             :     {
    1374          35 :         pArray[0] = pFrmFmtTbl;
    1375          35 :         pArray[1] = pSpzFrmFmtTbl;
    1376          35 :         nArrCnt = 2;
    1377             :     }
    1378             :     else
    1379             :     {
    1380             :         SAL_WARN("sw.core", "Invalid Pool Id: " << nId << " should be within " <<
    1381             :             "[" << int(RES_POOLCHR_BEGIN) << "," << int(RES_POOLCHR_END) << ") or " <<
    1382             :             "[" << int(RES_POOLFRM_BEGIN) << "," << int(RES_POOLFRM_END) << ")");
    1383           0 :         bFnd = false;
    1384             :     }
    1385             : 
    1386        1283 :     if( bFnd )
    1387             :     {
    1388        1283 :         bFnd = false;
    1389        3884 :         while( nArrCnt-- && !bFnd )
    1390       15214 :             for( sal_uInt16 n = 0; !bFnd && n < (*pArray[nArrCnt]).GetFmtCount(); ++n )
    1391       27792 :                 if( nId == ( pNewFmt = (*pArray[ nArrCnt ] ).GetFmt( n ) )->
    1392       13896 :                         GetPoolFmtId() )
    1393          48 :                     bFnd = true;
    1394             :     }
    1395             : 
    1396             :     // Not found or no dependecies?
    1397        1283 :     if( bFnd && pNewFmt->GetDepends() )
    1398             :     {
    1399             :         // Check if we have dependent ContentNodes in the Nodes array
    1400             :         // (also indirect ones for derived Formats)
    1401           4 :         SwAutoFmtGetDocNode aGetHt( &GetNodes() );
    1402           4 :         bFnd = !pNewFmt->GetInfo( aGetHt );
    1403             :     }
    1404             :     else
    1405        1279 :         bFnd = false;
    1406             : 
    1407        1283 :     return bFnd;
    1408             : }
    1409             : 
    1410             : 
    1411             : 
    1412          48 : static void lcl_GetStdPgSize( SwDoc* pDoc, SfxItemSet& rSet )
    1413             : {
    1414          48 :     SwPageDesc* pStdPgDsc = pDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
    1415          48 :     SwFmtFrmSize aFrmSz( pStdPgDsc->GetMaster().GetFrmSize() );
    1416          48 :     if( pStdPgDsc->GetLandscape() )
    1417             :     {
    1418           0 :         SwTwips nTmp = aFrmSz.GetHeight();
    1419           0 :         aFrmSz.SetHeight( aFrmSz.GetWidth() );
    1420           0 :         aFrmSz.SetWidth( nTmp );
    1421             :     }
    1422          48 :     rSet.Put( aFrmSz );
    1423          48 : }
    1424             : 
    1425        1466 : SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
    1426             : {
    1427             :     OSL_ENSURE( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END,
    1428             :             "Wrong AutoFormat Id" );
    1429             : 
    1430             :     SwPageDesc *pNewPgDsc;
    1431             :     sal_uInt16 n;
    1432             : 
    1433        1518 :     for( n = 0; n < aPageDescs.size(); ++n )
    1434        1186 :         if( nId == ( pNewPgDsc = aPageDescs[ n ] )->GetPoolFmtId() )
    1435             :         {
    1436        1134 :             return pNewPgDsc;
    1437             :         }
    1438             : 
    1439             :     // error: unknown Pool style
    1440         332 :     if( RES_POOLPAGE_BEGIN > nId ||  nId >= RES_POOLPAGE_END )
    1441             :     {
    1442             :         OSL_ENSURE( !this, "invalid Id" );
    1443           0 :         nId = RES_POOLPAGE_BEGIN;
    1444             :     }
    1445             : 
    1446         332 :     ResId aResId( sal_uInt32(RC_POOLPAGEDESC_BEGIN + nId - RES_POOLPAGE_BEGIN), *pSwResMgr );
    1447         332 :     String aNm( aResId );
    1448             :     {
    1449         332 :         bool bIsModified = IsModified();
    1450             : 
    1451             :         {
    1452         332 :             ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
    1453         332 :             n = MakePageDesc( aNm, 0, bRegardLanguage );
    1454             :         }
    1455             : 
    1456         332 :         pNewPgDsc = aPageDescs[ n ];
    1457         332 :         pNewPgDsc->SetPoolFmtId( nId );
    1458         332 :         if( !bIsModified )
    1459         276 :             ResetModified();
    1460             :     }
    1461             : 
    1462             : 
    1463         332 :     SvxLRSpaceItem aLR( RES_LR_SPACE );
    1464         332 :     aLR.SetLeft( GetMetricVal( CM_1 ) * 2 );
    1465         332 :     aLR.SetRight( aLR.GetLeft() );
    1466         332 :     SvxULSpaceItem aUL( RES_UL_SPACE );
    1467         332 :     aUL.SetUpper( (sal_uInt16)aLR.GetLeft() );
    1468         332 :     aUL.SetLower( (sal_uInt16)aLR.GetLeft() );
    1469             : 
    1470         332 :     SwAttrSet aSet( GetAttrPool(), aPgFrmFmtSetRange );
    1471         332 :     bool bSetLeft = true;
    1472             : 
    1473         332 :     switch( nId )
    1474             :     {
    1475             :     case RES_POOLPAGE_STANDARD:             // Standard page
    1476             :         {
    1477         284 :             aSet.Put( aLR );
    1478         284 :             aSet.Put( aUL );
    1479         284 :             if( pNewPgDsc )
    1480         284 :                 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL | nsUseOnPage::PD_FIRSTSHARE );
    1481             :         }
    1482         284 :         break;
    1483             : 
    1484             :     case RES_POOLPAGE_FIRST:                // First page
    1485             :     case RES_POOLPAGE_REGISTER:             // ToX
    1486             :         {
    1487          47 :             lcl_GetStdPgSize( this, aSet );
    1488          47 :             aSet.Put( aLR );
    1489          47 :             aSet.Put( aUL );
    1490          47 :             if( pNewPgDsc )
    1491             :             {
    1492          47 :                 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
    1493          47 :                 if( RES_POOLPAGE_FIRST == nId )
    1494          47 :                     pNewPgDsc->SetFollow( GetPageDescFromPool( RES_POOLPAGE_STANDARD ));
    1495             :             }
    1496             :         }
    1497          47 :         break;
    1498             : 
    1499             :     case RES_POOLPAGE_LEFT:                 // Left page
    1500             :         {
    1501           0 :             lcl_GetStdPgSize( this, aSet );
    1502           0 :             aSet.Put( aLR );
    1503           0 :             aSet.Put( aUL );
    1504           0 :             bSetLeft = false;
    1505           0 :             if( pNewPgDsc )
    1506             :             {
    1507           0 :                 pNewPgDsc->SetUseOn( nsUseOnPage::PD_LEFT );
    1508             :                 // this relies on GetPageDescFromPool() not going into infinite recursion
    1509             :                 // (by this point RES_POOLPAGE_LEFT will not reach this place again)
    1510           0 :                 pNewPgDsc->SetFollow( GetPageDescFromPool( RES_POOLPAGE_RIGHT ));
    1511             :             }
    1512             :         }
    1513           0 :         break;
    1514             :     case RES_POOLPAGE_RIGHT:                // Right page
    1515             :         {
    1516           0 :             lcl_GetStdPgSize( this, aSet );
    1517           0 :             aSet.Put( aLR );
    1518           0 :             aSet.Put( aUL );
    1519           0 :             bSetLeft = false;
    1520           0 :             if( pNewPgDsc )
    1521             :             {
    1522           0 :                 pNewPgDsc->SetUseOn( nsUseOnPage::PD_RIGHT );
    1523           0 :                 pNewPgDsc->SetFollow( GetPageDescFromPool( RES_POOLPAGE_LEFT ));
    1524             :             }
    1525             :         }
    1526           0 :         break;
    1527             : 
    1528             :     case RES_POOLPAGE_JAKET:                // envelope
    1529             :         {
    1530           0 :             aLR.SetLeft( 0 ); aLR.SetRight( 0 );
    1531           0 :             aUL.SetUpper( 0 ); aUL.SetLower( 0 );
    1532           0 :             Size aPSize( SvxPaperInfo::GetPaperSize( PAPER_ENV_C65 ) );
    1533           0 :             LandscapeSwap( aPSize );
    1534           0 :             aSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, aPSize.Width(), aPSize.Height() ));
    1535           0 :             aSet.Put( aLR );
    1536           0 :             aSet.Put( aUL );
    1537             : 
    1538           0 :             if( pNewPgDsc )
    1539             :             {
    1540           0 :                 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
    1541           0 :                 pNewPgDsc->SetLandscape( sal_True );
    1542             :             }
    1543             :         }
    1544           0 :         break;
    1545             : 
    1546             :     case RES_POOLPAGE_HTML:             // HTML
    1547             :         {
    1548           0 :             lcl_GetStdPgSize( this, aSet );
    1549           0 :             aLR.SetRight( GetMetricVal( CM_1 ));
    1550           0 :             aUL.SetUpper( (sal_uInt16)aLR.GetRight() );
    1551           0 :             aUL.SetLower( (sal_uInt16)aLR.GetRight() );
    1552           0 :             aSet.Put( aLR );
    1553           0 :             aSet.Put( aUL );
    1554             : 
    1555           0 :             if( pNewPgDsc )
    1556           0 :                 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
    1557             :         }
    1558           0 :         break;
    1559             :     case RES_POOLPAGE_FOOTNOTE:
    1560             :     case RES_POOLPAGE_ENDNOTE:
    1561             :         {
    1562           1 :             lcl_GetStdPgSize( this, aSet );
    1563           1 :             aSet.Put( aLR );
    1564           1 :             aSet.Put( aUL );
    1565           1 :             if( pNewPgDsc )
    1566           1 :                 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
    1567           1 :             SwPageFtnInfo aInf( pNewPgDsc->GetFtnInfo() );
    1568           1 :             aInf.SetLineWidth( 0 );
    1569           1 :             aInf.SetTopDist( 0 );
    1570           1 :             aInf.SetBottomDist( 0 );
    1571           1 :             pNewPgDsc->SetFtnInfo( aInf );
    1572             :         }
    1573           1 :         break;
    1574             :         case RES_POOLPAGE_LANDSCAPE:
    1575             :         {
    1576           0 :             SwPageDesc* pStdPgDsc = this->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
    1577           0 :             SwFmtFrmSize aFrmSz( pStdPgDsc->GetMaster().GetFrmSize() );
    1578           0 :             SwTwips nTmp = aFrmSz.GetHeight();
    1579           0 :             aFrmSz.SetHeight( aFrmSz.GetWidth() );
    1580           0 :             aFrmSz.SetWidth( nTmp );
    1581           0 :             aSet.Put( aFrmSz );
    1582           0 :             aSet.Put( aLR );
    1583           0 :             aSet.Put( aUL );
    1584           0 :             if( pNewPgDsc )
    1585             :             {
    1586           0 :                 pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
    1587           0 :                 pNewPgDsc->SetLandscape( sal_True );
    1588           0 :             }
    1589             :        }
    1590           0 :        break;
    1591             : 
    1592             :     }
    1593             : 
    1594         332 :     if( aSet.Count() )
    1595             :     {
    1596             :         {
    1597         332 :             if( bSetLeft )
    1598         332 :                 pNewPgDsc->GetLeft().SetFmtAttr( aSet );
    1599         332 :             pNewPgDsc->GetMaster().SetFmtAttr( aSet );
    1600             :         }
    1601             :     }
    1602         332 :     return pNewPgDsc;
    1603             : }
    1604             : 
    1605           2 : SwNumRule* SwDoc::GetNumRuleFromPool( sal_uInt16 nId )
    1606             : {
    1607             :     OSL_ENSURE( RES_POOLNUMRULE_BEGIN <= nId && nId < RES_POOLNUMRULE_END,
    1608             :             "Wrong AutoFormat Id" );
    1609             : 
    1610             :     SwNumRule* pNewRule;
    1611             :     sal_uInt16 n;
    1612             : 
    1613           5 :     for( n = 0; n < GetNumRuleTbl().size(); ++n )
    1614           3 :         if( nId == ( pNewRule = GetNumRuleTbl()[ n ] )->GetPoolFmtId() )
    1615             :         {
    1616           0 :             return pNewRule;
    1617             :         }
    1618             : 
    1619             :     // error: unknown Pool style
    1620           2 :     if( RES_POOLNUMRULE_BEGIN > nId ||  nId >= RES_POOLNUMRULE_END )
    1621             :     {
    1622             :         OSL_ENSURE( !this, "invalid Id" );
    1623           0 :         nId = RES_POOLNUMRULE_BEGIN;
    1624             :     }
    1625             : 
    1626           2 :     ResId aResId( sal_uInt32(RC_POOLNUMRULE_BEGIN + nId - RES_POOLNUMRULE_BEGIN), *pSwResMgr );
    1627           2 :     String aNm( aResId );
    1628             : 
    1629           2 :     SwCharFmt *pNumCFmt = 0, *pBullCFmt = 0;
    1630             : 
    1631             :     const SvxNumberFormat::SvxNumPositionAndSpaceMode eNumberFormatPositionAndSpaceMode
    1632           2 :                                   = numfunc::GetDefaultPositionAndSpaceMode(); //#i89178#
    1633             :     {
    1634           2 :         bool bIsModified = IsModified();
    1635             : 
    1636           2 :         n = MakeNumRule( aNm, 0, false, eNumberFormatPositionAndSpaceMode );
    1637             : 
    1638           2 :         pNewRule = GetNumRuleTbl()[ n ];
    1639           2 :         pNewRule->SetPoolFmtId( nId );
    1640           2 :         pNewRule->SetAutoRule( sal_False );
    1641             : 
    1642           2 :         if( RES_POOLNUMRULE_NUM1 <= nId && nId <= RES_POOLNUMRULE_NUM5 )
    1643           1 :             pNumCFmt = GetCharFmtFromPool( RES_POOLCHR_NUM_LEVEL );
    1644             : 
    1645           2 :         if( ( RES_POOLNUMRULE_BUL1 <= nId && nId <= RES_POOLNUMRULE_BUL5 ) ||
    1646             :             RES_POOLNUMRULE_NUM5 == nId )
    1647           1 :             pBullCFmt = GetCharFmtFromPool( RES_POOLCHR_NUM_LEVEL );
    1648             : 
    1649           2 :         if( !bIsModified )
    1650           0 :             ResetModified();
    1651             :     }
    1652             : 
    1653           2 :     switch( nId )
    1654             :     {
    1655             :     case RES_POOLNUMRULE_NUM1:
    1656             :         {
    1657           1 :             SwNumFmt aFmt;
    1658           1 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    1659           1 :             aFmt.SetNumberingType(SVX_NUM_ARABIC);
    1660           1 :             aFmt.SetCharFmt( pNumCFmt );
    1661           1 :             aFmt.SetStart( 1 );
    1662           1 :             aFmt.SetIncludeUpperLevels( 1 );
    1663           1 :             aFmt.SetSuffix( aDotStr );
    1664             : 
    1665             :             static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
    1666             :                 {
    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
    1669             :                 };
    1670             : #ifdef USE_MEASUREMENT
    1671             :             static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
    1672             :                 {
    1673             :                     283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835
    1674             :                 };
    1675             :             const sal_uInt16* pArr = MEASURE_METRIC ==
    1676             :                                 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
    1677             :                                     ? aAbsSpace
    1678             :                                     : aAbsSpaceInch;
    1679             : #else
    1680           1 :             const sal_uInt16* pArr = aAbsSpace;
    1681             : #endif
    1682             : 
    1683           1 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1684             :             {
    1685           0 :                 aFmt.SetFirstLineOffset( - (*pArr) );
    1686             :             }
    1687           1 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1688             :             {
    1689           1 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
    1690           1 :                 aFmt.SetFirstLineIndent( - (*pArr) );
    1691             :             }
    1692             : 
    1693          11 :             for( n = 0; n < MAXLEVEL; ++n, ++pArr )
    1694             :             {
    1695          10 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1696             :                 {
    1697           0 :                     aFmt.SetAbsLSpace( *pArr );
    1698             :                 }
    1699          10 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1700             :                 {
    1701          10 :                     aFmt.SetListtabPos( *pArr );
    1702          10 :                     aFmt.SetIndentAt( *pArr );
    1703             :                 }
    1704             : 
    1705          10 :                 pNewRule->Set( n, aFmt );
    1706           1 :             }
    1707             :         }
    1708           1 :         break;
    1709             : 
    1710             :     case RES_POOLNUMRULE_NUM2:
    1711             :         {
    1712             :             static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
    1713             :                 {
    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
    1717             :                 };
    1718             : 
    1719             : #ifdef USE_MEASUREMENT
    1720             :             static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
    1721             :                 {
    1722             :                     385,  385,  770,  963,
    1723             :                    1155, 1386, 1771, 2002,
    1724             :                    2156, 2387
    1725             :                 };
    1726             : 
    1727             :             const sal_uInt16* pArr = MEASURE_METRIC ==
    1728             :                                 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
    1729             :                                     ? aAbsSpace
    1730             :                                     : aAbsSpaceInch;
    1731             : #else
    1732           0 :             const sal_uInt16* pArr = aAbsSpace;
    1733             : #endif
    1734           0 :             SwNumFmt aFmt;
    1735             : 
    1736           0 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    1737           0 :             aFmt.SetNumberingType(SVX_NUM_ARABIC);
    1738           0 :             aFmt.SetCharFmt( pNumCFmt );
    1739           0 :             aFmt.SetIncludeUpperLevels( 1 );
    1740             : 
    1741           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1742             :             {
    1743           0 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
    1744             :             }
    1745             : 
    1746           0 :             sal_uInt16 nSpace = 0;
    1747           0 :             for( n = 0; n < MAXLEVEL; ++n )
    1748             :             {
    1749           0 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1750             :                 {
    1751           0 :                     aFmt.SetAbsLSpace( nSpace = nSpace + pArr[ n ] );
    1752           0 :                     aFmt.SetFirstLineOffset( - pArr[ n ] );
    1753             :                 }
    1754           0 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1755             :                 {
    1756           0 :                     aFmt.SetListtabPos( nSpace = nSpace + pArr[ n ] );
    1757           0 :                     aFmt.SetIndentAt( nSpace );
    1758           0 :                     aFmt.SetFirstLineIndent( - pArr[ n ] );
    1759             :                 }
    1760             : 
    1761           0 :                 aFmt.SetStart( n+1 );
    1762           0 :                 pNewRule->Set( n, aFmt );
    1763           0 :             }
    1764             :         }
    1765           0 :         break;
    1766             :     case RES_POOLNUMRULE_NUM3:
    1767             :         {
    1768           0 :             SwNumFmt aFmt;
    1769             : 
    1770           0 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    1771           0 :             aFmt.SetNumberingType(SVX_NUM_ARABIC);
    1772           0 :             aFmt.SetCharFmt( pNumCFmt );
    1773           0 :             aFmt.SetIncludeUpperLevels( 1 );
    1774             : 
    1775           0 :             sal_uInt16 nOffs = GetMetricVal( CM_1 ) * 3;
    1776             : 
    1777           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1778             :             {
    1779           0 :                 aFmt.SetFirstLineOffset( - nOffs );
    1780             :             }
    1781           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1782             :             {
    1783           0 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
    1784           0 :                 aFmt.SetFirstLineIndent( - nOffs );
    1785             :             }
    1786             : 
    1787           0 :             for( n = 0; n < MAXLEVEL; ++n )
    1788             :             {
    1789           0 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1790             :                 {
    1791           0 :                     aFmt.SetAbsLSpace( (n+1) * nOffs );
    1792             :                 }
    1793           0 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1794             :                 {
    1795           0 :                     aFmt.SetListtabPos( (n+1) * nOffs );
    1796           0 :                     aFmt.SetIndentAt( (n+1) * nOffs );
    1797             :                 }
    1798             : 
    1799           0 :                 aFmt.SetStart( n+1 );
    1800           0 :                 pNewRule->Set( n, aFmt );
    1801           0 :             }
    1802             :         }
    1803           0 :         break;
    1804             :     case RES_POOLNUMRULE_NUM4:
    1805             :         {
    1806           0 :             SwNumFmt aFmt;
    1807             : 
    1808           0 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    1809           0 :             aFmt.SetNumberingType(SVX_NUM_ROMAN_UPPER);
    1810           0 :             aFmt.SetCharFmt( pNumCFmt );
    1811           0 :             aFmt.SetIncludeUpperLevels( 1 );
    1812           0 :             aFmt.SetSuffix( aDotStr );
    1813             : 
    1814             :             static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
    1815             :                 {
    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
    1818             :                 };
    1819             : #ifdef USE_MEASUREMENT
    1820             :             static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
    1821             :                 {
    1822             :                     283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835
    1823             :                 };
    1824             :             const sal_uInt16* pArr = MEASURE_METRIC ==
    1825             :                                 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
    1826             :                                     ? aAbsSpace
    1827             :                                     : aAbsSpaceInch;
    1828             : #else
    1829           0 :             const sal_uInt16* pArr = aAbsSpace;
    1830             : #endif
    1831             : 
    1832           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1833             :             {
    1834           0 :                 aFmt.SetFirstLineOffset( - (*pArr) );
    1835             :             }
    1836           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1837             :             {
    1838           0 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::SPACE );
    1839           0 :                 aFmt.SetFirstLineIndent( - (*pArr) );
    1840             :             }
    1841             : 
    1842           0 :             for( n = 0; n < MAXLEVEL; ++n, ++pArr )
    1843             :             {
    1844           0 :                 aFmt.SetStart( n + 1 );
    1845             : 
    1846           0 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1847             :                 {
    1848           0 :                     aFmt.SetAbsLSpace( *pArr );
    1849             :                 }
    1850           0 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1851             :                 {
    1852           0 :                     aFmt.SetListtabPos( *pArr );
    1853           0 :                     aFmt.SetIndentAt( *pArr );
    1854             :                 }
    1855             : 
    1856           0 :                 pNewRule->Set( n, aFmt );
    1857           0 :             }
    1858             :         }
    1859           0 :         break;
    1860             :     case RES_POOLNUMRULE_NUM5:
    1861             :         {
    1862             :             // [ First, LSpace ]
    1863             :             static const sal_uInt16 aAbsSpace0to2[] =
    1864             :                 {
    1865             :                     227,  227,      // 0.40, 0.40,
    1866             :                     369,  624,      // 0.65, 1.10,
    1867             :                     255,  879       // 0.45, 1.55
    1868             :                 };
    1869             : 
    1870             : #ifdef USE_MEASUREMENT
    1871             :             static const sal_uInt16 aAbsSpaceInch0to2[] =
    1872             :                 {
    1873             :                     308,  308,
    1874             :                     501,  847,
    1875             :                     347, 1194
    1876             :                 };
    1877             :             const sal_uInt16* pArr0to2 = MEASURE_METRIC ==
    1878             :                             SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
    1879             :                                 ? aAbsSpace0to2
    1880             :                                 : aAbsSpaceInch0to2;
    1881             : #else
    1882           0 :             const sal_uInt16* pArr0to2 = aAbsSpace0to2;
    1883             : #endif
    1884           0 :             SwNumFmt aFmt;
    1885             : 
    1886           0 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    1887           0 :             aFmt.SetNumberingType(SVX_NUM_ARABIC);
    1888           0 :             aFmt.SetStart( 1 );
    1889           0 :             aFmt.SetIncludeUpperLevels( 1 );
    1890           0 :             aFmt.SetSuffix( aDotStr );
    1891             : 
    1892           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1893             :             {
    1894           0 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
    1895             :             }
    1896             : 
    1897           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1898             :             {
    1899           0 :                 aFmt.SetFirstLineOffset( -pArr0to2[0] );    // == 0.40 cm
    1900           0 :                 aFmt.SetAbsLSpace( pArr0to2[1] );           // == 0.40 cm
    1901             :             }
    1902           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1903             :             {
    1904           0 :                 aFmt.SetFirstLineIndent( -pArr0to2[0] );
    1905           0 :                 aFmt.SetListtabPos( pArr0to2[1] );
    1906           0 :                 aFmt.SetIndentAt( pArr0to2[1] );
    1907             :             }
    1908             : 
    1909           0 :             aFmt.SetCharFmt( pNumCFmt );
    1910           0 :             pNewRule->Set( 0, aFmt );
    1911             : 
    1912           0 :             aFmt.SetIncludeUpperLevels( 2 );
    1913           0 :             aFmt.SetStart( 2 );
    1914             : 
    1915           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1916             :             {
    1917           0 :                 aFmt.SetFirstLineOffset( -pArr0to2[2] );    // == 0.65 cm
    1918           0 :                 aFmt.SetAbsLSpace( pArr0to2[3] );           // == 1.10 cm
    1919             :             }
    1920           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1921             :             {
    1922           0 :                 aFmt.SetFirstLineIndent( -pArr0to2[2] );
    1923           0 :                 aFmt.SetListtabPos( pArr0to2[3] );
    1924           0 :                 aFmt.SetIndentAt( pArr0to2[3] );
    1925             :             }
    1926             : 
    1927           0 :             pNewRule->Set( 1, aFmt );
    1928             : 
    1929           0 :             aFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER);
    1930           0 :             aFmt.SetSuffix(rtl::OUString(static_cast<sal_Unicode>(')')));
    1931           0 :             aFmt.SetIncludeUpperLevels( 1 );
    1932           0 :             aFmt.SetStart( 3 );
    1933             : 
    1934           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1935             :             {
    1936           0 :                 aFmt.SetFirstLineOffset( - pArr0to2[4] );   // == 0.45cm
    1937           0 :                 aFmt.SetAbsLSpace( pArr0to2[5] );           // == 1.55 cm
    1938             :             }
    1939           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1940             :             {
    1941           0 :                 aFmt.SetFirstLineIndent( -pArr0to2[4] );
    1942           0 :                 aFmt.SetListtabPos( pArr0to2[5] );
    1943           0 :                 aFmt.SetIndentAt( pArr0to2[5] );
    1944             :             }
    1945             : 
    1946           0 :             pNewRule->Set( 2, aFmt );
    1947             : 
    1948             : 
    1949           0 :             aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
    1950           0 :             aFmt.SetCharFmt( pBullCFmt );
    1951           0 :             aFmt.SetBulletFont(  &numfunc::GetDefBulletFont() );
    1952           0 :             aFmt.SetBulletChar( cBulletChar );
    1953           0 :             sal_uInt16 nOffs = GetMetricVal( CM_01 ) * 4,
    1954           0 :                    nOffs2 = GetMetricVal( CM_1 ) * 2;
    1955             : 
    1956           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1957             :             {
    1958           0 :                 aFmt.SetFirstLineOffset( - nOffs );
    1959             :             }
    1960           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1961             :             {
    1962           0 :                 aFmt.SetFirstLineIndent( - nOffs );
    1963             :             }
    1964             : 
    1965           0 :             aFmt.SetSuffix( aEmptyStr );
    1966           0 :             for( n = 3; n < MAXLEVEL; ++n )
    1967             :             {
    1968           0 :                 aFmt.SetStart( n+1 );
    1969             : 
    1970           0 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    1971             :                 {
    1972           0 :                     aFmt.SetAbsLSpace( nOffs2 + ((n-3) * nOffs) );
    1973             :                 }
    1974           0 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    1975             :                 {
    1976           0 :                     aFmt.SetListtabPos( nOffs2 + ((n-3) * nOffs) );
    1977           0 :                     aFmt.SetIndentAt( nOffs2 + ((n-3) * nOffs) );
    1978             :                 }
    1979             : 
    1980           0 :                 pNewRule->Set( n, aFmt );
    1981           0 :             }
    1982             :         }
    1983           0 :         break;
    1984             : 
    1985             :     case RES_POOLNUMRULE_BUL1:
    1986             :         {
    1987           1 :             SwNumFmt aFmt;
    1988             : 
    1989           1 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    1990           1 :             aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
    1991           1 :             aFmt.SetCharFmt( pBullCFmt );
    1992           1 :             aFmt.SetStart( 1 );
    1993           1 :             aFmt.SetIncludeUpperLevels( 1 );
    1994           1 :             aFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
    1995           1 :             aFmt.SetBulletChar( cBulletChar );
    1996             : 
    1997             :             static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
    1998             :                 {
    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
    2001             :                 };
    2002             : #ifdef USE_MEASUREMENT
    2003             :             static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
    2004             :                 {
    2005             :                     227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
    2006             :                 };
    2007             :             const sal_uInt16* pArr = MEASURE_METRIC ==
    2008             :                                 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
    2009             :                                     ? aAbsSpace
    2010             :                                     : aAbsSpaceInch;
    2011             : #else
    2012           1 :             const sal_uInt16* pArr = aAbsSpace;
    2013             : #endif
    2014             : 
    2015           1 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2016             :             {
    2017           0 :                 aFmt.SetFirstLineOffset( - (*pArr) );
    2018             :             }
    2019           1 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2020             :             {
    2021           1 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
    2022           1 :                 aFmt.SetFirstLineIndent( - (*pArr) );
    2023             :             }
    2024             : 
    2025          11 :             for( n = 0; n < MAXLEVEL; ++n, ++pArr )
    2026             :             {
    2027          10 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2028             :                 {
    2029           0 :                     aFmt.SetAbsLSpace( *pArr );
    2030             :                 }
    2031          10 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2032             :                 {
    2033          10 :                     aFmt.SetListtabPos( *pArr );
    2034          10 :                     aFmt.SetIndentAt( *pArr );
    2035             :                 }
    2036             : 
    2037          10 :                 pNewRule->Set( n, aFmt );
    2038           1 :             }
    2039             :         }
    2040           1 :         break;
    2041             :     case RES_POOLNUMRULE_BUL2:
    2042             :         {
    2043           0 :             SwNumFmt aFmt;
    2044             : 
    2045           0 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    2046           0 :             aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
    2047           0 :             aFmt.SetCharFmt( pBullCFmt );
    2048           0 :             aFmt.SetStart( 1 );
    2049           0 :             aFmt.SetIncludeUpperLevels( 1 );
    2050           0 :             aFmt.SetBulletFont(  &numfunc::GetDefBulletFont() );
    2051           0 :             aFmt.SetBulletChar( 0x2013 );
    2052             : 
    2053             :             static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
    2054             :                 {
    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
    2057             :                 };
    2058             : #ifdef USE_MEASUREMENT
    2059             :             static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
    2060             :                 {
    2061             :                     170, 340, 510, 680, 850, 1020, 1191, 1361, 1531, 1701
    2062             :                 };
    2063             :             const sal_uInt16* pArr = MEASURE_METRIC ==
    2064             :                                 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
    2065             :                                     ? aAbsSpace
    2066             :                                     : aAbsSpaceInch;
    2067             : #else
    2068           0 :             const sal_uInt16* pArr = aAbsSpace;
    2069             : #endif
    2070             : 
    2071           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2072             :             {
    2073           0 :                 aFmt.SetFirstLineOffset( - (*pArr) );
    2074             :             }
    2075           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2076             :             {
    2077           0 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
    2078           0 :                 aFmt.SetFirstLineIndent( - (*pArr) );
    2079             :             }
    2080             : 
    2081           0 :             for( n = 0; n < MAXLEVEL; ++n, ++pArr )
    2082             :             {
    2083           0 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2084             :                 {
    2085           0 :                     aFmt.SetAbsLSpace( *pArr );
    2086             :                 }
    2087           0 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2088             :                 {
    2089           0 :                     aFmt.SetListtabPos( *pArr );
    2090           0 :                     aFmt.SetIndentAt( *pArr );
    2091             :                 }
    2092             : 
    2093           0 :                 pNewRule->Set( n, aFmt );
    2094           0 :             }
    2095             :         }
    2096           0 :         break;
    2097             :     case RES_POOLNUMRULE_BUL3:
    2098             :         {
    2099           0 :             SwNumFmt aFmt;
    2100             : 
    2101           0 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    2102             : 
    2103           0 :             aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
    2104           0 :             aFmt.SetCharFmt( pBullCFmt );
    2105           0 :             aFmt.SetStart( 1 );
    2106           0 :             aFmt.SetIncludeUpperLevels( 1 );
    2107           0 :             aFmt.SetBulletFont(  &numfunc::GetDefBulletFont() );
    2108             : 
    2109           0 :             sal_uInt16 nOffs = GetMetricVal( CM_01 ) * 4;
    2110             : 
    2111           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2112             :             {
    2113           0 :                 aFmt.SetFirstLineOffset( - nOffs );
    2114             :             }
    2115           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2116             :             {
    2117           0 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
    2118           0 :                 aFmt.SetFirstLineIndent( - nOffs );
    2119             :             }
    2120             : 
    2121           0 :             for( n = 0; n < MAXLEVEL; ++n )
    2122             :             {
    2123           0 :                 aFmt.SetBulletChar( ( n & 1 ? 0x25a1 : 0x2611 ) );
    2124             : 
    2125           0 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2126             :                 {
    2127           0 :                     aFmt.SetAbsLSpace( ((n & 1) +1) * nOffs );
    2128             :                 }
    2129           0 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2130             :                 {
    2131           0 :                     aFmt.SetListtabPos( ((n & 1) +1) * nOffs );
    2132           0 :                     aFmt.SetIndentAt( ((n & 1) +1) * nOffs );
    2133             :                 }
    2134             : 
    2135           0 :                 pNewRule->Set( n, aFmt );
    2136           0 :             }
    2137             :         }
    2138           0 :         break;
    2139             :     case RES_POOLNUMRULE_BUL4:
    2140             :         {
    2141           0 :             SwNumFmt aFmt;
    2142             : 
    2143           0 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    2144           0 :             aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
    2145           0 :             aFmt.SetCharFmt( pBullCFmt );
    2146           0 :             aFmt.SetStart( 1 );
    2147           0 :             aFmt.SetIncludeUpperLevels( 1 );
    2148           0 :             aFmt.SetBulletFont(  &numfunc::GetDefBulletFont() );
    2149             : 
    2150             :             static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
    2151             :                 {
    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
    2154             :                 };
    2155             : #ifdef USE_MEASUREMENT
    2156             :             static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
    2157             :                 {
    2158             :                     227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
    2159             :                 };
    2160             :             const sal_uInt16* pArr = MEASURE_METRIC ==
    2161             :                                 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
    2162             :                                     ? aAbsSpace
    2163             :                                     : aAbsSpaceInch;
    2164             : #else
    2165           0 :             const sal_uInt16* pArr = aAbsSpace;
    2166             : #endif
    2167             : 
    2168           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2169             :             {
    2170           0 :                 aFmt.SetFirstLineOffset( - (*pArr) );
    2171             :             }
    2172           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2173             :             {
    2174           0 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::SPACE );
    2175           0 :                 aFmt.SetFirstLineIndent( - (*pArr) );
    2176             :             }
    2177             : 
    2178           0 :             for( n = 0; n < MAXLEVEL; ++n, ++pArr )
    2179             :             {
    2180           0 :                 switch( n )
    2181             :                 {
    2182           0 :                 case 0:     aFmt.SetBulletChar( 0x27a2 );   break;
    2183           0 :                 case 1:     aFmt.SetBulletChar( 0xE006 );   break;
    2184           0 :                 default:    aFmt.SetBulletChar( 0xE004 );   break;
    2185             :                 }
    2186             : 
    2187           0 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2188             :                 {
    2189           0 :                     aFmt.SetAbsLSpace( *pArr );
    2190             :                 }
    2191           0 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2192             :                 {
    2193           0 :                     aFmt.SetListtabPos( *pArr );
    2194           0 :                     aFmt.SetIndentAt( *pArr );
    2195             :                 }
    2196             : 
    2197           0 :                 pNewRule->Set( n, aFmt );
    2198           0 :             }
    2199             :         }
    2200           0 :         break;
    2201             :     case RES_POOLNUMRULE_BUL5:
    2202             :         {
    2203           0 :             SwNumFmt aFmt;
    2204             : 
    2205           0 :             aFmt.SetPositionAndSpaceMode( eNumberFormatPositionAndSpaceMode );
    2206           0 :             aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
    2207           0 :             aFmt.SetCharFmt( pBullCFmt );
    2208           0 :             aFmt.SetStart( 1 );
    2209           0 :             aFmt.SetIncludeUpperLevels( 1 );
    2210           0 :             aFmt.SetBulletChar( 0x2717 );
    2211           0 :             aFmt.SetBulletFont( &numfunc::GetDefBulletFont() );
    2212             : 
    2213             :             static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
    2214             :                 {
    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
    2217             :                 };
    2218             : #ifdef USE_MEASUREMENT
    2219             :             static const sal_uInt16 aAbsSpaceInch[ MAXLEVEL ] =
    2220             :                 {
    2221             :                     227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268
    2222             :                 };
    2223             :             const sal_uInt16* pArr = MEASURE_METRIC ==
    2224             :                                 SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()
    2225             :                                     ? aAbsSpace
    2226             :                                     : aAbsSpaceInch;
    2227             : #else
    2228           0 :             const sal_uInt16* pArr = aAbsSpace;
    2229             : #endif
    2230             : 
    2231           0 :             if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2232             :             {
    2233           0 :                 aFmt.SetFirstLineOffset( - (*pArr) );
    2234             :             }
    2235           0 :             else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2236             :             {
    2237           0 :                 aFmt.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
    2238           0 :                 aFmt.SetFirstLineIndent( - (*pArr) );
    2239             :             }
    2240             : 
    2241           0 :             for( n = 0; n < MAXLEVEL; ++n, ++pArr )
    2242             :             {
    2243           0 :                 if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
    2244             :                 {
    2245           0 :                     aFmt.SetAbsLSpace( *pArr );
    2246             :                 }
    2247           0 :                 else if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
    2248             :                 {
    2249           0 :                     aFmt.SetListtabPos( *pArr );
    2250           0 :                     aFmt.SetIndentAt( *pArr );
    2251             :                 }
    2252             : 
    2253           0 :                 pNewRule->Set( n, aFmt );
    2254           0 :             }
    2255             :         }
    2256           0 :         break;
    2257             :     }
    2258             : 
    2259           2 :     return pNewRule;
    2260             : }
    2261             : 
    2262             : 
    2263             : 
    2264             : // Check if this AutoCollection is already/still in use in this Document
    2265         480 : bool SwDoc::IsPoolPageDescUsed( sal_uInt16 nId ) const
    2266             : {
    2267             :     OSL_ENSURE( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END,
    2268             :             "Wrong AutoFormat Id" );
    2269         480 :     SwPageDesc *pNewPgDsc = 0;
    2270         480 :     bool bFnd = false;
    2271        1494 :     for( sal_uInt16 n = 0; !bFnd && n < aPageDescs.size(); ++n )
    2272             :     {
    2273        1014 :         pNewPgDsc = aPageDescs[ n ];
    2274        1014 :         if( nId == pNewPgDsc->GetPoolFmtId() )
    2275          65 :             bFnd = true;
    2276             :     }
    2277             : 
    2278             :     // Not found or no dependencies?
    2279         480 :     if( !bFnd || !pNewPgDsc->GetDepends() )     // ??????
    2280         431 :         return false;
    2281             : 
    2282             :     // Check if we have dependent ContentNodes in the Nodes array
    2283             :     // (also indirect ones for derived Formats)
    2284          49 :     SwAutoFmtGetDocNode aGetHt( &GetNodes() );
    2285          49 :     return !pNewPgDsc->GetInfo( aGetHt );
    2286             : }
    2287             : 
    2288             : // See if the Paragraph/Character/Frame/Page style is in use
    2289        4135 : bool SwDoc::IsUsed( const SwModify& rModify ) const
    2290             : {
    2291             :     // Check if we have dependent ContentNodes in the Nodes array
    2292             :     // (also indirect ones for derived Formats)
    2293        4135 :     SwAutoFmtGetDocNode aGetHt( &GetNodes() );
    2294        4135 :     return !rModify.GetInfo( aGetHt );
    2295             : }
    2296             : 
    2297             : // See if the NumRule is used
    2298          35 : bool SwDoc::IsUsed( const SwNumRule& rRule ) const
    2299             : {
    2300          35 :     bool bUsed = rRule.GetTxtNodeListSize() > 0 ||
    2301          35 :                      rRule.GetParagraphStyleListSize() > 0;
    2302             : 
    2303          35 :     return bUsed;
    2304             : }
    2305             : 
    2306             : // Look for the style name's position. If it doesn't exist,
    2307             : // insert a anew
    2308           0 : sal_uInt16 SwDoc::SetDocPattern( const String& rPatternName )
    2309             : {
    2310             :     OSL_ENSURE( rPatternName.Len(), "no Document style name" );
    2311             : 
    2312           0 :     size_t nNewPos = aPatternNms.size();
    2313           0 :     for(size_t n = 0; n < aPatternNms.size(); ++n)
    2314           0 :         if( boost::is_null(aPatternNms.begin() + n) )
    2315             :         {
    2316           0 :             if( nNewPos == aPatternNms.size() )
    2317           0 :                 nNewPos = n;
    2318             :         }
    2319           0 :         else if( rPatternName == aPatternNms[n] )
    2320           0 :             return n;
    2321             : 
    2322           0 :     if( nNewPos < aPatternNms.size() )
    2323           0 :         aPatternNms.erase(aPatternNms.begin() + nNewPos);   // Free space again
    2324             : 
    2325           0 :     aPatternNms.insert(aPatternNms.begin() + nNewPos, new String(rPatternName));
    2326           0 :     SetModified();
    2327           0 :     return nNewPos;
    2328             : }
    2329             : 
    2330        1913 : sal_uInt16 GetPoolParent( sal_uInt16 nId )
    2331             : {
    2332        1913 :     sal_uInt16 nRet = USHRT_MAX;
    2333        1913 :     if( POOLGRP_NOCOLLID & nId )        // 1 == Formats / 0 == Collections
    2334             :     {
    2335           0 :         switch( ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID ) & nId )
    2336             :         {
    2337             :         case POOLGRP_CHARFMT:
    2338             :         case POOLGRP_FRAMEFMT:
    2339           0 :             nRet = 0;           // derived from the default
    2340           0 :             break;
    2341             :         case POOLGRP_PAGEDESC:
    2342             :         case POOLGRP_NUMRULE:
    2343           0 :             break;              // there are no derivations
    2344             :         }
    2345             :     }
    2346             :     else
    2347             :     {
    2348        1913 :         switch( COLL_GET_RANGE_BITS & nId )
    2349             :         {
    2350             :         case COLL_TEXT_BITS:
    2351         940 :             switch( nId )
    2352             :             {
    2353             :             case RES_POOLCOLL_STANDARD:
    2354         284 :                     nRet = 0;                                   break;
    2355             :             case RES_POOLCOLL_TEXT_IDENT:
    2356             :             case RES_POOLCOLL_TEXT_NEGIDENT:
    2357             :             case RES_POOLCOLL_TEXT_MOVE:
    2358             :             case RES_POOLCOLL_CONFRONTATION:
    2359             :             case RES_POOLCOLL_MARGINAL:
    2360           5 :                     nRet = RES_POOLCOLL_TEXT;                   break;
    2361             : 
    2362             :             case RES_POOLCOLL_TEXT:
    2363             :             case RES_POOLCOLL_GREETING:
    2364             :             case RES_POOLCOLL_SIGNATURE:
    2365             :             case RES_POOLCOLL_HEADLINE_BASE:
    2366         548 :                     nRet = RES_POOLCOLL_STANDARD;               break;
    2367             : 
    2368             :             case RES_POOLCOLL_HEADLINE1:
    2369             :             case RES_POOLCOLL_HEADLINE2:
    2370             :             case RES_POOLCOLL_HEADLINE3:
    2371             :             case RES_POOLCOLL_HEADLINE4:
    2372             :             case RES_POOLCOLL_HEADLINE5:
    2373             :             case RES_POOLCOLL_HEADLINE6:
    2374             :             case RES_POOLCOLL_HEADLINE7:
    2375             :             case RES_POOLCOLL_HEADLINE8:
    2376             :             case RES_POOLCOLL_HEADLINE9:
    2377             :             case RES_POOLCOLL_HEADLINE10:
    2378         103 :                     nRet = RES_POOLCOLL_HEADLINE_BASE;          break;
    2379             :             }
    2380         940 :             break;
    2381             : 
    2382             :         case COLL_LISTS_BITS:
    2383         274 :             switch( nId )
    2384             :             {
    2385             :             case RES_POOLCOLL_NUMBUL_BASE:
    2386         274 :                     nRet = RES_POOLCOLL_TEXT;                   break;
    2387             : 
    2388             :             default:
    2389           0 :                 nRet = RES_POOLCOLL_NUMBUL_BASE;                break;
    2390             :             }
    2391         274 :             break;
    2392             : 
    2393             :         case COLL_EXTRA_BITS:
    2394         387 :             switch( nId )
    2395             :             {
    2396             :             case RES_POOLCOLL_FRAME:
    2397          21 :                     nRet = RES_POOLCOLL_TEXT;                   break;
    2398             : 
    2399             :             case RES_POOLCOLL_TABLE_HDLN:
    2400          14 :                     nRet = RES_POOLCOLL_TABLE;                  break;
    2401             : 
    2402             :             case RES_POOLCOLL_TABLE:
    2403             :             case RES_POOLCOLL_FOOTNOTE:
    2404             :             case RES_POOLCOLL_ENDNOTE:
    2405             :             case RES_POOLCOLL_JAKETADRESS:
    2406             :             case RES_POOLCOLL_SENDADRESS:
    2407             :             case RES_POOLCOLL_HEADER:
    2408             :             case RES_POOLCOLL_HEADERL:
    2409             :             case RES_POOLCOLL_HEADERR:
    2410             :             case RES_POOLCOLL_FOOTER:
    2411             :             case RES_POOLCOLL_FOOTERL:
    2412             :             case RES_POOLCOLL_FOOTERR:
    2413             :             case RES_POOLCOLL_LABEL:
    2414         352 :                     nRet = RES_POOLCOLL_STANDARD;               break;
    2415             : 
    2416             :             case RES_POOLCOLL_LABEL_ABB:
    2417             :             case RES_POOLCOLL_LABEL_TABLE:
    2418             :             case RES_POOLCOLL_LABEL_FRAME:
    2419             :             case RES_POOLCOLL_LABEL_DRAWING:
    2420           0 :                     nRet = RES_POOLCOLL_LABEL;                  break;
    2421             :             }
    2422         387 :             break;
    2423             : 
    2424             :         case COLL_REGISTER_BITS:
    2425         301 :             switch( nId )
    2426             :             {
    2427             :             case RES_POOLCOLL_REGISTER_BASE:
    2428         274 :                     nRet = RES_POOLCOLL_STANDARD;               break;
    2429             : 
    2430             :             case RES_POOLCOLL_TOX_USERH:
    2431             :             case RES_POOLCOLL_TOX_CNTNTH:
    2432             :             case RES_POOLCOLL_TOX_IDXH:
    2433             :             case RES_POOLCOLL_TOX_ILLUSH:
    2434             :             case RES_POOLCOLL_TOX_OBJECTH:
    2435             :             case RES_POOLCOLL_TOX_TABLESH:
    2436             :             case RES_POOLCOLL_TOX_AUTHORITIESH:
    2437           0 :                     nRet = RES_POOLCOLL_HEADLINE_BASE;          break;
    2438             : 
    2439             :             default:
    2440          27 :                     nRet = RES_POOLCOLL_REGISTER_BASE;          break;
    2441             :             }
    2442         301 :             break;
    2443             : 
    2444             :         case COLL_DOC_BITS:
    2445           8 :             nRet = RES_POOLCOLL_HEADLINE_BASE;
    2446           8 :             break;
    2447             : 
    2448             :         case COLL_HTML_BITS:
    2449           3 :             nRet = RES_POOLCOLL_STANDARD;
    2450           3 :             break;
    2451             :         }
    2452             :     }
    2453             : 
    2454        1913 :     return nRet;
    2455             : }
    2456             : 
    2457          37 : void SwDoc::RemoveAllFmtLanguageDependencies()
    2458             : {
    2459             :     /* Restore the language independ pool defaults and styles. */
    2460          37 :     GetAttrPool().ResetPoolDefaultItem( RES_PARATR_ADJUST );
    2461             : 
    2462          37 :     SwTxtFmtColl * pTxtFmtColl = GetTxtCollFromPool( RES_POOLCOLL_STANDARD );
    2463             : 
    2464          37 :     pTxtFmtColl->ResetFmtAttr( RES_PARATR_ADJUST );
    2465             :     /* koreans do not like SvxScriptItem(TRUE) */
    2466          37 :     pTxtFmtColl->ResetFmtAttr( RES_PARATR_SCRIPTSPACE );
    2467             : 
    2468          37 :     SvxFrameDirectionItem aFrameDir( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR );
    2469             : 
    2470          37 :     sal_uInt16 nCount = GetPageDescCnt();
    2471          74 :     for( sal_uInt16 i=0; i<nCount; ++i )
    2472             :     {
    2473          37 :         SwPageDesc& rDesc = GetPageDesc( i );
    2474          37 :         rDesc.GetMaster().SetFmtAttr( aFrameDir );
    2475          37 :         rDesc.GetLeft().SetFmtAttr( aFrameDir );
    2476             :     }
    2477             : 
    2478             :     // #i18732# - restore static pool default for item
    2479             :     // RES_FOLLOW_TEXT_FLOW.
    2480          37 :     GetAttrPool().ResetPoolDefaultItem( RES_FOLLOW_TEXT_FLOW );
    2481             : 
    2482             :     //#i16874# AutoKerning as default for new documents
    2483          37 :     GetAttrPool().ResetPoolDefaultItem( RES_CHRATR_AUTOKERN );
    2484          37 : }
    2485             : 
    2486             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10