update dev300-m58
[ooovba.git] / sw / source / core / edit / ednumber.cxx
blobb9d4523edb6281b7d5536fba16efb6df13d68230
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: ednumber.cxx,v $
10 * $Revision: 1.28 $
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 #include <hintids.hxx>
36 #include <editsh.hxx>
37 #include <edimp.hxx>
38 #include <doc.hxx>
39 #include <ndtxt.hxx>
40 #include <paratr.hxx>
41 #include <swundo.hxx>
42 #include <numrule.hxx>
44 SV_IMPL_VARARR_SORT( _SwPamRanges, SwPamRange )
47 SwPamRanges::SwPamRanges( const SwPaM& rRing )
49 const SwPaM* pTmp = &rRing;
50 do {
51 Insert( pTmp->GetMark()->nNode, pTmp->GetPoint()->nNode );
52 } while( &rRing != ( pTmp = (const SwPaM*)pTmp->GetNext() ));
56 void SwPamRanges::Insert( const SwNodeIndex& rIdx1, const SwNodeIndex& rIdx2 )
58 SwPamRange aRg( rIdx1.GetIndex(), rIdx2.GetIndex() );
59 if( aRg.nEnd < aRg.nStart )
60 { aRg.nStart = aRg.nEnd; aRg.nEnd = rIdx1.GetIndex(); }
62 USHORT nPos = 0;
63 const SwPamRange* pTmp;
64 if( Count() && Seek_Entry( aRg, &nPos )) // suche Insert Position
66 // ist der im Array stehende kleiner ??
67 if( ( pTmp = GetData()+ nPos )->nEnd < aRg.nEnd )
69 aRg.nEnd = pTmp->nEnd;
70 Remove( nPos, 1 ); // zusammenfassen
72 else
73 return; // ende, weil schon alle zusammengefasst waren
76 BOOL bEnde;
77 do {
78 bEnde = TRUE;
80 // mit dem Vorgaenger zusammenfassen ??
81 if( nPos > 0 )
83 if( ( pTmp = GetData()+( nPos-1 ))->nEnd == aRg.nStart
84 || pTmp->nEnd+1 == aRg.nStart )
86 aRg.nStart = pTmp->nStart;
87 bEnde = FALSE;
88 Remove( --nPos, 1 ); // zusammenfassen
90 // SSelection im Bereich ??
91 else if( pTmp->nStart <= aRg.nStart && aRg.nEnd <= pTmp->nEnd )
92 return;
94 // mit dem Nachfolger zusammenfassen ??
95 if( nPos < Count() )
97 if( ( pTmp = GetData() + nPos )->nStart == aRg.nEnd ||
98 pTmp->nStart == aRg.nEnd+1 )
100 aRg.nEnd = pTmp->nEnd;
101 bEnde = FALSE;
102 Remove( nPos, 1 ); // zusammenfassen
105 // SSelection im Bereich ??
106 else if( pTmp->nStart <= aRg.nStart && aRg.nEnd <= pTmp->nEnd )
107 return;
109 } while( !bEnde );
111 _SwPamRanges::Insert( aRg );
116 SwPaM& SwPamRanges::SetPam( USHORT nArrPos, SwPaM& rPam )
118 ASSERT_ID( nArrPos < Count(), ERR_VAR_IDX );
119 const SwPamRange& rTmp = *(GetData() + nArrPos );
120 rPam.GetPoint()->nNode = rTmp.nStart;
121 rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 );
122 rPam.SetMark();
123 rPam.GetPoint()->nNode = rTmp.nEnd;
124 rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 );
125 return rPam;
130 // Numerierung Outline Regelwerk
133 void SwEditShell::SetOutlineNumRule(const SwNumRule& rRule)
135 StartAllAction(); // Klammern fuers Updaten !!
136 GetDoc()->SetOutlineNumRule(rRule);
137 EndAllAction();
141 const SwNumRule* SwEditShell::GetOutlineNumRule() const
143 return GetDoc()->GetOutlineNumRule();
146 // setzt, wenn noch keine Numerierung, sonst wird geaendert
147 // arbeitet mit alten und neuen Regeln, nur Differenzen aktualisieren
149 // Absaetze ohne Numerierung, aber mit Einzuegen
151 BOOL SwEditShell::NoNum()
153 BOOL bRet = TRUE;
154 StartAllAction();
156 SwPaM* pCrsr = GetCrsr();
157 if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
159 GetDoc()->StartUndo( UNDO_START, NULL );
160 SwPamRanges aRangeArr( *pCrsr );
161 SwPaM aPam( *pCrsr->GetPoint() );
162 for( USHORT n = 0; n < aRangeArr.Count(); ++n )
163 bRet = bRet && GetDoc()->NoNum( aRangeArr.SetPam( n, aPam ));
164 GetDoc()->EndUndo( UNDO_END, NULL );
166 else
167 bRet = GetDoc()->NoNum( *pCrsr );
169 EndAllAction();
170 return bRet;
172 // Loeschen, Splitten der Aufzaehlungsliste
174 // -> #i29560#
175 BOOL SwEditShell::HasNumber() const
177 BOOL bResult = FALSE;
179 const SwTxtNode * pTxtNd =
180 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
182 if (pTxtNd)
184 bResult = pTxtNd->HasNumber();
186 // --> OD 2005-10-26 #b6340308#
187 // special case: outline numbered, not counted paragraph
188 if ( bResult &&
189 pTxtNd->GetNumRule() == GetDoc()->GetOutlineNumRule() &&
190 !pTxtNd->IsCountedInList() )
192 bResult = FALSE;
194 // <--
197 return bResult;
200 BOOL SwEditShell::HasBullet() const
202 BOOL bResult = FALSE;
204 const SwTxtNode * pTxtNd =
205 GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
207 if (pTxtNd)
209 bResult = pTxtNd->HasBullet();
212 return bResult;
214 // <- #i29560#
216 void SwEditShell::DelNumRules()
218 StartAllAction();
220 SwPaM* pCrsr = GetCrsr();
221 if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
223 GetDoc()->StartUndo( UNDO_START, NULL );
224 SwPamRanges aRangeArr( *pCrsr );
225 SwPaM aPam( *pCrsr->GetPoint() );
226 for( USHORT n = 0; n < aRangeArr.Count(); ++n )
228 GetDoc()->DelNumRules( aRangeArr.SetPam( n, aPam ) );
230 GetDoc()->EndUndo( UNDO_END, NULL );
232 else
233 GetDoc()->DelNumRules( *pCrsr );
235 // rufe das AttrChangeNotify auf der UI-Seite. Sollte eigentlich
236 // ueberfluessig sein, aber VB hatte darueber eine Bugrep.
237 CallChgLnk();
239 // --> OD 2005-10-24 #126346# - cursor can not be anymore in
240 // front of a label, because numbering/bullet is deleted.
241 SetInFrontOfLabel( FALSE );
242 // <--
244 GetDoc()->SetModified();
245 EndAllAction();
248 // Hoch-/Runterstufen
251 BOOL SwEditShell::NumUpDown( BOOL bDown )
253 StartAllAction();
255 BOOL bRet = TRUE;
256 SwPaM* pCrsr = GetCrsr();
257 if( pCrsr->GetNext() == pCrsr ) // keine Mehrfachselektion ?
258 bRet = GetDoc()->NumUpDown( *pCrsr, bDown );
259 else
261 GetDoc()->StartUndo( UNDO_START, NULL );
262 SwPamRanges aRangeArr( *pCrsr );
263 SwPaM aPam( *pCrsr->GetPoint() );
264 for( USHORT n = 0; n < aRangeArr.Count(); ++n )
265 bRet = bRet && GetDoc()->NumUpDown( aRangeArr.SetPam( n, aPam ), bDown );
266 GetDoc()->EndUndo( UNDO_END, NULL );
268 GetDoc()->SetModified();
270 // --> FME 2005-09-19 #i54693# Update marked numbering levels
271 if ( IsInFrontOfLabel() )
272 UpdateMarkedListLevel();
273 // <--
275 CallChgLnk();
277 EndAllAction();
278 return bRet;
280 // -> #i23726#
281 BOOL SwEditShell::IsFirstOfNumRule() const
283 BOOL bResult = FALSE;
285 SwPaM * pCrsr = GetCrsr();
286 if (pCrsr->GetNext() == pCrsr)
288 bResult = IsFirstOfNumRule(*pCrsr);
291 return bResult;
294 BOOL SwEditShell::IsFirstOfNumRule(const SwPaM & rPaM) const
296 BOOL bResult = FALSE;
298 SwPosition aPos(*rPaM.GetPoint());
299 bResult = GetDoc()->IsFirstOfNumRule(aPos);
301 return bResult;
303 // <- #i23726#
305 // -> #i23725#
306 // --> OD 2008-06-09 #i90078#
307 // Remove unused default parameter <nLevel> and <bRelative>.
308 // Adjust method name and parameter name
309 void SwEditShell::ChangeIndentOfAllListLevels( short nDiff )
311 StartAllAction();
313 const SwNumRule *pCurNumRule = GetCurNumRule();
314 //#120911# check if numbering rule really exists
315 if (pCurNumRule)
317 SwNumRule aRule(*pCurNumRule);
318 // --> OD 2008-06-09 #i90078#
319 aRule.ChangeIndent( nDiff );
320 // <--
322 // --> OD 2008-03-17 #refactorlists#
323 // no start of new list
324 SetCurNumRule( aRule, false );
325 // <--
328 EndAllAction();
331 // --> OD 2008-06-09 #i90078#
332 // Adjust method name
333 void SwEditShell::SetIndent(short nIndent, const SwPosition & rPos)
334 // <--
336 StartAllAction();
338 SwNumRule *pCurNumRule = GetDoc()->GetCurrNumRule(rPos);
340 if (pCurNumRule)
342 SwPaM aPaM(rPos);
343 SwTxtNode * pTxtNode = aPaM.GetNode()->GetTxtNode();
345 // --> OD 2008-06-09 #i90078#
346 // int nLevel = -1;
347 // int nReferenceLevel = pTxtNode->GetActualListLevel();
348 // if (! IsFirstOfNumRule(aPaM))
349 // nLevel = nReferenceLevel;
351 SwNumRule aRule(*pCurNumRule);
352 // aRule.ChangeIndent(nIndent, nLevel, nReferenceLevel, FALSE);
353 if ( IsFirstOfNumRule() )
355 aRule.SetIndentOfFirstListLevelAndChangeOthers( nIndent );
357 else if ( pTxtNode->GetActualListLevel() >= 0 )
359 aRule.SetIndent( nIndent,
360 static_cast<USHORT>(pTxtNode->GetActualListLevel()) );
362 // <--
364 // --> OD 2005-02-18 #i42921# - 3rd parameter = false in order to
365 // suppress setting of num rule at <aPaM>.
366 // --> OD 2008-03-17 #refactorlists#
367 // do not apply any list
368 GetDoc()->SetNumRule( aPaM, aRule, false, String(), sal_False );
369 // <--
372 EndAllAction();
374 // <- #i23725#
376 BOOL SwEditShell::MoveParagraph( long nOffset )
378 StartAllAction();
380 SwPaM *pCrsr = GetCrsr();
381 if( !pCrsr->HasMark() )
383 // sorge dafuer, das Bound1 und Bound2 im gleichen Node stehen
384 pCrsr->SetMark();
385 pCrsr->DeleteMark();
388 BOOL bRet = GetDoc()->MoveParagraph( *pCrsr, nOffset );
390 GetDoc()->SetModified();
391 EndAllAction();
392 return bRet;
395 //#outline level add by zhaojianwei
396 int SwEditShell::GetCurrentParaOutlineLevel( ) const
398 int nLevel = 0;
400 SwPaM* pCrsr = GetCrsr();
401 const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
402 if( pTxtNd )
403 nLevel = pTxtNd->GetAttrOutlineLevel();
404 return nLevel;
406 //<-end,zhaojianwei
408 void SwEditShell::GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower )
410 SwPaM* pCrsr = GetCrsr();
411 SwPaM aCrsr( *pCrsr->Start() );
412 aCrsr.SetMark();
413 if( pCrsr->HasMark() )
414 *aCrsr.GetPoint() = *pCrsr->End();
415 GetDoc()->GotoNextNum( *aCrsr.GetPoint(), FALSE,
416 &rUpper, &rLower );
419 BOOL SwEditShell::MoveNumParas( BOOL bUpperLower, BOOL bUpperLeft )
421 StartAllAction();
423 // auf alle Selektionen ??
424 SwPaM* pCrsr = GetCrsr();
425 SwPaM aCrsr( *pCrsr->Start() );
426 aCrsr.SetMark();
428 if( pCrsr->HasMark() )
429 *aCrsr.GetPoint() = *pCrsr->End();
431 BOOL bRet = FALSE;
432 BYTE nUpperLevel, nLowerLevel;
433 if( GetDoc()->GotoNextNum( *aCrsr.GetPoint(), FALSE,
434 &nUpperLevel, &nLowerLevel ))
436 if( bUpperLower )
438 // ueber die naechste Nummerierung
439 long nOffset = 0;
440 const SwNode* pNd;
442 if( bUpperLeft ) // verschiebe nach oben
444 SwPosition aPos( *aCrsr.GetMark() );
445 if( GetDoc()->GotoPrevNum( aPos, FALSE ) )
446 nOffset = aPos.nNode.GetIndex() -
447 aCrsr.GetMark()->nNode.GetIndex();
448 else
450 ULONG nStt = aPos.nNode.GetIndex(), nIdx = nStt - 1;
451 while( nIdx && (
452 ( pNd = GetDoc()->GetNodes()[ nIdx ])->IsSectionNode() ||
453 ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode())))
454 --nIdx;
455 if( GetDoc()->GetNodes()[ nIdx ]->IsTxtNode() )
456 nOffset = nIdx - nStt;
459 else // verschiebe nach unten
461 const SwNumRule* pOrig = aCrsr.GetNode(FALSE)->GetTxtNode()->GetNumRule();
462 if( aCrsr.GetNode()->IsTxtNode() &&
463 pOrig == aCrsr.GetNode()->GetTxtNode()->GetNumRule() )
465 ULONG nStt = aCrsr.GetPoint()->nNode.GetIndex(), nIdx = nStt+1;
467 while (nIdx < GetDoc()->GetNodes().Count()-1)
469 pNd = GetDoc()->GetNodes()[ nIdx ];
471 if (pNd->IsSectionNode() ||
472 ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode()) ||
473 ( pNd->IsTxtNode() && pOrig == ((SwTxtNode*)pNd)->GetNumRule() &&
474 ((SwTxtNode*)pNd)->GetActualListLevel() > nUpperLevel ))
476 ++nIdx;
478 // --> OD 2005-11-14 #i57856#
479 else
481 break;
483 // <--
486 if( nStt == nIdx || !GetDoc()->GetNodes()[ nIdx ]->IsTxtNode() )
487 nOffset = 1;
488 else
489 nOffset = nIdx - nStt;
491 else
492 nOffset = 1;
495 if( nOffset )
497 aCrsr.Move( fnMoveBackward, fnGoNode );
498 bRet = GetDoc()->MoveParagraph( aCrsr, nOffset );
501 else if( bUpperLeft ? nUpperLevel : nLowerLevel+1 < MAXLEVEL )
503 aCrsr.Move( fnMoveBackward, fnGoNode );
504 bRet = GetDoc()->NumUpDown( aCrsr, !bUpperLeft );
508 GetDoc()->SetModified();
509 EndAllAction();
510 return bRet;
513 BOOL SwEditShell::OutlineUpDown( short nOffset )
515 StartAllAction();
517 BOOL bRet = TRUE;
518 SwPaM* pCrsr = GetCrsr();
519 if( pCrsr->GetNext() == pCrsr ) // keine Mehrfachselektion ?
520 bRet = GetDoc()->OutlineUpDown( *pCrsr, nOffset );
521 else
523 GetDoc()->StartUndo( UNDO_START, NULL );
524 SwPamRanges aRangeArr( *pCrsr );
525 SwPaM aPam( *pCrsr->GetPoint() );
526 for( USHORT n = 0; n < aRangeArr.Count(); ++n )
527 bRet = bRet && GetDoc()->OutlineUpDown(
528 aRangeArr.SetPam( n, aPam ), nOffset );
529 GetDoc()->EndUndo( UNDO_END, NULL );
531 GetDoc()->SetModified();
532 EndAllAction();
533 return bRet;
537 BOOL SwEditShell::MoveOutlinePara( short nOffset )
539 StartAllAction();
540 BOOL bRet = GetDoc()->MoveOutlinePara( *GetCrsr(), nOffset );
541 EndAllAction();
542 return bRet;
545 // Outlines and SubOutline are ReadOnly?
546 BOOL SwEditShell::IsProtectedOutlinePara() const
548 BOOL bRet = FALSE;
549 const SwNode& rNd = GetCrsr()->Start()->nNode.GetNode();
550 if( rNd.IsTxtNode() )
552 const SwOutlineNodes& rOutlNd = GetDoc()->GetNodes().GetOutLineNds();
553 SwNodePtr pNd = (SwNodePtr)&rNd;
554 BOOL bFirst = TRUE;
555 USHORT nPos;
556 int nLvl(0);
557 if( !rOutlNd.Seek_Entry( pNd, &nPos ) && nPos )
558 --nPos;
560 for( ; nPos < rOutlNd.Count(); ++nPos )
562 SwNodePtr pTmpNd = rOutlNd[ nPos ];
564 // --> OD 2008-04-02 #refactorlists#
565 // BYTE nTmpLvl = GetRealLevel( pTmpNd->GetTxtNode()->
566 // GetTxtColl()->GetOutlineLevel() );
567 // int nTmpLvl = pTmpNd->GetTxtNode()->GetOutlineLevel();//#outline level,zhaojianwei
568 int nTmpLvl = pTmpNd->GetTxtNode()->GetAttrOutlineLevel();
569 // ASSERT( nTmpLvl >= 0 && nTmpLvl < MAXLEVEL,
570 ASSERT( nTmpLvl >= 0 && nTmpLvl <= MAXLEVEL, //<-end,zhaojianwei
571 "<SwEditShell::IsProtectedOutlinePara()>" );
572 // <--
573 if( bFirst )
575 nLvl = nTmpLvl;
576 bFirst = FALSE;
578 else if( nLvl >= nTmpLvl )
579 break;
581 if( pTmpNd->IsProtect() )
583 bRet = TRUE;
584 break;
588 #ifndef PRODUCT
589 else
591 ASSERT(!this, "Cursor not on an outline node" );
593 #endif
594 return bRet;
597 /** Test whether outline may be moved (bCopy == false)
598 * or copied (bCopy == true)
599 * Verify these conditions:
600 * 1) outline must be within main body (and not in redline)
601 * 2) outline must not be within table
602 * 3) if bCopy is set, outline must not be write protected
604 BOOL lcl_IsOutlineMoveAndCopyable( const SwDoc* pDoc, USHORT nIdx, bool bCopy )
606 const SwNodes& rNds = pDoc->GetNodes();
607 const SwNode* pNd = rNds.GetOutLineNds()[ nIdx ];
608 return pNd->GetIndex() >= rNds.GetEndOfExtras().GetIndex() && // 1) body
609 !pNd->FindTableNode() && // 2) table
610 ( bCopy || !pNd->IsProtect() ); // 3) write
613 BOOL SwEditShell::IsOutlineMovable( USHORT nIdx ) const
615 return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, false );
618 BOOL SwEditShell::IsOutlineCopyable( USHORT nIdx ) const
620 return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, true );
624 BOOL SwEditShell::NumOrNoNum( BOOL bNumOn, BOOL bChkStart ) // #115901#
626 BOOL bRet = FALSE;
627 SwPaM* pCrsr = GetCrsr();
628 if( pCrsr->GetNext() == pCrsr && !pCrsr->HasMark() &&
629 ( !bChkStart || !pCrsr->GetPoint()->nContent.GetIndex()) )
631 StartAllAction(); // Klammern fuers Updaten !!
632 // #115901#
633 bRet = GetDoc()->NumOrNoNum( pCrsr->GetPoint()->nNode, !bNumOn ); // #i29560#
634 EndAllAction();
636 return bRet;
639 BOOL SwEditShell::IsNoNum( BOOL bChkStart ) const
641 // ein Backspace im Absatz ohne Nummer wird zum Delete
642 BOOL bResult = FALSE;
643 SwPaM* pCrsr = GetCrsr();
645 if (pCrsr->GetNext() == pCrsr && !pCrsr->HasMark() &&
646 (!bChkStart || !pCrsr->GetPoint()->nContent.GetIndex()))
648 const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
650 if (pTxtNd)
652 bResult = ! pTxtNd->IsCountedInList();
656 return bResult;
659 // --> OD 2008-02-29 #refactorlists# - removed <pHasChilds>
660 BYTE SwEditShell::GetNumLevel() const
662 // gebe die akt. Ebene zurueck, auf der sich der Point vom Cursor befindet
663 //BYTE nLevel = NO_NUMBERING; //#outline level,zhaojianwei
664 BYTE nLevel = MAXLEVEL; //end,zhaojianwei
666 SwPaM* pCrsr = GetCrsr();
667 const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
669 // --> FME 2005-09-12 #124972# Made code robust:
670 ASSERT( pTxtNd, "GetNumLevel() without text node" )
671 if ( !pTxtNd )
672 return nLevel;
673 // <--
675 const SwNumRule* pRule = pTxtNd->GetNumRule();
676 if(pRule)
678 // --> OD 2008-05-09 #refactorlists#
679 const int nListLevelOfTxtNode( pTxtNd->GetActualListLevel() );
680 if ( nListLevelOfTxtNode >= 0 )
682 nLevel = static_cast<BYTE>( nListLevelOfTxtNode );
684 // <--
687 return nLevel;
690 const SwNumRule* SwEditShell::GetCurNumRule() const
692 return GetDoc()->GetCurrNumRule( *GetCrsr()->GetPoint() );
695 // OD 2008-02-08 #newlistlevelattrs# - add handling of parameter <bResetIndentAttrs>
696 // --> OD 2008-03-17 #refactorlists#
697 void SwEditShell::SetCurNumRule( const SwNumRule& rRule,
698 const bool bCreateNewList,
699 const String sContinuedListId,
700 const bool bResetIndentAttrs )
702 StartAllAction();
704 SwPaM* pCrsr = GetCrsr();
705 if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
707 GetDoc()->StartUndo( UNDO_START, NULL );
708 SwPamRanges aRangeArr( *pCrsr );
709 SwPaM aPam( *pCrsr->GetPoint() );
710 for( USHORT n = 0; n < aRangeArr.Count(); ++n )
712 aRangeArr.SetPam( n, aPam );
713 // --> OD 2008-02-08 #newlistlevelattrs#
714 // --> OD 2008-03-17 #refactorlists#
715 GetDoc()->SetNumRule( aPam, rRule,
716 bCreateNewList, sContinuedListId,
717 sal_True, bResetIndentAttrs );
718 // <--
719 GetDoc()->SetCounted( aPam, true );
721 GetDoc()->EndUndo( UNDO_END, NULL );
723 else
725 GetDoc()->StartUndo( UNDO_START, NULL );
727 // --> OD 2008-02-08 #newlistlevelattrs#
728 // --> OD 2008-03-17 #refactorlists#
729 GetDoc()->SetNumRule( *pCrsr, rRule,
730 bCreateNewList, sContinuedListId,
731 sal_True, bResetIndentAttrs );
732 GetDoc()->SetCounted( *pCrsr, true );
734 GetDoc()->EndUndo( UNDO_END, NULL );
737 EndAllAction();
740 String SwEditShell::GetUniqueNumRuleName( const String* pChkStr, BOOL bAutoNum ) const
742 return GetDoc()->GetUniqueNumRuleName( pChkStr, bAutoNum );
745 void SwEditShell::ChgNumRuleFmts( const SwNumRule& rRule )
747 StartAllAction();
748 GetDoc()->ChgNumRuleFmts( rRule );
749 EndAllAction();
752 BOOL SwEditShell::ReplaceNumRule( const String& rOldRule, const String& rNewRule )
754 StartAllAction();
755 BOOL bRet = GetDoc()->ReplaceNumRule( *GetCrsr()->GetPoint(), rOldRule, rNewRule );
756 EndAllAction();
757 return bRet;
760 void SwEditShell::SetNumRuleStart( BOOL bFlag )
762 StartAllAction();
764 SwPaM* pCrsr = GetCrsr();
765 if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
767 GetDoc()->StartUndo( UNDO_START, NULL );
768 SwPamRanges aRangeArr( *pCrsr );
769 SwPaM aPam( *pCrsr->GetPoint() );
770 for( USHORT n = 0; n < aRangeArr.Count(); ++n )
771 GetDoc()->SetNumRuleStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), bFlag );
772 GetDoc()->EndUndo( UNDO_END, NULL );
774 else
775 GetDoc()->SetNumRuleStart( *pCrsr->GetPoint(), bFlag );
777 EndAllAction();
780 BOOL SwEditShell::IsNumRuleStart() const
782 BOOL bResult = FALSE;
783 const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode();
784 if( pTxtNd )
785 bResult = pTxtNd->IsListRestart() ? TRUE : FALSE;
786 return bResult;
789 void SwEditShell::SetNodeNumStart( USHORT nStt )
791 StartAllAction();
793 SwPaM* pCrsr = GetCrsr();
794 if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
796 GetDoc()->StartUndo( UNDO_START, NULL );
797 SwPamRanges aRangeArr( *pCrsr );
798 SwPaM aPam( *pCrsr->GetPoint() );
799 for( USHORT n = 0; n < aRangeArr.Count(); ++n )
800 GetDoc()->SetNodeNumStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), nStt );
801 GetDoc()->EndUndo( UNDO_END, NULL );
803 else
804 GetDoc()->SetNodeNumStart( *pCrsr->GetPoint(), nStt );
806 EndAllAction();
809 USHORT SwEditShell::GetNodeNumStart() const
811 const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode();
812 // --> OD 2008-02-28 #refactorlists#
813 // correction: check, if list restart value is set at text node and
814 // use new method <SwTxtNode::GetAttrListRestartValue()>.
815 // return USHRT_MAX, if no list restart value is found.
816 if ( pTxtNd && pTxtNd->HasAttrListRestartValue() )
818 return static_cast<USHORT>(pTxtNd->GetAttrListRestartValue());
820 return USHRT_MAX;
821 // <--
824 /*-- 26.08.2005 14:47:17---------------------------------------------------
826 -----------------------------------------------------------------------*/
827 // --> OD 2008-03-18 #refactorlists#
828 const SwNumRule * SwEditShell::SearchNumRule( const bool bForward,
829 const bool bNum,
830 const bool bOutline,
831 int nNonEmptyAllowed,
832 String& sListId )
834 return GetDoc()->SearchNumRule( *(bForward ? GetCrsr()->End() : GetCrsr()->Start()),
835 bForward, bNum, bOutline, nNonEmptyAllowed,
836 sListId );
838 // <--