xref: /trunk/main/sw/source/ui/app/docstyle.cxx (revision 3f09c2ce83c31bec9519173e2b25b00b5abfc6a1)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define _SVSTDARR_USHORTS
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <svl/smplhint.hxx>
30cdf0e10cSrcweir #include <hintids.hxx>
31cdf0e10cSrcweir #include <svl/itemiter.hxx>
32cdf0e10cSrcweir #include <svl/eitem.hxx>
33*3f09c2ceSJürgen Schmidt #include <svx/xdef.hxx>
34cdf0e10cSrcweir #include <unotools/syslocale.hxx>
35cdf0e10cSrcweir #include <editeng/boxitem.hxx>
36cdf0e10cSrcweir #include <editeng/numitem.hxx>
37cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
38cdf0e10cSrcweir #include <fmtcol.hxx>
39cdf0e10cSrcweir #include <uitool.hxx>
40cdf0e10cSrcweir #include <swmodule.hxx>
41cdf0e10cSrcweir #include <wrtsh.hxx>
42cdf0e10cSrcweir #include <docsh.hxx>
43cdf0e10cSrcweir #include <errhdl.hxx>
44cdf0e10cSrcweir #include <frmfmt.hxx>
45cdf0e10cSrcweir #include <charfmt.hxx>
46cdf0e10cSrcweir #include <poolfmt.hxx>
47cdf0e10cSrcweir #include <pagedesc.hxx>
48cdf0e10cSrcweir #include <docstyle.hxx>
49cdf0e10cSrcweir #include <docary.hxx>
50cdf0e10cSrcweir #include <ccoll.hxx>
51cdf0e10cSrcweir #include <doc.hxx>
52cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
53cdf0e10cSrcweir #include <cmdid.h>
54cdf0e10cSrcweir #include <swstyle.h>
55cdf0e10cSrcweir #include <app.hrc>
56cdf0e10cSrcweir #include <paratr.hxx>
57cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
58cdf0e10cSrcweir #include <svl/cjkoptions.hxx>
59cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
60cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
61cdf0e10cSrcweir #include <unotools/intlwrapper.hxx>
62cdf0e10cSrcweir #include <numrule.hxx>
63cdf0e10cSrcweir #include <fmthdft.hxx>
64cdf0e10cSrcweir #include <svx/svxids.hrc>
65cdf0e10cSrcweir #include <SwRewriter.hxx>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir // MD 06.02.95: Die Formatnamen in der Liste aller Namen haben als
68cdf0e10cSrcweir // erstes Zeichen die Familie:
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #define cCHAR       (sal_Unicode)'c'
71cdf0e10cSrcweir #define cPARA       (sal_Unicode)'p'
72cdf0e10cSrcweir #define cFRAME      (sal_Unicode)'f'
73cdf0e10cSrcweir #define cPAGE       (sal_Unicode)'g'
74cdf0e10cSrcweir #define cNUMRULE    (sal_Unicode)'n'
75cdf0e10cSrcweir 
76cdf0e10cSrcweir // Dieses Zeichen wird bei der Herausgabe der Namen wieder entfernt und
77cdf0e10cSrcweir // die Familie wird neu generiert.
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // Ausserdem gibt es jetzt zusaetzlich das Bit bPhysical. Ist dieses Bit
80cdf0e10cSrcweir // sal_True, werden die Pool-Formatnamen NICHT mit eingetragen.
81cdf0e10cSrcweir 
82cdf0e10cSrcweir class SwImplShellAction
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     SwWrtShell* pSh;
85cdf0e10cSrcweir     CurrShell* pCurrSh;
86cdf0e10cSrcweir public:
87cdf0e10cSrcweir     SwImplShellAction( SwDoc& rDoc );
88cdf0e10cSrcweir     ~SwImplShellAction();
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     SwWrtShell* GetSh() { return pSh; }
91cdf0e10cSrcweir };
92cdf0e10cSrcweir 
93cdf0e10cSrcweir SwImplShellAction::SwImplShellAction( SwDoc& rDoc )
94cdf0e10cSrcweir     : pCurrSh( 0 )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     if( rDoc.GetDocShell() )
97cdf0e10cSrcweir         pSh = rDoc.GetDocShell()->GetWrtShell();
98cdf0e10cSrcweir     else
99cdf0e10cSrcweir         pSh = 0;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     if( pSh )
102cdf0e10cSrcweir     {
103cdf0e10cSrcweir         pCurrSh = new CurrShell( pSh );
104cdf0e10cSrcweir         pSh->StartAllAction();
105cdf0e10cSrcweir     }
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir SwImplShellAction::~SwImplShellAction()
109cdf0e10cSrcweir {
110cdf0e10cSrcweir     if( pCurrSh )
111cdf0e10cSrcweir     {
112cdf0e10cSrcweir         pSh->EndAllAction();
113cdf0e10cSrcweir         delete pCurrSh;
114cdf0e10cSrcweir     }
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir /*--------------------------------------------------------------------
118cdf0e10cSrcweir     Beschreibung:   SwCharFormate finden/anlegen
119cdf0e10cSrcweir                     evtl. Style fuellen
120cdf0e10cSrcweir  --------------------------------------------------------------------*/
121cdf0e10cSrcweir 
122cdf0e10cSrcweir SwCharFmt* lcl_FindCharFmt( SwDoc& rDoc,
123cdf0e10cSrcweir                             const String& rName,
124cdf0e10cSrcweir                             SwDocStyleSheet* pStyle = 0,
125cdf0e10cSrcweir                             sal_Bool bCreate = sal_True )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     SwCharFmt*  pFmt = 0;
128cdf0e10cSrcweir     if( rName.Len() )
129cdf0e10cSrcweir     {
130cdf0e10cSrcweir         pFmt = rDoc.FindCharFmtByName( rName );
131cdf0e10cSrcweir         if( !pFmt && rName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
132cdf0e10cSrcweir                                                 RES_POOLCOLL_TEXT_BEGIN ] )
133cdf0e10cSrcweir         {
134cdf0e10cSrcweir             // Standard-Zeichenvorlage
135cdf0e10cSrcweir             pFmt = (SwCharFmt*)rDoc.GetDfltCharFmt();
136cdf0e10cSrcweir         }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         if( !pFmt && bCreate )
139cdf0e10cSrcweir         {   // Pool abklappern
140cdf0e10cSrcweir             const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
141cdf0e10cSrcweir             if(nId != USHRT_MAX)
142cdf0e10cSrcweir                 pFmt = rDoc.GetCharFmtFromPool(nId);
143cdf0e10cSrcweir         }
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir     if(pStyle)
146cdf0e10cSrcweir     {
147cdf0e10cSrcweir         if(pFmt)
148cdf0e10cSrcweir         {
149cdf0e10cSrcweir             pStyle->SetPhysical(sal_True);
150cdf0e10cSrcweir             SwFmt* p = pFmt->DerivedFrom();
151cdf0e10cSrcweir             if( p && !p->IsDefault() )
152cdf0e10cSrcweir                 pStyle->PresetParent( p->GetName() );
153cdf0e10cSrcweir             else
154cdf0e10cSrcweir                 pStyle->PresetParent( aEmptyStr );
155cdf0e10cSrcweir         }
156cdf0e10cSrcweir         else
157cdf0e10cSrcweir             pStyle->SetPhysical(sal_False);
158cdf0e10cSrcweir     }
159cdf0e10cSrcweir     return pFmt;
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 
163cdf0e10cSrcweir /*--------------------------------------------------------------------
164cdf0e10cSrcweir     Beschreibung:   ParaFormate finden/erzeugen
165cdf0e10cSrcweir                     Style fuellen
166cdf0e10cSrcweir  --------------------------------------------------------------------*/
167cdf0e10cSrcweir 
168cdf0e10cSrcweir SwTxtFmtColl* lcl_FindParaFmt(  SwDoc& rDoc,
169cdf0e10cSrcweir                                 const String& rName,
170cdf0e10cSrcweir                                 SwDocStyleSheet* pStyle = 0,
171cdf0e10cSrcweir                                 sal_Bool bCreate = sal_True )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir     SwTxtFmtColl*   pColl = 0;
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     if( rName.Len() )
176cdf0e10cSrcweir     {
177cdf0e10cSrcweir         pColl = rDoc.FindTxtFmtCollByName( rName );
178cdf0e10cSrcweir         if( !pColl && bCreate )
179cdf0e10cSrcweir         {   // Pool abklappern
180cdf0e10cSrcweir             const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
181cdf0e10cSrcweir             if(nId != USHRT_MAX)
182cdf0e10cSrcweir                 pColl = rDoc.GetTxtCollFromPool(nId);
183cdf0e10cSrcweir         }
184cdf0e10cSrcweir     }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     if(pStyle)
187cdf0e10cSrcweir     {
188cdf0e10cSrcweir         if(pColl)
189cdf0e10cSrcweir         {
190cdf0e10cSrcweir             pStyle->SetPhysical(sal_True);
191cdf0e10cSrcweir             if( pColl->DerivedFrom() && !pColl->DerivedFrom()->IsDefault() )
192cdf0e10cSrcweir                 pStyle->PresetParent( pColl->DerivedFrom()->GetName() );
193cdf0e10cSrcweir             else
194cdf0e10cSrcweir                 pStyle->PresetParent( aEmptyStr );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir             SwTxtFmtColl& rNext = pColl->GetNextTxtFmtColl();
197cdf0e10cSrcweir             pStyle->PresetFollow(rNext.GetName());
198cdf0e10cSrcweir         }
199cdf0e10cSrcweir         else
200cdf0e10cSrcweir             pStyle->SetPhysical(sal_False);
201cdf0e10cSrcweir     }
202cdf0e10cSrcweir     return pColl;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 
206cdf0e10cSrcweir /*--------------------------------------------------------------------
207cdf0e10cSrcweir     Beschreibung:   Rahmenformate
208cdf0e10cSrcweir  --------------------------------------------------------------------*/
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 
211cdf0e10cSrcweir SwFrmFmt* lcl_FindFrmFmt(   SwDoc& rDoc,
212cdf0e10cSrcweir                             const String& rName,
213cdf0e10cSrcweir                             SwDocStyleSheet* pStyle = 0,
214cdf0e10cSrcweir                             sal_Bool bCreate = sal_True )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir     SwFrmFmt* pFmt = 0;
217cdf0e10cSrcweir     if( rName.Len() )
218cdf0e10cSrcweir     {
219cdf0e10cSrcweir         pFmt = rDoc.FindFrmFmtByName( rName );
220cdf0e10cSrcweir         if( !pFmt && bCreate )
221cdf0e10cSrcweir         {   // Pool abklappern
222cdf0e10cSrcweir             const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT);
223cdf0e10cSrcweir             if(nId != USHRT_MAX)
224cdf0e10cSrcweir                 pFmt = rDoc.GetFrmFmtFromPool(nId);
225cdf0e10cSrcweir         }
226cdf0e10cSrcweir     }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     if(pStyle)
229cdf0e10cSrcweir     {
230cdf0e10cSrcweir         if(pFmt)
231cdf0e10cSrcweir         {
232cdf0e10cSrcweir             pStyle->SetPhysical(sal_True);
233cdf0e10cSrcweir             if( pFmt->DerivedFrom() && !pFmt->DerivedFrom()->IsDefault() )
234cdf0e10cSrcweir                 pStyle->PresetParent( pFmt->DerivedFrom()->GetName() );
235cdf0e10cSrcweir             else
236cdf0e10cSrcweir                 pStyle->PresetParent( aEmptyStr );
237cdf0e10cSrcweir         }
238cdf0e10cSrcweir         else
239cdf0e10cSrcweir             pStyle->SetPhysical(sal_False);
240cdf0e10cSrcweir     }
241cdf0e10cSrcweir     return pFmt;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir /*--------------------------------------------------------------------
245cdf0e10cSrcweir     Beschreibung:   Seitendescriptoren
246cdf0e10cSrcweir  --------------------------------------------------------------------*/
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 
249cdf0e10cSrcweir const SwPageDesc* lcl_FindPageDesc( SwDoc&  rDoc,
250cdf0e10cSrcweir                                     const String&    rName,
251cdf0e10cSrcweir                                     SwDocStyleSheet* pStyle = 0,
252cdf0e10cSrcweir                                     sal_Bool bCreate = sal_True )
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     const SwPageDesc* pDesc = 0;
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     if( rName.Len() )
257cdf0e10cSrcweir     {
258cdf0e10cSrcweir         pDesc = rDoc.FindPageDescByName( rName );
259cdf0e10cSrcweir         if( !pDesc && bCreate )
260cdf0e10cSrcweir         {
261cdf0e10cSrcweir             sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC);
262cdf0e10cSrcweir             if(nId != USHRT_MAX)
263cdf0e10cSrcweir                 pDesc = rDoc.GetPageDescFromPool(nId);
264cdf0e10cSrcweir         }
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     if(pStyle)
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         if(pDesc)
270cdf0e10cSrcweir         {
271cdf0e10cSrcweir             pStyle->SetPhysical(sal_True);
272cdf0e10cSrcweir             if(pDesc->GetFollow())
273cdf0e10cSrcweir                 pStyle->PresetFollow(pDesc->GetFollow()->GetName());
274cdf0e10cSrcweir             else
275cdf0e10cSrcweir                 pStyle->PresetParent( aEmptyStr );
276cdf0e10cSrcweir         }
277cdf0e10cSrcweir         else
278cdf0e10cSrcweir             pStyle->SetPhysical(sal_False);
279cdf0e10cSrcweir     }
280cdf0e10cSrcweir     return pDesc;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir const SwNumRule* lcl_FindNumRule(   SwDoc&  rDoc,
284cdf0e10cSrcweir                                     const String&    rName,
285cdf0e10cSrcweir                                     SwDocStyleSheet* pStyle = 0,
286cdf0e10cSrcweir                                     sal_Bool bCreate = sal_True )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir     const SwNumRule* pRule = 0;
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     if( rName.Len() )
291cdf0e10cSrcweir     {
292cdf0e10cSrcweir         pRule = rDoc.FindNumRulePtr( rName );
293cdf0e10cSrcweir         if( !pRule && bCreate )
294cdf0e10cSrcweir         {
295cdf0e10cSrcweir             sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE);
296cdf0e10cSrcweir             if(nId != USHRT_MAX)
297cdf0e10cSrcweir                 pRule = rDoc.GetNumRuleFromPool(nId);
298cdf0e10cSrcweir         }
299cdf0e10cSrcweir     }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir     if(pStyle)
302cdf0e10cSrcweir     {
303cdf0e10cSrcweir         if(pRule)
304cdf0e10cSrcweir         {
305cdf0e10cSrcweir             pStyle->SetPhysical(sal_True);
306cdf0e10cSrcweir             pStyle->PresetParent( aEmptyStr );
307cdf0e10cSrcweir         }
308cdf0e10cSrcweir         else
309cdf0e10cSrcweir             pStyle->SetPhysical(sal_False);
310cdf0e10cSrcweir     }
311cdf0e10cSrcweir     return pRule;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 
315cdf0e10cSrcweir sal_uInt16 lcl_FindName( const SwPoolFmtList& rLst, SfxStyleFamily eFam,
316cdf0e10cSrcweir                         const String& rName )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir     if( rLst.Count() )
319cdf0e10cSrcweir     {
320cdf0e10cSrcweir         // suchen
321cdf0e10cSrcweir         String sSrch( ' ' );
322cdf0e10cSrcweir         switch( eFam )
323cdf0e10cSrcweir         {
324cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR:  sSrch = cCHAR;     break;
325cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA:  sSrch = cPARA;     break;
326cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME: sSrch = cFRAME;    break;
327cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE:  sSrch = cPAGE;     break;
328cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO: sSrch = cNUMRULE; break;
329cdf0e10cSrcweir         default:; //prevent warning
330cdf0e10cSrcweir         }
331cdf0e10cSrcweir         sSrch += rName;
332cdf0e10cSrcweir         for( sal_uInt16 i=0; i < rLst.Count(); ++i )
333cdf0e10cSrcweir             if( *rLst[i] == sSrch )
334cdf0e10cSrcweir                 return i;
335cdf0e10cSrcweir     }
336cdf0e10cSrcweir     return USHRT_MAX;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir sal_Bool FindPhyStyle( SwDoc& rDoc, const String& rName, SfxStyleFamily eFam )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir     switch( eFam )
342cdf0e10cSrcweir     {
343cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR :
344cdf0e10cSrcweir         return 0 != lcl_FindCharFmt( rDoc, rName, 0, sal_False );
345cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA :
346cdf0e10cSrcweir         return 0 != lcl_FindParaFmt( rDoc, rName, 0, sal_False );
347cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME:
348cdf0e10cSrcweir         return 0 != lcl_FindFrmFmt( rDoc, rName, 0, sal_False );
349cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE :
350cdf0e10cSrcweir         return 0 != lcl_FindPageDesc( rDoc, rName, 0, sal_False );
351cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
352cdf0e10cSrcweir         return 0 != lcl_FindNumRule( rDoc, rName, 0, sal_False );
353cdf0e10cSrcweir     default:; //prevent warning
354cdf0e10cSrcweir     }
355cdf0e10cSrcweir     return sal_False;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 
359cdf0e10cSrcweir /*--------------------------------------------------------------------
360cdf0e10cSrcweir     Beschreibung:   Einfuegen von Strings in die Liste der Vorlagen
361cdf0e10cSrcweir  --------------------------------------------------------------------*/
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 
364cdf0e10cSrcweir void SwPoolFmtList::Append( char cChar, const String& rStr )
365cdf0e10cSrcweir {
366cdf0e10cSrcweir     String* pStr = new String( cChar );
367cdf0e10cSrcweir     *pStr += rStr;
368cdf0e10cSrcweir     for ( sal_uInt16 i=0; i < Count(); ++i )
369cdf0e10cSrcweir     {
370cdf0e10cSrcweir         if( *operator[](i) == *pStr )
371cdf0e10cSrcweir         {
372cdf0e10cSrcweir             delete pStr;
373cdf0e10cSrcweir             return;
374cdf0e10cSrcweir         }
375cdf0e10cSrcweir     }
376cdf0e10cSrcweir     Insert( pStr, Count() );
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir /*--------------------------------------------------------------------
380cdf0e10cSrcweir     Beschreibung:   Liste kompletti loeschen
381cdf0e10cSrcweir  --------------------------------------------------------------------*/
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 
384cdf0e10cSrcweir void SwPoolFmtList::Erase()
385cdf0e10cSrcweir {
386cdf0e10cSrcweir     DeleteAndDestroy( 0, Count() );
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir /*  */
390cdf0e10cSrcweir 
391cdf0e10cSrcweir /*--------------------------------------------------------------------
392cdf0e10cSrcweir     Beschreibung:  UI-seitige implementierung von StyleSheets
393cdf0e10cSrcweir                    greift auf die Core-Engine zu
394cdf0e10cSrcweir  --------------------------------------------------------------------*/
395cdf0e10cSrcweir 
396cdf0e10cSrcweir SwDocStyleSheet::SwDocStyleSheet(   SwDoc&          rDocument,
397cdf0e10cSrcweir                                     const String&           rName,
398cdf0e10cSrcweir                                     SwDocStyleSheetPool&    _rPool,
399cdf0e10cSrcweir                                     SfxStyleFamily          eFam,
400cdf0e10cSrcweir                                     sal_uInt16                  _nMask) :
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     SfxStyleSheetBase( rName, _rPool, eFam, _nMask ),
403cdf0e10cSrcweir     pCharFmt(0),
404cdf0e10cSrcweir     pColl(0),
405cdf0e10cSrcweir     pFrmFmt(0),
406cdf0e10cSrcweir     pDesc(0),
407cdf0e10cSrcweir     pNumRule(0),
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     rDoc(rDocument),
41064b14621SArmin Le Grand     aCoreSet(GetPool().GetPool(),   //UUUU sorted by indices, one double removed
41164b14621SArmin Le Grand             RES_CHRATR_BEGIN,       RES_CHRATR_END - 1,             // [1
41264b14621SArmin Le Grand             RES_PARATR_BEGIN,       RES_PARATR_END - 1,             // [60
413cdf0e10cSrcweir             // --> OD 2008-02-25 #refactorlists#
41464b14621SArmin Le Grand             RES_PARATR_LIST_BEGIN,  RES_PARATR_LIST_END - 1,        // [77
415cdf0e10cSrcweir             // <--
41664b14621SArmin Le Grand             RES_FRMATR_BEGIN,       RES_FRMATR_END - 1,             // [82
41764b14621SArmin Le Grand             RES_UNKNOWNATR_BEGIN,   RES_UNKNOWNATR_END-1,           // [143
41864b14621SArmin Le Grand 
41964b14621SArmin Le Grand             //UUUU FillAttribute support
42064b14621SArmin Le Grand             XATTR_FILL_FIRST, XATTR_FILL_LAST,                      // [1014
42164b14621SArmin Le Grand 
42264b14621SArmin Le Grand             SID_ATTR_BORDER_INNER,  SID_ATTR_BORDER_INNER,          // [10023
42364b14621SArmin Le Grand             SID_ATTR_PAGE,          SID_ATTR_PAGE_EXT1,             // [10050
42464b14621SArmin Le Grand             SID_ATTR_PAGE_HEADERSET,SID_ATTR_PAGE_FOOTERSET,        // [10058
42564b14621SArmin Le Grand             SID_ATTR_PARA_MODEL,    SID_ATTR_PARA_MODEL,            // [10065
42664b14621SArmin Le Grand 
42764b14621SArmin Le Grand             //UUUU items to hand over XPropertyList things like
42864b14621SArmin Le Grand             // XColorList, XHatchList, XGradientList and XBitmapList
42964b14621SArmin Le Grand             // to the Area TabPage
43064b14621SArmin Le Grand             SID_COLOR_TABLE,        SID_BITMAP_LIST,                // [10179
43164b14621SArmin Le Grand 
43264b14621SArmin Le Grand             SID_SWREGISTER_COLLECTION, SID_SWREGISTER_COLLECTION,   // [10451
43364b14621SArmin Le Grand             SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM,           // [10457
43464b14621SArmin Le Grand             SID_SWREGISTER_MODE,    SID_SWREGISTER_MODE,            // [10467
43564b14621SArmin Le Grand             SID_PARA_BACKGRND_DESTINATION,  SID_ATTR_BRUSH_CHAR,    // [10590
43664b14621SArmin Le Grand             SID_ATTR_NUMBERING_RULE,    SID_ATTR_NUMBERING_RULE,    // [10855
43764b14621SArmin Le Grand             SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE, // [12065
43864b14621SArmin Le Grand             FN_PARAM_FTN_INFO,      FN_PARAM_FTN_INFO,              // [21123
43964b14621SArmin Le Grand             FN_COND_COLL,           FN_COND_COLL,                   // [22401
440cdf0e10cSrcweir             0),
441cdf0e10cSrcweir     bPhysical(sal_False)
442cdf0e10cSrcweir {
443cdf0e10cSrcweir     nHelpId = UCHAR_MAX;
444cdf0e10cSrcweir }
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 
447cdf0e10cSrcweir SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet& rOrg) :
448cdf0e10cSrcweir     SfxStyleSheetBase(rOrg),
449cdf0e10cSrcweir     pCharFmt(rOrg.pCharFmt),
450cdf0e10cSrcweir     pColl(rOrg.pColl),
451cdf0e10cSrcweir     pFrmFmt(rOrg.pFrmFmt),
452cdf0e10cSrcweir     pDesc(rOrg.pDesc),
453cdf0e10cSrcweir     pNumRule(rOrg.pNumRule),
454cdf0e10cSrcweir     rDoc(rOrg.rDoc),
455cdf0e10cSrcweir     aCoreSet(rOrg.aCoreSet),
456cdf0e10cSrcweir     bPhysical(rOrg.bPhysical)
457cdf0e10cSrcweir {
458cdf0e10cSrcweir }
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 
461cdf0e10cSrcweir  SwDocStyleSheet::~SwDocStyleSheet()
462cdf0e10cSrcweir {
463cdf0e10cSrcweir }
464cdf0e10cSrcweir 
465cdf0e10cSrcweir /*--------------------------------------------------------------------
466cdf0e10cSrcweir     Beschreibung:   Zuruecksetzen
467cdf0e10cSrcweir  --------------------------------------------------------------------*/
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 
470cdf0e10cSrcweir void  SwDocStyleSheet::Reset()
471cdf0e10cSrcweir {
472cdf0e10cSrcweir     aName.Erase();
473cdf0e10cSrcweir     aFollow.Erase();
474cdf0e10cSrcweir     aParent.Erase();
475cdf0e10cSrcweir     SetPhysical(sal_False);
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
478cdf0e10cSrcweir /*--------------------------------------------------------------------
479cdf0e10cSrcweir     Beschreibung:   virtuelle Methoden
480cdf0e10cSrcweir  --------------------------------------------------------------------*/
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 
483cdf0e10cSrcweir const String&  SwDocStyleSheet::GetParent() const
484cdf0e10cSrcweir {
485cdf0e10cSrcweir     if( !bPhysical )
486cdf0e10cSrcweir     {
487cdf0e10cSrcweir         // dann pruefe, ob schon im Doc vorhanden
488cdf0e10cSrcweir         SwFmt* pFmt = 0;
489cdf0e10cSrcweir         SwGetPoolIdFromName eGetType;
490cdf0e10cSrcweir         switch(nFamily)
491cdf0e10cSrcweir         {
492cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR:
493cdf0e10cSrcweir             pFmt = rDoc.FindCharFmtByName( aName );
494cdf0e10cSrcweir             eGetType = nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
495cdf0e10cSrcweir             break;
496cdf0e10cSrcweir 
497cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA:
498cdf0e10cSrcweir             pFmt = rDoc.FindTxtFmtCollByName( aName );
499cdf0e10cSrcweir             eGetType = nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
500cdf0e10cSrcweir             break;
501cdf0e10cSrcweir 
502cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME:
503cdf0e10cSrcweir             pFmt = rDoc.FindFrmFmtByName( aName );
504cdf0e10cSrcweir             eGetType = nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
505cdf0e10cSrcweir             break;
506cdf0e10cSrcweir 
507cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE:
508cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO:
509cdf0e10cSrcweir         default:
510cdf0e10cSrcweir             return aEmptyStr;       // es gibt keinen Parent
511cdf0e10cSrcweir         }
512cdf0e10cSrcweir 
513cdf0e10cSrcweir         String sTmp;
514cdf0e10cSrcweir         if( !pFmt )         // noch nicht vorhanden, also dflt. Parent
515cdf0e10cSrcweir         {
516cdf0e10cSrcweir             sal_uInt16 i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType );
517cdf0e10cSrcweir             i = ::GetPoolParent( i );
518cdf0e10cSrcweir             if( i && USHRT_MAX != i )
519cdf0e10cSrcweir                 SwStyleNameMapper::FillUIName( i, sTmp );
520cdf0e10cSrcweir         }
521cdf0e10cSrcweir         else
522cdf0e10cSrcweir         {
523cdf0e10cSrcweir             SwFmt* p = pFmt->DerivedFrom();
524cdf0e10cSrcweir             if( p && !p->IsDefault() )
525cdf0e10cSrcweir                 sTmp = p->GetName();
526cdf0e10cSrcweir         }
527cdf0e10cSrcweir         SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
528cdf0e10cSrcweir         pThis->aParent = sTmp;
529cdf0e10cSrcweir     }
530cdf0e10cSrcweir     return aParent;
531cdf0e10cSrcweir }
532cdf0e10cSrcweir 
533cdf0e10cSrcweir /*--------------------------------------------------------------------
534cdf0e10cSrcweir    Beschreibung:    Nachfolger
535cdf0e10cSrcweir  --------------------------------------------------------------------*/
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 
538cdf0e10cSrcweir const String&  SwDocStyleSheet::GetFollow() const
539cdf0e10cSrcweir {
540cdf0e10cSrcweir     if( !bPhysical )
541cdf0e10cSrcweir     {
542cdf0e10cSrcweir         SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
543cdf0e10cSrcweir         pThis->FillStyleSheet( FillAllInfo );
544cdf0e10cSrcweir     }
545cdf0e10cSrcweir     return aFollow;
546cdf0e10cSrcweir }
547cdf0e10cSrcweir 
548cdf0e10cSrcweir /*--------------------------------------------------------------------
549cdf0e10cSrcweir     Beschreibung:   Welche Verkettung ist moeglich
550cdf0e10cSrcweir  --------------------------------------------------------------------*/
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 
553cdf0e10cSrcweir sal_Bool  SwDocStyleSheet::HasFollowSupport() const
554cdf0e10cSrcweir {
555cdf0e10cSrcweir     switch(nFamily)
556cdf0e10cSrcweir     {
557cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA :
558cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE : return sal_True;
559cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME:
560cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR :
561cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO: return sal_False;
562cdf0e10cSrcweir         default:
563cdf0e10cSrcweir             ASSERT(!this, "unbekannte Style-Familie");
564cdf0e10cSrcweir     }
565cdf0e10cSrcweir     return sal_False;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
568cdf0e10cSrcweir /*--------------------------------------------------------------------
569cdf0e10cSrcweir     Beschreibung:   Parent ?
570cdf0e10cSrcweir  --------------------------------------------------------------------*/
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 
573cdf0e10cSrcweir sal_Bool  SwDocStyleSheet::HasParentSupport() const
574cdf0e10cSrcweir {
575cdf0e10cSrcweir     sal_Bool bRet = sal_False;
576cdf0e10cSrcweir     switch(nFamily)
577cdf0e10cSrcweir     {
578cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR :
579cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA :
580cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME: bRet = sal_True;
581cdf0e10cSrcweir         default:; //prevent warning
582cdf0e10cSrcweir     }
583cdf0e10cSrcweir     return bRet;
584cdf0e10cSrcweir }
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 
587cdf0e10cSrcweir sal_Bool  SwDocStyleSheet::HasClearParentSupport() const
588cdf0e10cSrcweir {
589cdf0e10cSrcweir     sal_Bool bRet = sal_False;
590cdf0e10cSrcweir     switch(nFamily)
591cdf0e10cSrcweir     {
592cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA :
593cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR :
594cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME: bRet = sal_True;
595cdf0e10cSrcweir         default:; //prevent warning
596cdf0e10cSrcweir     }
597cdf0e10cSrcweir     return bRet;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir 
600cdf0e10cSrcweir /*--------------------------------------------------------------------
601cdf0e10cSrcweir     Beschreibung:   textuelle Beschreibung ermitteln
602cdf0e10cSrcweir  --------------------------------------------------------------------*/
603cdf0e10cSrcweir String  SwDocStyleSheet::GetDescription(SfxMapUnit eUnit)
604cdf0e10cSrcweir {
605cdf0e10cSrcweir     IntlWrapper aIntlWrapper(
606cdf0e10cSrcweir         ::comphelper::getProcessServiceFactory(),
607cdf0e10cSrcweir         SvtSysLocale().GetLocaleData().getLocale());
608cdf0e10cSrcweir 
609cdf0e10cSrcweir     String sPlus(String::CreateFromAscii(" + "));
610cdf0e10cSrcweir     if ( SFX_STYLE_FAMILY_PAGE == nFamily )
611cdf0e10cSrcweir     {
612cdf0e10cSrcweir         if( !pSet )
613cdf0e10cSrcweir             GetItemSet();
614cdf0e10cSrcweir 
615cdf0e10cSrcweir         SfxItemIter aIter( *pSet );
616cdf0e10cSrcweir         String aDesc;
617cdf0e10cSrcweir         const SfxPoolItem* pItem = aIter.FirstItem();
618cdf0e10cSrcweir 
619cdf0e10cSrcweir         while ( pItem )
620cdf0e10cSrcweir         {
621cdf0e10cSrcweir             if(!IsInvalidItem(pItem))
622cdf0e10cSrcweir                 switch ( pItem->Which() )
623cdf0e10cSrcweir                 {
624cdf0e10cSrcweir                     case RES_LR_SPACE:
625cdf0e10cSrcweir                     case SID_ATTR_PAGE_SIZE:
626cdf0e10cSrcweir                     case SID_ATTR_PAGE_MAXSIZE:
627cdf0e10cSrcweir                     case SID_ATTR_PAGE_PAPERBIN:
628cdf0e10cSrcweir                     case SID_ATTR_PAGE_APP:
629cdf0e10cSrcweir                     case SID_ATTR_BORDER_INNER:
630cdf0e10cSrcweir                         break;
631cdf0e10cSrcweir                     default:
632cdf0e10cSrcweir                     {
633cdf0e10cSrcweir                         String aItemPresentation;
634cdf0e10cSrcweir                         if ( !IsInvalidItem( pItem ) &&
635cdf0e10cSrcweir                              rPool.GetPool().GetPresentation(
636cdf0e10cSrcweir                                 *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
637cdf0e10cSrcweir                                 eUnit, aItemPresentation, &aIntlWrapper ) )
638cdf0e10cSrcweir                         {
639cdf0e10cSrcweir                             if ( aDesc.Len() && aItemPresentation.Len() )
640cdf0e10cSrcweir                                 aDesc += sPlus;
641cdf0e10cSrcweir                             aDesc += aItemPresentation;
642cdf0e10cSrcweir                         }
643cdf0e10cSrcweir                     }
644cdf0e10cSrcweir                 }
645cdf0e10cSrcweir             pItem = aIter.NextItem();
646cdf0e10cSrcweir         }
647cdf0e10cSrcweir         return aDesc;
648cdf0e10cSrcweir     }
649cdf0e10cSrcweir     else if ( SFX_STYLE_FAMILY_FRAME == nFamily ||
650cdf0e10cSrcweir                     SFX_STYLE_FAMILY_PARA == nFamily)
651cdf0e10cSrcweir     {
652cdf0e10cSrcweir         if( !pSet )
653cdf0e10cSrcweir             GetItemSet();
654cdf0e10cSrcweir 
655cdf0e10cSrcweir         SfxItemIter aIter( *pSet );
656cdf0e10cSrcweir         String aDesc;
657cdf0e10cSrcweir         const SfxPoolItem* pItem = aIter.FirstItem();
658cdf0e10cSrcweir 
659cdf0e10cSrcweir         String sPageNum, sModel, sBreak;
660cdf0e10cSrcweir         sal_Bool bHasWesternFontPrefix = sal_False;
661cdf0e10cSrcweir         sal_Bool bHasCJKFontPrefix = sal_False;
662cdf0e10cSrcweir         SvtCJKOptions aCJKOptions;
663cdf0e10cSrcweir 
664cdf0e10cSrcweir         while ( pItem )
665cdf0e10cSrcweir         {
666cdf0e10cSrcweir             if(!IsInvalidItem(pItem))
667cdf0e10cSrcweir                 switch ( pItem->Which() )
668cdf0e10cSrcweir                 {
669cdf0e10cSrcweir                     case SID_ATTR_AUTO_STYLE_UPDATE:
670cdf0e10cSrcweir                     case SID_PARA_BACKGRND_DESTINATION:
671cdf0e10cSrcweir                     case RES_PAGEDESC:
672cdf0e10cSrcweir                     //CTL no yet supported
673cdf0e10cSrcweir                     case RES_CHRATR_CTL_FONT:
674cdf0e10cSrcweir                     case RES_CHRATR_CTL_FONTSIZE:
675cdf0e10cSrcweir                     case RES_CHRATR_CTL_LANGUAGE:
676cdf0e10cSrcweir                     case RES_CHRATR_CTL_POSTURE:
677cdf0e10cSrcweir                     case RES_CHRATR_CTL_WEIGHT:
678cdf0e10cSrcweir                         break;
679cdf0e10cSrcweir                     default:
680cdf0e10cSrcweir                     {
681cdf0e10cSrcweir                         String aItemPresentation;
682cdf0e10cSrcweir                         if ( !IsInvalidItem( pItem ) &&
683cdf0e10cSrcweir                              rPool.GetPool().GetPresentation(
684cdf0e10cSrcweir                                 *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
685cdf0e10cSrcweir                                 eUnit, aItemPresentation, &aIntlWrapper ) )
686cdf0e10cSrcweir                         {
687cdf0e10cSrcweir                             sal_Bool bIsDefault = sal_False;
688cdf0e10cSrcweir                             switch ( pItem->Which() )
689cdf0e10cSrcweir                             {
690cdf0e10cSrcweir                                 case SID_ATTR_PARA_PAGENUM:
691cdf0e10cSrcweir                                     sPageNum = aItemPresentation;
692cdf0e10cSrcweir                                     break;
693cdf0e10cSrcweir                                 case SID_ATTR_PARA_MODEL:
694cdf0e10cSrcweir                                     sModel = aItemPresentation;
695cdf0e10cSrcweir                                     break;
696cdf0e10cSrcweir                                 case RES_BREAK:
697cdf0e10cSrcweir                                     sBreak = aItemPresentation;
698cdf0e10cSrcweir                                     break;
699cdf0e10cSrcweir                                 case RES_CHRATR_CJK_FONT:
700cdf0e10cSrcweir                                 case RES_CHRATR_CJK_FONTSIZE:
701cdf0e10cSrcweir                                 case RES_CHRATR_CJK_LANGUAGE:
702cdf0e10cSrcweir                                 case RES_CHRATR_CJK_POSTURE:
703cdf0e10cSrcweir                                 case RES_CHRATR_CJK_WEIGHT:
704cdf0e10cSrcweir                                 if(aCJKOptions.IsCJKFontEnabled())
705cdf0e10cSrcweir                                     bIsDefault = sal_True;
706cdf0e10cSrcweir                                 if(!bHasCJKFontPrefix)
707cdf0e10cSrcweir                                 {
708cdf0e10cSrcweir                                     aItemPresentation.Insert(SW_RESSTR(STR_CJK_FONT), 0);
709cdf0e10cSrcweir                                     bHasCJKFontPrefix = sal_True;
710cdf0e10cSrcweir                                 }
711cdf0e10cSrcweir                                 break;
712cdf0e10cSrcweir                                 case RES_CHRATR_FONT:
713cdf0e10cSrcweir                                 case RES_CHRATR_FONTSIZE:
714cdf0e10cSrcweir                                 case RES_CHRATR_LANGUAGE:
715cdf0e10cSrcweir                                 case RES_CHRATR_POSTURE:
716cdf0e10cSrcweir                                 case RES_CHRATR_WEIGHT:
717cdf0e10cSrcweir                                 if(!bHasWesternFontPrefix)
718cdf0e10cSrcweir                                 {
719cdf0e10cSrcweir                                     aItemPresentation.Insert(SW_RESSTR(STR_WESTERN_FONT), 0);
720cdf0e10cSrcweir                                     bHasWesternFontPrefix = sal_True;
721cdf0e10cSrcweir                                     bIsDefault = sal_True;
722cdf0e10cSrcweir                                 }
723cdf0e10cSrcweir                                 // no break;
724cdf0e10cSrcweir                                 default:
725cdf0e10cSrcweir                                     bIsDefault = sal_True;
726cdf0e10cSrcweir                             }
727cdf0e10cSrcweir                             if(bIsDefault)
728cdf0e10cSrcweir                             {
729cdf0e10cSrcweir                                 if ( aDesc.Len() && aItemPresentation.Len() )
730cdf0e10cSrcweir                                     aDesc += sPlus;
731cdf0e10cSrcweir                                 aDesc += aItemPresentation;
732cdf0e10cSrcweir                             }
733cdf0e10cSrcweir                         }
734cdf0e10cSrcweir                     }
735cdf0e10cSrcweir                 }
736cdf0e10cSrcweir             pItem = aIter.NextItem();
737cdf0e10cSrcweir         }
738cdf0e10cSrcweir         //Sonderbehandlung fuer Umburch, Seitenvorlage und Seitenoffset
739cdf0e10cSrcweir         if(sBreak.Len() && !sModel.Len())  // wemm Model. dann ist Break ungueltig
740cdf0e10cSrcweir         {
741cdf0e10cSrcweir             if(aDesc.Len())
742cdf0e10cSrcweir                 aDesc += sPlus;
743cdf0e10cSrcweir             aDesc += sBreak;
744cdf0e10cSrcweir         }
745cdf0e10cSrcweir         if(sModel.Len())
746cdf0e10cSrcweir         {
747cdf0e10cSrcweir             if(aDesc.Len())
748cdf0e10cSrcweir                 aDesc += sPlus;
749cdf0e10cSrcweir             aDesc += SW_RESSTR(STR_PAGEBREAK);
750cdf0e10cSrcweir             aDesc += sPlus;
751cdf0e10cSrcweir             aDesc += sModel;
752cdf0e10cSrcweir             if(sPageNum != String(UniString::CreateFromInt32(0)))
753cdf0e10cSrcweir             {
754cdf0e10cSrcweir                 aDesc += sPlus;
755cdf0e10cSrcweir                 aDesc += SW_RESSTR(STR_PAGEOFFSET);
756cdf0e10cSrcweir                 aDesc += sPageNum;
757cdf0e10cSrcweir             }
758cdf0e10cSrcweir         }
759cdf0e10cSrcweir         return aDesc;
760cdf0e10cSrcweir     }
761cdf0e10cSrcweir     else if( SFX_STYLE_FAMILY_PSEUDO == nFamily )
762cdf0e10cSrcweir     {
763cdf0e10cSrcweir //      if( pNumRule )
764cdf0e10cSrcweir //          return pNumRule->GetName();
765cdf0e10cSrcweir         //os: was sollte man bei Numerierungen schon anzeigen?
766cdf0e10cSrcweir         return aEmptyStr;
767cdf0e10cSrcweir     }
768cdf0e10cSrcweir 
769cdf0e10cSrcweir     return SfxStyleSheetBase::GetDescription(eUnit);
770cdf0e10cSrcweir }
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 
773cdf0e10cSrcweir String  SwDocStyleSheet::GetDescription()
774cdf0e10cSrcweir {
775cdf0e10cSrcweir     return GetDescription(SFX_MAPUNIT_CM);
776cdf0e10cSrcweir }
777cdf0e10cSrcweir 
778cdf0e10cSrcweir /*--------------------------------------------------------------------
779cdf0e10cSrcweir     Beschreibung:   Namen setzen
780cdf0e10cSrcweir  --------------------------------------------------------------------*/
781cdf0e10cSrcweir 
782cdf0e10cSrcweir 
783cdf0e10cSrcweir sal_Bool  SwDocStyleSheet::SetName( const String& rStr)
784cdf0e10cSrcweir {
785cdf0e10cSrcweir     if( !rStr.Len() )
786cdf0e10cSrcweir         return sal_False;
787cdf0e10cSrcweir 
788cdf0e10cSrcweir     if( aName != rStr )
789cdf0e10cSrcweir     {
790cdf0e10cSrcweir         if( !SfxStyleSheetBase::SetName( rStr ))
791cdf0e10cSrcweir             return sal_False;
792cdf0e10cSrcweir     }
793cdf0e10cSrcweir     else if(!bPhysical)
794cdf0e10cSrcweir         FillStyleSheet( FillPhysical );
795cdf0e10cSrcweir 
796cdf0e10cSrcweir     int bChg = sal_False;
797cdf0e10cSrcweir     switch(nFamily)
798cdf0e10cSrcweir     {
799cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR :
800cdf0e10cSrcweir         {
801cdf0e10cSrcweir             ASSERT(pCharFmt, "SwCharFormat fehlt!");
802cdf0e10cSrcweir             if( pCharFmt && pCharFmt->GetName() != rStr )
803cdf0e10cSrcweir             {
804cdf0e10cSrcweir                 pCharFmt->SetName( rStr );
805cdf0e10cSrcweir                 bChg = sal_True;
806cdf0e10cSrcweir             }
807cdf0e10cSrcweir             break;
808cdf0e10cSrcweir         }
809cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA :
810cdf0e10cSrcweir         {
811cdf0e10cSrcweir             ASSERT(pColl, "Collektion fehlt!");
812cdf0e10cSrcweir             if( pColl && pColl->GetName() != rStr )
813cdf0e10cSrcweir             {
814cdf0e10cSrcweir                 if (pColl->GetName().Len() > 0)
815cdf0e10cSrcweir                     rDoc.RenameFmt(*pColl, rStr);
816cdf0e10cSrcweir                 else
817cdf0e10cSrcweir                     pColl->SetName(rStr);
818cdf0e10cSrcweir 
819cdf0e10cSrcweir                 bChg = sal_True;
820cdf0e10cSrcweir             }
821cdf0e10cSrcweir             break;
822cdf0e10cSrcweir         }
823cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME:
824cdf0e10cSrcweir         {
825cdf0e10cSrcweir             ASSERT(pFrmFmt, "FrmFmt fehlt!");
826cdf0e10cSrcweir             if( pFrmFmt && pFrmFmt->GetName() != rStr )
827cdf0e10cSrcweir             {
828cdf0e10cSrcweir                 if (pFrmFmt->GetName().Len() > 0)
829cdf0e10cSrcweir                     rDoc.RenameFmt(*pFrmFmt, rStr);
830cdf0e10cSrcweir                 else
831cdf0e10cSrcweir                     pFrmFmt->SetName( rStr );
832cdf0e10cSrcweir 
833cdf0e10cSrcweir                 bChg = sal_True;
834cdf0e10cSrcweir             }
835cdf0e10cSrcweir             break;
836cdf0e10cSrcweir         }
837cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE :
838cdf0e10cSrcweir             ASSERT(pDesc, "PageDesc fehlt!");
839cdf0e10cSrcweir             if( pDesc && pDesc->GetName() != rStr )
840cdf0e10cSrcweir             {
841cdf0e10cSrcweir                 //PageDesc setzen - mit vorherigem kopieren - ist fuer das
842cdf0e10cSrcweir                 //setzen des Namens wohl nicht notwendig. Deshalb erlauben
843cdf0e10cSrcweir                 //wir hier mal einen cast.
844cdf0e10cSrcweir                 // -> #116530#
845cdf0e10cSrcweir                 SwPageDesc aPageDesc(*((SwPageDesc*)pDesc));
846cdf0e10cSrcweir                 String aOldName(aPageDesc.GetName());
847cdf0e10cSrcweir 
848cdf0e10cSrcweir                 aPageDesc.SetName( rStr );
849cdf0e10cSrcweir                 bool const bDoesUndo = rDoc.GetIDocumentUndoRedo().DoesUndo();
850cdf0e10cSrcweir 
851cdf0e10cSrcweir                 rDoc.GetIDocumentUndoRedo().DoUndo(aOldName.Len() > 0);
852cdf0e10cSrcweir                 rDoc.ChgPageDesc(aOldName, aPageDesc);
853cdf0e10cSrcweir                 rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo);
854cdf0e10cSrcweir                 // <- #116530#
855cdf0e10cSrcweir 
856cdf0e10cSrcweir                 rDoc.SetModified();
857cdf0e10cSrcweir                 bChg = sal_True;
858cdf0e10cSrcweir             }
859cdf0e10cSrcweir             break;
860cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO:
861cdf0e10cSrcweir             ASSERT(pNumRule, "NumRule fehlt!");
862cdf0e10cSrcweir 
863cdf0e10cSrcweir             // -> #106897#
864cdf0e10cSrcweir             if (pNumRule)
865cdf0e10cSrcweir             {
866cdf0e10cSrcweir                 String aOldName = pNumRule->GetName();
867cdf0e10cSrcweir 
868cdf0e10cSrcweir                 if (aOldName.Len() > 0)
869cdf0e10cSrcweir                 {
870cdf0e10cSrcweir                     if ( aOldName != rStr &&
871cdf0e10cSrcweir                          rDoc.RenameNumRule(aOldName, rStr))
872cdf0e10cSrcweir                     {
873cdf0e10cSrcweir                         pNumRule = rDoc.FindNumRulePtr(rStr);
874cdf0e10cSrcweir                         rDoc.SetModified();
875cdf0e10cSrcweir 
876cdf0e10cSrcweir                         bChg = sal_True;
877cdf0e10cSrcweir                     }
878cdf0e10cSrcweir                 }
879cdf0e10cSrcweir                 else
880cdf0e10cSrcweir                 {
881cdf0e10cSrcweir                     // --> OD 2008-07-08 #i91400#
882cdf0e10cSrcweir                     ((SwNumRule*)pNumRule)->SetName( rStr, rDoc );
883cdf0e10cSrcweir                     // <--
884cdf0e10cSrcweir                     rDoc.SetModified();
885cdf0e10cSrcweir 
886cdf0e10cSrcweir                     bChg = sal_True;
887cdf0e10cSrcweir                 }
888cdf0e10cSrcweir             }
889cdf0e10cSrcweir             // <- #106897#
890cdf0e10cSrcweir 
891cdf0e10cSrcweir             break;
892cdf0e10cSrcweir 
893cdf0e10cSrcweir         default:
894cdf0e10cSrcweir             ASSERT(!this, "unbekannte Style-Familie");
895cdf0e10cSrcweir     }
896cdf0e10cSrcweir 
897cdf0e10cSrcweir     if( bChg )
898cdf0e10cSrcweir     {
899cdf0e10cSrcweir         rPool.First();      // interne Liste muss geupdatet werden
900cdf0e10cSrcweir         rPool.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
901cdf0e10cSrcweir         SwEditShell* pSh = rDoc.GetEditShell();
902cdf0e10cSrcweir         if( pSh )
903cdf0e10cSrcweir             pSh->CallChgLnk();
904cdf0e10cSrcweir     }
905cdf0e10cSrcweir     return sal_True;
906cdf0e10cSrcweir }
907cdf0e10cSrcweir 
908cdf0e10cSrcweir /*--------------------------------------------------------------------
909cdf0e10cSrcweir     Beschreibung:   Ableitungshirachie
910cdf0e10cSrcweir  --------------------------------------------------------------------*/
911cdf0e10cSrcweir 
912cdf0e10cSrcweir 
913cdf0e10cSrcweir sal_Bool   SwDocStyleSheet::SetParent( const String& rStr)
914cdf0e10cSrcweir {
915cdf0e10cSrcweir     SwFmt* pFmt = 0, *pParent = 0;
916cdf0e10cSrcweir     switch(nFamily)
917cdf0e10cSrcweir     {
918cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR :
919cdf0e10cSrcweir             ASSERT( pCharFmt, "SwCharFormat fehlt!" )
920cdf0e10cSrcweir             if( 0 != ( pFmt = pCharFmt ) && rStr.Len() )
921cdf0e10cSrcweir                 pParent = lcl_FindCharFmt(rDoc, rStr);
922cdf0e10cSrcweir             break;
923cdf0e10cSrcweir 
924cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA :
925cdf0e10cSrcweir             ASSERT( pColl, "Collektion fehlt!")
926cdf0e10cSrcweir             if( 0 != ( pFmt = pColl ) && rStr.Len() )
927cdf0e10cSrcweir                 pParent = lcl_FindParaFmt( rDoc, rStr );
928cdf0e10cSrcweir             break;
929cdf0e10cSrcweir 
930cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME:
931cdf0e10cSrcweir             ASSERT(pFrmFmt, "FrameFormat fehlt!");
932cdf0e10cSrcweir             if( 0 != ( pFmt = pFrmFmt ) && rStr.Len() )
933cdf0e10cSrcweir                 pParent = lcl_FindFrmFmt( rDoc, rStr );
934cdf0e10cSrcweir             break;
935cdf0e10cSrcweir 
936cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE:
937cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO:
938cdf0e10cSrcweir             break;
939cdf0e10cSrcweir         default:
940cdf0e10cSrcweir             ASSERT(!this, "unbekannte Style-Familie");
941cdf0e10cSrcweir     }
942cdf0e10cSrcweir 
943cdf0e10cSrcweir     sal_Bool bRet = sal_False;
944cdf0e10cSrcweir     if( pFmt && pFmt->DerivedFrom() &&
945cdf0e10cSrcweir         pFmt->DerivedFrom()->GetName() != rStr )
946cdf0e10cSrcweir     {
947cdf0e10cSrcweir         {
948cdf0e10cSrcweir             SwImplShellAction aTmp( rDoc );
949cdf0e10cSrcweir             bRet = pFmt->SetDerivedFrom( pParent );
950cdf0e10cSrcweir         }
951cdf0e10cSrcweir 
952cdf0e10cSrcweir         if( bRet )
953cdf0e10cSrcweir         {
954cdf0e10cSrcweir             aParent = rStr;
955cdf0e10cSrcweir             rPool.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
956cdf0e10cSrcweir                             *this ) );
957cdf0e10cSrcweir         }
958cdf0e10cSrcweir     }
959cdf0e10cSrcweir 
960cdf0e10cSrcweir     return bRet;
961cdf0e10cSrcweir }
962cdf0e10cSrcweir 
963cdf0e10cSrcweir /*--------------------------------------------------------------------
964cdf0e10cSrcweir     Beschreibung:   Nachfolger detzen
965cdf0e10cSrcweir  --------------------------------------------------------------------*/
966cdf0e10cSrcweir 
967cdf0e10cSrcweir 
968cdf0e10cSrcweir sal_Bool   SwDocStyleSheet::SetFollow( const String& rStr)
969cdf0e10cSrcweir {
970cdf0e10cSrcweir     if( rStr.Len() && !SfxStyleSheetBase::SetFollow( rStr ))
971cdf0e10cSrcweir         return sal_False;
972cdf0e10cSrcweir 
973cdf0e10cSrcweir     SwImplShellAction aTmpSh( rDoc );
974cdf0e10cSrcweir     switch(nFamily)
975cdf0e10cSrcweir     {
976cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA :
977cdf0e10cSrcweir     {
978cdf0e10cSrcweir         ASSERT(pColl, "Collection fehlt!");
979cdf0e10cSrcweir         if( pColl )
980cdf0e10cSrcweir         {
981cdf0e10cSrcweir             SwTxtFmtColl* pFollow = pColl;
982cdf0e10cSrcweir             if( rStr.Len() && 0 == (pFollow = lcl_FindParaFmt(rDoc, rStr) ))
983cdf0e10cSrcweir                 pFollow = pColl;
984cdf0e10cSrcweir 
985cdf0e10cSrcweir             pColl->SetNextTxtFmtColl(*pFollow);
986cdf0e10cSrcweir         }
987cdf0e10cSrcweir         break;
988cdf0e10cSrcweir     }
989cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE :
990cdf0e10cSrcweir     {
991cdf0e10cSrcweir         ASSERT(pDesc, "PageDesc fehlt!");
992cdf0e10cSrcweir         if( pDesc )
993cdf0e10cSrcweir         {
994cdf0e10cSrcweir             const SwPageDesc* pFollowDesc = rStr.Len()
995cdf0e10cSrcweir                                             ? lcl_FindPageDesc(rDoc, rStr)
996cdf0e10cSrcweir                                             : 0;
997cdf0e10cSrcweir             sal_uInt16 nId;
998cdf0e10cSrcweir             if( pFollowDesc != pDesc->GetFollow() &&
999cdf0e10cSrcweir                 rDoc.FindPageDescByName( pDesc->GetName(), &nId ) )
1000cdf0e10cSrcweir             {
1001cdf0e10cSrcweir                 SwPageDesc aDesc( *pDesc );
1002cdf0e10cSrcweir                 aDesc.SetFollow( pFollowDesc );
1003cdf0e10cSrcweir                 rDoc.ChgPageDesc( nId, aDesc );
1004cdf0e10cSrcweir                 pDesc = &const_cast<const SwDoc &>(rDoc).GetPageDesc( nId );
1005cdf0e10cSrcweir             }
1006cdf0e10cSrcweir         }
1007cdf0e10cSrcweir         break;
1008cdf0e10cSrcweir     }
1009cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR:
1010cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME:
1011cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
1012cdf0e10cSrcweir         break;
1013cdf0e10cSrcweir     default:
1014cdf0e10cSrcweir         ASSERT(!this, "unbekannte Style-Familie");
1015cdf0e10cSrcweir     }
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir     return sal_True;
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir /*--------------------------------------------------------------------
1021cdf0e10cSrcweir     Beschreibung:   ueber Name und Family, Mask den ItemSet rausholen
1022cdf0e10cSrcweir  --------------------------------------------------------------------*/
1023cdf0e10cSrcweir 
102464b14621SArmin Le Grand //UUUU
102564b14621SArmin Le Grand #include <svx/svdmodel.hxx>
102664b14621SArmin Le Grand #include <svx/drawitem.hxx>
102764b14621SArmin Le Grand 
1028cdf0e10cSrcweir SfxItemSet&   SwDocStyleSheet::GetItemSet()
1029cdf0e10cSrcweir {
1030cdf0e10cSrcweir     if(!bPhysical)
1031cdf0e10cSrcweir         FillStyleSheet( FillPhysical );
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir     switch(nFamily)
1034cdf0e10cSrcweir     {
1035cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR:
1036cdf0e10cSrcweir             {
1037cdf0e10cSrcweir                 ASSERT(pCharFmt, "Wo ist das SwCharFmt");
1038cdf0e10cSrcweir                 aCoreSet.Put(pCharFmt->GetAttrSet());
1039cdf0e10cSrcweir                 if(pCharFmt->DerivedFrom())
1040cdf0e10cSrcweir                     aCoreSet.SetParent(&pCharFmt->DerivedFrom()->GetAttrSet());
1041cdf0e10cSrcweir             }
1042cdf0e10cSrcweir             break;
1043cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA :
1044cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME:
1045cdf0e10cSrcweir             {
1046cdf0e10cSrcweir                 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1047cdf0e10cSrcweir                 aBoxInfo.SetTable( sal_False );
1048cdf0e10cSrcweir                 aBoxInfo.SetDist( sal_True);    // Abstandsfeld immer anzeigen
1049cdf0e10cSrcweir                 aBoxInfo.SetMinDist( sal_True );// Minimalgroesse in Tabellen und Absaetzen setzen
1050cdf0e10cSrcweir                 aBoxInfo.SetDefDist( MIN_BORDER_DIST );// Default-Abstand immer setzen
1051cdf0e10cSrcweir                     // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
1052cdf0e10cSrcweir                 aBoxInfo.SetValid( VALID_DISABLE, sal_True );
1053cdf0e10cSrcweir                 if ( nFamily == SFX_STYLE_FAMILY_PARA )
1054cdf0e10cSrcweir                 {
1055cdf0e10cSrcweir                     ASSERT(pColl, "Wo ist die Collektion");
1056cdf0e10cSrcweir                     aCoreSet.Put(pColl->GetAttrSet());
1057cdf0e10cSrcweir                     aCoreSet.Put( aBoxInfo );
1058cdf0e10cSrcweir                     aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pColl->IsAutoUpdateFmt()));
1059cdf0e10cSrcweir                     if(pColl->DerivedFrom())
1060cdf0e10cSrcweir                         aCoreSet.SetParent(&pColl->DerivedFrom()->GetAttrSet());
1061cdf0e10cSrcweir                 }
1062cdf0e10cSrcweir                 else
1063cdf0e10cSrcweir                 {
1064cdf0e10cSrcweir                     ASSERT(pFrmFmt, "Wo ist das FrmFmt");
1065cdf0e10cSrcweir                     aCoreSet.Put(pFrmFmt->GetAttrSet());
1066cdf0e10cSrcweir                     aCoreSet.Put( aBoxInfo );
1067cdf0e10cSrcweir                     aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pFrmFmt->IsAutoUpdateFmt()));
1068cdf0e10cSrcweir                     if(pFrmFmt->DerivedFrom())
1069cdf0e10cSrcweir                         aCoreSet.SetParent(&pFrmFmt->DerivedFrom()->GetAttrSet());
107064b14621SArmin Le Grand 
107164b14621SArmin Le Grand                     //UUUU create needed items for XPropertyList entries from the DrawModel so that
107264b14621SArmin Le Grand                     // the Area TabPage can access them
107364b14621SArmin Le Grand                     const SdrModel* pDrawModel = rDoc.GetDrawModel();
107464b14621SArmin Le Grand 
107564b14621SArmin Le Grand                     aCoreSet.Put(SvxColorTableItem(pDrawModel->GetColorTableFromSdrModel(), SID_COLOR_TABLE));
107664b14621SArmin Le Grand                     aCoreSet.Put(SvxGradientListItem(pDrawModel->GetGradientListFromSdrModel(), SID_GRADIENT_LIST));
107764b14621SArmin Le Grand                     aCoreSet.Put(SvxHatchListItem(pDrawModel->GetHatchListFromSdrModel(), SID_HATCH_LIST));
107864b14621SArmin Le Grand                     aCoreSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapListFromSdrModel(), SID_BITMAP_LIST));
1079cdf0e10cSrcweir                 }
1080cdf0e10cSrcweir             }
1081cdf0e10cSrcweir             break;
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE :
1084cdf0e10cSrcweir             {
1085cdf0e10cSrcweir                 ASSERT(pDesc, "Kein PageDescriptor");
1086cdf0e10cSrcweir                 ::PageDescToItemSet(*((SwPageDesc*)pDesc), aCoreSet);
1087cdf0e10cSrcweir             }
1088cdf0e10cSrcweir             break;
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO:
1091cdf0e10cSrcweir             {
1092cdf0e10cSrcweir                 ASSERT(pNumRule, "Keine NumRule");
1093cdf0e10cSrcweir                 SvxNumRule aRule = pNumRule->MakeSvxNumRule();
1094cdf0e10cSrcweir                 aCoreSet.Put(SvxNumBulletItem(aRule));
1095cdf0e10cSrcweir             }
1096cdf0e10cSrcweir             break;
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir         default:
1099cdf0e10cSrcweir             ASSERT(!this, "unbekannte Style-Familie");
1100cdf0e10cSrcweir     }
1101cdf0e10cSrcweir     // Member der Basisklasse
1102cdf0e10cSrcweir     pSet = &aCoreSet;
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir     return aCoreSet;
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir // --> OD 2008-02-13 #newlistlevelattrs#
1108cdf0e10cSrcweir void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet )
1109cdf0e10cSrcweir {
1110cdf0e10cSrcweir     if ( nFamily != SFX_STYLE_FAMILY_PARA )
1111cdf0e10cSrcweir     {
1112cdf0e10cSrcweir         return;
1113cdf0e10cSrcweir     }
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir     ASSERT( pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style");
1116cdf0e10cSrcweir     if ( pColl->AreListLevelIndentsApplicable() )
1117cdf0e10cSrcweir     {
1118cdf0e10cSrcweir         ASSERT( pColl->GetItemState( RES_PARATR_NUMRULE ) == SFX_ITEM_SET,
1119cdf0e10cSrcweir                 "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - list level indents are applicable at paragraph style, but no list style found. Serious defect -> please inform OD." );
1120cdf0e10cSrcweir         const String sNumRule = pColl->GetNumRule().GetValue();
1121cdf0e10cSrcweir         if( sNumRule.Len() )
1122cdf0e10cSrcweir         {
1123cdf0e10cSrcweir             const SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
1124cdf0e10cSrcweir             if( pRule )
1125cdf0e10cSrcweir             {
1126cdf0e10cSrcweir                 const SwNumFmt& rFmt = pRule->Get( 0 );
1127cdf0e10cSrcweir                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1128cdf0e10cSrcweir                 {
1129cdf0e10cSrcweir                     SvxLRSpaceItem aLR( RES_LR_SPACE );
1130cdf0e10cSrcweir                     aLR.SetTxtLeft( rFmt.GetIndentAt() );
1131cdf0e10cSrcweir                     aLR.SetTxtFirstLineOfst( static_cast<short>(rFmt.GetFirstLineIndent()) );
1132cdf0e10cSrcweir                     rSet.Put( aLR );
1133cdf0e10cSrcweir                 }
1134cdf0e10cSrcweir             }
1135cdf0e10cSrcweir         }
1136cdf0e10cSrcweir     }
1137cdf0e10cSrcweir }
1138cdf0e10cSrcweir // <--
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir /*--------------------------------------------------------------------
1141cdf0e10cSrcweir     Beschreibung:   ItemSet setzen
1142cdf0e10cSrcweir  --------------------------------------------------------------------*/
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir // --> OD 2008-02-12 #newlistlevelattrs#
1145cdf0e10cSrcweir // handling of parameter <bResetIndentAttrsAtParagraphStyle>
1146cdf0e10cSrcweir void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
1147cdf0e10cSrcweir                                   const bool bResetIndentAttrsAtParagraphStyle )
1148cdf0e10cSrcweir {
1149cdf0e10cSrcweir     // gegebenenfalls Format erst ermitteln
1150cdf0e10cSrcweir     if(!bPhysical)
1151cdf0e10cSrcweir         FillStyleSheet( FillPhysical );
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir     SwImplShellAction aTmpSh( rDoc );
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir     ASSERT( &rSet != &aCoreSet, "SetItemSet mit eigenem Set ist nicht erlaubt" );
1156cdf0e10cSrcweir 
1157cdf0e10cSrcweir     // --> OD 2008-02-12 #newlistlevelattrs#
1158cdf0e10cSrcweir     if (rDoc.GetIDocumentUndoRedo().DoesUndo())
1159cdf0e10cSrcweir     {
1160cdf0e10cSrcweir         SwRewriter aRewriter;
1161cdf0e10cSrcweir         aRewriter.AddRule( UNDO_ARG1, GetName() );
1162cdf0e10cSrcweir         rDoc.GetIDocumentUndoRedo().StartUndo( UNDO_INSFMTATTR, &aRewriter );
1163cdf0e10cSrcweir     }
1164cdf0e10cSrcweir     // <--
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir     SwFmt* pFmt = 0;
1167cdf0e10cSrcweir     SwPageDesc* pNewDsc = 0;
1168cdf0e10cSrcweir     sal_uInt16 nPgDscPos = 0;
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir     switch(nFamily)
1171cdf0e10cSrcweir     {
1172cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR :
1173cdf0e10cSrcweir             {
1174cdf0e10cSrcweir                 ASSERT(pCharFmt, "Wo ist das CharFormat");
1175cdf0e10cSrcweir                 pFmt = pCharFmt;
1176cdf0e10cSrcweir             }
1177cdf0e10cSrcweir             break;
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA :
1180cdf0e10cSrcweir         {
1181cdf0e10cSrcweir             ASSERT(pColl, "Wo ist die Collection");
1182cdf0e10cSrcweir             const SfxPoolItem* pAutoUpdate;
1183cdf0e10cSrcweir             if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,sal_False, &pAutoUpdate ))
1184cdf0e10cSrcweir             {
1185cdf0e10cSrcweir                 pColl->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
1186cdf0e10cSrcweir             }
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir             const SwCondCollItem* pCondItem;
1189cdf0e10cSrcweir             if( SFX_ITEM_SET != rSet.GetItemState( FN_COND_COLL, sal_False,
1190cdf0e10cSrcweir                 (const SfxPoolItem**)&pCondItem ))
1191cdf0e10cSrcweir                 pCondItem = 0;
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir             if( RES_CONDTXTFMTCOLL == pColl->Which() && pCondItem )
1194cdf0e10cSrcweir             {
1195cdf0e10cSrcweir                 SwFmt* pFindFmt;
1196cdf0e10cSrcweir                 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1197cdf0e10cSrcweir                 for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
1198cdf0e10cSrcweir                 {
1199cdf0e10cSrcweir                     SwCollCondition aCond( 0, pCmds[ i ].nCnd, pCmds[ i ].nSubCond );
1200cdf0e10cSrcweir                     ((SwConditionTxtFmtColl*)pColl)->RemoveCondition( aCond );
1201cdf0e10cSrcweir                     const String& rStyle = pCondItem->GetStyle( i );
1202cdf0e10cSrcweir                     if( rStyle.Len() &&
1203cdf0e10cSrcweir                         0 != ( pFindFmt = lcl_FindParaFmt( rDoc, rStyle, 0, sal_True )))
1204cdf0e10cSrcweir                     {
1205cdf0e10cSrcweir                         aCond.RegisterToFormat( *pFindFmt );
1206cdf0e10cSrcweir                         ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond );
1207cdf0e10cSrcweir                     }
1208cdf0e10cSrcweir                 }
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir                 // Document auf die neue Bedingungen updaten
1211cdf0e10cSrcweir                 SwCondCollCondChg aMsg( pColl );
1212cdf0e10cSrcweir                 pColl->ModifyNotification( &aMsg, &aMsg );
1213cdf0e10cSrcweir             }
1214cdf0e10cSrcweir             else if( pCondItem && !pColl->GetDepends() )
1215cdf0e10cSrcweir             {
1216cdf0e10cSrcweir                 // keine bedingte Vorlage, dann erstmal erzeugen und
1217cdf0e10cSrcweir                 // alle wichtigen Werte uebernehmen
1218cdf0e10cSrcweir                 SwConditionTxtFmtColl* pCColl = rDoc.MakeCondTxtFmtColl(
1219cdf0e10cSrcweir                         pColl->GetName(), (SwTxtFmtColl*)pColl->DerivedFrom() );
1220cdf0e10cSrcweir                 if( pColl != &pColl->GetNextTxtFmtColl() )
1221cdf0e10cSrcweir                     pCColl->SetNextTxtFmtColl( pColl->GetNextTxtFmtColl() );
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir                 //pCColl->SetOutlineLevel( pColl->GetOutlineLevel() );//#outline level,zhaojianwei
1224cdf0e10cSrcweir                 if( pColl->IsAssignedToListLevelOfOutlineStyle())
1225cdf0e10cSrcweir                     pCColl->AssignToListLevelOfOutlineStyle(pColl->GetAssignedOutlineStyleLevel());
1226cdf0e10cSrcweir                 else
1227cdf0e10cSrcweir                     pCColl->DeleteAssignmentToListLevelOfOutlineStyle();//<--end,zhaojianwei
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir                 SwTxtFmtColl* pFindFmt;
1232cdf0e10cSrcweir                 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1233cdf0e10cSrcweir                 for( sal_uInt16 i = 0; i < COND_COMMAND_COUNT; ++i )
1234cdf0e10cSrcweir                 {
1235cdf0e10cSrcweir                     const String& rStyle = pCondItem->GetStyle( i );
1236cdf0e10cSrcweir                     if( rStyle.Len() &&
1237cdf0e10cSrcweir                         0 != ( pFindFmt = lcl_FindParaFmt( rDoc, rStyle, 0, sal_True )))
1238cdf0e10cSrcweir                     {
1239cdf0e10cSrcweir                         pCColl->InsertCondition( SwCollCondition( pFindFmt,
1240cdf0e10cSrcweir                                     pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) );
1241cdf0e10cSrcweir                     }
1242cdf0e10cSrcweir                 }
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir                 rDoc.DelTxtFmtColl( pColl );
1245cdf0e10cSrcweir                 pColl = pCColl;
1246cdf0e10cSrcweir             }
1247cdf0e10cSrcweir             // --> OD 2008-02-12 #newlistlevelattrs#
1248cdf0e10cSrcweir             if ( bResetIndentAttrsAtParagraphStyle &&
1249cdf0e10cSrcweir                  rSet.GetItemState( RES_PARATR_NUMRULE, sal_False, 0 ) == SFX_ITEM_SET &&
1250cdf0e10cSrcweir                  rSet.GetItemState( RES_LR_SPACE, sal_False, 0 ) != SFX_ITEM_SET &&
1251cdf0e10cSrcweir                  pColl->GetItemState( RES_LR_SPACE, sal_False, 0 ) == SFX_ITEM_SET )
1252cdf0e10cSrcweir             {
1253cdf0e10cSrcweir                 rDoc.ResetAttrAtFormat( RES_LR_SPACE, *pColl );
1254cdf0e10cSrcweir             }
1255cdf0e10cSrcweir             // <--
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir             // #i56252: If a standard numbering style is assigned to a standard paragraph style
1258cdf0e10cSrcweir             // we have to create a physical instance of the numbering style. If we do not and
1259cdf0e10cSrcweir             // neither the paragraph style nor the numbering style is used in the document
1260cdf0e10cSrcweir             // the numbering style will not be saved with the document and the assignment got lost.
1261cdf0e10cSrcweir             const SfxPoolItem* pNumRuleItem = 0;
1262cdf0e10cSrcweir             if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, sal_False, &pNumRuleItem ) )
1263cdf0e10cSrcweir             {   // Setting a numbering rule?
1264cdf0e10cSrcweir                 String sNumRule = ((SwNumRuleItem*)pNumRuleItem)->GetValue();
1265cdf0e10cSrcweir                 if( sNumRule.Len() )
1266cdf0e10cSrcweir                 {
1267cdf0e10cSrcweir                     SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
1268cdf0e10cSrcweir                     if( !pRule )
1269cdf0e10cSrcweir                     {   // Numbering rule not in use yet.
1270cdf0e10cSrcweir                         sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sNumRule, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
1271cdf0e10cSrcweir                         if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
1272cdf0e10cSrcweir                         {
1273cdf0e10cSrcweir                             pRule = rDoc.GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
1274cdf0e10cSrcweir                         }
1275cdf0e10cSrcweir                     }
1276cdf0e10cSrcweir                 }
1277cdf0e10cSrcweir             }
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir             pFmt = pColl;
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir             sal_uInt16 nId = pColl->GetPoolFmtId() &
1282cdf0e10cSrcweir                             ~ ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID );
1283cdf0e10cSrcweir             switch( GetMask() & ( 0x0fff & ~SWSTYLEBIT_CONDCOLL ) )
1284cdf0e10cSrcweir             {
1285cdf0e10cSrcweir                 case SWSTYLEBIT_TEXT:
1286cdf0e10cSrcweir                     nId |= COLL_TEXT_BITS;
1287cdf0e10cSrcweir                     break;
1288cdf0e10cSrcweir                 case SWSTYLEBIT_CHAPTER:
1289cdf0e10cSrcweir                     nId |= COLL_DOC_BITS;
1290cdf0e10cSrcweir                     break;
1291cdf0e10cSrcweir                 case SWSTYLEBIT_LIST:
1292cdf0e10cSrcweir                     nId |= COLL_LISTS_BITS;
1293cdf0e10cSrcweir                     break;
1294cdf0e10cSrcweir                 case SWSTYLEBIT_IDX:
1295cdf0e10cSrcweir                     nId |= COLL_REGISTER_BITS;
1296cdf0e10cSrcweir                     break;
1297cdf0e10cSrcweir                 case SWSTYLEBIT_EXTRA:
1298cdf0e10cSrcweir                     nId |= COLL_EXTRA_BITS;
1299cdf0e10cSrcweir                     break;
1300cdf0e10cSrcweir                 case SWSTYLEBIT_HTML:
1301cdf0e10cSrcweir                     nId |= COLL_HTML_BITS;
1302cdf0e10cSrcweir                     break;
1303cdf0e10cSrcweir             }
1304cdf0e10cSrcweir             pColl->SetPoolFmtId( nId );
1305cdf0e10cSrcweir             break;
1306cdf0e10cSrcweir         }
1307cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME:
1308cdf0e10cSrcweir         {
1309cdf0e10cSrcweir             ASSERT(pFrmFmt, "Wo ist das FrmFmt");
1310cdf0e10cSrcweir             const SfxPoolItem* pAutoUpdate;
1311cdf0e10cSrcweir             if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,sal_False, &pAutoUpdate ))
1312cdf0e10cSrcweir             {
1313cdf0e10cSrcweir                 pFrmFmt->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
1314cdf0e10cSrcweir             }
1315cdf0e10cSrcweir             pFmt = pFrmFmt;
1316cdf0e10cSrcweir         }
1317cdf0e10cSrcweir         break;
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE :
1320cdf0e10cSrcweir             {
1321cdf0e10cSrcweir                 ASSERT(pDesc, "Wo ist der PageDescriptor");
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir                 if( rDoc.FindPageDescByName( pDesc->GetName(), &nPgDscPos ))
1324cdf0e10cSrcweir                 {
1325cdf0e10cSrcweir                     pNewDsc = new SwPageDesc( *pDesc );
1326cdf0e10cSrcweir                     // --> OD 2005-05-09 #i48949# - no undo actions for the
1327cdf0e10cSrcweir                     // copy of the page style
1328cdf0e10cSrcweir                     ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
1329cdf0e10cSrcweir                     rDoc.CopyPageDesc(*pDesc, *pNewDsc); // #i7983#
1330cdf0e10cSrcweir                     // <--
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir                     pFmt = &pNewDsc->GetMaster();
1333cdf0e10cSrcweir                 }
1334cdf0e10cSrcweir             }
1335cdf0e10cSrcweir             break;
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO:
1338cdf0e10cSrcweir             {
1339cdf0e10cSrcweir                 ASSERT(pNumRule, "Wo ist die NumRule");
1340cdf0e10cSrcweir 
1341cdf0e10cSrcweir                 if (!pNumRule)
1342cdf0e10cSrcweir                     break;
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir                 const SfxPoolItem* pItem;
1345cdf0e10cSrcweir                 switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, sal_False, &pItem ))
1346cdf0e10cSrcweir                 {
1347cdf0e10cSrcweir                 case SFX_ITEM_SET:
1348cdf0e10cSrcweir                 {
1349cdf0e10cSrcweir                     SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
1350cdf0e10cSrcweir                     pSetRule->UnLinkGraphics();
1351cdf0e10cSrcweir                     //SwNumRule aSetRule(rDoc.GetUniqueNumRuleName());
1352cdf0e10cSrcweir                     SwNumRule aSetRule(*pNumRule);
1353cdf0e10cSrcweir                     aSetRule.SetSvxRule(*pSetRule, &rDoc);
1354cdf0e10cSrcweir                     rDoc.ChgNumRuleFmts( aSetRule );
1355cdf0e10cSrcweir                 }
1356cdf0e10cSrcweir                 break;
1357cdf0e10cSrcweir                 case SFX_ITEM_DONTCARE:
1358cdf0e10cSrcweir                     // NumRule auf default Werte
1359cdf0e10cSrcweir                     // was sind die default Werte?
1360cdf0e10cSrcweir                     {
1361cdf0e10cSrcweir                         // --> OD 2008-02-11 #newlistlevelattrs#
1362cdf0e10cSrcweir                         SwNumRule aRule( pNumRule->GetName(),
1363cdf0e10cSrcweir                                          // --> OD 2008-06-06 #i89178#
1364cdf0e10cSrcweir                                          numfunc::GetDefaultPositionAndSpaceMode() );
1365cdf0e10cSrcweir                                          // <--
1366cdf0e10cSrcweir                         // <--
1367cdf0e10cSrcweir                         rDoc.ChgNumRuleFmts( aRule );
1368cdf0e10cSrcweir                     }
1369cdf0e10cSrcweir                     break;
1370cdf0e10cSrcweir                 }
1371cdf0e10cSrcweir             }
1372cdf0e10cSrcweir             break;
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir         default:
1375cdf0e10cSrcweir             ASSERT(!this, "unbekannte Style-Familie");
1376cdf0e10cSrcweir     }
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir     if( pFmt && rSet.Count())
1379cdf0e10cSrcweir     {
1380cdf0e10cSrcweir         SfxItemIter aIter( rSet );
1381cdf0e10cSrcweir         const SfxPoolItem* pItem = aIter.GetCurItem();
1382cdf0e10cSrcweir         while( sal_True )
1383cdf0e10cSrcweir         {
1384cdf0e10cSrcweir             if( IsInvalidItem( pItem ) )            // Clearen
1385cdf0e10cSrcweir             {
1386cdf0e10cSrcweir                 // --> OD 2008-02-12 #newlistlevelattrs#
1387cdf0e10cSrcweir                 // use method <SwDoc::ResetAttrAtFormat(..)> in order to
1388cdf0e10cSrcweir                 // create an Undo object for the attribute reset.
1389cdf0e10cSrcweir //                pFmt->ResetAttr( rSet.GetWhichByPos(aIter.GetCurPos()));
1390cdf0e10cSrcweir                 rDoc.ResetAttrAtFormat( rSet.GetWhichByPos(aIter.GetCurPos()),
1391cdf0e10cSrcweir                                         *pFmt );
1392cdf0e10cSrcweir             }
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir             if( aIter.IsAtEnd() )
1395cdf0e10cSrcweir                 break;
1396cdf0e10cSrcweir             pItem = aIter.NextItem();
1397cdf0e10cSrcweir         }
1398cdf0e10cSrcweir         SfxItemSet aSet(rSet);
1399cdf0e10cSrcweir         aSet.ClearInvalidItems();
1400cdf0e10cSrcweir 
140164b14621SArmin Le Grand         if(SFX_STYLE_FAMILY_FRAME == nFamily)
140264b14621SArmin Le Grand         {
140364b14621SArmin Le Grand             //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
140464b14621SArmin Le Grand             // and evtl. correct that item to ensure unique names for that type. This call may
140564b14621SArmin Le Grand             // modify/correct entries inside of the given SfxItemSet
140664b14621SArmin Le Grand             rDoc.CheckForUniqueItemForLineFillNameOrIndex(aSet);
140764b14621SArmin Le Grand         }
140864b14621SArmin Le Grand 
1409cdf0e10cSrcweir         aCoreSet.ClearItem();
1410cdf0e10cSrcweir 
1411cdf0e10cSrcweir         if( pNewDsc )
1412cdf0e10cSrcweir         {
1413cdf0e10cSrcweir             ::ItemSetToPageDesc( aSet, *pNewDsc );
1414cdf0e10cSrcweir             rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
1415cdf0e10cSrcweir             pDesc = &const_cast<const SwDoc &>(rDoc).GetPageDesc( nPgDscPos );
1416cdf0e10cSrcweir             rDoc.PreDelPageDesc(pNewDsc); // #i7983#
1417cdf0e10cSrcweir             delete pNewDsc;
1418cdf0e10cSrcweir         }
1419cdf0e10cSrcweir         else
1420cdf0e10cSrcweir             rDoc.ChgFmt(*pFmt, aSet);       // alles gesetzten Putten
1421cdf0e10cSrcweir     }
1422cdf0e10cSrcweir     else
1423cdf0e10cSrcweir     {
1424cdf0e10cSrcweir         aCoreSet.ClearItem();
1425cdf0e10cSrcweir         if( pNewDsc )           // den muessen wir noch vernichten!!
1426cdf0e10cSrcweir         {
1427cdf0e10cSrcweir             rDoc.PreDelPageDesc(pNewDsc); // #i7983#
1428cdf0e10cSrcweir             delete pNewDsc;
1429cdf0e10cSrcweir         }
1430cdf0e10cSrcweir     }
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir     // --> OD 2008-02-12 #newlistlevelattrs#
1433cdf0e10cSrcweir     if (rDoc.GetIDocumentUndoRedo().DoesUndo())
1434cdf0e10cSrcweir     {
1435cdf0e10cSrcweir         rDoc.GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
1436cdf0e10cSrcweir     }
1437cdf0e10cSrcweir     // <--
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir 
1440cdf0e10cSrcweir void lcl_SaveStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc )
1441cdf0e10cSrcweir {
1442cdf0e10cSrcweir     switch( nFamily )
1443cdf0e10cSrcweir     {
1444cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR:
1445cdf0e10cSrcweir         {
1446cdf0e10cSrcweir             const SwCharFmts& rTbl = *rDoc.GetCharFmts();
1447cdf0e10cSrcweir             for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1448cdf0e10cSrcweir             {
1449cdf0e10cSrcweir                 void* p = (void*)rTbl[ n ];
1450cdf0e10cSrcweir                 rArr.Insert( p, n );
1451cdf0e10cSrcweir             }
1452cdf0e10cSrcweir         }
1453cdf0e10cSrcweir         break;
1454cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA:
1455cdf0e10cSrcweir         {
1456cdf0e10cSrcweir             const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
1457cdf0e10cSrcweir             for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1458cdf0e10cSrcweir             {
1459cdf0e10cSrcweir                 void* p = (void*)rTbl[ n ];
1460cdf0e10cSrcweir                 rArr.Insert( p, n );
1461cdf0e10cSrcweir             }
1462cdf0e10cSrcweir         }
1463cdf0e10cSrcweir         break;
1464cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME:
1465cdf0e10cSrcweir         {
1466cdf0e10cSrcweir             const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
1467cdf0e10cSrcweir             for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1468cdf0e10cSrcweir             {
1469cdf0e10cSrcweir                 void* p = (void*)rTbl[ n ];
1470cdf0e10cSrcweir                 rArr.Insert( p, n );
1471cdf0e10cSrcweir             }
1472cdf0e10cSrcweir         }
1473cdf0e10cSrcweir         break;
1474cdf0e10cSrcweir 
1475cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE:
1476cdf0e10cSrcweir         {
1477cdf0e10cSrcweir             for( sal_uInt16 n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1478cdf0e10cSrcweir             {
1479cdf0e10cSrcweir                 void* p =
1480cdf0e10cSrcweir                     (void*)&const_cast<const SwDoc &>(rDoc).GetPageDesc( n );
1481cdf0e10cSrcweir                 rArr.Insert( p, n );
1482cdf0e10cSrcweir             }
1483cdf0e10cSrcweir         }
1484cdf0e10cSrcweir         break;
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
1487cdf0e10cSrcweir         {
1488cdf0e10cSrcweir             const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
1489cdf0e10cSrcweir             for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1490cdf0e10cSrcweir             {
1491cdf0e10cSrcweir                 void* p = (void*)rTbl[ n ];
1492cdf0e10cSrcweir                 rArr.Insert( p, n );
1493cdf0e10cSrcweir             }
1494cdf0e10cSrcweir         }
1495cdf0e10cSrcweir         break;
1496cdf0e10cSrcweir     }
1497cdf0e10cSrcweir }
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir void lcl_DeleteInfoStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc )
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir     sal_uInt16 n, nCnt;
1502cdf0e10cSrcweir     switch( nFamily )
1503cdf0e10cSrcweir     {
1504cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR:
1505cdf0e10cSrcweir         {
1506cdf0e10cSrcweir             SvUShorts aDelArr;
1507cdf0e10cSrcweir             const SwCharFmts& rTbl = *rDoc.GetCharFmts();
1508cdf0e10cSrcweir             for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1509cdf0e10cSrcweir             {
1510cdf0e10cSrcweir                 void* p = (void*)rTbl[ n ];
1511cdf0e10cSrcweir                 if( USHRT_MAX == rArr.GetPos( p ))
1512cdf0e10cSrcweir                     aDelArr.Insert( n, 0 );
1513cdf0e10cSrcweir             }
1514cdf0e10cSrcweir             for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1515cdf0e10cSrcweir                 rDoc.DelCharFmt( aDelArr[ n ] );
1516cdf0e10cSrcweir         }
1517cdf0e10cSrcweir         break;
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA :
1520cdf0e10cSrcweir         {
1521cdf0e10cSrcweir             SvUShorts aDelArr;
1522cdf0e10cSrcweir             const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
1523cdf0e10cSrcweir             for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1524cdf0e10cSrcweir             {
1525cdf0e10cSrcweir                 void* p = (void*)rTbl[ n ];
1526cdf0e10cSrcweir                 if( USHRT_MAX == rArr.GetPos( p ))
1527cdf0e10cSrcweir                     aDelArr.Insert( n, 0 );
1528cdf0e10cSrcweir             }
1529cdf0e10cSrcweir             for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1530cdf0e10cSrcweir                 rDoc.DelTxtFmtColl( aDelArr[ n ] );
1531cdf0e10cSrcweir         }
1532cdf0e10cSrcweir         break;
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME:
1535cdf0e10cSrcweir         {
1536cdf0e10cSrcweir             SvPtrarr aDelArr;
1537cdf0e10cSrcweir             const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
1538cdf0e10cSrcweir             for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1539cdf0e10cSrcweir             {
1540cdf0e10cSrcweir                 void* p = (void*)rTbl[ n ];
1541cdf0e10cSrcweir                 if( USHRT_MAX == rArr.GetPos( p ))
1542cdf0e10cSrcweir                     aDelArr.Insert( p, 0 );
1543cdf0e10cSrcweir             }
1544cdf0e10cSrcweir             for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1545cdf0e10cSrcweir                 rDoc.DelFrmFmt( (SwFrmFmt*)aDelArr[ n ] );
1546cdf0e10cSrcweir         }
1547cdf0e10cSrcweir         break;
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE:
1550cdf0e10cSrcweir         {
1551cdf0e10cSrcweir             SvUShorts aDelArr;
1552cdf0e10cSrcweir             for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1553cdf0e10cSrcweir             {
1554cdf0e10cSrcweir                 void* p =
1555cdf0e10cSrcweir                     (void*)&const_cast<const SwDoc &>(rDoc).GetPageDesc( n );
1556cdf0e10cSrcweir                 if( USHRT_MAX == rArr.GetPos( p ))
1557cdf0e10cSrcweir                     aDelArr.Insert( n, 0 );
1558cdf0e10cSrcweir             }
1559cdf0e10cSrcweir             for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1560cdf0e10cSrcweir                 rDoc.DelPageDesc( aDelArr[ n ] );
1561cdf0e10cSrcweir         }
1562cdf0e10cSrcweir         break;
1563cdf0e10cSrcweir 
1564cdf0e10cSrcweir 
1565cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
1566cdf0e10cSrcweir         {
1567cdf0e10cSrcweir             SvPtrarr aDelArr;
1568cdf0e10cSrcweir             const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
1569cdf0e10cSrcweir             for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1570cdf0e10cSrcweir             {
1571cdf0e10cSrcweir                 void* p = (void*)rTbl[ n ];
1572cdf0e10cSrcweir                 if( USHRT_MAX == rArr.GetPos( p ))
1573cdf0e10cSrcweir                     aDelArr.Insert( p, 0 );
1574cdf0e10cSrcweir             }
1575cdf0e10cSrcweir             for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1576cdf0e10cSrcweir                 rDoc.DelNumRule( ((SwNumRule*)aDelArr[ n ])->GetName() );
1577cdf0e10cSrcweir         }
1578cdf0e10cSrcweir         break;
1579cdf0e10cSrcweir     }
1580cdf0e10cSrcweir }
1581cdf0e10cSrcweir 
1582cdf0e10cSrcweir /*--------------------------------------------------------------------
1583cdf0e10cSrcweir     Beschreibung:   Das Format ermitteln
1584cdf0e10cSrcweir  --------------------------------------------------------------------*/
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir sal_Bool SwDocStyleSheet::FillStyleSheet( FillStyleType eFType )
1587cdf0e10cSrcweir {
1588cdf0e10cSrcweir     sal_Bool bRet = sal_False;
1589cdf0e10cSrcweir     sal_uInt16 nPoolId = USHRT_MAX;
1590cdf0e10cSrcweir     SwFmt* pFmt = 0;
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir     sal_Bool bCreate = FillPhysical == eFType;
1593cdf0e10cSrcweir     sal_Bool bDeleteInfo = sal_False;
1594cdf0e10cSrcweir     sal_Bool bFillOnlyInfo = FillAllInfo == eFType;
1595cdf0e10cSrcweir     SvPtrarr aDelArr;
1596cdf0e10cSrcweir 
1597cdf0e10cSrcweir     switch(nFamily)
1598cdf0e10cSrcweir     {
1599cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR:
1600cdf0e10cSrcweir         pCharFmt = lcl_FindCharFmt(rDoc, aName, this, bCreate );
1601cdf0e10cSrcweir         bPhysical = 0 != pCharFmt;
1602cdf0e10cSrcweir         if( bFillOnlyInfo && !bPhysical )
1603cdf0e10cSrcweir         {
1604cdf0e10cSrcweir             bDeleteInfo = sal_True;
1605cdf0e10cSrcweir             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1606cdf0e10cSrcweir             pCharFmt = lcl_FindCharFmt(rDoc, aName, this, sal_True );
1607cdf0e10cSrcweir         }
1608cdf0e10cSrcweir 
1609cdf0e10cSrcweir         pFmt = pCharFmt;
1610cdf0e10cSrcweir         if( !bCreate && !pFmt )
1611cdf0e10cSrcweir         {
1612cdf0e10cSrcweir             if( aName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
1613cdf0e10cSrcweir                                             RES_POOLCOLL_TEXT_BEGIN ] )
1614cdf0e10cSrcweir                 nPoolId = 0;
1615cdf0e10cSrcweir             else
1616cdf0e10cSrcweir                 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
1617cdf0e10cSrcweir         }
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir         bRet = 0 != pCharFmt || USHRT_MAX != nPoolId;
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir         if( bDeleteInfo )
1622cdf0e10cSrcweir             pCharFmt = 0;
1623cdf0e10cSrcweir         break;
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA:
1626cdf0e10cSrcweir         {
1627cdf0e10cSrcweir             pColl = lcl_FindParaFmt(rDoc, aName, this, bCreate);
1628cdf0e10cSrcweir             bPhysical = 0 != pColl;
1629cdf0e10cSrcweir             if( bFillOnlyInfo && !bPhysical )
1630cdf0e10cSrcweir             {
1631cdf0e10cSrcweir                 bDeleteInfo = sal_True;
1632cdf0e10cSrcweir                 ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1633cdf0e10cSrcweir                 pColl = lcl_FindParaFmt(rDoc, aName, this, sal_True );
1634cdf0e10cSrcweir             }
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir             pFmt = pColl;
1637cdf0e10cSrcweir             if( pColl )
1638cdf0e10cSrcweir                 PresetFollow( pColl->GetNextTxtFmtColl().GetName() );
1639cdf0e10cSrcweir             else if( !bCreate )
1640cdf0e10cSrcweir                 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir             bRet = 0 != pColl || USHRT_MAX != nPoolId;
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir             if( bDeleteInfo )
1645cdf0e10cSrcweir                 pColl = 0;
1646cdf0e10cSrcweir         }
1647cdf0e10cSrcweir         break;
1648cdf0e10cSrcweir 
1649cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME:
1650cdf0e10cSrcweir         pFrmFmt = lcl_FindFrmFmt(rDoc,  aName, this, bCreate);
1651cdf0e10cSrcweir         bPhysical = 0 != pFrmFmt;
1652cdf0e10cSrcweir         if( bFillOnlyInfo && bPhysical )
1653cdf0e10cSrcweir         {
1654cdf0e10cSrcweir             bDeleteInfo = sal_True;
1655cdf0e10cSrcweir             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1656cdf0e10cSrcweir             pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, sal_True );
1657cdf0e10cSrcweir         }
1658cdf0e10cSrcweir         pFmt = pFrmFmt;
1659cdf0e10cSrcweir         if( !bCreate && !pFmt )
1660cdf0e10cSrcweir             nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir         bRet = 0 != pFrmFmt || USHRT_MAX != nPoolId;
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir         if( bDeleteInfo )
1665cdf0e10cSrcweir             pFrmFmt = 0;
1666cdf0e10cSrcweir         break;
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE:
1669cdf0e10cSrcweir         pDesc = lcl_FindPageDesc(rDoc, aName, this, bCreate);
1670cdf0e10cSrcweir         bPhysical = 0 != pDesc;
1671cdf0e10cSrcweir         if( bFillOnlyInfo && !pDesc )
1672cdf0e10cSrcweir         {
1673cdf0e10cSrcweir             bDeleteInfo = sal_True;
1674cdf0e10cSrcweir             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1675cdf0e10cSrcweir             pDesc = lcl_FindPageDesc( rDoc, aName, this, sal_True );
1676cdf0e10cSrcweir         }
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir         if( pDesc )
1679cdf0e10cSrcweir         {
1680cdf0e10cSrcweir             nPoolId = pDesc->GetPoolFmtId();
1681cdf0e10cSrcweir             nHelpId = pDesc->GetPoolHelpId();
1682cdf0e10cSrcweir             if( pDesc->GetPoolHlpFileId() != UCHAR_MAX )
1683cdf0e10cSrcweir                 aHelpFile = *rDoc.GetDocPattern( pDesc->GetPoolHlpFileId() );
1684cdf0e10cSrcweir             else
1685cdf0e10cSrcweir                 aHelpFile.Erase();
1686cdf0e10cSrcweir         }
1687cdf0e10cSrcweir         else if( !bCreate )
1688cdf0e10cSrcweir             nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
1689cdf0e10cSrcweir         SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
1690cdf0e10cSrcweir 
1691cdf0e10cSrcweir         bRet = 0 != pDesc || USHRT_MAX != nPoolId;
1692cdf0e10cSrcweir         if( bDeleteInfo )
1693cdf0e10cSrcweir             pDesc = 0;
1694cdf0e10cSrcweir         break;
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
1697cdf0e10cSrcweir         pNumRule = lcl_FindNumRule(rDoc, aName, this, bCreate);
1698cdf0e10cSrcweir         bPhysical = 0 != pNumRule;
1699cdf0e10cSrcweir         if( bFillOnlyInfo && !pNumRule )
1700cdf0e10cSrcweir         {
1701cdf0e10cSrcweir             bDeleteInfo = sal_True;
1702cdf0e10cSrcweir             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1703cdf0e10cSrcweir             pNumRule = lcl_FindNumRule( rDoc, aName, this, sal_True );
1704cdf0e10cSrcweir         }
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir         if( pNumRule )
1707cdf0e10cSrcweir         {
1708cdf0e10cSrcweir             nPoolId = pNumRule->GetPoolFmtId();
1709cdf0e10cSrcweir             nHelpId = pNumRule->GetPoolHelpId();
1710cdf0e10cSrcweir             if( pNumRule->GetPoolHlpFileId() != UCHAR_MAX )
1711cdf0e10cSrcweir                 aHelpFile = *rDoc.GetDocPattern( pNumRule->GetPoolHlpFileId() );
1712cdf0e10cSrcweir             else
1713cdf0e10cSrcweir                 aHelpFile.Erase();
1714cdf0e10cSrcweir         }
1715cdf0e10cSrcweir         else if( !bCreate )
1716cdf0e10cSrcweir             nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
1717cdf0e10cSrcweir         SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
1718cdf0e10cSrcweir 
1719cdf0e10cSrcweir         bRet = 0 != pNumRule || USHRT_MAX != nPoolId;
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir         if( bDeleteInfo )
1722cdf0e10cSrcweir             pNumRule = 0;
1723cdf0e10cSrcweir         break;
1724cdf0e10cSrcweir         default:; //prevent warning
1725cdf0e10cSrcweir     }
1726cdf0e10cSrcweir 
1727cdf0e10cSrcweir     if( SFX_STYLE_FAMILY_CHAR == nFamily ||
1728cdf0e10cSrcweir         SFX_STYLE_FAMILY_PARA == nFamily ||
1729cdf0e10cSrcweir         SFX_STYLE_FAMILY_FRAME == nFamily )
1730cdf0e10cSrcweir     {
1731cdf0e10cSrcweir         if( pFmt )
1732cdf0e10cSrcweir             nPoolId = pFmt->GetPoolFmtId();
1733cdf0e10cSrcweir 
1734cdf0e10cSrcweir         sal_uInt16 _nMask = 0;
1735cdf0e10cSrcweir         if( pFmt == rDoc.GetDfltCharFmt() )
1736cdf0e10cSrcweir             _nMask |= SFXSTYLEBIT_READONLY;
1737cdf0e10cSrcweir         else if( USER_FMT & nPoolId )
1738cdf0e10cSrcweir             _nMask |= SFXSTYLEBIT_USERDEF;
1739cdf0e10cSrcweir 
1740cdf0e10cSrcweir         switch ( COLL_GET_RANGE_BITS & nPoolId )
1741cdf0e10cSrcweir         {
1742cdf0e10cSrcweir         case COLL_TEXT_BITS:     _nMask |= SWSTYLEBIT_TEXT;   break;
1743cdf0e10cSrcweir         case COLL_DOC_BITS :     _nMask |= SWSTYLEBIT_CHAPTER; break;
1744cdf0e10cSrcweir         case COLL_LISTS_BITS:    _nMask |= SWSTYLEBIT_LIST;   break;
1745cdf0e10cSrcweir         case COLL_REGISTER_BITS: _nMask |= SWSTYLEBIT_IDX;    break;
1746cdf0e10cSrcweir         case COLL_EXTRA_BITS:    _nMask |= SWSTYLEBIT_EXTRA;      break;
1747cdf0e10cSrcweir         case COLL_HTML_BITS:     _nMask |= SWSTYLEBIT_HTML;   break;
1748cdf0e10cSrcweir         }
1749cdf0e10cSrcweir 
1750cdf0e10cSrcweir         if( pFmt )
1751cdf0e10cSrcweir         {
1752cdf0e10cSrcweir             ASSERT( bPhysical, "Format nicht gefunden" );
1753cdf0e10cSrcweir 
1754cdf0e10cSrcweir             nHelpId = pFmt->GetPoolHelpId();
1755cdf0e10cSrcweir             if( pFmt->GetPoolHlpFileId() != UCHAR_MAX )
1756cdf0e10cSrcweir                 aHelpFile = *rDoc.GetDocPattern( pFmt->GetPoolHlpFileId() );
1757cdf0e10cSrcweir             else
1758cdf0e10cSrcweir                 aHelpFile.Erase();
1759cdf0e10cSrcweir 
1760cdf0e10cSrcweir             if( RES_CONDTXTFMTCOLL == pFmt->Which() )
1761cdf0e10cSrcweir                 _nMask |= SWSTYLEBIT_CONDCOLL;
1762cdf0e10cSrcweir         }
1763cdf0e10cSrcweir 
1764cdf0e10cSrcweir         SetMask( _nMask );
1765cdf0e10cSrcweir     }
1766cdf0e10cSrcweir     if( bDeleteInfo && bFillOnlyInfo )
1767cdf0e10cSrcweir         ::lcl_DeleteInfoStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1768cdf0e10cSrcweir     return bRet;
1769cdf0e10cSrcweir }
1770cdf0e10cSrcweir 
1771cdf0e10cSrcweir /*--------------------------------------------------------------------
1772cdf0e10cSrcweir     Beschreibung:   Neues Format in der Core anlegen
1773cdf0e10cSrcweir  --------------------------------------------------------------------*/
1774cdf0e10cSrcweir 
1775cdf0e10cSrcweir 
1776cdf0e10cSrcweir void SwDocStyleSheet::Create()
1777cdf0e10cSrcweir {
1778cdf0e10cSrcweir     switch(nFamily)
1779cdf0e10cSrcweir     {
1780cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR :
1781cdf0e10cSrcweir             pCharFmt = lcl_FindCharFmt( rDoc, aName );
1782cdf0e10cSrcweir             if( !pCharFmt )
1783cdf0e10cSrcweir                 pCharFmt = rDoc.MakeCharFmt(aName,
1784cdf0e10cSrcweir                                             rDoc.GetDfltCharFmt());
1785cdf0e10cSrcweir             pCharFmt->SetAuto( sal_False );
1786cdf0e10cSrcweir             break;
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA :
1789cdf0e10cSrcweir             pColl = lcl_FindParaFmt( rDoc, aName );
1790cdf0e10cSrcweir             if( !pColl )
1791cdf0e10cSrcweir             {
1792cdf0e10cSrcweir                 SwTxtFmtColl *pPar = (*rDoc.GetTxtFmtColls())[0];
1793cdf0e10cSrcweir                 if( nMask & SWSTYLEBIT_CONDCOLL )
1794cdf0e10cSrcweir                     pColl = rDoc.MakeCondTxtFmtColl( aName, pPar );
1795cdf0e10cSrcweir                 else
1796cdf0e10cSrcweir                     pColl = rDoc.MakeTxtFmtColl( aName, pPar );
1797cdf0e10cSrcweir             }
1798cdf0e10cSrcweir             break;
1799cdf0e10cSrcweir 
1800cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME:
1801cdf0e10cSrcweir             pFrmFmt = lcl_FindFrmFmt( rDoc, aName );
1802cdf0e10cSrcweir             if( !pFrmFmt )
1803cdf0e10cSrcweir                 pFrmFmt = rDoc.MakeFrmFmt(aName, rDoc.GetDfltFrmFmt(), sal_False, sal_False);
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir             break;
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE :
1808cdf0e10cSrcweir             pDesc = lcl_FindPageDesc( rDoc, aName );
1809cdf0e10cSrcweir             if( !pDesc )
1810cdf0e10cSrcweir             {
1811cdf0e10cSrcweir                 sal_uInt16 nId = rDoc.MakePageDesc(aName);
1812cdf0e10cSrcweir                 pDesc = &const_cast<const SwDoc &>(rDoc).GetPageDesc(nId);
1813cdf0e10cSrcweir             }
1814cdf0e10cSrcweir             break;
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO:
1817cdf0e10cSrcweir             pNumRule = lcl_FindNumRule( rDoc, aName );
1818cdf0e10cSrcweir             if( !pNumRule )
1819cdf0e10cSrcweir             {
1820cdf0e10cSrcweir                 //JP 05.02.99: temp Namen erzeugen, damit kein ASSERT kommt
1821cdf0e10cSrcweir                 String sTmpNm( aName );
1822cdf0e10cSrcweir                 if( !aName.Len() )
1823cdf0e10cSrcweir                     sTmpNm = rDoc.GetUniqueNumRuleName();
1824cdf0e10cSrcweir 
1825cdf0e10cSrcweir                 // --> OD 2008-02-11 #newlistlevelattrs#
1826cdf0e10cSrcweir                 SwNumRule* pRule = rDoc.GetNumRuleTbl()[
1827cdf0e10cSrcweir                     rDoc.MakeNumRule( sTmpNm, 0, sal_False,
1828cdf0e10cSrcweir                                       // --> OD 2008-06-06 #i89178#
1829cdf0e10cSrcweir                                       numfunc::GetDefaultPositionAndSpaceMode() ) ];
1830cdf0e10cSrcweir                                       // <--
1831cdf0e10cSrcweir                 // <--
1832cdf0e10cSrcweir                 pRule->SetAutoRule( sal_False );
1833cdf0e10cSrcweir                 if( !aName.Len() )
1834cdf0e10cSrcweir                 {
1835cdf0e10cSrcweir                     // --> OD 2008-07-08 #i91400#
1836cdf0e10cSrcweir                     pRule->SetName( aName, rDoc );
1837cdf0e10cSrcweir                     // <--
1838cdf0e10cSrcweir                 }
1839cdf0e10cSrcweir                 pNumRule = pRule;
1840cdf0e10cSrcweir             }
1841cdf0e10cSrcweir             break;
1842cdf0e10cSrcweir         default:; //prevent warning
1843cdf0e10cSrcweir     }
1844cdf0e10cSrcweir     bPhysical = sal_True;
1845cdf0e10cSrcweir     aCoreSet.ClearItem();
1846cdf0e10cSrcweir }
1847cdf0e10cSrcweir 
1848cdf0e10cSrcweir /*--------------------------------------------------------------------
1849cdf0e10cSrcweir     Beschreibung:   Konkrete Formate rausholen
1850cdf0e10cSrcweir  --------------------------------------------------------------------*/
1851cdf0e10cSrcweir 
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir 
1854cdf0e10cSrcweir SwCharFmt* SwDocStyleSheet::GetCharFmt()
1855cdf0e10cSrcweir {
1856cdf0e10cSrcweir     if(!bPhysical)
1857cdf0e10cSrcweir         FillStyleSheet( FillPhysical );
1858cdf0e10cSrcweir     return pCharFmt;
1859cdf0e10cSrcweir }
1860cdf0e10cSrcweir 
1861cdf0e10cSrcweir 
1862cdf0e10cSrcweir SwTxtFmtColl* SwDocStyleSheet::GetCollection()
1863cdf0e10cSrcweir {
1864cdf0e10cSrcweir     if(!bPhysical)
1865cdf0e10cSrcweir         FillStyleSheet( FillPhysical );
1866cdf0e10cSrcweir     return pColl;
1867cdf0e10cSrcweir }
1868cdf0e10cSrcweir 
1869cdf0e10cSrcweir 
1870cdf0e10cSrcweir const SwPageDesc* SwDocStyleSheet::GetPageDesc()
1871cdf0e10cSrcweir {
1872cdf0e10cSrcweir     if(!bPhysical)
1873cdf0e10cSrcweir         FillStyleSheet( FillPhysical );
1874cdf0e10cSrcweir     return pDesc;
1875cdf0e10cSrcweir }
1876cdf0e10cSrcweir 
1877cdf0e10cSrcweir const SwNumRule * SwDocStyleSheet::GetNumRule()
1878cdf0e10cSrcweir {
1879cdf0e10cSrcweir     if(!bPhysical)
1880cdf0e10cSrcweir         FillStyleSheet( FillPhysical );
1881cdf0e10cSrcweir     return pNumRule;
1882cdf0e10cSrcweir }
1883cdf0e10cSrcweir 
1884cdf0e10cSrcweir void SwDocStyleSheet::SetNumRule(const SwNumRule& rRule)
1885cdf0e10cSrcweir {
1886cdf0e10cSrcweir     DBG_ASSERT(pNumRule, "Wo ist die NumRule");
1887cdf0e10cSrcweir     rDoc.ChgNumRuleFmts( rRule );
1888cdf0e10cSrcweir }
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir // Namen UND Familie aus String re-generieren
1891cdf0e10cSrcweir // First() und Next() (s.u.) fuegen einen Kennbuchstaben an Pos.1 ein
1892cdf0e10cSrcweir 
1893cdf0e10cSrcweir void SwDocStyleSheet::PresetNameAndFamily(const String& rName)
1894cdf0e10cSrcweir {
1895cdf0e10cSrcweir     switch( rName.GetChar(0) )
1896cdf0e10cSrcweir     {
1897cdf0e10cSrcweir         case cPARA:     nFamily = SFX_STYLE_FAMILY_PARA; break;
1898cdf0e10cSrcweir         case cFRAME:    nFamily = SFX_STYLE_FAMILY_FRAME; break;
1899cdf0e10cSrcweir         case cPAGE:     nFamily = SFX_STYLE_FAMILY_PAGE; break;
1900cdf0e10cSrcweir         case cNUMRULE:  nFamily = SFX_STYLE_FAMILY_PSEUDO; break;
1901cdf0e10cSrcweir         default:        nFamily = SFX_STYLE_FAMILY_CHAR; break;
1902cdf0e10cSrcweir     }
1903cdf0e10cSrcweir     aName = rName;
1904cdf0e10cSrcweir     aName.Erase( 0, 1 );
1905cdf0e10cSrcweir }
1906cdf0e10cSrcweir 
1907cdf0e10cSrcweir /*--------------------------------------------------------------------
1908cdf0e10cSrcweir     Beschreibung:   Ist das Format physikalisch schon vorhanden
1909cdf0e10cSrcweir  --------------------------------------------------------------------*/
1910cdf0e10cSrcweir 
1911cdf0e10cSrcweir 
1912cdf0e10cSrcweir void SwDocStyleSheet::SetPhysical(sal_Bool bPhys)
1913cdf0e10cSrcweir {
1914cdf0e10cSrcweir     bPhysical = bPhys;
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir     if(!bPhys)
1917cdf0e10cSrcweir     {
1918cdf0e10cSrcweir         pCharFmt = 0;
1919cdf0e10cSrcweir         pColl    = 0;
1920cdf0e10cSrcweir         pFrmFmt  = 0;
1921cdf0e10cSrcweir         pDesc    = 0;
1922cdf0e10cSrcweir     }
1923cdf0e10cSrcweir }
1924cdf0e10cSrcweir 
1925cdf0e10cSrcweir SwFrmFmt* SwDocStyleSheet::GetFrmFmt()
1926cdf0e10cSrcweir {
1927cdf0e10cSrcweir     if(!bPhysical)
1928cdf0e10cSrcweir         FillStyleSheet( FillPhysical );
1929cdf0e10cSrcweir     return pFrmFmt;
1930cdf0e10cSrcweir }
1931cdf0e10cSrcweir 
1932cdf0e10cSrcweir 
1933cdf0e10cSrcweir sal_Bool  SwDocStyleSheet::IsUsed() const
1934cdf0e10cSrcweir {
1935cdf0e10cSrcweir     if( !bPhysical )
1936cdf0e10cSrcweir     {
1937cdf0e10cSrcweir         SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
1938cdf0e10cSrcweir         pThis->FillStyleSheet( FillOnlyName );
1939cdf0e10cSrcweir     }
1940cdf0e10cSrcweir 
1941cdf0e10cSrcweir     // immer noch nicht ?
1942cdf0e10cSrcweir     if( !bPhysical )
1943cdf0e10cSrcweir         return sal_False;
1944cdf0e10cSrcweir 
1945cdf0e10cSrcweir     const SwModify* pMod;
1946cdf0e10cSrcweir     switch( nFamily )
1947cdf0e10cSrcweir     {
1948cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR : pMod = pCharFmt;   break;
1949cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA : pMod = pColl;      break;
1950cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME: pMod = pFrmFmt;    break;
1951cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE : pMod = pDesc;      break;
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
1954cdf0e10cSrcweir             return pNumRule ? rDoc.IsUsed( *pNumRule ) : sal_False;
1955cdf0e10cSrcweir 
1956cdf0e10cSrcweir     default:
1957cdf0e10cSrcweir         ASSERT(!this, "unbekannte Style-Familie");
1958cdf0e10cSrcweir         return sal_False;
1959cdf0e10cSrcweir     }
1960cdf0e10cSrcweir     return rDoc.IsUsed( *pMod );
1961cdf0e10cSrcweir }
1962cdf0e10cSrcweir 
1963cdf0e10cSrcweir 
1964cdf0e10cSrcweir sal_uLong  SwDocStyleSheet::GetHelpId( String& rFile )
1965cdf0e10cSrcweir {
1966cdf0e10cSrcweir static String sTemplateHelpFile = String::CreateFromAscii("swrhlppi.hlp");
1967cdf0e10cSrcweir 
1968cdf0e10cSrcweir     sal_uInt16 nId = 0;
1969cdf0e10cSrcweir     sal_uInt16 nPoolId = 0;
1970cdf0e10cSrcweir     unsigned char nFileId = UCHAR_MAX;
1971cdf0e10cSrcweir 
1972cdf0e10cSrcweir     rFile = sTemplateHelpFile;
1973cdf0e10cSrcweir 
1974cdf0e10cSrcweir     const SwFmt* pTmpFmt = 0;
1975cdf0e10cSrcweir     switch( nFamily )
1976cdf0e10cSrcweir     {
1977cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR :
1978cdf0e10cSrcweir         if( !pCharFmt &&
1979cdf0e10cSrcweir             0 == (pCharFmt = lcl_FindCharFmt( rDoc, aName, 0, sal_False )) )
1980cdf0e10cSrcweir         {
1981cdf0e10cSrcweir             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
1982cdf0e10cSrcweir             return USHRT_MAX == nId ? 0 : nId;
1983cdf0e10cSrcweir         }
1984cdf0e10cSrcweir         pTmpFmt = pCharFmt;
1985cdf0e10cSrcweir         break;
1986cdf0e10cSrcweir 
1987cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA:
1988cdf0e10cSrcweir         if( !pColl &&
1989cdf0e10cSrcweir             0 == ( pColl = lcl_FindParaFmt( rDoc, aName, 0, sal_False )) )
1990cdf0e10cSrcweir         {
1991cdf0e10cSrcweir             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
1992cdf0e10cSrcweir             return USHRT_MAX == nId ? 0 : nId;
1993cdf0e10cSrcweir         }
1994cdf0e10cSrcweir         pTmpFmt = pColl;
1995cdf0e10cSrcweir         break;
1996cdf0e10cSrcweir 
1997cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME:
1998cdf0e10cSrcweir         if( !pFrmFmt &&
1999cdf0e10cSrcweir             0 == ( pFrmFmt = lcl_FindFrmFmt( rDoc, aName, 0, sal_False ) ) )
2000cdf0e10cSrcweir         {
2001cdf0e10cSrcweir             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
2002cdf0e10cSrcweir             return USHRT_MAX == nId ? 0 : nId;
2003cdf0e10cSrcweir         }
2004cdf0e10cSrcweir         pTmpFmt = pFrmFmt;
2005cdf0e10cSrcweir         break;
2006cdf0e10cSrcweir 
2007cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE:
2008cdf0e10cSrcweir         if( !pDesc &&
2009cdf0e10cSrcweir             0 == ( pDesc = lcl_FindPageDesc( rDoc, aName, 0, sal_False ) ) )
2010cdf0e10cSrcweir         {
2011cdf0e10cSrcweir             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
2012cdf0e10cSrcweir             return USHRT_MAX == nId ? 0 : nId;
2013cdf0e10cSrcweir         }
2014cdf0e10cSrcweir 
2015cdf0e10cSrcweir         nId = pDesc->GetPoolHelpId();
2016cdf0e10cSrcweir         nFileId = pDesc->GetPoolHlpFileId();
2017cdf0e10cSrcweir         nPoolId = pDesc->GetPoolFmtId();
2018cdf0e10cSrcweir         break;
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
2021cdf0e10cSrcweir         if( !pNumRule &&
2022cdf0e10cSrcweir             0 == ( pNumRule = lcl_FindNumRule( rDoc, aName, 0, sal_False ) ) )
2023cdf0e10cSrcweir         {
2024cdf0e10cSrcweir             nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
2025cdf0e10cSrcweir             return USHRT_MAX == nId ? 0 : nId;
2026cdf0e10cSrcweir         }
2027cdf0e10cSrcweir 
2028cdf0e10cSrcweir         nId = pNumRule->GetPoolHelpId();
2029cdf0e10cSrcweir         nFileId = pNumRule->GetPoolHlpFileId();
2030cdf0e10cSrcweir         nPoolId = pNumRule->GetPoolFmtId();
2031cdf0e10cSrcweir         break;
2032cdf0e10cSrcweir 
2033cdf0e10cSrcweir     default:
2034cdf0e10cSrcweir         ASSERT(!this, "unbekannte Style-Familie");
2035cdf0e10cSrcweir         return 0;
2036cdf0e10cSrcweir     }
2037cdf0e10cSrcweir 
2038cdf0e10cSrcweir     if( pTmpFmt )
2039cdf0e10cSrcweir     {
2040cdf0e10cSrcweir         nId = pTmpFmt->GetPoolHelpId();
2041cdf0e10cSrcweir         nFileId = pTmpFmt->GetPoolHlpFileId();
2042cdf0e10cSrcweir         nPoolId = pTmpFmt->GetPoolFmtId();
2043cdf0e10cSrcweir     }
2044cdf0e10cSrcweir 
2045cdf0e10cSrcweir     if( UCHAR_MAX != nFileId )
2046cdf0e10cSrcweir     {
2047cdf0e10cSrcweir         const String *pTemplate = rDoc.GetDocPattern( nFileId );
2048cdf0e10cSrcweir         if( pTemplate )
2049cdf0e10cSrcweir         {
2050cdf0e10cSrcweir //          const String aHelpPath(MakeHelpPath(*pTemplate));
2051cdf0e10cSrcweir             rFile = *pTemplate;
2052cdf0e10cSrcweir         }
2053cdf0e10cSrcweir     }
2054cdf0e10cSrcweir     else if( !IsPoolUserFmt( nPoolId ) )
2055cdf0e10cSrcweir     {
2056cdf0e10cSrcweir         nId = nPoolId;
2057cdf0e10cSrcweir     }
2058cdf0e10cSrcweir 
2059cdf0e10cSrcweir     // weil sich der SFX so anstellt mit der HilfeId:
2060cdf0e10cSrcweir     if( USHRT_MAX == nId )
2061cdf0e10cSrcweir         nId = 0;        // entsp. keine Hilfe anzeigen
2062cdf0e10cSrcweir 
2063cdf0e10cSrcweir     return nId;
2064cdf0e10cSrcweir }
2065cdf0e10cSrcweir 
2066cdf0e10cSrcweir 
2067cdf0e10cSrcweir void  SwDocStyleSheet::SetHelpId( const String& r, sal_uLong nId )
2068cdf0e10cSrcweir {
2069cdf0e10cSrcweir     sal_uInt8 nFileId = static_cast< sal_uInt8 >(rDoc.SetDocPattern( r ));
2070cdf0e10cSrcweir     sal_uInt16 nHId = static_cast< sal_uInt16 >(nId);     //!! SFX hat eigenmaechtig auf sal_uLong umgestellt!
2071cdf0e10cSrcweir 
2072cdf0e10cSrcweir     SwFmt* pTmpFmt = 0;
2073cdf0e10cSrcweir     switch( nFamily )
2074cdf0e10cSrcweir     {
2075cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR : pTmpFmt = pCharFmt;    break;
2076cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA : pTmpFmt = pColl;       break;
2077cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME: pTmpFmt = pFrmFmt;     break;
2078cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE :
2079cdf0e10cSrcweir         ((SwPageDesc*)pDesc)->SetPoolHelpId( nHId );
2080cdf0e10cSrcweir         ((SwPageDesc*)pDesc)->SetPoolHlpFileId( nFileId );
2081cdf0e10cSrcweir         break;
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
2084cdf0e10cSrcweir         ((SwNumRule*)pNumRule)->SetPoolHelpId( nHId );
2085cdf0e10cSrcweir         ((SwNumRule*)pNumRule)->SetPoolHlpFileId( nFileId );
2086cdf0e10cSrcweir         break;
2087cdf0e10cSrcweir 
2088cdf0e10cSrcweir     default:
2089cdf0e10cSrcweir         ASSERT(!this, "unbekannte Style-Familie");
2090cdf0e10cSrcweir         return ;
2091cdf0e10cSrcweir     }
2092cdf0e10cSrcweir     if( pTmpFmt )
2093cdf0e10cSrcweir     {
2094cdf0e10cSrcweir         pTmpFmt->SetPoolHelpId( nHId );
2095cdf0e10cSrcweir         pTmpFmt->SetPoolHlpFileId( nFileId );
2096cdf0e10cSrcweir     }
2097cdf0e10cSrcweir }
2098cdf0e10cSrcweir 
2099cdf0e10cSrcweir 
2100cdf0e10cSrcweir /*  */
2101cdf0e10cSrcweir 
2102cdf0e10cSrcweir /*--------------------------------------------------------------------
2103cdf0e10cSrcweir     Beschreibung:   Methoden fuer den DocStyleSheetPool
2104cdf0e10cSrcweir  --------------------------------------------------------------------*/
2105cdf0e10cSrcweir 
2106cdf0e10cSrcweir SwDocStyleSheetPool::SwDocStyleSheetPool( SwDoc& rDocument, sal_Bool bOrg )
2107cdf0e10cSrcweir : SfxStyleSheetBasePool( rDocument.GetAttrPool() )
2108cdf0e10cSrcweir , mxStyleSheet( new SwDocStyleSheet( rDocument, aEmptyStr, *this, SFX_STYLE_FAMILY_CHAR, 0 ) )
2109cdf0e10cSrcweir , rDoc( rDocument )
2110cdf0e10cSrcweir {
2111cdf0e10cSrcweir     bOrganizer = bOrg;
2112cdf0e10cSrcweir }
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir  SwDocStyleSheetPool::~SwDocStyleSheetPool()
2115cdf0e10cSrcweir {
2116cdf0e10cSrcweir }
2117cdf0e10cSrcweir 
2118cdf0e10cSrcweir void SAL_CALL SwDocStyleSheetPool::acquire(  ) throw ()
2119cdf0e10cSrcweir {
2120cdf0e10cSrcweir     comphelper::OWeakTypeObject::acquire();
2121cdf0e10cSrcweir }
2122cdf0e10cSrcweir 
2123cdf0e10cSrcweir void SAL_CALL SwDocStyleSheetPool::release(  ) throw ()
2124cdf0e10cSrcweir {
2125cdf0e10cSrcweir     comphelper::OWeakTypeObject::release();
2126cdf0e10cSrcweir }
2127cdf0e10cSrcweir 
2128cdf0e10cSrcweir SfxStyleSheetBase&   SwDocStyleSheetPool::Make(
2129cdf0e10cSrcweir         const String&   rName,
2130cdf0e10cSrcweir         SfxStyleFamily  eFam,
2131cdf0e10cSrcweir         sal_uInt16          _nMask,
2132cdf0e10cSrcweir         sal_uInt16          /*nPos*/ )
2133cdf0e10cSrcweir {
2134cdf0e10cSrcweir     mxStyleSheet->PresetName(rName);
2135cdf0e10cSrcweir     mxStyleSheet->PresetParent(aEmptyStr);
2136cdf0e10cSrcweir     mxStyleSheet->PresetFollow(aEmptyStr);
2137cdf0e10cSrcweir     mxStyleSheet->SetMask(_nMask) ;
2138cdf0e10cSrcweir     mxStyleSheet->SetFamily(eFam);
2139cdf0e10cSrcweir     mxStyleSheet->SetPhysical(sal_True);
2140cdf0e10cSrcweir     mxStyleSheet->Create();
2141cdf0e10cSrcweir 
2142cdf0e10cSrcweir     return *mxStyleSheet.get();
2143cdf0e10cSrcweir }
2144cdf0e10cSrcweir 
2145cdf0e10cSrcweir 
2146cdf0e10cSrcweir SfxStyleSheetBase*   SwDocStyleSheetPool::Create( const SfxStyleSheetBase& /*rOrg*/)
2147cdf0e10cSrcweir {
2148cdf0e10cSrcweir     ASSERT(!this , "Create im SW-Stylesheet-Pool geht nicht" );
2149cdf0e10cSrcweir     return NULL;
2150cdf0e10cSrcweir }
2151cdf0e10cSrcweir 
2152cdf0e10cSrcweir 
2153cdf0e10cSrcweir SfxStyleSheetBase*   SwDocStyleSheetPool::Create( const String &,
2154cdf0e10cSrcweir                                                 SfxStyleFamily, sal_uInt16 )
2155cdf0e10cSrcweir {
2156cdf0e10cSrcweir     ASSERT( !this, "Create im SW-Stylesheet-Pool geht nicht" );
2157cdf0e10cSrcweir     return NULL;
2158cdf0e10cSrcweir }
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir void  SwDocStyleSheetPool::Replace( SfxStyleSheetBase& rSource,
2161cdf0e10cSrcweir                                             SfxStyleSheetBase& rTarget )
2162cdf0e10cSrcweir {
2163cdf0e10cSrcweir     SfxStyleFamily eFamily( rSource.GetFamily() );
2164cdf0e10cSrcweir     if( rSource.HasParentSupport())
2165cdf0e10cSrcweir     {
2166cdf0e10cSrcweir         const String& rParentName = rSource.GetParent();
2167cdf0e10cSrcweir         if( 0 != rParentName.Len() )
2168cdf0e10cSrcweir         {
2169cdf0e10cSrcweir             SfxStyleSheetBase* pParentOfNew = Find( rParentName, eFamily );
2170cdf0e10cSrcweir             if( pParentOfNew )
2171cdf0e10cSrcweir                 rTarget.SetParent( rParentName );
2172cdf0e10cSrcweir         }
2173cdf0e10cSrcweir     }
2174cdf0e10cSrcweir     if( rSource.HasFollowSupport())
2175cdf0e10cSrcweir     {
2176cdf0e10cSrcweir         const String& rFollowName = rSource.GetFollow();
2177cdf0e10cSrcweir         if( 0 != rFollowName.Len() )
2178cdf0e10cSrcweir         {
2179cdf0e10cSrcweir             SfxStyleSheetBase* pFollowOfNew = Find( rFollowName, eFamily );
2180cdf0e10cSrcweir             if( pFollowOfNew )
2181cdf0e10cSrcweir                 rTarget.SetFollow( rFollowName );
2182cdf0e10cSrcweir         }
2183cdf0e10cSrcweir     }
2184cdf0e10cSrcweir 
2185cdf0e10cSrcweir     SwImplShellAction aTmpSh( rDoc );
2186cdf0e10cSrcweir 
2187cdf0e10cSrcweir     sal_Bool bSwSrcPool = GetAppName() == rSource.GetPool().GetAppName();
2188cdf0e10cSrcweir     if( SFX_STYLE_FAMILY_PAGE == eFamily && bSwSrcPool )
2189cdf0e10cSrcweir     {
2190cdf0e10cSrcweir         // gesondert behandeln!!
2191cdf0e10cSrcweir         SwPageDesc* pDestDsc =
2192cdf0e10cSrcweir             (SwPageDesc*)((SwDocStyleSheet&)rTarget).GetPageDesc();
2193cdf0e10cSrcweir         SwPageDesc* pCpyDsc =
2194cdf0e10cSrcweir             (SwPageDesc*)((SwDocStyleSheet&)rSource).GetPageDesc();
2195cdf0e10cSrcweir         rDoc.CopyPageDesc( *pCpyDsc, *pDestDsc );
2196cdf0e10cSrcweir     }
2197cdf0e10cSrcweir     else
2198cdf0e10cSrcweir     {
2199cdf0e10cSrcweir         const SwFmt *pSourceFmt = 0;
2200cdf0e10cSrcweir         SwFmt *pTargetFmt = 0;
2201cdf0e10cSrcweir         sal_uInt16 nPgDscPos = USHRT_MAX;
2202cdf0e10cSrcweir         switch( eFamily )
2203cdf0e10cSrcweir         {
2204cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR :
2205cdf0e10cSrcweir             if( bSwSrcPool )
2206cdf0e10cSrcweir                 pSourceFmt = ((SwDocStyleSheet&)rSource).GetCharFmt();
2207cdf0e10cSrcweir             pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCharFmt();
2208cdf0e10cSrcweir             break;
2209cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA :
2210cdf0e10cSrcweir             if( bSwSrcPool )
2211cdf0e10cSrcweir                 pSourceFmt = ((SwDocStyleSheet&)rSource).GetCollection();
2212cdf0e10cSrcweir             pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCollection();
2213cdf0e10cSrcweir             break;
2214cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME:
2215cdf0e10cSrcweir             if( bSwSrcPool )
2216cdf0e10cSrcweir                 pSourceFmt = ((SwDocStyleSheet&)rSource).GetFrmFmt();
2217cdf0e10cSrcweir             pTargetFmt = ((SwDocStyleSheet&)rTarget).GetFrmFmt();
2218cdf0e10cSrcweir             break;
2219cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE:
2220cdf0e10cSrcweir             if( bSwSrcPool )
2221cdf0e10cSrcweir                 pSourceFmt = &((SwDocStyleSheet&)rSource).GetPageDesc()
2222cdf0e10cSrcweir                                 ->GetMaster();
2223cdf0e10cSrcweir             {
2224cdf0e10cSrcweir                 SwPageDesc *pDesc = rDoc.FindPageDescByName(
2225cdf0e10cSrcweir                     ((SwDocStyleSheet&)rTarget).GetPageDesc()->GetName(),
2226cdf0e10cSrcweir                     &nPgDscPos );
2227cdf0e10cSrcweir 
2228cdf0e10cSrcweir                 if( pDesc )
2229cdf0e10cSrcweir                     pTargetFmt = &pDesc->GetMaster();
2230cdf0e10cSrcweir             }
2231cdf0e10cSrcweir             break;
2232cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO:
2233cdf0e10cSrcweir             // Eine NumRule besteht nur aus einem Item, also muss man
2234cdf0e10cSrcweir             // hier nichts loeschen.
2235cdf0e10cSrcweir             break;
2236cdf0e10cSrcweir         default:; //prevent warning
2237cdf0e10cSrcweir         }
2238cdf0e10cSrcweir         if( pTargetFmt )
2239cdf0e10cSrcweir         {
2240cdf0e10cSrcweir             if( pSourceFmt )
2241cdf0e10cSrcweir                 pTargetFmt->DelDiffs( *pSourceFmt );
2242cdf0e10cSrcweir             else if( USHRT_MAX != nPgDscPos )
2243cdf0e10cSrcweir                 pTargetFmt->ResetFmtAttr( RES_PAGEDESC, RES_FRMATR_END-1 );
2244cdf0e10cSrcweir             else
2245cdf0e10cSrcweir             {
2246cdf0e10cSrcweir                 // --> OD 2007-01-25 #i73790# - method renamed
2247cdf0e10cSrcweir                 pTargetFmt->ResetAllFmtAttr();
2248cdf0e10cSrcweir                 // <--
2249cdf0e10cSrcweir             }
2250cdf0e10cSrcweir 
2251cdf0e10cSrcweir             if( USHRT_MAX != nPgDscPos )
2252cdf0e10cSrcweir                 rDoc.ChgPageDesc( nPgDscPos,
2253cdf0e10cSrcweir                                   const_cast<const SwDoc &>(rDoc).
2254cdf0e10cSrcweir                                   GetPageDesc(nPgDscPos) );
2255cdf0e10cSrcweir         }
2256cdf0e10cSrcweir         ((SwDocStyleSheet&)rTarget).SetItemSet( rSource.GetItemSet() );
2257cdf0e10cSrcweir     }
2258cdf0e10cSrcweir }
2259cdf0e10cSrcweir 
226049bd4d4bSArmin Le Grand SfxStyleSheetIteratorPtr SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, sal_uInt16 _nMask )
226149bd4d4bSArmin Le Grand {
226249bd4d4bSArmin Le Grand     return SfxStyleSheetIteratorPtr(new SwStyleSheetIterator( this, eFam, _nMask ));
226349bd4d4bSArmin Le Grand }
226449bd4d4bSArmin Le Grand 
2265cdf0e10cSrcweir void SwDocStyleSheetPool::dispose()
2266cdf0e10cSrcweir {
2267cdf0e10cSrcweir     mxStyleSheet.clear();
2268cdf0e10cSrcweir }
2269cdf0e10cSrcweir 
2270cdf0e10cSrcweir void SwDocStyleSheetPool::Remove( SfxStyleSheetBase* pStyle)
2271cdf0e10cSrcweir {
2272cdf0e10cSrcweir     if( !pStyle )
2273cdf0e10cSrcweir         return;
2274cdf0e10cSrcweir 
2275cdf0e10cSrcweir     sal_Bool bBroadcast = sal_True;
2276cdf0e10cSrcweir     SwImplShellAction aTmpSh( rDoc );
2277cdf0e10cSrcweir     const String& rName = pStyle->GetName();
2278cdf0e10cSrcweir     switch( pStyle->GetFamily() )
2279cdf0e10cSrcweir     {
2280cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR:
2281cdf0e10cSrcweir         {
2282cdf0e10cSrcweir             SwCharFmt* pFmt = lcl_FindCharFmt(rDoc, rName, 0, sal_False );
2283cdf0e10cSrcweir             if(pFmt)
2284cdf0e10cSrcweir                 rDoc.DelCharFmt(pFmt);
2285cdf0e10cSrcweir         }
2286cdf0e10cSrcweir         break;
2287cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA:
2288cdf0e10cSrcweir         {
2289cdf0e10cSrcweir             SwTxtFmtColl* pColl = lcl_FindParaFmt(rDoc, rName, 0, sal_False );
2290cdf0e10cSrcweir             if(pColl)
2291cdf0e10cSrcweir                 rDoc.DelTxtFmtColl(pColl);
2292cdf0e10cSrcweir         }
2293cdf0e10cSrcweir         break;
2294cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME:
2295cdf0e10cSrcweir         {
2296cdf0e10cSrcweir             SwFrmFmt* pFmt = lcl_FindFrmFmt(rDoc, rName, 0, sal_False );
2297cdf0e10cSrcweir             if(pFmt)
2298cdf0e10cSrcweir                 rDoc.DelFrmFmt(pFmt);
2299cdf0e10cSrcweir         }
2300cdf0e10cSrcweir         break;
2301cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE :
2302cdf0e10cSrcweir         {
2303cdf0e10cSrcweir             sal_uInt16 nPos;
2304cdf0e10cSrcweir             if( rDoc.FindPageDescByName( rName, &nPos ))
2305cdf0e10cSrcweir                 rDoc.DelPageDesc( nPos );
2306cdf0e10cSrcweir         }
2307cdf0e10cSrcweir         break;
2308cdf0e10cSrcweir 
2309cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
2310cdf0e10cSrcweir         {
2311cdf0e10cSrcweir             if( !rDoc.DelNumRule( rName ) )
2312cdf0e10cSrcweir                 // Broadcast nur versenden, wenn etwas geloescht wurde
2313cdf0e10cSrcweir                 bBroadcast = sal_False;
2314cdf0e10cSrcweir         }
2315cdf0e10cSrcweir         break;
2316cdf0e10cSrcweir 
2317cdf0e10cSrcweir     default:
2318cdf0e10cSrcweir         ASSERT(!this, "unbekannte Style-Familie");
2319cdf0e10cSrcweir         bBroadcast = sal_False;
2320cdf0e10cSrcweir     }
2321cdf0e10cSrcweir 
2322cdf0e10cSrcweir     if( bBroadcast )
2323cdf0e10cSrcweir         Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *pStyle ) );
2324cdf0e10cSrcweir }
2325cdf0e10cSrcweir 
2326cdf0e10cSrcweir 
2327cdf0e10cSrcweir 
2328cdf0e10cSrcweir sal_Bool  SwDocStyleSheetPool::SetParent( SfxStyleFamily eFam,
2329cdf0e10cSrcweir                                 const String &rStyle, const String &rParent )
2330cdf0e10cSrcweir {
2331cdf0e10cSrcweir     SwFmt* pFmt = 0, *pParent = 0;
2332cdf0e10cSrcweir     switch( eFam )
2333cdf0e10cSrcweir     {
2334cdf0e10cSrcweir     case SFX_STYLE_FAMILY_CHAR :
2335cdf0e10cSrcweir         if( 0 != ( pFmt = lcl_FindCharFmt( rDoc, rStyle ) ) && rParent.Len() )
2336cdf0e10cSrcweir             pParent = lcl_FindCharFmt(rDoc, rParent );
2337cdf0e10cSrcweir         break;
2338cdf0e10cSrcweir 
2339cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PARA :
2340cdf0e10cSrcweir         if( 0 != ( pFmt = lcl_FindParaFmt( rDoc, rStyle ) ) && rParent.Len() )
2341cdf0e10cSrcweir             pParent = lcl_FindParaFmt( rDoc, rParent );
2342cdf0e10cSrcweir         break;
2343cdf0e10cSrcweir 
2344cdf0e10cSrcweir     case SFX_STYLE_FAMILY_FRAME:
2345cdf0e10cSrcweir         if( 0 != ( pFmt = lcl_FindFrmFmt( rDoc, rStyle ) ) && rParent.Len() )
2346cdf0e10cSrcweir             pParent = lcl_FindFrmFmt( rDoc, rParent );
2347cdf0e10cSrcweir         break;
2348cdf0e10cSrcweir 
2349cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PAGE:
2350cdf0e10cSrcweir     case SFX_STYLE_FAMILY_PSEUDO:
2351cdf0e10cSrcweir         break;
2352cdf0e10cSrcweir 
2353cdf0e10cSrcweir     default:
2354cdf0e10cSrcweir         ASSERT(!this, "unbekannte Style-Familie");
2355cdf0e10cSrcweir     }
2356cdf0e10cSrcweir 
2357cdf0e10cSrcweir     sal_Bool bRet = sal_False;
2358cdf0e10cSrcweir     if( pFmt && pFmt->DerivedFrom() &&
2359cdf0e10cSrcweir         pFmt->DerivedFrom()->GetName() != rParent )
2360cdf0e10cSrcweir     {
2361cdf0e10cSrcweir         {
2362cdf0e10cSrcweir             SwImplShellAction aTmpSh( rDoc );
2363cdf0e10cSrcweir             bRet = pFmt->SetDerivedFrom( pParent );
2364cdf0e10cSrcweir         }
2365cdf0e10cSrcweir 
2366cdf0e10cSrcweir         if( bRet )
2367cdf0e10cSrcweir         {
2368cdf0e10cSrcweir             // nur fuer das Broadcasting
2369cdf0e10cSrcweir             mxStyleSheet->PresetName( rStyle );
2370cdf0e10cSrcweir             mxStyleSheet->PresetParent( rParent );
2371cdf0e10cSrcweir             if( SFX_STYLE_FAMILY_PARA == eFam )
2372cdf0e10cSrcweir                 mxStyleSheet->PresetFollow( ((SwTxtFmtColl*)pFmt)->
2373cdf0e10cSrcweir                         GetNextTxtFmtColl().GetName() );
2374cdf0e10cSrcweir             else
2375cdf0e10cSrcweir                 mxStyleSheet->PresetFollow( aEmptyStr );
2376cdf0e10cSrcweir 
2377cdf0e10cSrcweir             Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
2378cdf0e10cSrcweir                                             *(mxStyleSheet.get()) ) );
2379cdf0e10cSrcweir         }
2380cdf0e10cSrcweir     }
2381cdf0e10cSrcweir 
2382cdf0e10cSrcweir     return bRet;
2383cdf0e10cSrcweir }
2384cdf0e10cSrcweir 
2385cdf0e10cSrcweir SfxStyleSheetBase* SwDocStyleSheetPool::Find( const String& rName,
2386cdf0e10cSrcweir                                             SfxStyleFamily eFam, sal_uInt16 n )
2387cdf0e10cSrcweir {
2388cdf0e10cSrcweir     sal_uInt16 nSMask = n;
2389cdf0e10cSrcweir     if( SFX_STYLE_FAMILY_PARA == eFam && rDoc.get(IDocumentSettingAccess::HTML_MODE) )
2390cdf0e10cSrcweir     {
2391cdf0e10cSrcweir         // dann sind nur HTML-Vorlagen von Interesse
2392cdf0e10cSrcweir         if( USHRT_MAX == nSMask )
2393cdf0e10cSrcweir             nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED;
2394cdf0e10cSrcweir         else
2395cdf0e10cSrcweir             nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
2396cdf0e10cSrcweir                                 SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
2397cdf0e10cSrcweir         if( !nSMask )
2398cdf0e10cSrcweir             nSMask = SWSTYLEBIT_HTML;
2399cdf0e10cSrcweir     }
2400cdf0e10cSrcweir 
2401cdf0e10cSrcweir     const sal_Bool bSearchUsed = ( n != SFXSTYLEBIT_ALL &&
2402cdf0e10cSrcweir                              n & SFXSTYLEBIT_USED ) ? sal_True : sal_False;
2403cdf0e10cSrcweir     const SwModify* pMod = 0;
2404cdf0e10cSrcweir 
2405cdf0e10cSrcweir     mxStyleSheet->SetPhysical( sal_False );
2406cdf0e10cSrcweir     mxStyleSheet->PresetName( rName );
2407cdf0e10cSrcweir     mxStyleSheet->SetFamily( eFam );
2408cdf0e10cSrcweir     sal_Bool bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2409cdf0e10cSrcweir 
2410cdf0e10cSrcweir     if( mxStyleSheet->IsPhysical() )
2411cdf0e10cSrcweir     {
2412cdf0e10cSrcweir         switch( eFam )
2413cdf0e10cSrcweir         {
2414cdf0e10cSrcweir         case SFX_STYLE_FAMILY_CHAR:
2415cdf0e10cSrcweir             pMod = mxStyleSheet->GetCharFmt();
2416cdf0e10cSrcweir             break;
2417cdf0e10cSrcweir 
2418cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PARA:
2419cdf0e10cSrcweir             pMod = mxStyleSheet->GetCollection();
2420cdf0e10cSrcweir             break;
2421cdf0e10cSrcweir 
2422cdf0e10cSrcweir         case SFX_STYLE_FAMILY_FRAME:
2423cdf0e10cSrcweir             pMod = mxStyleSheet->GetFrmFmt();
2424cdf0e10cSrcweir             break;
2425cdf0e10cSrcweir 
2426cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PAGE:
2427cdf0e10cSrcweir             pMod = mxStyleSheet->GetPageDesc();
2428cdf0e10cSrcweir             break;
2429cdf0e10cSrcweir 
2430cdf0e10cSrcweir         case SFX_STYLE_FAMILY_PSEUDO:
2431cdf0e10cSrcweir             {
2432cdf0e10cSrcweir                 const SwNumRule* pRule = mxStyleSheet->GetNumRule();
2433cdf0e10cSrcweir                 if( pRule &&
2434cdf0e10cSrcweir                     !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pRule)) ) &&
2435cdf0e10cSrcweir                     (( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2436cdf0e10cSrcweir                             ? !(pRule->GetPoolFmtId() & USER_FMT)
2437cdf0e10cSrcweir                                 // benutzte gesucht und keine gefunden
2438cdf0e10cSrcweir                             : bSearchUsed ))
2439cdf0e10cSrcweir                     bFnd = sal_False;
2440cdf0e10cSrcweir             }
2441cdf0e10cSrcweir             break;
2442cdf0e10cSrcweir 
2443cdf0e10cSrcweir         default:
2444cdf0e10cSrcweir             ASSERT(!this, "unbekannte Style-Familie");
2445cdf0e10cSrcweir         }
2446cdf0e10cSrcweir     }
2447cdf0e10cSrcweir 
2448cdf0e10cSrcweir     // dann noch die Maske auswerten:
2449cdf0e10cSrcweir     if( pMod && !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pMod)) ) )
2450cdf0e10cSrcweir     {
2451cdf0e10cSrcweir         const sal_uInt16 nId = SFX_STYLE_FAMILY_PAGE == eFam
2452cdf0e10cSrcweir                         ? ((SwPageDesc*)pMod)->GetPoolFmtId()
2453cdf0e10cSrcweir                         : ((SwFmt*)pMod)->GetPoolFmtId();
2454cdf0e10cSrcweir 
2455cdf0e10cSrcweir         if( ( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2456cdf0e10cSrcweir             ? !(nId & USER_FMT)
2457cdf0e10cSrcweir                 // benutzte gesucht und keine gefunden
2458cdf0e10cSrcweir             : bSearchUsed )
2459cdf0e10cSrcweir             bFnd = sal_False;
2460cdf0e10cSrcweir     }
2461cdf0e10cSrcweir     return bFnd ? mxStyleSheet.get() : 0;
2462cdf0e10cSrcweir }
2463cdf0e10cSrcweir 
2464cdf0e10cSrcweir /*  */
2465cdf0e10cSrcweir 
2466cdf0e10cSrcweir SwStyleSheetIterator::SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
2467cdf0e10cSrcweir                                 SfxStyleFamily eFam, sal_uInt16 n )
2468cdf0e10cSrcweir     : SfxStyleSheetIterator( pBase, eFam, n ),
2469cdf0e10cSrcweir     mxIterSheet( new SwDocStyleSheet( pBase->GetDoc(), aEmptyStr, *pBase, SFX_STYLE_FAMILY_CHAR, 0 ) ),
2470cdf0e10cSrcweir     mxStyleSheet( new SwDocStyleSheet( pBase->GetDoc(), aEmptyStr, *pBase, SFX_STYLE_FAMILY_CHAR, 0 ) )
2471cdf0e10cSrcweir {
2472cdf0e10cSrcweir     bFirstCalled = sal_False;
2473cdf0e10cSrcweir     nLastPos = 0;
2474cdf0e10cSrcweir     StartListening( *pBase );
2475cdf0e10cSrcweir }
2476cdf0e10cSrcweir 
2477cdf0e10cSrcweir  SwStyleSheetIterator::~SwStyleSheetIterator()
2478cdf0e10cSrcweir {
2479cdf0e10cSrcweir     EndListening( mxIterSheet->GetPool() );
2480cdf0e10cSrcweir }
2481cdf0e10cSrcweir 
2482cdf0e10cSrcweir sal_uInt16  SwStyleSheetIterator::Count()
2483cdf0e10cSrcweir {
2484cdf0e10cSrcweir     // Liste richtig fuellen lassen !!
2485cdf0e10cSrcweir     if( !bFirstCalled )
2486cdf0e10cSrcweir         First();
2487cdf0e10cSrcweir     return aLst.Count();
2488cdf0e10cSrcweir }
2489cdf0e10cSrcweir 
2490cdf0e10cSrcweir SfxStyleSheetBase*  SwStyleSheetIterator::operator[]( sal_uInt16 nIdx )
2491cdf0e10cSrcweir {
2492cdf0e10cSrcweir     // gefunden
2493cdf0e10cSrcweir     if( !bFirstCalled )
2494cdf0e10cSrcweir         First();
2495cdf0e10cSrcweir     mxStyleSheet->PresetNameAndFamily( *aLst[ nIdx ] );
2496cdf0e10cSrcweir     mxStyleSheet->SetPhysical( sal_False );
2497cdf0e10cSrcweir     mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2498cdf0e10cSrcweir 
2499cdf0e10cSrcweir     return mxStyleSheet.get();
2500cdf0e10cSrcweir }
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir SfxStyleSheetBase*  SwStyleSheetIterator::First()
2503cdf0e10cSrcweir {
2504cdf0e10cSrcweir     // Alte Liste loeschen
2505cdf0e10cSrcweir     bFirstCalled = sal_True;
2506cdf0e10cSrcweir     nLastPos = 0;
2507cdf0e10cSrcweir     aLst.Erase();
2508cdf0e10cSrcweir 
2509cdf0e10cSrcweir     // aktuellen loeschen
2510cdf0e10cSrcweir     mxIterSheet->Reset();
2511cdf0e10cSrcweir 
2512cdf0e10cSrcweir     SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
2513cdf0e10cSrcweir     const sal_uInt16 nSrchMask = nMask;
2514cdf0e10cSrcweir     const sal_Bool bIsSearchUsed = SearchUsed();
2515cdf0e10cSrcweir 
2516cdf0e10cSrcweir     const sal_Bool bOrganizer = ((SwDocStyleSheetPool*)pBasePool)->IsOrganizerMode();
2517cdf0e10cSrcweir 
2518cdf0e10cSrcweir     if( nSearchFamily == SFX_STYLE_FAMILY_CHAR
2519cdf0e10cSrcweir      || nSearchFamily == SFX_STYLE_FAMILY_ALL )
2520cdf0e10cSrcweir     {
2521cdf0e10cSrcweir         const sal_uInt16 nArrLen = rDoc.GetCharFmts()->Count();
2522cdf0e10cSrcweir         for( sal_uInt16 i = 0; i < nArrLen; i++ )
2523cdf0e10cSrcweir         {
2524cdf0e10cSrcweir             SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
2525cdf0e10cSrcweir             if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() )
2526cdf0e10cSrcweir                 continue;
2527cdf0e10cSrcweir 
2528cdf0e10cSrcweir             const sal_Bool  bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFmt));
2529cdf0e10cSrcweir             if( !bUsed )
2530cdf0e10cSrcweir             {
2531cdf0e10cSrcweir                 // Standard ist keine Benutzervorlage #46181#
2532cdf0e10cSrcweir                 const sal_uInt16 nId = rDoc.GetDfltCharFmt() == pFmt ?
2533cdf0e10cSrcweir                         sal_uInt16( RES_POOLCHR_INET_NORMAL ):
2534cdf0e10cSrcweir                                 pFmt->GetPoolFmtId();
2535cdf0e10cSrcweir                 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2536cdf0e10cSrcweir                     ? !(nId & USER_FMT)
2537cdf0e10cSrcweir                         // benutzte gesucht und keine gefunden
2538cdf0e10cSrcweir                     : bIsSearchUsed )
2539cdf0e10cSrcweir                 continue;
2540cdf0e10cSrcweir 
2541cdf0e10cSrcweir                 if( rDoc.get(IDocumentSettingAccess::HTML_MODE) && !(nId & USER_FMT) &&
2542cdf0e10cSrcweir                     !( RES_POOLCHR_HTML_BEGIN <= nId &&
2543cdf0e10cSrcweir                           nId < RES_POOLCHR_HTML_END ) &&
2544cdf0e10cSrcweir                     RES_POOLCHR_INET_NORMAL != nId &&
2545cdf0e10cSrcweir                     RES_POOLCHR_INET_VISIT != nId &&
2546cdf0e10cSrcweir                     RES_POOLCHR_FOOTNOTE  != nId &&
2547cdf0e10cSrcweir                     RES_POOLCHR_ENDNOTE != nId )
2548cdf0e10cSrcweir                     continue;
2549cdf0e10cSrcweir             }
2550cdf0e10cSrcweir 
2551cdf0e10cSrcweir             aLst.Append( cCHAR, pFmt == rDoc.GetDfltCharFmt()
2552cdf0e10cSrcweir                         ? (const String&) *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
2553cdf0e10cSrcweir                                                 RES_POOLCOLL_TEXT_BEGIN ]
2554cdf0e10cSrcweir                         : pFmt->GetName() );
2555cdf0e10cSrcweir         }
2556cdf0e10cSrcweir 
2557cdf0e10cSrcweir         // PoolFormate
2558cdf0e10cSrcweir         //
2559cdf0e10cSrcweir         if( nSrchMask == SFXSTYLEBIT_ALL )
2560cdf0e10cSrcweir         {
2561cdf0e10cSrcweir             if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) )
2562cdf0e10cSrcweir                 AppendStyleList(SwStyleNameMapper::GetChrFmtUINameArray(),
2563cdf0e10cSrcweir                                 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
2564cdf0e10cSrcweir             else
2565cdf0e10cSrcweir             {
2566cdf0e10cSrcweir                 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[
2567cdf0e10cSrcweir                         RES_POOLCHR_INET_NORMAL - RES_POOLCHR_BEGIN ] );
2568cdf0e10cSrcweir                 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[
2569cdf0e10cSrcweir                         RES_POOLCHR_INET_VISIT - RES_POOLCHR_BEGIN ] );
2570cdf0e10cSrcweir                 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[
2571cdf0e10cSrcweir                         RES_POOLCHR_ENDNOTE - RES_POOLCHR_BEGIN ] );
2572cdf0e10cSrcweir                 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[
2573cdf0e10cSrcweir                         RES_POOLCHR_FOOTNOTE - RES_POOLCHR_BEGIN ] );
2574cdf0e10cSrcweir             }
2575cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetHTMLChrFmtUINameArray(),
2576cdf0e10cSrcweir                                 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
2577cdf0e10cSrcweir         }
2578cdf0e10cSrcweir     }
2579cdf0e10cSrcweir 
2580cdf0e10cSrcweir     if( nSearchFamily == SFX_STYLE_FAMILY_PARA ||
2581cdf0e10cSrcweir         nSearchFamily == SFX_STYLE_FAMILY_ALL )
2582cdf0e10cSrcweir     {
2583cdf0e10cSrcweir         sal_uInt16 nSMask = nSrchMask;
2584cdf0e10cSrcweir         if( rDoc.get(IDocumentSettingAccess::HTML_MODE) )
2585cdf0e10cSrcweir         {
2586cdf0e10cSrcweir             // dann sind nur HTML-Vorlagen von Interesse
2587cdf0e10cSrcweir             if( USHRT_MAX == nSMask )
2588cdf0e10cSrcweir                 nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF |
2589cdf0e10cSrcweir                             SFXSTYLEBIT_USED;
2590cdf0e10cSrcweir             else
2591cdf0e10cSrcweir                 nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
2592cdf0e10cSrcweir                                 SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
2593cdf0e10cSrcweir             if( !nSMask )
2594cdf0e10cSrcweir                 nSMask = SWSTYLEBIT_HTML;
2595cdf0e10cSrcweir         }
2596cdf0e10cSrcweir 
2597cdf0e10cSrcweir         const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count();
2598cdf0e10cSrcweir         for( sal_uInt16 i = 0; i < nArrLen; i++ )
2599cdf0e10cSrcweir         {
2600cdf0e10cSrcweir             SwTxtFmtColl* pColl = (*rDoc.GetTxtFmtColls())[ i ];
2601cdf0e10cSrcweir 
2602cdf0e10cSrcweir             if(pColl->IsDefault())
2603cdf0e10cSrcweir                 continue;
2604cdf0e10cSrcweir 
2605cdf0e10cSrcweir             const sal_Bool bUsed = bOrganizer || rDoc.IsUsed(*pColl);
2606cdf0e10cSrcweir             if( !(bIsSearchUsed && bUsed ))
2607cdf0e10cSrcweir             {
2608cdf0e10cSrcweir                 const sal_uInt16 nId = pColl->GetPoolFmtId();
2609cdf0e10cSrcweir                 switch ( (nSMask & ~SFXSTYLEBIT_USED) )
2610cdf0e10cSrcweir                 {
2611cdf0e10cSrcweir                 case SFXSTYLEBIT_USERDEF:
2612cdf0e10cSrcweir                     if(!IsPoolUserFmt(nId)) continue;
2613cdf0e10cSrcweir                     break;
2614cdf0e10cSrcweir                 case SWSTYLEBIT_TEXT:
2615cdf0e10cSrcweir                     if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue;
2616cdf0e10cSrcweir                     break;
2617cdf0e10cSrcweir                 case SWSTYLEBIT_CHAPTER:
2618cdf0e10cSrcweir                     if((nId  & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue;
2619cdf0e10cSrcweir                     break;
2620cdf0e10cSrcweir                 case SWSTYLEBIT_LIST:
2621cdf0e10cSrcweir                     if((nId  & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue;
2622cdf0e10cSrcweir                     break;
2623cdf0e10cSrcweir                 case SWSTYLEBIT_IDX:
2624cdf0e10cSrcweir                     if((nId  & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue;
2625cdf0e10cSrcweir                     break;
2626cdf0e10cSrcweir                 case SWSTYLEBIT_EXTRA:
2627cdf0e10cSrcweir                     if((nId  & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue;
2628cdf0e10cSrcweir                     break;
2629cdf0e10cSrcweir 
2630cdf0e10cSrcweir                 case SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF:
2631cdf0e10cSrcweir                     if(IsPoolUserFmt(nId))
2632cdf0e10cSrcweir                         break;
2633cdf0e10cSrcweir                     // ansonten weiter
2634cdf0e10cSrcweir                 case SWSTYLEBIT_HTML:
2635cdf0e10cSrcweir                     if( (nId  & COLL_GET_RANGE_BITS) != COLL_HTML_BITS)
2636cdf0e10cSrcweir                     {
2637cdf0e10cSrcweir                         // einige wollen wir aber auch in dieser Section sehen
2638cdf0e10cSrcweir                         sal_Bool bWeiter = sal_True;
2639cdf0e10cSrcweir                         switch( nId )
2640cdf0e10cSrcweir                         {
2641cdf0e10cSrcweir                         case RES_POOLCOLL_SENDADRESS:   //  --> ADDRESS
2642cdf0e10cSrcweir                         case RES_POOLCOLL_TABLE_HDLN:   //  --> TH
2643cdf0e10cSrcweir                         case RES_POOLCOLL_TABLE:        //  --> TD
2644cdf0e10cSrcweir                         case RES_POOLCOLL_TEXT:         //  --> P
2645cdf0e10cSrcweir                         case RES_POOLCOLL_HEADLINE_BASE://  --> H
2646cdf0e10cSrcweir                         case RES_POOLCOLL_HEADLINE1:    //  --> H1
2647cdf0e10cSrcweir                         case RES_POOLCOLL_HEADLINE2:    //  --> H2
2648cdf0e10cSrcweir                         case RES_POOLCOLL_HEADLINE3:    //  --> H3
2649cdf0e10cSrcweir                         case RES_POOLCOLL_HEADLINE4:    //  --> H4
2650cdf0e10cSrcweir                         case RES_POOLCOLL_HEADLINE5:    //  --> H5
2651cdf0e10cSrcweir                         case RES_POOLCOLL_HEADLINE6:    //  --> H6
2652cdf0e10cSrcweir                         case RES_POOLCOLL_STANDARD:     //  --> P
2653cdf0e10cSrcweir                         case RES_POOLCOLL_FOOTNOTE:
2654cdf0e10cSrcweir                         case RES_POOLCOLL_ENDNOTE:
2655cdf0e10cSrcweir                             bWeiter = sal_False;
2656cdf0e10cSrcweir                             break;
2657cdf0e10cSrcweir                         }
2658cdf0e10cSrcweir                         if( bWeiter )
2659cdf0e10cSrcweir                             continue;
2660cdf0e10cSrcweir                     }
2661cdf0e10cSrcweir                     break;
2662cdf0e10cSrcweir                 case SWSTYLEBIT_CONDCOLL:
2663cdf0e10cSrcweir                     if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue;
2664cdf0e10cSrcweir                     break;
2665cdf0e10cSrcweir                 default:
2666cdf0e10cSrcweir                     // benutzte gesucht und keine gefunden
2667cdf0e10cSrcweir                     if( bIsSearchUsed )
2668cdf0e10cSrcweir                         continue;
2669cdf0e10cSrcweir                 }
2670cdf0e10cSrcweir             }
2671cdf0e10cSrcweir             aLst.Append( cPARA, pColl->GetName() );
2672cdf0e10cSrcweir         }
2673cdf0e10cSrcweir 
2674cdf0e10cSrcweir         const sal_Bool bAll = nSMask == SFXSTYLEBIT_ALL;
2675cdf0e10cSrcweir         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_TEXT )
2676cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetTextUINameArray(),
2677cdf0e10cSrcweir                             bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA );
2678cdf0e10cSrcweir         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CHAPTER )
2679cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetDocUINameArray(),
2680cdf0e10cSrcweir                             bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2681cdf0e10cSrcweir         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_LIST )
2682cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetListsUINameArray(),
2683cdf0e10cSrcweir                             bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2684cdf0e10cSrcweir         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_IDX )
2685cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetRegisterUINameArray(),
2686cdf0e10cSrcweir                             bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2687cdf0e10cSrcweir         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_EXTRA )
2688cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetExtraUINameArray(),
2689cdf0e10cSrcweir                             bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2690cdf0e10cSrcweir         if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CONDCOLL )
2691cdf0e10cSrcweir         {
2692cdf0e10cSrcweir             if( !bIsSearchUsed ||
2693cdf0e10cSrcweir                 rDoc.IsPoolTxtCollUsed( RES_POOLCOLL_TEXT ))
2694cdf0e10cSrcweir                 aLst.Append( cPARA, *SwStyleNameMapper::GetTextUINameArray()[
2695cdf0e10cSrcweir                         RES_POOLCOLL_TEXT - RES_POOLCOLL_TEXT_BEGIN ] );
2696cdf0e10cSrcweir         }
2697cdf0e10cSrcweir         if ( bAll ||
2698cdf0e10cSrcweir             (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_HTML ||
2699cdf0e10cSrcweir             (nSMask & ~SFXSTYLEBIT_USED) ==
2700cdf0e10cSrcweir                         (SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF) )
2701cdf0e10cSrcweir         {
2702cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetHTMLUINameArray(),
2703cdf0e10cSrcweir                             bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2704cdf0e10cSrcweir             if( !bAll )
2705cdf0e10cSrcweir             {
2706cdf0e10cSrcweir                 // dann auch die, die wir mappen:
2707cdf0e10cSrcweir                 static sal_uInt16 aPoolIds[] = {
2708cdf0e10cSrcweir                     RES_POOLCOLL_SENDADRESS,    //  --> ADDRESS
2709cdf0e10cSrcweir                     RES_POOLCOLL_TABLE_HDLN,    //  --> TH
2710cdf0e10cSrcweir                     RES_POOLCOLL_TABLE,     //  --> TD
2711cdf0e10cSrcweir                     RES_POOLCOLL_STANDARD,      //  --> P
2712cdf0e10cSrcweir                     RES_POOLCOLL_TEXT,          //  --> P
2713cdf0e10cSrcweir                     RES_POOLCOLL_HEADLINE_BASE, //  --> H
2714cdf0e10cSrcweir                     RES_POOLCOLL_HEADLINE1, //  --> H1
2715cdf0e10cSrcweir                     RES_POOLCOLL_HEADLINE2, //  --> H2
2716cdf0e10cSrcweir                     RES_POOLCOLL_HEADLINE3, //  --> H3
2717cdf0e10cSrcweir                     RES_POOLCOLL_HEADLINE4, //  --> H4
2718cdf0e10cSrcweir                     RES_POOLCOLL_HEADLINE5, //  --> H5
2719cdf0e10cSrcweir                     RES_POOLCOLL_HEADLINE6, //  --> H6
2720cdf0e10cSrcweir                     RES_POOLCOLL_FOOTNOTE,
2721cdf0e10cSrcweir                     RES_POOLCOLL_ENDNOTE,
2722cdf0e10cSrcweir                     0
2723cdf0e10cSrcweir                     };
2724cdf0e10cSrcweir 
2725cdf0e10cSrcweir                 sal_uInt16* pPoolIds = aPoolIds;
2726cdf0e10cSrcweir                 String s;
2727cdf0e10cSrcweir                 while( *pPoolIds )
2728cdf0e10cSrcweir                 {
2729cdf0e10cSrcweir                     if( !bIsSearchUsed || rDoc.IsPoolTxtCollUsed( *pPoolIds ) )
2730cdf0e10cSrcweir                         aLst.Append( cPARA,
2731cdf0e10cSrcweir                             s = SwStyleNameMapper::GetUIName( *pPoolIds, s ));
2732cdf0e10cSrcweir                     ++pPoolIds;
2733cdf0e10cSrcweir                 }
2734cdf0e10cSrcweir             }
2735cdf0e10cSrcweir         }
2736cdf0e10cSrcweir     }
2737cdf0e10cSrcweir 
2738cdf0e10cSrcweir     if( nSearchFamily == SFX_STYLE_FAMILY_FRAME ||
2739cdf0e10cSrcweir         nSearchFamily == SFX_STYLE_FAMILY_ALL )
2740cdf0e10cSrcweir     {
2741cdf0e10cSrcweir         const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->Count();
2742cdf0e10cSrcweir         for( sal_uInt16 i = 0; i < nArrLen; i++ )
2743cdf0e10cSrcweir         {
2744cdf0e10cSrcweir             SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
2745cdf0e10cSrcweir 
2746cdf0e10cSrcweir             if(pFmt->IsDefault() || pFmt->IsAuto())
2747cdf0e10cSrcweir             {
2748cdf0e10cSrcweir                 continue;
2749cdf0e10cSrcweir             }
2750cdf0e10cSrcweir 
2751cdf0e10cSrcweir             const sal_uInt16 nId = pFmt->GetPoolFmtId();
2752cdf0e10cSrcweir             sal_Bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFmt));
2753cdf0e10cSrcweir             if( !bUsed )
2754cdf0e10cSrcweir             {
2755cdf0e10cSrcweir                 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2756cdf0e10cSrcweir                     ? !(nId & USER_FMT)
2757cdf0e10cSrcweir                     // benutzte gesucht und keine gefunden
2758cdf0e10cSrcweir                     : bIsSearchUsed )
2759cdf0e10cSrcweir                 {
2760cdf0e10cSrcweir                     continue;
2761cdf0e10cSrcweir                 }
2762cdf0e10cSrcweir             }
2763cdf0e10cSrcweir 
2764cdf0e10cSrcweir             aLst.Append( cFRAME, pFmt->GetName() );
2765cdf0e10cSrcweir         }
2766cdf0e10cSrcweir 
2767cdf0e10cSrcweir         // PoolFormate
2768cdf0e10cSrcweir         //
2769cdf0e10cSrcweir         if ( nSrchMask == SFXSTYLEBIT_ALL )
2770cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetFrmFmtUINameArray(),
2771cdf0e10cSrcweir                                     bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, cFRAME);
2772cdf0e10cSrcweir     }
2773cdf0e10cSrcweir 
2774cdf0e10cSrcweir     if( nSearchFamily == SFX_STYLE_FAMILY_PAGE ||
2775cdf0e10cSrcweir         nSearchFamily == SFX_STYLE_FAMILY_ALL )
2776cdf0e10cSrcweir     {
2777cdf0e10cSrcweir         const sal_uInt16 nCount = rDoc.GetPageDescCnt();
2778cdf0e10cSrcweir         for(sal_uInt16 i = 0; i < nCount; ++i)
2779cdf0e10cSrcweir         {
2780cdf0e10cSrcweir             const SwPageDesc& rDesc =
2781cdf0e10cSrcweir                 const_cast<const SwDoc &>(rDoc).GetPageDesc(i);
2782cdf0e10cSrcweir             const sal_uInt16 nId = rDesc.GetPoolFmtId();
2783cdf0e10cSrcweir             sal_Bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc));
2784cdf0e10cSrcweir             if( !bUsed )
2785cdf0e10cSrcweir             {
2786cdf0e10cSrcweir                 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2787cdf0e10cSrcweir                     ? !(nId & USER_FMT)
2788cdf0e10cSrcweir                     // benutzte gesucht und keine gefunden
2789cdf0e10cSrcweir                     : bIsSearchUsed )
2790cdf0e10cSrcweir                     continue;
2791cdf0e10cSrcweir             }
2792cdf0e10cSrcweir 
2793cdf0e10cSrcweir             aLst.Append( cPAGE, rDesc.GetName() );
2794cdf0e10cSrcweir         }
2795cdf0e10cSrcweir         if ( nSrchMask == SFXSTYLEBIT_ALL )
2796cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetPageDescUINameArray(),
2797cdf0e10cSrcweir                             bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, cPAGE);
2798cdf0e10cSrcweir     }
2799cdf0e10cSrcweir 
2800cdf0e10cSrcweir     if( nSearchFamily == SFX_STYLE_FAMILY_PSEUDO ||
2801cdf0e10cSrcweir         nSearchFamily == SFX_STYLE_FAMILY_ALL )
2802cdf0e10cSrcweir     {
2803cdf0e10cSrcweir         const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
2804cdf0e10cSrcweir         for(sal_uInt16 i = 0; i < rNumTbl.Count(); ++i)
2805cdf0e10cSrcweir         {
2806cdf0e10cSrcweir             const SwNumRule& rRule = *rNumTbl[ i ];
2807cdf0e10cSrcweir             if( !rRule.IsAutoRule() )
2808cdf0e10cSrcweir             {
2809cdf0e10cSrcweir                 sal_Bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rRule) );
2810cdf0e10cSrcweir                 if( !bUsed )
2811cdf0e10cSrcweir                 {
2812cdf0e10cSrcweir                     if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2813cdf0e10cSrcweir                         ? !(rRule.GetPoolFmtId() & USER_FMT)
2814cdf0e10cSrcweir                         // benutzte gesucht und keine gefunden
2815cdf0e10cSrcweir                         : bIsSearchUsed )
2816cdf0e10cSrcweir                         continue;
2817cdf0e10cSrcweir                 }
2818cdf0e10cSrcweir 
2819cdf0e10cSrcweir                 aLst.Append( cNUMRULE, rRule.GetName() );
2820cdf0e10cSrcweir             }
2821cdf0e10cSrcweir         }
2822cdf0e10cSrcweir         if ( nSrchMask == SFXSTYLEBIT_ALL )
2823cdf0e10cSrcweir             AppendStyleList(SwStyleNameMapper::GetNumRuleUINameArray(),
2824cdf0e10cSrcweir                             bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, cNUMRULE);
2825cdf0e10cSrcweir     }
2826cdf0e10cSrcweir 
2827cdf0e10cSrcweir     if(aLst.Count() > 0)
2828cdf0e10cSrcweir     {
2829cdf0e10cSrcweir         nLastPos = USHRT_MAX;
2830cdf0e10cSrcweir         return Next();
2831cdf0e10cSrcweir     }
2832cdf0e10cSrcweir     return 0;
2833cdf0e10cSrcweir }
2834cdf0e10cSrcweir 
2835cdf0e10cSrcweir SfxStyleSheetBase*  SwStyleSheetIterator::Next()
2836cdf0e10cSrcweir {
2837cdf0e10cSrcweir     nLastPos++;
2838cdf0e10cSrcweir     if(aLst.Count() > 0 && nLastPos < aLst.Count())
2839cdf0e10cSrcweir     {
2840cdf0e10cSrcweir         mxIterSheet->PresetNameAndFamily(*aLst[nLastPos]);
2841cdf0e10cSrcweir         mxIterSheet->SetPhysical( sal_False );
2842cdf0e10cSrcweir         mxIterSheet->SetMask( nMask );
2843cdf0e10cSrcweir         if(mxIterSheet->pSet)
2844cdf0e10cSrcweir         {
2845cdf0e10cSrcweir             mxIterSheet->pSet->ClearItem(0);
2846cdf0e10cSrcweir             mxIterSheet->pSet= 0;
2847cdf0e10cSrcweir         }
2848cdf0e10cSrcweir         return mxIterSheet.get();
2849cdf0e10cSrcweir     }
2850cdf0e10cSrcweir     return 0;
2851cdf0e10cSrcweir }
2852cdf0e10cSrcweir 
2853cdf0e10cSrcweir SfxStyleSheetBase*  SwStyleSheetIterator::Find( const UniString& rName )
2854cdf0e10cSrcweir {
2855cdf0e10cSrcweir     // suchen
2856cdf0e10cSrcweir     if( !bFirstCalled )
2857cdf0e10cSrcweir         First();
2858cdf0e10cSrcweir 
2859cdf0e10cSrcweir     nLastPos = lcl_FindName( aLst, nSearchFamily, rName );
2860cdf0e10cSrcweir     if( USHRT_MAX != nLastPos )
2861cdf0e10cSrcweir     {
2862cdf0e10cSrcweir         // gefunden
2863cdf0e10cSrcweir         mxStyleSheet->PresetNameAndFamily(*aLst[nLastPos]);
2864cdf0e10cSrcweir         // neuer Name gesetzt, also bestimme seine Daten
2865cdf0e10cSrcweir         mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2866cdf0e10cSrcweir         if( !mxStyleSheet->IsPhysical() )
2867cdf0e10cSrcweir             mxStyleSheet->SetPhysical( sal_False );
2868cdf0e10cSrcweir 
2869cdf0e10cSrcweir         return mxStyleSheet.get();
2870cdf0e10cSrcweir     }
2871cdf0e10cSrcweir     return 0;
2872cdf0e10cSrcweir }
2873cdf0e10cSrcweir 
2874cdf0e10cSrcweir void SwStyleSheetIterator::AppendStyleList(const SvStringsDtor& rList,
2875cdf0e10cSrcweir                                             sal_Bool    bTestUsed,
2876cdf0e10cSrcweir                                             sal_uInt16 nSection, char cType )
2877cdf0e10cSrcweir {
2878cdf0e10cSrcweir     if( bTestUsed )
2879cdf0e10cSrcweir     {
2880cdf0e10cSrcweir         SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
2881cdf0e10cSrcweir         for ( sal_uInt16 i=0; i < rList.Count(); ++i )
2882cdf0e10cSrcweir         {
2883cdf0e10cSrcweir             sal_Bool bUsed = sal_False;
2884cdf0e10cSrcweir             sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(*rList[i], (SwGetPoolIdFromName)nSection);
2885cdf0e10cSrcweir             switch ( nSection )
2886cdf0e10cSrcweir             {
2887cdf0e10cSrcweir                 case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL:
2888cdf0e10cSrcweir                         bUsed = rDoc.IsPoolTxtCollUsed( nId );
2889cdf0e10cSrcweir                         break;
2890cdf0e10cSrcweir                 case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT:
2891cdf0e10cSrcweir                         bUsed = rDoc.IsPoolFmtUsed( nId );
2892cdf0e10cSrcweir                         break;
2893cdf0e10cSrcweir                 case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT:
2894cdf0e10cSrcweir                         bUsed = rDoc.IsPoolFmtUsed( nId );
2895cdf0e10cSrcweir                 case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC:
2896cdf0e10cSrcweir                         bUsed = rDoc.IsPoolPageDescUsed( nId );
2897cdf0e10cSrcweir                         break;
2898cdf0e10cSrcweir                 default:
2899cdf0e10cSrcweir                     ASSERT( !this, "unknown PoolFmt-Id" );
2900cdf0e10cSrcweir             }
2901cdf0e10cSrcweir             if ( bUsed )
2902cdf0e10cSrcweir                 aLst.Append( cType, *rList[i] );
2903cdf0e10cSrcweir         }
2904cdf0e10cSrcweir     }
2905cdf0e10cSrcweir     else
2906cdf0e10cSrcweir         for ( sal_uInt16 i=0; i < rList.Count(); ++i )
2907cdf0e10cSrcweir             aLst.Append( cType, *rList[i] );
2908cdf0e10cSrcweir }
2909cdf0e10cSrcweir 
2910cdf0e10cSrcweir void  SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint )
2911cdf0e10cSrcweir {
2912cdf0e10cSrcweir     // suchen und aus der Anzeige-Liste entfernen !!
2913cdf0e10cSrcweir     if( rHint.ISA( SfxStyleSheetHint ) &&
2914cdf0e10cSrcweir         SFX_STYLESHEET_ERASED == ((SfxStyleSheetHint&) rHint).GetHint() )
2915cdf0e10cSrcweir     {
2916cdf0e10cSrcweir         SfxStyleSheetBase* pStyle = ((SfxStyleSheetHint&)rHint).GetStyleSheet();
2917cdf0e10cSrcweir 
2918cdf0e10cSrcweir         if (pStyle)
2919cdf0e10cSrcweir         {
2920cdf0e10cSrcweir             sal_uInt16 nTmpPos = lcl_FindName( aLst, pStyle->GetFamily(),
2921cdf0e10cSrcweir                                            pStyle->GetName() );
2922cdf0e10cSrcweir             if( nTmpPos < aLst.Count() )
2923cdf0e10cSrcweir                 aLst.DeleteAndDestroy( nTmpPos );
2924cdf0e10cSrcweir         }
2925cdf0e10cSrcweir     }
2926cdf0e10cSrcweir }
2927cdf0e10cSrcweir 
2928cdf0e10cSrcweir 
2929