1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docfmt.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #define _ZFORLIST_DECLARE_TABLE
36 #define _SVSTDARR_USHORTSSORT
37 #define _SVSTDARR_USHORTS
38 #include <hintids.hxx>
39 #include <rtl/logfile.hxx>
40 #include <svtools/itemiter.hxx>
41 #include <sfx2/app.hxx>
42 #include <svtools/misccfg.hxx>
43 #include <svx/tstpitem.hxx>
44 #include <svx/eeitem.hxx>
45 #include <svx/langitem.hxx>
46 #include <svx/lrspitem.hxx>
47 #include <svx/brkitem.hxx>
48 #include <svtools/whiter.hxx>
49 #ifndef _ZFORLIST_HXX //autogen
50 #define _ZFORLIST_DECLARE_TABLE
51 #include <svtools/zforlist.hxx>
53 #include <comphelper/processfactory.hxx>
54 #include <com/sun/star/i18n/WordType.hdl>
55 #include <fmtpdsc.hxx>
56 #include <fmthdft.hxx>
57 #include <fmtcntnt.hxx>
60 #include <rootfrm.hxx>
61 #include <pagefrm.hxx>
62 #include <hints.hxx> // fuer SwHyphenBug (in SetDefault)
67 #include <pagedesc.hxx> // Fuer Sonderbehandlung in InsFrmFmt
68 #include <rolbck.hxx> // Undo-Attr
69 #include <mvsave.hxx> // servieren: Veraenderungen erkennen
70 #include <txatbase.hxx>
71 #include <swtable.hxx>
72 #include <swtblfmt.hxx>
73 #include <charfmt.hxx>
76 #include <redline.hxx>
78 #include <txtinet.hxx>
79 #include <fmtinfmt.hxx>
80 #include <breakit.hxx>
81 #include <SwStyleNameMapper.hxx>
82 #include <fmtautofmt.hxx>
83 #include <istyleaccess.hxx>
84 #include <SwUndoFmt.hxx>
87 using namespace ::com::sun::star::i18n
;
88 using namespace ::com::sun::star::lang
;
89 using namespace ::com::sun::star::uno
;
91 SV_IMPL_PTRARR(SwFrmFmts
,SwFrmFmtPtr
)
92 SV_IMPL_PTRARR(SwCharFmts
,SwCharFmtPtr
)
94 //Spezifische Frameformate (Rahmen)
95 SV_IMPL_PTRARR(SwSpzFrmFmts
,SwFrmFmtPtr
)
101 BOOL
SetTxtFmtCollNext( const SwTxtFmtCollPtr
& rpTxtColl
, void* pArgs
)
103 SwTxtFmtColl
*pDel
= (SwTxtFmtColl
*) pArgs
;
104 if ( &rpTxtColl
->GetNextTxtFmtColl() == pDel
)
106 rpTxtColl
->SetNextTxtFmtColl( *rpTxtColl
);
112 * Zuruecksetzen der harten Formatierung fuer Text
115 // Uebergabeparameter fuer _Rst und lcl_SetTxtFmtColl
120 const SwPosition
*pSttNd
, *pEndNd
;
121 const SfxItemSet
* pDelSet
;
124 // --> OD 2007-11-06 #i62575#
125 bool bResetListAttrs
;
128 bool bInclRefToxMark
;
130 bool bKeepOutlineLevelAttr
; //#outline level,add by zhaojianwei
132 ParaRstFmt( const SwPosition
* pStt
, const SwPosition
* pEnd
,
133 SwHistory
* pHst
, USHORT nWhch
= 0, const SfxItemSet
* pSet
= 0 )
140 // --> OD 2007-11-06 #i62675#
142 bResetListAttrs( false ),
145 bInclRefToxMark( false ),
146 bKeepOutlineLevelAttr( false ) //#outline level,add by zhaojianwei
149 ParaRstFmt( SwHistory
* pHst
)
156 // --> OD 2007-11-06 #i62675#
158 bResetListAttrs( false ),
161 bInclRefToxMark( false ),
162 bKeepOutlineLevelAttr( false ) //#outline level,add by zhaojianwei
166 /* in pArgs steht die ChrFmtTablle vom Dokument
167 * (wird bei Selectionen am Start/Ende und bei keiner SSelection benoetigt)
170 BOOL
lcl_RstTxtAttr( const SwNodePtr
& rpNd
, void* pArgs
)
172 ParaRstFmt
* pPara
= (ParaRstFmt
*)pArgs
;
173 SwTxtNode
* pTxtNode
= (SwTxtNode
*)rpNd
->GetTxtNode();
174 if( pTxtNode
&& pTxtNode
->GetpSwpHints() )
176 SwIndex
aSt( pTxtNode
, 0 );
177 USHORT nEnd
= pTxtNode
->Len();
179 if( &pPara
->pSttNd
->nNode
.GetNode() == pTxtNode
&&
180 pPara
->pSttNd
->nContent
.GetIndex() )
181 aSt
= pPara
->pSttNd
->nContent
.GetIndex();
183 if( &pPara
->pEndNd
->nNode
.GetNode() == rpNd
)
184 nEnd
= pPara
->pEndNd
->nContent
.GetIndex();
186 if( pPara
->pHistory
)
188 // fuers Undo alle Attribute sichern
189 SwRegHistory
aRHst( *pTxtNode
, pPara
->pHistory
);
190 pTxtNode
->GetpSwpHints()->Register( &aRHst
);
191 pTxtNode
->RstAttr( aSt
, nEnd
- aSt
.GetIndex(), pPara
->nWhich
,
192 pPara
->pDelSet
, pPara
->bInclRefToxMark
);
193 if( pTxtNode
->GetpSwpHints() )
194 pTxtNode
->GetpSwpHints()->DeRegister();
197 pTxtNode
->RstAttr( aSt
, nEnd
- aSt
.GetIndex(), pPara
->nWhich
,
198 pPara
->pDelSet
, pPara
->bInclRefToxMark
);
203 BOOL
lcl_RstAttr( const SwNodePtr
& rpNd
, void* pArgs
)
205 ParaRstFmt
* pPara
= (ParaRstFmt
*)pArgs
;
206 SwCntntNode
* pNode
= (SwCntntNode
*)rpNd
->GetCntntNode();
207 if( pNode
&& pNode
->HasSwAttrSet() )
209 const BOOL bLocked
= pNode
->IsModifyLocked();
212 SwDoc
* pDoc
= pNode
->GetDoc();
214 // --> OD 2008-04-14 #refactorlists#
215 // remove unused attribute RES_LR_SPACE
216 // add list attributes
217 SfxItemSet
aSet( pDoc
->GetAttrPool(),
218 RES_PAGEDESC
, RES_BREAK
,
219 RES_PARATR_NUMRULE
, RES_PARATR_NUMRULE
,
220 RES_PARATR_OUTLINELEVEL
,RES_PARATR_OUTLINELEVEL
,//#outline level,removed by zhaojianwei
221 RES_PARATR_LIST_BEGIN
, RES_PARATR_LIST_END
- 1,
223 const SfxItemSet
* pSet
= pNode
->GetpSwAttrSet();
225 // --> OD 2008-04-15 #refactorlists#
226 // std::vector<USHORT> aClearWhichIds;
227 SvUShorts aClearWhichIds
;
229 // --> OD 2008-04-15 #refactorlists#
230 // restoring all paragraph list attributes
232 SfxItemSet
aListAttrSet( pDoc
->GetAttrPool(),
233 RES_PARATR_LIST_BEGIN
, RES_PARATR_LIST_END
- 1,
235 aListAttrSet
.Set( *pSet
);
236 if ( aListAttrSet
.Count() )
238 aSet
.Put( aListAttrSet
);
239 SfxItemIter
aIter( aListAttrSet
);
240 const SfxPoolItem
* pItem
= aIter
.GetCurItem();
243 aClearWhichIds
.Insert( pItem
->Which(), aClearWhichIds
.Count() );
244 pItem
= aIter
.NextItem();
250 const SfxPoolItem
* pItem
;
251 // USHORT __READONLY_DATA aSavIds[ 3 ] = { RES_PAGEDESC, RES_BREAK, //#outline level,removed by zhaojianwei
252 // RES_PARATR_NUMRULE };
253 //for( USHORT n = 0; n < 3; ++n )
254 USHORT __READONLY_DATA aSavIds
[ 4 ] = { RES_PAGEDESC
, RES_BREAK
, //->add by zhaojianwei
256 RES_PARATR_OUTLINELEVEL
};
257 for( USHORT n
= 0; n
< 4; ++n
) //<-end,zhaojianwei
259 if( SFX_ITEM_SET
== pSet
->GetItemState( aSavIds
[ n
], FALSE
, &pItem
))
262 switch( aSavIds
[ n
] )
265 bSave
= 0 != ((SwFmtPageDesc
*)pItem
)->GetPageDesc();
268 bSave
= SVX_BREAK_NONE
!= ((SvxFmtBreakItem
*)pItem
)->GetBreak();
270 case RES_PARATR_NUMRULE
:
272 bSave
= 0 != ((SwNumRuleItem
*)pItem
)->GetValue().Len();
275 case RES_PARATR_OUTLINELEVEL
: //#outline level,add by zhaojianwei
277 bSave
= pPara
&& pPara
->bKeepOutlineLevelAttr
;
279 break; //<-end,zhaojianwei
284 // --> OD 2008-04-15 #refactorlists#
285 // aClearWhichIds.push_back( aSavIds[n] );
286 aClearWhichIds
.Insert( aSavIds
[n
], aClearWhichIds
.Count() );
291 // --> OD 2008-04-14 #refactorlists#
292 // do not clear items directly from item set and only clear to be kept
293 // attributes, if no deletion item set is found.
294 // pNode->ClearItemsFromAttrSet( aClearWhichIds );
295 const bool bKeepAttributes
=
296 !pPara
|| !pPara
->pDelSet
|| pPara
->pDelSet
->Count() == 0;
297 if ( bKeepAttributes
)
299 pNode
->ResetAttr( aClearWhichIds
);
304 pNode
->UnlockModify();
308 SwRegHistory
aRegH( pNode
, *pNode
, pPara
->pHistory
);
310 if( pPara
->pDelSet
&& pPara
->pDelSet
->Count() )
312 // --> OD 2008-04-15 #refactorlists#
313 ASSERT( !bKeepAttributes
,
314 "<lcl_RstAttr(..)> - certain attributes are kept, but not needed. -> please inform OD" );
316 SfxItemIter
aIter( *pPara
->pDelSet
);
317 pItem
= aIter
.FirstItem();
320 // --> OD 2008-04-14 #refactorlists#
322 if ( ( pItem
->Which() != RES_PAGEDESC
&&
323 pItem
->Which() != RES_BREAK
&&
324 pItem
->Which() != RES_PARATR_NUMRULE
) ||
325 ( aSet
.GetItemState( pItem
->Which(), FALSE
) != SFX_ITEM_SET
) )
327 pNode
->ResetAttr( pItem
->Which() );
330 if( aIter
.IsAtEnd() )
332 pItem
= aIter
.NextItem();
335 else if( pPara
->bResetAll
)
336 pNode
->ResetAllAttr();
338 pNode
->ResetAttr( RES_PARATR_BEGIN
, POOLATTR_END
- 1 );
341 pNode
->ResetAllAttr();
343 // --> OD 2008-04-15 #refactorlists#
344 // only restore saved attributes, if needed
345 if ( bKeepAttributes
&& aSet
.Count() )
350 pNode
->SetAttr( aSet
);
353 pNode
->UnlockModify();
359 void SwDoc::RstTxtAttrs(const SwPaM
&rRg
, BOOL bInclRefToxMark
)
362 SwDataChanged
aTmp( rRg
, 0 );
366 SwUndoResetAttr
* pUndo
= new SwUndoResetAttr( rRg
, RES_CHRFMT
);
367 pHst
= &pUndo
->GetHistory();
370 const SwPosition
*pStt
= rRg
.Start(), *pEnd
= rRg
.End();
371 ParaRstFmt
aPara( pStt
, pEnd
, pHst
);
372 aPara
.bInclRefToxMark
= ( bInclRefToxMark
== TRUE
);
373 GetNodes().ForEach( pStt
->nNode
.GetIndex(), pEnd
->nNode
.GetIndex()+1,
374 lcl_RstTxtAttr
, &aPara
);
378 void SwDoc::ResetAttrs( const SwPaM
&rRg
,
380 const SvUShortsSort
* pAttrs
,
381 // --> OD 2008-11-28 #b96644#
382 const bool bSendDataChangedEvents
)
385 SwPaM
* pPam
= (SwPaM
*)&rRg
;
386 if( !bTxtAttr
&& pAttrs
&& pAttrs
->Count() &&
387 RES_TXTATR_END
> (*pAttrs
)[ 0 ] )
392 SwTxtNode
* pTxtNd
= rRg
.GetPoint()->nNode
.GetNode().GetTxtNode();
396 pPam
= new SwPaM( *rRg
.GetPoint() );
398 SwIndex
& rSt
= pPam
->GetPoint()->nContent
;
399 USHORT nMkPos
, nPtPos
= rSt
.GetIndex();
401 // JP 22.08.96: Sonderfall: steht der Crsr in einem URL-Attribut
402 // dann wird dessen Bereich genommen
403 const SwTxtAttr
* pURLAttr
;
404 if( pTxtNd
->HasHints() &&
405 0 != ( pURLAttr
= pTxtNd
->GetTxtAttr( rSt
, RES_TXTATR_INETFMT
))
406 && pURLAttr
->GetINetFmt().GetValue().Len() )
408 nMkPos
= *pURLAttr
->GetStart();
409 nPtPos
= *pURLAttr
->GetEnd();
414 if( pBreakIt
->GetBreakIter().is() )
415 aBndry
= pBreakIt
->GetBreakIter()->getWordBoundary(
416 pTxtNd
->GetTxt(), nPtPos
,
417 pBreakIt
->GetLocale( pTxtNd
->GetLang( nPtPos
) ),
418 WordType::ANY_WORD
/*ANYWORD_IGNOREWHITESPACES*/,
421 if( aBndry
.startPos
< nPtPos
&& nPtPos
< aBndry
.endPos
)
423 nMkPos
= (xub_StrLen
)aBndry
.startPos
;
424 nPtPos
= (xub_StrLen
)aBndry
.endPos
;
428 nPtPos
= nMkPos
= rSt
.GetIndex();
430 pTxtNd
->DontExpandFmt( rSt
, TRUE
);
436 pPam
->GetPoint()->nContent
= nPtPos
;
439 // --> OD 2008-11-28 #i96644#
440 // SwDataChanged aTmp( *pPam, 0 );
441 std::auto_ptr
< SwDataChanged
> pDataChanged
;
442 if ( bSendDataChangedEvents
)
444 pDataChanged
.reset( new SwDataChanged( *pPam
, 0 ) );
451 SwUndoResetAttr
* pUndo
= new SwUndoResetAttr( rRg
,
452 static_cast<USHORT
>(bTxtAttr
? RES_CONDTXTFMTCOLL
: RES_TXTFMTCOLL
));
453 if( pAttrs
&& pAttrs
->Count() )
455 pUndo
->SetAttrs( *pAttrs
);
457 pHst
= &pUndo
->GetHistory();
461 const SwPosition
*pStt
= pPam
->Start(), *pEnd
= pPam
->End();
462 ParaRstFmt
aPara( pStt
, pEnd
, pHst
);
464 USHORT __FAR_DATA aResetableSetRange
[] = {
465 RES_FRMATR_BEGIN
, RES_FRMATR_END
-1,
466 RES_CHRATR_BEGIN
, RES_CHRATR_END
-1,
467 RES_PARATR_BEGIN
, RES_PARATR_END
-1,
468 // --> OD 2008-02-25 #refactorlists#
469 RES_PARATR_LIST_BEGIN
, RES_PARATR_LIST_END
-1,
471 RES_TXTATR_CHARFMT
, RES_TXTATR_CHARFMT
,
472 RES_TXTATR_INETFMT
, RES_TXTATR_INETFMT
,
473 RES_TXTATR_CJK_RUBY
, RES_TXTATR_UNKNOWN_CONTAINER
,
474 RES_UNKNOWNATR_BEGIN
, RES_UNKNOWNATR_END
-1,
478 SfxItemSet
aDelSet( GetAttrPool(), aResetableSetRange
);
479 if( pAttrs
&& pAttrs
->Count() )
481 for( USHORT n
= pAttrs
->Count(); n
; )
482 if( POOLATTR_END
> (*pAttrs
)[ --n
] )
483 aDelSet
.Put( *GetDfltAttr( (*pAttrs
)[ n
] ));
485 if( aDelSet
.Count() )
486 aPara
.pDelSet
= &aDelSet
;
490 SwNodeIndex
aTmpStt( pStt
->nNode
);
491 SwNodeIndex
aTmpEnd( pEnd
->nNode
);
492 if( pStt
->nContent
.GetIndex() ) // nur ein Teil
494 // dann spaeter aufsetzen und alle CharFmtAttr -> TxtFmtAttr
495 SwTxtNode
* pTNd
= aTmpStt
.GetNode().GetTxtNode();
496 if( pTNd
&& pTNd
->HasSwAttrSet() && pTNd
->GetpSwAttrSet()->Count() )
498 SfxItemIter
aIter( *pTNd
->GetpSwAttrSet() );
499 const SfxPoolItem
* pItem
= aIter
.GetCurItem();
500 SfxItemSet
aCharSet( GetAttrPool(), RES_CHRATR_BEGIN
, RES_CHRATR_END
);
504 if( IsInRange( aCharFmtSetRange
, pItem
->Which() ))
506 pTNd
->GetOrCreateSwpHints();
508 aCharSet
.Put( *pItem
);
512 SwRegHistory
aRegH( pTNd
, *pTNd
, pHst
);
513 pTNd
->ResetAttr( pItem
->Which() );
516 pTNd
->ResetAttr( pItem
->Which() );
518 if( aIter
.IsAtEnd() )
520 pItem
= aIter
.NextItem();
523 if ( aCharSet
.Count() )
527 SwRegHistory( pTNd
, aCharSet
, 0, pTNd
->GetTxt().Len(), nsSetAttrMode::SETATTR_NOFORMATATTR
, pHst
);
531 SwTxtAttr
* pNew
= pTNd
->MakeTxtAttr( aCharSet
, 0, pTNd
->GetTxt().Len() );
532 pTNd
->Insert( pNew
);
539 if( pEnd
->nContent
.GetIndex() == pEnd
->nNode
.GetNode().GetCntntNode()->Len() )
540 // dann spaeter aufsetzen und alle CharFmtAttr -> TxtFmtAttr
541 aTmpEnd
++, bAdd
= FALSE
;
542 else if( pStt
->nNode
!= pEnd
->nNode
|| !pStt
->nContent
.GetIndex() )
544 SwTxtNode
* pTNd
= aTmpEnd
.GetNode().GetTxtNode();
545 if( pTNd
&& pTNd
->HasSwAttrSet() && pTNd
->GetpSwAttrSet()->Count() )
547 SfxItemIter
aIter( *pTNd
->GetpSwAttrSet() );
548 const SfxPoolItem
* pItem
= aIter
.GetCurItem();
551 if( IsInRange( aCharFmtSetRange
, pItem
->Which() ))
553 SwTxtAttr
* pTAttr
= pTNd
->MakeTxtAttr( *pItem
, 0,
554 pTNd
->GetTxt().Len() );
555 SwpHints
& rHints
= pTNd
->GetOrCreateSwpHints();
556 rHints
.SwpHintsArray::Insert( pTAttr
);
559 SwRegHistory
aRegH( pTNd
, *pTNd
, pHst
);
560 pTNd
->ResetAttr( pItem
->Which() );
561 pHst
->Add( pTAttr
, aTmpEnd
.GetIndex(), true );
564 pTNd
->ResetAttr( pItem
->Which() );
566 if( aIter
.IsAtEnd() )
568 pItem
= aIter
.NextItem();
573 if( aTmpStt
< aTmpEnd
)
574 GetNodes().ForEach( pStt
->nNode
, aTmpEnd
, lcl_RstAttr
, &aPara
);
575 else if( !rRg
.HasMark() )
577 aPara
.bResetAll
= false ;
578 ::lcl_RstAttr( &pStt
->nNode
.GetNode(), &aPara
);
579 aPara
.bResetAll
= true ;
586 GetNodes().ForEach( pStt
->nNode
, aTmpEnd
, lcl_RstTxtAttr
, &aPara
);
595 #define DELETECHARSETS if ( bDelete ) { delete pCharSet; delete pOtherSet; }
597 // Einfuegen der Hints nach Inhaltsformen;
598 // wird in SwDoc::Insert(..., SwFmtHint &rHt) benutzt
600 BOOL
InsAttr( SwDoc
*pDoc
, const SwPaM
&rRg
, const SfxItemSet
& rChgSet
,
601 USHORT nFlags
, SwUndoAttr
* pUndo
)
603 // teil die Sets auf (fuer Selektion in Nodes)
604 const SfxItemSet
* pCharSet
= 0;
605 const SfxItemSet
* pOtherSet
= 0;
606 bool bDelete
= false;
607 bool bCharAttr
= false;
608 bool bOtherAttr
= false;
610 // Check, if we can work with rChgSet or if we have to create additional SfxItemSets
611 if ( 1 == rChgSet
.Count() )
613 SfxItemIter
aIter( rChgSet
);
614 const SfxPoolItem
* pItem
= aIter
.FirstItem();
615 const USHORT nWhich
= pItem
->Which();
617 if ( isCHRATR(nWhich
) ||
618 (RES_TXTATR_CHARFMT
== nWhich
) ||
619 (RES_TXTATR_INETFMT
== nWhich
) ||
620 (RES_TXTATR_AUTOFMT
== nWhich
) ||
621 isUNKNOWNATR(nWhich
) )
627 if ( isPARATR(nWhich
)
628 // --> OD 2008-02-25 #refactorlists#
629 || isPARATR_LIST(nWhich
)
632 || isGRFATR(nWhich
) )
634 pOtherSet
= &rChgSet
;
639 // Build new itemset if either
640 // - rChgSet.Count() > 1 or
641 // - The attribute in rChgSet does not belong to one of the above categories
642 if ( !bCharAttr
&& !bOtherAttr
)
644 SfxItemSet
* pTmpCharItemSet
= new SfxItemSet( pDoc
->GetAttrPool(),
645 RES_CHRATR_BEGIN
, RES_CHRATR_END
-1,
646 RES_TXTATR_AUTOFMT
, RES_TXTATR_AUTOFMT
,
647 RES_TXTATR_INETFMT
, RES_TXTATR_INETFMT
,
648 RES_TXTATR_CHARFMT
, RES_TXTATR_CHARFMT
,
649 RES_UNKNOWNATR_BEGIN
, RES_UNKNOWNATR_END
-1,
652 SfxItemSet
* pTmpOtherItemSet
= new SfxItemSet( pDoc
->GetAttrPool(),
653 RES_PARATR_BEGIN
, RES_PARATR_END
-1,
654 // --> OD 2008-02-25 #refactorlists#
655 RES_PARATR_LIST_BEGIN
, RES_PARATR_LIST_END
-1,
657 RES_FRMATR_BEGIN
, RES_FRMATR_END
-1,
658 RES_GRFATR_BEGIN
, RES_GRFATR_END
-1,
661 pTmpCharItemSet
->Put( rChgSet
);
662 pTmpOtherItemSet
->Put( rChgSet
);
664 pCharSet
= pTmpCharItemSet
;
665 pOtherSet
= pTmpOtherItemSet
;
670 SwHistory
* pHistory
= pUndo
? &pUndo
->GetHistory() : 0;
672 const SwPosition
*pStt
= rRg
.Start(), *pEnd
= rRg
.End();
673 SwCntntNode
* pNode
= pStt
->nNode
.GetNode().GetCntntNode();
675 if( pNode
&& pNode
->IsTxtNode() )
678 if (rRg
.IsInFrontOfLabel())
680 SwTxtNode
* pTxtNd
= pNode
->GetTxtNode();
681 SwNumRule
* pNumRule
= pTxtNd
->GetNumRule();
683 // --> OD 2005-10-24 #126346# - make code robust:
687 "<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect, please inform OD." );
693 SwNumFmt aNumFmt
= pNumRule
->Get(static_cast<USHORT
>(pTxtNd
->GetActualListLevel()));
694 SwCharFmt
* pCharFmt
=
695 pDoc
->FindCharFmtByName(aNumFmt
.GetCharFmtName());
700 pHistory
->Add(pCharFmt
->GetAttrSet(), *pCharFmt
);
703 pCharFmt
->SetFmtAttr(*pCharSet
);
711 const SwIndex
& rSt
= pStt
->nContent
;
713 // Attribute ohne Ende haben keinen Bereich
714 if ( !bCharAttr
&& !bOtherAttr
)
716 SfxItemSet
aTxtSet( pDoc
->GetAttrPool(),
717 RES_TXTATR_NOEND_BEGIN
, RES_TXTATR_NOEND_END
-1 );
718 aTxtSet
.Put( rChgSet
);
719 if( aTxtSet
.Count() )
721 SwRegHistory( (SwTxtNode
*)pNode
, aTxtSet
, rSt
.GetIndex(),
722 rSt
.GetIndex(), nFlags
, pHistory
);
725 if( pDoc
->IsRedlineOn() || (!pDoc
->IsIgnoreRedline() &&
726 pDoc
->GetRedlineTbl().Count() ))
728 SwPaM
aPam( pStt
->nNode
, pStt
->nContent
.GetIndex()-1,
729 pStt
->nNode
, pStt
->nContent
.GetIndex() );
732 pUndo
->SaveRedlineData( aPam
, TRUE
);
734 if( pDoc
->IsRedlineOn() )
735 pDoc
->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT
, aPam
), true);
737 pDoc
->SplitRedline( aPam
);
742 // TextAttribute mit Ende expandieren nie ihren Bereich
743 if ( !bCharAttr
&& !bOtherAttr
)
745 // CharFmt wird gesondert behandelt !!!
746 // JP 22.08.96: URL-Attribute auch!!
747 // TEST_TEMP ToDo: AutoFmt!
748 SfxItemSet
aTxtSet( pDoc
->GetAttrPool(),
749 RES_TXTATR_REFMARK
, RES_TXTATR_TOXMARK
,
750 RES_TXTATR_DUMMY5
, RES_TXTATR_WITHEND_END
-1,
753 aTxtSet
.Put( rChgSet
);
754 if( aTxtSet
.Count() )
756 USHORT nInsCnt
= rSt
.GetIndex();
757 USHORT nEnd
= pStt
->nNode
== pEnd
->nNode
758 ? pEnd
->nContent
.GetIndex()
760 SwRegHistory( (SwTxtNode
*)pNode
, aTxtSet
, nInsCnt
,
761 nEnd
, nFlags
, pHistory
);
764 if( pDoc
->IsRedlineOn() || (!pDoc
->IsIgnoreRedline() &&
765 pDoc
->GetRedlineTbl().Count() ) )
767 // wurde Text-Inhalt eingefuegt? (RefMark/TOXMarks ohne Ende)
768 BOOL bTxtIns
= nInsCnt
!= rSt
.GetIndex();
769 // wurde Inhalt eingefuegt oder ueber die Selektion gesetzt?
770 SwPaM
aPam( pStt
->nNode
, bTxtIns
? nInsCnt
+ 1 : nEnd
,
771 pStt
->nNode
, nInsCnt
);
773 pUndo
->SaveRedlineData( aPam
, bTxtIns
);
775 if( pDoc
->IsRedlineOn() )
776 pDoc
->AppendRedline( new SwRedline( bTxtIns
777 ? nsRedlineType_t::REDLINE_INSERT
: nsRedlineType_t::REDLINE_FORMAT
, aPam
), true);
779 pDoc
->SplitRedline( aPam
);
785 // bei PageDesc's, die am Node gesetzt werden, muss immer das
786 // Auto-Flag gesetzt werden!!
787 const SvxLRSpaceItem
* pLRSpace
= 0;
788 if( pOtherSet
&& pOtherSet
->Count() )
791 const SwFmtPageDesc
* pDesc
;
792 if( SFX_ITEM_SET
== pOtherSet
->GetItemState( RES_PAGEDESC
,
793 FALSE
, (const SfxPoolItem
**)&pDesc
))
797 // Auto-Flag setzen, nur in Vorlagen ist ohne Auto !
798 SwFmtPageDesc
aNew( *pDesc
);
799 // Bug 38479: AutoFlag wird jetzt in der WrtShell gesetzt
802 // Tabellen kennen jetzt auch Umbrueche
803 if( 0 == (nFlags
& nsSetAttrMode::SETATTR_APICALL
) &&
804 0 != ( pTblNd
= pNode
->FindTableNode() ) )
806 SwTableNode
* pCurTblNd
= pTblNd
;
807 while ( 0 != ( pCurTblNd
= pCurTblNd
->StartOfSectionNode()->FindTableNode() ) )
810 // dann am Tabellen Format setzen
811 SwFrmFmt
* pFmt
= pTblNd
->GetTable().GetFrmFmt();
812 SwRegHistory
aRegH( pFmt
, *pTblNd
, pHistory
);
813 pFmt
->SetFmtAttr( aNew
);
817 SwRegHistory
aRegH( pNode
, *pNode
, pHistory
);
818 pNode
->SetAttr( aNew
);
822 // bOtherAttr = true means that pOtherSet == rChgSet. In this case
823 // we know, that there is only one attribute in pOtherSet. We cannot
824 // perform the following operations, instead we return:
828 const_cast<SfxItemSet
*>(pOtherSet
)->ClearItem( RES_PAGEDESC
);
829 if( !pOtherSet
->Count() )
836 // Tabellen kennen jetzt auch Umbrueche
837 const SvxFmtBreakItem
* pBreak
;
838 if( pNode
&& 0 == (nFlags
& nsSetAttrMode::SETATTR_APICALL
) &&
839 0 != (pTblNd
= pNode
->FindTableNode() ) &&
840 SFX_ITEM_SET
== pOtherSet
->GetItemState( RES_BREAK
,
841 FALSE
, (const SfxPoolItem
**)&pBreak
) )
843 SwTableNode
* pCurTblNd
= pTblNd
;
844 while ( 0 != ( pCurTblNd
= pCurTblNd
->StartOfSectionNode()->FindTableNode() ) )
847 // dann am Tabellen Format setzen
848 SwFrmFmt
* pFmt
= pTblNd
->GetTable().GetFrmFmt();
849 SwRegHistory
aRegH( pFmt
, *pTblNd
, pHistory
);
850 pFmt
->SetFmtAttr( *pBreak
);
852 // bOtherAttr = true means that pOtherSet == rChgSet. In this case
853 // we know, that there is only one attribute in pOtherSet. We cannot
854 // perform the following operations, instead we return:
858 const_cast<SfxItemSet
*>(pOtherSet
)->ClearItem( RES_BREAK
);
859 if( !pOtherSet
->Count() )
866 // fuer Sonderbehandlung von LR-Space innerhalb einer Numerierung !!!
867 pOtherSet
->GetItemState( RES_LR_SPACE
, FALSE
,
868 (const SfxPoolItem
**)&pLRSpace
);
871 // wenns eine PoolNumRule ist, diese ggfs. anlegen
872 const SwNumRuleItem
* pRule
;
874 if( SFX_ITEM_SET
== pOtherSet
->GetItemState( RES_PARATR_NUMRULE
,
875 FALSE
, (const SfxPoolItem
**)&pRule
) &&
876 !pDoc
->FindNumRulePtr( pRule
->GetValue() ) &&
877 USHRT_MAX
!= (nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName ( pRule
->GetValue(),
878 nsSwGetPoolIdFromName::GET_POOLID_NUMRULE
)) )
879 pDoc
->GetNumRuleFromPool( nPoolId
);
884 if( !rRg
.HasMark() ) // kein Bereich
892 if( pNode
->IsTxtNode() && pCharSet
&& pCharSet
->Count() )
894 SwTxtNode
* pTxtNd
= (SwTxtNode
*)pNode
;
895 const SwIndex
& rSt
= pStt
->nContent
;
896 USHORT nMkPos
, nPtPos
= rSt
.GetIndex();
897 const String
& rStr
= pTxtNd
->GetTxt();
899 // JP 22.08.96: Sonderfall: steht der Crsr in einem URL-Attribut
900 // dann wird dessen Bereich genommen
901 const SwTxtAttr
* pURLAttr
;
902 if( pTxtNd
->HasHints() &&
903 0 != ( pURLAttr
= pTxtNd
->GetTxtAttr( rSt
, RES_TXTATR_INETFMT
))
904 && pURLAttr
->GetINetFmt().GetValue().Len() )
906 nMkPos
= *pURLAttr
->GetStart();
907 nPtPos
= *pURLAttr
->GetEnd();
912 if( pBreakIt
->GetBreakIter().is() )
913 aBndry
= pBreakIt
->GetBreakIter()->getWordBoundary(
914 pTxtNd
->GetTxt(), nPtPos
,
915 pBreakIt
->GetLocale( pTxtNd
->GetLang( nPtPos
) ),
916 WordType::ANY_WORD
/*ANYWORD_IGNOREWHITESPACES*/,
919 if( aBndry
.startPos
< nPtPos
&& nPtPos
< aBndry
.endPos
)
921 nMkPos
= (xub_StrLen
)aBndry
.startPos
;
922 nPtPos
= (xub_StrLen
)aBndry
.endPos
;
925 nPtPos
= nMkPos
= rSt
.GetIndex();
928 // erstmal die zu ueberschreibenden Attribute aus dem
929 // SwpHintsArray entfernen, wenn die Selektion den gesamten
930 // Absatz umspannt. (Diese Attribute werden als FormatAttr.
931 // eingefuegt und verdraengen nie die TextAttr.!)
932 if( !(nFlags
& nsSetAttrMode::SETATTR_DONTREPLACE
) &&
933 pTxtNd
->HasHints() && !nMkPos
&& nPtPos
== rStr
.Len() )
935 SwIndex
aSt( pTxtNd
);
938 // fuers Undo alle Attribute sichern
939 SwRegHistory
aRHst( *pTxtNd
, pHistory
);
940 pTxtNd
->GetpSwpHints()->Register( &aRHst
);
941 pTxtNd
->RstAttr( aSt
, nPtPos
, 0, pCharSet
);
942 if( pTxtNd
->GetpSwpHints() )
943 pTxtNd
->GetpSwpHints()->DeRegister();
946 pTxtNd
->RstAttr( aSt
, nPtPos
, 0, pCharSet
);
949 // eintragen des Attributes im Node erledigt die SwRegHistory !!
950 SwRegHistory( (SwTxtNode
*)pNode
, *pCharSet
,
951 nMkPos
, nPtPos
, nFlags
, pHistory
);
954 if( pDoc
->IsRedlineOn() )
956 SwPaM
aPam( *pNode
, nMkPos
, *pNode
, nPtPos
);
959 pUndo
->SaveRedlineData( aPam
, FALSE
);
960 pDoc
->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_FORMAT
, aPam
), true);
963 if( pOtherSet
&& pOtherSet
->Count() )
965 SwRegHistory
aRegH( pNode
, *pNode
, pHistory
);
966 pNode
->SetAttr( *pOtherSet
);
974 if( pDoc
->IsRedlineOn() && pCharSet
&& pCharSet
->Count() )
977 pUndo
->SaveRedlineData( rRg
, FALSE
);
978 pDoc
->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_FORMAT
, rRg
), true);
981 /* jetzt wenn Bereich */
984 SwNodeIndex
aSt( pDoc
->GetNodes() );
985 SwNodeIndex
aEnd( pDoc
->GetNodes() );
986 SwIndex
aCntEnd( pEnd
->nContent
);
990 USHORT nLen
= pNode
->Len();
991 if( pStt
->nNode
!= pEnd
->nNode
)
992 aCntEnd
.Assign( pNode
, nLen
);
994 if( pStt
->nContent
.GetIndex() != 0 || aCntEnd
.GetIndex() != nLen
)
996 // eintragen des Attributes im Node erledigt die SwRegHistory !!
997 if( pNode
->IsTxtNode() && pCharSet
&& pCharSet
->Count() )
999 SwRegHistory( (SwTxtNode
*)pNode
, *pCharSet
,
1000 pStt
->nContent
.GetIndex(), aCntEnd
.GetIndex(),
1004 if( pOtherSet
&& pOtherSet
->Count() )
1006 SwRegHistory
aRegH( pNode
, *pNode
, pHistory
);
1007 pNode
->SetAttr( *pOtherSet
);
1010 // lediglich Selektion in einem Node.
1011 if( pStt
->nNode
== pEnd
->nNode
)
1017 aSt
.Assign( pStt
->nNode
.GetNode(), +1 );
1021 aCntEnd
= pEnd
->nContent
; // aEnd wurde veraendert !!
1024 aSt
.Assign( pStt
->nNode
.GetNode(), +1 );
1026 // aSt zeigt jetzt auf den ersten vollen Node
1029 * die Selektion umfasst mehr als einen Node
1031 if( pStt
->nNode
< pEnd
->nNode
)
1033 pNode
= pEnd
->nNode
.GetNode().GetCntntNode();
1036 USHORT nLen
= pNode
->Len();
1037 if( aCntEnd
.GetIndex() != nLen
)
1039 // eintragen des Attributes im Node erledigt die SwRegHistory !!
1040 if( pNode
->IsTxtNode() && pCharSet
&& pCharSet
->Count() )
1042 SwRegHistory( (SwTxtNode
*)pNode
, *pCharSet
,
1043 0, aCntEnd
.GetIndex(), nFlags
, pHistory
);
1046 if( pOtherSet
&& pOtherSet
->Count() )
1048 SwRegHistory
aRegH( pNode
, *pNode
, pHistory
);
1049 pNode
->SetAttr( *pOtherSet
);
1056 aEnd
.Assign( pEnd
->nNode
.GetNode(), +1 );
1062 aEnd
.Assign( pEnd
->nNode
.GetNode(), +1 );
1064 // aEnd zeigt jetzt HINTER den letzten voll Node
1066 /* Bearbeitung der vollstaendig selektierten Nodes. */
1067 // alle Attribute aus dem Set zuruecksetzen !!
1068 if( pCharSet
&& pCharSet
->Count() && !( nsSetAttrMode::SETATTR_DONTREPLACE
& nFlags
) )
1071 ParaRstFmt
aPara( pStt
, pEnd
, pHistory
, 0, pCharSet
);
1072 pDoc
->GetNodes().ForEach( aSt
, aEnd
, lcl_RstTxtAttr
, &aPara
);
1075 BOOL bCreateSwpHints
= pCharSet
&& (
1076 SFX_ITEM_SET
== pCharSet
->GetItemState( RES_TXTATR_CHARFMT
, FALSE
) ||
1077 SFX_ITEM_SET
== pCharSet
->GetItemState( RES_TXTATR_INETFMT
, FALSE
) );
1079 for(; aSt
< aEnd
; aSt
++ )
1081 pNode
= aSt
.GetNode().GetCntntNode();
1085 SwTxtNode
* pTNd
= pNode
->GetTxtNode();
1088 SwRegHistory
aRegH( pNode
, *pNode
, pHistory
);
1089 SwpHints
*pSwpHints
;
1091 if( pTNd
&& pCharSet
&& pCharSet
->Count() )
1093 pSwpHints
= bCreateSwpHints
? &pTNd
->GetOrCreateSwpHints()
1094 : pTNd
->GetpSwpHints();
1096 pSwpHints
->Register( &aRegH
);
1098 pTNd
->SetAttr( *pCharSet
, 0, pTNd
->GetTxt().Len(), nFlags
);
1100 pSwpHints
->DeRegister();
1102 if( pOtherSet
&& pOtherSet
->Count() )
1103 pNode
->SetAttr( *pOtherSet
);
1107 if( pTNd
&& pCharSet
&& pCharSet
->Count() )
1108 pTNd
->SetAttr( *pCharSet
, 0, pTNd
->GetTxt().Len(), nFlags
);
1109 if( pOtherSet
&& pOtherSet
->Count() )
1110 pNode
->SetAttr( *pOtherSet
);
1120 bool SwDoc::Insert( const SwPaM
&rRg
, const SfxPoolItem
&rHt
, USHORT nFlags
)
1122 SwDataChanged
aTmp( rRg
, 0 );
1124 SwUndoAttr
* pUndoAttr
= 0;
1128 pUndoAttr
= new SwUndoAttr( rRg
, rHt
, nFlags
);
1131 SfxItemSet
aSet( GetAttrPool(), rHt
.Which(), rHt
.Which() );
1133 bRet
= InsAttr( this, rRg
, aSet
, nFlags
, pUndoAttr
);
1136 AppendUndo( pUndoAttr
);
1143 bool SwDoc::Insert( const SwPaM
&rRg
, const SfxItemSet
&rSet
, USHORT nFlags
)
1145 SwDataChanged
aTmp( rRg
, 0 );
1146 SwUndoAttr
* pUndoAttr
= 0;
1150 pUndoAttr
= new SwUndoAttr( rRg
, rSet
);
1153 BOOL bRet
= InsAttr( this, rRg
, rSet
, nFlags
, pUndoAttr
);
1156 AppendUndo( pUndoAttr
);
1164 // Setze das Attribut im angegebenen Format. Ist Undo aktiv, wird
1165 // das alte in die Undo-History aufgenommen
1166 void SwDoc::SetAttr( const SfxPoolItem
& rAttr
, SwFmt
& rFmt
)
1168 SfxItemSet
aSet( GetAttrPool(), rAttr
.Which(), rAttr
.Which() );
1170 SetAttr( aSet
, rFmt
);
1174 // Setze das Attribut im angegebenen Format. Ist Undo aktiv, wird
1175 // das alte in die Undo-History aufgenommen
1176 void SwDoc::SetAttr( const SfxItemSet
& rSet
, SwFmt
& rFmt
)
1181 SwUndoFmtAttrHelper
aTmp( rFmt
);
1182 rFmt
.SetFmtAttr( rSet
);
1183 if ( aTmp
.GetUndo() )
1185 AppendUndo( aTmp
.ReleaseUndo() );
1190 rFmt
.SetFmtAttr( rSet
);
1195 // --> OD 2008-02-12 #newlistlevelattrs#
1196 void SwDoc::ResetAttrAtFormat( const USHORT nWhichId
,
1197 SwFmt
& rChangedFormat
)
1201 pUndo
= new SwUndoFmtResetAttr( rChangedFormat
, nWhichId
);
1203 const BOOL bAttrReset
= rChangedFormat
.ResetFmtAttr( nWhichId
);
1208 AppendUndo( pUndo
);
1217 int lcl_SetNewDefTabStops( SwTwips nOldWidth
, SwTwips nNewWidth
,
1218 SvxTabStopItem
& rChgTabStop
)
1220 // dann aender bei allen TabStop die default's auf den neuen Wert
1221 // !!! Achtung: hier wird immer auf dem PoolAttribut gearbeitet,
1222 // damit nicht in allen Sets die gleiche Berechnung
1223 // auf dem gleichen TabStop (gepoolt!) vorgenommen
1224 // wird. Als Modify wird ein FmtChg verschickt.
1226 USHORT nOldCnt
= rChgTabStop
.Count();
1227 if( !nOldCnt
|| nOldWidth
== nNewWidth
)
1230 // suche den Anfang der Defaults
1231 SvxTabStop
* pTabs
= ((SvxTabStop
*)rChgTabStop
.GetStart())
1235 for( n
= nOldCnt
; n
; --n
, --pTabs
)
1236 if( SVX_TAB_ADJUST_DEFAULT
!= pTabs
->GetAdjustment() )
1239 if( n
< nOldCnt
) // die DefTabStops loeschen
1240 rChgTabStop
.Remove( n
, nOldCnt
- n
);
1244 // Setze das Attribut als neues default Attribut in diesem Dokument.
1245 // Ist Undo aktiv, wird das alte in die Undo-History aufgenommen
1246 void SwDoc::SetDefault( const SfxPoolItem
& rAttr
)
1248 SfxItemSet
aSet( GetAttrPool(), rAttr
.Which(), rAttr
.Which() );
1253 void SwDoc::SetDefault( const SfxItemSet
& rSet
)
1258 SwModify
aCallMod( 0 );
1259 SwAttrSet
aOld( GetAttrPool(), rSet
.GetRanges() ),
1260 aNew( GetAttrPool(), rSet
.GetRanges() );
1261 SfxItemIter
aIter( rSet
);
1263 const SfxPoolItem
* pItem
= aIter
.GetCurItem();
1264 SfxItemPool
* pSdrPool
= GetAttrPool().GetSecondaryPool();
1267 BOOL bCheckSdrDflt
= FALSE
;
1268 nWhich
= pItem
->Which();
1269 aOld
.Put( GetAttrPool().GetDefaultItem( nWhich
) );
1270 GetAttrPool().SetPoolDefaultItem( *pItem
);
1271 aNew
.Put( GetAttrPool().GetDefaultItem( nWhich
) );
1273 if (isCHRATR(nWhich
) || isTXTATR(nWhich
))
1275 aCallMod
.Add( pDfltTxtFmtColl
);
1276 aCallMod
.Add( pDfltCharFmt
);
1277 bCheckSdrDflt
= 0 != pSdrPool
;
1279 else if ( isPARATR(nWhich
) ||
1280 // --> OD 2008-02-25 #refactorlists#
1281 isPARATR_LIST(nWhich
) )
1284 aCallMod
.Add( pDfltTxtFmtColl
);
1285 bCheckSdrDflt
= 0 != pSdrPool
;
1287 else if (isGRFATR(nWhich
))
1289 aCallMod
.Add( pDfltGrfFmtColl
);
1291 else if (isFRMATR(nWhich
))
1293 aCallMod
.Add( pDfltGrfFmtColl
);
1294 aCallMod
.Add( pDfltTxtFmtColl
);
1295 aCallMod
.Add( pDfltFrmFmt
);
1297 else if (isBOXATR(nWhich
))
1299 aCallMod
.Add( pDfltFrmFmt
);
1302 // copy also the defaults
1305 USHORT nEdtWhich
, nSlotId
;
1306 if( 0 != (nSlotId
= GetAttrPool().GetSlotId( nWhich
) ) &&
1307 nSlotId
!= nWhich
&&
1308 0 != (nEdtWhich
= pSdrPool
->GetWhich( nSlotId
)) &&
1309 nSlotId
!= nEdtWhich
)
1311 SfxPoolItem
* pCpy
= pItem
->Clone();
1312 pCpy
->SetWhich( nEdtWhich
);
1313 pSdrPool
->SetPoolDefaultItem( *pCpy
);
1318 if( aIter
.IsAtEnd() )
1320 pItem
= aIter
.NextItem();
1323 if( aNew
.Count() && aCallMod
.GetDepends() )
1328 AppendUndo( new SwUndoDefaultAttr( aOld
) );
1331 const SfxPoolItem
* pTmpItem
;
1332 if( ( SFX_ITEM_SET
==
1333 aNew
.GetItemState( RES_PARATR_TABSTOP
, FALSE
, &pTmpItem
) ) &&
1334 ((SvxTabStopItem
*)pTmpItem
)->Count() )
1336 // TabStop-Aenderungen behandeln wir erstmal anders:
1337 // dann aender bei allen TabStop die dafault's auf den neuen Wert
1338 // !!! Achtung: hier wird immer auf dem PoolAttribut gearbeitet,
1339 // damit nicht in allen Sets die gleiche Berechnung
1340 // auf dem gleichen TabStop (gepoolt!) vorgenommen
1341 // wird. Als Modify wird ein FmtChg verschickt.
1342 SwTwips nNewWidth
= (*(SvxTabStopItem
*)pTmpItem
)[ 0 ].GetTabPos(),
1343 nOldWidth
= ((SvxTabStopItem
&)aOld
.Get(RES_PARATR_TABSTOP
))[ 0 ].GetTabPos();
1346 USHORT nMaxItems
= GetAttrPool().GetItemCount( RES_PARATR_TABSTOP
);
1347 for( USHORT n
= 0; n
< nMaxItems
; ++n
)
1348 if( 0 != (pTmpItem
= GetAttrPool().GetItem( RES_PARATR_TABSTOP
, n
) ))
1349 bChg
|= lcl_SetNewDefTabStops( nOldWidth
, nNewWidth
,
1350 *(SvxTabStopItem
*)pTmpItem
);
1352 aNew
.ClearItem( RES_PARATR_TABSTOP
);
1353 aOld
.ClearItem( RES_PARATR_TABSTOP
);
1356 SwFmtChg
aChgFmt( pDfltCharFmt
);
1357 // dann sage mal den Frames bescheid
1358 aCallMod
.Modify( &aChgFmt
, &aChgFmt
);
1363 if( aNew
.Count() && aCallMod
.GetDepends() )
1365 SwAttrSetChg
aChgOld( aOld
, aOld
);
1366 SwAttrSetChg
aChgNew( aNew
, aNew
);
1367 aCallMod
.Modify( &aChgOld
, &aChgNew
); // alle veraenderten werden verschickt
1370 // und die default-Formate wieder beim Object austragen
1372 while( 0 != ( pDep
= (SwClient
*)aCallMod
.GetDepends()) )
1373 aCallMod
.Remove( pDep
);
1378 // Erfrage das Default Attribut in diesem Dokument.
1379 const SfxPoolItem
& SwDoc::GetDefault( USHORT nFmtHint
) const
1381 return GetAttrPool().GetDefaultItem( nFmtHint
);
1385 * Loeschen der Formate
1387 void SwDoc::DelCharFmt(USHORT nFmt
, BOOL bBroadcast
)
1389 SwCharFmt
* pDel
= (*pCharFmtTbl
)[nFmt
];
1392 BroadcastStyleOperation(pDel
->GetName(), SFX_STYLE_FAMILY_CHAR
,
1393 SFX_STYLESHEET_ERASED
);
1398 new SwUndoCharFmtDelete(pDel
, this);
1403 pCharFmtTbl
->DeleteAndDestroy(nFmt
);
1408 void SwDoc::DelCharFmt( SwCharFmt
*pFmt
, BOOL bBroadcast
)
1410 USHORT nFmt
= pCharFmtTbl
->GetPos( pFmt
);
1411 ASSERT( USHRT_MAX
!= nFmt
, "Fmt not found," );
1413 DelCharFmt( nFmt
, bBroadcast
);
1416 void SwDoc::DelFrmFmt( SwFrmFmt
*pFmt
, BOOL bBroadcast
)
1418 if( pFmt
->ISA( SwTableBoxFmt
) || pFmt
->ISA( SwTableLineFmt
))
1420 ASSERT( !this, "Format steht nicht mehr im DocArray, "
1421 "kann per delete geloescht werden" );
1427 //Das Format muss in einem der beiden Arrays stehen, in welchem
1428 //werden wir schon merken.
1430 if ( USHRT_MAX
!= ( nPos
= pFrmFmtTbl
->GetPos( pFmt
)) )
1433 BroadcastStyleOperation(pFmt
->GetName(),
1434 SFX_STYLE_FAMILY_FRAME
,
1435 SFX_STYLESHEET_ERASED
);
1439 SwUndo
* pUndo
= new SwUndoFrmFmtDelete(pFmt
, this);
1444 pFrmFmtTbl
->DeleteAndDestroy( nPos
);
1448 nPos
= GetSpzFrmFmts()->GetPos( pFmt
);
1449 ASSERT( nPos
!= USHRT_MAX
, "FrmFmt not found." );
1450 if( USHRT_MAX
!= nPos
)
1451 GetSpzFrmFmts()->DeleteAndDestroy( nPos
);
1456 void SwDoc::DelTblFrmFmt( SwTableFmt
*pFmt
)
1458 USHORT nPos
= pTblFrmFmtTbl
->GetPos( pFmt
);
1459 ASSERT( USHRT_MAX
!= nPos
, "Fmt not found," );
1460 pTblFrmFmtTbl
->DeleteAndDestroy( nPos
);
1464 * Erzeugen der Formate
1466 SwFlyFrmFmt
*SwDoc::MakeFlyFrmFmt( const String
&rFmtName
,
1467 SwFrmFmt
*pDerivedFrom
)
1469 SwFlyFrmFmt
*pFmt
= new SwFlyFrmFmt( GetAttrPool(), rFmtName
, pDerivedFrom
);
1470 GetSpzFrmFmts()->Insert(pFmt
, GetSpzFrmFmts()->Count());
1475 SwDrawFrmFmt
*SwDoc::MakeDrawFrmFmt( const String
&rFmtName
,
1476 SwFrmFmt
*pDerivedFrom
)
1478 SwDrawFrmFmt
*pFmt
= new SwDrawFrmFmt( GetAttrPool(), rFmtName
, pDerivedFrom
);
1479 GetSpzFrmFmts()->Insert(pFmt
,GetSpzFrmFmts()->Count());
1485 USHORT
SwDoc::GetTblFrmFmtCount(BOOL bUsed
) const
1487 USHORT nCount
= pTblFrmFmtTbl
->Count();
1490 SwAutoFmtGetDocNode
aGetHt( &aNodes
);
1491 for ( USHORT i
= nCount
; i
; )
1493 if((*pTblFrmFmtTbl
)[--i
]->GetInfo( aGetHt
))
1503 SwFrmFmt
& SwDoc::GetTblFrmFmt(USHORT nFmt
, BOOL bUsed
) const
1505 USHORT nRemoved
= 0;
1508 SwAutoFmtGetDocNode
aGetHt( &aNodes
);
1510 for ( USHORT i
= 0; i
<= nFmt
; i
++ )
1512 while ( (*pTblFrmFmtTbl
)[ i
+ nRemoved
]->GetInfo( aGetHt
))
1518 return *((*pTblFrmFmtTbl
)[nRemoved
+ nFmt
]);
1521 SwTableFmt
* SwDoc::MakeTblFrmFmt( const String
&rFmtName
,
1522 SwFrmFmt
*pDerivedFrom
)
1524 SwTableFmt
* pFmt
= new SwTableFmt( GetAttrPool(), rFmtName
, pDerivedFrom
);
1525 pTblFrmFmtTbl
->Insert( pFmt
, pTblFrmFmtTbl
->Count() );
1531 SwFrmFmt
*SwDoc::MakeFrmFmt(const String
&rFmtName
,
1532 SwFrmFmt
*pDerivedFrom
,
1533 BOOL bBroadcast
, BOOL bAuto
)
1536 SwFrmFmt
*pFmt
= new SwFrmFmt( GetAttrPool(), rFmtName
, pDerivedFrom
);
1538 pFmt
->SetAuto(bAuto
);
1539 pFrmFmtTbl
->Insert( pFmt
, pFrmFmtTbl
->Count());
1544 BroadcastStyleOperation(rFmtName
, SFX_STYLE_FAMILY_PARA
,
1545 SFX_STYLESHEET_CREATED
);
1549 SwUndo
* pUndo
= new SwUndoFrmFmtCreate(pFmt
, pDerivedFrom
, this);
1558 SwFmt
*SwDoc::_MakeFrmFmt(const String
&rFmtName
,
1559 SwFmt
*pDerivedFrom
,
1560 BOOL bBroadcast
, BOOL bAuto
)
1562 SwFrmFmt
*pFrmFmt
= dynamic_cast<SwFrmFmt
*>(pDerivedFrom
);
1563 pFrmFmt
= MakeFrmFmt( rFmtName
, pFrmFmt
, bBroadcast
, bAuto
);
1564 return dynamic_cast<SwFmt
*>(pFrmFmt
);
1568 // --> OD 2005-01-13 #i40550# - add parameter <bAuto> - not relevant
1569 SwCharFmt
*SwDoc::MakeCharFmt( const String
&rFmtName
,
1570 SwCharFmt
*pDerivedFrom
,
1575 SwCharFmt
*pFmt
= new SwCharFmt( GetAttrPool(), rFmtName
, pDerivedFrom
);
1576 pCharFmtTbl
->Insert( pFmt
, pCharFmtTbl
->Count() );
1577 pFmt
->SetAuto( FALSE
);
1582 SwUndo
* pUndo
= new SwUndoCharFmtCreate(pFmt
, pDerivedFrom
, this);
1589 BroadcastStyleOperation(rFmtName
, SFX_STYLE_FAMILY_CHAR
,
1590 SFX_STYLESHEET_CREATED
);
1596 SwFmt
*SwDoc::_MakeCharFmt(const String
&rFmtName
,
1597 SwFmt
*pDerivedFrom
,
1598 BOOL bBroadcast
, BOOL bAuto
)
1600 SwCharFmt
*pCharFmt
= dynamic_cast<SwCharFmt
*>(pDerivedFrom
);
1601 pCharFmt
= MakeCharFmt( rFmtName
, pCharFmt
, bBroadcast
, bAuto
);
1602 return dynamic_cast<SwFmt
*>(pCharFmt
);
1607 * Erzeugen der FormatCollections
1610 // --> OD 2005-01-13 #i40550# - add parameter <bAuto> - not relevant
1611 SwTxtFmtColl
* SwDoc::MakeTxtFmtColl( const String
&rFmtName
,
1612 SwTxtFmtColl
*pDerivedFrom
,
1617 SwTxtFmtColl
*pFmtColl
= new SwTxtFmtColl( GetAttrPool(), rFmtName
,
1619 pTxtFmtCollTbl
->Insert(pFmtColl
, pTxtFmtCollTbl
->Count());
1620 pFmtColl
->SetAuto( FALSE
);
1625 SwUndo
* pUndo
= new SwUndoTxtFmtCollCreate(pFmtColl
, pDerivedFrom
,
1631 BroadcastStyleOperation(rFmtName
, SFX_STYLE_FAMILY_PARA
,
1632 SFX_STYLESHEET_CREATED
);
1637 SwFmt
*SwDoc::_MakeTxtFmtColl(const String
&rFmtName
,
1638 SwFmt
*pDerivedFrom
,
1639 BOOL bBroadcast
, BOOL bAuto
)
1641 SwTxtFmtColl
*pTxtFmtColl
= dynamic_cast<SwTxtFmtColl
*>(pDerivedFrom
);
1642 pTxtFmtColl
= MakeTxtFmtColl( rFmtName
, pTxtFmtColl
, bBroadcast
, bAuto
);
1643 return dynamic_cast<SwFmt
*>(pTxtFmtColl
);
1648 SwConditionTxtFmtColl
* SwDoc::MakeCondTxtFmtColl( const String
&rFmtName
,
1649 SwTxtFmtColl
*pDerivedFrom
,
1652 SwConditionTxtFmtColl
*pFmtColl
= new SwConditionTxtFmtColl( GetAttrPool(),
1653 rFmtName
, pDerivedFrom
);
1654 pTxtFmtCollTbl
->Insert(pFmtColl
, pTxtFmtCollTbl
->Count());
1655 pFmtColl
->SetAuto( FALSE
);
1659 BroadcastStyleOperation(rFmtName
, SFX_STYLE_FAMILY_PARA
,
1660 SFX_STYLESHEET_CREATED
);
1668 SwGrfFmtColl
* SwDoc::MakeGrfFmtColl( const String
&rFmtName
,
1669 SwGrfFmtColl
*pDerivedFrom
)
1671 SwGrfFmtColl
*pFmtColl
= new SwGrfFmtColl( GetAttrPool(), rFmtName
,
1673 pGrfFmtCollTbl
->Insert( pFmtColl
, pGrfFmtCollTbl
->Count() );
1674 pFmtColl
->SetAuto( FALSE
);
1679 void SwDoc::DelTxtFmtColl(USHORT nFmtColl
, BOOL bBroadcast
)
1681 ASSERT( nFmtColl
, "Remove fuer Coll 0." );
1683 // Wer hat die zu loeschende als Next
1684 SwTxtFmtColl
*pDel
= (*pTxtFmtCollTbl
)[nFmtColl
];
1685 if( pDfltTxtFmtColl
== pDel
)
1686 return; // default nie loeschen !!
1689 BroadcastStyleOperation(pDel
->GetName(), SFX_STYLE_FAMILY_PARA
,
1690 SFX_STYLESHEET_ERASED
);
1694 SwUndoTxtFmtCollDelete
* pUndo
=
1695 new SwUndoTxtFmtCollDelete(pDel
, this);
1700 // Die FmtColl austragen
1701 pTxtFmtCollTbl
->Remove(nFmtColl
);
1703 pTxtFmtCollTbl
->ForEach( 1, pTxtFmtCollTbl
->Count(),
1704 &SetTxtFmtCollNext
, pDel
);
1709 void SwDoc::DelTxtFmtColl( SwTxtFmtColl
*pColl
, BOOL bBroadcast
)
1711 USHORT nFmt
= pTxtFmtCollTbl
->GetPos( pColl
);
1712 ASSERT( USHRT_MAX
!= nFmt
, "Collection not found," );
1713 DelTxtFmtColl( nFmt
, bBroadcast
);
1716 BOOL
lcl_SetTxtFmtColl( const SwNodePtr
& rpNode
, void* pArgs
)
1718 // ParaSetFmtColl * pPara = (ParaSetFmtColl*)pArgs;
1719 SwCntntNode
* pCNd
= (SwCntntNode
*)rpNode
->GetTxtNode();
1722 ParaRstFmt
* pPara
= (ParaRstFmt
*)pArgs
;
1724 SwTxtFmtColl
* pFmt
= static_cast<SwTxtFmtColl
*>(pPara
->pFmtColl
);
1725 if ( pPara
->bReset
)
1728 if( pFmt
->GetAttrOutlineLevel() == 0 && pPara
)
1729 pPara
->bKeepOutlineLevelAttr
= true;
1731 lcl_RstAttr( pCNd
, pPara
);
1733 // --> OD 2007-11-06 #i62675#
1734 // --> OD 2008-04-15 #refactorlists#
1735 // check, if paragraph style has changed
1736 if ( pPara
->bResetListAttrs
&&
1737 pFmt
!= pCNd
->GetFmtColl() &&
1738 pFmt
->GetItemState( RES_PARATR_NUMRULE
) == SFX_ITEM_SET
)
1740 // --> OD 2008-04-08 #refactorlists#
1741 // if ( pPara->pHistory )
1743 // SwTxtNode* pTNd( dynamic_cast<SwTxtNode*>(pCNd) );
1745 // "<lcl_SetTxtFmtColl(..)> - text node expected -> crash" );
1746 // SwRegHistory aRegH( pTNd, *pTNd, pPara->pHistory );
1747 // pCNd->ResetAttr( RES_PARATR_NUMRULE );
1751 // pCNd->ResetAttr( RES_PARATR_NUMRULE );
1753 std::auto_ptr
< SwRegHistory
> pRegH
;
1754 if ( pPara
->pHistory
)
1756 SwTxtNode
* pTNd( dynamic_cast<SwTxtNode
*>(pCNd
) );
1758 "<lcl_SetTxtFmtColl(..)> - text node expected -> crash" );
1759 pRegH
.reset( new SwRegHistory( pTNd
, *pTNd
, pPara
->pHistory
) );
1762 pCNd
->ResetAttr( RES_PARATR_NUMRULE
);
1764 // reset all list attributes
1765 pCNd
->ResetAttr( RES_PARATR_LIST_LEVEL
);
1766 pCNd
->ResetAttr( RES_PARATR_LIST_ISRESTART
);
1767 pCNd
->ResetAttr( RES_PARATR_LIST_RESTARTVALUE
);
1768 pCNd
->ResetAttr( RES_PARATR_LIST_ISCOUNTED
);
1769 pCNd
->ResetAttr( RES_PARATR_LIST_ID
);
1774 // erst in die History aufnehmen, damit ggfs. alte Daten
1775 // gesichert werden koennen
1776 if( pPara
->pHistory
)
1777 pPara
->pHistory
->Add( pCNd
->GetFmtColl(), pCNd
->GetIndex(),
1780 pCNd
->ChgFmtColl( pFmt
);
1787 BOOL
SwDoc::SetTxtFmtColl( const SwPaM
&rRg
,
1790 bool bResetListAttrs
)
1792 SwDataChanged
aTmp( rRg
, 0 );
1793 const SwPosition
*pStt
= rRg
.Start(), *pEnd
= rRg
.End();
1794 SwHistory
* pHst
= 0;
1800 // --> OD 2008-04-15 #refactorlists#
1801 SwUndoFmtColl
* pUndo
= new SwUndoFmtColl( rRg
, pFmt
,
1805 pHst
= pUndo
->GetHistory();
1806 AppendUndo( pUndo
);
1809 ParaRstFmt
aPara( pStt
, pEnd
, pHst
);
1810 aPara
.pFmtColl
= pFmt
;
1811 aPara
.bReset
= bReset
;
1812 // --> OD 2007-11-06 #i62675#
1813 aPara
.bResetListAttrs
= bResetListAttrs
;
1816 GetNodes().ForEach( pStt
->nNode
.GetIndex(), pEnd
->nNode
.GetIndex()+1,
1817 lcl_SetTxtFmtColl
, &aPara
);
1819 bRet
= FALSE
; // keinen gueltigen Node gefunden
1827 // ---- Kopiere die Formate in sich selbst (SwDoc) ----------------------
1829 SwFmt
* SwDoc::CopyFmt( const SwFmt
& rFmt
,
1830 const SvPtrarr
& rFmtArr
,
1831 FNCopyFmt fnCopyFmt
, const SwFmt
& rDfltFmt
)
1833 // kein-Autoformat || default Format || Collection-Format
1834 // dann suche danach.
1835 if( !rFmt
.IsAuto() || !rFmt
.GetRegisteredIn() )
1836 for( USHORT n
= 0; n
< rFmtArr
.Count(); n
++ )
1838 // ist die Vorlage schon im Doc vorhanden ??
1839 if( ((SwFmt
*)rFmtArr
[n
])->GetName().Equals( rFmt
.GetName() ))
1840 return (SwFmt
*)rFmtArr
[n
];
1843 // suche erstmal nach dem "Parent"
1844 SwFmt
* pParent
= (SwFmt
*)&rDfltFmt
;
1845 if( rFmt
.DerivedFrom() && pParent
!= rFmt
.DerivedFrom() )
1846 pParent
= CopyFmt( *rFmt
.DerivedFrom(), rFmtArr
,
1847 fnCopyFmt
, rDfltFmt
);
1849 // erzeuge das Format und kopiere die Attribute
1850 // --> OD 2005-01-13 #i40550#
1851 SwFmt
* pNewFmt
= (this->*fnCopyFmt
)( rFmt
.GetName(), pParent
, FALSE
, TRUE
);
1853 pNewFmt
->SetAuto( rFmt
.IsAuto() );
1854 pNewFmt
->CopyAttrs( rFmt
, TRUE
); // kopiere Attribute
1856 pNewFmt
->SetPoolFmtId( rFmt
.GetPoolFmtId() );
1857 pNewFmt
->SetPoolHelpId( rFmt
.GetPoolHelpId() );
1859 // HelpFile-Id immer auf dflt setzen !!
1860 pNewFmt
->SetPoolHlpFileId( UCHAR_MAX
);
1866 // ---- kopiere das Frame-Format --------
1867 SwFrmFmt
* SwDoc::CopyFrmFmt( const SwFrmFmt
& rFmt
)
1870 return (SwFrmFmt
*)CopyFmt( rFmt
, *GetFrmFmts(), &SwDoc::_MakeFrmFmt
,
1874 // ---- kopiere das Char-Format --------
1875 SwCharFmt
* SwDoc::CopyCharFmt( const SwCharFmt
& rFmt
)
1877 return (SwCharFmt
*)CopyFmt( rFmt
, *GetCharFmts(),
1878 &SwDoc::_MakeCharFmt
,
1879 *GetDfltCharFmt() );
1883 // --- Kopiere TextNodes ----
1885 SwTxtFmtColl
* SwDoc::CopyTxtColl( const SwTxtFmtColl
& rColl
)
1887 SwTxtFmtColl
* pNewColl
= FindTxtFmtCollByName( rColl
.GetName() );
1891 // suche erstmal nach dem "Parent"
1892 SwTxtFmtColl
* pParent
= pDfltTxtFmtColl
;
1893 if( pParent
!= rColl
.DerivedFrom() )
1894 pParent
= CopyTxtColl( *(SwTxtFmtColl
*)rColl
.DerivedFrom() );
1898 if( RES_CONDTXTFMTCOLL
== rColl
.Which() )
1900 pNewColl
= new SwConditionTxtFmtColl( GetAttrPool(), rColl
.GetName(),
1902 pTxtFmtCollTbl
->Insert( pNewColl
, pTxtFmtCollTbl
->Count() );
1903 pNewColl
->SetAuto( FALSE
);
1906 // Kopiere noch die Bedingungen
1907 ((SwConditionTxtFmtColl
*)pNewColl
)->SetConditions(
1908 ((SwConditionTxtFmtColl
&)rColl
).GetCondColls() );
1912 pNewColl
= MakeTxtFmtColl( rColl
.GetName(), pParent
);
1914 // kopiere jetzt noch die Auto-Formate oder kopiere die Attribute
1915 pNewColl
->CopyAttrs( rColl
, TRUE
);
1917 // setze noch den Outline-Level
1918 //if( NO_NUMBERING != rColl.GetOutlineLevel() ) //#outline level,zhaojianwei
1919 // pNewColl->SetOutlineLevel( rColl.GetOutlineLevel() );
1920 if(rColl
.IsAssignedToListLevelOfOutlineStyle())
1921 pNewColl
->AssignToListLevelOfOutlineStyle(rColl
.GetAssignedOutlineStyleLevel());//<-end,zhaojianwei
1923 pNewColl
->SetPoolFmtId( rColl
.GetPoolFmtId() );
1924 pNewColl
->SetPoolHelpId( rColl
.GetPoolHelpId() );
1926 // HelpFile-Id immer auf dflt setzen !!
1927 pNewColl
->SetPoolHlpFileId( UCHAR_MAX
);
1929 if( &rColl
.GetNextTxtFmtColl() != &rColl
)
1930 pNewColl
->SetNextTxtFmtColl( *CopyTxtColl( rColl
.GetNextTxtFmtColl() ));
1932 // ggfs. die NumRule erzeugen
1933 if( this != rColl
.GetDoc() )
1935 const SfxPoolItem
* pItem
;
1936 if( SFX_ITEM_SET
== pNewColl
->GetItemState( RES_PARATR_NUMRULE
,
1939 const SwNumRule
* pRule
;
1940 const String
& rName
= ((SwNumRuleItem
*)pItem
)->GetValue();
1942 0 != ( pRule
= rColl
.GetDoc()->FindNumRulePtr( rName
)) &&
1943 !pRule
->IsAutoRule() )
1945 SwNumRule
* pDestRule
= FindNumRulePtr( rName
);
1947 pDestRule
->SetInvalidRule( TRUE
);
1949 MakeNumRule( rName
, pRule
);
1956 // --- Kopiere GrafikNodes ----
1958 SwGrfFmtColl
* SwDoc::CopyGrfColl( const SwGrfFmtColl
& rColl
)
1960 SwGrfFmtColl
* pNewColl
= FindGrfFmtCollByName( rColl
.GetName() );
1964 // suche erstmal nach dem "Parent"
1965 SwGrfFmtColl
* pParent
= pDfltGrfFmtColl
;
1966 if( pParent
!= rColl
.DerivedFrom() )
1967 pParent
= CopyGrfColl( *(SwGrfFmtColl
*)rColl
.DerivedFrom() );
1969 // falls nicht, so kopiere sie
1970 pNewColl
= MakeGrfFmtColl( rColl
.GetName(), pParent
);
1972 // noch die Attribute kopieren
1973 pNewColl
->CopyAttrs( rColl
);
1975 pNewColl
->SetPoolFmtId( rColl
.GetPoolFmtId() );
1976 pNewColl
->SetPoolHelpId( rColl
.GetPoolHelpId() );
1978 // HelpFile-Id immer auf dflt setzen !!
1979 pNewColl
->SetPoolHlpFileId( UCHAR_MAX
);
1984 SwPageDesc
* lcl_FindPageDesc( const SwPageDescs
& rArr
, const String
& rName
)
1986 for( USHORT n
= rArr
.Count(); n
; )
1988 SwPageDesc
* pDesc
= rArr
[ --n
];
1989 if( pDesc
->GetName() == rName
)
1995 void SwDoc::CopyFmtArr( const SvPtrarr
& rSourceArr
,
1997 FNCopyFmt fnCopyFmt
,
2001 SwFmt
* pSrc
, *pDest
;
2003 // 1. Schritt alle Formate anlegen (das 0. ueberspringen - Default!)
2004 for( nSrc
= rSourceArr
.Count(); nSrc
> 1; )
2006 pSrc
= (SwFmt
*)rSourceArr
[ --nSrc
];
2007 if( pSrc
->IsDefault() || pSrc
->IsAuto() )
2010 if( 0 == FindFmtByName( rDestArr
, pSrc
->GetName() ) )
2012 if( RES_CONDTXTFMTCOLL
== pSrc
->Which() )
2013 MakeCondTxtFmtColl( pSrc
->GetName(), (SwTxtFmtColl
*)&rDfltFmt
);
2015 // --> OD 2005-01-13 #i40550#
2016 (this->*fnCopyFmt
)( pSrc
->GetName(), &rDfltFmt
, FALSE
, TRUE
);
2021 // 2. Schritt alle Attribute kopieren, richtige Parents setzen
2022 for( nSrc
= rSourceArr
.Count(); nSrc
> 1; )
2024 pSrc
= (SwFmt
*)rSourceArr
[ --nSrc
];
2025 if( pSrc
->IsDefault() || pSrc
->IsAuto() )
2028 pDest
= FindFmtByName( rDestArr
, pSrc
->GetName() );
2029 pDest
->SetAuto( FALSE
);
2030 // pDest->ResetAllAttr();
2031 // pDest->CopyAttrs( *pSrc, TRUE ); // kopiere Attribute
2032 //JP 19.02.96: ist so wohl optimaler - loest ggfs. kein Modify aus!
2033 pDest
->DelDiffs( *pSrc
);
2034 // --> OD 2009-03-23 #i94285#
2035 // copy existing <SwFmtPageDesc> instance, before copying attributes
2036 // pDest->SetFmtAttr( pSrc->GetAttrSet() ); // kopiere Attribute
2037 //JP 18.08.98: Bug 55115 - copy PageDescAttribute in this case
2038 const SfxPoolItem
* pItem
;
2039 if( &GetAttrPool() != pSrc
->GetAttrSet().GetPool() &&
2040 SFX_ITEM_SET
== pSrc
->GetAttrSet().GetItemState(
2041 RES_PAGEDESC
, FALSE
, &pItem
) &&
2042 ((SwFmtPageDesc
*)pItem
)->GetPageDesc() )
2044 SwFmtPageDesc
aPageDesc( *(SwFmtPageDesc
*)pItem
);
2045 const String
& rNm
= aPageDesc
.GetPageDesc()->GetName();
2046 SwPageDesc
* pPageDesc
= ::lcl_FindPageDesc( aPageDescs
, rNm
);
2049 pPageDesc
= aPageDescs
[ MakePageDesc( rNm
) ];
2051 pPageDesc
->Add( &aPageDesc
);
2052 // pDest->SetFmtAttr( aPageDesc );
2053 SwAttrSet
aTmpAttrSet( pSrc
->GetAttrSet() );
2054 aTmpAttrSet
.Put( aPageDesc
);
2055 pDest
->SetFmtAttr( aTmpAttrSet
);
2059 pDest
->SetFmtAttr( pSrc
->GetAttrSet() );
2063 pDest
->SetPoolFmtId( pSrc
->GetPoolFmtId() );
2064 pDest
->SetPoolHelpId( pSrc
->GetPoolHelpId() );
2066 // HelpFile-Id immer auf dflt setzen !!
2067 pDest
->SetPoolHlpFileId( UCHAR_MAX
);
2069 if( pSrc
->DerivedFrom() )
2070 pDest
->SetDerivedFrom( FindFmtByName( rDestArr
,
2071 pSrc
->DerivedFrom()->GetName() ) );
2072 if( RES_TXTFMTCOLL
== pSrc
->Which() ||
2073 RES_CONDTXTFMTCOLL
== pSrc
->Which() )
2075 SwTxtFmtColl
* pSrcColl
= (SwTxtFmtColl
*)pSrc
,
2076 * pDstColl
= (SwTxtFmtColl
*)pDest
;
2077 if( &pSrcColl
->GetNextTxtFmtColl() != pSrcColl
)
2078 pDstColl
->SetNextTxtFmtColl( *(SwTxtFmtColl
*)FindFmtByName(
2079 rDestArr
, pSrcColl
->GetNextTxtFmtColl().GetName() ) );
2081 // setze noch den Outline-Level
2082 //if( NO_NUMBERING != pSrcColl->GetOutlineLevel() ) //#outline level,zhaojianwei
2083 // pDstColl->SetOutlineLevel( pSrcColl->GetOutlineLevel() );
2084 if(pSrcColl
->IsAssignedToListLevelOfOutlineStyle())
2085 pDstColl
->AssignToListLevelOfOutlineStyle(pSrcColl
->GetAssignedOutlineStyleLevel());//<-end,zhaojianwei
2089 if( RES_CONDTXTFMTCOLL
== pSrc
->Which() )
2090 // Kopiere noch die Bedingungen
2091 // aber erst die alten loeschen!
2092 ((SwConditionTxtFmtColl
*)pDstColl
)->SetConditions(
2093 ((SwConditionTxtFmtColl
*)pSrc
)->GetCondColls() );
2099 void SwDoc::_CopyPageDescHeaderFooter( BOOL bCpyHeader
,
2100 const SwFrmFmt
& rSrcFmt
, SwFrmFmt
& rDestFmt
)
2102 // jetzt noch Header-/Footer-Attribute richtig behandeln
2103 // Contenten Nodes Dokumentuebergreifend kopieren!
2104 USHORT nAttr
= static_cast<USHORT
>( bCpyHeader
? RES_HEADER
: RES_FOOTER
);
2105 const SfxPoolItem
* pItem
;
2106 if( SFX_ITEM_SET
!= rSrcFmt
.GetAttrSet().GetItemState( nAttr
, FALSE
, &pItem
))
2109 // Im Header steht noch der Verweis auf das Format aus dem
2110 // anderen Document!!
2111 SfxPoolItem
* pNewItem
= pItem
->Clone();
2115 pOldFmt
= ((SwFmtHeader
*)pNewItem
)->GetHeaderFmt();
2117 pOldFmt
= ((SwFmtFooter
*)pNewItem
)->GetFooterFmt();
2121 SwFrmFmt
* pNewFmt
= new SwFrmFmt( GetAttrPool(), "CpyDesc",
2123 pNewFmt
->CopyAttrs( *pOldFmt
, TRUE
);
2125 if( SFX_ITEM_SET
== pNewFmt
->GetAttrSet().GetItemState(
2126 RES_CNTNT
, FALSE
, &pItem
))
2128 SwFmtCntnt
* pCntnt
= (SwFmtCntnt
*)pItem
;
2129 if( pCntnt
->GetCntntIdx() )
2131 SwNodeIndex
aTmpIdx( GetNodes().GetEndOfAutotext() );
2132 const SwNodes
& rSrcNds
= rSrcFmt
.GetDoc()->GetNodes();
2133 SwStartNode
* pSttNd
= GetNodes().MakeEmptySection( aTmpIdx
,
2136 : SwFooterStartNode
);
2137 const SwNode
& rCSttNd
= pCntnt
->GetCntntIdx()->GetNode();
2138 SwNodeRange
aRg( rCSttNd
, 0, *rCSttNd
.EndOfSectionNode() );
2139 aTmpIdx
= *pSttNd
->EndOfSectionNode();
2140 rSrcNds
._Copy( aRg
, aTmpIdx
);
2142 rSrcFmt
.GetDoc()->_CopyFlyInFly( aRg
, 0, aTmpIdx
);
2143 pNewFmt
->SetFmtAttr( SwFmtCntnt( pSttNd
));
2146 pNewFmt
->ResetFmtAttr( RES_CNTNT
);
2149 pNewFmt
->Add( (SwFmtHeader
*)pNewItem
);
2151 pNewFmt
->Add( (SwFmtFooter
*)pNewItem
);
2152 rDestFmt
.SetFmtAttr( *pNewItem
);
2157 void SwDoc::CopyPageDesc( const SwPageDesc
& rSrcDesc
, SwPageDesc
& rDstDesc
,
2160 BOOL bNotifyLayout
= FALSE
;
2162 rDstDesc
.SetLandscape( rSrcDesc
.GetLandscape() );
2163 rDstDesc
.SetNumType( rSrcDesc
.GetNumType() );
2164 if( rDstDesc
.ReadUseOn() != rSrcDesc
.ReadUseOn() )
2166 rDstDesc
.WriteUseOn( rSrcDesc
.ReadUseOn() );
2167 bNotifyLayout
= TRUE
;
2172 rDstDesc
.SetPoolFmtId( rSrcDesc
.GetPoolFmtId() );
2173 rDstDesc
.SetPoolHelpId( rSrcDesc
.GetPoolHelpId() );
2174 // HelpFile-Id immer auf dflt setzen !!
2175 rDstDesc
.SetPoolHlpFileId( UCHAR_MAX
);
2178 if( rSrcDesc
.GetFollow() != &rSrcDesc
)
2180 SwPageDesc
* pFollow
= ::lcl_FindPageDesc( aPageDescs
,
2181 rSrcDesc
.GetFollow()->GetName() );
2184 // dann mal kopieren
2185 USHORT nPos
= MakePageDesc( rSrcDesc
.GetFollow()->GetName() );
2186 pFollow
= aPageDescs
[ nPos
];
2187 CopyPageDesc( *rSrcDesc
.GetFollow(), *pFollow
);
2189 rDstDesc
.SetFollow( pFollow
);
2190 bNotifyLayout
= TRUE
;
2193 // die Header/Footer-Attribute werden gesondert kopiert, die Content-
2194 // Sections muessen vollstaendig mitgenommen werden!
2196 SfxItemSet
aAttrSet( rSrcDesc
.GetMaster().GetAttrSet() );
2197 aAttrSet
.ClearItem( RES_HEADER
);
2198 aAttrSet
.ClearItem( RES_FOOTER
);
2200 rDstDesc
.GetMaster().DelDiffs( aAttrSet
);
2201 rDstDesc
.GetMaster().SetFmtAttr( aAttrSet
);
2203 aAttrSet
.ClearItem();
2204 aAttrSet
.Put( rSrcDesc
.GetLeft().GetAttrSet() );
2205 aAttrSet
.ClearItem( RES_HEADER
);
2206 aAttrSet
.ClearItem( RES_FOOTER
);
2208 rDstDesc
.GetLeft().DelDiffs( aAttrSet
);
2209 rDstDesc
.GetLeft().SetFmtAttr( aAttrSet
);
2212 CopyHeader( rSrcDesc
.GetMaster(), rDstDesc
.GetMaster() );
2213 CopyFooter( rSrcDesc
.GetMaster(), rDstDesc
.GetMaster() );
2214 if( !rDstDesc
.IsHeaderShared() )
2215 CopyHeader( rSrcDesc
.GetLeft(), rDstDesc
.GetLeft() );
2217 rDstDesc
.GetLeft().SetFmtAttr( rDstDesc
.GetMaster().GetHeader() );
2219 if( !rDstDesc
.IsFooterShared() )
2220 CopyFooter( rSrcDesc
.GetLeft(), rDstDesc
.GetLeft() );
2222 rDstDesc
.GetLeft().SetFmtAttr( rDstDesc
.GetMaster().GetFooter() );
2224 if( bNotifyLayout
&& GetRootFrm() )
2225 //Layot benachrichtigen!
2226 GetRootFrm()->CheckPageDescs( (SwPageFrm
*)GetRootFrm()->Lower() );
2228 //Wenn sich FussnotenInfo veraendert, so werden die Seiten
2230 if( !(rDstDesc
.GetFtnInfo() == rSrcDesc
.GetFtnInfo()) )
2232 rDstDesc
.SetFtnInfo( rSrcDesc
.GetFtnInfo() );
2233 SwMsgPoolItem
aInfo( RES_PAGEDESC_FTNINFO
);
2235 SwClientIter
aIter( rDstDesc
.GetMaster() );
2236 for( SwClient
* pLast
= aIter
.First(TYPE(SwFrm
)); pLast
;
2237 pLast
= aIter
.Next() )
2238 pLast
->Modify( &aInfo
, 0 );
2241 SwClientIter
aIter( rDstDesc
.GetLeft() );
2242 for( SwClient
* pLast
= aIter
.First(TYPE(SwFrm
)); pLast
;
2243 pLast
= aIter
.Next() )
2244 pLast
->Modify( &aInfo
, 0 );
2249 void SwDoc::ReplaceStyles( SwDoc
& rSource
)
2251 BOOL bIsUndo
= DoesUndo();
2254 CopyFmtArr( *rSource
.pCharFmtTbl
, *pCharFmtTbl
,
2255 &SwDoc::_MakeCharFmt
, *pDfltCharFmt
);
2256 CopyFmtArr( *rSource
.pFrmFmtTbl
, *pFrmFmtTbl
,
2257 &SwDoc::_MakeFrmFmt
, *pDfltFrmFmt
);
2258 CopyFmtArr( *rSource
.pTxtFmtCollTbl
, *pTxtFmtCollTbl
,
2259 &SwDoc::_MakeTxtFmtColl
, *pDfltTxtFmtColl
);
2261 // und jetzt noch die Seiten-Vorlagen
2262 USHORT nCnt
= rSource
.aPageDescs
.Count();
2265 // ein anderes Doc -> Numberformatter muessen gemergt werden
2266 SwTblNumFmtMerge
aTNFM( rSource
, *this );
2268 // 1. Schritt alle Formate anlegen (das 0. ueberspringen - Default!)
2271 SwPageDesc
*pSrc
= rSource
.aPageDescs
[ --nCnt
];
2272 if( 0 == ::lcl_FindPageDesc( aPageDescs
, pSrc
->GetName() ) )
2273 MakePageDesc( pSrc
->GetName() );
2276 // 2. Schritt alle Attribute kopieren, richtige Parents setzen
2277 for( nCnt
= rSource
.aPageDescs
.Count(); nCnt
; )
2279 SwPageDesc
*pSrc
= rSource
.aPageDescs
[ --nCnt
];
2280 CopyPageDesc( *pSrc
, *::lcl_FindPageDesc( aPageDescs
, pSrc
->GetName() ));
2284 //JP 08.04.99: und dann sind da noch die Numerierungs-Vorlagen
2285 nCnt
= rSource
.GetNumRuleTbl().Count();
2288 const SwNumRuleTbl
& rArr
= rSource
.GetNumRuleTbl();
2289 for( USHORT n
= 0; n
< nCnt
; ++n
)
2291 const SwNumRule
& rR
= *rArr
[ n
];
2292 if( !rR
.IsAutoRule() )
2294 SwNumRule
* pNew
= FindNumRulePtr( rR
.GetName());
2296 pNew
->CopyNumRule( this, rR
);
2298 MakeNumRule( rR
.GetName(), &rR
);
2305 // es wurde am Nodes-Array gedreht!
2314 SwFmt
* SwDoc::FindFmtByName( const SvPtrarr
& rFmtArr
,
2315 const String
& rName
) const
2318 for( USHORT n
= 0; n
< rFmtArr
.Count(); n
++ )
2320 // ist die Vorlage schon im Doc vorhanden ??
2321 if( ((SwFmt
*)rFmtArr
[n
])->GetName() == rName
)
2323 pFnd
= (SwFmt
*)rFmtArr
[n
];
2330 void SwDoc::MoveLeftMargin( const SwPaM
& rPam
, BOOL bRight
, BOOL bModulus
)
2332 SwHistory
* pHistory
= 0;
2336 SwUndoMoveLeftMargin
* pUndo
= new SwUndoMoveLeftMargin( rPam
, bRight
,
2338 pHistory
= &pUndo
->GetHistory();
2339 AppendUndo( pUndo
);
2342 const SvxTabStopItem
& rTabItem
= (SvxTabStopItem
&)GetDefault( RES_PARATR_TABSTOP
);
2343 USHORT nDefDist
= rTabItem
.Count() ?
2344 static_cast<USHORT
>(rTabItem
[0].GetTabPos()) : 1134;
2345 const SwPosition
&rStt
= *rPam
.Start(), &rEnd
= *rPam
.End();
2346 SwNodeIndex
aIdx( rStt
.nNode
);
2347 while( aIdx
<= rEnd
.nNode
)
2349 SwTxtNode
* pTNd
= aIdx
.GetNode().GetTxtNode();
2352 SvxLRSpaceItem
aLS( (SvxLRSpaceItem
&)pTNd
->SwCntntNode::GetAttr( RES_LR_SPACE
) );
2354 // --> FME 2008-09-16 #i93873# See also lcl_MergeListLevelIndentAsLRSpaceItem in thints.cxx
2355 if ( pTNd
->AreListLevelIndentsApplicable() )
2357 const SwNumRule
* pRule
= pTNd
->GetNumRule();
2360 const int nListLevel
= pTNd
->GetActualListLevel();
2361 if ( nListLevel
>= 0 )
2363 const SwNumFmt
& rFmt
= pRule
->Get(static_cast<USHORT
>(nListLevel
));
2364 if ( rFmt
.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT
)
2366 aLS
.SetTxtLeft( rFmt
.GetIndentAt() );
2367 aLS
.SetTxtFirstLineOfst( static_cast<short>(rFmt
.GetFirstLineIndent()) );
2373 long nNext
= aLS
.GetTxtLeft();
2375 nNext
= ( nNext
/ nDefDist
) * nDefDist
;
2382 aLS
.SetTxtLeft( nNext
);
2384 SwRegHistory
aRegH( pTNd
, *pTNd
, pHistory
);
2385 pTNd
->SetAttr( aLS
);
2392 BOOL
SwDoc::DontExpandFmt( const SwPosition
& rPos
, BOOL bFlag
)
2395 SwTxtNode
* pTxtNd
= rPos
.nNode
.GetNode().GetTxtNode();
2398 bRet
= pTxtNd
->DontExpandFmt( rPos
.nContent
, bFlag
);
2399 if( bRet
&& DoesUndo() )
2402 AppendUndo( new SwUndoDontExpandFmt( rPos
));
2408 SwTableBoxFmt
* SwDoc::MakeTableBoxFmt()
2410 SwTableBoxFmt
* pFmt
= new SwTableBoxFmt( GetAttrPool(), aEmptyStr
,
2416 SwTableLineFmt
* SwDoc::MakeTableLineFmt()
2418 SwTableLineFmt
* pFmt
= new SwTableLineFmt( GetAttrPool(), aEmptyStr
,
2424 void SwDoc::_CreateNumberFormatter()
2426 RTL_LOGFILE_CONTEXT_AUTHOR( aLog
, "SW", "JP93722", "SwDoc::_CreateNumberFormatter" );
2428 ASSERT( !pNumberFormatter
, "ist doch schon vorhanden" );
2431 LanguageType eLang
= LANGUAGE_SYSTEM
; //System::GetLanguage();
2432 /* ((const SvxLanguageItem&)GetAttrPool().
2433 GetDefaultItem( RES_CHRATR_LANGUAGE )).GetLanguage();
2435 Reference
< XMultiServiceFactory
> xMSF
= ::comphelper::getProcessServiceFactory();
2436 pNumberFormatter
= new SvNumberFormatter( xMSF
, eLang
);
2437 pNumberFormatter
->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL
);
2438 pNumberFormatter
->SetYear2000(static_cast<USHORT
>(SFX_APP()->GetMiscConfig()->GetYear2000()));
2442 SwTblNumFmtMerge::SwTblNumFmtMerge( const SwDoc
& rSrc
, SwDoc
& rDest
)
2445 // ein anderes Doc -> Numberformatter muessen gemergt werden
2446 SvNumberFormatter
* pN
;
2447 if( &rSrc
!= &rDest
&& 0 != ( pN
= ((SwDoc
&)rSrc
).GetNumberFormatter( FALSE
) ))
2448 ( pNFmt
= rDest
.GetNumberFormatter( TRUE
))->MergeFormatter( *pN
);
2450 if( &rSrc
!= &rDest
)
2451 ((SwGetRefFieldType
*)rSrc
.GetSysFldType( RES_GETREFFLD
))->
2452 MergeWithOtherDoc( rDest
);
2455 SwTblNumFmtMerge::~SwTblNumFmtMerge()
2458 pNFmt
->ClearMergeTable();
2462 void SwDoc::SetTxtFmtCollByAutoFmt( const SwPosition
& rPos
, USHORT nPoolId
,
2463 const SfxItemSet
* pSet
)
2466 SwTxtNode
* pTNd
= rPos
.nNode
.GetNode().GetTxtNode();
2468 if( mbIsAutoFmtRedline
&& pTNd
)
2470 // dann das Redline Object anlegen
2471 const SwTxtFmtColl
& rColl
= *pTNd
->GetTxtColl();
2472 SwRedline
* pRedl
= new SwRedline( nsRedlineType_t::REDLINE_FMTCOLL
, aPam
);
2475 // interressant sind nur die Items, die vom Set NICHT wieder
2476 // in den Node gesetzt werden. Also muss man die Differenz nehmen
2477 SwRedlineExtraData_FmtColl
aExtraData( rColl
.GetName(),
2478 rColl
.GetPoolFmtId() );
2479 if( pSet
&& pTNd
->HasSwAttrSet() )
2481 SfxItemSet
aTmp( *pTNd
->GetpSwAttrSet() );
2482 aTmp
.Differentiate( *pSet
);
2483 // das Adjust Item behalten wir extra
2484 const SfxPoolItem
* pItem
;
2485 if( SFX_ITEM_SET
== pTNd
->GetpSwAttrSet()->GetItemState(
2486 RES_PARATR_ADJUST
, FALSE
, &pItem
))
2488 aExtraData
.SetItemSet( aTmp
);
2490 pRedl
->SetExtraData( &aExtraData
);
2492 // !!!!!!!!! Undo fehlt noch !!!!!!!!!!!!!!!!!!
2493 AppendRedline( pRedl
, true );
2496 SetTxtFmtColl( aPam
, GetTxtCollFromPool( nPoolId
) );
2498 if( pSet
&& pTNd
&& pSet
->Count() )
2501 aPam
.GetMark()->nContent
.Assign( pTNd
, pTNd
->GetTxt().Len() );
2502 Insert( aPam
, *pSet
, 0 );
2506 void SwDoc::SetFmtItemByAutoFmt( const SwPaM
& rPam
, const SfxItemSet
& rSet
)
2508 SwTxtNode
* pTNd
= rPam
.GetPoint()->nNode
.GetNode().GetTxtNode();
2510 RedlineMode_t eOld
= GetRedlineMode();
2512 if( mbIsAutoFmtRedline
&& pTNd
)
2514 // dann das Redline Object anlegen
2515 SwRedline
* pRedl
= new SwRedline( nsRedlineType_t::REDLINE_FORMAT
, rPam
);
2516 if( !pRedl
->HasMark() )
2519 // interressant sind nur die Items, die vom Set NICHT wieder
2520 // in den Node gesetzt werden. Also muss man die Differenz nehmen
2521 SwRedlineExtraData_Format
aExtraData( rSet
);
2524 if( pSet && pTNd->HasSwAttrSet() )
2526 SfxItemSet aTmp( *pTNd->GetpSwAttrSet() );
2527 aTmp.Differentiate( *pSet );
2528 // das Adjust Item behalten wir extra
2529 const SfxPoolItem* pItem;
2530 if( SFX_ITEM_SET == pTNd->GetpSwAttrSet()->GetItemState(
2531 RES_PARATR_ADJUST, FALSE, &pItem ))
2533 aExtraData.SetItemSet( aTmp );
2536 pRedl
->SetExtraData( &aExtraData
);
2538 // !!!!!!!!! Undo fehlt noch !!!!!!!!!!!!!!!!!!
2539 AppendRedline( pRedl
, true );
2541 SetRedlineMode_intern( (RedlineMode_t
)(eOld
| nsRedlineMode_t::REDLINE_IGNORE
));
2544 Insert( rPam
, rSet
, nsSetAttrMode::SETATTR_DONTEXPAND
);
2545 SetRedlineMode_intern( eOld
);
2548 void SwDoc::ChgFmt(SwFmt
& rFmt
, const SfxItemSet
& rSet
)
2552 // copying <rSet> to <aSet>
2553 SfxItemSet
aSet(rSet
);
2554 // remove from <aSet> all items, which are already set at the format
2555 aSet
.Differentiate(rFmt
.GetAttrSet());
2556 // <aSet> contains now all *new* items for the format
2558 // copying current format item set to <aOldSet>
2559 SfxItemSet
aOldSet(rFmt
.GetAttrSet());
2560 // insert new items into <aOldSet>
2562 // invalidate all new items in <aOldSet> in order to clear these items,
2563 // if the undo action is triggered.
2565 SfxItemIter
aIter(aSet
);
2567 const SfxPoolItem
* pItem
= aIter
.FirstItem();
2568 while (pItem
!= NULL
)
2570 aOldSet
.InvalidateItem(pItem
->Which());
2572 pItem
= aIter
.NextItem();
2576 SwUndo
* pUndo
= new SwUndoFmtAttr(aOldSet
, rFmt
);
2581 rFmt
.SetFmtAttr(rSet
);
2584 void SwDoc::RenameFmt(SwFmt
& rFmt
, const String
& sNewName
,
2587 SfxStyleFamily eFamily
= SFX_STYLE_FAMILY_ALL
;
2591 SwUndo
* pUndo
= NULL
;
2593 switch (rFmt
.Which())
2596 pUndo
= new SwUndoRenameCharFmt(rFmt
.GetName(), sNewName
, this);
2597 eFamily
= SFX_STYLE_FAMILY_PARA
;
2599 case RES_TXTFMTCOLL
:
2600 pUndo
= new SwUndoRenameFmtColl(rFmt
.GetName(), sNewName
, this);
2601 eFamily
= SFX_STYLE_FAMILY_CHAR
;
2604 pUndo
= new SwUndoRenameFrmFmt(rFmt
.GetName(), sNewName
, this);
2605 eFamily
= SFX_STYLE_FAMILY_FRAME
;
2616 rFmt
.SetName(sNewName
);
2619 BroadcastStyleOperation(sNewName
, eFamily
, SFX_STYLESHEET_MODIFIED
);
2622 // --> OD 2006-09-27 #i69627#
2625 bool HasOutlineStyleToBeWrittenAsNormalListStyle( SwDoc
& rDoc
)
2627 // If a parent paragraph style of one of the parargraph styles, which
2628 // are assigned to the list levels of the outline style, has a list style
2629 // set or inherits a list style from its parent style, the outline style
2630 // has to be written as a normal list style to the OpenDocument file
2631 // format or the OpenOffice.org file format.
2634 const SwTxtFmtColls
* pTxtFmtColls( rDoc
.GetTxtFmtColls() );
2637 const USHORT nCount
= pTxtFmtColls
->Count();
2638 for ( USHORT i
= 0; i
< nCount
; ++i
)
2640 SwTxtFmtColl
* pTxtFmtColl
= (*pTxtFmtColls
)[i
];
2642 if ( pTxtFmtColl
->IsDefault() ||
2643 // pTxtFmtColl->GetOutlineLevel() == NO_NUMBERING ) //#outline level,zhaojianwei
2644 ! pTxtFmtColl
->IsAssignedToListLevelOfOutlineStyle() ) //<-end,zhaojianwei
2649 const SwTxtFmtColl
* pParentTxtFmtColl
=
2650 dynamic_cast<const SwTxtFmtColl
*>( pTxtFmtColl
->DerivedFrom());
2651 if ( !pParentTxtFmtColl
)
2654 // --> OD 2007-12-07 #i77708#
2655 // consider that explicitly no list style is set - empty string
2657 // const SwNumRuleItem& rDirectItem = pParentTxtFmtColl->GetNumRule();
2658 // if ( rDirectItem.GetValue().Len() != 0 )
2659 if ( SFX_ITEM_SET
== pParentTxtFmtColl
->GetItemState( RES_PARATR_NUMRULE
) )