LCOV - code coverage report
Current view: top level - sw/source/core/uibase/app - docstyle.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 943 1485 63.5 %
Date: 2014-04-11 Functions: 62 77 80.5 %
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             : #include <svl/smplhint.hxx>
      21             : #include <hintids.hxx>
      22             : #include <svl/itemiter.hxx>
      23             : #include <svl/eitem.hxx>
      24             : #include <unotools/syslocale.hxx>
      25             : #include <editeng/boxitem.hxx>
      26             : #include <editeng/numitem.hxx>
      27             : #include <editeng/lrspitem.hxx>
      28             : #include <fmtcol.hxx>
      29             : #include <uitool.hxx>
      30             : #include <swmodule.hxx>
      31             : #include <wrtsh.hxx>
      32             : #include <docsh.hxx>
      33             : #include <frmfmt.hxx>
      34             : #include <charfmt.hxx>
      35             : #include <poolfmt.hxx>
      36             : #include <pagedesc.hxx>
      37             : #include <docstyle.hxx>
      38             : #include <docary.hxx>
      39             : #include <ccoll.hxx>
      40             : #include <doc.hxx>
      41             : #include <IDocumentUndoRedo.hxx>
      42             : #include <cmdid.h>
      43             : #include <swstyle.h>
      44             : #include <app.hrc>
      45             : #include <paratr.hxx>
      46             : #include <SwStyleNameMapper.hxx>
      47             : #include <svl/cjkoptions.hxx>
      48             : #include <comphelper/processfactory.hxx>
      49             : #include <unotools/localedatawrapper.hxx>
      50             : #include <unotools/intlwrapper.hxx>
      51             : #include <numrule.hxx>
      52             : #include <fmthdft.hxx>
      53             : #include <svx/svxids.hrc>
      54             : #include <svx/xdef.hxx>
      55             : #include <SwRewriter.hxx>
      56             : 
      57             : using namespace com::sun::star;
      58             : 
      59             : // The Format names in the list of all names have the
      60             : // following family as their first character:
      61             : 
      62             : #define cCHAR       (sal_Unicode)'c'
      63             : #define cPARA       (sal_Unicode)'p'
      64             : #define cFRAME      (sal_Unicode)'f'
      65             : #define cPAGE       (sal_Unicode)'g'
      66             : #define cNUMRULE    (sal_Unicode)'n'
      67             : 
      68             : // At the names' publication, this character is removed again and the
      69             : // family is newly generated.
      70             : 
      71             : // In addition now there is the Bit bPhysical. In case this Bit is
      72             : // TRUE, the Pool-Formatnames are not being submitted.
      73             : 
      74             : class SwImplShellAction
      75             : {
      76             :     SwWrtShell* pSh;
      77             :     CurrShell* pCurrSh;
      78             : public:
      79             :     SwImplShellAction( SwDoc& rDoc );
      80             :     ~SwImplShellAction();
      81             : 
      82             :     SwWrtShell* GetSh() { return pSh; }
      83             : };
      84             : 
      85      222315 : SwImplShellAction::SwImplShellAction( SwDoc& rDoc )
      86      222315 :     : pCurrSh( 0 )
      87             : {
      88      222315 :     if( rDoc.GetDocShell() )
      89      222315 :         pSh = rDoc.GetDocShell()->GetWrtShell();
      90             :     else
      91           0 :         pSh = 0;
      92             : 
      93      222315 :     if( pSh )
      94             :     {
      95        1304 :         pCurrSh = new CurrShell( pSh );
      96        1304 :         pSh->StartAllAction();
      97             :     }
      98      222315 : }
      99             : 
     100      222315 : SwImplShellAction::~SwImplShellAction()
     101             : {
     102      222315 :     if( pCurrSh )
     103             :     {
     104        1304 :         pSh->EndAllAction();
     105        1304 :         delete pCurrSh;
     106             :     }
     107      222315 : }
     108             : 
     109             : // find/create SwCharFormate
     110             : // possibly fill Style
     111       73557 : static SwCharFmt* lcl_FindCharFmt( SwDoc& rDoc,
     112             :                             const OUString& rName,
     113             :                             SwDocStyleSheet* pStyle = 0,
     114             :                             bool bCreate = true )
     115             : {
     116       73557 :     SwCharFmt*  pFmt = 0;
     117       73557 :     if (!rName.isEmpty())
     118             :     {
     119       73534 :         pFmt = rDoc.FindCharFmtByName( rName );
     120      104035 :         if( !pFmt && rName == SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
     121       30501 :                                                 RES_POOLCOLL_TEXT_BEGIN ] )
     122             :         {
     123             :             // Standard-Character template
     124         426 :             pFmt = (SwCharFmt*)rDoc.GetDfltCharFmt();
     125             :         }
     126             : 
     127       73534 :         if( !pFmt && bCreate )
     128             :         {   // explore Pool
     129        4920 :             const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
     130        4920 :             if(nId != USHRT_MAX)
     131         375 :                 pFmt = rDoc.GetCharFmtFromPool(nId);
     132             :         }
     133             :     }
     134       73557 :     if(pStyle)
     135             :     {
     136       63281 :         if(pFmt)
     137             :         {
     138       38103 :             pStyle->SetPhysical(sal_True);
     139       38103 :             SwFmt* p = pFmt->DerivedFrom();
     140       38103 :             if( p && !p->IsDefault() )
     141       22911 :                 pStyle->PresetParent( p->GetName() );
     142             :             else
     143       15192 :                 pStyle->PresetParent( OUString() );
     144             :         }
     145             :         else
     146       25178 :             pStyle->SetPhysical(sal_False);
     147             :     }
     148       73557 :     return pFmt;
     149             : }
     150             : 
     151             : // find/create ParaFormats
     152             : // fill Style
     153      176624 : static SwTxtFmtColl* lcl_FindParaFmt(  SwDoc& rDoc,
     154             :                                 const OUString& rName,
     155             :                                 SwDocStyleSheet* pStyle = 0,
     156             :                                 bool bCreate = true )
     157             : {
     158      176624 :     SwTxtFmtColl*   pColl = 0;
     159             : 
     160      176624 :     if (!rName.isEmpty())
     161             :     {
     162      176565 :         pColl = rDoc.FindTxtFmtCollByName( rName );
     163      176565 :         if( !pColl && bCreate )
     164             :         {   // explore Pool
     165        6549 :             const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
     166        6549 :             if(nId != USHRT_MAX)
     167        2957 :                 pColl = rDoc.GetTxtCollFromPool(nId);
     168             :         }
     169             :     }
     170             : 
     171      176624 :     if(pStyle)
     172             :     {
     173      162723 :         if(pColl)
     174             :         {
     175      118810 :             pStyle->SetPhysical(sal_True);
     176      118810 :             if( pColl->DerivedFrom() && !pColl->DerivedFrom()->IsDefault() )
     177       61652 :                 pStyle->PresetParent( pColl->DerivedFrom()->GetName() );
     178             :             else
     179       57158 :                 pStyle->PresetParent( OUString() );
     180             : 
     181      118810 :             SwTxtFmtColl& rNext = pColl->GetNextTxtFmtColl();
     182      118810 :             pStyle->PresetFollow(rNext.GetName());
     183             :         }
     184             :         else
     185       43913 :             pStyle->SetPhysical(sal_False);
     186             :     }
     187      176624 :     return pColl;
     188             : }
     189             : 
     190             : // Border formats
     191        7053 : static SwFrmFmt* lcl_FindFrmFmt(   SwDoc& rDoc,
     192             :                             const OUString& rName,
     193             :                             SwDocStyleSheet* pStyle = 0,
     194             :                             bool bCreate = true )
     195             : {
     196        7053 :     SwFrmFmt* pFmt = 0;
     197        7053 :     if( !rName.isEmpty() )
     198             :     {
     199        7053 :         pFmt = rDoc.FindFrmFmtByName( rName );
     200        7053 :         if( !pFmt && bCreate )
     201             :         {   // explore Pool
     202         360 :             const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT);
     203         360 :             if(nId != USHRT_MAX)
     204         199 :                 pFmt = rDoc.GetFrmFmtFromPool(nId);
     205             :         }
     206             :     }
     207             : 
     208        7053 :     if(pStyle)
     209             :     {
     210        6892 :         if(pFmt)
     211             :         {
     212        4756 :             pStyle->SetPhysical(sal_True);
     213        4756 :             if( pFmt->DerivedFrom() && !pFmt->DerivedFrom()->IsDefault() )
     214           0 :                 pStyle->PresetParent( pFmt->DerivedFrom()->GetName() );
     215             :             else
     216        4756 :                 pStyle->PresetParent( OUString() );
     217             :         }
     218             :         else
     219        2136 :             pStyle->SetPhysical(sal_False);
     220             :     }
     221        7053 :     return pFmt;
     222             : }
     223             : 
     224             : // Page descriptors
     225       20104 : static const SwPageDesc* lcl_FindPageDesc( SwDoc&  rDoc,
     226             :                                     const OUString& rName,
     227             :                                     SwDocStyleSheet* pStyle = 0,
     228             :                                     bool bCreate = true )
     229             : {
     230       20104 :     const SwPageDesc* pDesc = 0;
     231             : 
     232       20104 :     if (!rName.isEmpty())
     233             :     {
     234       20061 :         pDesc = rDoc.FindPageDescByName( rName );
     235       20061 :         if( !pDesc && bCreate )
     236             :         {
     237         414 :             sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC);
     238         414 :             if(nId != USHRT_MAX)
     239         205 :                 pDesc = rDoc.GetPageDescFromPool(nId);
     240             :         }
     241             :     }
     242             : 
     243       20104 :     if(pStyle)
     244             :     {
     245       19881 :         if(pDesc)
     246             :         {
     247       15568 :             pStyle->SetPhysical(sal_True);
     248       15568 :             if(pDesc->GetFollow())
     249       15568 :                 pStyle->PresetFollow(pDesc->GetFollow()->GetName());
     250             :             else
     251           0 :                 pStyle->PresetParent( OUString() );
     252             :         }
     253             :         else
     254        4313 :             pStyle->SetPhysical(sal_False);
     255             :     }
     256       20104 :     return pDesc;
     257             : }
     258             : 
     259      231877 : static const SwNumRule* lcl_FindNumRule(   SwDoc&  rDoc,
     260             :                                     const OUString& rName,
     261             :                                     SwDocStyleSheet* pStyle = 0,
     262             :                                     bool bCreate = true )
     263             : {
     264      231877 :     const SwNumRule* pRule = 0;
     265             : 
     266      231877 :     if (!rName.isEmpty())
     267             :     {
     268      231877 :         pRule = rDoc.FindNumRulePtr( rName );
     269      231877 :         if( !pRule && bCreate )
     270             :         {
     271       14859 :             sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE);
     272       14859 :             if(nId != USHRT_MAX)
     273           6 :                 pRule = rDoc.GetNumRuleFromPool(nId);
     274             :         }
     275             :     }
     276             : 
     277      231877 :     if(pStyle)
     278             :     {
     279      217024 :         if(pRule)
     280             :         {
     281      173713 :             pStyle->SetPhysical(sal_True);
     282      173713 :             pStyle->PresetParent( OUString() );
     283             :         }
     284             :         else
     285       43311 :             pStyle->SetPhysical(sal_False);
     286             :     }
     287      231877 :     return pRule;
     288             : }
     289             : 
     290           1 : static sal_uInt16 lcl_FindName(const SwPoolFmtList& rLst, SfxStyleFamily eFam,
     291             :     const OUString& rName)
     292             : {
     293           1 :     if(!rLst.empty())
     294             :     {
     295           1 :         sal_Unicode cStyle(0);
     296           1 :         switch( eFam )
     297             :         {
     298             :         case SFX_STYLE_FAMILY_CHAR:
     299           1 :             cStyle = cCHAR;
     300           1 :             break;
     301             :         case SFX_STYLE_FAMILY_PARA:
     302           0 :             cStyle = cPARA;
     303           0 :             break;
     304             :         case SFX_STYLE_FAMILY_FRAME:
     305           0 :             cStyle = cFRAME;
     306           0 :             break;
     307             :         case SFX_STYLE_FAMILY_PAGE:
     308           0 :             cStyle = cPAGE;
     309           0 :             break;
     310             :         case SFX_STYLE_FAMILY_PSEUDO:
     311           0 :             cStyle = cNUMRULE;
     312           0 :             break;
     313             :         default:
     314           0 :             cStyle = ' ';
     315           0 :             break;
     316             :         }
     317           1 :         const OUString sSrch = OUString(cStyle) + rName;
     318           2 :         for(size_t i = 0; i < rLst.size(); ++i)
     319           1 :             if(rLst[i] == sSrch)
     320           1 :                 return i;
     321             :     }
     322           1 :     return USHRT_MAX;
     323             : }
     324             : 
     325           0 : bool FindPhyStyle( SwDoc& rDoc, const OUString& rName, SfxStyleFamily eFam )
     326             : {
     327           0 :     switch( eFam )
     328             :     {
     329             :     case SFX_STYLE_FAMILY_CHAR :
     330           0 :         return 0 != lcl_FindCharFmt( rDoc, rName, 0, false );
     331             :     case SFX_STYLE_FAMILY_PARA :
     332           0 :         return 0 != lcl_FindParaFmt( rDoc, rName, 0, false );
     333             :     case SFX_STYLE_FAMILY_FRAME:
     334           0 :         return 0 != lcl_FindFrmFmt( rDoc, rName, 0, false );
     335             :     case SFX_STYLE_FAMILY_PAGE :
     336           0 :         return 0 != lcl_FindPageDesc( rDoc, rName, 0, false );
     337             :     case SFX_STYLE_FAMILY_PSEUDO:
     338           0 :         return 0 != lcl_FindNumRule( rDoc, rName, 0, false );
     339             :     default:; //prevent warning
     340             :     }
     341           0 :     return false;
     342             : }
     343             : 
     344             : // Add Strings to the list of templates
     345      187809 : void SwPoolFmtList::Append( char cChar, const OUString& rStr )
     346             : {
     347      187809 :     const OUString aStr = OUString(cChar) + rStr;
     348     9651653 :     for(std::vector<OUString>::const_iterator i = begin(); i != end(); ++i)
     349     9473171 :         if(*i == aStr)
     350      197136 :             return;
     351      178482 :     push_back(aStr);
     352             : }
     353             : 
     354             : // Erase the list completely
     355       37016 : void SwPoolFmtList::Erase()
     356             : {
     357       37016 :     clear();
     358       37016 : }
     359             : 
     360             : // UI-sided implementation of StyleSheets
     361             : // uses the Core-Engine
     362       18913 : SwDocStyleSheet::SwDocStyleSheet(   SwDoc&          rDocument,
     363             :                                     const OUString&           rName,
     364             :                                     SwDocStyleSheetPool*    _rPool,
     365             :                                     SfxStyleFamily          eFam,
     366             :                                     sal_uInt16                  _nMask) :
     367             : 
     368             :     SfxStyleSheetBase( rName, _rPool, eFam, _nMask ),
     369             :     pCharFmt(0),
     370             :     pColl(0),
     371             :     pFrmFmt(0),
     372             :     pDesc(0),
     373             :     pNumRule(0),
     374             : 
     375             :     rDoc(rDocument),
     376       18913 :     aCoreSet(GetPool().GetPool(),   //UUUU sorted by indices, one double removed
     377             :             RES_CHRATR_BEGIN,       RES_CHRATR_END - 1,             // [1
     378             :             RES_PARATR_BEGIN,       RES_PARATR_END - 1,             // [60
     379             :             RES_PARATR_LIST_BEGIN,  RES_PARATR_LIST_END - 1,        // [77
     380             :             RES_FRMATR_BEGIN,       RES_FRMATR_END - 1,             // [82
     381             :             RES_UNKNOWNATR_BEGIN,   RES_UNKNOWNATR_END-1,           // [143
     382             : 
     383             :             //UUUU FillAttribute support
     384             :             XATTR_FILL_FIRST, XATTR_FILL_LAST,                      // [1014
     385             : 
     386             :             SID_ATTR_BORDER_INNER,  SID_ATTR_BORDER_INNER,          // [10023
     387             :             SID_ATTR_PAGE,          SID_ATTR_PAGE_EXT1,             // [10050
     388             :             SID_ATTR_PAGE_HEADERSET,SID_ATTR_PAGE_FOOTERSET,        // [10058
     389             :             SID_ATTR_PARA_MODEL,    SID_ATTR_PARA_MODEL,            // [10065
     390             : 
     391             :             //UUUU items to hand over XPropertyList things like
     392             :             // XColorList, XHatchList, XGradientList and XBitmapList
     393             :             // to the Area TabPage
     394             :             SID_COLOR_TABLE,        SID_BITMAP_LIST,                // [10179
     395             : 
     396             :             SID_SWREGISTER_COLLECTION, SID_SWREGISTER_COLLECTION,   // [10451
     397             :             SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM,           // [10457
     398             :             SID_SWREGISTER_MODE,    SID_SWREGISTER_MODE,            // [10467
     399             :             SID_PARA_BACKGRND_DESTINATION,  SID_ATTR_BRUSH_CHAR,    // [10590
     400             :             SID_ATTR_NUMBERING_RULE,    SID_ATTR_NUMBERING_RULE,    // [10855
     401             :             SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE, // [12065
     402             :             FN_PARAM_FTN_INFO,      FN_PARAM_FTN_INFO,              // [21123
     403             :             FN_COND_COLL,           FN_COND_COLL,                   // [22401
     404             :             0),
     405       37826 :     bPhysical(sal_False)
     406             : {
     407       18913 :     nHelpId = UCHAR_MAX;
     408       18913 : }
     409             : 
     410      255488 : SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet& rOrg) :
     411             :     SfxStyleSheetBase(rOrg),
     412             :     pCharFmt(rOrg.pCharFmt),
     413             :     pColl(rOrg.pColl),
     414             :     pFrmFmt(rOrg.pFrmFmt),
     415             :     pDesc(rOrg.pDesc),
     416             :     pNumRule(rOrg.pNumRule),
     417             :     rDoc(rOrg.rDoc),
     418             :     aCoreSet(rOrg.aCoreSet),
     419      255488 :     bPhysical(rOrg.bPhysical)
     420             : {
     421      255488 : }
     422             : 
     423      548776 :  SwDocStyleSheet::~SwDocStyleSheet()
     424             : {
     425      548776 : }
     426             : 
     427             : // Reset
     428       11937 : void  SwDocStyleSheet::Reset()
     429             : {
     430       11937 :     aName = "";
     431       11937 :     aFollow = "";
     432       11937 :     aParent = "";
     433       11937 :     SetPhysical(sal_False);
     434       11937 : }
     435             : 
     436       23344 : void SwDocStyleSheet::SetGrabBagItem(const uno::Any& rVal)
     437             : {
     438       23344 :     bool bChg = false;
     439       23344 :     if (!bPhysical)
     440           0 :         FillStyleSheet(FillPhysical);
     441             : 
     442       23344 :     SwFmt* pFmt = 0;
     443       23344 :     switch (nFamily)
     444             :     {
     445             :         case SFX_STYLE_FAMILY_CHAR:
     446        4072 :             pFmt = rDoc.FindCharFmtByName(aName);
     447        4072 :             if (pFmt)
     448             :             {
     449        4072 :                 pFmt->SetGrabBagItem(rVal);
     450        4072 :                 bChg = true;
     451             :             }
     452        4072 :             break;
     453             :         case SFX_STYLE_FAMILY_PARA:
     454        6386 :             pFmt = rDoc.FindTxtFmtCollByName(aName);
     455        6386 :             if (pFmt)
     456             :             {
     457        6386 :                 pFmt->SetGrabBagItem(rVal);
     458        6386 :                 bChg = true;
     459             :             }
     460        6386 :             break;
     461             :         case SFX_STYLE_FAMILY_PSEUDO:
     462             :             {
     463       12886 :                 SwNumRule* pRule = rDoc.FindNumRulePtr(aName);
     464       12886 :                 if (pRule)
     465             :                 {
     466       12886 :                     pRule->SetGrabBagItem(rVal);
     467       12886 :                     bChg = true;
     468             :                 }
     469             :             }
     470       12886 :             break;
     471             :         default:
     472           0 :             break;
     473             :     }
     474             : 
     475       23344 :     if (bChg)
     476             :     {
     477       23344 :         dynamic_cast<SwDocStyleSheetPool&>(*pPool).InvalidateIterator();
     478       23344 :         pPool->Broadcast(SfxStyleSheetHint(SFX_STYLESHEET_MODIFIED, *this));
     479       23344 :         SwEditShell* pSh = rDoc.GetEditShell();
     480       23344 :         if (pSh)
     481           2 :             pSh->CallChgLnk();
     482             :     }
     483       23344 : }
     484             : 
     485           9 : void SwDocStyleSheet::GetGrabBagItem(uno::Any& rVal) const
     486             : {
     487           9 :     SwFmt* pFmt = 0;
     488           9 :     switch (nFamily)
     489             :     {
     490             :         case SFX_STYLE_FAMILY_CHAR:
     491           7 :             pFmt = rDoc.FindCharFmtByName(aName);
     492           7 :             if (pFmt)
     493           7 :                 pFmt->GetGrabBagItem(rVal);
     494           7 :             break;
     495             :         case SFX_STYLE_FAMILY_PARA:
     496           2 :             pFmt = rDoc.FindTxtFmtCollByName(aName);
     497           2 :             if (pFmt)
     498           2 :                 pFmt->GetGrabBagItem(rVal);
     499           2 :             break;
     500             :         case SFX_STYLE_FAMILY_PSEUDO:
     501             :             {
     502           0 :                 SwNumRule* pRule = rDoc.FindNumRulePtr(aName);
     503           0 :                 if (pRule)
     504           0 :                     pRule->GetGrabBagItem(rVal);
     505             :             }
     506           0 :             break;
     507             :         default:
     508           0 :             break;
     509             :     }
     510           9 : }
     511             : // virtual methods
     512        1735 : void SwDocStyleSheet::SetHidden( bool bValue )
     513             : {
     514        1735 :     bool bChg = false;
     515        1735 :     if(!bPhysical)
     516           0 :         FillStyleSheet( FillPhysical );
     517             : 
     518        1735 :     SwFmt* pFmt = 0;
     519        1735 :     switch(nFamily)
     520             :     {
     521             :         case SFX_STYLE_FAMILY_CHAR:
     522         240 :             pFmt = rDoc.FindCharFmtByName( aName );
     523         240 :             if ( pFmt )
     524             :             {
     525         240 :                 pFmt->SetHidden( bValue );
     526         240 :                 bChg = true;
     527             :             }
     528         240 :             break;
     529             : 
     530             :         case SFX_STYLE_FAMILY_PARA:
     531        1013 :             pFmt = rDoc.FindTxtFmtCollByName( aName );
     532        1013 :             if ( pFmt )
     533             :             {
     534        1013 :                 pFmt->SetHidden( bValue );
     535        1013 :                 bChg = true;
     536             :             }
     537        1013 :             break;
     538             : 
     539             :         case SFX_STYLE_FAMILY_FRAME:
     540         217 :             pFmt = rDoc.FindFrmFmtByName( aName );
     541         217 :             if ( pFmt )
     542             :             {
     543         217 :                 pFmt->SetHidden( bValue );
     544         217 :                 bChg = true;
     545             :             }
     546         217 :             break;
     547             : 
     548             :         case SFX_STYLE_FAMILY_PAGE:
     549             :             {
     550         214 :                 SwPageDesc* pPgDesc = rDoc.FindPageDescByName( aName );
     551         214 :                 if ( pPgDesc )
     552             :                 {
     553         214 :                     pPgDesc->SetHidden( bValue );
     554         214 :                     bChg = true;
     555             :                 }
     556             :             }
     557         214 :             break;
     558             : 
     559             :         case SFX_STYLE_FAMILY_PSEUDO:
     560             :             {
     561          51 :                 SwNumRule* pRule = rDoc.FindNumRulePtr( aName );
     562          51 :                 if ( pRule )
     563             :                 {
     564          51 :                     pRule->SetHidden( bValue );
     565          51 :                     bChg = true;
     566             :                 }
     567             :             }
     568             :         default:;
     569             :     }
     570             : 
     571        1735 :     if( bChg )
     572             :     {
     573             :         // calling pPool->First() here would be quite slow...
     574        1735 :         dynamic_cast<SwDocStyleSheetPool*>(pPool)->InvalidateIterator(); // internal list has to be updated
     575        1735 :         pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
     576        1735 :         SwEditShell* pSh = rDoc.GetEditShell();
     577        1735 :         if( pSh )
     578         278 :             pSh->CallChgLnk();
     579             :     }
     580        1735 : }
     581             : 
     582        1361 : bool SwDocStyleSheet::IsHidden( ) const
     583             : {
     584        1361 :     sal_Bool bRet = sal_False;
     585             : 
     586        1361 :     SwFmt* pFmt = 0;
     587        1361 :     switch(nFamily)
     588             :     {
     589             :         case SFX_STYLE_FAMILY_CHAR:
     590          69 :             pFmt = rDoc.FindCharFmtByName( aName );
     591          69 :             bRet = pFmt && pFmt->IsHidden( );
     592          69 :             break;
     593             : 
     594             :         case SFX_STYLE_FAMILY_PARA:
     595        1213 :             pFmt = rDoc.FindTxtFmtCollByName( aName );
     596        1213 :             bRet = pFmt && pFmt->IsHidden( );
     597        1213 :             break;
     598             : 
     599             :         case SFX_STYLE_FAMILY_FRAME:
     600          11 :             pFmt = rDoc.FindFrmFmtByName( aName );
     601          11 :             bRet = pFmt && pFmt->IsHidden( );
     602          11 :             break;
     603             : 
     604             :         case SFX_STYLE_FAMILY_PAGE:
     605             :             {
     606          26 :                 SwPageDesc* pPgDesc = rDoc.FindPageDescByName( aName );
     607          26 :                 bRet = pPgDesc && pPgDesc->IsHidden( );
     608             :             }
     609          26 :             break;
     610             :         case SFX_STYLE_FAMILY_PSEUDO:
     611             :             {
     612          42 :                 SwNumRule* pRule = rDoc.FindNumRulePtr( aName );
     613          42 :                 bRet = pRule && pRule->IsHidden( );
     614             :             }
     615             :         default:;
     616             :     }
     617             : 
     618        1361 :     return bRet;
     619             : }
     620             : 
     621       23725 : const OUString&  SwDocStyleSheet::GetParent() const
     622             : {
     623       23725 :     if( !bPhysical )
     624             :     {
     625             :         // check if it's already in document
     626       14966 :         SwFmt* pFmt = 0;
     627             :         SwGetPoolIdFromName eGetType;
     628       14966 :         switch(nFamily)
     629             :         {
     630             :         case SFX_STYLE_FAMILY_CHAR:
     631          56 :             pFmt = rDoc.FindCharFmtByName( aName );
     632          56 :             eGetType = nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
     633          56 :             break;
     634             : 
     635             :         case SFX_STYLE_FAMILY_PARA:
     636       14888 :             pFmt = rDoc.FindTxtFmtCollByName( aName );
     637       14888 :             eGetType = nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
     638       14888 :             break;
     639             : 
     640             :         case SFX_STYLE_FAMILY_FRAME:
     641           0 :             pFmt = rDoc.FindFrmFmtByName( aName );
     642           0 :             eGetType = nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
     643           0 :             break;
     644             : 
     645             :         case SFX_STYLE_FAMILY_PAGE:
     646             :         case SFX_STYLE_FAMILY_PSEUDO:
     647             :         default:
     648          22 :             return aEmptyOUStr;       // there's no parent
     649             :         }
     650             : 
     651       14944 :         OUString sTmp;
     652       14944 :         if( !pFmt )         // not yet there, so default Parent
     653             :         {
     654       14200 :             sal_uInt16 i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType );
     655       14200 :             i = ::GetPoolParent( i );
     656       14200 :             if( i && USHRT_MAX != i )
     657       14148 :                 SwStyleNameMapper::FillUIName( i, sTmp );
     658             :         }
     659             :         else
     660             :         {
     661         744 :             SwFmt* p = pFmt->DerivedFrom();
     662         744 :             if( p && !p->IsDefault() )
     663         620 :                 sTmp = p->GetName();
     664             :         }
     665       14944 :         SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
     666       14944 :         pThis->aParent = sTmp;
     667             :     }
     668       23703 :     return aParent;
     669             : }
     670             : 
     671             : // Follower
     672        1429 : const OUString&  SwDocStyleSheet::GetFollow() const
     673             : {
     674        1429 :     if( !bPhysical )
     675             :     {
     676           0 :         SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
     677           0 :         pThis->FillStyleSheet( FillAllInfo );
     678             :     }
     679        1429 :     return aFollow;
     680             : }
     681             : 
     682             : // What Linkage is possible
     683           0 : bool  SwDocStyleSheet::HasFollowSupport() const
     684             : {
     685           0 :     switch(nFamily)
     686             :     {
     687             :         case SFX_STYLE_FAMILY_PARA :
     688           0 :         case SFX_STYLE_FAMILY_PAGE : return true;
     689             :         case SFX_STYLE_FAMILY_FRAME:
     690             :         case SFX_STYLE_FAMILY_CHAR :
     691           0 :         case SFX_STYLE_FAMILY_PSEUDO: return false;
     692             :         default:
     693             :             OSL_ENSURE(!this, "unknown style family");
     694             :     }
     695           0 :     return false;
     696             : }
     697             : 
     698             : // Parent ?
     699         236 : bool  SwDocStyleSheet::HasParentSupport() const
     700             : {
     701         236 :     bool bRet = false;
     702         236 :     switch(nFamily)
     703             :     {
     704             :         case SFX_STYLE_FAMILY_CHAR :
     705             :         case SFX_STYLE_FAMILY_PARA :
     706         236 :         case SFX_STYLE_FAMILY_FRAME: bRet = true;
     707             :         default:; //prevent warning
     708             :     }
     709         236 :     return bRet;
     710             : }
     711             : 
     712           0 : bool  SwDocStyleSheet::HasClearParentSupport() const
     713             : {
     714           0 :     bool bRet = false;
     715           0 :     switch(nFamily)
     716             :     {
     717             :         case SFX_STYLE_FAMILY_PARA :
     718             :         case SFX_STYLE_FAMILY_CHAR :
     719           0 :         case SFX_STYLE_FAMILY_FRAME: bRet = true;
     720             :         default:; //prevent warning
     721             :     }
     722           0 :     return bRet;
     723             : }
     724             : 
     725             : // determine textual description
     726           0 : OUString  SwDocStyleSheet::GetDescription(SfxMapUnit eUnit)
     727             : {
     728           0 :     IntlWrapper aIntlWrapper( SvtSysLocale().GetLanguageTag() );
     729             : 
     730           0 :     const OUString sPlus(" + ");
     731           0 :     if ( SFX_STYLE_FAMILY_PAGE == nFamily )
     732             :     {
     733           0 :         if( !pSet )
     734           0 :             GetItemSet();
     735             : 
     736           0 :         SfxItemIter aIter( *pSet );
     737           0 :         OUString aDesc;
     738             : 
     739           0 :         for (const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem())
     740             :         {
     741           0 :             if(!IsInvalidItem(pItem))
     742             :             {
     743           0 :                 switch ( pItem->Which() )
     744             :                 {
     745             :                     case RES_LR_SPACE:
     746             :                     case SID_ATTR_PAGE_SIZE:
     747             :                     case SID_ATTR_PAGE_MAXSIZE:
     748             :                     case SID_ATTR_PAGE_PAPERBIN:
     749             :                     case SID_ATTR_PAGE_APP:
     750             :                     case SID_ATTR_BORDER_INNER:
     751           0 :                         break;
     752             :                     default:
     753             :                     {
     754           0 :                         OUString aItemPresentation;
     755           0 :                         if ( !IsInvalidItem( pItem ) &&
     756           0 :                              pPool->GetPool().GetPresentation(
     757             :                                 *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
     758           0 :                                 eUnit, aItemPresentation, &aIntlWrapper ) )
     759             :                         {
     760           0 :                             if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
     761           0 :                                 aDesc += sPlus;
     762           0 :                             aDesc += aItemPresentation;
     763           0 :                         }
     764             :                     }
     765             :                 }
     766             :             }
     767             :         }
     768           0 :         return aDesc;
     769             :     }
     770             : 
     771           0 :     if ( SFX_STYLE_FAMILY_FRAME == nFamily || SFX_STYLE_FAMILY_PARA == nFamily)
     772             :     {
     773           0 :         if( !pSet )
     774           0 :             GetItemSet();
     775             : 
     776           0 :         SfxItemIter aIter( *pSet );
     777           0 :         OUString aDesc;
     778           0 :         OUString sPageNum;
     779           0 :         OUString sModel;
     780           0 :         OUString sBreak;
     781           0 :         bool bHasWesternFontPrefix = false;
     782           0 :         bool bHasCJKFontPrefix = false;
     783           0 :         SvtCJKOptions aCJKOptions;
     784             : 
     785           0 :         for ( const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem() )
     786             :         {
     787           0 :             if(!IsInvalidItem(pItem))
     788             :             {
     789           0 :                 switch ( pItem->Which() )
     790             :                 {
     791             :                     case SID_ATTR_AUTO_STYLE_UPDATE:
     792             :                     case SID_PARA_BACKGRND_DESTINATION:
     793             :                     case RES_PAGEDESC:
     794             :                     //CTL not yet supported
     795             :                     case RES_CHRATR_CTL_FONT:
     796             :                     case RES_CHRATR_CTL_FONTSIZE:
     797             :                     case RES_CHRATR_CTL_LANGUAGE:
     798             :                     case RES_CHRATR_CTL_POSTURE:
     799             :                     case RES_CHRATR_CTL_WEIGHT:
     800           0 :                         break;
     801             :                     default:
     802             :                     {
     803           0 :                         OUString aItemPresentation;
     804           0 :                         if ( !IsInvalidItem( pItem ) &&
     805           0 :                              pPool->GetPool().GetPresentation(
     806             :                                 *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
     807           0 :                                 eUnit, aItemPresentation, &aIntlWrapper ) )
     808             :                         {
     809           0 :                             bool bIsDefault = false;
     810           0 :                             switch ( pItem->Which() )
     811             :                             {
     812             :                                 case SID_ATTR_PARA_PAGENUM:
     813           0 :                                     sPageNum = aItemPresentation;
     814           0 :                                     break;
     815             :                                 case SID_ATTR_PARA_MODEL:
     816           0 :                                     sModel = aItemPresentation;
     817           0 :                                     break;
     818             :                                 case RES_BREAK:
     819           0 :                                     sBreak = aItemPresentation;
     820           0 :                                     break;
     821             :                                 case RES_CHRATR_CJK_FONT:
     822             :                                 case RES_CHRATR_CJK_FONTSIZE:
     823             :                                 case RES_CHRATR_CJK_LANGUAGE:
     824             :                                 case RES_CHRATR_CJK_POSTURE:
     825             :                                 case RES_CHRATR_CJK_WEIGHT:
     826           0 :                                 if(aCJKOptions.IsCJKFontEnabled())
     827           0 :                                     bIsDefault = true;
     828           0 :                                 if(!bHasCJKFontPrefix)
     829             :                                 {
     830           0 :                                     aItemPresentation = SW_RESSTR(STR_CJK_FONT) + aItemPresentation;
     831           0 :                                     bHasCJKFontPrefix = true;
     832             :                                 }
     833           0 :                                 break;
     834             :                                 case RES_CHRATR_FONT:
     835             :                                 case RES_CHRATR_FONTSIZE:
     836             :                                 case RES_CHRATR_LANGUAGE:
     837             :                                 case RES_CHRATR_POSTURE:
     838             :                                 case RES_CHRATR_WEIGHT:
     839           0 :                                 if(!bHasWesternFontPrefix)
     840             :                                 {
     841           0 :                                     aItemPresentation = SW_RESSTR(STR_WESTERN_FONT) + aItemPresentation;
     842           0 :                                     bHasWesternFontPrefix = true;
     843           0 :                                     bIsDefault = true;
     844             :                                 }
     845             :                                 // no break;
     846             :                                 default:
     847           0 :                                     bIsDefault = true;
     848             :                             }
     849           0 :                             if(bIsDefault)
     850             :                             {
     851           0 :                                 if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
     852           0 :                                     aDesc += sPlus;
     853           0 :                                 aDesc += aItemPresentation;
     854             :                             }
     855           0 :                         }
     856             :                     }
     857             :                 }
     858             :             }
     859             :         }
     860             :         // Special treatment for Break, Page template and Site offset
     861           0 :         if (!sModel.isEmpty())
     862             :         {
     863           0 :             if (!aDesc.isEmpty())
     864           0 :                 aDesc += sPlus;
     865           0 :             aDesc += SW_RESSTR(STR_PAGEBREAK) + sPlus + sModel;
     866           0 :             if (sPageNum != "0")
     867             :             {
     868           0 :                 aDesc += sPlus + SW_RESSTR(STR_PAGEOFFSET) + sPageNum;
     869             :             }
     870             :         }
     871           0 :         else if (!sBreak.isEmpty()) // Break can be valid only when NO Model
     872             :         {
     873           0 :             if (!aDesc.isEmpty())
     874           0 :                 aDesc += sPlus;
     875           0 :             aDesc += sBreak;
     876             :         }
     877           0 :         return aDesc;
     878             :     }
     879             : 
     880           0 :     if( SFX_STYLE_FAMILY_PSEUDO == nFamily )
     881             :     {
     882           0 :         return OUString();
     883             :     }
     884             : 
     885           0 :     return SfxStyleSheetBase::GetDescription(eUnit);
     886             : }
     887             : 
     888           0 : OUString  SwDocStyleSheet::GetDescription()
     889             : {
     890           0 :     return GetDescription(SFX_MAPUNIT_CM);
     891             : }
     892             : 
     893             : // Set names
     894           8 : bool  SwDocStyleSheet::SetName( const OUString& rStr)
     895             : {
     896           8 :     if( rStr.isEmpty() )
     897           0 :         return false;
     898             : 
     899           8 :     if( aName != rStr )
     900             :     {
     901           8 :         if( !SfxStyleSheetBase::SetName( rStr ))
     902           0 :             return false;
     903             :     }
     904           0 :     else if(!bPhysical)
     905           0 :         FillStyleSheet( FillPhysical );
     906             : 
     907           8 :     bool bChg = false;
     908           8 :     switch(nFamily)
     909             :     {
     910             :         case SFX_STYLE_FAMILY_CHAR :
     911             :         {
     912             :             OSL_ENSURE(pCharFmt, "SwCharFormat missing!");
     913           2 :             if( pCharFmt && pCharFmt->GetName() != rStr )
     914             :             {
     915           2 :                 pCharFmt->SetName( rStr );
     916           2 :                 bChg = true;
     917             :             }
     918           2 :             break;
     919             :         }
     920             :         case SFX_STYLE_FAMILY_PARA :
     921             :         {
     922             :             OSL_ENSURE(pColl, "Collection missing!");
     923           4 :             if( pColl && pColl->GetName() != rStr )
     924             :             {
     925           4 :                 if (!pColl->GetName().isEmpty())
     926           4 :                     rDoc.RenameFmt(*pColl, rStr);
     927             :                 else
     928           0 :                     pColl->SetName(rStr);
     929             : 
     930           4 :                 bChg = true;
     931             :             }
     932           4 :             break;
     933             :         }
     934             :         case SFX_STYLE_FAMILY_FRAME:
     935             :         {
     936             :             OSL_ENSURE(pFrmFmt, "FrmFmt missing!");
     937           0 :             if( pFrmFmt && pFrmFmt->GetName() != rStr )
     938             :             {
     939           0 :                 if (!pFrmFmt->GetName().isEmpty())
     940           0 :                     rDoc.RenameFmt(*pFrmFmt, rStr);
     941             :                 else
     942           0 :                     pFrmFmt->SetName( rStr );
     943             : 
     944           0 :                 bChg = true;
     945             :             }
     946           0 :             break;
     947             :         }
     948             :         case SFX_STYLE_FAMILY_PAGE :
     949             :             OSL_ENSURE(pDesc, "PageDesc missing!");
     950           2 :             if( pDesc && pDesc->GetName() != rStr )
     951             :             {
     952             :                 // Set PageDesc - copy with earlier one - probably not
     953             :                 // necessary for setting the name. So here we allow a
     954             :                 // cast.
     955           2 :                 SwPageDesc aPageDesc(*((SwPageDesc*)pDesc));
     956           4 :                 const OUString aOldName(aPageDesc.GetName());
     957             : 
     958           2 :                 aPageDesc.SetName( rStr );
     959           2 :                 bool const bDoesUndo = rDoc.GetIDocumentUndoRedo().DoesUndo();
     960             : 
     961           2 :                 rDoc.GetIDocumentUndoRedo().DoUndo(!aOldName.isEmpty());
     962           2 :                 rDoc.ChgPageDesc(aOldName, aPageDesc);
     963           2 :                 rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo);
     964             : 
     965           2 :                 rDoc.SetModified();
     966           4 :                 bChg = true;
     967             :             }
     968           2 :             break;
     969             :         case SFX_STYLE_FAMILY_PSEUDO:
     970             :             OSL_ENSURE(pNumRule, "NumRule missing!");
     971             : 
     972           0 :             if (pNumRule)
     973             :             {
     974           0 :                 OUString aOldName = pNumRule->GetName();
     975             : 
     976           0 :                 if (!aOldName.isEmpty())
     977             :                 {
     978           0 :                     if ( aOldName != rStr &&
     979           0 :                          rDoc.RenameNumRule(aOldName, rStr))
     980             :                     {
     981           0 :                         pNumRule = rDoc.FindNumRulePtr(rStr);
     982           0 :                         rDoc.SetModified();
     983             : 
     984           0 :                         bChg = true;
     985             :                     }
     986             :                 }
     987             :                 else
     988             :                 {
     989             :                     // #i91400#
     990           0 :                     ((SwNumRule*)pNumRule)->SetName( rStr, rDoc );
     991           0 :                     rDoc.SetModified();
     992             : 
     993           0 :                     bChg = true;
     994           0 :                 }
     995             :             }
     996             : 
     997           0 :             break;
     998             : 
     999             :         default:
    1000             :             OSL_ENSURE(!this, "unknown style family");
    1001             :     }
    1002             : 
    1003           8 :     if( bChg )
    1004             :     {
    1005           8 :         pPool->First();  // internal list has to be updated
    1006           8 :         pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
    1007           8 :         SwEditShell* pSh = rDoc.GetEditShell();
    1008           8 :         if( pSh )
    1009           8 :             pSh->CallChgLnk();
    1010             :     }
    1011           8 :     return true;
    1012             : }
    1013             : 
    1014             : // hierarchy of deduction
    1015        3544 : bool   SwDocStyleSheet::SetParent( const OUString& rStr)
    1016             : {
    1017        3544 :     SwFmt* pFmt = 0, *pParent = 0;
    1018        3544 :     switch(nFamily)
    1019             :     {
    1020             :         case SFX_STYLE_FAMILY_CHAR :
    1021             :             OSL_ENSURE( pCharFmt, "SwCharFormat missing!" );
    1022         262 :             if( 0 != ( pFmt = pCharFmt ) && !rStr.isEmpty() )
    1023         262 :                 pParent = lcl_FindCharFmt(rDoc, rStr);
    1024         262 :             break;
    1025             : 
    1026             :         case SFX_STYLE_FAMILY_PARA :
    1027             :             OSL_ENSURE( pColl, "Collektion missing!");
    1028        3282 :             if( 0 != ( pFmt = pColl ) && !rStr.isEmpty() )
    1029        2483 :                 pParent = lcl_FindParaFmt( rDoc, rStr );
    1030        3282 :             break;
    1031             : 
    1032             :         case SFX_STYLE_FAMILY_FRAME:
    1033             :             OSL_ENSURE(pFrmFmt, "FrameFormat missing!");
    1034           0 :             if( 0 != ( pFmt = pFrmFmt ) && !rStr.isEmpty() )
    1035           0 :                 pParent = lcl_FindFrmFmt( rDoc, rStr );
    1036           0 :             break;
    1037             : 
    1038             :         case SFX_STYLE_FAMILY_PAGE:
    1039             :         case SFX_STYLE_FAMILY_PSEUDO:
    1040           0 :             break;
    1041             :         default:
    1042             :             OSL_ENSURE(!this, "unknown style family");
    1043             :     }
    1044             : 
    1045        3544 :     bool bRet = false;
    1046       14176 :     if( pFmt && pFmt->DerivedFrom() &&
    1047       14176 :         pFmt->DerivedFrom()->GetName() != rStr )
    1048             :     {
    1049             :         {
    1050        3544 :             SwImplShellAction aTmp( rDoc );
    1051        3544 :             bRet = pFmt->SetDerivedFrom( pParent );
    1052             :         }
    1053             : 
    1054        3544 :         if( bRet )
    1055             :         {
    1056        3544 :             aParent = rStr;
    1057             :             pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
    1058        3544 :                             *this ) );
    1059             :         }
    1060             :     }
    1061             : 
    1062        3544 :     return bRet;
    1063             : }
    1064             : 
    1065             : // Set Follower
    1066        2779 : bool   SwDocStyleSheet::SetFollow( const OUString& rStr)
    1067             : {
    1068        2779 :     if( !rStr.isEmpty() && !SfxStyleSheetBase::SetFollow( rStr ))
    1069         705 :         return false;
    1070             : 
    1071        2074 :     SwImplShellAction aTmpSh( rDoc );
    1072        2074 :     switch(nFamily)
    1073             :     {
    1074             :     case SFX_STYLE_FAMILY_PARA :
    1075             :     {
    1076             :         OSL_ENSURE(pColl, "Collection missing!");
    1077        2060 :         if( pColl )
    1078             :         {
    1079        2060 :             SwTxtFmtColl* pFollow = pColl;
    1080        2060 :             if( !rStr.isEmpty() && 0 == (pFollow = lcl_FindParaFmt(rDoc, rStr) ))
    1081           0 :                 pFollow = pColl;
    1082             : 
    1083        2060 :             pColl->SetNextTxtFmtColl(*pFollow);
    1084             :         }
    1085        2060 :         break;
    1086             :     }
    1087             :     case SFX_STYLE_FAMILY_PAGE :
    1088             :     {
    1089             :         OSL_ENSURE(pDesc, "PageDesc missing!");
    1090          14 :         if( pDesc )
    1091             :         {
    1092          14 :             const SwPageDesc* pFollowDesc = !rStr.isEmpty()
    1093          14 :                                             ? lcl_FindPageDesc(rDoc, rStr)
    1094          28 :                                             : 0;
    1095          14 :             sal_uInt16 nId = 0;
    1096          56 :             if( pFollowDesc != pDesc->GetFollow() &&
    1097          56 :                 rDoc.FindPageDescByName( pDesc->GetName(), &nId ) )
    1098             :             {
    1099          14 :                 SwPageDesc aDesc( *pDesc );
    1100          14 :                 aDesc.SetFollow( pFollowDesc );
    1101          14 :                 rDoc.ChgPageDesc( nId, aDesc );
    1102          14 :                 pDesc = &rDoc.GetPageDesc( nId );
    1103             :             }
    1104             :         }
    1105          14 :         break;
    1106             :     }
    1107             :     case SFX_STYLE_FAMILY_CHAR:
    1108             :     case SFX_STYLE_FAMILY_FRAME:
    1109             :     case SFX_STYLE_FAMILY_PSEUDO:
    1110           0 :         break;
    1111             :     default:
    1112             :         OSL_ENSURE(!this, "unknwown style family");
    1113             :     }
    1114             : 
    1115        2074 :     return true;
    1116             : }
    1117             : 
    1118             : // extract ItemSet to Name and Family, Mask
    1119             : 
    1120             : //UUUU
    1121             : #include <svx/svdmodel.hxx>
    1122             : #include <svx/drawitem.hxx>
    1123             : 
    1124      251425 : SfxItemSet&   SwDocStyleSheet::GetItemSet()
    1125             : {
    1126      251425 :     if(!bPhysical)
    1127        3227 :         FillStyleSheet( FillPhysical );
    1128             : 
    1129      251425 :     switch(nFamily)
    1130             :     {
    1131             :         case SFX_STYLE_FAMILY_CHAR:
    1132             :         case SFX_STYLE_FAMILY_PARA:
    1133             :         case SFX_STYLE_FAMILY_FRAME:
    1134             :             {
    1135       87324 :                 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
    1136       87324 :                 aBoxInfo.SetTable( false );
    1137       87324 :                 aBoxInfo.SetDist( true );   // always show gap field
    1138       87324 :                 aBoxInfo.SetMinDist( true );// set minimum size in tables and paragraphs
    1139       87324 :                 aBoxInfo.SetDefDist( MIN_BORDER_DIST );// always set Default-Gap
    1140             :                     // Single lines can only have DontCare-Status in tables
    1141       87324 :                 aBoxInfo.SetValid( VALID_DISABLE, true );
    1142             : 
    1143       87324 :                 if( nFamily == SFX_STYLE_FAMILY_CHAR )
    1144             :                 {
    1145             :                     SAL_WARN_IF(!pCharFmt, "sw.ui", "Where's SwCharFmt");
    1146       27110 :                     aCoreSet.Put(pCharFmt->GetAttrSet());
    1147       27110 :                     aCoreSet.Put( aBoxInfo );
    1148             : 
    1149       27110 :                     if(pCharFmt->DerivedFrom())
    1150       27110 :                         aCoreSet.SetParent(&pCharFmt->DerivedFrom()->GetAttrSet());
    1151             :                 }
    1152       60214 :                 else if ( nFamily == SFX_STYLE_FAMILY_PARA )
    1153             :                 {
    1154             :                     OSL_ENSURE(pColl, "Where's Collection");
    1155       57008 :                     aCoreSet.Put(pColl->GetAttrSet());
    1156       57008 :                     aCoreSet.Put( aBoxInfo );
    1157       57008 :                     aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pColl->IsAutoUpdateFmt()));
    1158             : 
    1159       57008 :                     if(pColl->DerivedFrom())
    1160       57008 :                         aCoreSet.SetParent(&pColl->DerivedFrom()->GetAttrSet());
    1161             :                 }
    1162             :                 else
    1163             :                 {
    1164             :                     OSL_ENSURE(pFrmFmt, "Where's FrmFmt");
    1165        3206 :                     aCoreSet.Put(pFrmFmt->GetAttrSet());
    1166        3206 :                     aCoreSet.Put( aBoxInfo );
    1167        3206 :                     aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pFrmFmt->IsAutoUpdateFmt()));
    1168             : 
    1169        3206 :                     if(pFrmFmt->DerivedFrom())
    1170        3206 :                         aCoreSet.SetParent(&pFrmFmt->DerivedFrom()->GetAttrSet());
    1171             : 
    1172             :                     //UUUU create needed items for XPropertyList entries from the DrawModel so that
    1173             :                     // the Area TabPage can access them
    1174        3206 :                     const SdrModel* pDrawModel = rDoc.GetDrawModel();
    1175             : 
    1176        3206 :                     aCoreSet.Put(SvxColorListItem(pDrawModel->GetColorList(), SID_COLOR_TABLE));
    1177        3206 :                     aCoreSet.Put(SvxGradientListItem(pDrawModel->GetGradientList(), SID_GRADIENT_LIST));
    1178        3206 :                     aCoreSet.Put(SvxHatchListItem(pDrawModel->GetHatchList(), SID_HATCH_LIST));
    1179        3206 :                     aCoreSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapList(), SID_BITMAP_LIST));
    1180       87324 :                 }
    1181             :             }
    1182       87324 :             break;
    1183             : 
    1184             :         case SFX_STYLE_FAMILY_PAGE :
    1185             :             {
    1186             :                 OSL_ENSURE(pDesc, "No PageDescriptor");
    1187        7478 :                 ::PageDescToItemSet(*((SwPageDesc*)pDesc), aCoreSet);
    1188             :             }
    1189        7478 :             break;
    1190             : 
    1191             :         case SFX_STYLE_FAMILY_PSEUDO:
    1192             :             {
    1193             :                 OSL_ENSURE(pNumRule, "No NumRule");
    1194      156623 :                 SvxNumRule aRule = pNumRule->MakeSvxNumRule();
    1195      156623 :                 aCoreSet.Put(SvxNumBulletItem(aRule));
    1196             :             }
    1197      156623 :             break;
    1198             : 
    1199             :         default:
    1200             :             OSL_ENSURE(!this, "unknown style family");
    1201             :     }
    1202             :     // Member of Baseclass
    1203      251425 :     pSet = &aCoreSet;
    1204             : 
    1205      251425 :     return aCoreSet;
    1206             : }
    1207             : 
    1208           0 : void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet )
    1209             : {
    1210           0 :     if ( nFamily != SFX_STYLE_FAMILY_PARA )
    1211             :     {
    1212           0 :         return;
    1213             :     }
    1214             : 
    1215             :     OSL_ENSURE( pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style");
    1216           0 :     if ( pColl->AreListLevelIndentsApplicable() )
    1217             :     {
    1218             :         OSL_ENSURE( pColl->GetItemState( RES_PARATR_NUMRULE ) == SFX_ITEM_SET,
    1219             :                 "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - list level indents are applicable at paragraph style, but no list style found. Serious defect -> please inform OD." );
    1220           0 :         const OUString sNumRule = pColl->GetNumRule().GetValue();
    1221           0 :         if (!sNumRule.isEmpty())
    1222             :         {
    1223           0 :             const SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
    1224           0 :             if( pRule )
    1225             :             {
    1226           0 :                 const SwNumFmt& rFmt = pRule->Get( 0 );
    1227           0 :                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
    1228             :                 {
    1229           0 :                     SvxLRSpaceItem aLR( RES_LR_SPACE );
    1230           0 :                     aLR.SetTxtLeft( rFmt.GetIndentAt() );
    1231           0 :                     aLR.SetTxtFirstLineOfst( static_cast<short>(rFmt.GetFirstLineIndent()) );
    1232           0 :                     rSet.Put( aLR );
    1233             :                 }
    1234             :             }
    1235           0 :         }
    1236             :     }
    1237             : }
    1238             : 
    1239             : // handling of parameter <bResetIndentAttrsAtParagraphStyle>
    1240      211066 : void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
    1241             :                                   const bool bResetIndentAttrsAtParagraphStyle )
    1242             : {
    1243             :     // if applicable determine format first
    1244      211066 :     if(!bPhysical)
    1245           0 :         FillStyleSheet( FillPhysical );
    1246             : 
    1247      211066 :     SwImplShellAction aTmpSh( rDoc );
    1248             : 
    1249             :     OSL_ENSURE( &rSet != &aCoreSet, "SetItemSet with own Set is not allowed" );
    1250             : 
    1251      211066 :     if (rDoc.GetIDocumentUndoRedo().DoesUndo())
    1252             :     {
    1253        1010 :         SwRewriter aRewriter;
    1254        1010 :         aRewriter.AddRule( UndoArg1, GetName() );
    1255        1010 :         rDoc.GetIDocumentUndoRedo().StartUndo( UNDO_INSFMTATTR, &aRewriter );
    1256             :     }
    1257             : 
    1258      211066 :     SwFmt* pFmt = 0;
    1259      211066 :     SwPageDesc* pNewDsc = 0;
    1260      211066 :     sal_uInt16 nPgDscPos = 0;
    1261             : 
    1262      211066 :     switch(nFamily)
    1263             :     {
    1264             :         case SFX_STYLE_FAMILY_CHAR :
    1265             :             {
    1266             :                 OSL_ENSURE(pCharFmt, "Where's CharFormat");
    1267       21757 :                 pFmt = pCharFmt;
    1268             :             }
    1269       21757 :             break;
    1270             : 
    1271             :         case SFX_STYLE_FAMILY_PARA :
    1272             :         {
    1273             :             OSL_ENSURE(pColl, "Where's Collection");
    1274             :             const SfxPoolItem* pAutoUpdate;
    1275       41714 :             if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,false, &pAutoUpdate ))
    1276             :             {
    1277       41714 :                 pColl->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
    1278             :             }
    1279             : 
    1280             :             const SwCondCollItem* pCondItem;
    1281       41714 :             if( SFX_ITEM_SET != rSet.GetItemState( FN_COND_COLL, false,
    1282       41714 :                 (const SfxPoolItem**)&pCondItem ))
    1283       41714 :                 pCondItem = 0;
    1284             : 
    1285       41714 :             if( RES_CONDTXTFMTCOLL == pColl->Which() && pCondItem )
    1286             :             {
    1287           0 :                 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
    1288           0 :                 for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
    1289             :                 {
    1290           0 :                     SwCollCondition aCond( 0, pCmds[ i ].nCnd, pCmds[ i ].nSubCond );
    1291           0 :                     ((SwConditionTxtFmtColl*)pColl)->RemoveCondition( aCond );
    1292           0 :                     const OUString sStyle = pCondItem->GetStyle( i );
    1293           0 :                     if (sStyle.isEmpty())
    1294           0 :                         continue;
    1295           0 :                     SwFmt *const pFindFmt = lcl_FindParaFmt( rDoc, sStyle, 0, true );
    1296           0 :                     if (pFindFmt)
    1297             :                     {
    1298           0 :                         aCond.RegisterToFormat( *pFindFmt );
    1299           0 :                         ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond );
    1300             :                     }
    1301           0 :                 }
    1302             : 
    1303             :                 // Update document to new conditions
    1304           0 :                 SwCondCollCondChg aMsg( pColl );
    1305           0 :                 pColl->ModifyNotification( &aMsg, &aMsg );
    1306             :             }
    1307       41714 :             else if( pCondItem && !pColl->GetDepends() )
    1308             :             {
    1309             :                 // no conditional template, then first create and adopt
    1310             :                 // all important values
    1311             :                 SwConditionTxtFmtColl* pCColl = rDoc.MakeCondTxtFmtColl(
    1312           0 :                         pColl->GetName(), (SwTxtFmtColl*)pColl->DerivedFrom() );
    1313           0 :                 if( pColl != &pColl->GetNextTxtFmtColl() )
    1314           0 :                     pCColl->SetNextTxtFmtColl( pColl->GetNextTxtFmtColl() );
    1315             : 
    1316           0 :                 if( pColl->IsAssignedToListLevelOfOutlineStyle())
    1317           0 :                     pCColl->AssignToListLevelOfOutlineStyle(pColl->GetAssignedOutlineStyleLevel());
    1318             :                 else
    1319           0 :                     pCColl->DeleteAssignmentToListLevelOfOutlineStyle();
    1320             : 
    1321           0 :                 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
    1322           0 :                 for( sal_uInt16 i = 0; i < COND_COMMAND_COUNT; ++i )
    1323             :                 {
    1324           0 :                     const OUString sStyle = pCondItem->GetStyle( i );
    1325           0 :                     if (sStyle.isEmpty())
    1326           0 :                         continue;
    1327           0 :                     SwTxtFmtColl *const pFindFmt = lcl_FindParaFmt( rDoc, sStyle, 0, true );
    1328           0 :                     if (pFindFmt)
    1329             :                     {
    1330             :                         pCColl->InsertCondition( SwCollCondition( pFindFmt,
    1331           0 :                                     pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) );
    1332             :                     }
    1333           0 :                 }
    1334             : 
    1335           0 :                 rDoc.DelTxtFmtColl( pColl );
    1336           0 :                 pColl = pCColl;
    1337             :             }
    1338       41714 :             if ( bResetIndentAttrsAtParagraphStyle &&
    1339           0 :                  rSet.GetItemState( RES_PARATR_NUMRULE, false, 0 ) == SFX_ITEM_SET &&
    1340       41714 :                  rSet.GetItemState( RES_LR_SPACE, false, 0 ) != SFX_ITEM_SET &&
    1341           0 :                  pColl->GetItemState( RES_LR_SPACE, sal_False, 0 ) == SFX_ITEM_SET )
    1342             :             {
    1343           0 :                 rDoc.ResetAttrAtFormat( RES_LR_SPACE, *pColl );
    1344             :             }
    1345             : 
    1346             :             // #i56252: If a standard numbering style is assigned to a standard paragraph style
    1347             :             // we have to create a physical instance of the numbering style. If we do not and
    1348             :             // neither the paragraph style nor the numbering style is used in the document
    1349             :             // the numbering style will not be saved with the document and the assignment got lost.
    1350       41714 :             const SfxPoolItem* pNumRuleItem = 0;
    1351       41714 :             if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, false, &pNumRuleItem ) )
    1352             :             {   // Setting a numbering rule?
    1353          23 :                 const OUString sNumRule = ((SwNumRuleItem*)pNumRuleItem)->GetValue();
    1354          23 :                 if (!sNumRule.isEmpty())
    1355             :                 {
    1356          14 :                     SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
    1357          14 :                     if( !pRule )
    1358             :                     {   // Numbering rule not in use yet.
    1359           0 :                         sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sNumRule, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
    1360           0 :                         if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
    1361             :                         {
    1362           0 :                             pRule = rDoc.GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
    1363             :                         }
    1364             :                     }
    1365          23 :                 }
    1366             :             }
    1367             : 
    1368       41714 :             pFmt = pColl;
    1369             : 
    1370       41714 :             sal_uInt16 nId = pColl->GetPoolFmtId() &
    1371       41714 :                             ~ ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID );
    1372       41714 :             switch( GetMask() & ( 0x0fff & ~SWSTYLEBIT_CONDCOLL ) )
    1373             :             {
    1374             :                 case SWSTYLEBIT_TEXT:
    1375        5894 :                     nId |= COLL_TEXT_BITS;
    1376        5894 :                     break;
    1377             :                 case SWSTYLEBIT_CHAPTER:
    1378         464 :                     nId |= COLL_DOC_BITS;
    1379         464 :                     break;
    1380             :                 case SWSTYLEBIT_LIST:
    1381         879 :                     nId |= COLL_LISTS_BITS;
    1382         879 :                     break;
    1383             :                 case SWSTYLEBIT_IDX:
    1384        2243 :                     nId |= COLL_REGISTER_BITS;
    1385        2243 :                     break;
    1386             :                 case SWSTYLEBIT_EXTRA:
    1387        2403 :                     nId |= COLL_EXTRA_BITS;
    1388        2403 :                     break;
    1389             :                 case SWSTYLEBIT_HTML:
    1390           6 :                     nId |= COLL_HTML_BITS;
    1391           6 :                     break;
    1392             :             }
    1393       41714 :             pColl->SetPoolFmtId( nId );
    1394       41714 :             break;
    1395             :         }
    1396             :         case SFX_STYLE_FAMILY_FRAME:
    1397             :         {
    1398             :             OSL_ENSURE(pFrmFmt, "Where's FrmFmt");
    1399             :             const SfxPoolItem* pAutoUpdate;
    1400         651 :             if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,false, &pAutoUpdate ))
    1401             :             {
    1402         651 :                 pFrmFmt->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
    1403             :             }
    1404         651 :             pFmt = pFrmFmt;
    1405             :         }
    1406         651 :         break;
    1407             : 
    1408             :         case SFX_STYLE_FAMILY_PAGE :
    1409             :             {
    1410             :                 OSL_ENSURE(pDesc, "Where's PageDescriptor");
    1411             : 
    1412        3258 :                 if( rDoc.FindPageDescByName( pDesc->GetName(), &nPgDscPos ))
    1413             :                 {
    1414        3258 :                     pNewDsc = new SwPageDesc( *pDesc );
    1415             :                     // #i48949# - no undo actions for the
    1416             :                     // copy of the page style
    1417        3258 :                     ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
    1418        3258 :                     rDoc.CopyPageDesc(*pDesc, *pNewDsc); // #i7983#
    1419             : 
    1420        3258 :                     pFmt = &pNewDsc->GetMaster();
    1421             :                 }
    1422             :             }
    1423        3258 :             break;
    1424             : 
    1425             :         case SFX_STYLE_FAMILY_PSEUDO:
    1426             :             {
    1427             :                 OSL_ENSURE(pNumRule, "Where's NumRule");
    1428             : 
    1429      143686 :                 if (!pNumRule)
    1430           0 :                     break;
    1431             : 
    1432             :                 const SfxPoolItem* pItem;
    1433      143686 :                 switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
    1434             :                 {
    1435             :                 case SFX_ITEM_SET:
    1436             :                 {
    1437      143686 :                     SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
    1438      143686 :                     pSetRule->UnLinkGraphics();
    1439      143686 :                     SwNumRule aSetRule(*pNumRule);
    1440      143686 :                     aSetRule.SetSvxRule(*pSetRule, &rDoc);
    1441      143686 :                     rDoc.ChgNumRuleFmts( aSetRule );
    1442             :                 }
    1443      143686 :                 break;
    1444             :                 case SFX_ITEM_DONTCARE:
    1445             :                     // set NumRule to default values
    1446             :                     // what are the default values?
    1447             :                     {
    1448             :                         SwNumRule aRule( pNumRule->GetName(),
    1449             :                                          // #i89178#
    1450           0 :                                          numfunc::GetDefaultPositionAndSpaceMode() );
    1451           0 :                         rDoc.ChgNumRuleFmts( aRule );
    1452             :                     }
    1453           0 :                     break;
    1454             :                 }
    1455             :             }
    1456      143686 :             break;
    1457             : 
    1458             :         default:
    1459             :             OSL_ENSURE(!this, "unknown style family");
    1460             :     }
    1461             : 
    1462      211066 :     if( pFmt && rSet.Count())
    1463             :     {
    1464       67380 :         SfxItemIter aIter( rSet );
    1465       67380 :         const SfxPoolItem* pItem = aIter.GetCurItem();
    1466             :         while( true )
    1467             :         {
    1468      489710 :             if( IsInvalidItem( pItem ) )            // Clear
    1469             :             {
    1470             :                 // use method <SwDoc::ResetAttrAtFormat(..)> in order to
    1471             :                 // create an Undo object for the attribute reset.
    1472           0 :                 rDoc.ResetAttrAtFormat( rSet.GetWhichByPos(aIter.GetCurPos()),
    1473           0 :                                         *pFmt );
    1474             :             }
    1475             : 
    1476      489710 :             if( aIter.IsAtEnd() )
    1477       67380 :                 break;
    1478      422330 :             pItem = aIter.NextItem();
    1479             :         }
    1480      134760 :         SfxItemSet aSet(rSet);
    1481       67380 :         aSet.ClearInvalidItems();
    1482             : 
    1483       67380 :         if(SFX_STYLE_FAMILY_FRAME == nFamily)
    1484             :         {
    1485             :             //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
    1486             :             // and evtl. correct that item to ensure unique names for that type. This call may
    1487             :             // modify/correct entries inside of the given SfxItemSet
    1488         651 :             rDoc.CheckForUniqueItemForLineFillNameOrIndex(aSet);
    1489             :         }
    1490             : 
    1491       67380 :         aCoreSet.ClearItem();
    1492             : 
    1493       67380 :         if( pNewDsc )
    1494             :         {
    1495        3258 :             ::ItemSetToPageDesc( aSet, *pNewDsc );
    1496        3258 :             rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
    1497        3258 :             pDesc = &rDoc.GetPageDesc( nPgDscPos );
    1498        3258 :             rDoc.PreDelPageDesc(pNewDsc); // #i7983#
    1499        3258 :             delete pNewDsc;
    1500             :         }
    1501             :         else
    1502      131502 :             rDoc.ChgFmt(*pFmt, aSet);       // put all that is set
    1503             :     }
    1504             :     else
    1505             :     {
    1506      143686 :         aCoreSet.ClearItem();
    1507      143686 :         if( pNewDsc )       // we still need to delete it
    1508             :         {
    1509           0 :             rDoc.PreDelPageDesc(pNewDsc); // #i7983#
    1510           0 :             delete pNewDsc;
    1511             :         }
    1512             :     }
    1513             : 
    1514      211066 :     if (rDoc.GetIDocumentUndoRedo().DoesUndo())
    1515             :     {
    1516        1010 :         rDoc.GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
    1517      211066 :     }
    1518      211066 : }
    1519             : 
    1520           0 : static void lcl_SaveStyles( sal_uInt16 nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
    1521             : {
    1522           0 :     switch( nFamily )
    1523             :     {
    1524             :     case SFX_STYLE_FAMILY_CHAR:
    1525             :         {
    1526           0 :             const SwCharFmts& rTbl = *rDoc.GetCharFmts();
    1527           0 :             for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
    1528             :             {
    1529           0 :                 rArr.push_back( rTbl[ n ] );
    1530             :             }
    1531             :         }
    1532           0 :         break;
    1533             :     case SFX_STYLE_FAMILY_PARA:
    1534             :         {
    1535           0 :             const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
    1536           0 :             for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
    1537             :             {
    1538           0 :                 rArr.push_back( rTbl[ n ] );
    1539             :             }
    1540             :         }
    1541           0 :         break;
    1542             :     case SFX_STYLE_FAMILY_FRAME:
    1543             :         {
    1544           0 :             const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
    1545           0 :             for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
    1546             :             {
    1547           0 :                 rArr.push_back( rTbl[ n ] );
    1548             :             }
    1549             :         }
    1550           0 :         break;
    1551             : 
    1552             :     case SFX_STYLE_FAMILY_PAGE:
    1553             :         {
    1554           0 :             for( sal_uInt16 n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
    1555             :             {
    1556           0 :                 rArr.push_back( &rDoc.GetPageDesc( n ) );
    1557             :             }
    1558             :         }
    1559           0 :         break;
    1560             : 
    1561             :     case SFX_STYLE_FAMILY_PSEUDO:
    1562             :         {
    1563           0 :             const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
    1564           0 :             for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
    1565             :             {
    1566           0 :                 rArr.push_back( rTbl[ n ] );
    1567             :             }
    1568             :         }
    1569           0 :         break;
    1570             :     }
    1571           0 : }
    1572             : 
    1573           0 : static bool lcl_Contains(const std::vector<void*>& rArr, const void* p)
    1574             : {
    1575           0 :     return std::find( rArr.begin(), rArr.end(), p ) != rArr.end();
    1576             : }
    1577             : 
    1578           0 : static void lcl_DeleteInfoStyles( sal_uInt16 nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
    1579             : {
    1580             :     sal_uInt16 n, nCnt;
    1581           0 :     switch( nFamily )
    1582             :     {
    1583             :     case SFX_STYLE_FAMILY_CHAR:
    1584             :         {
    1585           0 :             std::deque<sal_uInt16> aDelArr;
    1586           0 :             const SwCharFmts& rTbl = *rDoc.GetCharFmts();
    1587           0 :             for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
    1588             :             {
    1589           0 :                 if( !lcl_Contains( rArr, rTbl[ n ] ))
    1590           0 :                     aDelArr.push_front( n );
    1591             :             }
    1592           0 :             for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
    1593           0 :                 rDoc.DelCharFmt( aDelArr[ n ] );
    1594             :         }
    1595           0 :         break;
    1596             : 
    1597             :     case SFX_STYLE_FAMILY_PARA :
    1598             :         {
    1599           0 :             std::deque<sal_uInt16> aDelArr;
    1600           0 :             const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
    1601           0 :             for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
    1602             :             {
    1603           0 :                 if( !lcl_Contains( rArr, rTbl[ n ] ))
    1604           0 :                     aDelArr.push_front( n );
    1605             :             }
    1606           0 :             for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
    1607           0 :                 rDoc.DelTxtFmtColl( aDelArr[ n ] );
    1608             :         }
    1609           0 :         break;
    1610             : 
    1611             :     case SFX_STYLE_FAMILY_FRAME:
    1612             :         {
    1613           0 :             std::deque<SwFrmFmt*> aDelArr;
    1614           0 :             const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
    1615           0 :             for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
    1616             :             {
    1617           0 :                 if( !lcl_Contains( rArr, rTbl[ n ] ))
    1618           0 :                     aDelArr.push_front( rTbl[ n ] );
    1619             :             }
    1620           0 :             for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
    1621           0 :                 rDoc.DelFrmFmt( aDelArr[ n ] );
    1622             :         }
    1623           0 :         break;
    1624             : 
    1625             :     case SFX_STYLE_FAMILY_PAGE:
    1626             :         {
    1627           0 :             std::deque<sal_uInt16> aDelArr;
    1628           0 :             for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
    1629             :             {
    1630           0 :                 if( !lcl_Contains( rArr, &rDoc.GetPageDesc( n ) ))
    1631           0 :                     aDelArr.push_front( n );
    1632             :             }
    1633           0 :             for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
    1634           0 :                 rDoc.DelPageDesc( aDelArr[ n ] );
    1635             :         }
    1636           0 :         break;
    1637             : 
    1638             :     case SFX_STYLE_FAMILY_PSEUDO:
    1639             :         {
    1640           0 :             std::deque<SwNumRule*> aDelArr;
    1641           0 :             const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
    1642           0 :             for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
    1643             :             {
    1644           0 :                 if( !lcl_Contains( rArr, rTbl[ n ] ))
    1645           0 :                     aDelArr.push_front( rTbl[ n ] );
    1646             :             }
    1647           0 :             for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
    1648           0 :                 rDoc.DelNumRule( aDelArr[ n ]->GetName() );
    1649             :         }
    1650           0 :         break;
    1651             :     }
    1652           0 : }
    1653             : 
    1654             : // determine the format
    1655      469801 : sal_Bool SwDocStyleSheet::FillStyleSheet( FillStyleType eFType )
    1656             : {
    1657      469801 :     sal_Bool bRet = sal_False;
    1658      469801 :     sal_uInt16 nPoolId = USHRT_MAX;
    1659      469801 :     SwFmt* pFmt = 0;
    1660             : 
    1661      469801 :     bool bCreate = FillPhysical == eFType;
    1662      469801 :     bool bDeleteInfo = false;
    1663      469801 :     bool bFillOnlyInfo = FillAllInfo == eFType;
    1664      469801 :     std::vector<void*> aDelArr;
    1665             : 
    1666      469801 :     switch(nFamily)
    1667             :     {
    1668             :     case SFX_STYLE_FAMILY_CHAR:
    1669       63281 :         pCharFmt = lcl_FindCharFmt(rDoc, aName, this, bCreate );
    1670       63281 :         bPhysical = 0 != pCharFmt;
    1671       63281 :         if( bFillOnlyInfo && !bPhysical )
    1672             :         {
    1673           0 :             bDeleteInfo = true;
    1674           0 :             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
    1675           0 :             pCharFmt = lcl_FindCharFmt(rDoc, aName, this, true );
    1676             :         }
    1677             : 
    1678       63281 :         pFmt = pCharFmt;
    1679       63281 :         if( !bCreate && !pFmt )
    1680             :         {
    1681       50356 :             if( aName == SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
    1682       25178 :                                             RES_POOLCOLL_TEXT_BEGIN ] )
    1683           0 :                 nPoolId = 0;
    1684             :             else
    1685       25178 :                 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
    1686             :         }
    1687             : 
    1688       63281 :         bRet = 0 != pCharFmt || USHRT_MAX != nPoolId;
    1689             : 
    1690       63281 :         if( bDeleteInfo )
    1691           0 :             pCharFmt = 0;
    1692       63281 :         break;
    1693             : 
    1694             :     case SFX_STYLE_FAMILY_PARA:
    1695             :         {
    1696      162723 :             pColl = lcl_FindParaFmt(rDoc, aName, this, bCreate);
    1697      162723 :             bPhysical = 0 != pColl;
    1698      162723 :             if( bFillOnlyInfo && !bPhysical )
    1699             :             {
    1700           0 :                 bDeleteInfo = true;
    1701           0 :                 ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
    1702           0 :                 pColl = lcl_FindParaFmt(rDoc, aName, this, true );
    1703             :             }
    1704             : 
    1705      162723 :             pFmt = pColl;
    1706      162723 :             if( pColl )
    1707      118810 :                 PresetFollow( pColl->GetNextTxtFmtColl().GetName() );
    1708       43913 :             else if( !bCreate )
    1709       43913 :                 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
    1710             : 
    1711      162723 :             bRet = 0 != pColl || USHRT_MAX != nPoolId;
    1712             : 
    1713      162723 :             if( bDeleteInfo )
    1714           0 :                 pColl = 0;
    1715             :         }
    1716      162723 :         break;
    1717             : 
    1718             :     case SFX_STYLE_FAMILY_FRAME:
    1719        6892 :         pFrmFmt = lcl_FindFrmFmt(rDoc,  aName, this, bCreate);
    1720        6892 :         bPhysical = 0 != pFrmFmt;
    1721        6892 :         if( bFillOnlyInfo && bPhysical )
    1722             :         {
    1723           0 :             bDeleteInfo = true;
    1724           0 :             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
    1725           0 :             pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, true );
    1726             :         }
    1727        6892 :         pFmt = pFrmFmt;
    1728        6892 :         if( !bCreate && !pFmt )
    1729        2136 :             nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
    1730             : 
    1731        6892 :         bRet = 0 != pFrmFmt || USHRT_MAX != nPoolId;
    1732             : 
    1733        6892 :         if( bDeleteInfo )
    1734           0 :             pFrmFmt = 0;
    1735        6892 :         break;
    1736             : 
    1737             :     case SFX_STYLE_FAMILY_PAGE:
    1738       19881 :         pDesc = lcl_FindPageDesc(rDoc, aName, this, bCreate);
    1739       19881 :         bPhysical = 0 != pDesc;
    1740       19881 :         if( bFillOnlyInfo && !pDesc )
    1741             :         {
    1742           0 :             bDeleteInfo = true;
    1743           0 :             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
    1744           0 :             pDesc = lcl_FindPageDesc( rDoc, aName, this, true );
    1745             :         }
    1746             : 
    1747       19881 :         if( pDesc )
    1748             :         {
    1749       15568 :             nPoolId = pDesc->GetPoolFmtId();
    1750       15568 :             nHelpId = pDesc->GetPoolHelpId();
    1751       15568 :             if( pDesc->GetPoolHlpFileId() != UCHAR_MAX )
    1752           0 :                 aHelpFile = *rDoc.GetDocPattern( pDesc->GetPoolHlpFileId() );
    1753             :             else
    1754       15568 :                 aHelpFile = "";
    1755             :         }
    1756        4313 :         else if( !bCreate )
    1757        4313 :             nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
    1758       19881 :         SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
    1759             : 
    1760       19881 :         bRet = 0 != pDesc || USHRT_MAX != nPoolId;
    1761       19881 :         if( bDeleteInfo )
    1762           0 :             pDesc = 0;
    1763       19881 :         break;
    1764             : 
    1765             :     case SFX_STYLE_FAMILY_PSEUDO:
    1766      217024 :         pNumRule = lcl_FindNumRule(rDoc, aName, this, bCreate);
    1767      217024 :         bPhysical = 0 != pNumRule;
    1768      217024 :         if( bFillOnlyInfo && !pNumRule )
    1769             :         {
    1770           0 :             bDeleteInfo = true;
    1771           0 :             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
    1772           0 :             pNumRule = lcl_FindNumRule( rDoc, aName, this, true );
    1773             :         }
    1774             : 
    1775      217024 :         if( pNumRule )
    1776             :         {
    1777      173713 :             nPoolId = pNumRule->GetPoolFmtId();
    1778      173713 :             nHelpId = pNumRule->GetPoolHelpId();
    1779      173713 :             if( pNumRule->GetPoolHlpFileId() != UCHAR_MAX )
    1780           0 :                 aHelpFile = *rDoc.GetDocPattern( pNumRule->GetPoolHlpFileId() );
    1781             :             else
    1782      173713 :                 aHelpFile = "";
    1783             :         }
    1784       43311 :         else if( !bCreate )
    1785       43311 :             nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
    1786      217024 :         SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
    1787             : 
    1788      217024 :         bRet = 0 != pNumRule || USHRT_MAX != nPoolId;
    1789             : 
    1790      217024 :         if( bDeleteInfo )
    1791           0 :             pNumRule = 0;
    1792      217024 :         break;
    1793             :         default:; //prevent warning
    1794             :     }
    1795             : 
    1796      876321 :     if( SFX_STYLE_FAMILY_CHAR == nFamily ||
    1797      650317 :         SFX_STYLE_FAMILY_PARA == nFamily ||
    1798      243797 :         SFX_STYLE_FAMILY_FRAME == nFamily )
    1799             :     {
    1800      232896 :         if( pFmt )
    1801      161669 :             nPoolId = pFmt->GetPoolFmtId();
    1802             : 
    1803      232896 :         sal_uInt16 _nMask = 0;
    1804      232896 :         if( pFmt == rDoc.GetDfltCharFmt() )
    1805         426 :             _nMask |= SFXSTYLEBIT_READONLY;
    1806      232470 :         else if( USER_FMT & nPoolId )
    1807       99585 :             _nMask |= SFXSTYLEBIT_USERDEF;
    1808             : 
    1809      232896 :         switch ( COLL_GET_RANGE_BITS & nPoolId )
    1810             :         {
    1811       76904 :         case COLL_TEXT_BITS:     _nMask |= SWSTYLEBIT_TEXT;   break;
    1812        4001 :         case COLL_DOC_BITS :     _nMask |= SWSTYLEBIT_CHAPTER; break;
    1813        8773 :         case COLL_LISTS_BITS:    _nMask |= SWSTYLEBIT_LIST;   break;
    1814       12881 :         case COLL_REGISTER_BITS: _nMask |= SWSTYLEBIT_IDX;    break;
    1815       14730 :         case COLL_EXTRA_BITS:    _nMask |= SWSTYLEBIT_EXTRA;      break;
    1816        1778 :         case COLL_HTML_BITS:     _nMask |= SWSTYLEBIT_HTML;   break;
    1817             :         }
    1818             : 
    1819      232896 :         if( pFmt )
    1820             :         {
    1821             :             OSL_ENSURE( bPhysical, "Format not found" );
    1822             : 
    1823      161669 :             nHelpId = pFmt->GetPoolHelpId();
    1824      161669 :             if( pFmt->GetPoolHlpFileId() != UCHAR_MAX )
    1825           0 :                 aHelpFile = *rDoc.GetDocPattern( pFmt->GetPoolHlpFileId() );
    1826             :             else
    1827      161669 :                 aHelpFile = "";
    1828             : 
    1829      161669 :             if( RES_CONDTXTFMTCOLL == pFmt->Which() )
    1830        6771 :                 _nMask |= SWSTYLEBIT_CONDCOLL;
    1831             :         }
    1832             : 
    1833      232896 :         SetMask( _nMask );
    1834             :     }
    1835      469801 :     if( bDeleteInfo && bFillOnlyInfo )
    1836           0 :         ::lcl_DeleteInfoStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
    1837      469801 :     return bRet;
    1838             : }
    1839             : 
    1840             : // Create new format in Core
    1841       23334 : void SwDocStyleSheet::Create()
    1842             : {
    1843       23334 :     switch(nFamily)
    1844             :     {
    1845             :         case SFX_STYLE_FAMILY_CHAR :
    1846        4545 :             pCharFmt = lcl_FindCharFmt( rDoc, aName );
    1847        4545 :             if( !pCharFmt )
    1848             :                 pCharFmt = rDoc.MakeCharFmt(aName,
    1849        4545 :                                             rDoc.GetDfltCharFmt());
    1850        4545 :             pCharFmt->SetAuto( false );
    1851        4545 :             break;
    1852             : 
    1853             :         case SFX_STYLE_FAMILY_PARA :
    1854        3566 :             pColl = lcl_FindParaFmt( rDoc, aName );
    1855        3566 :             if( !pColl )
    1856             :             {
    1857        3566 :                 SwTxtFmtColl *pPar = (*rDoc.GetTxtFmtColls())[0];
    1858        3566 :                 if( nMask & SWSTYLEBIT_CONDCOLL )
    1859           2 :                     pColl = rDoc.MakeCondTxtFmtColl( aName, pPar );
    1860             :                 else
    1861        3564 :                     pColl = rDoc.MakeTxtFmtColl( aName, pPar );
    1862             :             }
    1863        3566 :             break;
    1864             : 
    1865             :         case SFX_STYLE_FAMILY_FRAME:
    1866         161 :             pFrmFmt = lcl_FindFrmFmt( rDoc, aName );
    1867         161 :             if( !pFrmFmt )
    1868         161 :                 pFrmFmt = rDoc.MakeFrmFmt(aName, rDoc.GetDfltFrmFmt(), false, false);
    1869             : 
    1870         161 :             break;
    1871             : 
    1872             :         case SFX_STYLE_FAMILY_PAGE :
    1873         209 :             pDesc = lcl_FindPageDesc( rDoc, aName );
    1874         209 :             if( !pDesc )
    1875             :             {
    1876         209 :                 sal_uInt16 nId = rDoc.MakePageDesc(aName);
    1877         209 :                 pDesc = &rDoc.GetPageDesc(nId);
    1878             :             }
    1879         209 :             break;
    1880             : 
    1881             :         case SFX_STYLE_FAMILY_PSEUDO:
    1882       14853 :             pNumRule = lcl_FindNumRule( rDoc, aName );
    1883       14853 :             if( !pNumRule )
    1884             :             {
    1885       14853 :                 const OUString sTmpNm( aName.isEmpty() ? rDoc.GetUniqueNumRuleName() : aName );
    1886       14853 :                 SwNumRule* pRule = rDoc.GetNumRuleTbl()[
    1887             :                     rDoc.MakeNumRule( sTmpNm, 0, false,
    1888             :                                       // #i89178#
    1889       29706 :                                       numfunc::GetDefaultPositionAndSpaceMode() ) ];
    1890       14853 :                 pRule->SetAutoRule( sal_False );
    1891       14853 :                 if( aName.isEmpty() )
    1892             :                 {
    1893             :                     // #i91400#
    1894           0 :                     pRule->SetName( aName, rDoc );
    1895             :                 }
    1896       14853 :                 pNumRule = pRule;
    1897             :             }
    1898       14853 :             break;
    1899             :         default:; //prevent warning
    1900             :     }
    1901       23334 :     bPhysical = sal_True;
    1902       23334 :     aCoreSet.ClearItem();
    1903       23334 : }
    1904             : 
    1905       31219 : SwCharFmt* SwDocStyleSheet::GetCharFmt()
    1906             : {
    1907       31219 :     if(!bPhysical)
    1908         105 :         FillStyleSheet( FillPhysical );
    1909       31219 :     return pCharFmt;
    1910             : }
    1911             : 
    1912      159882 : SwTxtFmtColl* SwDocStyleSheet::GetCollection()
    1913             : {
    1914      159882 :     if(!bPhysical)
    1915         729 :         FillStyleSheet( FillPhysical );
    1916      159882 :     return pColl;
    1917             : }
    1918             : 
    1919       14520 : const SwPageDesc* SwDocStyleSheet::GetPageDesc()
    1920             : {
    1921       14520 :     if(!bPhysical)
    1922          27 :         FillStyleSheet( FillPhysical );
    1923       14520 :     return pDesc;
    1924             : }
    1925             : 
    1926      188650 : const SwNumRule * SwDocStyleSheet::GetNumRule()
    1927             : {
    1928      188650 :     if(!bPhysical)
    1929           1 :         FillStyleSheet( FillPhysical );
    1930      188650 :     return pNumRule;
    1931             : }
    1932             : 
    1933      130749 : void SwDocStyleSheet::SetNumRule(const SwNumRule& rRule)
    1934             : {
    1935             :     OSL_ENSURE(pNumRule, "Wo ist die NumRule");
    1936      130749 :     rDoc.ChgNumRuleFmts( rRule );
    1937      130749 : }
    1938             : 
    1939             : // re-generate Name AND Family from String
    1940             : // First() and Next() (see below) insert an identification letter at Pos.1
    1941             : 
    1942       63162 : void SwDocStyleSheet::PresetNameAndFamily(const OUString& rName)
    1943             : {
    1944       63162 :     switch( rName[0] )
    1945             :     {
    1946       42972 :     case cPARA:     nFamily = SFX_STYLE_FAMILY_PARA; break;
    1947         184 :     case cFRAME:    nFamily = SFX_STYLE_FAMILY_FRAME; break;
    1948        2859 :     case cPAGE:     nFamily = SFX_STYLE_FAMILY_PAGE; break;
    1949           0 :     case cNUMRULE:  nFamily = SFX_STYLE_FAMILY_PSEUDO; break;
    1950       17147 :     default:        nFamily = SFX_STYLE_FAMILY_CHAR; break;
    1951             :     }
    1952       63162 :     aName = rName.copy(1);
    1953       63162 : }
    1954             : 
    1955             : // Is the format physically present yet
    1956     1011653 : void SwDocStyleSheet::SetPhysical(sal_Bool bPhys)
    1957             : {
    1958     1011653 :     bPhysical = bPhys;
    1959             : 
    1960     1011653 :     if(!bPhys)
    1961             :     {
    1962      637369 :         pCharFmt = 0;
    1963      637369 :         pColl    = 0;
    1964      637369 :         pFrmFmt  = 0;
    1965      637369 :         pDesc    = 0;
    1966             :     }
    1967     1011653 : }
    1968             : 
    1969        5201 : SwFrmFmt* SwDocStyleSheet::GetFrmFmt()
    1970             : {
    1971        5201 :     if(!bPhysical)
    1972          59 :         FillStyleSheet( FillPhysical );
    1973        5201 :     return pFrmFmt;
    1974             : }
    1975             : 
    1976         557 : bool  SwDocStyleSheet::IsUsed() const
    1977             : {
    1978         557 :     if( !bPhysical )
    1979             :     {
    1980           0 :         SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
    1981           0 :         pThis->FillStyleSheet( FillOnlyName );
    1982             :     }
    1983             : 
    1984         557 :     if( !bPhysical )
    1985           0 :         return false;
    1986             : 
    1987             :     const SwModify* pMod;
    1988         557 :     switch( nFamily )
    1989             :     {
    1990           1 :     case SFX_STYLE_FAMILY_CHAR : pMod = pCharFmt;   break;
    1991         544 :     case SFX_STYLE_FAMILY_PARA : pMod = pColl;      break;
    1992           0 :     case SFX_STYLE_FAMILY_FRAME: pMod = pFrmFmt;    break;
    1993          12 :     case SFX_STYLE_FAMILY_PAGE : pMod = pDesc;      break;
    1994             : 
    1995             :     case SFX_STYLE_FAMILY_PSEUDO:
    1996           0 :             return pNumRule ? rDoc.IsUsed( *pNumRule ) : false;
    1997             : 
    1998             :     default:
    1999             :         OSL_ENSURE(!this, "unknown style family");
    2000           0 :         return false;
    2001             :     }
    2002         557 :     return rDoc.IsUsed( *pMod );
    2003             : }
    2004             : 
    2005           0 : sal_uLong  SwDocStyleSheet::GetHelpId( OUString& rFile )
    2006             : {
    2007           0 :     sal_uInt16 nId = 0;
    2008           0 :     sal_uInt16 nPoolId = 0;
    2009           0 :     unsigned char nFileId = UCHAR_MAX;
    2010             : 
    2011           0 :     rFile = "swrhlppi.hlp";
    2012             : 
    2013           0 :     const SwFmt* pTmpFmt = 0;
    2014           0 :     switch( nFamily )
    2015             :     {
    2016             :     case SFX_STYLE_FAMILY_CHAR :
    2017           0 :         if( !pCharFmt &&
    2018           0 :             0 == (pCharFmt = lcl_FindCharFmt( rDoc, aName, 0, false )) )
    2019             :         {
    2020           0 :             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
    2021           0 :             return USHRT_MAX == nId ? 0 : nId;
    2022             :         }
    2023           0 :         pTmpFmt = pCharFmt;
    2024           0 :         break;
    2025             : 
    2026             :     case SFX_STYLE_FAMILY_PARA:
    2027           0 :         if( !pColl &&
    2028           0 :             0 == ( pColl = lcl_FindParaFmt( rDoc, aName, 0, false )) )
    2029             :         {
    2030           0 :             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
    2031           0 :             return USHRT_MAX == nId ? 0 : nId;
    2032             :         }
    2033           0 :         pTmpFmt = pColl;
    2034           0 :         break;
    2035             : 
    2036             :     case SFX_STYLE_FAMILY_FRAME:
    2037           0 :         if( !pFrmFmt &&
    2038           0 :             0 == ( pFrmFmt = lcl_FindFrmFmt( rDoc, aName, 0, false ) ) )
    2039             :         {
    2040           0 :             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
    2041           0 :             return USHRT_MAX == nId ? 0 : nId;
    2042             :         }
    2043           0 :         pTmpFmt = pFrmFmt;
    2044           0 :         break;
    2045             : 
    2046             :     case SFX_STYLE_FAMILY_PAGE:
    2047           0 :         if( !pDesc &&
    2048           0 :             0 == ( pDesc = lcl_FindPageDesc( rDoc, aName, 0, false ) ) )
    2049             :         {
    2050           0 :             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
    2051           0 :             return USHRT_MAX == nId ? 0 : nId;
    2052             :         }
    2053             : 
    2054           0 :         nId = pDesc->GetPoolHelpId();
    2055           0 :         nFileId = pDesc->GetPoolHlpFileId();
    2056           0 :         nPoolId = pDesc->GetPoolFmtId();
    2057           0 :         break;
    2058             : 
    2059             :     case SFX_STYLE_FAMILY_PSEUDO:
    2060           0 :         if( !pNumRule &&
    2061           0 :             0 == ( pNumRule = lcl_FindNumRule( rDoc, aName, 0, false ) ) )
    2062             :         {
    2063           0 :             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
    2064           0 :             return USHRT_MAX == nId ? 0 : nId;
    2065             :         }
    2066             : 
    2067           0 :         nId = pNumRule->GetPoolHelpId();
    2068           0 :         nFileId = pNumRule->GetPoolHlpFileId();
    2069           0 :         nPoolId = pNumRule->GetPoolFmtId();
    2070           0 :         break;
    2071             : 
    2072             :     default:
    2073             :         OSL_ENSURE(!this, "unknown style family");
    2074           0 :         return 0;
    2075             :     }
    2076             : 
    2077           0 :     if( pTmpFmt )
    2078             :     {
    2079           0 :         nId = pTmpFmt->GetPoolHelpId();
    2080           0 :         nFileId = pTmpFmt->GetPoolHlpFileId();
    2081           0 :         nPoolId = pTmpFmt->GetPoolFmtId();
    2082             :     }
    2083             : 
    2084           0 :     if( UCHAR_MAX != nFileId )
    2085             :     {
    2086           0 :         const OUString *pTemplate = rDoc.GetDocPattern( nFileId );
    2087           0 :         if( pTemplate )
    2088             :         {
    2089           0 :             rFile = *pTemplate;
    2090             :         }
    2091             :     }
    2092           0 :     else if( !IsPoolUserFmt( nPoolId ) )
    2093             :     {
    2094           0 :         nId = nPoolId;
    2095             :     }
    2096             : 
    2097             :     // because SFX acts like that, with HelpId:
    2098           0 :     if( USHRT_MAX == nId )
    2099           0 :         nId = 0;        // don't show Help accordingly
    2100             : 
    2101           0 :     return nId;
    2102             : }
    2103             : 
    2104           0 : void  SwDocStyleSheet::SetHelpId( const OUString& r, sal_uLong nId )
    2105             : {
    2106           0 :     sal_uInt8 nFileId = static_cast< sal_uInt8 >(rDoc.SetDocPattern( r ));
    2107           0 :     sal_uInt16 nHId = static_cast< sal_uInt16 >(nId); //!! SFX changed over to ULONG arbitrarily!
    2108             : 
    2109           0 :     SwFmt* pTmpFmt = 0;
    2110           0 :     switch( nFamily )
    2111             :     {
    2112           0 :     case SFX_STYLE_FAMILY_CHAR : pTmpFmt = pCharFmt;    break;
    2113           0 :     case SFX_STYLE_FAMILY_PARA : pTmpFmt = pColl;       break;
    2114           0 :     case SFX_STYLE_FAMILY_FRAME: pTmpFmt = pFrmFmt;     break;
    2115             :     case SFX_STYLE_FAMILY_PAGE :
    2116           0 :         ((SwPageDesc*)pDesc)->SetPoolHelpId( nHId );
    2117           0 :         ((SwPageDesc*)pDesc)->SetPoolHlpFileId( nFileId );
    2118           0 :         break;
    2119             : 
    2120             :     case SFX_STYLE_FAMILY_PSEUDO:
    2121           0 :         ((SwNumRule*)pNumRule)->SetPoolHelpId( nHId );
    2122           0 :         ((SwNumRule*)pNumRule)->SetPoolHlpFileId( nFileId );
    2123           0 :         break;
    2124             : 
    2125             :     default:
    2126             :         OSL_ENSURE(!this, "unknown style family");
    2127           0 :         return ;
    2128             :     }
    2129           0 :     if( pTmpFmt )
    2130             :     {
    2131           0 :         pTmpFmt->SetPoolHelpId( nHId );
    2132           0 :         pTmpFmt->SetPoolHlpFileId( nFileId );
    2133             :     }
    2134             : }
    2135             : 
    2136             : // methods for DocStyleSheetPool
    2137        1849 : SwDocStyleSheetPool::SwDocStyleSheetPool( SwDoc& rDocument, sal_Bool bOrg )
    2138        1849 : : SfxStyleSheetBasePool( rDocument.GetAttrPool() )
    2139        1849 : , mxStyleSheet( new SwDocStyleSheet( rDocument, OUString(), this, SFX_STYLE_FAMILY_CHAR, 0 ) )
    2140        3698 : , rDoc( rDocument )
    2141             : {
    2142        1849 :     bOrganizer = bOrg;
    2143        1849 : }
    2144             : 
    2145        3676 :  SwDocStyleSheetPool::~SwDocStyleSheetPool()
    2146             : {
    2147        3676 : }
    2148             : 
    2149        1849 : void SAL_CALL SwDocStyleSheetPool::acquire(  ) throw ()
    2150             : {
    2151        1849 :     comphelper::OWeakTypeObject::acquire();
    2152        1849 : }
    2153             : 
    2154        1838 : void SAL_CALL SwDocStyleSheetPool::release(  ) throw ()
    2155             : {
    2156        1838 :     comphelper::OWeakTypeObject::release();
    2157        1838 : }
    2158             : 
    2159       23334 : SfxStyleSheetBase&   SwDocStyleSheetPool::Make( const OUString&   rName,
    2160             :                                                 SfxStyleFamily  eFam,
    2161             :                                                 sal_uInt16          _nMask)
    2162             : {
    2163       23334 :     mxStyleSheet->PresetName(rName);
    2164       23334 :     mxStyleSheet->PresetParent(OUString());
    2165       23334 :     mxStyleSheet->PresetFollow(OUString());
    2166       23334 :     mxStyleSheet->SetMask(_nMask) ;
    2167       23334 :     mxStyleSheet->SetFamily(eFam);
    2168       23334 :     mxStyleSheet->SetPhysical(sal_True);
    2169       23334 :     mxStyleSheet->Create();
    2170             : 
    2171       23334 :     return *mxStyleSheet.get();
    2172             : }
    2173             : 
    2174           0 : SfxStyleSheetBase*   SwDocStyleSheetPool::Create( const SfxStyleSheetBase& /*rOrg*/)
    2175             : {
    2176             :     OSL_ENSURE(!this , "Create im SW-Stylesheet-Pool geht nicht" );
    2177           0 :     return NULL;
    2178             : }
    2179             : 
    2180           0 : SfxStyleSheetBase*   SwDocStyleSheetPool::Create( const OUString &,
    2181             :                                                   SfxStyleFamily, sal_uInt16 )
    2182             : {
    2183             :     OSL_ENSURE( !this, "Create im SW-Stylesheet-Pool geht nicht" );
    2184           0 :     return NULL;
    2185             : }
    2186             : 
    2187           0 : void  SwDocStyleSheetPool::Replace( SfxStyleSheetBase& rSource,
    2188             :                                     SfxStyleSheetBase& rTarget )
    2189             : {
    2190           0 :     SfxStyleFamily eFamily( rSource.GetFamily() );
    2191           0 :     if( rSource.HasParentSupport())
    2192             :     {
    2193           0 :         const OUString sParentName = rSource.GetParent();
    2194           0 :         if (!sParentName.isEmpty())
    2195             :         {
    2196           0 :             SfxStyleSheetBase* pParentOfNew = Find( sParentName, eFamily );
    2197           0 :             if( pParentOfNew )
    2198           0 :                 rTarget.SetParent( sParentName );
    2199           0 :         }
    2200             :     }
    2201           0 :     if( rSource.HasFollowSupport())
    2202             :     {
    2203           0 :         const OUString sFollowName = rSource.GetFollow();
    2204           0 :         if (!sFollowName.isEmpty())
    2205             :         {
    2206           0 :             SfxStyleSheetBase* pFollowOfNew = Find( sFollowName, eFamily );
    2207           0 :             if( pFollowOfNew )
    2208           0 :                 rTarget.SetFollow( sFollowName );
    2209           0 :         }
    2210             :     }
    2211             : 
    2212           0 :     SwImplShellAction aTmpSh( rDoc );
    2213             : 
    2214           0 :     bool bSwSrcPool = GetAppName() == rSource.GetPool().GetAppName();
    2215           0 :     if( SFX_STYLE_FAMILY_PAGE == eFamily && bSwSrcPool )
    2216             :     {
    2217             :         // deal with separately!
    2218             :         SwPageDesc* pDestDsc =
    2219           0 :             (SwPageDesc*)((SwDocStyleSheet&)rTarget).GetPageDesc();
    2220             :         SwPageDesc* pCpyDsc =
    2221           0 :             (SwPageDesc*)((SwDocStyleSheet&)rSource).GetPageDesc();
    2222           0 :         rDoc.CopyPageDesc( *pCpyDsc, *pDestDsc );
    2223             :     }
    2224             :     else
    2225             :     {
    2226           0 :         const SwFmt *pSourceFmt = 0;
    2227           0 :         SwFmt *pTargetFmt = 0;
    2228           0 :         sal_uInt16 nPgDscPos = USHRT_MAX;
    2229           0 :         switch( eFamily )
    2230             :         {
    2231             :         case SFX_STYLE_FAMILY_CHAR :
    2232           0 :             if( bSwSrcPool )
    2233           0 :                 pSourceFmt = ((SwDocStyleSheet&)rSource).GetCharFmt();
    2234           0 :             pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCharFmt();
    2235           0 :             break;
    2236             :         case SFX_STYLE_FAMILY_PARA :
    2237           0 :             if( bSwSrcPool )
    2238           0 :                 pSourceFmt = ((SwDocStyleSheet&)rSource).GetCollection();
    2239           0 :             pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCollection();
    2240           0 :             break;
    2241             :         case SFX_STYLE_FAMILY_FRAME:
    2242           0 :             if( bSwSrcPool )
    2243           0 :                 pSourceFmt = ((SwDocStyleSheet&)rSource).GetFrmFmt();
    2244           0 :             pTargetFmt = ((SwDocStyleSheet&)rTarget).GetFrmFmt();
    2245           0 :             break;
    2246             :         case SFX_STYLE_FAMILY_PAGE:
    2247             :             {
    2248             :                 SwPageDesc *pDesc = rDoc.FindPageDescByName(
    2249             :                     ((SwDocStyleSheet&)rTarget).GetPageDesc()->GetName(),
    2250           0 :                     &nPgDscPos );
    2251             : 
    2252           0 :                 if( pDesc )
    2253           0 :                     pTargetFmt = &pDesc->GetMaster();
    2254             :             }
    2255           0 :             break;
    2256             :         case SFX_STYLE_FAMILY_PSEUDO:
    2257             :             // A NumRule only consists of one Item, so nothing has
    2258             :             // to be deleted here.
    2259           0 :             break;
    2260             :         default:; //prevent warning
    2261             :         }
    2262           0 :         if( pTargetFmt )
    2263             :         {
    2264           0 :             if( pSourceFmt )
    2265           0 :                 pTargetFmt->DelDiffs( *pSourceFmt );
    2266           0 :             else if( USHRT_MAX != nPgDscPos )
    2267           0 :                 pTargetFmt->ResetFmtAttr( RES_PAGEDESC, RES_FRMATR_END-1 );
    2268             :             else
    2269             :             {
    2270             :                 // #i73790# - method renamed
    2271           0 :                 pTargetFmt->ResetAllFmtAttr();
    2272             :             }
    2273             : 
    2274           0 :             if( USHRT_MAX != nPgDscPos )
    2275             :                 rDoc.ChgPageDesc( nPgDscPos,
    2276           0 :                                   rDoc.GetPageDesc(nPgDscPos) );
    2277             :         }
    2278           0 :         ((SwDocStyleSheet&)rTarget).SetItemSet( rSource.GetItemSet() );
    2279           0 :     }
    2280           0 : }
    2281             : 
    2282        8532 : SfxStyleSheetIteratorPtr SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, sal_uInt16 _nMask )
    2283             : {
    2284        8532 :     return SfxStyleSheetIteratorPtr(new SwStyleSheetIterator( this, eFam, _nMask ));
    2285             : }
    2286             : 
    2287        1838 : void SwDocStyleSheetPool::dispose()
    2288             : {
    2289        1838 :     mxStyleSheet.clear();
    2290        1838 : }
    2291             : 
    2292           1 : void SwDocStyleSheetPool::Remove( SfxStyleSheetBase* pStyle)
    2293             : {
    2294           1 :     if( !pStyle )
    2295           1 :         return;
    2296             : 
    2297           1 :     bool bBroadcast = true;
    2298           1 :     SwImplShellAction aTmpSh( rDoc );
    2299           2 :     const OUString sName = pStyle->GetName();
    2300           1 :     switch( pStyle->GetFamily() )
    2301             :     {
    2302             :     case SFX_STYLE_FAMILY_CHAR:
    2303             :         {
    2304           1 :             SwCharFmt* pFmt = lcl_FindCharFmt(rDoc, sName, 0, false );
    2305           1 :             if(pFmt)
    2306           1 :                 rDoc.DelCharFmt(pFmt);
    2307             :         }
    2308           1 :         break;
    2309             :     case SFX_STYLE_FAMILY_PARA:
    2310             :         {
    2311           0 :             SwTxtFmtColl* pColl = lcl_FindParaFmt(rDoc, sName, 0, false );
    2312           0 :             if(pColl)
    2313           0 :                 rDoc.DelTxtFmtColl(pColl);
    2314             :         }
    2315           0 :         break;
    2316             :     case SFX_STYLE_FAMILY_FRAME:
    2317             :         {
    2318           0 :             SwFrmFmt* pFmt = lcl_FindFrmFmt(rDoc, sName, 0, false );
    2319           0 :             if(pFmt)
    2320           0 :                 rDoc.DelFrmFmt(pFmt);
    2321             :         }
    2322           0 :         break;
    2323             :     case SFX_STYLE_FAMILY_PAGE :
    2324             :         {
    2325             :             sal_uInt16 nPos;
    2326           0 :             if( rDoc.FindPageDescByName( sName, &nPos ))
    2327           0 :                 rDoc.DelPageDesc( nPos );
    2328             :         }
    2329           0 :         break;
    2330             : 
    2331             :     case SFX_STYLE_FAMILY_PSEUDO:
    2332             :         {
    2333           0 :             if( !rDoc.DelNumRule( sName ) )
    2334             :                 // Only send Broadcast, when something was deleted
    2335           0 :                 bBroadcast = false;
    2336             :         }
    2337           0 :         break;
    2338             : 
    2339             :     default:
    2340             :         OSL_ENSURE(!this, "unknown style family");
    2341           0 :         bBroadcast = false;
    2342             :     }
    2343             : 
    2344           1 :     if( bBroadcast )
    2345           2 :         Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *pStyle ) );
    2346             : }
    2347             : 
    2348        5630 : bool  SwDocStyleSheetPool::SetParent( SfxStyleFamily eFam,
    2349             :                                       const OUString &rStyle, const OUString &rParent )
    2350             : {
    2351        5630 :     SwFmt* pFmt = 0, *pParent = 0;
    2352        5630 :     switch( eFam )
    2353             :     {
    2354             :     case SFX_STYLE_FAMILY_CHAR :
    2355        2734 :         if( 0 != ( pFmt = lcl_FindCharFmt( rDoc, rStyle ) ) && !rParent.isEmpty() )
    2356        2734 :             pParent = lcl_FindCharFmt(rDoc, rParent );
    2357        2734 :         break;
    2358             : 
    2359             :     case SFX_STYLE_FAMILY_PARA :
    2360        2896 :         if( 0 != ( pFmt = lcl_FindParaFmt( rDoc, rStyle ) ) && !rParent.isEmpty() )
    2361        2896 :             pParent = lcl_FindParaFmt( rDoc, rParent );
    2362        2896 :         break;
    2363             : 
    2364             :     case SFX_STYLE_FAMILY_FRAME:
    2365           0 :         if( 0 != ( pFmt = lcl_FindFrmFmt( rDoc, rStyle ) ) && !rParent.isEmpty() )
    2366           0 :             pParent = lcl_FindFrmFmt( rDoc, rParent );
    2367           0 :         break;
    2368             : 
    2369             :     case SFX_STYLE_FAMILY_PAGE:
    2370             :     case SFX_STYLE_FAMILY_PSEUDO:
    2371           0 :         break;
    2372             : 
    2373             :     default:
    2374             :         OSL_ENSURE(!this, "unknown style family");
    2375             :     }
    2376             : 
    2377        5630 :     bool bRet = false;
    2378       22520 :     if( pFmt && pFmt->DerivedFrom() &&
    2379       22520 :         pFmt->DerivedFrom()->GetName() != rParent )
    2380             :     {
    2381             :         {
    2382        5630 :             SwImplShellAction aTmpSh( rDoc );
    2383        5630 :             bRet = pFmt->SetDerivedFrom( pParent );
    2384             :         }
    2385             : 
    2386        5630 :         if( bRet )
    2387             :         {
    2388             :             // only for Broadcasting
    2389        5630 :             mxStyleSheet->PresetName( rStyle );
    2390        5630 :             mxStyleSheet->PresetParent( rParent );
    2391        5630 :             if( SFX_STYLE_FAMILY_PARA == eFam )
    2392             :                 mxStyleSheet->PresetFollow( ((SwTxtFmtColl*)pFmt)->
    2393        2896 :                         GetNextTxtFmtColl().GetName() );
    2394             :             else
    2395        2734 :                 mxStyleSheet->PresetFollow( OUString() );
    2396             : 
    2397             :             Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
    2398        5630 :                                             *(mxStyleSheet.get()) ) );
    2399             :         }
    2400             :     }
    2401             : 
    2402        5630 :     return bRet;
    2403             : }
    2404             : 
    2405      443419 : SfxStyleSheetBase* SwDocStyleSheetPool::Find( const OUString& rName,
    2406             :                                               SfxStyleFamily eFam, sal_uInt16 n )
    2407             : {
    2408      443419 :     sal_uInt16 nSMask = n;
    2409      443419 :     if( SFX_STYLE_FAMILY_PARA == eFam && rDoc.get(IDocumentSettingAccess::HTML_MODE) )
    2410             :     {
    2411             :         // then only HTML-Templates are of interest
    2412           0 :         if( USHRT_MAX == nSMask )
    2413           0 :             nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED;
    2414             :         else
    2415             :             nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
    2416           0 :                                 SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
    2417           0 :         if( !nSMask )
    2418           0 :             nSMask = SWSTYLEBIT_HTML;
    2419             :     }
    2420             : 
    2421      443419 :     const bool bSearchUsed = ( n != SFXSTYLEBIT_ALL && n & SFXSTYLEBIT_USED );
    2422      443419 :     const SwModify* pMod = 0;
    2423             : 
    2424      443419 :     mxStyleSheet->SetPhysical( sal_False );
    2425      443419 :     mxStyleSheet->PresetName( rName );
    2426      443419 :     mxStyleSheet->SetFamily( eFam );
    2427      443419 :     sal_Bool bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
    2428             : 
    2429      443419 :     if( mxStyleSheet->IsPhysical() )
    2430             :     {
    2431      337824 :         switch( eFam )
    2432             :         {
    2433             :         case SFX_STYLE_FAMILY_CHAR:
    2434       29996 :             pMod = mxStyleSheet->GetCharFmt();
    2435       29996 :             break;
    2436             : 
    2437             :         case SFX_STYLE_FAMILY_PARA:
    2438      115273 :             pMod = mxStyleSheet->GetCollection();
    2439      115273 :             break;
    2440             : 
    2441             :         case SFX_STYLE_FAMILY_FRAME:
    2442        4546 :             pMod = mxStyleSheet->GetFrmFmt();
    2443        4546 :             break;
    2444             : 
    2445             :         case SFX_STYLE_FAMILY_PAGE:
    2446       14302 :             pMod = mxStyleSheet->GetPageDesc();
    2447       14302 :             break;
    2448             : 
    2449             :         case SFX_STYLE_FAMILY_PSEUDO:
    2450             :             {
    2451      173707 :                 const SwNumRule* pRule = mxStyleSheet->GetNumRule();
    2452      347414 :                 if( pRule &&
    2453      347414 :                     !bSearchUsed &&
    2454      173707 :                     (( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
    2455           0 :                             ? !(pRule->GetPoolFmtId() & USER_FMT)
    2456             :                                 // searched for used and found none
    2457             :                             : bSearchUsed ))
    2458           0 :                     bFnd = sal_False;
    2459             :             }
    2460      173707 :             break;
    2461             : 
    2462             :         default:
    2463             :             OSL_ENSURE(!this, "unknown style family");
    2464             :         }
    2465             :     }
    2466             : 
    2467             :     // then evaluate the mask:
    2468      443419 :     if( pMod && !bSearchUsed )
    2469             :     {
    2470             :         const sal_uInt16 nId = SFX_STYLE_FAMILY_PAGE == eFam
    2471             :                         ? ((SwPageDesc*)pMod)->GetPoolFmtId()
    2472      164102 :                         : ((SwFmt*)pMod)->GetPoolFmtId();
    2473             : 
    2474      164102 :         if( ( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
    2475           0 :             ? !(nId & USER_FMT)
    2476             :                 // searched for used and found none
    2477             :             : bSearchUsed )
    2478           0 :             bFnd = sal_False;
    2479             :     }
    2480      443419 :     return bFnd ? mxStyleSheet.get() : 0;
    2481             : }
    2482             : 
    2483        8532 : SwStyleSheetIterator::SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
    2484             :                                 SfxStyleFamily eFam, sal_uInt16 n )
    2485             :     : SfxStyleSheetIterator( pBase, eFam, n ),
    2486        8532 :     mxIterSheet( new SwDocStyleSheet( pBase->GetDoc(), OUString(), pBase, SFX_STYLE_FAMILY_CHAR, 0 ) ),
    2487       17064 :     mxStyleSheet( new SwDocStyleSheet( pBase->GetDoc(), OUString(), pBase, SFX_STYLE_FAMILY_CHAR, 0 ) )
    2488             : {
    2489        8532 :     bFirstCalled = sal_False;
    2490        8532 :     nLastPos = 0;
    2491        8532 :     StartListening( *pBase );
    2492        8532 : }
    2493             : 
    2494       25593 : SwStyleSheetIterator::~SwStyleSheetIterator()
    2495             : {
    2496        8531 :     EndListening( mxIterSheet->GetPool() );
    2497       17062 : }
    2498             : 
    2499        5647 : sal_uInt16  SwStyleSheetIterator::Count()
    2500             : {
    2501             :     // let the list fill correctly!!
    2502        5647 :     if( !bFirstCalled )
    2503        1013 :         First();
    2504        5647 :     return aLst.size();
    2505             : }
    2506             : 
    2507       22234 : SfxStyleSheetBase*  SwStyleSheetIterator::operator[]( sal_uInt16 nIdx )
    2508             : {
    2509             :     // found
    2510       22234 :     if( !bFirstCalled )
    2511           0 :         First();
    2512       22234 :     mxStyleSheet->PresetNameAndFamily( aLst[ nIdx ] );
    2513       22234 :     mxStyleSheet->SetPhysical( sal_False );
    2514       22234 :     mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
    2515             : 
    2516       22234 :     return mxStyleSheet.get();
    2517             : }
    2518             : 
    2519       11937 : SfxStyleSheetBase*  SwStyleSheetIterator::First()
    2520             : {
    2521             :     // Delete old list
    2522       11937 :     bFirstCalled = sal_True;
    2523       11937 :     nLastPos = 0;
    2524       11937 :     aLst.Erase();
    2525             : 
    2526             :     // Delete current
    2527       11937 :     mxIterSheet->Reset();
    2528             : 
    2529       11937 :     SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
    2530       11937 :     const sal_uInt16 nSrchMask = nMask;
    2531       11937 :     const sal_Bool bIsSearchUsed = SearchUsed();
    2532             : 
    2533       11937 :     bool bSearchHidden = ( nMask & SFXSTYLEBIT_HIDDEN );
    2534       11937 :     bool bOnlyHidden = nMask == SFXSTYLEBIT_HIDDEN;
    2535             : 
    2536       11937 :     const sal_Bool bOrganizer = ((SwDocStyleSheetPool*)pBasePool)->IsOrganizerMode();
    2537       11937 :     bool bAll = ( nSrchMask & SFXSTYLEBIT_ALL_VISIBLE ) == SFXSTYLEBIT_ALL_VISIBLE;
    2538             : 
    2539       11937 :     if( nSearchFamily == SFX_STYLE_FAMILY_CHAR
    2540       11569 :      || nSearchFamily == SFX_STYLE_FAMILY_ALL )
    2541             :     {
    2542         368 :         const sal_uInt16 nArrLen = rDoc.GetCharFmts()->size();
    2543        8119 :         for( sal_uInt16 i = 0; i < nArrLen; i++ )
    2544             :         {
    2545        7751 :             SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
    2546             : 
    2547        7751 :             const bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFmt));
    2548        7751 :             if( ( !bSearchHidden && pFmt->IsHidden() && !bUsed ) || ( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() ) )
    2549           0 :                 continue;
    2550             : 
    2551        7751 :             if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !pFmt->IsHidden( ) )
    2552           0 :                 continue;
    2553             : 
    2554        7751 :             if( !bUsed )
    2555             :             {
    2556             :                 // Standard is no User template
    2557        7751 :                 const sal_uInt16 nId = rDoc.GetDfltCharFmt() == pFmt ?
    2558             :                         sal_uInt16( RES_POOLCHR_INET_NORMAL ):
    2559        7751 :                                 pFmt->GetPoolFmtId();
    2560       15502 :                 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
    2561             :                     ? !(nId & USER_FMT)
    2562             :                         // searched for used and found none
    2563        7751 :                     : bIsSearchUsed )
    2564             :                 {
    2565           0 :                     continue;
    2566             :                 }
    2567             : 
    2568       15502 :                 if( rDoc.get(IDocumentSettingAccess::HTML_MODE) && !(nId & USER_FMT) &&
    2569             :                     !( RES_POOLCHR_HTML_BEGIN <= nId &&
    2570           0 :                           nId < RES_POOLCHR_HTML_END ) &&
    2571           0 :                     RES_POOLCHR_INET_NORMAL != nId &&
    2572           0 :                     RES_POOLCHR_INET_VISIT != nId &&
    2573        7751 :                     RES_POOLCHR_FOOTNOTE  != nId &&
    2574             :                     RES_POOLCHR_ENDNOTE != nId )
    2575           0 :                     continue;
    2576             :             }
    2577             : 
    2578        7751 :             aLst.Append( cCHAR, pFmt == rDoc.GetDfltCharFmt()
    2579         368 :                         ? SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
    2580         368 :                                                 RES_POOLCOLL_TEXT_BEGIN ]
    2581        8119 :                         : pFmt->GetName() );
    2582             :         }
    2583             : 
    2584             :         // PoolFormate
    2585         368 :         if( bAll )
    2586             :         {
    2587         368 :             if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) )
    2588         368 :                 AppendStyleList(SwStyleNameMapper::GetChrFmtUINameArray(),
    2589             :                                 bIsSearchUsed, bSearchHidden, bOnlyHidden,
    2590         736 :                                 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
    2591             :             else
    2592             :             {
    2593           0 :                 aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
    2594           0 :                         RES_POOLCHR_INET_NORMAL - RES_POOLCHR_BEGIN ] );
    2595           0 :                 aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
    2596           0 :                         RES_POOLCHR_INET_VISIT - RES_POOLCHR_BEGIN ] );
    2597           0 :                 aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
    2598           0 :                         RES_POOLCHR_ENDNOTE - RES_POOLCHR_BEGIN ] );
    2599           0 :                 aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
    2600           0 :                         RES_POOLCHR_FOOTNOTE - RES_POOLCHR_BEGIN ] );
    2601             :             }
    2602         368 :             AppendStyleList(SwStyleNameMapper::GetHTMLChrFmtUINameArray(),
    2603             :                                 bIsSearchUsed, bSearchHidden, bOnlyHidden,
    2604         736 :                                 nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
    2605             :         }
    2606             :     }
    2607             : 
    2608       13341 :     if( nSearchFamily == SFX_STYLE_FAMILY_PARA ||
    2609        1404 :         nSearchFamily == SFX_STYLE_FAMILY_ALL )
    2610             :     {
    2611       10533 :         sal_uInt16 nSMask = nSrchMask;
    2612       10533 :         if( rDoc.get(IDocumentSettingAccess::HTML_MODE) )
    2613             :         {
    2614             :             // then only HTML-Template are of interest
    2615          38 :             if( SFXSTYLEBIT_ALL_VISIBLE == ( nSMask & SFXSTYLEBIT_ALL_VISIBLE ) )
    2616             :                 nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF |
    2617           2 :                             SFXSTYLEBIT_USED;
    2618             :             else
    2619             :                 nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
    2620          36 :                                 SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
    2621          38 :             if( !nSMask )
    2622          36 :                 nSMask = SWSTYLEBIT_HTML;
    2623             :         }
    2624             : 
    2625       10533 :         const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->size();
    2626       85123 :         for( sal_uInt16 i = 0; i < nArrLen; i++ )
    2627             :         {
    2628       74590 :             SwTxtFmtColl* pColl = (*rDoc.GetTxtFmtColls())[ i ];
    2629             : 
    2630       74590 :             const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl);
    2631       74590 :             if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed ) || pColl->IsDefault() )
    2632       10533 :                 continue;
    2633             : 
    2634       64057 :             if ( nSMask == SFXSTYLEBIT_HIDDEN && !pColl->IsHidden( ) )
    2635           0 :                 continue;
    2636             : 
    2637       64057 :             if( !(bIsSearchUsed && bUsed ))
    2638             :             {
    2639       54221 :                 const sal_uInt16 nId = pColl->GetPoolFmtId();
    2640       54221 :                 switch ( (nSMask & ~SFXSTYLEBIT_USED) )
    2641             :                 {
    2642             :                 case SFXSTYLEBIT_USERDEF:
    2643           0 :                     if(!IsPoolUserFmt(nId)) continue;
    2644           0 :                     break;
    2645             :                 case SWSTYLEBIT_TEXT:
    2646           0 :                     if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue;
    2647           0 :                     break;
    2648             :                 case SWSTYLEBIT_CHAPTER:
    2649           0 :                     if((nId  & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue;
    2650           0 :                     break;
    2651             :                 case SWSTYLEBIT_LIST:
    2652           0 :                     if((nId  & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue;
    2653           0 :                     break;
    2654             :                 case SWSTYLEBIT_IDX:
    2655           0 :                     if((nId  & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue;
    2656           0 :                     break;
    2657             :                 case SWSTYLEBIT_EXTRA:
    2658           0 :                     if((nId  & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue;
    2659           0 :                     break;
    2660             :                 case SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF:
    2661          24 :                     if(IsPoolUserFmt(nId))
    2662           0 :                         break;
    2663             :                     // otherwise move on
    2664             :                 case SWSTYLEBIT_HTML:
    2665         384 :                     if( (nId  & COLL_GET_RANGE_BITS) != COLL_HTML_BITS)
    2666             :                     {
    2667             :                         // but some we also want to see in this section
    2668         346 :                         bool bContinue = true;
    2669         346 :                         switch( nId )
    2670             :                         {
    2671             :                         case RES_POOLCOLL_SENDADRESS:   //  --> ADDRESS
    2672             :                         case RES_POOLCOLL_TABLE_HDLN:   //  --> TH
    2673             :                         case RES_POOLCOLL_TABLE:        //  --> TD
    2674             :                         case RES_POOLCOLL_TEXT:         //  --> P
    2675             :                         case RES_POOLCOLL_HEADLINE_BASE://  --> H
    2676             :                         case RES_POOLCOLL_HEADLINE1:    //  --> H1
    2677             :                         case RES_POOLCOLL_HEADLINE2:    //  --> H2
    2678             :                         case RES_POOLCOLL_HEADLINE3:    //  --> H3
    2679             :                         case RES_POOLCOLL_HEADLINE4:    //  --> H4
    2680             :                         case RES_POOLCOLL_HEADLINE5:    //  --> H5
    2681             :                         case RES_POOLCOLL_HEADLINE6:    //  --> H6
    2682             :                         case RES_POOLCOLL_STANDARD:     //  --> P
    2683             :                         case RES_POOLCOLL_FOOTNOTE:
    2684             :                         case RES_POOLCOLL_ENDNOTE:
    2685         156 :                             bContinue = false;
    2686         156 :                             break;
    2687             :                         }
    2688         346 :                         if( bContinue )
    2689         190 :                             continue;
    2690             :                     }
    2691         194 :                     break;
    2692             :                 case SWSTYLEBIT_CONDCOLL:
    2693           0 :                     if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue;
    2694           0 :                     break;
    2695             :                 default:
    2696             :                     // searched for used and found none
    2697       53837 :                     if( bIsSearchUsed )
    2698       46406 :                         continue;
    2699             :                 }
    2700             :             }
    2701       17461 :             aLst.Append( cPARA, pColl->GetName() );
    2702             :         }
    2703             : 
    2704       10533 :         bAll = ( nSMask & SFXSTYLEBIT_ALL_VISIBLE ) == SFXSTYLEBIT_ALL_VISIBLE;
    2705       10533 :         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_TEXT )
    2706        1217 :             AppendStyleList(SwStyleNameMapper::GetTextUINameArray(),
    2707        2434 :                             bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA );
    2708       10533 :         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CHAPTER )
    2709        1217 :             AppendStyleList(SwStyleNameMapper::GetDocUINameArray(),
    2710        2434 :                             bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
    2711       10533 :         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_LIST )
    2712        1217 :             AppendStyleList(SwStyleNameMapper::GetListsUINameArray(),
    2713        2434 :                             bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
    2714       10533 :         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_IDX )
    2715        1217 :             AppendStyleList(SwStyleNameMapper::GetRegisterUINameArray(),
    2716        2434 :                             bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
    2717       10533 :         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_EXTRA )
    2718        1217 :             AppendStyleList(SwStyleNameMapper::GetExtraUINameArray(),
    2719        2434 :                             bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
    2720       10533 :         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CONDCOLL )
    2721             :         {
    2722        1217 :             if( !bIsSearchUsed ||
    2723           0 :                 rDoc.IsPoolTxtCollUsed( RES_POOLCOLL_TEXT ))
    2724        1217 :                 aLst.Append( cPARA, SwStyleNameMapper::GetTextUINameArray()[
    2725        1217 :                         RES_POOLCOLL_TEXT - RES_POOLCOLL_TEXT_BEGIN ] );
    2726             :         }
    2727       19849 :         if ( bAll ||
    2728       18596 :             (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_HTML ||
    2729        9280 :             (nSMask & ~SFXSTYLEBIT_USED) ==
    2730             :                         (SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF) )
    2731             :         {
    2732        1255 :             AppendStyleList(SwStyleNameMapper::GetHTMLUINameArray(),
    2733        2510 :                             bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
    2734        1255 :             if( !bAll )
    2735             :             {
    2736             :                 // then also the ones, that we are mapping:
    2737             :                 static sal_uInt16 aPoolIds[] = {
    2738             :                     RES_POOLCOLL_SENDADRESS,    //  --> ADDRESS
    2739             :                     RES_POOLCOLL_TABLE_HDLN,    //  --> TH
    2740             :                     RES_POOLCOLL_TABLE,     //  --> TD
    2741             :                     RES_POOLCOLL_STANDARD,      //  --> P
    2742             :                     RES_POOLCOLL_TEXT,          //  --> P
    2743             :                     RES_POOLCOLL_HEADLINE_BASE, //  --> H
    2744             :                     RES_POOLCOLL_HEADLINE1, //  --> H1
    2745             :                     RES_POOLCOLL_HEADLINE2, //  --> H2
    2746             :                     RES_POOLCOLL_HEADLINE3, //  --> H3
    2747             :                     RES_POOLCOLL_HEADLINE4, //  --> H4
    2748             :                     RES_POOLCOLL_HEADLINE5, //  --> H5
    2749             :                     RES_POOLCOLL_HEADLINE6, //  --> H6
    2750             :                     RES_POOLCOLL_FOOTNOTE,
    2751             :                     RES_POOLCOLL_ENDNOTE,
    2752             :                     0
    2753             :                     };
    2754             : 
    2755          38 :                 sal_uInt16* pPoolIds = aPoolIds;
    2756          38 :                 OUString s;
    2757         608 :                 while( *pPoolIds )
    2758             :                 {
    2759         532 :                     if( !bIsSearchUsed || rDoc.IsPoolTxtCollUsed( *pPoolIds ) )
    2760             :                         aLst.Append( cPARA,
    2761         100 :                             s = SwStyleNameMapper::GetUIName( *pPoolIds, s ));
    2762         532 :                     ++pPoolIds;
    2763          38 :                 }
    2764             :             }
    2765             :         }
    2766             :     }
    2767             : 
    2768       23027 :     if( nSearchFamily == SFX_STYLE_FAMILY_FRAME ||
    2769       11090 :         nSearchFamily == SFX_STYLE_FAMILY_ALL )
    2770             :     {
    2771         847 :         const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->size();
    2772        2578 :         for( sal_uInt16 i = 0; i < nArrLen; i++ )
    2773             :         {
    2774        1731 :             SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
    2775             : 
    2776        1731 :             bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFmt));
    2777        1731 :             if( ( !bSearchHidden && pFmt->IsHidden( ) && !bUsed ) || pFmt->IsDefault() || pFmt->IsAuto() )
    2778        1699 :                 continue;
    2779             : 
    2780          32 :             if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !pFmt->IsHidden( ) )
    2781           0 :                 continue;
    2782             : 
    2783          32 :             const sal_uInt16 nId = pFmt->GetPoolFmtId();
    2784          32 :             if( !bUsed )
    2785             :             {
    2786          52 :                 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
    2787             :                     ? !(nId & USER_FMT)
    2788             :                     // searched for used and found none
    2789          26 :                     : bIsSearchUsed )
    2790             :                 {
    2791           6 :                     continue;
    2792             :                 }
    2793             :             }
    2794             : 
    2795          26 :             aLst.Append( cFRAME, pFmt->GetName() );
    2796             :         }
    2797             : 
    2798             :         // PoolFormate
    2799         847 :         if ( bAll )
    2800          33 :             AppendStyleList(SwStyleNameMapper::GetFrmFmtUINameArray(),
    2801          66 :                                     bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, cFRAME);
    2802             :     }
    2803             : 
    2804       23685 :     if( nSearchFamily == SFX_STYLE_FAMILY_PAGE ||
    2805       11748 :         nSearchFamily == SFX_STYLE_FAMILY_ALL )
    2806             :     {
    2807         189 :         const sal_uInt16 nCount = rDoc.GetPageDescCnt();
    2808        1270 :         for(sal_uInt16 i = 0; i < nCount; ++i)
    2809             :         {
    2810        1081 :             const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
    2811        1081 :             const sal_uInt16 nId = rDesc.GetPoolFmtId();
    2812        1081 :             bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc));
    2813        1081 :             if( !bUsed )
    2814             :             {
    2815        2162 :                 if ( ( !bSearchHidden && rDesc.IsHidden() ) ||
    2816        1081 :                        ( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
    2817             :                     ? !(nId & USER_FMT)
    2818             :                     // searched for used and found none
    2819        1081 :                     : bIsSearchUsed ) )
    2820           0 :                     continue;
    2821             :             }
    2822             : 
    2823        1081 :             if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !rDesc.IsHidden( ) )
    2824           0 :                 continue;
    2825             : 
    2826        1081 :             aLst.Append( cPAGE, rDesc.GetName() );
    2827             :         }
    2828         189 :         if ( bAll )
    2829         189 :             AppendStyleList(SwStyleNameMapper::GetPageDescUINameArray(),
    2830         378 :                             bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, cPAGE);
    2831             :     }
    2832             : 
    2833       23874 :     if( nSearchFamily == SFX_STYLE_FAMILY_PSEUDO ||
    2834       11937 :         nSearchFamily == SFX_STYLE_FAMILY_ALL )
    2835             :     {
    2836           0 :         const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
    2837           0 :         for(sal_uInt16 i = 0; i < rNumTbl.size(); ++i)
    2838             :         {
    2839           0 :             const SwNumRule& rRule = *rNumTbl[ i ];
    2840           0 :             if( !rRule.IsAutoRule() )
    2841             :             {
    2842           0 :                 if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !rRule.IsHidden( ) )
    2843           0 :                     continue;
    2844             : 
    2845           0 :                 bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rRule) );
    2846           0 :                 if( !bUsed )
    2847             :                 {
    2848           0 :                     if( ( !bSearchHidden && rRule.IsHidden() ) ||
    2849           0 :                            ( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
    2850           0 :                         ? !(rRule.GetPoolFmtId() & USER_FMT)
    2851             :                         // searched for used and found none
    2852           0 :                         : bIsSearchUsed ) )
    2853           0 :                         continue;
    2854             :                 }
    2855             : 
    2856           0 :                 aLst.Append( cNUMRULE, rRule.GetName() );
    2857             :             }
    2858             :         }
    2859           0 :         if ( bAll )
    2860           0 :             AppendStyleList(SwStyleNameMapper::GetNumRuleUINameArray(),
    2861           0 :                             bIsSearchUsed, bSearchHidden, bOnlyHidden, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, cNUMRULE);
    2862             :     }
    2863             : 
    2864       11937 :     if(!aLst.empty())
    2865             :     {
    2866       11125 :         nLastPos = USHRT_MAX;
    2867       11125 :         return Next();
    2868             :     }
    2869         812 :     return 0;
    2870             : }
    2871             : 
    2872       45834 : SfxStyleSheetBase*  SwStyleSheetIterator::Next()
    2873             : {
    2874             :     assert(bFirstCalled);
    2875       45834 :     ++nLastPos;
    2876       45834 :     if(!aLst.empty() && nLastPos < aLst.size())
    2877             :     {
    2878       40928 :         mxIterSheet->PresetNameAndFamily(aLst[nLastPos]);
    2879       40928 :         mxIterSheet->SetPhysical( sal_False );
    2880       40928 :         mxIterSheet->SetMask( nMask );
    2881       40928 :         if(mxIterSheet->pSet)
    2882             :         {
    2883          16 :             mxIterSheet->pSet->ClearItem(0);
    2884          16 :             mxIterSheet->pSet= 0;
    2885             :         }
    2886       40928 :         return mxIterSheet.get();
    2887             :     }
    2888        4906 :     return 0;
    2889             : }
    2890             : 
    2891           0 : SfxStyleSheetBase*  SwStyleSheetIterator::Find(const OUString& rName)
    2892             : {
    2893             :     // searching
    2894           0 :     if( !bFirstCalled )
    2895           0 :         First();
    2896             : 
    2897           0 :     nLastPos = lcl_FindName( aLst, nSearchFamily, rName );
    2898           0 :     if( USHRT_MAX != nLastPos )
    2899             :     {
    2900             :         // found
    2901           0 :         mxStyleSheet->PresetNameAndFamily(aLst[nLastPos]);
    2902             :         // new name is set, so determine its Data
    2903           0 :         mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
    2904           0 :         if( !mxStyleSheet->IsPhysical() )
    2905           0 :             mxStyleSheet->SetPhysical( sal_False );
    2906             : 
    2907           0 :         return mxStyleSheet.get();
    2908             :     }
    2909           0 :     return 0;
    2910             : }
    2911             : 
    2912        8298 : void SwStyleSheetIterator::AppendStyleList(const ::std::vector<OUString>& rList,
    2913             :                                             sal_Bool bTestUsed, sal_Bool bTestHidden, bool bOnlyHidden,
    2914             :                                             sal_uInt16 nSection, char cType )
    2915             : {
    2916        8298 :     SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
    2917        8298 :     sal_Bool bUsed = sal_False;
    2918      168651 :     for ( sal_uInt16 i=0; i < rList.size(); ++i )
    2919             :     {
    2920      160353 :         bool bHidden = false;
    2921      160353 :         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rList[i], (SwGetPoolIdFromName)nSection);
    2922      160353 :         switch ( nSection )
    2923             :         {
    2924             :             case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL:
    2925             :                 {
    2926      148664 :                     bUsed = rDoc.IsPoolTxtCollUsed( nId );
    2927      148664 :                     SwFmt* pFmt = rDoc.FindTxtFmtCollByName( rList[i] );
    2928      148664 :                     bHidden = pFmt && pFmt->IsHidden( );
    2929             :                 }
    2930      148664 :                 break;
    2931             :             case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT:
    2932             :                 {
    2933        9568 :                     bUsed = rDoc.IsPoolFmtUsed( nId );
    2934        9568 :                     SwFmt* pFmt = rDoc.FindCharFmtByName( rList[i] );
    2935        9568 :                     bHidden = pFmt && pFmt->IsHidden( );
    2936             :                 }
    2937        9568 :                 break;
    2938             :             case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT:
    2939             :                 {
    2940         231 :                     bUsed = rDoc.IsPoolFmtUsed( nId );
    2941         231 :                     SwFmt* pFmt = rDoc.FindFrmFmtByName( rList[i] );
    2942         231 :                     bHidden = pFmt && pFmt->IsHidden( );
    2943             :                 }
    2944         231 :                 break;
    2945             :             case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC:
    2946             :                 {
    2947        1890 :                     bUsed = rDoc.IsPoolPageDescUsed( nId );
    2948        1890 :                     SwPageDesc* pPgDesc = rDoc.FindPageDescByName( rList[i] );
    2949        1890 :                     bHidden = pPgDesc && pPgDesc->IsHidden( );
    2950             :                 }
    2951        1890 :                 break;
    2952             :             case nsSwGetPoolIdFromName::GET_POOLID_NUMRULE:
    2953             :                 {
    2954           0 :                     SwNumRule* pRule = rDoc.FindNumRulePtr( rList[i] );
    2955           0 :                     bUsed = pRule && rDoc.IsUsed( *pRule );
    2956           0 :                     bHidden = pRule && pRule->IsHidden( );
    2957             :                 }
    2958           0 :                 break;
    2959             :             default:
    2960             :                 OSL_ENSURE( !this, "unknown PoolFmt-Id" );
    2961             :         }
    2962             : 
    2963      160353 :         bool bMatchHidden = ( bTestHidden && ( bHidden || !bOnlyHidden ) ) || ( !bTestHidden && ( !bHidden || bUsed ) );
    2964      160353 :         if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) )
    2965      160173 :             aLst.Append( cType, rList[i] );
    2966             :     }
    2967        8298 : }
    2968             : 
    2969       25079 : void SwDocStyleSheetPool::InvalidateIterator()
    2970             : {
    2971       25079 :     dynamic_cast<SwStyleSheetIterator&>(GetIterator_Impl()).InvalidateIterator();
    2972       25079 : }
    2973             : 
    2974       25079 : void  SwStyleSheetIterator::InvalidateIterator()
    2975             : {
    2976             :     // potentially we could send an SfxHint to Notify but currently it's
    2977             :     // iterating over the vector anyway so would still be slow - why does
    2978             :     // this iterator not use a map?
    2979       25079 :     bFirstCalled = false;
    2980       25079 :     nLastPos = 0;
    2981       25079 :     aLst.Erase();
    2982       25079 : }
    2983             : 
    2984       36754 : void  SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint )
    2985             : {
    2986             :     // search and remove from View-List!!
    2987       72186 :     if( rHint.ISA( SfxStyleSheetHint ) &&
    2988       35432 :         SFX_STYLESHEET_ERASED == ((SfxStyleSheetHint&) rHint).GetHint() )
    2989             :     {
    2990           1 :         SfxStyleSheetBase* pStyle = ((SfxStyleSheetHint&)rHint).GetStyleSheet();
    2991             : 
    2992           1 :         if (pStyle)
    2993             :         {
    2994             :             sal_uInt16 nTmpPos = lcl_FindName( aLst, pStyle->GetFamily(),
    2995           1 :                                            pStyle->GetName() );
    2996           1 :             if( nTmpPos < aLst.size() )
    2997           0 :                 aLst.erase(aLst.begin() + nTmpPos);
    2998             :         }
    2999             :     }
    3000       36865 : }
    3001             : 
    3002             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10