xref: /trunk/main/sw/source/core/doc/docfmt.cxx (revision 46c69c84579d1f1df536015e7d54c9965db90b69)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #define _ZFORLIST_DECLARE_TABLE
29 #define _SVSTDARR_USHORTSSORT
30 #define _SVSTDARR_USHORTS
31 #include <hintids.hxx>
32 #include <rtl/logfile.hxx>
33 #include <svl/itemiter.hxx>
34 #include <sfx2/app.hxx>
35 #include <editeng/tstpitem.hxx>
36 #include <editeng/eeitem.hxx>
37 #include <editeng/langitem.hxx>
38 #include <editeng/lrspitem.hxx>
39 #include <editeng/brkitem.hxx>
40 #include <svl/whiter.hxx>
41 #ifndef _ZFORLIST_HXX //autogen
42 #define _ZFORLIST_DECLARE_TABLE
43 #include <svl/zforlist.hxx>
44 #endif
45 #include <comphelper/processfactory.hxx>
46 #include <unotools/misccfg.hxx>
47 #include <com/sun/star/i18n/WordType.hdl>
48 #include <fmtpdsc.hxx>
49 #include <fmthdft.hxx>
50 #include <fmtcntnt.hxx>
51 #include <frmatr.hxx>
52 #include <doc.hxx>
53 #include <IDocumentUndoRedo.hxx>
54 #include <rootfrm.hxx>
55 #include <pagefrm.hxx>
56 #include <hints.hxx>            // fuer SwHyphenBug (in SetDefault)
57 #include <ndtxt.hxx>
58 #include <pam.hxx>
59 #include <UndoCore.hxx>
60 #include <UndoAttribute.hxx>
61 #include <ndgrf.hxx>
62 #include <pagedesc.hxx>         // Fuer Sonderbehandlung in InsFrmFmt
63 #include <rolbck.hxx>           // Undo-Attr
64 #include <mvsave.hxx>           // servieren: Veraenderungen erkennen
65 #include <txatbase.hxx>
66 #include <swtable.hxx>
67 #include <swtblfmt.hxx>
68 #include <charfmt.hxx>
69 #include <docary.hxx>
70 #include <paratr.hxx>
71 #include <redline.hxx>
72 #include <reffld.hxx>
73 #include <txtinet.hxx>
74 #include <fmtinfmt.hxx>
75 #include <breakit.hxx>
76 #include <SwStyleNameMapper.hxx>
77 #include <fmtautofmt.hxx>
78 #include <istyleaccess.hxx>
79 #include <SwUndoFmt.hxx>
80 #include <docsh.hxx>
81 #include <functional>
82 
83 using namespace ::com::sun::star::i18n;
84 using namespace ::com::sun::star::lang;
85 using namespace ::com::sun::star::uno;
86 
SV_IMPL_PTRARR(SwFrmFmts,SwFrmFmtPtr)87 SV_IMPL_PTRARR(SwFrmFmts,SwFrmFmtPtr)
88 SV_IMPL_PTRARR(SwCharFmts,SwCharFmtPtr)
89 
90 //Spezifische Frameformate (Rahmen)
91 SV_IMPL_PTRARR(SwSpzFrmFmts,SwFrmFmtPtr)
92 
93 /*
94  * interne Funktionen
95  */
96 
97 sal_Bool SetTxtFmtCollNext( const SwTxtFmtCollPtr& rpTxtColl, void* pArgs )
98 {
99     SwTxtFmtColl *pDel = (SwTxtFmtColl*) pArgs;
100     if ( &rpTxtColl->GetNextTxtFmtColl() == pDel )
101     {
102         rpTxtColl->SetNextTxtFmtColl( *rpTxtColl );
103     }
104     return sal_True;
105 }
106 
107 /*
108  * Zuruecksetzen der harten Formatierung fuer Text
109  */
110 
111 // Uebergabeparameter fuer _Rst und lcl_SetTxtFmtColl
112 struct ParaRstFmt
113 {
114     SwFmtColl* pFmtColl;
115     SwHistory* pHistory;
116     const SwPosition *pSttNd, *pEndNd;
117     const SfxItemSet* pDelSet;
118     sal_uInt16 nWhich;
119     bool bReset;
120     bool bResetListAttrs;
121     bool bResetAll;
122     bool bInclRefToxMark;
123 
ParaRstFmtParaRstFmt124     ParaRstFmt( const SwPosition* pStt, const SwPosition* pEnd,
125                 SwHistory* pHst, sal_uInt16 nWhch = 0, const SfxItemSet* pSet = 0 )
126         : pFmtColl(0),
127           pHistory(pHst),
128           pSttNd(pStt),
129           pEndNd(pEnd),
130           pDelSet(pSet),
131           nWhich(nWhch),
132           bReset( false ),
133           bResetListAttrs( false ),
134           bResetAll( true ),
135           bInclRefToxMark( false )
136     {
137     }
138 
ParaRstFmtParaRstFmt139     ParaRstFmt( SwHistory* pHst )
140         : pFmtColl(0),
141           pHistory(pHst),
142           pSttNd(0),
143           pEndNd(0),
144           pDelSet(0),
145           nWhich(0),
146           bReset( false ),
147           bResetListAttrs( false ),
148           bResetAll( true ),
149           bInclRefToxMark( false )
150     {
151     }
152 };
153 
154 /* in pArgs steht die ChrFmtTablle vom Dokument
155  * (wird bei Selectionen am Start/Ende und bei keiner SSelection benoetigt)
156  */
157 
lcl_RstTxtAttr(const SwNodePtr & rpNd,void * pArgs)158 sal_Bool lcl_RstTxtAttr( const SwNodePtr& rpNd, void* pArgs )
159 {
160     ParaRstFmt* pPara = (ParaRstFmt*)pArgs;
161     SwTxtNode * pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
162     if( pTxtNode && pTxtNode->GetpSwpHints() )
163     {
164         SwIndex aSt( pTxtNode, 0 );
165         sal_uInt16 nEnd = pTxtNode->Len();
166 
167         if( &pPara->pSttNd->nNode.GetNode() == pTxtNode &&
168             pPara->pSttNd->nContent.GetIndex() )
169             aSt = pPara->pSttNd->nContent.GetIndex();
170 
171         if( &pPara->pEndNd->nNode.GetNode() == rpNd )
172             nEnd = pPara->pEndNd->nContent.GetIndex();
173 
174         if( pPara->pHistory )
175         {
176             // fuers Undo alle Attribute sichern
177             SwRegHistory aRHst( *pTxtNode, pPara->pHistory );
178             pTxtNode->GetpSwpHints()->Register( &aRHst );
179             pTxtNode->RstTxtAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich,
180                                   pPara->pDelSet, pPara->bInclRefToxMark );
181             if( pTxtNode->GetpSwpHints() )
182                 pTxtNode->GetpSwpHints()->DeRegister();
183         }
184         else
185             pTxtNode->RstTxtAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich,
186                                   pPara->pDelSet, pPara->bInclRefToxMark );
187     }
188     return sal_True;
189 }
190 
lcl_RstAttr(const SwNodePtr & rpNd,void * pArgs)191 sal_Bool lcl_RstAttr( const SwNodePtr& rpNd, void* pArgs )
192 {
193     const ParaRstFmt* pPara = (ParaRstFmt*) pArgs;
194     SwCntntNode* pNode = (SwCntntNode*) rpNd->GetCntntNode();
195     if( pNode && pNode->HasSwAttrSet() )
196     {
197         const sal_Bool bLocked = pNode->IsModifyLocked();
198         pNode->LockModify();
199 
200         SwDoc* pDoc = pNode->GetDoc();
201 
202         SfxItemSet aSavedAttrsSet(
203             pDoc->GetAttrPool(),
204             RES_PAGEDESC, RES_BREAK,
205             RES_PARATR_NUMRULE, RES_PARATR_NUMRULE,
206             RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1,
207             0 );
208         const SfxItemSet* pAttrSetOfNode = pNode->GetpSwAttrSet();
209 
210         SvUShorts aClearWhichIds;
211         // restoring all paragraph list attributes
212         {
213             SfxItemSet aListAttrSet( pDoc->GetAttrPool(),
214                                      RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1,
215                                      0 );
216             aListAttrSet.Set( *pAttrSetOfNode );
217             if ( aListAttrSet.Count() )
218             {
219                 aSavedAttrsSet.Put( aListAttrSet );
220                 SfxItemIter aIter( aListAttrSet );
221                 const SfxPoolItem* pItem = aIter.GetCurItem();
222                 while( pItem )
223                 {
224                     aClearWhichIds.Insert( pItem->Which(), aClearWhichIds.Count() );
225                     pItem = aIter.NextItem();
226                 }
227             }
228         }
229 
230         const SfxPoolItem* pItem;
231         sal_uInt16 __READONLY_DATA aSavIds[3] =
232                 { RES_PAGEDESC, RES_BREAK, RES_PARATR_NUMRULE };
233         for ( sal_uInt16 n = 0; n < 3; ++n )
234         {
235             if ( SFX_ITEM_SET == pAttrSetOfNode->GetItemState( aSavIds[n], sal_False, &pItem ) )
236             {
237                 bool bSave = false;
238                 switch (aSavIds[n])
239                 {
240                 case RES_PAGEDESC:
241                     bSave = 0 != ( (SwFmtPageDesc*) pItem )->GetPageDesc();
242                     break;
243                 case RES_BREAK:
244                     bSave = SVX_BREAK_NONE != ( (SvxFmtBreakItem*) pItem )->GetBreak();
245                     break;
246                 case RES_PARATR_NUMRULE:
247                     bSave = 0 != ( (SwNumRuleItem*) pItem )->GetValue().Len();
248                     break;
249                 }
250                 if ( bSave )
251                 {
252                     aSavedAttrsSet.Put( *pItem );
253                     aClearWhichIds.Insert( aSavIds[n], aClearWhichIds.Count() );
254                 }
255             }
256         }
257 
258         // do not clear items directly from item set and only clear to be kept
259         // attributes, if no deletion item set is found.
260         const bool bKeepAttributes =
261                     !pPara || !pPara->pDelSet || pPara->pDelSet->Count() == 0;
262         if ( bKeepAttributes )
263         {
264             pNode->ResetAttr( aClearWhichIds );
265         }
266 
267         if( !bLocked )
268             pNode->UnlockModify();
269 
270         if ( pPara )
271         {
272             SwRegHistory aRegH( pNode, *pNode, pPara->pHistory );
273 
274             if ( pPara->pDelSet && pPara->pDelSet->Count() )
275             {
276                 ASSERT( !bKeepAttributes,
277                         "<lcl_RstAttr(..)> - certain attributes are kept, but not needed. -> please inform OD" );
278                 SfxItemIter aIter( *pPara->pDelSet );
279                 pItem = aIter.FirstItem();
280                 while ( sal_True )
281                 {
282                     if ( ( pItem->Which() != RES_PAGEDESC &&
283                            pItem->Which() != RES_BREAK &&
284                            pItem->Which() != RES_PARATR_NUMRULE ) ||
285                          ( aSavedAttrsSet.GetItemState( pItem->Which(), sal_False ) != SFX_ITEM_SET ) )
286                     {
287                         pNode->ResetAttr( pItem->Which() );
288                     }
289                     if ( aIter.IsAtEnd() )
290                         break;
291                     pItem = aIter.NextItem();
292                 }
293             }
294             else if ( pPara->bResetAll )
295                 pNode->ResetAllAttr();
296             else
297                 pNode->ResetAttr( RES_PARATR_BEGIN, POOLATTR_END - 1 );
298         }
299         else
300             pNode->ResetAllAttr();
301 
302         // only restore saved attributes, if needed
303         if ( bKeepAttributes && aSavedAttrsSet.Count() )
304         {
305             pNode->LockModify();
306 
307             pNode->SetAttr( aSavedAttrsSet );
308 
309             if ( !bLocked )
310                 pNode->UnlockModify();
311         }
312     }
313     return sal_True;
314 }
315 
316 
RstTxtAttrs(const SwPaM & rRg,sal_Bool bInclRefToxMark)317 void SwDoc::RstTxtAttrs(const SwPaM &rRg, sal_Bool bInclRefToxMark )
318 {
319     SwHistory* pHst = 0;
320     SwDataChanged aTmp( rRg, 0 );
321     if (GetIDocumentUndoRedo().DoesUndo())
322     {
323         SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg, RES_CHRFMT );
324         pHst = &pUndo->GetHistory();
325         GetIDocumentUndoRedo().AppendUndo(pUndo);
326     }
327     const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
328     ParaRstFmt aPara( pStt, pEnd, pHst );
329     aPara.bInclRefToxMark = ( bInclRefToxMark == sal_True );
330     GetNodes().ForEach( pStt->nNode.GetIndex(), pEnd->nNode.GetIndex()+1,
331                         lcl_RstTxtAttr, &aPara );
332     SetModified();
333 }
334 
ResetAttrs(const SwPaM & rRg,sal_Bool bTxtAttr,const SvUShortsSort * pAttrs,const bool bSendDataChangedEvents)335 void SwDoc::ResetAttrs( const SwPaM &rRg,
336                         sal_Bool bTxtAttr,
337                         const SvUShortsSort* pAttrs,
338                         // --> OD 2008-11-28 #b96644#
339                         const bool bSendDataChangedEvents )
340                         // <--
341 {
342     SwPaM* pPam = (SwPaM*)&rRg;
343     if( !bTxtAttr && pAttrs && pAttrs->Count() &&
344         RES_TXTATR_END > (*pAttrs)[ 0 ] )
345         bTxtAttr = sal_True;
346 
347     if( !rRg.HasMark() )
348     {
349         SwTxtNode* pTxtNd = rRg.GetPoint()->nNode.GetNode().GetTxtNode();
350         if( !pTxtNd )
351             return ;
352 
353         pPam = new SwPaM( *rRg.GetPoint() );
354 
355         SwIndex& rSt = pPam->GetPoint()->nContent;
356         sal_uInt16 nMkPos, nPtPos = rSt.GetIndex();
357 
358         // JP 22.08.96: Sonderfall: steht der Crsr in einem URL-Attribut
359         //              dann wird dessen Bereich genommen
360         SwTxtAttr const*const pURLAttr(
361             pTxtNd->GetTxtAttrAt(rSt.GetIndex(), RES_TXTATR_INETFMT));
362         if (pURLAttr && pURLAttr->GetINetFmt().GetValue().Len())
363         {
364             nMkPos = *pURLAttr->GetStart();
365             nPtPos = *pURLAttr->End();
366         }
367         else
368         {
369             Boundary aBndry;
370             if( pBreakIt->GetBreakIter().is() )
371                 aBndry = pBreakIt->GetBreakIter()->getWordBoundary(
372                             pTxtNd->GetTxt(), nPtPos,
373                             pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
374                             WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
375                             sal_True );
376 
377             if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
378             {
379                 nMkPos = (xub_StrLen)aBndry.startPos;
380                 nPtPos = (xub_StrLen)aBndry.endPos;
381             }
382             else
383             {
384                 nPtPos = nMkPos = rSt.GetIndex();
385                 if( bTxtAttr )
386                     pTxtNd->DontExpandFmt( rSt, sal_True );
387             }
388         }
389 
390         rSt = nMkPos;
391         pPam->SetMark();
392         pPam->GetPoint()->nContent = nPtPos;
393     }
394 
395     // --> OD 2008-11-28 #i96644#
396 //    SwDataChanged aTmp( *pPam, 0 );
397     std::unique_ptr< SwDataChanged > pDataChanged;
398     if ( bSendDataChangedEvents )
399     {
400         pDataChanged.reset( new SwDataChanged( *pPam, 0 ) );
401     }
402     // <--
403     SwHistory* pHst = 0;
404     if (GetIDocumentUndoRedo().DoesUndo())
405     {
406         SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg,
407             static_cast<sal_uInt16>(bTxtAttr ? RES_CONDTXTFMTCOLL : RES_TXTFMTCOLL ));
408         if( pAttrs && pAttrs->Count() )
409         {
410             pUndo->SetAttrs( *pAttrs );
411         }
412         pHst = &pUndo->GetHistory();
413         GetIDocumentUndoRedo().AppendUndo(pUndo);
414     }
415 
416     const SwPosition *pStt = pPam->Start(), *pEnd = pPam->End();
417     ParaRstFmt aPara( pStt, pEnd, pHst );
418 
419     // mst: not including META here; it seems attrs with CH_TXTATR are omitted
420     sal_uInt16 __FAR_DATA aResetableSetRange[] = {
421         RES_FRMATR_BEGIN, RES_FRMATR_END-1,
422         RES_CHRATR_BEGIN, RES_CHRATR_END-1,
423         RES_PARATR_BEGIN, RES_PARATR_END-1,
424         // --> OD 2008-02-25 #refactorlists#
425         RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
426         // <--
427         RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
428         RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT,
429         RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
430         RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
431         RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
432         0
433     };
434 
435     SfxItemSet aDelSet( GetAttrPool(), aResetableSetRange );
436     if( pAttrs && pAttrs->Count() )
437     {
438         for( sal_uInt16 n = pAttrs->Count(); n; )
439             if( POOLATTR_END > (*pAttrs)[ --n ] )
440                 aDelSet.Put( *GetDfltAttr( (*pAttrs)[ n ] ));
441 
442         if( aDelSet.Count() )
443             aPara.pDelSet = &aDelSet;
444     }
445 
446     sal_Bool bAdd = sal_True;
447     SwNodeIndex aTmpStt( pStt->nNode );
448     SwNodeIndex aTmpEnd( pEnd->nNode );
449     if( pStt->nContent.GetIndex() )     // nur ein Teil
450     {
451         // dann spaeter aufsetzen und alle CharFmtAttr -> TxtFmtAttr
452         SwTxtNode* pTNd = aTmpStt.GetNode().GetTxtNode();
453         if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() )
454         {
455             if (pHst)
456             {
457                 SwRegHistory history(pTNd, *pTNd, pHst);
458                 pTNd->FmtToTxtAttr(pTNd);
459             }
460             else
461             {
462                 pTNd->FmtToTxtAttr(pTNd);
463             }
464         }
465 
466         aTmpStt++;
467     }
468     if( pEnd->nContent.GetIndex() == pEnd->nNode.GetNode().GetCntntNode()->Len() )
469         // dann spaeter aufsetzen und alle CharFmtAttr -> TxtFmtAttr
470         aTmpEnd++, bAdd = sal_False;
471     else if( pStt->nNode != pEnd->nNode || !pStt->nContent.GetIndex() )
472     {
473         SwTxtNode* pTNd = aTmpEnd.GetNode().GetTxtNode();
474         if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() )
475         {
476             if (pHst)
477             {
478                 SwRegHistory history(pTNd, *pTNd, pHst);
479                 pTNd->FmtToTxtAttr(pTNd);
480             }
481             else
482             {
483                 pTNd->FmtToTxtAttr(pTNd);
484             }
485         }
486     }
487 
488     if( aTmpStt < aTmpEnd )
489         GetNodes().ForEach( pStt->nNode, aTmpEnd, lcl_RstAttr, &aPara );
490     else if( !rRg.HasMark() )
491     {
492         aPara.bResetAll = false ;
493         ::lcl_RstAttr( &pStt->nNode.GetNode(), &aPara );
494         aPara.bResetAll = true ;
495     }
496 
497     if( bTxtAttr )
498     {
499         if( bAdd )
500             aTmpEnd++;
501         GetNodes().ForEach( pStt->nNode, aTmpEnd, lcl_RstTxtAttr, &aPara );
502     }
503 
504     if( pPam != &rRg )
505         delete pPam;
506 
507     SetModified();
508 }
509 
510 #define DELETECHARSETS if ( bDelete ) { delete pCharSet; delete pOtherSet; }
511 
512 // Einfuegen der Hints nach Inhaltsformen;
513 // wird in SwDoc::Insert(..., SwFmtHint &rHt) benutzt
514 
lcl_InsAttr(SwDoc * const pDoc,const SwPaM & rRg,const SfxItemSet & rChgSet,const SetAttrMode nFlags,SwUndoAttr * const pUndo,const bool bExpandCharToPara=false)515 static bool lcl_InsAttr(
516     SwDoc *const pDoc,
517     const SwPaM &rRg,
518     const SfxItemSet& rChgSet,
519     const SetAttrMode nFlags,
520     SwUndoAttr *const pUndo,
521     //Modify here for #119405, by easyfan, 2012-05-24
522     const bool bExpandCharToPara=false)
523     //End of modification, by easyfan
524 {
525     // teil die Sets auf (fuer Selektion in Nodes)
526     const SfxItemSet* pCharSet = 0;
527     const SfxItemSet* pOtherSet = 0;
528     bool bDelete = false;
529     bool bCharAttr = false;
530     bool bOtherAttr = false;
531 
532     // Check, if we can work with rChgSet or if we have to create additional SfxItemSets
533     if ( 1 == rChgSet.Count() )
534     {
535         SfxItemIter aIter( rChgSet );
536         const SfxPoolItem* pItem = aIter.FirstItem();
537 
538         if (!IsInvalidItem(pItem))
539         {
540             const sal_uInt16 nWhich = pItem->Which();
541 
542             if ( isCHRATR(nWhich) ||
543                  (RES_TXTATR_CHARFMT == nWhich) ||
544                  (RES_TXTATR_INETFMT == nWhich) ||
545                  (RES_TXTATR_AUTOFMT == nWhich) ||
546                  (RES_TXTATR_UNKNOWN_CONTAINER == nWhich) )
547             {
548                 pCharSet  = &rChgSet;
549                 bCharAttr = true;
550             }
551 
552             if (    isPARATR(nWhich)
553                     || isPARATR_LIST(nWhich)
554                     || isFRMATR(nWhich)
555                     || isGRFATR(nWhich)
556                     || isUNKNOWNATR(nWhich)
557                     || isDrawingLayerAttribute(nWhich) ) //UUUU
558             {
559                 pOtherSet = &rChgSet;
560                 bOtherAttr = true;
561             }
562         }
563     }
564 
565     // Build new itemset if either
566     // - rChgSet.Count() > 1 or
567     // - The attribute in rChgSet does not belong to one of the above categories
568     if ( !bCharAttr && !bOtherAttr )
569     {
570         SfxItemSet* pTmpCharItemSet = new SfxItemSet( pDoc->GetAttrPool(),
571                                    RES_CHRATR_BEGIN, RES_CHRATR_END-1,
572                                    RES_TXTATR_AUTOFMT, RES_TXTATR_AUTOFMT,
573                                    RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
574                                    RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT,
575                RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
576                                    0 );
577 
578         SfxItemSet* pTmpOtherItemSet = new SfxItemSet( pDoc->GetAttrPool(),
579                                     RES_PARATR_BEGIN, RES_PARATR_END-1,
580                                     RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
581                                     RES_FRMATR_BEGIN, RES_FRMATR_END-1,
582                                     RES_GRFATR_BEGIN, RES_GRFATR_END-1,
583                                     RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
584 
585                                     //UUUU FillAttribute support
586                                     XATTR_FILL_FIRST, XATTR_FILL_LAST,
587 
588                                     0 );
589 
590         pTmpCharItemSet->Put( rChgSet );
591         pTmpOtherItemSet->Put( rChgSet );
592 
593         pCharSet = pTmpCharItemSet;
594         pOtherSet = pTmpOtherItemSet;
595 
596         bDelete = true;
597     }
598 
599     SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0;
600     bool bRet = false;
601     const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
602     SwCntntNode* pNode = pStt->nNode.GetNode().GetCntntNode();
603 
604     if( pNode && pNode->IsTxtNode() )
605     {
606         // -> #i27615#
607         if (rRg.IsInFrontOfLabel())
608         {
609             SwTxtNode * pTxtNd = pNode->GetTxtNode();
610             SwNumRule * pNumRule = pTxtNd->GetNumRule();
611 
612             if ( !pNumRule )
613             {
614                 ASSERT( false,
615                         "<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect, please inform OD." );
616                 DELETECHARSETS
617                 return false;
618             }
619 
620             SwNumFmt aNumFmt = pNumRule->Get(static_cast<sal_uInt16>(pTxtNd->GetActualListLevel()));
621             SwCharFmt * pCharFmt =
622                 pDoc->FindCharFmtByName(aNumFmt.GetCharFmtName());
623 
624             if (pCharFmt)
625             {
626                 if (pHistory)
627                     pHistory->Add(pCharFmt->GetAttrSet(), *pCharFmt);
628 
629                 if ( pCharSet )
630                     pCharFmt->SetFmtAttr(*pCharSet);
631             }
632 
633             DELETECHARSETS
634             return true;
635         }
636 
637         const SwIndex& rSt = pStt->nContent;
638 
639         // Attribute ohne Ende haben keinen Bereich
640         if ( !bCharAttr && !bOtherAttr )
641         {
642             SfxItemSet aTxtSet( pDoc->GetAttrPool(),
643                         RES_TXTATR_NOEND_BEGIN, RES_TXTATR_NOEND_END-1 );
644             aTxtSet.Put( rChgSet );
645             if( aTxtSet.Count() )
646             {
647                 SwRegHistory history( pNode, *pNode, pHistory );
648                 bRet = history.InsertItems(
649                     aTxtSet, rSt.GetIndex(), rSt.GetIndex(), nFlags ) || bRet;
650 
651                 if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
652                                 && pDoc->GetRedlineTbl().Count())))
653                 {
654                     SwPaM aPam( pStt->nNode, pStt->nContent.GetIndex()-1,
655                                 pStt->nNode, pStt->nContent.GetIndex() );
656 
657                     if( pUndo )
658                         pUndo->SaveRedlineData( aPam, sal_True );
659 
660                     if( pDoc->IsRedlineOn() )
661                         pDoc->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
662                     else
663                         pDoc->SplitRedline( aPam );
664                 }
665             }
666         }
667 
668         // TextAttribute mit Ende expandieren nie ihren Bereich
669         if ( !bCharAttr && !bOtherAttr )
670         {
671             // CharFmt wird gesondert behandelt !!!
672             // JP 22.08.96: URL-Attribute auch!!
673             // TEST_TEMP ToDo: AutoFmt!
674             SfxItemSet aTxtSet( pDoc->GetAttrPool(),
675                                 RES_TXTATR_REFMARK, RES_TXTATR_TOXMARK,
676                                 RES_TXTATR_META, RES_TXTATR_METAFIELD,
677                                 RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
678                                 RES_TXTATR_INPUTFIELD, RES_TXTATR_INPUTFIELD,
679                                 0 );
680 
681             aTxtSet.Put( rChgSet );
682             if( aTxtSet.Count() )
683             {
684                 sal_uInt16 nInsCnt = rSt.GetIndex();
685                 sal_uInt16 nEnd = pStt->nNode == pEnd->nNode
686                                 ? pEnd->nContent.GetIndex()
687                                 : pNode->Len();
688                 SwRegHistory history( pNode, *pNode, pHistory );
689                 bRet = history.InsertItems( aTxtSet, nInsCnt, nEnd, nFlags )
690                        || bRet;
691 
692                 if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
693                                 && pDoc->GetRedlineTbl().Count())))
694                 {
695                     // wurde Text-Inhalt eingefuegt? (RefMark/TOXMarks ohne Ende)
696                     sal_Bool bTxtIns = nInsCnt != rSt.GetIndex();
697                     // wurde Inhalt eingefuegt oder ueber die Selektion gesetzt?
698                     SwPaM aPam( pStt->nNode, bTxtIns ? nInsCnt + 1 : nEnd,
699                                 pStt->nNode, nInsCnt );
700                     if( pUndo )
701                         pUndo->SaveRedlineData( aPam, bTxtIns );
702 
703                     if( pDoc->IsRedlineOn() )
704                         pDoc->AppendRedline(
705                             new SwRedline(
706                                 bTxtIns ? nsRedlineType_t::REDLINE_INSERT : nsRedlineType_t::REDLINE_FORMAT, aPam ),
707                                 true);
708                     else if( bTxtIns )
709                         pDoc->SplitRedline( aPam );
710                 }
711             }
712         }
713     }
714 
715     // bei PageDesc's, die am Node gesetzt werden, muss immer das
716     // Auto-Flag gesetzt werden!!
717     if( pOtherSet && pOtherSet->Count() )
718     {
719         SwTableNode* pTblNd;
720         const SwFmtPageDesc* pDesc;
721         if( SFX_ITEM_SET == pOtherSet->GetItemState( RES_PAGEDESC,
722                         sal_False, (const SfxPoolItem**)&pDesc ))
723         {
724             if( pNode )
725             {
726                 // Auto-Flag setzen, nur in Vorlagen ist ohne Auto !
727                 SwFmtPageDesc aNew( *pDesc );
728                 // Bug 38479: AutoFlag wird jetzt in der WrtShell gesetzt
729                 // aNew.SetAuto();
730 
731                 // Tabellen kennen jetzt auch Umbrueche
732                 if( 0 == (nFlags & nsSetAttrMode::SETATTR_APICALL) &&
733                     0 != ( pTblNd = pNode->FindTableNode() ) )
734                 {
735                     SwTableNode* pCurTblNd = pTblNd;
736                     while ( 0 != ( pCurTblNd = pCurTblNd->StartOfSectionNode()->FindTableNode() ) )
737                         pTblNd = pCurTblNd;
738 
739                     // dann am Tabellen Format setzen
740                     SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt();
741                     SwRegHistory aRegH( pFmt, *pTblNd, pHistory );
742                     pFmt->SetFmtAttr( aNew );
743                     bRet = true;
744                 }
745                 else
746                 {
747                     SwRegHistory aRegH( pNode, *pNode, pHistory );
748                     bRet = pNode->SetAttr( aNew ) || bRet;
749                 }
750             }
751 
752             // bOtherAttr = true means that pOtherSet == rChgSet. In this case
753             // we know, that there is only one attribute in pOtherSet. We cannot
754             // perform the following operations, instead we return:
755             if ( bOtherAttr )
756                 return bRet;
757 
758             const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_PAGEDESC );
759             if( !pOtherSet->Count() )
760             {
761                 DELETECHARSETS
762                 return bRet;
763             }
764         }
765 
766         // Tabellen kennen jetzt auch Umbrueche
767         const SvxFmtBreakItem* pBreak;
768         if( pNode && 0 == (nFlags & nsSetAttrMode::SETATTR_APICALL) &&
769             0 != (pTblNd = pNode->FindTableNode() ) &&
770             SFX_ITEM_SET == pOtherSet->GetItemState( RES_BREAK,
771                         sal_False, (const SfxPoolItem**)&pBreak ) )
772         {
773             SwTableNode* pCurTblNd = pTblNd;
774             while ( 0 != ( pCurTblNd = pCurTblNd->StartOfSectionNode()->FindTableNode() ) )
775                 pTblNd = pCurTblNd;
776 
777             // dann am Tabellen Format setzen
778             SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt();
779             SwRegHistory aRegH( pFmt, *pTblNd, pHistory );
780             pFmt->SetFmtAttr( *pBreak );
781             bRet = true;
782 
783             // bOtherAttr = true means that pOtherSet == rChgSet. In this case
784             // we know, that there is only one attribute in pOtherSet. We cannot
785             // perform the following operations, instead we return:
786             if ( bOtherAttr )
787                 return bRet;
788 
789             const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_BREAK );
790             if( !pOtherSet->Count() )
791             {
792                 DELETECHARSETS
793                 return bRet;
794             }
795         }
796 
797         {
798             // wenns eine PoolNumRule ist, diese ggfs. anlegen
799             const SwNumRuleItem* pRule;
800             sal_uInt16 nPoolId;
801             if( SFX_ITEM_SET == pOtherSet->GetItemState( RES_PARATR_NUMRULE,
802                                 sal_False, (const SfxPoolItem**)&pRule ) &&
803                 !pDoc->FindNumRulePtr( pRule->GetValue() ) &&
804                 USHRT_MAX != (nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( pRule->GetValue(),
805                                 nsSwGetPoolIdFromName::GET_POOLID_NUMRULE )) )
806                 pDoc->GetNumRuleFromPool( nPoolId );
807         }
808 
809     }
810 
811     if( !rRg.HasMark() )        // kein Bereich
812     {
813         if( !pNode )
814         {
815             DELETECHARSETS
816             return bRet;
817         }
818 
819         if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
820         {
821             SwTxtNode* pTxtNd = static_cast<SwTxtNode*>(pNode);
822             const SwIndex& rSt = pStt->nContent;
823             sal_uInt16 nMkPos, nPtPos = rSt.GetIndex();
824             const String& rStr = pTxtNd->GetTxt();
825 
826             // JP 22.08.96: Sonderfall: steht der Crsr in einem URL-Attribut
827             //              dann wird dessen Bereich genommen
828             SwTxtAttr const*const pURLAttr(
829                 pTxtNd->GetTxtAttrAt(rSt.GetIndex(), RES_TXTATR_INETFMT));
830             if (pURLAttr && pURLAttr->GetINetFmt().GetValue().Len())
831             {
832                 nMkPos = *pURLAttr->GetStart();
833                 nPtPos = *pURLAttr->End();
834             }
835             else
836             {
837                 Boundary aBndry;
838                 if( pBreakIt->GetBreakIter().is() )
839                     aBndry = pBreakIt->GetBreakIter()->getWordBoundary(
840                                 pTxtNd->GetTxt(), nPtPos,
841                                 pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
842                                 WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
843                                 sal_True );
844 
845                 if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
846                 {
847                     nMkPos = (xub_StrLen)aBndry.startPos;
848                     nPtPos = (xub_StrLen)aBndry.endPos;
849                 }
850                 else
851                     nPtPos = nMkPos = rSt.GetIndex();
852             }
853 
854             // erstmal die zu ueberschreibenden Attribute aus dem
855             // SwpHintsArray entfernen, wenn die Selektion den gesamten
856             // Absatz umspannt. (Diese Attribute werden als FormatAttr.
857             // eingefuegt und verdraengen nie die TextAttr.!)
858             if( !(nFlags & nsSetAttrMode::SETATTR_DONTREPLACE ) &&
859                 pTxtNd->HasHints() && !nMkPos && nPtPos == rStr.Len() )
860             {
861                 SwIndex aSt( pTxtNd );
862                 if( pHistory )
863                 {
864                     // fuers Undo alle Attribute sichern
865                     SwRegHistory aRHst( *pTxtNd, pHistory );
866                     pTxtNd->GetpSwpHints()->Register( &aRHst );
867                     pTxtNd->RstTxtAttr( aSt, nPtPos, 0, pCharSet );
868                     if( pTxtNd->GetpSwpHints() )
869                         pTxtNd->GetpSwpHints()->DeRegister();
870                 }
871                 else
872                     pTxtNd->RstTxtAttr( aSt, nPtPos, 0, pCharSet );
873             }
874 
875             // the SwRegHistory inserts the attribute into the TxtNode!
876             SwRegHistory history( pNode, *pNode, pHistory );
877             bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags )
878                 || bRet;
879 
880             if( pDoc->IsRedlineOn() )
881             {
882                 SwPaM aPam( *pNode, nMkPos, *pNode, nPtPos );
883 
884                 if( pUndo )
885                     pUndo->SaveRedlineData( aPam, sal_False );
886                 pDoc->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_FORMAT, aPam ), true);
887             }
888         }
889         if( pOtherSet && pOtherSet->Count() )
890         {
891             SwRegHistory aRegH( pNode, *pNode, pHistory );
892 
893             //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
894             // and evtl. correct that item to ensure unique names for that type. This call may
895             // modify/correct entries inside of the given SfxItemSet
896             SfxItemSet aTempLocalCopy(*pOtherSet);
897 
898             pDoc->CheckForUniqueItemForLineFillNameOrIndex(aTempLocalCopy);
899             bRet = pNode->SetAttr(aTempLocalCopy) || bRet;
900         }
901 
902         DELETECHARSETS
903         return bRet;
904     }
905 
906     if( pDoc->IsRedlineOn() && pCharSet && pCharSet->Count() )
907     {
908         if( pUndo )
909             pUndo->SaveRedlineData( rRg, sal_False );
910         pDoc->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_FORMAT, rRg ), true);
911     }
912 
913     /* jetzt wenn Bereich */
914     sal_uLong nNodes = 0;
915 
916     SwNodeIndex aSt( pDoc->GetNodes() );
917     SwNodeIndex aEnd( pDoc->GetNodes() );
918     SwIndex aCntEnd( pEnd->nContent );
919 
920     if( pNode )
921     {
922         sal_uInt16 nLen = pNode->Len();
923         if( pStt->nNode != pEnd->nNode )
924             aCntEnd.Assign( pNode, nLen );
925 
926         if( pStt->nContent.GetIndex() != 0 || aCntEnd.GetIndex() != nLen )
927         {
928             // the SwRegHistory inserts the attribute into the TxtNode!
929             if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
930             {
931                 SwRegHistory history( pNode, *pNode, pHistory );
932                 bRet = history.InsertItems(*pCharSet,
933                         pStt->nContent.GetIndex(), aCntEnd.GetIndex(), nFlags)
934                     || bRet;
935             }
936 
937             if( pOtherSet && pOtherSet->Count() )
938             {
939                 SwRegHistory aRegH( pNode, *pNode, pHistory );
940                 bRet = pNode->SetAttr( *pOtherSet ) || bRet;
941             }
942 
943             // lediglich Selektion in einem Node.
944             if( pStt->nNode == pEnd->nNode )
945             {
946             //Modify here for #119405, by easyfan, 2012-05-24
947             //The data parameter flag: bExpandCharToPara, comes from the data member of SwDoc,
948             //Which is set in SW MS word Binary filter WW8ImplRreader. With this flag on, means that
949             //current setting attribute set is a character range properties set and comes from a MS word
950             //binary file, And the setting range include a paragraph end position (0X0D);
951             //More specifications, as such property inside the character range properties set recorded in
952             //MS word binary file are dealed and inserted into data model (SwDoc) one by one, so we
953             //only dealing the scenario that the char properties set with 1 item inside;
954 
955                     if (bExpandCharToPara && pCharSet && pCharSet->Count() ==1 )
956             {
957                 SwTxtNode* pCurrentNd = pStt->nNode.GetNode().GetTxtNode();
958 
959                 if (pCurrentNd)
960                 {
961                     pCurrentNd->TryCharSetExpandToNum(*pCharSet);
962 
963                 }
964             }
965             //End of modification, by easyfan
966                 DELETECHARSETS
967                 return bRet;
968             }
969             ++nNodes;
970             aSt.Assign( pStt->nNode.GetNode(), +1 );
971         }
972         else
973             aSt = pStt->nNode;
974         aCntEnd = pEnd->nContent; // aEnd wurde veraendert !!
975     }
976     else
977         aSt.Assign( pStt->nNode.GetNode(), +1 );
978 
979     // aSt zeigt jetzt auf den ersten vollen Node
980 
981     /*
982      * die Selektion umfasst mehr als einen Node
983      */
984     if( pStt->nNode < pEnd->nNode )
985     {
986         pNode = pEnd->nNode.GetNode().GetCntntNode();
987         if(pNode)
988         {
989             sal_uInt16 nLen = pNode->Len();
990             if( aCntEnd.GetIndex() != nLen )
991             {
992                 // the SwRegHistory inserts the attribute into the TxtNode!
993                 if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
994                 {
995                     SwRegHistory history( pNode, *pNode, pHistory );
996                     history.InsertItems(*pCharSet,
997                             0, aCntEnd.GetIndex(), nFlags);
998                 }
999 
1000                 if( pOtherSet && pOtherSet->Count() )
1001                 {
1002                     SwRegHistory aRegH( pNode, *pNode, pHistory );
1003                     pNode->SetAttr( *pOtherSet );
1004                 }
1005 
1006                 ++nNodes;
1007                 aEnd = pEnd->nNode;
1008             }
1009             else
1010                 aEnd.Assign( pEnd->nNode.GetNode(), +1 );
1011         }
1012         else
1013             aEnd = pEnd->nNode;
1014     }
1015     else
1016         aEnd.Assign( pEnd->nNode.GetNode(), +1 );
1017 
1018     // aEnd zeigt jetzt HINTER den letzten voll Node
1019 
1020     /* Bearbeitung der vollstaendig selektierten Nodes. */
1021 // alle Attribute aus dem Set zuruecksetzen !!
1022     if( pCharSet && pCharSet->Count() && !( nsSetAttrMode::SETATTR_DONTREPLACE & nFlags ) )
1023     {
1024 
1025         ParaRstFmt aPara( pStt, pEnd, pHistory, 0, pCharSet );
1026         pDoc->GetNodes().ForEach( aSt, aEnd, lcl_RstTxtAttr, &aPara );
1027     }
1028 
1029     sal_Bool bCreateSwpHints = pCharSet && (
1030         SFX_ITEM_SET == pCharSet->GetItemState( RES_TXTATR_CHARFMT, sal_False ) ||
1031         SFX_ITEM_SET == pCharSet->GetItemState( RES_TXTATR_INETFMT, sal_False ) );
1032 
1033     for(; aSt < aEnd; aSt++ )
1034     {
1035         pNode = aSt.GetNode().GetCntntNode();
1036         if( !pNode )
1037             continue;
1038 
1039         SwTxtNode* pTNd = pNode->GetTxtNode();
1040         if( pHistory )
1041         {
1042             SwRegHistory aRegH( pNode, *pNode, pHistory );
1043             SwpHints *pSwpHints;
1044 
1045             if( pTNd && pCharSet && pCharSet->Count() )
1046             {
1047                 pSwpHints = bCreateSwpHints ? &pTNd->GetOrCreateSwpHints()
1048                                             : pTNd->GetpSwpHints();
1049                 if( pSwpHints )
1050                     pSwpHints->Register( &aRegH );
1051 
1052                 pTNd->SetAttr( *pCharSet, 0, pTNd->GetTxt().Len(), nFlags );
1053                 if( pSwpHints )
1054                     pSwpHints->DeRegister();
1055             }
1056             if( pOtherSet && pOtherSet->Count() )
1057                 pNode->SetAttr( *pOtherSet );
1058         }
1059         else
1060         {
1061             if( pTNd && pCharSet && pCharSet->Count() )
1062                 pTNd->SetAttr( *pCharSet, 0, pTNd->GetTxt().Len(), nFlags );
1063             if( pOtherSet && pOtherSet->Count() )
1064                 pNode->SetAttr( *pOtherSet );
1065         }
1066         ++nNodes;
1067     }
1068 
1069     //The data parameter flag: bExpandCharToPara, comes from the data member of SwDoc,
1070     //Which is set in SW MS word Binary filter WW8ImplRreader. With this flag on, means that
1071     //current setting attribute set is a character range properties set and comes from a MS word
1072     //binary file, And the setting range include a paragraph end position (0X0D);
1073     //More specifications, as such property inside the character range properties set recorded in
1074     //MS word binary file are dealed and inserted into data model (SwDoc) one by one, so we
1075     //only dealing the scenario that the char properties set with 1 item inside;
1076     if (bExpandCharToPara && pCharSet && pCharSet->Count() ==1)
1077     {
1078         SwPosition aStartPos (*rRg.Start());
1079         SwPosition aEndPos (*rRg.End());
1080 
1081         if (aEndPos.nNode.GetNode().GetTxtNode() && aEndPos.nContent != aEndPos.nNode.GetNode().GetTxtNode()->Len())
1082             aEndPos.nNode--;
1083 
1084         for (;aStartPos<=aEndPos;aStartPos.nNode++)
1085         {
1086             SwTxtNode* pCurrentNd = aStartPos.nNode.GetNode().GetTxtNode();
1087 
1088             if (pCurrentNd)
1089             {
1090                 pCurrentNd->TryCharSetExpandToNum(*pCharSet);
1091 
1092             }
1093 
1094         }
1095     }
1096 
1097     DELETECHARSETS
1098     return (nNodes != 0) || bRet;
1099 }
1100 
InsertPoolItem(const SwPaM & rRg,const SfxPoolItem & rHt,const SetAttrMode nFlags,const bool bExpandCharToPara)1101 bool SwDoc::InsertPoolItem(
1102     const SwPaM &rRg,
1103     const SfxPoolItem &rHt,
1104     const SetAttrMode nFlags,
1105     const bool bExpandCharToPara)
1106 {
1107     SwDataChanged aTmp( rRg, 0 );
1108     SwUndoAttr* pUndoAttr = 0;
1109     if (GetIDocumentUndoRedo().DoesUndo())
1110     {
1111         GetIDocumentUndoRedo().ClearRedo();
1112         pUndoAttr = new SwUndoAttr( rRg, rHt, nFlags );
1113     }
1114 
1115     SfxItemSet aSet( GetAttrPool(), rHt.Which(), rHt.Which() );
1116     aSet.Put( rHt );
1117     const bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr,bExpandCharToPara );
1118 
1119     if (GetIDocumentUndoRedo().DoesUndo())
1120     {
1121         GetIDocumentUndoRedo().AppendUndo( pUndoAttr );
1122     }
1123 
1124     if( bRet )
1125     {
1126         SetModified();
1127     }
1128     return bRet;
1129 }
1130 
InsertItemSet(const SwPaM & rRg,const SfxItemSet & rSet,const SetAttrMode nFlags)1131 bool SwDoc::InsertItemSet ( const SwPaM &rRg, const SfxItemSet &rSet,
1132                             const SetAttrMode nFlags )
1133 {
1134     SwDataChanged aTmp( rRg, 0 );
1135     SwUndoAttr* pUndoAttr = 0;
1136     if (GetIDocumentUndoRedo().DoesUndo())
1137     {
1138         GetIDocumentUndoRedo().ClearRedo();
1139         pUndoAttr = new SwUndoAttr( rRg, rSet, nFlags );
1140     }
1141 
1142     bool bRet = lcl_InsAttr( this, rRg, rSet, nFlags, pUndoAttr );
1143 
1144     if (GetIDocumentUndoRedo().DoesUndo())
1145     {
1146         GetIDocumentUndoRedo().AppendUndo( pUndoAttr );
1147     }
1148 
1149     if( bRet )
1150         SetModified();
1151     return bRet;
1152 }
1153 
1154 
1155     // Setze das Attribut im angegebenen Format. Ist Undo aktiv, wird
1156     // das alte in die Undo-History aufgenommen
SetAttr(const SfxPoolItem & rAttr,SwFmt & rFmt)1157 void SwDoc::SetAttr( const SfxPoolItem& rAttr, SwFmt& rFmt )
1158 {
1159     SfxItemSet aSet( GetAttrPool(), rAttr.Which(), rAttr.Which() );
1160     aSet.Put( rAttr );
1161     SetAttr( aSet, rFmt );
1162 }
1163 
1164 
1165     // Setze das Attribut im angegebenen Format. Ist Undo aktiv, wird
1166     // das alte in die Undo-History aufgenommen
SetAttr(const SfxItemSet & rSet,SwFmt & rFmt)1167 void SwDoc::SetAttr( const SfxItemSet& rSet, SwFmt& rFmt )
1168 {
1169     if (GetIDocumentUndoRedo().DoesUndo())
1170     {
1171         SwUndoFmtAttrHelper aTmp( rFmt );
1172         rFmt.SetFmtAttr( rSet );
1173         if ( aTmp.GetUndo() )
1174         {
1175             GetIDocumentUndoRedo().AppendUndo( aTmp.ReleaseUndo() );
1176         }
1177         else
1178         {
1179             GetIDocumentUndoRedo().ClearRedo();
1180         }
1181     }
1182     else
1183     {
1184         rFmt.SetFmtAttr( rSet );
1185     }
1186     SetModified();
1187 }
1188 
1189 // --> OD 2008-02-12 #newlistlevelattrs#
ResetAttrAtFormat(const sal_uInt16 nWhichId,SwFmt & rChangedFormat)1190 void SwDoc::ResetAttrAtFormat( const sal_uInt16 nWhichId,
1191                                SwFmt& rChangedFormat )
1192 {
1193     SwUndo *const pUndo = (GetIDocumentUndoRedo().DoesUndo())
1194         ?   new SwUndoFmtResetAttr( rChangedFormat, nWhichId )
1195         :   0;
1196 
1197     const sal_Bool bAttrReset = rChangedFormat.ResetFmtAttr( nWhichId );
1198 
1199     if ( bAttrReset )
1200     {
1201         if ( pUndo )
1202         {
1203             GetIDocumentUndoRedo().AppendUndo( pUndo );
1204         }
1205 
1206         SetModified();
1207     }
1208     else if ( pUndo )
1209         delete pUndo;
1210 }
1211 // <--
1212 
lcl_SetNewDefTabStops(SwTwips nOldWidth,SwTwips nNewWidth,SvxTabStopItem & rChgTabStop)1213 int lcl_SetNewDefTabStops( SwTwips nOldWidth, SwTwips nNewWidth,
1214                                 SvxTabStopItem& rChgTabStop )
1215 {
1216     // dann aender bei allen TabStop die default's auf den neuen Wert
1217     // !!! Achtung: hier wird immer auf dem PoolAttribut gearbeitet,
1218     //              damit nicht in allen Sets die gleiche Berechnung
1219     //              auf dem gleichen TabStop (gepoolt!) vorgenommen
1220     //              wird. Als Modify wird ein FmtChg verschickt.
1221 
1222     sal_uInt16 nOldCnt = rChgTabStop.Count();
1223     if( !nOldCnt || nOldWidth == nNewWidth )
1224         return sal_False;
1225 
1226     // suche den Anfang der Defaults
1227     SvxTabStop* pTabs = ((SvxTabStop*)rChgTabStop.GetStart())
1228                         + (nOldCnt-1);
1229     sal_uInt16 n;
1230 
1231     for( n = nOldCnt; n ; --n, --pTabs )
1232         if( SVX_TAB_ADJUST_DEFAULT != pTabs->GetAdjustment() )
1233             break;
1234     ++n;
1235     if( n < nOldCnt )   // die DefTabStops loeschen
1236         rChgTabStop.Remove( n, nOldCnt - n );
1237     return sal_True;
1238 }
1239 
1240 // Setze das Attribut als neues default Attribut in diesem Dokument.
1241 // Ist Undo aktiv, wird das alte in die Undo-History aufgenommen
SetDefault(const SfxPoolItem & rAttr)1242 void SwDoc::SetDefault( const SfxPoolItem& rAttr )
1243 {
1244     SfxItemSet aSet( GetAttrPool(), rAttr.Which(), rAttr.Which() );
1245     aSet.Put( rAttr );
1246     SetDefault( aSet );
1247 }
1248 
SetDefault(const SfxItemSet & rSet)1249 void SwDoc::SetDefault( const SfxItemSet& rSet )
1250 {
1251     if( !rSet.Count() )
1252         return;
1253 
1254     SwModify aCallMod( 0 );
1255     SwAttrSet aOld( GetAttrPool(), rSet.GetRanges() ),
1256             aNew( GetAttrPool(), rSet.GetRanges() );
1257     SfxItemIter aIter( rSet );
1258     sal_uInt16 nWhich;
1259     const SfxPoolItem* pItem = aIter.GetCurItem();
1260     SfxItemPool* pSdrPool = GetAttrPool().GetSecondaryPool();
1261     while( sal_True )
1262     {
1263         sal_Bool bCheckSdrDflt = sal_False;
1264         nWhich = pItem->Which();
1265         aOld.Put( GetAttrPool().GetDefaultItem( nWhich ) );
1266         GetAttrPool().SetPoolDefaultItem( *pItem );
1267         aNew.Put( GetAttrPool().GetDefaultItem( nWhich ) );
1268 
1269         if (isCHRATR(nWhich) || isTXTATR(nWhich))
1270         {
1271             aCallMod.Add( pDfltTxtFmtColl );
1272             aCallMod.Add( pDfltCharFmt );
1273             bCheckSdrDflt = 0 != pSdrPool;
1274         }
1275         else if ( isPARATR(nWhich) ||
1276                   // --> OD 2008-02-25 #refactorlists#
1277                   isPARATR_LIST(nWhich) )
1278                   // <--
1279         {
1280             aCallMod.Add( pDfltTxtFmtColl );
1281             bCheckSdrDflt = 0 != pSdrPool;
1282         }
1283         else if (isGRFATR(nWhich))
1284         {
1285             aCallMod.Add( pDfltGrfFmtColl );
1286         }
1287         else if (isFRMATR(nWhich) || isDrawingLayerAttribute(nWhich) ) //UUUU
1288         {
1289             aCallMod.Add( pDfltGrfFmtColl );
1290             aCallMod.Add( pDfltTxtFmtColl );
1291             aCallMod.Add( pDfltFrmFmt );
1292         }
1293         else if (isBOXATR(nWhich))
1294         {
1295             aCallMod.Add( pDfltFrmFmt );
1296         }
1297 
1298         // copy also the defaults
1299         if( bCheckSdrDflt )
1300         {
1301             sal_uInt16 nEdtWhich, nSlotId;
1302             if( 0 != (nSlotId = GetAttrPool().GetSlotId( nWhich ) ) &&
1303                 nSlotId != nWhich &&
1304                 0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
1305                 nSlotId != nEdtWhich )
1306             {
1307                 SfxPoolItem* pCpy = pItem->Clone();
1308                 pCpy->SetWhich( nEdtWhich );
1309                 pSdrPool->SetPoolDefaultItem( *pCpy );
1310                 delete pCpy;
1311             }
1312         }
1313 
1314         if( aIter.IsAtEnd() )
1315             break;
1316         pItem = aIter.NextItem();
1317     }
1318 
1319     if( aNew.Count() && aCallMod.GetDepends() )
1320     {
1321         if (GetIDocumentUndoRedo().DoesUndo())
1322         {
1323             GetIDocumentUndoRedo().AppendUndo( new SwUndoDefaultAttr( aOld ) );
1324         }
1325 
1326         const SfxPoolItem* pTmpItem;
1327         if( ( SFX_ITEM_SET ==
1328                 aNew.GetItemState( RES_PARATR_TABSTOP, sal_False, &pTmpItem ) ) &&
1329             ((SvxTabStopItem*)pTmpItem)->Count() )
1330         {
1331             // TabStop-Aenderungen behandeln wir erstmal anders:
1332             // dann aender bei allen TabStop die dafault's auf den neuen Wert
1333             // !!! Achtung: hier wird immer auf dem PoolAttribut gearbeitet,
1334             //              damit nicht in allen Sets die gleiche Berechnung
1335             //              auf dem gleichen TabStop (gepoolt!) vorgenommen
1336             //              wird. Als Modify wird ein FmtChg verschickt.
1337             SwTwips nNewWidth = (*(SvxTabStopItem*)pTmpItem)[ 0 ].GetTabPos(),
1338                     nOldWidth = ((SvxTabStopItem&)aOld.Get(RES_PARATR_TABSTOP))[ 0 ].GetTabPos();
1339 
1340             int bChg = sal_False;
1341             sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_PARATR_TABSTOP );
1342             for( sal_uInt32 n = 0; n < nMaxItems; ++n )
1343                 if( 0 != (pTmpItem = GetAttrPool().GetItem2( RES_PARATR_TABSTOP, n ) ))
1344                     bChg |= lcl_SetNewDefTabStops( nOldWidth, nNewWidth,
1345                                                 *(SvxTabStopItem*)pTmpItem );
1346 
1347             aNew.ClearItem( RES_PARATR_TABSTOP );
1348             aOld.ClearItem( RES_PARATR_TABSTOP );
1349             if( bChg )
1350             {
1351                 SwFmtChg aChgFmt( pDfltCharFmt );
1352                 // dann sage mal den Frames bescheid
1353                 aCallMod.ModifyNotification( &aChgFmt, &aChgFmt );
1354             }
1355         }
1356     }
1357 
1358     if( aNew.Count() && aCallMod.GetDepends() )
1359     {
1360         SwAttrSetChg aChgOld( aOld, aOld );
1361         SwAttrSetChg aChgNew( aNew, aNew );
1362         aCallMod.ModifyNotification( &aChgOld, &aChgNew );      // alle veraenderten werden verschickt
1363     }
1364 
1365     // und die default-Formate wieder beim Object austragen
1366     SwClient* pDep;
1367     while( 0 != ( pDep = (SwClient*)aCallMod.GetDepends()) )
1368         aCallMod.Remove( pDep );
1369 
1370     SetModified();
1371 }
1372 
1373     // Erfrage das Default Attribut in diesem Dokument.
GetDefault(sal_uInt16 nFmtHint) const1374 const SfxPoolItem& SwDoc::GetDefault( sal_uInt16 nFmtHint ) const
1375 {
1376     return GetAttrPool().GetDefaultItem( nFmtHint );
1377 }
1378 
1379 /*
1380  * Loeschen der Formate
1381  */
DelCharFmt(sal_uInt16 nFmt,sal_Bool bBroadcast)1382 void SwDoc::DelCharFmt(sal_uInt16 nFmt, sal_Bool bBroadcast)
1383 {
1384     SwCharFmt * pDel = (*pCharFmtTbl)[nFmt];
1385 
1386     if (bBroadcast)
1387         BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_CHAR,
1388                                 SFX_STYLESHEET_ERASED);
1389 
1390     if (GetIDocumentUndoRedo().DoesUndo())
1391     {
1392         SwUndo * pUndo =
1393             new SwUndoCharFmtDelete(pDel, this);
1394 
1395         GetIDocumentUndoRedo().AppendUndo(pUndo);
1396     }
1397 
1398     pCharFmtTbl->DeleteAndDestroy(nFmt);
1399 
1400     SetModified();
1401 }
1402 
DelCharFmt(SwCharFmt * pFmt,sal_Bool bBroadcast)1403 void SwDoc::DelCharFmt( SwCharFmt *pFmt, sal_Bool bBroadcast )
1404 {
1405     sal_uInt16 nFmt = pCharFmtTbl->GetPos( pFmt );
1406     ASSERT( USHRT_MAX != nFmt, "Fmt not found," );
1407 
1408     DelCharFmt( nFmt, bBroadcast );
1409 }
1410 
DelFrmFmt(SwFrmFmt * pFmt,sal_Bool bBroadcast)1411 void SwDoc::DelFrmFmt( SwFrmFmt *pFmt, sal_Bool bBroadcast )
1412 {
1413     if( pFmt->ISA( SwTableBoxFmt ) || pFmt->ISA( SwTableLineFmt ))
1414     {
1415         ASSERT( sal_False, "Format is no longer in DocArray, "
1416                        "can be deleted by delete" );
1417         delete pFmt;
1418     }
1419     else
1420     {
1421 
1422         //Das Format muss in einem der beiden Arrays stehen, in welchem
1423         //werden wir schon merken.
1424         sal_uInt16 nPos;
1425         if ( USHRT_MAX != ( nPos = pFrmFmtTbl->GetPos( pFmt )) )
1426         {
1427             if (bBroadcast)
1428                 BroadcastStyleOperation(pFmt->GetName(),
1429                                         SFX_STYLE_FAMILY_FRAME,
1430                                         SFX_STYLESHEET_ERASED);
1431 
1432             if (GetIDocumentUndoRedo().DoesUndo())
1433             {
1434                 SwUndo * pUndo = new SwUndoFrmFmtDelete(pFmt, this);
1435 
1436                 GetIDocumentUndoRedo().AppendUndo(pUndo);
1437             }
1438 
1439             pFrmFmtTbl->DeleteAndDestroy( nPos );
1440         }
1441         else
1442         {
1443             nPos = GetSpzFrmFmts()->GetPos( pFmt );
1444             ASSERT( nPos != USHRT_MAX, "FrmFmt not found." );
1445             if( USHRT_MAX != nPos )
1446                 GetSpzFrmFmts()->DeleteAndDestroy( nPos );
1447         }
1448     }
1449 }
1450 
DelTblFrmFmt(SwTableFmt * pFmt)1451 void SwDoc::DelTblFrmFmt( SwTableFmt *pFmt )
1452 {
1453     sal_uInt16 nPos = pTblFrmFmtTbl->GetPos( pFmt );
1454     ASSERT( USHRT_MAX != nPos, "Fmt not found," );
1455     pTblFrmFmtTbl->DeleteAndDestroy( nPos );
1456 }
1457 
1458 /*
1459  * Erzeugen der Formate
1460  */
MakeFlyFrmFmt(const String & rFmtName,SwFrmFmt * pDerivedFrom)1461 SwFlyFrmFmt *SwDoc::MakeFlyFrmFmt( const String &rFmtName,
1462                                     SwFrmFmt *pDerivedFrom )
1463 {
1464     SwFlyFrmFmt *pFmt = new SwFlyFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom );
1465     GetSpzFrmFmts()->Insert(pFmt, GetSpzFrmFmts()->Count());
1466     SetModified();
1467     return pFmt;
1468 }
1469 
MakeDrawFrmFmt(const String & rFmtName,SwFrmFmt * pDerivedFrom)1470 SwDrawFrmFmt *SwDoc::MakeDrawFrmFmt( const String &rFmtName,
1471                                      SwFrmFmt *pDerivedFrom )
1472 {
1473     SwDrawFrmFmt *pFmt = new SwDrawFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom);
1474     GetSpzFrmFmts()->Insert(pFmt,GetSpzFrmFmts()->Count());
1475     SetModified();
1476     return pFmt;
1477 }
1478 
1479 
GetTblFrmFmtCount(sal_Bool bUsed) const1480 sal_uInt16 SwDoc::GetTblFrmFmtCount(sal_Bool bUsed) const
1481 {
1482     sal_uInt16 nCount = pTblFrmFmtTbl->Count();
1483     if(bUsed)
1484     {
1485         SwAutoFmtGetDocNode aGetHt( &GetNodes() );
1486         for ( sal_uInt16 i = nCount; i; )
1487         {
1488             if((*pTblFrmFmtTbl)[--i]->GetInfo( aGetHt ))
1489 
1490                 --nCount;
1491         }
1492     }
1493 
1494     return nCount;
1495 }
1496 
1497 
GetTblFrmFmt(sal_uInt16 nFmt,sal_Bool bUsed) const1498 SwFrmFmt& SwDoc::GetTblFrmFmt(sal_uInt16 nFmt, sal_Bool bUsed ) const
1499 {
1500     sal_uInt16 nRemoved = 0;
1501     if(bUsed)
1502     {
1503         SwAutoFmtGetDocNode aGetHt( &GetNodes() );
1504         for ( sal_uInt16 i = 0; i <= nFmt; i++ )
1505         {
1506             while ( (*pTblFrmFmtTbl)[ i + nRemoved]->GetInfo( aGetHt ))
1507             {
1508                 nRemoved++;
1509             }
1510         }
1511     }
1512     return *((*pTblFrmFmtTbl)[nRemoved + nFmt]);
1513 }
1514 
MakeTblFrmFmt(const String & rFmtName,SwFrmFmt * pDerivedFrom)1515 SwTableFmt* SwDoc::MakeTblFrmFmt( const String &rFmtName,
1516                                     SwFrmFmt *pDerivedFrom )
1517 {
1518     SwTableFmt* pFmt = new SwTableFmt( GetAttrPool(), rFmtName, pDerivedFrom );
1519     pTblFrmFmtTbl->Insert( pFmt, pTblFrmFmtTbl->Count() );
1520     SetModified();
1521 
1522     return pFmt;
1523 }
1524 
MakeFrmFmt(const String & rFmtName,SwFrmFmt * pDerivedFrom,sal_Bool bBroadcast,sal_Bool bAuto)1525 SwFrmFmt *SwDoc::MakeFrmFmt(const String &rFmtName,
1526                             SwFrmFmt *pDerivedFrom,
1527                             sal_Bool bBroadcast, sal_Bool bAuto)
1528 {
1529 
1530     SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom );
1531 
1532     pFmt->SetAuto(bAuto);
1533     pFrmFmtTbl->Insert( pFmt, pFrmFmtTbl->Count());
1534     SetModified();
1535 
1536     if (bBroadcast)
1537     {
1538         BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_PARA,
1539                                 SFX_STYLESHEET_CREATED);
1540 
1541         if (GetIDocumentUndoRedo().DoesUndo())
1542         {
1543             SwUndo * pUndo = new SwUndoFrmFmtCreate(pFmt, pDerivedFrom, this);
1544 
1545             GetIDocumentUndoRedo().AppendUndo(pUndo);
1546         }
1547     }
1548 
1549     return pFmt;
1550 }
1551 
_MakeFrmFmt(const String & rFmtName,SwFmt * pDerivedFrom,sal_Bool bBroadcast,sal_Bool bAuto)1552 SwFmt *SwDoc::_MakeFrmFmt(const String &rFmtName,
1553                             SwFmt *pDerivedFrom,
1554                             sal_Bool bBroadcast, sal_Bool bAuto)
1555 {
1556     SwFrmFmt *pFrmFmt = dynamic_cast<SwFrmFmt*>(pDerivedFrom);
1557     pFrmFmt = MakeFrmFmt( rFmtName, pFrmFmt, bBroadcast, bAuto );
1558     return dynamic_cast<SwFmt*>(pFrmFmt);
1559 }
1560 
1561 
1562 // --> OD 2005-01-13 #i40550# - add parameter <bAuto> - not relevant
MakeCharFmt(const String & rFmtName,SwCharFmt * pDerivedFrom,sal_Bool bBroadcast,sal_Bool)1563 SwCharFmt *SwDoc::MakeCharFmt( const String &rFmtName,
1564                                SwCharFmt *pDerivedFrom,
1565                                sal_Bool bBroadcast,
1566                                sal_Bool )
1567 // <--
1568 {
1569     SwCharFmt *pFmt = new SwCharFmt( GetAttrPool(), rFmtName, pDerivedFrom );
1570     pCharFmtTbl->Insert( pFmt, pCharFmtTbl->Count() );
1571     pFmt->SetAuto( sal_False );
1572     SetModified();
1573 
1574     if (GetIDocumentUndoRedo().DoesUndo())
1575     {
1576         SwUndo * pUndo = new SwUndoCharFmtCreate(pFmt, pDerivedFrom, this);
1577 
1578         GetIDocumentUndoRedo().AppendUndo(pUndo);
1579     }
1580 
1581     if (bBroadcast)
1582     {
1583         BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_CHAR,
1584                                 SFX_STYLESHEET_CREATED);
1585     }
1586 
1587     return pFmt;
1588 }
1589 
_MakeCharFmt(const String & rFmtName,SwFmt * pDerivedFrom,sal_Bool bBroadcast,sal_Bool bAuto)1590 SwFmt *SwDoc::_MakeCharFmt(const String &rFmtName,
1591                             SwFmt *pDerivedFrom,
1592                             sal_Bool bBroadcast, sal_Bool bAuto)
1593 {
1594     SwCharFmt *pCharFmt = dynamic_cast<SwCharFmt*>(pDerivedFrom);
1595     pCharFmt = MakeCharFmt( rFmtName, pCharFmt, bBroadcast, bAuto );
1596     return dynamic_cast<SwFmt*>(pCharFmt);
1597 }
1598 
1599 
1600 /*
1601  * Erzeugen der FormatCollections
1602  */
1603 // TXT
1604 // --> OD 2005-01-13 #i40550# - add parameter <bAuto> - not relevant
MakeTxtFmtColl(const String & rFmtName,SwTxtFmtColl * pDerivedFrom,sal_Bool bBroadcast,sal_Bool)1605 SwTxtFmtColl* SwDoc::MakeTxtFmtColl( const String &rFmtName,
1606                                      SwTxtFmtColl *pDerivedFrom,
1607                                      sal_Bool bBroadcast,
1608                                      sal_Bool )
1609 // <--
1610 {
1611     SwTxtFmtColl *pFmtColl = new SwTxtFmtColl( GetAttrPool(), rFmtName,
1612                                                 pDerivedFrom );
1613     pTxtFmtCollTbl->Insert(pFmtColl, pTxtFmtCollTbl->Count());
1614     pFmtColl->SetAuto( sal_False );
1615     SetModified();
1616 
1617     if (GetIDocumentUndoRedo().DoesUndo())
1618     {
1619         SwUndo * pUndo = new SwUndoTxtFmtCollCreate(pFmtColl, pDerivedFrom,
1620                                                     this);
1621         GetIDocumentUndoRedo().AppendUndo(pUndo);
1622     }
1623 
1624     if (bBroadcast)
1625         BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_PARA,
1626                                 SFX_STYLESHEET_CREATED);
1627 
1628     return pFmtColl;
1629 }
1630 
_MakeTxtFmtColl(const String & rFmtName,SwFmt * pDerivedFrom,sal_Bool bBroadcast,sal_Bool bAuto)1631 SwFmt *SwDoc::_MakeTxtFmtColl(const String &rFmtName,
1632                             SwFmt *pDerivedFrom,
1633                             sal_Bool bBroadcast, sal_Bool bAuto)
1634 {
1635     SwTxtFmtColl *pTxtFmtColl = dynamic_cast<SwTxtFmtColl*>(pDerivedFrom);
1636     pTxtFmtColl = MakeTxtFmtColl( rFmtName, pTxtFmtColl, bBroadcast, bAuto );
1637     return dynamic_cast<SwFmt*>(pTxtFmtColl);
1638 }
1639 
1640 
1641 //FEATURE::CONDCOLL
MakeCondTxtFmtColl(const String & rFmtName,SwTxtFmtColl * pDerivedFrom,sal_Bool bBroadcast)1642 SwConditionTxtFmtColl* SwDoc::MakeCondTxtFmtColl( const String &rFmtName,
1643                                                   SwTxtFmtColl *pDerivedFrom,
1644                                                   sal_Bool bBroadcast)
1645 {
1646     SwConditionTxtFmtColl*pFmtColl = new SwConditionTxtFmtColl( GetAttrPool(),
1647                                                     rFmtName, pDerivedFrom );
1648     pTxtFmtCollTbl->Insert(pFmtColl, pTxtFmtCollTbl->Count());
1649     pFmtColl->SetAuto( sal_False );
1650     SetModified();
1651 
1652     if (bBroadcast)
1653         BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_PARA,
1654                                 SFX_STYLESHEET_CREATED);
1655 
1656     return pFmtColl;
1657 }
1658 //FEATURE::CONDCOLL
1659 
1660 // GRF
1661 
MakeGrfFmtColl(const String & rFmtName,SwGrfFmtColl * pDerivedFrom)1662 SwGrfFmtColl* SwDoc::MakeGrfFmtColl( const String &rFmtName,
1663                                      SwGrfFmtColl *pDerivedFrom )
1664 {
1665     SwGrfFmtColl *pFmtColl = new SwGrfFmtColl( GetAttrPool(), rFmtName,
1666                                                 pDerivedFrom );
1667     pGrfFmtCollTbl->Insert( pFmtColl, pGrfFmtCollTbl->Count() );
1668     pFmtColl->SetAuto( sal_False );
1669     SetModified();
1670     return pFmtColl;
1671 }
1672 
DelTxtFmtColl(sal_uInt16 nFmtColl,sal_Bool bBroadcast)1673 void SwDoc::DelTxtFmtColl(sal_uInt16 nFmtColl, sal_Bool bBroadcast)
1674 {
1675     ASSERT( nFmtColl, "Remove fuer Coll 0." );
1676 
1677     // Wer hat die zu loeschende als Next
1678     SwTxtFmtColl *pDel = (*pTxtFmtCollTbl)[nFmtColl];
1679     if( pDfltTxtFmtColl == pDel )
1680         return;     // default nie loeschen !!
1681 
1682     if (bBroadcast)
1683         BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_PARA,
1684                                 SFX_STYLESHEET_ERASED);
1685 
1686     if (GetIDocumentUndoRedo().DoesUndo())
1687     {
1688         SwUndoTxtFmtCollDelete * pUndo =
1689             new SwUndoTxtFmtCollDelete(pDel, this);
1690 
1691         GetIDocumentUndoRedo().AppendUndo(pUndo);
1692     }
1693 
1694     // Die FmtColl austragen
1695     pTxtFmtCollTbl->Remove(nFmtColl);
1696     // Next korrigieren
1697     pTxtFmtCollTbl->ForEach( 1, pTxtFmtCollTbl->Count(),
1698                             &SetTxtFmtCollNext, pDel );
1699     delete pDel;
1700     SetModified();
1701 }
1702 
DelTxtFmtColl(SwTxtFmtColl * pColl,sal_Bool bBroadcast)1703 void SwDoc::DelTxtFmtColl( SwTxtFmtColl *pColl, sal_Bool bBroadcast )
1704 {
1705     sal_uInt16 nFmt = pTxtFmtCollTbl->GetPos( pColl );
1706     ASSERT( USHRT_MAX != nFmt, "Collection not found," );
1707     DelTxtFmtColl( nFmt, bBroadcast );
1708 }
1709 
lcl_SetTxtFmtColl(const SwNodePtr & rpNode,void * pArgs)1710 sal_Bool lcl_SetTxtFmtColl( const SwNodePtr& rpNode, void* pArgs )
1711 {
1712     SwCntntNode* pCNd = (SwCntntNode*) rpNode->GetTxtNode();
1713     if ( pCNd )
1714     {
1715         ParaRstFmt* pPara = (ParaRstFmt*) pArgs;
1716 
1717         SwTxtFmtColl* pFmt = static_cast< SwTxtFmtColl* >( pPara->pFmtColl );
1718         if ( pPara->bReset )
1719         {
1720 
1721             lcl_RstAttr( pCNd, pPara );
1722 
1723             // check, if paragraph style has changed
1724             if ( pPara->bResetListAttrs &&
1725                  pFmt != pCNd->GetFmtColl() &&
1726                  pFmt->GetItemState( RES_PARATR_NUMRULE ) == SFX_ITEM_SET )
1727             {
1728                 // --> OD 2009-09-07 #b6876367#
1729                 // Check, if the list style of the paragraph will change.
1730                 bool bChangeOfListStyleAtParagraph( true );
1731                 SwTxtNode* pTNd( dynamic_cast<SwTxtNode*>(pCNd) );
1732                 ASSERT( pTNd,
1733                         "<lcl_SetTxtFmtColl(..)> - text node expected -> crash" );
1734                 {
1735                     SwNumRule* pNumRuleAtParagraph( pTNd->GetNumRule() );
1736                     if ( pNumRuleAtParagraph )
1737                     {
1738                         const SwNumRuleItem& rNumRuleItemAtParagraphStyle =
1739                                                             pFmt->GetNumRule();
1740                         if ( rNumRuleItemAtParagraphStyle.GetValue() ==
1741                                                 pNumRuleAtParagraph->GetName() )
1742                         {
1743                             bChangeOfListStyleAtParagraph = false;
1744                         }
1745                     }
1746                 }
1747 
1748                 if ( bChangeOfListStyleAtParagraph )
1749                 {
1750                     std::unique_ptr< SwRegHistory > pRegH;
1751                     if ( pPara->pHistory )
1752                     {
1753                         pRegH.reset( new SwRegHistory( pTNd, *pTNd, pPara->pHistory ) );
1754                     }
1755 
1756                     pCNd->ResetAttr( RES_PARATR_NUMRULE );
1757 
1758                     // reset all list attributes
1759                     pCNd->ResetAttr( RES_PARATR_LIST_LEVEL );
1760                     pCNd->ResetAttr( RES_PARATR_LIST_ISRESTART );
1761                     pCNd->ResetAttr( RES_PARATR_LIST_RESTARTVALUE );
1762                     pCNd->ResetAttr( RES_PARATR_LIST_ISCOUNTED );
1763                     pCNd->ResetAttr( RES_PARATR_LIST_ID );
1764                 }
1765             }
1766         }
1767 
1768         // erst in die History aufnehmen, damit ggfs. alte Daten
1769         // gesichert werden koennen
1770         if( pPara->pHistory )
1771             pPara->pHistory->Add( pCNd->GetFmtColl(), pCNd->GetIndex(),
1772                                     ND_TEXTNODE );
1773 
1774         pCNd->ChgFmtColl( pFmt );
1775 
1776         pPara->nWhich++;
1777     }
1778     return sal_True;
1779 }
1780 
1781 
SetTxtFmtColl(const SwPaM & rRg,SwTxtFmtColl * pFmt,const bool bReset,const bool bResetListAttrs)1782 sal_Bool SwDoc::SetTxtFmtColl(
1783     const SwPaM &rRg,
1784     SwTxtFmtColl *pFmt,
1785     const bool bReset,
1786     const bool bResetListAttrs )
1787 {
1788     SwDataChanged aTmp( rRg, 0 );
1789     const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
1790     SwHistory* pHst = 0;
1791     sal_Bool bRet = sal_True;
1792 
1793     if (GetIDocumentUndoRedo().DoesUndo())
1794     {
1795         SwUndoFmtColl* pUndo = new SwUndoFmtColl( rRg, pFmt,
1796                                                   bReset,
1797                                                   bResetListAttrs );
1798         pHst = pUndo->GetHistory();
1799         GetIDocumentUndoRedo().AppendUndo(pUndo);
1800     }
1801 
1802     ParaRstFmt aPara( pStt, pEnd, pHst );
1803     aPara.pFmtColl = pFmt;
1804     aPara.bReset = bReset;
1805     aPara.bResetListAttrs = bResetListAttrs;
1806 
1807     GetNodes().ForEach( pStt->nNode.GetIndex(), pEnd->nNode.GetIndex()+1,
1808                         lcl_SetTxtFmtColl, &aPara );
1809     if ( !aPara.nWhich )
1810         bRet = sal_False;           // keinen gueltigen Node gefunden
1811 
1812     if ( bRet )
1813     {
1814         SetModified();
1815     }
1816 
1817     return bRet;
1818 }
1819 
1820 
1821 // ---- Kopiere die Formate in sich selbst (SwDoc) ----------------------
1822 
CopyFmt(const SwFmt & rFmt,const SvPtrarr & rFmtArr,FNCopyFmt fnCopyFmt,const SwFmt & rDfltFmt)1823 SwFmt* SwDoc::CopyFmt( const SwFmt& rFmt,
1824                         const SvPtrarr& rFmtArr,
1825                         FNCopyFmt fnCopyFmt, const SwFmt& rDfltFmt )
1826 {
1827     //  kein-Autoformat || default Format || Collection-Format
1828     // dann suche danach.
1829     if( !rFmt.IsAuto() || !rFmt.GetRegisteredIn() )
1830         for( sal_uInt16 n = 0; n < rFmtArr.Count(); n++ )
1831         {
1832             // ist die Vorlage schon im Doc vorhanden ??
1833             if( ((SwFmt*)rFmtArr[n])->GetName().Equals( rFmt.GetName() ))
1834                 return (SwFmt*)rFmtArr[n];
1835         }
1836 
1837     // suche erstmal nach dem "Parent"
1838     SwFmt* pParent = (SwFmt*)&rDfltFmt;
1839     if( rFmt.DerivedFrom() && pParent != rFmt.DerivedFrom() )
1840         pParent = CopyFmt( *rFmt.DerivedFrom(), rFmtArr,
1841                                 fnCopyFmt, rDfltFmt );
1842 
1843     // erzeuge das Format und kopiere die Attribute
1844     // --> OD 2005-01-13 #i40550#
1845     SwFmt* pNewFmt = (this->*fnCopyFmt)( rFmt.GetName(), pParent, sal_False, sal_True );
1846     // <--
1847     pNewFmt->SetAuto( rFmt.IsAuto() );
1848     pNewFmt->CopyAttrs( rFmt, sal_True );           // kopiere Attribute
1849 
1850     pNewFmt->SetPoolFmtId( rFmt.GetPoolFmtId() );
1851     pNewFmt->SetPoolHelpId( rFmt.GetPoolHelpId() );
1852 
1853     // HelpFile-Id immer auf dflt setzen !!
1854     pNewFmt->SetPoolHlpFileId( UCHAR_MAX );
1855 
1856     return pNewFmt;
1857 }
1858 
1859 
1860 // ---- kopiere das Frame-Format --------
CopyFrmFmt(const SwFrmFmt & rFmt)1861 SwFrmFmt* SwDoc::CopyFrmFmt( const SwFrmFmt& rFmt )
1862 {
1863 
1864     return (SwFrmFmt*)CopyFmt( rFmt, *GetFrmFmts(), &SwDoc::_MakeFrmFmt,
1865                                 *GetDfltFrmFmt() );
1866 }
1867 
1868 // ---- kopiere das Char-Format --------
CopyCharFmt(const SwCharFmt & rFmt)1869 SwCharFmt* SwDoc::CopyCharFmt( const SwCharFmt& rFmt )
1870 {
1871     return (SwCharFmt*)CopyFmt( rFmt, *GetCharFmts(),
1872                                 &SwDoc::_MakeCharFmt,
1873                                 *GetDfltCharFmt() );
1874 }
1875 
1876 
1877 // --- Kopiere TextNodes ----
1878 
CopyTxtColl(const SwTxtFmtColl & rColl)1879 SwTxtFmtColl* SwDoc::CopyTxtColl( const SwTxtFmtColl& rColl )
1880 {
1881     SwTxtFmtColl* pNewColl = FindTxtFmtCollByName( rColl.GetName() );
1882     if( pNewColl )
1883         return pNewColl;
1884 
1885     // suche erstmal nach dem "Parent"
1886     SwTxtFmtColl* pParent = pDfltTxtFmtColl;
1887     if( pParent != rColl.DerivedFrom() )
1888         pParent = CopyTxtColl( *(SwTxtFmtColl*)rColl.DerivedFrom() );
1889 
1890 
1891 //FEATURE::CONDCOLL
1892     if( RES_CONDTXTFMTCOLL == rColl.Which() )
1893     {
1894         pNewColl = new SwConditionTxtFmtColl( GetAttrPool(), rColl.GetName(),
1895                                                 pParent);
1896         pTxtFmtCollTbl->Insert( pNewColl, pTxtFmtCollTbl->Count() );
1897         pNewColl->SetAuto( sal_False );
1898         SetModified();
1899 
1900         // Kopiere noch die Bedingungen
1901         ((SwConditionTxtFmtColl*)pNewColl)->SetConditions(
1902                             ((SwConditionTxtFmtColl&)rColl).GetCondColls() );
1903     }
1904     else
1905 //FEATURE::CONDCOLL
1906         pNewColl = MakeTxtFmtColl( rColl.GetName(), pParent );
1907 
1908     // kopiere jetzt noch die Auto-Formate oder kopiere die Attribute
1909     pNewColl->CopyAttrs( rColl, sal_True );
1910 
1911     // setze noch den Outline-Level
1912     if ( rColl.IsAssignedToListLevelOfOutlineStyle() )
1913         pNewColl->AssignToListLevelOfOutlineStyle( rColl.GetAssignedOutlineStyleLevel() );
1914 
1915     pNewColl->SetPoolFmtId( rColl.GetPoolFmtId() );
1916     pNewColl->SetPoolHelpId( rColl.GetPoolHelpId() );
1917 
1918     // HelpFile-Id immer auf dflt setzen !!
1919     pNewColl->SetPoolHlpFileId( UCHAR_MAX );
1920 
1921     if( &rColl.GetNextTxtFmtColl() != &rColl )
1922         pNewColl->SetNextTxtFmtColl( *CopyTxtColl( rColl.GetNextTxtFmtColl() ));
1923 
1924     // ggfs. die NumRule erzeugen
1925     if( this != rColl.GetDoc() )
1926     {
1927         const SfxPoolItem* pItem;
1928         if( SFX_ITEM_SET == pNewColl->GetItemState( RES_PARATR_NUMRULE,
1929             sal_False, &pItem ))
1930         {
1931             const SwNumRule* pRule;
1932             const String& rName = ((SwNumRuleItem*)pItem)->GetValue();
1933             if( rName.Len() &&
1934                 0 != ( pRule = rColl.GetDoc()->FindNumRulePtr( rName )) &&
1935                 !pRule->IsAutoRule() )
1936             {
1937                 SwNumRule* pDestRule = FindNumRulePtr( rName );
1938                 if( pDestRule )
1939                     pDestRule->SetInvalidRule( sal_True );
1940                 else
1941                     MakeNumRule( rName, pRule );
1942             }
1943         }
1944     }
1945     return pNewColl;
1946 }
1947 
1948 // --- Kopiere GrafikNodes ----
1949 
CopyGrfColl(const SwGrfFmtColl & rColl)1950 SwGrfFmtColl* SwDoc::CopyGrfColl( const SwGrfFmtColl& rColl )
1951 {
1952     SwGrfFmtColl* pNewColl = FindGrfFmtCollByName( rColl.GetName() );
1953     if( pNewColl )
1954         return pNewColl;
1955 
1956     // suche erstmal nach dem "Parent"
1957     SwGrfFmtColl* pParent = pDfltGrfFmtColl;
1958     if( pParent != rColl.DerivedFrom() )
1959         pParent = CopyGrfColl( *(SwGrfFmtColl*)rColl.DerivedFrom() );
1960 
1961     // falls nicht, so kopiere sie
1962     pNewColl = MakeGrfFmtColl( rColl.GetName(), pParent );
1963 
1964     // noch die Attribute kopieren
1965     pNewColl->CopyAttrs( rColl );
1966 
1967     pNewColl->SetPoolFmtId( rColl.GetPoolFmtId() );
1968     pNewColl->SetPoolHelpId( rColl.GetPoolHelpId() );
1969 
1970     // HelpFile-Id immer auf dflt setzen !!
1971     pNewColl->SetPoolHlpFileId( UCHAR_MAX );
1972 
1973     return pNewColl;
1974 }
1975 
lcl_FindPageDesc(const SwPageDescs & rArr,const String & rName)1976 SwPageDesc* lcl_FindPageDesc( const SwPageDescs& rArr, const String& rName )
1977 {
1978     for( sal_uInt16 n = rArr.Count(); n; )
1979     {
1980         SwPageDesc* pDesc = rArr[ --n ];
1981         if( pDesc->GetName() == rName )
1982             return pDesc;
1983     }
1984     return 0;
1985 }
1986 
CopyFmtArr(const SvPtrarr & rSourceArr,SvPtrarr & rDestArr,FNCopyFmt fnCopyFmt,SwFmt & rDfltFmt)1987 void SwDoc::CopyFmtArr( const SvPtrarr& rSourceArr,
1988                         SvPtrarr& rDestArr,
1989                         FNCopyFmt fnCopyFmt,
1990                         SwFmt& rDfltFmt )
1991 {
1992     sal_uInt16 nSrc;
1993     SwFmt* pSrc, *pDest;
1994 
1995     // 1. Schritt alle Formate anlegen (das 0. ueberspringen - Default!)
1996     for( nSrc = rSourceArr.Count(); nSrc > 1; )
1997     {
1998         pSrc = (SwFmt*)rSourceArr[ --nSrc ];
1999         if( pSrc->IsDefault() || pSrc->IsAuto() )
2000             continue;
2001 
2002         if( 0 == FindFmtByName( rDestArr, pSrc->GetName() ) )
2003         {
2004             if( RES_CONDTXTFMTCOLL == pSrc->Which() )
2005                 MakeCondTxtFmtColl( pSrc->GetName(), (SwTxtFmtColl*)&rDfltFmt );
2006             else
2007                 // --> OD 2005-01-13 #i40550#
2008                 (this->*fnCopyFmt)( pSrc->GetName(), &rDfltFmt, sal_False, sal_True );
2009                 // <--
2010         }
2011     }
2012 
2013     // 2. Schritt alle Attribute kopieren, richtige Parents setzen
2014     for( nSrc = rSourceArr.Count(); nSrc > 1; )
2015     {
2016         pSrc = (SwFmt*)rSourceArr[ --nSrc ];
2017         if( pSrc->IsDefault() || pSrc->IsAuto() )
2018             continue;
2019 
2020         pDest = FindFmtByName( rDestArr, pSrc->GetName() );
2021         pDest->SetAuto( sal_False );
2022         pDest->DelDiffs( *pSrc );
2023 
2024         // #i94285#: existing <SwFmtPageDesc> instance, before copying attributes
2025         const SfxPoolItem* pItem;
2026         if( &GetAttrPool() != pSrc->GetAttrSet().GetPool() &&
2027             SFX_ITEM_SET == pSrc->GetAttrSet().GetItemState(
2028             RES_PAGEDESC, sal_False, &pItem ) &&
2029             ((SwFmtPageDesc*)pItem)->GetPageDesc() )
2030         {
2031             SwFmtPageDesc aPageDesc( *(SwFmtPageDesc*)pItem );
2032             const String& rNm = aPageDesc.GetPageDesc()->GetName();
2033             SwPageDesc* pPageDesc = ::lcl_FindPageDesc( aPageDescs, rNm );
2034             if( !pPageDesc )
2035             {
2036                 pPageDesc = aPageDescs[ MakePageDesc( rNm ) ];
2037             }
2038             aPageDesc.RegisterToPageDesc( *pPageDesc );
2039             SwAttrSet aTmpAttrSet( pSrc->GetAttrSet() );
2040             aTmpAttrSet.Put( aPageDesc );
2041             pDest->SetFmtAttr( aTmpAttrSet );
2042         }
2043         else
2044         {
2045             pDest->SetFmtAttr( pSrc->GetAttrSet() );
2046         }
2047 
2048         pDest->SetPoolFmtId( pSrc->GetPoolFmtId() );
2049         pDest->SetPoolHelpId( pSrc->GetPoolHelpId() );
2050 
2051         // HelpFile-Id immer auf dflt setzen !!
2052         pDest->SetPoolHlpFileId( UCHAR_MAX );
2053 
2054         if( pSrc->DerivedFrom() )
2055             pDest->SetDerivedFrom( FindFmtByName( rDestArr,
2056                                         pSrc->DerivedFrom()->GetName() ) );
2057         if( RES_TXTFMTCOLL == pSrc->Which() ||
2058             RES_CONDTXTFMTCOLL == pSrc->Which() )
2059         {
2060             SwTxtFmtColl* pSrcColl = (SwTxtFmtColl*)pSrc,
2061                         * pDstColl = (SwTxtFmtColl*)pDest;
2062             if( &pSrcColl->GetNextTxtFmtColl() != pSrcColl )
2063                 pDstColl->SetNextTxtFmtColl( *(SwTxtFmtColl*)FindFmtByName(
2064                     rDestArr, pSrcColl->GetNextTxtFmtColl().GetName() ) );
2065 
2066             // setze noch den Outline-Level
2067             if(pSrcColl->IsAssignedToListLevelOfOutlineStyle())
2068                 pDstColl->AssignToListLevelOfOutlineStyle(pSrcColl->GetAssignedOutlineStyleLevel());
2069 
2070 //FEATURE::CONDCOLL
2071             if( RES_CONDTXTFMTCOLL == pSrc->Which() )
2072                 // Kopiere noch die Bedingungen
2073                 // aber erst die alten loeschen!
2074                 ((SwConditionTxtFmtColl*)pDstColl)->SetConditions(
2075                             ((SwConditionTxtFmtColl*)pSrc)->GetCondColls() );
2076 //FEATURE::CONDCOLL
2077         }
2078     }
2079 }
2080 
CopyPageDescHeaderFooterImpl(bool bCpyHeader,const SwFrmFmt & rSrcFmt,SwFrmFmt & rDestFmt)2081 void SwDoc::CopyPageDescHeaderFooterImpl( bool bCpyHeader,
2082                                 const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt )
2083 {
2084     // jetzt noch Header-/Footer-Attribute richtig behandeln
2085     // Contenten Nodes Dokumentuebergreifend kopieren!
2086     sal_uInt16 nAttr = static_cast<sal_uInt16>( bCpyHeader ? RES_HEADER : RES_FOOTER );
2087     const SfxPoolItem* pItem;
2088     if( SFX_ITEM_SET != rSrcFmt.GetAttrSet().GetItemState( nAttr, sal_False, &pItem ))
2089         return ;
2090 
2091     // Im Header steht noch der Verweis auf das Format aus dem
2092     // anderen Document!!
2093     SfxPoolItem* pNewItem = pItem->Clone();
2094 
2095     SwFrmFmt* pOldFmt;
2096     if( bCpyHeader )
2097          pOldFmt = ((SwFmtHeader*)pNewItem)->GetHeaderFmt();
2098     else
2099          pOldFmt = ((SwFmtFooter*)pNewItem)->GetFooterFmt();
2100 
2101     if( pOldFmt )
2102     {
2103         SwFrmFmt* pNewFmt = new SwFrmFmt( GetAttrPool(), "CpyDesc",
2104                                             GetDfltFrmFmt() );
2105         pNewFmt->CopyAttrs( *pOldFmt, sal_True );
2106 
2107         if( SFX_ITEM_SET == pNewFmt->GetAttrSet().GetItemState(
2108             RES_CNTNT, sal_False, &pItem ))
2109         {
2110             SwFmtCntnt* pCntnt = (SwFmtCntnt*)pItem;
2111             if( pCntnt->GetCntntIdx() )
2112             {
2113                 SwNodeIndex aTmpIdx( GetNodes().GetEndOfAutotext() );
2114                 const SwNodes& rSrcNds = rSrcFmt.GetDoc()->GetNodes();
2115                 SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmpIdx,
2116                                                 bCpyHeader
2117                                                     ? SwHeaderStartNode
2118                                                     : SwFooterStartNode );
2119                 const SwNode& rCSttNd = pCntnt->GetCntntIdx()->GetNode();
2120                 SwNodeRange aRg( rCSttNd, 0, *rCSttNd.EndOfSectionNode() );
2121                 aTmpIdx = *pSttNd->EndOfSectionNode();
2122                 rSrcNds._Copy( aRg, aTmpIdx );
2123                 aTmpIdx = *pSttNd;
2124                 rSrcFmt.GetDoc()->CopyFlyInFlyImpl( aRg, 0, aTmpIdx );
2125                 pNewFmt->SetFmtAttr( SwFmtCntnt( pSttNd ));
2126             }
2127             else
2128                 pNewFmt->ResetFmtAttr( RES_CNTNT );
2129         }
2130         if( bCpyHeader )
2131             ((SwFmtHeader*)pNewItem)->RegisterToFormat(*pNewFmt);
2132         else
2133             ((SwFmtFooter*)pNewItem)->RegisterToFormat(*pNewFmt);
2134         rDestFmt.SetFmtAttr( *pNewItem );
2135     }
2136     delete pNewItem;
2137 }
2138 
CopyPageDesc(const SwPageDesc & rSrcDesc,SwPageDesc & rDstDesc,sal_Bool bCopyPoolIds)2139 void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
2140                             sal_Bool bCopyPoolIds )
2141 {
2142     sal_Bool bNotifyLayout = sal_False;
2143     SwRootFrm* pTmpRoot = GetCurrentLayout();//swmod 080219
2144 
2145     rDstDesc.SetLandscape( rSrcDesc.GetLandscape() );
2146     rDstDesc.SetNumType( rSrcDesc.GetNumType() );
2147     if( rDstDesc.ReadUseOn() != rSrcDesc.ReadUseOn() )
2148     {
2149         rDstDesc.WriteUseOn( rSrcDesc.ReadUseOn() );
2150         bNotifyLayout = sal_True;
2151     }
2152 
2153     if( bCopyPoolIds )
2154     {
2155         rDstDesc.SetPoolFmtId( rSrcDesc.GetPoolFmtId() );
2156         rDstDesc.SetPoolHelpId( rSrcDesc.GetPoolHelpId() );
2157         // HelpFile-Id immer auf dflt setzen !!
2158         rDstDesc.SetPoolHlpFileId( UCHAR_MAX );
2159     }
2160 
2161     if( rSrcDesc.GetFollow() != &rSrcDesc )
2162     {
2163         SwPageDesc* pFollow = ::lcl_FindPageDesc( aPageDescs,
2164                                     rSrcDesc.GetFollow()->GetName() );
2165         if( !pFollow )
2166         {
2167             // dann mal kopieren
2168             sal_uInt16 nPos = MakePageDesc( rSrcDesc.GetFollow()->GetName() );
2169             pFollow = aPageDescs[ nPos ];
2170             CopyPageDesc( *rSrcDesc.GetFollow(), *pFollow );
2171         }
2172         rDstDesc.SetFollow( pFollow );
2173         bNotifyLayout = sal_True;
2174     }
2175 
2176     // die Header/Footer-Attribute werden gesondert kopiert, die Content-
2177     // Sections muessen vollstaendig mitgenommen werden!
2178     {
2179         SfxItemSet aAttrSet( rSrcDesc.GetMaster().GetAttrSet() );
2180         aAttrSet.ClearItem( RES_HEADER );
2181         aAttrSet.ClearItem( RES_FOOTER );
2182 
2183         rDstDesc.GetMaster().DelDiffs( aAttrSet );
2184         rDstDesc.GetMaster().SetFmtAttr( aAttrSet );
2185 
2186         aAttrSet.ClearItem();
2187         aAttrSet.Put( rSrcDesc.GetLeft().GetAttrSet() );
2188         aAttrSet.ClearItem( RES_HEADER );
2189         aAttrSet.ClearItem( RES_FOOTER );
2190 
2191         rDstDesc.GetLeft().DelDiffs( aAttrSet );
2192         rDstDesc.GetLeft().SetFmtAttr( aAttrSet );
2193     }
2194 
2195     CopyHeader( rSrcDesc.GetMaster(), rDstDesc.GetMaster() );
2196     CopyFooter( rSrcDesc.GetMaster(), rDstDesc.GetMaster() );
2197     if( !rDstDesc.IsHeaderShared() )
2198         CopyHeader( rSrcDesc.GetLeft(), rDstDesc.GetLeft() );
2199     else
2200         rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetHeader() );
2201 
2202     if( !rDstDesc.IsFooterShared() )
2203         CopyFooter( rSrcDesc.GetLeft(), rDstDesc.GetLeft() );
2204     else
2205         rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetFooter() );
2206 
2207     if( bNotifyLayout && pTmpRoot )
2208     {
2209         std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080225
2210         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fn(&SwRootFrm::AllCheckPageDescs));//swmod 080226
2211     }
2212 
2213     //Wenn sich FussnotenInfo veraendert, so werden die Seiten
2214     //angetriggert.
2215     if( !(rDstDesc.GetFtnInfo() == rSrcDesc.GetFtnInfo()) )
2216     {
2217         rDstDesc.SetFtnInfo( rSrcDesc.GetFtnInfo() );
2218         SwMsgPoolItem  aInfo( RES_PAGEDESC_FTNINFO );
2219         {
2220             rDstDesc.GetMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
2221         }
2222         {
2223             rDstDesc.GetLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
2224         }
2225     }
2226 }
2227 
ReplaceStyles(SwDoc & rSource)2228 void SwDoc::ReplaceStyles( SwDoc& rSource )
2229 {
2230     ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
2231 
2232     CopyFmtArr( *rSource.pCharFmtTbl, *pCharFmtTbl,
2233                 &SwDoc::_MakeCharFmt, *pDfltCharFmt );
2234     CopyFmtArr( *rSource.pFrmFmtTbl, *pFrmFmtTbl,
2235                 &SwDoc::_MakeFrmFmt, *pDfltFrmFmt );
2236     CopyFmtArr( *rSource.pTxtFmtCollTbl, *pTxtFmtCollTbl,
2237                 &SwDoc::_MakeTxtFmtColl, *pDfltTxtFmtColl );
2238 
2239     // und jetzt noch die Seiten-Vorlagen
2240     sal_uInt16 nCnt = rSource.aPageDescs.Count();
2241     if( nCnt )
2242     {
2243         // ein anderes Doc -> Numberformatter muessen gemergt werden
2244         SwTblNumFmtMerge aTNFM( rSource, *this );
2245 
2246         // 1. Schritt alle Formate anlegen (das 0. ueberspringen - Default!)
2247         while( nCnt )
2248         {
2249             SwPageDesc *pSrc = rSource.aPageDescs[ --nCnt ];
2250             if( 0 == ::lcl_FindPageDesc( aPageDescs, pSrc->GetName() ) )
2251                 MakePageDesc( pSrc->GetName() );
2252         }
2253 
2254         // 2. Schritt alle Attribute kopieren, richtige Parents setzen
2255         for( nCnt = rSource.aPageDescs.Count(); nCnt; )
2256         {
2257             SwPageDesc *pSrc = rSource.aPageDescs[ --nCnt ];
2258             CopyPageDesc( *pSrc, *::lcl_FindPageDesc( aPageDescs, pSrc->GetName() ));
2259         }
2260     }
2261 
2262     //JP 08.04.99: und dann sind da noch die Numerierungs-Vorlagen
2263     nCnt = rSource.GetNumRuleTbl().Count();
2264     if( nCnt )
2265     {
2266         const SwNumRuleTbl& rArr = rSource.GetNumRuleTbl();
2267         for( sal_uInt16 n = 0; n < nCnt; ++n )
2268         {
2269             const SwNumRule& rR = *rArr[ n ];
2270             if( !rR.IsAutoRule() )
2271             {
2272                 SwNumRule* pNew = FindNumRulePtr( rR.GetName());
2273                 if( pNew )
2274                     pNew->CopyNumRule( this, rR );
2275                 else
2276                     MakeNumRule( rR.GetName(), &rR );
2277             }
2278         }
2279     }
2280 
2281     if (undoGuard.UndoWasEnabled())
2282     {
2283         // nodes array was modified!
2284         GetIDocumentUndoRedo().DelAllUndoObj();
2285     }
2286 
2287     SetModified();
2288 }
2289 
FindFmtByName(const SvPtrarr & rFmtArr,const String & rName) const2290 SwFmt* SwDoc::FindFmtByName( const SvPtrarr& rFmtArr,
2291                                     const String& rName ) const
2292 {
2293     SwFmt* pFnd = 0;
2294     for( sal_uInt16 n = 0; n < rFmtArr.Count(); n++ )
2295     {
2296         // ist die Vorlage schon im Doc vorhanden ??
2297         if( ((SwFmt*)rFmtArr[n])->GetName() == rName )
2298         {
2299             pFnd = (SwFmt*)rFmtArr[n];
2300             break;
2301         }
2302     }
2303     return pFnd;
2304 }
2305 
MoveLeftMargin(const SwPaM & rPam,sal_Bool bRight,sal_Bool bModulus)2306 void SwDoc::MoveLeftMargin( const SwPaM& rPam, sal_Bool bRight, sal_Bool bModulus )
2307 {
2308     SwHistory* pHistory = 0;
2309     if (GetIDocumentUndoRedo().DoesUndo())
2310     {
2311         SwUndoMoveLeftMargin* pUndo = new SwUndoMoveLeftMargin( rPam, bRight,
2312                                                                 bModulus );
2313         pHistory = &pUndo->GetHistory();
2314         GetIDocumentUndoRedo().AppendUndo( pUndo );
2315     }
2316 
2317     const SvxTabStopItem& rTabItem = (SvxTabStopItem&)GetDefault( RES_PARATR_TABSTOP );
2318     sal_uInt16 nDefDist = rTabItem.Count() ?
2319         static_cast<sal_uInt16>(rTabItem[0].GetTabPos()) : 1134;
2320     const SwPosition &rStt = *rPam.Start(), &rEnd = *rPam.End();
2321     SwNodeIndex aIdx( rStt.nNode );
2322     while( aIdx <= rEnd.nNode )
2323     {
2324         SwTxtNode* pTNd = aIdx.GetNode().GetTxtNode();
2325         if( pTNd )
2326         {
2327             SvxLRSpaceItem aLS( (SvxLRSpaceItem&)pTNd->SwCntntNode::GetAttr( RES_LR_SPACE ) );
2328 
2329             // --> FME 2008-09-16 #i93873# See also lcl_MergeListLevelIndentAsLRSpaceItem in thints.cxx
2330             if ( pTNd->AreListLevelIndentsApplicable() )
2331             {
2332                 const SwNumRule* pRule = pTNd->GetNumRule();
2333                 if ( pRule )
2334                 {
2335                     const int nListLevel = pTNd->GetActualListLevel();
2336                     if ( nListLevel >= 0 )
2337                     {
2338                         const SwNumFmt& rFmt = pRule->Get(static_cast<sal_uInt16>(nListLevel));
2339                         if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2340                         {
2341                             aLS.SetTxtLeft( rFmt.GetIndentAt() );
2342                             aLS.SetTxtFirstLineOfst( static_cast<short>(rFmt.GetFirstLineIndent()) );
2343                         }
2344                     }
2345                 }
2346             }
2347 
2348             long nNext = aLS.GetTxtLeft();
2349             if( bModulus )
2350                 nNext = ( nNext / nDefDist ) * nDefDist;
2351 
2352             if( bRight )
2353                 nNext += nDefDist;
2354             else
2355                 nNext -= nDefDist;
2356 
2357             aLS.SetTxtLeft( nNext );
2358 
2359             SwRegHistory aRegH( pTNd, *pTNd, pHistory );
2360             pTNd->SetAttr( aLS );
2361         }
2362         aIdx++;
2363     }
2364     SetModified();
2365 }
2366 
DontExpandFmt(const SwPosition & rPos,sal_Bool bFlag)2367 sal_Bool SwDoc::DontExpandFmt( const SwPosition& rPos, sal_Bool bFlag )
2368 {
2369     sal_Bool bRet = sal_False;
2370     SwTxtNode* pTxtNd = rPos.nNode.GetNode().GetTxtNode();
2371     if( pTxtNd )
2372     {
2373         bRet = pTxtNd->DontExpandFmt( rPos.nContent, bFlag );
2374         if( bRet && GetIDocumentUndoRedo().DoesUndo() )
2375         {
2376             GetIDocumentUndoRedo().AppendUndo( new SwUndoDontExpandFmt(rPos) );
2377         }
2378     }
2379     return bRet;
2380 }
2381 
MakeTableBoxFmt()2382 SwTableBoxFmt* SwDoc::MakeTableBoxFmt()
2383 {
2384     SwTableBoxFmt* pFmt = new SwTableBoxFmt( GetAttrPool(), aEmptyStr,
2385                                                 pDfltFrmFmt );
2386     SetModified();
2387     return pFmt;
2388 }
2389 
MakeTableLineFmt()2390 SwTableLineFmt* SwDoc::MakeTableLineFmt()
2391 {
2392     SwTableLineFmt* pFmt = new SwTableLineFmt( GetAttrPool(), aEmptyStr,
2393                                                 pDfltFrmFmt );
2394     SetModified();
2395     return pFmt;
2396 }
2397 
_CreateNumberFormatter()2398 void SwDoc::_CreateNumberFormatter()
2399 {
2400     RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722",  "SwDoc::_CreateNumberFormatter" );
2401 
2402     ASSERT( !pNumberFormatter, "ist doch schon vorhanden" );
2403 
2404 
2405     LanguageType eLang = LANGUAGE_SYSTEM; //System::GetLanguage();
2406 /*              ((const SvxLanguageItem&)GetAttrPool().
2407                     GetDefaultItem( RES_CHRATR_LANGUAGE )).GetLanguage();
2408 */
2409     Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
2410     pNumberFormatter = new SvNumberFormatter( xMSF, eLang );
2411     pNumberFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL );
2412     pNumberFormatter->SetYear2000(static_cast<sal_uInt16>(::utl::MiscCfg().GetYear2000()));
2413 
2414 }
2415 
SwTblNumFmtMerge(const SwDoc & rSrc,SwDoc & rDest)2416 SwTblNumFmtMerge::SwTblNumFmtMerge( const SwDoc& rSrc, SwDoc& rDest )
2417     : pNFmt( 0 )
2418 {
2419     // ein anderes Doc -> Numberformatter muessen gemergt werden
2420     SvNumberFormatter* pN;
2421     if( &rSrc != &rDest && 0 != ( pN = ((SwDoc&)rSrc).GetNumberFormatter( sal_False ) ))
2422         ( pNFmt = rDest.GetNumberFormatter( sal_True ))->MergeFormatter( *pN );
2423 
2424     if( &rSrc != &rDest )
2425         ((SwGetRefFieldType*)rSrc.GetSysFldType( RES_GETREFFLD ))->
2426             MergeWithOtherDoc( rDest );
2427 }
2428 
~SwTblNumFmtMerge()2429 SwTblNumFmtMerge::~SwTblNumFmtMerge()
2430 {
2431     if( pNFmt )
2432         pNFmt->ClearMergeTable();
2433 }
2434 
2435 
SetTxtFmtCollByAutoFmt(const SwPosition & rPos,sal_uInt16 nPoolId,const SfxItemSet * pSet)2436 void SwDoc::SetTxtFmtCollByAutoFmt( const SwPosition& rPos, sal_uInt16 nPoolId,
2437                                     const SfxItemSet* pSet )
2438 {
2439     SwPaM aPam( rPos );
2440     SwTxtNode* pTNd = rPos.nNode.GetNode().GetTxtNode();
2441 
2442     if( mbIsAutoFmtRedline && pTNd )
2443     {
2444         // dann das Redline Object anlegen
2445         const SwTxtFmtColl& rColl = *pTNd->GetTxtColl();
2446         SwRedline* pRedl = new SwRedline( nsRedlineType_t::REDLINE_FMTCOLL, aPam );
2447         pRedl->SetMark();
2448 
2449         // interressant sind nur die Items, die vom Set NICHT wieder
2450         // in den Node gesetzt werden. Also muss man die Differenz nehmen
2451         SwRedlineExtraData_FmtColl aExtraData( rColl.GetName(),
2452                                                 rColl.GetPoolFmtId() );
2453         if( pSet && pTNd->HasSwAttrSet() )
2454         {
2455             SfxItemSet aTmp( *pTNd->GetpSwAttrSet() );
2456             aTmp.Differentiate( *pSet );
2457             // das Adjust Item behalten wir extra
2458             const SfxPoolItem* pItem;
2459             if( SFX_ITEM_SET == pTNd->GetpSwAttrSet()->GetItemState(
2460                     RES_PARATR_ADJUST, sal_False, &pItem ))
2461                 aTmp.Put( *pItem );
2462             aExtraData.SetItemSet( aTmp );
2463         }
2464         pRedl->SetExtraData( &aExtraData );
2465 
2466 // !!!!!!!!! Undo fehlt noch !!!!!!!!!!!!!!!!!!
2467         AppendRedline( pRedl, true );
2468     }
2469 
2470     SetTxtFmtColl( aPam, GetTxtCollFromPool( nPoolId ) );
2471 
2472     if( pSet && pTNd && pSet->Count() )
2473     {
2474         aPam.SetMark();
2475         aPam.GetMark()->nContent.Assign( pTNd, pTNd->GetTxt().Len() );
2476         InsertItemSet( aPam, *pSet, 0 );
2477     }
2478 }
2479 
SetFmtItemByAutoFmt(const SwPaM & rPam,const SfxItemSet & rSet)2480 void SwDoc::SetFmtItemByAutoFmt( const SwPaM& rPam, const SfxItemSet& rSet )
2481 {
2482     SwTxtNode* pTNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode();
2483 
2484     RedlineMode_t eOld = GetRedlineMode();
2485 
2486     if( mbIsAutoFmtRedline && pTNd )
2487     {
2488         // dann das Redline Object anlegen
2489         SwRedline* pRedl = new SwRedline( nsRedlineType_t::REDLINE_FORMAT, rPam );
2490         if( !pRedl->HasMark() )
2491             pRedl->SetMark();
2492 
2493         // interressant sind nur die Items, die vom Set NICHT wieder
2494         // in den Node gesetzt werden. Also muss man die Differenz nehmen
2495         SwRedlineExtraData_Format aExtraData( rSet );
2496 
2497 /*
2498         if( pSet && pTNd->HasSwAttrSet() )
2499         {
2500             SfxItemSet aTmp( *pTNd->GetpSwAttrSet() );
2501             aTmp.Differentiate( *pSet );
2502             // das Adjust Item behalten wir extra
2503             const SfxPoolItem* pItem;
2504             if( SFX_ITEM_SET == pTNd->GetpSwAttrSet()->GetItemState(
2505                     RES_PARATR_ADJUST, sal_False, &pItem ))
2506                 aTmp.Put( *pItem );
2507             aExtraData.SetItemSet( aTmp );
2508         }
2509 */
2510         pRedl->SetExtraData( &aExtraData );
2511 
2512 // !!!!!!!!! Undo fehlt noch !!!!!!!!!!!!!!!!!!
2513         AppendRedline( pRedl, true );
2514 
2515         SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
2516     }
2517 
2518     InsertItemSet( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND );
2519     SetRedlineMode_intern( eOld );
2520 }
2521 
ChgFmt(SwFmt & rFmt,const SfxItemSet & rSet)2522 void SwDoc::ChgFmt(SwFmt & rFmt, const SfxItemSet & rSet)
2523 {
2524     if (GetIDocumentUndoRedo().DoesUndo())
2525     {
2526         // copying <rSet> to <aSet>
2527         SfxItemSet aSet(rSet);
2528         // remove from <aSet> all items, which are already set at the format
2529         aSet.Differentiate(rFmt.GetAttrSet());
2530         // <aSet> contains now all *new* items for the format
2531 
2532         // copying current format item set to <aOldSet>
2533         SfxItemSet aOldSet(rFmt.GetAttrSet());
2534         // insert new items into <aOldSet>
2535         aOldSet.Put(aSet);
2536         // invalidate all new items in <aOldSet> in order to clear these items,
2537         // if the undo action is triggered.
2538         {
2539             SfxItemIter aIter(aSet);
2540 
2541             const SfxPoolItem * pItem = aIter.FirstItem();
2542             while (pItem != NULL)
2543             {
2544                 aOldSet.InvalidateItem(pItem->Which());
2545 
2546                 pItem = aIter.NextItem();
2547             }
2548         }
2549 
2550         SwUndo * pUndo = new SwUndoFmtAttr(aOldSet, rFmt);
2551 
2552         GetIDocumentUndoRedo().AppendUndo(pUndo);
2553     }
2554 
2555     rFmt.SetFmtAttr(rSet);
2556 }
2557 
RenameFmt(SwFmt & rFmt,const String & sNewName,sal_Bool bBroadcast)2558 void SwDoc::RenameFmt(SwFmt & rFmt, const String & sNewName,
2559                       sal_Bool bBroadcast)
2560 {
2561     SfxStyleFamily eFamily = SFX_STYLE_FAMILY_ALL;
2562 
2563     if (GetIDocumentUndoRedo().DoesUndo())
2564     {
2565         SwUndo * pUndo = NULL;
2566 
2567         switch (rFmt.Which())
2568         {
2569         case RES_CHRFMT:
2570             pUndo = new SwUndoRenameCharFmt(rFmt.GetName(), sNewName, this);
2571             eFamily = SFX_STYLE_FAMILY_PARA;
2572             break;
2573         case RES_TXTFMTCOLL:
2574             pUndo = new SwUndoRenameFmtColl(rFmt.GetName(), sNewName, this);
2575             eFamily = SFX_STYLE_FAMILY_CHAR;
2576             break;
2577         case RES_FRMFMT:
2578             pUndo = new SwUndoRenameFrmFmt(rFmt.GetName(), sNewName, this);
2579             eFamily = SFX_STYLE_FAMILY_FRAME;
2580             break;
2581 
2582         default:
2583             break;
2584         }
2585 
2586         if (pUndo)
2587         {
2588             GetIDocumentUndoRedo().AppendUndo(pUndo);
2589         }
2590     }
2591 
2592     rFmt.SetName(sNewName);
2593 
2594     if (bBroadcast)
2595         BroadcastStyleOperation(sNewName, eFamily, SFX_STYLESHEET_MODIFIED);
2596 }
2597 
2598 // --> OD 2006-09-27 #i69627#
2599 namespace docfunc
2600 {
HasOutlineStyleToBeWrittenAsNormalListStyle(SwDoc & rDoc)2601     bool HasOutlineStyleToBeWrittenAsNormalListStyle( SwDoc& rDoc )
2602     {
2603         // If a parent paragraph style of one of the parargraph styles, which
2604         // are assigned to the list levels of the outline style, has a list style
2605         // set or inherits a list style from its parent style, the outline style
2606         // has to be written as a normal list style to the OpenDocument file
2607         // format or the OpenOffice.org file format.
2608         bool bRet( false );
2609 
2610         const SwTxtFmtColls* pTxtFmtColls( rDoc.GetTxtFmtColls() );
2611         if ( pTxtFmtColls )
2612         {
2613             const sal_uInt16 nCount = pTxtFmtColls->Count();
2614             for ( sal_uInt16 i = 0; i < nCount; ++i )
2615             {
2616                 SwTxtFmtColl* pTxtFmtColl = (*pTxtFmtColls)[i];
2617 
2618                 if ( pTxtFmtColl->IsDefault() ||
2619                    //  pTxtFmtColl->GetOutlineLevel() == NO_NUMBERING ) //#outline level,zhaojianwei
2620                     ! pTxtFmtColl->IsAssignedToListLevelOfOutlineStyle() )  //<-end,zhaojianwei
2621                 {
2622                     continue;
2623                 }
2624 
2625                 const SwTxtFmtColl* pParentTxtFmtColl =
2626                    dynamic_cast<const SwTxtFmtColl*>( pTxtFmtColl->DerivedFrom());
2627                 if ( !pParentTxtFmtColl )
2628                     continue;
2629 
2630                 if ( SFX_ITEM_SET == pParentTxtFmtColl->GetItemState( RES_PARATR_NUMRULE ) )
2631                 {
2632                     // --> OD 2009-11-12 #i106218#
2633                     // consider that the outline style is set
2634                     const SwNumRuleItem& rDirectItem = pParentTxtFmtColl->GetNumRule();
2635                     if ( rDirectItem.GetValue() != rDoc.GetOutlineNumRule()->GetName() )
2636                     {
2637                         bRet = true;
2638                         break;
2639                     }
2640                     // <--
2641                 }
2642             }
2643 
2644         }
2645         return bRet;
2646     }
2647 }
2648 // <--
2649