xref: /aoo42x/main/sw/source/core/edit/ednumber.cxx (revision efeef26f)
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 #include <hintids.hxx>
29 #include <editsh.hxx>
30 #include <edimp.hxx>
31 #include <doc.hxx>
32 #include <IDocumentUndoRedo.hxx>
33 #include <ndtxt.hxx>
34 #include <paratr.hxx>
35 #include <swundo.hxx>
36 #include <numrule.hxx>
37 
38 SV_IMPL_VARARR_SORT( _SwPamRanges, SwPamRange )
39 
40 
41 SwPamRanges::SwPamRanges( const SwPaM& rRing )
42 {
43 	const SwPaM* pTmp = &rRing;
44 	do {
45 		Insert( pTmp->GetMark()->nNode, pTmp->GetPoint()->nNode );
46 	} while( &rRing != ( pTmp = (const SwPaM*)pTmp->GetNext() ));
47 }
48 
49 
50 void SwPamRanges::Insert( const SwNodeIndex& rIdx1, const SwNodeIndex& rIdx2 )
51 {
52 	SwPamRange aRg( rIdx1.GetIndex(), rIdx2.GetIndex() );
53 	if( aRg.nEnd < aRg.nStart )
54 	{	aRg.nStart = aRg.nEnd; aRg.nEnd = rIdx1.GetIndex(); }
55 
56 	sal_uInt16 nPos = 0;
57 	const SwPamRange* pTmp;
58 	if( Count() && Seek_Entry( aRg, &nPos ))		// suche Insert Position
59 	{
60 		// ist der im Array stehende kleiner ??
61 		if( ( pTmp = GetData()+ nPos )->nEnd < aRg.nEnd )
62 		{
63 			aRg.nEnd = pTmp->nEnd;
64 			Remove( nPos, 1 );		// zusammenfassen
65 		}
66 		else
67 			return;		// ende, weil schon alle zusammengefasst waren
68 	}
69 
70 	sal_Bool bEnde;
71 	do {
72 		bEnde = sal_True;
73 
74 		// mit dem Vorgaenger zusammenfassen ??
75 		if( nPos > 0 )
76 		{
77 			if( ( pTmp = GetData()+( nPos-1 ))->nEnd == aRg.nStart
78 				|| pTmp->nEnd+1 == aRg.nStart )
79 			{
80 				aRg.nStart = pTmp->nStart;
81 				bEnde = sal_False;
82 				Remove( --nPos, 1 );		// zusammenfassen
83 			}
84 			// SSelection im Bereich ??
85 			else if( pTmp->nStart <= aRg.nStart && aRg.nEnd <= pTmp->nEnd )
86 				return;
87 		}
88 			// mit dem Nachfolger zusammenfassen ??
89 		if( nPos < Count() )
90 		{
91 			if( ( pTmp = GetData() + nPos )->nStart == aRg.nEnd ||
92 				pTmp->nStart == aRg.nEnd+1 )
93 			{
94 				aRg.nEnd = pTmp->nEnd;
95 				bEnde = sal_False;
96 				Remove( nPos, 1 );		// zusammenfassen
97 			}
98 
99 			// SSelection im Bereich ??
100 			else if( pTmp->nStart <= aRg.nStart && aRg.nEnd <= pTmp->nEnd )
101 				return;
102 		}
103 	} while( !bEnde );
104 
105 	_SwPamRanges::Insert( aRg );
106 }
107 
108 
109 
110 SwPaM& SwPamRanges::SetPam( sal_uInt16 nArrPos, SwPaM& rPam )
111 {
112 	ASSERT_ID( nArrPos < Count(), ERR_VAR_IDX );
113 	const SwPamRange& rTmp = *(GetData() + nArrPos );
114 	rPam.GetPoint()->nNode = rTmp.nStart;
115 	rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 );
116 	rPam.SetMark();
117 	rPam.GetPoint()->nNode = rTmp.nEnd;
118 	rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 );
119 	return rPam;
120 }
121 
122 
123 
124 // Numerierung Outline Regelwerk
125 
126 
127 void SwEditShell::SetOutlineNumRule(const SwNumRule& rRule)
128 {
129 	StartAllAction();		// Klammern fuers Updaten !!
130 	GetDoc()->SetOutlineNumRule(rRule);
131 	EndAllAction();
132 }
133 
134 
135 const SwNumRule* SwEditShell::GetOutlineNumRule() const
136 {
137 	return GetDoc()->GetOutlineNumRule();
138 }
139 
140 // setzt, wenn noch keine Numerierung, sonst wird geaendert
141 // arbeitet mit alten und neuen Regeln, nur Differenzen aktualisieren
142 
143 // Absaetze ohne Numerierung, aber mit Einzuegen
144 
145 sal_Bool SwEditShell::NoNum()
146 {
147 	sal_Bool bRet = sal_True;
148 	StartAllAction();
149 
150 	SwPaM* pCrsr = GetCrsr();
151 	if( pCrsr->GetNext() != pCrsr )			// Mehrfachselektion ?
152     {
153         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
154 		SwPamRanges aRangeArr( *pCrsr );
155 		SwPaM aPam( *pCrsr->GetPoint() );
156 		for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
157 			bRet = bRet && GetDoc()->NoNum( aRangeArr.SetPam( n, aPam ));
158         GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
159     }
160     else
161 		bRet = GetDoc()->NoNum( *pCrsr );
162 
163 	EndAllAction();
164 	return bRet;
165 }
166 // Loeschen, Splitten der Aufzaehlungsliste
167 
168 // -> #i29560#
169 sal_Bool SwEditShell::HasNumber() const
170 {
171     sal_Bool bResult = sal_False;
172 
173     const SwTxtNode * pTxtNd =
174         GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
175 
176     if (pTxtNd)
177     {
178         bResult = pTxtNd->HasNumber();
179 
180         // --> OD 2005-10-26 #b6340308#
181         // special case: outline numbered, not counted paragraph
182         if ( bResult &&
183              pTxtNd->GetNumRule() == GetDoc()->GetOutlineNumRule() &&
184              !pTxtNd->IsCountedInList() )
185         {
186             bResult = sal_False;
187         }
188         // <--
189     }
190 
191     return bResult;
192 }
193 
194 sal_Bool SwEditShell::HasBullet() const
195 {
196     sal_Bool bResult = sal_False;
197 
198     const SwTxtNode * pTxtNd =
199         GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
200 
201     if (pTxtNd)
202     {
203         bResult = pTxtNd->HasBullet();
204     }
205 
206     return bResult;
207 }
208 // <- #i29560#
209 
210 void SwEditShell::DelNumRules()
211 {
212 	StartAllAction();
213 
214 	SwPaM* pCrsr = GetCrsr();
215 	if( pCrsr->GetNext() != pCrsr )			// Mehrfachselektion ?
216     {
217         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
218 		SwPamRanges aRangeArr( *pCrsr );
219 		SwPaM aPam( *pCrsr->GetPoint() );
220 		for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
221         {
222             GetDoc()->DelNumRules( aRangeArr.SetPam( n, aPam ) );
223         }
224         GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
225     }
226     else
227         GetDoc()->DelNumRules( *pCrsr );
228 
229 	// rufe das AttrChangeNotify auf der UI-Seite. Sollte eigentlich
230 	// ueberfluessig sein, aber VB hatte darueber eine Bugrep.
231 	CallChgLnk();
232 
233     // --> OD 2005-10-24 #126346# - cursor can not be anymore in
234     // front of a label, because numbering/bullet is deleted.
235     SetInFrontOfLabel( sal_False );
236     // <--
237 
238 	GetDoc()->SetModified();
239 	EndAllAction();
240 }
241 
242 // Hoch-/Runterstufen
243 
244 
245 sal_Bool SwEditShell::NumUpDown( sal_Bool bDown )
246 {
247 	StartAllAction();
248 
249 	sal_Bool bRet = sal_True;
250 	SwPaM* pCrsr = GetCrsr();
251 	if( pCrsr->GetNext() == pCrsr )			// keine Mehrfachselektion ?
252 		bRet = GetDoc()->NumUpDown( *pCrsr, bDown );
253     else
254     {
255         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
256 		SwPamRanges aRangeArr( *pCrsr );
257 		SwPaM aPam( *pCrsr->GetPoint() );
258 		for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
259 			bRet = bRet && GetDoc()->NumUpDown( aRangeArr.SetPam( n, aPam ), bDown );
260         GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
261     }
262 	GetDoc()->SetModified();
263 
264     // --> FME 2005-09-19 #i54693# Update marked numbering levels
265     if ( IsInFrontOfLabel() )
266         UpdateMarkedListLevel();
267     // <--
268 
269     CallChgLnk();
270 
271 	EndAllAction();
272 	return bRet;
273 }
274 // -> #i23726#
275 sal_Bool SwEditShell::IsFirstOfNumRule() const
276 {
277     sal_Bool bResult = sal_False;
278 
279     SwPaM * pCrsr = GetCrsr();
280     if (pCrsr->GetNext() == pCrsr)
281     {
282         bResult = IsFirstOfNumRule(*pCrsr);
283     }
284 
285     return bResult;
286 }
287 
288 sal_Bool SwEditShell::IsFirstOfNumRule(const SwPaM & rPaM) const
289 {
290     sal_Bool bResult = sal_False;
291 
292     SwPosition aPos(*rPaM.GetPoint());
293     bResult = GetDoc()->IsFirstOfNumRule(aPos);
294 
295     return bResult;
296 }
297 // <- #i23726#
298 
299 // -> #i23725#
300 // --> OD 2008-06-09 #i90078#
301 // Remove unused default parameter <nLevel> and <bRelative>.
302 // Adjust method name and parameter name
303 void SwEditShell::ChangeIndentOfAllListLevels( short nDiff )
304 {
305     StartAllAction();
306 
307     const SwNumRule *pCurNumRule = GetCurNumRule();
308     //#120911# check if numbering rule really exists
309     if (pCurNumRule)
310     {
311         SwNumRule aRule(*pCurNumRule);
312         // --> OD 2008-06-09 #i90078#
313         aRule.ChangeIndent( nDiff );
314         // <--
315 
316         // --> OD 2008-03-17 #refactorlists#
317         // no start of new list
318         SetCurNumRule( aRule, false );
319         // <--
320     }
321 
322     EndAllAction();
323 }
324 
325 // --> OD 2008-06-09 #i90078#
326 // Adjust method name
327 void SwEditShell::SetIndent(short nIndent, const SwPosition & rPos)
328 // <--
329 {
330     StartAllAction();
331 
332     SwNumRule *pCurNumRule = GetDoc()->GetCurrNumRule(rPos);
333 
334     if (pCurNumRule)
335     {
336         SwPaM aPaM(rPos);
337         SwTxtNode * pTxtNode = aPaM.GetNode()->GetTxtNode();
338 
339         // --> OD 2008-06-09 #i90078#
340 //        int nLevel = -1;
341 //        int nReferenceLevel = pTxtNode->GetActualListLevel();
342 //        if (! IsFirstOfNumRule(aPaM))
343 //            nLevel = nReferenceLevel;
344 
345         SwNumRule aRule(*pCurNumRule);
346 //        aRule.ChangeIndent(nIndent, nLevel, nReferenceLevel, sal_False);
347         if ( IsFirstOfNumRule() )
348         {
349             aRule.SetIndentOfFirstListLevelAndChangeOthers( nIndent );
350         }
351         else if ( pTxtNode->GetActualListLevel() >= 0  )
352         {
353             aRule.SetIndent( nIndent,
354                              static_cast<sal_uInt16>(pTxtNode->GetActualListLevel()) );
355         }
356         // <--
357 
358         // --> OD 2005-02-18 #i42921# - 3rd parameter = false in order to
359         // suppress setting of num rule at <aPaM>.
360         // --> OD 2008-03-17 #refactorlists#
361         // do not apply any list
362         GetDoc()->SetNumRule( aPaM, aRule, false, String(), sal_False );
363         // <--
364     }
365 
366     EndAllAction();
367 }
368 // <- #i23725#
369 
370 sal_Bool SwEditShell::MoveParagraph( long nOffset )
371 {
372 	StartAllAction();
373 
374 	SwPaM *pCrsr = GetCrsr();
375 	if( !pCrsr->HasMark() )
376 	{
377 		// sorge dafuer, das Bound1 und Bound2 im gleichen Node stehen
378 		pCrsr->SetMark();
379 		pCrsr->DeleteMark();
380 	}
381 
382 	sal_Bool bRet = GetDoc()->MoveParagraph( *pCrsr, nOffset );
383 
384 	GetDoc()->SetModified();
385 	EndAllAction();
386 	return bRet;
387 }
388 
389 //#outline level add by zhaojianwei
390 int SwEditShell::GetCurrentParaOutlineLevel( ) const
391 {
392 	int nLevel = 0;
393 
394 	SwPaM* pCrsr = GetCrsr();
395 	const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
396 	if( pTxtNd )
397 		nLevel = pTxtNd->GetAttrOutlineLevel();
398 	return nLevel;
399 }
400 //<-end,zhaojianwei
401 
402 void SwEditShell::GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower )
403 {
404     SwPaM* pCrsr = GetCrsr();
405 	SwPaM aCrsr( *pCrsr->Start() );
406 	aCrsr.SetMark();
407 	if( pCrsr->HasMark() )
408 		*aCrsr.GetPoint() = *pCrsr->End();
409     GetDoc()->GotoNextNum( *aCrsr.GetPoint(), sal_False,
410                             &rUpper, &rLower );
411 }
412 
413 sal_Bool SwEditShell::MoveNumParas( sal_Bool bUpperLower, sal_Bool bUpperLeft )
414 {
415 	StartAllAction();
416 
417 	// auf alle Selektionen ??
418 	SwPaM* pCrsr = GetCrsr();
419 	SwPaM aCrsr( *pCrsr->Start() );
420 	aCrsr.SetMark();
421 
422 	if( pCrsr->HasMark() )
423 		*aCrsr.GetPoint() = *pCrsr->End();
424 
425 	sal_Bool bRet = sal_False;
426 	sal_uInt8 nUpperLevel, nLowerLevel;
427 	if( GetDoc()->GotoNextNum( *aCrsr.GetPoint(), sal_False,
428 								&nUpperLevel, &nLowerLevel ))
429 	{
430 		if( bUpperLower )
431 		{
432 			// ueber die naechste Nummerierung
433 			long nOffset = 0;
434 			const SwNode* pNd;
435 
436 			if( bUpperLeft )		// verschiebe nach oben
437 			{
438 				SwPosition aPos( *aCrsr.GetMark() );
439 				if( GetDoc()->GotoPrevNum( aPos, sal_False ) )
440 					nOffset = aPos.nNode.GetIndex() -
441 							aCrsr.GetMark()->nNode.GetIndex();
442 				else
443 				{
444 					sal_uLong nStt = aPos.nNode.GetIndex(), nIdx = nStt - 1;
445 					while( nIdx && (
446 						( pNd = GetDoc()->GetNodes()[ nIdx ])->IsSectionNode() ||
447                         ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode())))
448 						--nIdx;
449 					if( GetDoc()->GetNodes()[ nIdx ]->IsTxtNode() )
450 						nOffset = nIdx - nStt;
451 				}
452 			}
453 			else					// verschiebe nach unten
454 			{
455 				const SwNumRule* pOrig = aCrsr.GetNode(sal_False)->GetTxtNode()->GetNumRule();
456 				if( aCrsr.GetNode()->IsTxtNode() &&
457 					pOrig == aCrsr.GetNode()->GetTxtNode()->GetNumRule() )
458 				{
459 					sal_uLong nStt = aCrsr.GetPoint()->nNode.GetIndex(), nIdx = nStt+1;
460 
461                     while (nIdx < GetDoc()->GetNodes().Count()-1)
462                     {
463                         pNd = GetDoc()->GetNodes()[ nIdx ];
464 
465                         if (pNd->IsSectionNode() ||
466                             ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode()) ||
467                             ( pNd->IsTxtNode() && pOrig == ((SwTxtNode*)pNd)->GetNumRule() &&
468                               ((SwTxtNode*)pNd)->GetActualListLevel() > nUpperLevel ))
469                         {
470                             ++nIdx;
471                         }
472                         // --> OD 2005-11-14 #i57856#
473                         else
474                         {
475                             break;
476                         }
477                         // <--
478                     }
479 
480 					if( nStt == nIdx || !GetDoc()->GetNodes()[ nIdx ]->IsTxtNode() )
481 						nOffset = 1;
482 					else
483 						nOffset = nIdx - nStt;
484 				}
485 				else
486 					nOffset = 1;
487 			}
488 
489 			if( nOffset )
490 			{
491 				aCrsr.Move( fnMoveBackward, fnGoNode );
492 				bRet = GetDoc()->MoveParagraph( aCrsr, nOffset );
493 			}
494 		}
495 		else if( bUpperLeft ? nUpperLevel : nLowerLevel+1 < MAXLEVEL )
496 		{
497 			aCrsr.Move( fnMoveBackward, fnGoNode );
498 			bRet = GetDoc()->NumUpDown( aCrsr, !bUpperLeft );
499 		}
500 	}
501 
502 	GetDoc()->SetModified();
503 	EndAllAction();
504 	return bRet;
505 }
506 
507 sal_Bool SwEditShell::OutlineUpDown( short nOffset )
508 {
509 	StartAllAction();
510 
511 	sal_Bool bRet = sal_True;
512 	SwPaM* pCrsr = GetCrsr();
513 	if( pCrsr->GetNext() == pCrsr )			// keine Mehrfachselektion ?
514 		bRet = GetDoc()->OutlineUpDown( *pCrsr, nOffset );
515     else
516     {
517         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
518 		SwPamRanges aRangeArr( *pCrsr );
519 		SwPaM aPam( *pCrsr->GetPoint() );
520 		for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
521 			bRet = bRet && GetDoc()->OutlineUpDown(
522 									aRangeArr.SetPam( n, aPam ), nOffset );
523         GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
524     }
525 	GetDoc()->SetModified();
526 	EndAllAction();
527 	return bRet;
528 }
529 
530 
531 sal_Bool SwEditShell::MoveOutlinePara( short nOffset )
532 {
533 	StartAllAction();
534 	sal_Bool bRet = GetDoc()->MoveOutlinePara( *GetCrsr(), nOffset );
535 	EndAllAction();
536 	return bRet;
537 }
538 
539 // Outlines and SubOutline are ReadOnly?
540 sal_Bool SwEditShell::IsProtectedOutlinePara() const
541 {
542 	sal_Bool bRet = sal_False;
543 	const SwNode& rNd = GetCrsr()->Start()->nNode.GetNode();
544 	if( rNd.IsTxtNode() )
545 	{
546 		const SwOutlineNodes& rOutlNd = GetDoc()->GetNodes().GetOutLineNds();
547 		SwNodePtr pNd = (SwNodePtr)&rNd;
548 		sal_Bool bFirst = sal_True;
549 		sal_uInt16 nPos;
550         int nLvl(0);
551 		if( !rOutlNd.Seek_Entry( pNd, &nPos ) && nPos )
552 			--nPos;
553 
554 		for( ; nPos < rOutlNd.Count(); ++nPos )
555 		{
556             SwNodePtr pTmpNd = rOutlNd[ nPos ];
557 
558 			// --> OD 2008-04-02 #refactorlists#
559 //            sal_uInt8 nTmpLvl = GetRealLevel( pTmpNd->GetTxtNode()->
560 //                                    GetTxtColl()->GetOutlineLevel() );
561  //           int nTmpLvl = pTmpNd->GetTxtNode()->GetOutlineLevel();//#outline level,zhaojianwei
562             int nTmpLvl = pTmpNd->GetTxtNode()->GetAttrOutlineLevel();
563  //           ASSERT( nTmpLvl >= 0 && nTmpLvl < MAXLEVEL,
564             ASSERT( nTmpLvl >= 0 && nTmpLvl <= MAXLEVEL,			//<-end,zhaojianwei
565                     "<SwEditShell::IsProtectedOutlinePara()>" );
566             // <--
567 			if( bFirst )
568 			{
569 				nLvl = nTmpLvl;
570 				bFirst = sal_False;
571 			}
572 			else if( nLvl >= nTmpLvl )
573 				break;
574 
575             if( pTmpNd->IsProtect() )
576 			{
577 				bRet = sal_True;
578 				break;
579 			}
580 		}
581 	}
582 #ifdef DBG_UTIL
583 	else
584 	{
585 		ASSERT(!this, "Cursor not on an outline node" );
586 	}
587 #endif
588 	return bRet;
589 }
590 
591 /** Test whether outline may be moved (bCopy == false)
592  *                           or copied (bCopy == true)
593  * Verify these conditions:
594  * 1) outline must be within main body (and not in redline)
595  * 2) outline must not be within table
596  * 3) if bCopy is set, outline must not be write protected
597  */
598 sal_Bool lcl_IsOutlineMoveAndCopyable( const SwDoc* pDoc, sal_uInt16 nIdx, bool bCopy )
599 {
600 	const SwNodes& rNds = pDoc->GetNodes();
601     const SwNode* pNd = rNds.GetOutLineNds()[ nIdx ];
602     return pNd->GetIndex() >= rNds.GetEndOfExtras().GetIndex() &&   // 1) body
603             !pNd->FindTableNode() &&                                // 2) table
604             ( bCopy || !pNd->IsProtect() );                         // 3) write
605 }
606 
607 sal_Bool SwEditShell::IsOutlineMovable( sal_uInt16 nIdx ) const
608 {
609     return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, false );
610 }
611 
612 sal_Bool SwEditShell::IsOutlineCopyable( sal_uInt16 nIdx ) const
613 {
614     return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, true );
615 }
616 
617 
618 sal_Bool SwEditShell::NumOrNoNum( sal_Bool bNumOn, sal_Bool bChkStart ) // #115901#
619 {
620 	sal_Bool bRet = sal_False;
621 	SwPaM* pCrsr = GetCrsr();
622 	if( pCrsr->GetNext() == pCrsr && !pCrsr->HasMark() &&
623 		( !bChkStart || !pCrsr->GetPoint()->nContent.GetIndex()) )
624 	{
625 		StartAllAction();		// Klammern fuers Updaten !!
626         // #115901#
627 		bRet = GetDoc()->NumOrNoNum( pCrsr->GetPoint()->nNode, !bNumOn ); // #i29560#
628 		EndAllAction();
629 	}
630 	return bRet;
631 }
632 
633 sal_Bool SwEditShell::IsNoNum( sal_Bool bChkStart ) const
634 {
635 	// ein Backspace im Absatz ohne Nummer wird zum Delete
636     sal_Bool bResult = sal_False;
637 	SwPaM* pCrsr = GetCrsr();
638 
639     if (pCrsr->GetNext() == pCrsr && !pCrsr->HasMark() &&
640 		(!bChkStart || !pCrsr->GetPoint()->nContent.GetIndex()))
641     {
642         const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
643 
644         if (pTxtNd)
645         {
646             bResult =  ! pTxtNd->IsCountedInList();
647         }
648     }
649 
650     return bResult;
651 }
652 
653 // --> OD 2008-02-29 #refactorlists# - removed <pHasChilds>
654 sal_uInt8 SwEditShell::GetNumLevel() const
655 {
656 	// gebe die akt. Ebene zurueck, auf der sich der Point vom Cursor befindet
657 	//sal_uInt8 nLevel = NO_NUMBERING;	//#outline level,zhaojianwei
658 	sal_uInt8 nLevel = MAXLEVEL;		//end,zhaojianwei
659 
660 	SwPaM* pCrsr = GetCrsr();
661 	const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
662 
663     // --> FME 2005-09-12 #124972# Made code robust:
664     ASSERT( pTxtNd, "GetNumLevel() without text node" )
665     if ( !pTxtNd )
666         return nLevel;
667     // <--
668 
669 	const SwNumRule* pRule = pTxtNd->GetNumRule();
670 	if(pRule)
671 	{
672         // --> OD 2008-05-09 #refactorlists#
673         const int nListLevelOfTxtNode( pTxtNd->GetActualListLevel() );
674         if ( nListLevelOfTxtNode >= 0 )
675         {
676             nLevel = static_cast<sal_uInt8>( nListLevelOfTxtNode );
677         }
678         // <--
679 	}
680 
681 	return nLevel;
682 }
683 
684 const SwNumRule* SwEditShell::GetCurNumRule() const
685 {
686 	return GetDoc()->GetCurrNumRule( *GetCrsr()->GetPoint() );
687 }
688 
689 // OD 2008-02-08 #newlistlevelattrs# - add handling of parameter <bResetIndentAttrs>
690 // --> OD 2008-03-17 #refactorlists#
691 void SwEditShell::SetCurNumRule( const SwNumRule& rRule,
692                                  const bool bCreateNewList,
693                                  const String sContinuedListId,
694                                  const bool bResetIndentAttrs )
695 {
696 	StartAllAction();
697 
698     GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
699 
700 	SwPaM* pCrsr = GetCrsr();
701 	if( pCrsr->GetNext() != pCrsr )			// Mehrfachselektion ?
702     {
703 		SwPamRanges aRangeArr( *pCrsr );
704 		SwPaM aPam( *pCrsr->GetPoint() );
705 		for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
706 		  {
707 		    aRangeArr.SetPam( n, aPam );
708             // --> OD 2008-02-08 #newlistlevelattrs#
709             // --> OD 2008-03-17 #refactorlists#
710             GetDoc()->SetNumRule( aPam, rRule,
711                                   bCreateNewList, sContinuedListId,
712                                   sal_True, bResetIndentAttrs );
713             // <--
714 		    GetDoc()->SetCounted( aPam, true );
715           }
716     }
717     else
718     {
719         // --> OD 2008-02-08 #newlistlevelattrs#
720         // --> OD 2008-03-17 #refactorlists#
721         GetDoc()->SetNumRule( *pCrsr, rRule,
722                               bCreateNewList, sContinuedListId,
723                               sal_True, bResetIndentAttrs );
724         GetDoc()->SetCounted( *pCrsr, true );
725     }
726     GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
727 
728 	EndAllAction();
729 }
730 
731 String SwEditShell::GetUniqueNumRuleName( const String* pChkStr, sal_Bool bAutoNum ) const
732 {
733 	return GetDoc()->GetUniqueNumRuleName( pChkStr, bAutoNum );
734 }
735 
736 void SwEditShell::ChgNumRuleFmts( const SwNumRule& rRule )
737 {
738 	StartAllAction();
739 	GetDoc()->ChgNumRuleFmts( rRule );
740 	EndAllAction();
741 }
742 
743 sal_Bool SwEditShell::ReplaceNumRule( const String& rOldRule, const String& rNewRule )
744 {
745 	StartAllAction();
746 	sal_Bool bRet = GetDoc()->ReplaceNumRule( *GetCrsr()->GetPoint(), rOldRule, rNewRule );
747 	EndAllAction();
748 	return bRet;
749 }
750 
751 void SwEditShell::SetNumRuleStart( sal_Bool bFlag )
752 {
753 	StartAllAction();
754 
755 	SwPaM* pCrsr = GetCrsr();
756 	if( pCrsr->GetNext() != pCrsr )			// Mehrfachselektion ?
757     {
758         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
759 		SwPamRanges aRangeArr( *pCrsr );
760 		SwPaM aPam( *pCrsr->GetPoint() );
761 		for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
762 			GetDoc()->SetNumRuleStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), bFlag );
763         GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
764     }
765     else
766 		GetDoc()->SetNumRuleStart( *pCrsr->GetPoint(), bFlag );
767 
768 	EndAllAction();
769 }
770 
771 sal_Bool SwEditShell::IsNumRuleStart() const
772 {
773     sal_Bool bResult = sal_False;
774 	const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode();
775 	if( pTxtNd )
776         bResult = pTxtNd->IsListRestart() ? sal_True : sal_False;
777 	return bResult;
778 }
779 
780 void SwEditShell::SetNodeNumStart( sal_uInt16 nStt )
781 {
782 	StartAllAction();
783 
784 	SwPaM* pCrsr = GetCrsr();
785 	if( pCrsr->GetNext() != pCrsr )			// Mehrfachselektion ?
786     {
787         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
788 		SwPamRanges aRangeArr( *pCrsr );
789 		SwPaM aPam( *pCrsr->GetPoint() );
790 		for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
791 			GetDoc()->SetNodeNumStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), nStt );
792         GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
793     }
794     else
795 		GetDoc()->SetNodeNumStart( *pCrsr->GetPoint(), nStt );
796 
797 	EndAllAction();
798 }
799 
800 sal_uInt16 SwEditShell::GetNodeNumStart() const
801 {
802 	const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode();
803     // --> OD 2008-02-28 #refactorlists#
804     // correction: check, if list restart value is set at text node and
805     // use new method <SwTxtNode::GetAttrListRestartValue()>.
806     // return USHRT_MAX, if no list restart value is found.
807     if ( pTxtNd && pTxtNd->HasAttrListRestartValue() )
808     {
809         return static_cast<sal_uInt16>(pTxtNd->GetAttrListRestartValue());
810     }
811     return USHRT_MAX;
812     // <--
813 }
814 
815 /*-- 26.08.2005 14:47:17---------------------------------------------------
816 
817   -----------------------------------------------------------------------*/
818 // --> OD 2008-03-18 #refactorlists#
819 const SwNumRule * SwEditShell::SearchNumRule( const bool bForward,
820                                               const bool bNum,
821                                               const bool bOutline,
822                                               int nNonEmptyAllowed,
823                                               String& sListId )
824 {
825     return GetDoc()->SearchNumRule( *(bForward ? GetCrsr()->End() : GetCrsr()->Start()),
826                                     bForward, bNum, bOutline, nNonEmptyAllowed,
827                                     sListId );
828 }
829 // <--
830