1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #include <editsh.hxx>
30cdf0e10cSrcweir #include <edimp.hxx>
31cdf0e10cSrcweir #include <doc.hxx>
32cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
33cdf0e10cSrcweir #include <ndtxt.hxx>
34cdf0e10cSrcweir #include <paratr.hxx>
35cdf0e10cSrcweir #include <swundo.hxx>
36cdf0e10cSrcweir #include <numrule.hxx>
37cdf0e10cSrcweir
SV_IMPL_VARARR_SORT(_SwPamRanges,SwPamRange)38cdf0e10cSrcweir SV_IMPL_VARARR_SORT( _SwPamRanges, SwPamRange )
39cdf0e10cSrcweir
40cdf0e10cSrcweir
41cdf0e10cSrcweir SwPamRanges::SwPamRanges( const SwPaM& rRing )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir const SwPaM* pTmp = &rRing;
44cdf0e10cSrcweir do {
45cdf0e10cSrcweir Insert( pTmp->GetMark()->nNode, pTmp->GetPoint()->nNode );
46cdf0e10cSrcweir } while( &rRing != ( pTmp = (const SwPaM*)pTmp->GetNext() ));
47cdf0e10cSrcweir }
48cdf0e10cSrcweir
49cdf0e10cSrcweir
Insert(const SwNodeIndex & rIdx1,const SwNodeIndex & rIdx2)50cdf0e10cSrcweir void SwPamRanges::Insert( const SwNodeIndex& rIdx1, const SwNodeIndex& rIdx2 )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir SwPamRange aRg( rIdx1.GetIndex(), rIdx2.GetIndex() );
53cdf0e10cSrcweir if( aRg.nEnd < aRg.nStart )
54cdf0e10cSrcweir { aRg.nStart = aRg.nEnd; aRg.nEnd = rIdx1.GetIndex(); }
55cdf0e10cSrcweir
56cdf0e10cSrcweir sal_uInt16 nPos = 0;
57cdf0e10cSrcweir const SwPamRange* pTmp;
58cdf0e10cSrcweir if( Count() && Seek_Entry( aRg, &nPos )) // suche Insert Position
59cdf0e10cSrcweir {
60cdf0e10cSrcweir // ist der im Array stehende kleiner ??
61cdf0e10cSrcweir if( ( pTmp = GetData()+ nPos )->nEnd < aRg.nEnd )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir aRg.nEnd = pTmp->nEnd;
64cdf0e10cSrcweir Remove( nPos, 1 ); // zusammenfassen
65cdf0e10cSrcweir }
66cdf0e10cSrcweir else
67cdf0e10cSrcweir return; // ende, weil schon alle zusammengefasst waren
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
70cdf0e10cSrcweir sal_Bool bEnde;
71cdf0e10cSrcweir do {
72cdf0e10cSrcweir bEnde = sal_True;
73cdf0e10cSrcweir
74cdf0e10cSrcweir // mit dem Vorgaenger zusammenfassen ??
75cdf0e10cSrcweir if( nPos > 0 )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir if( ( pTmp = GetData()+( nPos-1 ))->nEnd == aRg.nStart
78cdf0e10cSrcweir || pTmp->nEnd+1 == aRg.nStart )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir aRg.nStart = pTmp->nStart;
81cdf0e10cSrcweir bEnde = sal_False;
82cdf0e10cSrcweir Remove( --nPos, 1 ); // zusammenfassen
83cdf0e10cSrcweir }
84cdf0e10cSrcweir // SSelection im Bereich ??
85cdf0e10cSrcweir else if( pTmp->nStart <= aRg.nStart && aRg.nEnd <= pTmp->nEnd )
86cdf0e10cSrcweir return;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir // mit dem Nachfolger zusammenfassen ??
89cdf0e10cSrcweir if( nPos < Count() )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir if( ( pTmp = GetData() + nPos )->nStart == aRg.nEnd ||
92cdf0e10cSrcweir pTmp->nStart == aRg.nEnd+1 )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir aRg.nEnd = pTmp->nEnd;
95cdf0e10cSrcweir bEnde = sal_False;
96cdf0e10cSrcweir Remove( nPos, 1 ); // zusammenfassen
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir // SSelection im Bereich ??
100cdf0e10cSrcweir else if( pTmp->nStart <= aRg.nStart && aRg.nEnd <= pTmp->nEnd )
101cdf0e10cSrcweir return;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir } while( !bEnde );
104cdf0e10cSrcweir
105cdf0e10cSrcweir _SwPamRanges::Insert( aRg );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir
109cdf0e10cSrcweir
SetPam(sal_uInt16 nArrPos,SwPaM & rPam)110cdf0e10cSrcweir SwPaM& SwPamRanges::SetPam( sal_uInt16 nArrPos, SwPaM& rPam )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir ASSERT_ID( nArrPos < Count(), ERR_VAR_IDX );
113cdf0e10cSrcweir const SwPamRange& rTmp = *(GetData() + nArrPos );
114cdf0e10cSrcweir rPam.GetPoint()->nNode = rTmp.nStart;
115cdf0e10cSrcweir rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 );
116cdf0e10cSrcweir rPam.SetMark();
117cdf0e10cSrcweir rPam.GetPoint()->nNode = rTmp.nEnd;
118cdf0e10cSrcweir rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 );
119cdf0e10cSrcweir return rPam;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir
123cdf0e10cSrcweir
124cdf0e10cSrcweir // Numerierung Outline Regelwerk
125cdf0e10cSrcweir
126cdf0e10cSrcweir
SetOutlineNumRule(const SwNumRule & rRule)127cdf0e10cSrcweir void SwEditShell::SetOutlineNumRule(const SwNumRule& rRule)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir StartAllAction(); // Klammern fuers Updaten !!
130cdf0e10cSrcweir GetDoc()->SetOutlineNumRule(rRule);
131cdf0e10cSrcweir EndAllAction();
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir
GetOutlineNumRule() const135cdf0e10cSrcweir const SwNumRule* SwEditShell::GetOutlineNumRule() const
136cdf0e10cSrcweir {
137cdf0e10cSrcweir return GetDoc()->GetOutlineNumRule();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir
140cdf0e10cSrcweir // setzt, wenn noch keine Numerierung, sonst wird geaendert
141cdf0e10cSrcweir // arbeitet mit alten und neuen Regeln, nur Differenzen aktualisieren
142cdf0e10cSrcweir
143cdf0e10cSrcweir // Absaetze ohne Numerierung, aber mit Einzuegen
144cdf0e10cSrcweir
NoNum()145cdf0e10cSrcweir sal_Bool SwEditShell::NoNum()
146cdf0e10cSrcweir {
147cdf0e10cSrcweir sal_Bool bRet = sal_True;
148cdf0e10cSrcweir StartAllAction();
149cdf0e10cSrcweir
150cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
151cdf0e10cSrcweir if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
152cdf0e10cSrcweir {
153cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
154cdf0e10cSrcweir SwPamRanges aRangeArr( *pCrsr );
155cdf0e10cSrcweir SwPaM aPam( *pCrsr->GetPoint() );
156cdf0e10cSrcweir for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
157cdf0e10cSrcweir bRet = bRet && GetDoc()->NoNum( aRangeArr.SetPam( n, aPam ));
158cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
159cdf0e10cSrcweir }
160cdf0e10cSrcweir else
161cdf0e10cSrcweir bRet = GetDoc()->NoNum( *pCrsr );
162cdf0e10cSrcweir
163cdf0e10cSrcweir EndAllAction();
164cdf0e10cSrcweir return bRet;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir // Loeschen, Splitten der Aufzaehlungsliste
SelectionHasNumber() const1671ff378efSZheng Fan sal_Bool SwEditShell::SelectionHasNumber() const
1681ff378efSZheng Fan {
1691ff378efSZheng Fan sal_Bool bResult = HasNumber();
1701ff378efSZheng Fan const SwTxtNode * pTxtNd =
1711ff378efSZheng Fan GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
1721ff378efSZheng Fan if (!bResult && pTxtNd && pTxtNd->Len()==0 && !pTxtNd->GetNumRule()) {
1731ff378efSZheng Fan SwPamRanges aRangeArr( *GetCrsr() );
1741ff378efSZheng Fan SwPaM aPam( *GetCrsr()->GetPoint() );
1751ff378efSZheng Fan for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
1761ff378efSZheng Fan {
1771ff378efSZheng Fan aRangeArr.SetPam( n, aPam );
1781ff378efSZheng Fan {
1791ff378efSZheng Fan sal_uInt32 nStt = aPam.GetPoint()->nNode.GetIndex(),
1801ff378efSZheng Fan nEnd = aPam.GetMark()->nNode.GetIndex();
1811ff378efSZheng Fan if( nStt > nEnd )
1821ff378efSZheng Fan {
1831ff378efSZheng Fan sal_uInt32 nTmp = nStt; nStt = nEnd; nEnd = nTmp;
1841ff378efSZheng Fan }
1851ff378efSZheng Fan for (sal_uInt32 nPos = nStt; nPos<=nEnd; nPos++) {
1861ff378efSZheng Fan SwTxtNode * pTxtNd = pDoc->GetNodes()[nPos]->GetTxtNode();
1871ff378efSZheng Fan if (pTxtNd && pTxtNd->Len()!=0)
1881ff378efSZheng Fan {
1891ff378efSZheng Fan bResult = pTxtNd->HasNumber();
1901ff378efSZheng Fan
1911ff378efSZheng Fan // --> OD 2005-10-26 #b6340308#
1921ff378efSZheng Fan // special case: outline numbered, not counted paragraph
1931ff378efSZheng Fan if ( bResult &&
1941ff378efSZheng Fan pTxtNd->GetNumRule() == GetDoc()->GetOutlineNumRule() &&
1951ff378efSZheng Fan !pTxtNd->IsCountedInList() )
1961ff378efSZheng Fan {
1971ff378efSZheng Fan bResult = sal_False;
1981ff378efSZheng Fan }
1991ff378efSZheng Fan if (bResult==sal_False) {
2001ff378efSZheng Fan break;
2011ff378efSZheng Fan }
2021ff378efSZheng Fan // <--
2031ff378efSZheng Fan }
2041ff378efSZheng Fan }
2051ff378efSZheng Fan }
2061ff378efSZheng Fan }
2071ff378efSZheng Fan
2081ff378efSZheng Fan }
209cdf0e10cSrcweir
2101ff378efSZheng Fan return bResult;
2111ff378efSZheng Fan }
2120deba7fbSSteve Yin //add a new function to determine number on/off status
SelectionHasBullet() const2131ff378efSZheng Fan sal_Bool SwEditShell::SelectionHasBullet() const
2141ff378efSZheng Fan {
2151ff378efSZheng Fan sal_Bool bResult = HasBullet();
2161ff378efSZheng Fan const SwTxtNode * pTxtNd =
2171ff378efSZheng Fan GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
2181ff378efSZheng Fan if (!bResult && pTxtNd && pTxtNd->Len()==0 && !pTxtNd->GetNumRule()) {
2191ff378efSZheng Fan SwPamRanges aRangeArr( *GetCrsr() );
2201ff378efSZheng Fan SwPaM aPam( *GetCrsr()->GetPoint() );
2211ff378efSZheng Fan for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
2221ff378efSZheng Fan {
2231ff378efSZheng Fan aRangeArr.SetPam( n, aPam );
2241ff378efSZheng Fan {
2251ff378efSZheng Fan sal_uInt32 nStt = aPam.GetPoint()->nNode.GetIndex(),
2261ff378efSZheng Fan nEnd = aPam.GetMark()->nNode.GetIndex();
2271ff378efSZheng Fan if( nStt > nEnd )
2281ff378efSZheng Fan {
2291ff378efSZheng Fan sal_uInt32 nTmp = nStt; nStt = nEnd; nEnd = nTmp;
2301ff378efSZheng Fan }
2311ff378efSZheng Fan for (sal_uInt32 nPos = nStt; nPos<=nEnd; nPos++) {
2321ff378efSZheng Fan SwTxtNode * pTxtNd = pDoc->GetNodes()[nPos]->GetTxtNode();
2331ff378efSZheng Fan if (pTxtNd && pTxtNd->Len()!=0)
2341ff378efSZheng Fan {
2351ff378efSZheng Fan bResult = pTxtNd->HasBullet();
2361ff378efSZheng Fan
2371ff378efSZheng Fan if (bResult==sal_False) {
2381ff378efSZheng Fan break;
2391ff378efSZheng Fan }
2401ff378efSZheng Fan }
2411ff378efSZheng Fan }
2421ff378efSZheng Fan }
2431ff378efSZheng Fan }
2441ff378efSZheng Fan
2451ff378efSZheng Fan }
2461ff378efSZheng Fan
2471ff378efSZheng Fan return bResult;
2481ff378efSZheng Fan }
249cdf0e10cSrcweir // -> #i29560#
HasNumber() const250cdf0e10cSrcweir sal_Bool SwEditShell::HasNumber() const
251cdf0e10cSrcweir {
252cdf0e10cSrcweir sal_Bool bResult = sal_False;
253cdf0e10cSrcweir
254cdf0e10cSrcweir const SwTxtNode * pTxtNd =
255cdf0e10cSrcweir GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
256cdf0e10cSrcweir
257cdf0e10cSrcweir if (pTxtNd)
258cdf0e10cSrcweir {
259cdf0e10cSrcweir bResult = pTxtNd->HasNumber();
260cdf0e10cSrcweir
261cdf0e10cSrcweir // --> OD 2005-10-26 #b6340308#
262cdf0e10cSrcweir // special case: outline numbered, not counted paragraph
263cdf0e10cSrcweir if ( bResult &&
264cdf0e10cSrcweir pTxtNd->GetNumRule() == GetDoc()->GetOutlineNumRule() &&
265cdf0e10cSrcweir !pTxtNd->IsCountedInList() )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir bResult = sal_False;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir // <--
270cdf0e10cSrcweir }
271cdf0e10cSrcweir
272cdf0e10cSrcweir return bResult;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir
HasBullet() const275cdf0e10cSrcweir sal_Bool SwEditShell::HasBullet() const
276cdf0e10cSrcweir {
277cdf0e10cSrcweir sal_Bool bResult = sal_False;
278cdf0e10cSrcweir
279cdf0e10cSrcweir const SwTxtNode * pTxtNd =
280cdf0e10cSrcweir GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode();
281cdf0e10cSrcweir
282cdf0e10cSrcweir if (pTxtNd)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir bResult = pTxtNd->HasBullet();
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
287cdf0e10cSrcweir return bResult;
288cdf0e10cSrcweir }
289cdf0e10cSrcweir // <- #i29560#
290cdf0e10cSrcweir
DelNumRules()291cdf0e10cSrcweir void SwEditShell::DelNumRules()
292cdf0e10cSrcweir {
293cdf0e10cSrcweir StartAllAction();
294cdf0e10cSrcweir
295cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
296cdf0e10cSrcweir if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
297cdf0e10cSrcweir {
298cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
299cdf0e10cSrcweir SwPamRanges aRangeArr( *pCrsr );
300cdf0e10cSrcweir SwPaM aPam( *pCrsr->GetPoint() );
301cdf0e10cSrcweir for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir GetDoc()->DelNumRules( aRangeArr.SetPam( n, aPam ) );
304cdf0e10cSrcweir }
305cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
306cdf0e10cSrcweir }
307cdf0e10cSrcweir else
308cdf0e10cSrcweir GetDoc()->DelNumRules( *pCrsr );
309cdf0e10cSrcweir
310cdf0e10cSrcweir // rufe das AttrChangeNotify auf der UI-Seite. Sollte eigentlich
311cdf0e10cSrcweir // ueberfluessig sein, aber VB hatte darueber eine Bugrep.
312cdf0e10cSrcweir CallChgLnk();
313cdf0e10cSrcweir
314cdf0e10cSrcweir // --> OD 2005-10-24 #126346# - cursor can not be anymore in
315cdf0e10cSrcweir // front of a label, because numbering/bullet is deleted.
316cdf0e10cSrcweir SetInFrontOfLabel( sal_False );
317cdf0e10cSrcweir // <--
318cdf0e10cSrcweir
319cdf0e10cSrcweir GetDoc()->SetModified();
320cdf0e10cSrcweir EndAllAction();
321cdf0e10cSrcweir }
322cdf0e10cSrcweir
323cdf0e10cSrcweir // Hoch-/Runterstufen
324cdf0e10cSrcweir
325cdf0e10cSrcweir
NumUpDown(sal_Bool bDown)326cdf0e10cSrcweir sal_Bool SwEditShell::NumUpDown( sal_Bool bDown )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir StartAllAction();
329cdf0e10cSrcweir
330cdf0e10cSrcweir sal_Bool bRet = sal_True;
331cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
332cdf0e10cSrcweir if( pCrsr->GetNext() == pCrsr ) // keine Mehrfachselektion ?
333cdf0e10cSrcweir bRet = GetDoc()->NumUpDown( *pCrsr, bDown );
334cdf0e10cSrcweir else
335cdf0e10cSrcweir {
336cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
337cdf0e10cSrcweir SwPamRanges aRangeArr( *pCrsr );
338cdf0e10cSrcweir SwPaM aPam( *pCrsr->GetPoint() );
339cdf0e10cSrcweir for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
340cdf0e10cSrcweir bRet = bRet && GetDoc()->NumUpDown( aRangeArr.SetPam( n, aPam ), bDown );
341cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
342cdf0e10cSrcweir }
343cdf0e10cSrcweir GetDoc()->SetModified();
344cdf0e10cSrcweir
345cdf0e10cSrcweir // --> FME 2005-09-19 #i54693# Update marked numbering levels
346cdf0e10cSrcweir if ( IsInFrontOfLabel() )
347cdf0e10cSrcweir UpdateMarkedListLevel();
348cdf0e10cSrcweir // <--
349cdf0e10cSrcweir
350cdf0e10cSrcweir CallChgLnk();
351cdf0e10cSrcweir
352cdf0e10cSrcweir EndAllAction();
353cdf0e10cSrcweir return bRet;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir // -> #i23726#
IsFirstOfNumRule() const356cdf0e10cSrcweir sal_Bool SwEditShell::IsFirstOfNumRule() const
357cdf0e10cSrcweir {
358cdf0e10cSrcweir sal_Bool bResult = sal_False;
359cdf0e10cSrcweir
360cdf0e10cSrcweir SwPaM * pCrsr = GetCrsr();
361cdf0e10cSrcweir if (pCrsr->GetNext() == pCrsr)
362cdf0e10cSrcweir {
363cdf0e10cSrcweir bResult = IsFirstOfNumRule(*pCrsr);
364cdf0e10cSrcweir }
365cdf0e10cSrcweir
366cdf0e10cSrcweir return bResult;
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
IsFirstOfNumRule(const SwPaM & rPaM) const369cdf0e10cSrcweir sal_Bool SwEditShell::IsFirstOfNumRule(const SwPaM & rPaM) const
370cdf0e10cSrcweir {
371cdf0e10cSrcweir sal_Bool bResult = sal_False;
372cdf0e10cSrcweir
373cdf0e10cSrcweir SwPosition aPos(*rPaM.GetPoint());
374cdf0e10cSrcweir bResult = GetDoc()->IsFirstOfNumRule(aPos);
375cdf0e10cSrcweir
376cdf0e10cSrcweir return bResult;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir // <- #i23726#
379cdf0e10cSrcweir
380cdf0e10cSrcweir // -> #i23725#
381cdf0e10cSrcweir // --> OD 2008-06-09 #i90078#
382cdf0e10cSrcweir // Remove unused default parameter <nLevel> and <bRelative>.
383cdf0e10cSrcweir // Adjust method name and parameter name
ChangeIndentOfAllListLevels(short nDiff)384cdf0e10cSrcweir void SwEditShell::ChangeIndentOfAllListLevels( short nDiff )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir StartAllAction();
387cdf0e10cSrcweir
388cdf0e10cSrcweir const SwNumRule *pCurNumRule = GetCurNumRule();
389cdf0e10cSrcweir //#120911# check if numbering rule really exists
390cdf0e10cSrcweir if (pCurNumRule)
391cdf0e10cSrcweir {
392cdf0e10cSrcweir SwNumRule aRule(*pCurNumRule);
393cdf0e10cSrcweir // --> OD 2008-06-09 #i90078#
394cdf0e10cSrcweir aRule.ChangeIndent( nDiff );
395cdf0e10cSrcweir // <--
396cdf0e10cSrcweir
397cdf0e10cSrcweir // --> OD 2008-03-17 #refactorlists#
398cdf0e10cSrcweir // no start of new list
399cdf0e10cSrcweir SetCurNumRule( aRule, false );
400cdf0e10cSrcweir // <--
401cdf0e10cSrcweir }
402cdf0e10cSrcweir
403cdf0e10cSrcweir EndAllAction();
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir // --> OD 2008-06-09 #i90078#
407cdf0e10cSrcweir // Adjust method name
SetIndent(short nIndent,const SwPosition & rPos)408cdf0e10cSrcweir void SwEditShell::SetIndent(short nIndent, const SwPosition & rPos)
409cdf0e10cSrcweir // <--
410cdf0e10cSrcweir {
411cdf0e10cSrcweir StartAllAction();
412cdf0e10cSrcweir
413cdf0e10cSrcweir SwNumRule *pCurNumRule = GetDoc()->GetCurrNumRule(rPos);
414cdf0e10cSrcweir
415cdf0e10cSrcweir if (pCurNumRule)
416cdf0e10cSrcweir {
417cdf0e10cSrcweir SwPaM aPaM(rPos);
418cdf0e10cSrcweir SwTxtNode * pTxtNode = aPaM.GetNode()->GetTxtNode();
419cdf0e10cSrcweir
420cdf0e10cSrcweir // --> OD 2008-06-09 #i90078#
421cdf0e10cSrcweir // int nLevel = -1;
422cdf0e10cSrcweir // int nReferenceLevel = pTxtNode->GetActualListLevel();
423cdf0e10cSrcweir // if (! IsFirstOfNumRule(aPaM))
424cdf0e10cSrcweir // nLevel = nReferenceLevel;
425cdf0e10cSrcweir
426cdf0e10cSrcweir SwNumRule aRule(*pCurNumRule);
427cdf0e10cSrcweir // aRule.ChangeIndent(nIndent, nLevel, nReferenceLevel, sal_False);
428cdf0e10cSrcweir if ( IsFirstOfNumRule() )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir aRule.SetIndentOfFirstListLevelAndChangeOthers( nIndent );
431cdf0e10cSrcweir }
432cdf0e10cSrcweir else if ( pTxtNode->GetActualListLevel() >= 0 )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir aRule.SetIndent( nIndent,
435cdf0e10cSrcweir static_cast<sal_uInt16>(pTxtNode->GetActualListLevel()) );
436cdf0e10cSrcweir }
437cdf0e10cSrcweir // <--
438cdf0e10cSrcweir
439cdf0e10cSrcweir // --> OD 2005-02-18 #i42921# - 3rd parameter = false in order to
440cdf0e10cSrcweir // suppress setting of num rule at <aPaM>.
441cdf0e10cSrcweir // --> OD 2008-03-17 #refactorlists#
442cdf0e10cSrcweir // do not apply any list
443cdf0e10cSrcweir GetDoc()->SetNumRule( aPaM, aRule, false, String(), sal_False );
444cdf0e10cSrcweir // <--
445cdf0e10cSrcweir }
446cdf0e10cSrcweir
447cdf0e10cSrcweir EndAllAction();
448cdf0e10cSrcweir }
449cdf0e10cSrcweir // <- #i23725#
450cdf0e10cSrcweir
MoveParagraph(long nOffset)451cdf0e10cSrcweir sal_Bool SwEditShell::MoveParagraph( long nOffset )
452cdf0e10cSrcweir {
453cdf0e10cSrcweir StartAllAction();
454cdf0e10cSrcweir
455cdf0e10cSrcweir SwPaM *pCrsr = GetCrsr();
456cdf0e10cSrcweir if( !pCrsr->HasMark() )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir // sorge dafuer, das Bound1 und Bound2 im gleichen Node stehen
459cdf0e10cSrcweir pCrsr->SetMark();
460cdf0e10cSrcweir pCrsr->DeleteMark();
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
463cdf0e10cSrcweir sal_Bool bRet = GetDoc()->MoveParagraph( *pCrsr, nOffset );
464cdf0e10cSrcweir
465cdf0e10cSrcweir GetDoc()->SetModified();
466cdf0e10cSrcweir EndAllAction();
467cdf0e10cSrcweir return bRet;
468cdf0e10cSrcweir }
469cdf0e10cSrcweir
470cdf0e10cSrcweir //#outline level add by zhaojianwei
GetCurrentParaOutlineLevel() const471cdf0e10cSrcweir int SwEditShell::GetCurrentParaOutlineLevel( ) const
472cdf0e10cSrcweir {
473cdf0e10cSrcweir int nLevel = 0;
474cdf0e10cSrcweir
475cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
476cdf0e10cSrcweir const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
477cdf0e10cSrcweir if( pTxtNd )
478cdf0e10cSrcweir nLevel = pTxtNd->GetAttrOutlineLevel();
479cdf0e10cSrcweir return nLevel;
480cdf0e10cSrcweir }
481cdf0e10cSrcweir //<-end,zhaojianwei
482cdf0e10cSrcweir
GetCurrentOutlineLevels(sal_uInt8 & rUpper,sal_uInt8 & rLower)483cdf0e10cSrcweir void SwEditShell::GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
486cdf0e10cSrcweir SwPaM aCrsr( *pCrsr->Start() );
487cdf0e10cSrcweir aCrsr.SetMark();
488cdf0e10cSrcweir if( pCrsr->HasMark() )
489cdf0e10cSrcweir *aCrsr.GetPoint() = *pCrsr->End();
490cdf0e10cSrcweir GetDoc()->GotoNextNum( *aCrsr.GetPoint(), sal_False,
491cdf0e10cSrcweir &rUpper, &rLower );
492cdf0e10cSrcweir }
493cdf0e10cSrcweir
MoveNumParas(sal_Bool bUpperLower,sal_Bool bUpperLeft)494cdf0e10cSrcweir sal_Bool SwEditShell::MoveNumParas( sal_Bool bUpperLower, sal_Bool bUpperLeft )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir StartAllAction();
497cdf0e10cSrcweir
498cdf0e10cSrcweir // auf alle Selektionen ??
499cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
500cdf0e10cSrcweir SwPaM aCrsr( *pCrsr->Start() );
501cdf0e10cSrcweir aCrsr.SetMark();
502cdf0e10cSrcweir
503cdf0e10cSrcweir if( pCrsr->HasMark() )
504cdf0e10cSrcweir *aCrsr.GetPoint() = *pCrsr->End();
505cdf0e10cSrcweir
506cdf0e10cSrcweir sal_Bool bRet = sal_False;
507cdf0e10cSrcweir sal_uInt8 nUpperLevel, nLowerLevel;
508cdf0e10cSrcweir if( GetDoc()->GotoNextNum( *aCrsr.GetPoint(), sal_False,
509cdf0e10cSrcweir &nUpperLevel, &nLowerLevel ))
510cdf0e10cSrcweir {
511cdf0e10cSrcweir if( bUpperLower )
512cdf0e10cSrcweir {
513cdf0e10cSrcweir // ueber die naechste Nummerierung
514cdf0e10cSrcweir long nOffset = 0;
515cdf0e10cSrcweir const SwNode* pNd;
516cdf0e10cSrcweir
517cdf0e10cSrcweir if( bUpperLeft ) // verschiebe nach oben
518cdf0e10cSrcweir {
519cdf0e10cSrcweir SwPosition aPos( *aCrsr.GetMark() );
520cdf0e10cSrcweir if( GetDoc()->GotoPrevNum( aPos, sal_False ) )
521cdf0e10cSrcweir nOffset = aPos.nNode.GetIndex() -
522cdf0e10cSrcweir aCrsr.GetMark()->nNode.GetIndex();
523cdf0e10cSrcweir else
524cdf0e10cSrcweir {
525cdf0e10cSrcweir sal_uLong nStt = aPos.nNode.GetIndex(), nIdx = nStt - 1;
526cdf0e10cSrcweir while( nIdx && (
527cdf0e10cSrcweir ( pNd = GetDoc()->GetNodes()[ nIdx ])->IsSectionNode() ||
528cdf0e10cSrcweir ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode())))
529cdf0e10cSrcweir --nIdx;
530cdf0e10cSrcweir if( GetDoc()->GetNodes()[ nIdx ]->IsTxtNode() )
531cdf0e10cSrcweir nOffset = nIdx - nStt;
532cdf0e10cSrcweir }
533cdf0e10cSrcweir }
534cdf0e10cSrcweir else // verschiebe nach unten
535cdf0e10cSrcweir {
536cdf0e10cSrcweir const SwNumRule* pOrig = aCrsr.GetNode(sal_False)->GetTxtNode()->GetNumRule();
537cdf0e10cSrcweir if( aCrsr.GetNode()->IsTxtNode() &&
538cdf0e10cSrcweir pOrig == aCrsr.GetNode()->GetTxtNode()->GetNumRule() )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir sal_uLong nStt = aCrsr.GetPoint()->nNode.GetIndex(), nIdx = nStt+1;
541cdf0e10cSrcweir
542cdf0e10cSrcweir while (nIdx < GetDoc()->GetNodes().Count()-1)
543cdf0e10cSrcweir {
544cdf0e10cSrcweir pNd = GetDoc()->GetNodes()[ nIdx ];
545cdf0e10cSrcweir
546cdf0e10cSrcweir if (pNd->IsSectionNode() ||
547cdf0e10cSrcweir ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode()) ||
548cdf0e10cSrcweir ( pNd->IsTxtNode() && pOrig == ((SwTxtNode*)pNd)->GetNumRule() &&
549cdf0e10cSrcweir ((SwTxtNode*)pNd)->GetActualListLevel() > nUpperLevel ))
550cdf0e10cSrcweir {
551cdf0e10cSrcweir ++nIdx;
552cdf0e10cSrcweir }
553cdf0e10cSrcweir // --> OD 2005-11-14 #i57856#
554cdf0e10cSrcweir else
555cdf0e10cSrcweir {
556cdf0e10cSrcweir break;
557cdf0e10cSrcweir }
558cdf0e10cSrcweir // <--
559cdf0e10cSrcweir }
560cdf0e10cSrcweir
561cdf0e10cSrcweir if( nStt == nIdx || !GetDoc()->GetNodes()[ nIdx ]->IsTxtNode() )
562cdf0e10cSrcweir nOffset = 1;
563cdf0e10cSrcweir else
564cdf0e10cSrcweir nOffset = nIdx - nStt;
565cdf0e10cSrcweir }
566cdf0e10cSrcweir else
567cdf0e10cSrcweir nOffset = 1;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir
570cdf0e10cSrcweir if( nOffset )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir aCrsr.Move( fnMoveBackward, fnGoNode );
573cdf0e10cSrcweir bRet = GetDoc()->MoveParagraph( aCrsr, nOffset );
574cdf0e10cSrcweir }
575cdf0e10cSrcweir }
576cdf0e10cSrcweir else if( bUpperLeft ? nUpperLevel : nLowerLevel+1 < MAXLEVEL )
577cdf0e10cSrcweir {
578cdf0e10cSrcweir aCrsr.Move( fnMoveBackward, fnGoNode );
579cdf0e10cSrcweir bRet = GetDoc()->NumUpDown( aCrsr, !bUpperLeft );
580cdf0e10cSrcweir }
581cdf0e10cSrcweir }
582cdf0e10cSrcweir
583cdf0e10cSrcweir GetDoc()->SetModified();
584cdf0e10cSrcweir EndAllAction();
585cdf0e10cSrcweir return bRet;
586cdf0e10cSrcweir }
587cdf0e10cSrcweir
OutlineUpDown(short nOffset)588cdf0e10cSrcweir sal_Bool SwEditShell::OutlineUpDown( short nOffset )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir StartAllAction();
591cdf0e10cSrcweir
592cdf0e10cSrcweir sal_Bool bRet = sal_True;
593cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
594cdf0e10cSrcweir if( pCrsr->GetNext() == pCrsr ) // keine Mehrfachselektion ?
595cdf0e10cSrcweir bRet = GetDoc()->OutlineUpDown( *pCrsr, nOffset );
596cdf0e10cSrcweir else
597cdf0e10cSrcweir {
598cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
599cdf0e10cSrcweir SwPamRanges aRangeArr( *pCrsr );
600cdf0e10cSrcweir SwPaM aPam( *pCrsr->GetPoint() );
601cdf0e10cSrcweir for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
602cdf0e10cSrcweir bRet = bRet && GetDoc()->OutlineUpDown(
603cdf0e10cSrcweir aRangeArr.SetPam( n, aPam ), nOffset );
604cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
605cdf0e10cSrcweir }
606cdf0e10cSrcweir GetDoc()->SetModified();
607cdf0e10cSrcweir EndAllAction();
608cdf0e10cSrcweir return bRet;
609cdf0e10cSrcweir }
610cdf0e10cSrcweir
611cdf0e10cSrcweir
MoveOutlinePara(short nOffset)612cdf0e10cSrcweir sal_Bool SwEditShell::MoveOutlinePara( short nOffset )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir StartAllAction();
615cdf0e10cSrcweir sal_Bool bRet = GetDoc()->MoveOutlinePara( *GetCrsr(), nOffset );
616cdf0e10cSrcweir EndAllAction();
617cdf0e10cSrcweir return bRet;
618cdf0e10cSrcweir }
619cdf0e10cSrcweir
620cdf0e10cSrcweir // Outlines and SubOutline are ReadOnly?
IsProtectedOutlinePara() const621cdf0e10cSrcweir sal_Bool SwEditShell::IsProtectedOutlinePara() const
622cdf0e10cSrcweir {
623cdf0e10cSrcweir sal_Bool bRet = sal_False;
624cdf0e10cSrcweir const SwNode& rNd = GetCrsr()->Start()->nNode.GetNode();
625cdf0e10cSrcweir if( rNd.IsTxtNode() )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir const SwOutlineNodes& rOutlNd = GetDoc()->GetNodes().GetOutLineNds();
628cdf0e10cSrcweir SwNodePtr pNd = (SwNodePtr)&rNd;
629cdf0e10cSrcweir sal_Bool bFirst = sal_True;
630cdf0e10cSrcweir sal_uInt16 nPos;
631cdf0e10cSrcweir int nLvl(0);
632cdf0e10cSrcweir if( !rOutlNd.Seek_Entry( pNd, &nPos ) && nPos )
633cdf0e10cSrcweir --nPos;
634cdf0e10cSrcweir
635cdf0e10cSrcweir for( ; nPos < rOutlNd.Count(); ++nPos )
636cdf0e10cSrcweir {
637cdf0e10cSrcweir SwNodePtr pTmpNd = rOutlNd[ nPos ];
638cdf0e10cSrcweir
639cdf0e10cSrcweir // --> OD 2008-04-02 #refactorlists#
640cdf0e10cSrcweir // sal_uInt8 nTmpLvl = GetRealLevel( pTmpNd->GetTxtNode()->
641cdf0e10cSrcweir // GetTxtColl()->GetOutlineLevel() );
642cdf0e10cSrcweir // int nTmpLvl = pTmpNd->GetTxtNode()->GetOutlineLevel();//#outline level,zhaojianwei
643cdf0e10cSrcweir int nTmpLvl = pTmpNd->GetTxtNode()->GetAttrOutlineLevel();
644cdf0e10cSrcweir // ASSERT( nTmpLvl >= 0 && nTmpLvl < MAXLEVEL,
645cdf0e10cSrcweir ASSERT( nTmpLvl >= 0 && nTmpLvl <= MAXLEVEL, //<-end,zhaojianwei
646cdf0e10cSrcweir "<SwEditShell::IsProtectedOutlinePara()>" );
647cdf0e10cSrcweir // <--
648cdf0e10cSrcweir if( bFirst )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir nLvl = nTmpLvl;
651cdf0e10cSrcweir bFirst = sal_False;
652cdf0e10cSrcweir }
653cdf0e10cSrcweir else if( nLvl >= nTmpLvl )
654cdf0e10cSrcweir break;
655cdf0e10cSrcweir
656cdf0e10cSrcweir if( pTmpNd->IsProtect() )
657cdf0e10cSrcweir {
658cdf0e10cSrcweir bRet = sal_True;
659cdf0e10cSrcweir break;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir }
662cdf0e10cSrcweir }
663cdf0e10cSrcweir #ifdef DBG_UTIL
664cdf0e10cSrcweir else
665cdf0e10cSrcweir {
666cdf0e10cSrcweir ASSERT(!this, "Cursor not on an outline node" );
667cdf0e10cSrcweir }
668cdf0e10cSrcweir #endif
669cdf0e10cSrcweir return bRet;
670cdf0e10cSrcweir }
671cdf0e10cSrcweir
672cdf0e10cSrcweir /** Test whether outline may be moved (bCopy == false)
673cdf0e10cSrcweir * or copied (bCopy == true)
674cdf0e10cSrcweir * Verify these conditions:
675cdf0e10cSrcweir * 1) outline must be within main body (and not in redline)
676cdf0e10cSrcweir * 2) outline must not be within table
677cdf0e10cSrcweir * 3) if bCopy is set, outline must not be write protected
678cdf0e10cSrcweir */
lcl_IsOutlineMoveAndCopyable(const SwDoc * pDoc,sal_uInt16 nIdx,bool bCopy)679cdf0e10cSrcweir sal_Bool lcl_IsOutlineMoveAndCopyable( const SwDoc* pDoc, sal_uInt16 nIdx, bool bCopy )
680cdf0e10cSrcweir {
681cdf0e10cSrcweir const SwNodes& rNds = pDoc->GetNodes();
682cdf0e10cSrcweir const SwNode* pNd = rNds.GetOutLineNds()[ nIdx ];
683cdf0e10cSrcweir return pNd->GetIndex() >= rNds.GetEndOfExtras().GetIndex() && // 1) body
684cdf0e10cSrcweir !pNd->FindTableNode() && // 2) table
685cdf0e10cSrcweir ( bCopy || !pNd->IsProtect() ); // 3) write
686cdf0e10cSrcweir }
687cdf0e10cSrcweir
IsOutlineMovable(sal_uInt16 nIdx) const688cdf0e10cSrcweir sal_Bool SwEditShell::IsOutlineMovable( sal_uInt16 nIdx ) const
689cdf0e10cSrcweir {
690cdf0e10cSrcweir return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, false );
691cdf0e10cSrcweir }
692cdf0e10cSrcweir
IsOutlineCopyable(sal_uInt16 nIdx) const693cdf0e10cSrcweir sal_Bool SwEditShell::IsOutlineCopyable( sal_uInt16 nIdx ) const
694cdf0e10cSrcweir {
695cdf0e10cSrcweir return lcl_IsOutlineMoveAndCopyable( GetDoc(), nIdx, true );
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
698cdf0e10cSrcweir
NumOrNoNum(sal_Bool bNumOn,sal_Bool bChkStart)699*23d8f725SOliver-Rainer Wittmann sal_Bool SwEditShell::NumOrNoNum(
700*23d8f725SOliver-Rainer Wittmann sal_Bool bNumOn,
701*23d8f725SOliver-Rainer Wittmann sal_Bool bChkStart )
702cdf0e10cSrcweir {
703*23d8f725SOliver-Rainer Wittmann sal_Bool bRet = sal_False;
704*23d8f725SOliver-Rainer Wittmann
705*23d8f725SOliver-Rainer Wittmann if ( !IsMultiSelection()
706*23d8f725SOliver-Rainer Wittmann && !HasSelection()
707*23d8f725SOliver-Rainer Wittmann && ( !bChkStart || IsSttPara() ) )
708*23d8f725SOliver-Rainer Wittmann {
709*23d8f725SOliver-Rainer Wittmann StartAllAction();
710*23d8f725SOliver-Rainer Wittmann bRet = GetDoc()->NumOrNoNum( GetCrsr()->GetPoint()->nNode, !bNumOn );
711*23d8f725SOliver-Rainer Wittmann EndAllAction();
712*23d8f725SOliver-Rainer Wittmann }
713*23d8f725SOliver-Rainer Wittmann return bRet;
714cdf0e10cSrcweir }
715cdf0e10cSrcweir
716*23d8f725SOliver-Rainer Wittmann
IsNoNum(sal_Bool bChkStart) const717cdf0e10cSrcweir sal_Bool SwEditShell::IsNoNum( sal_Bool bChkStart ) const
718cdf0e10cSrcweir {
719cdf0e10cSrcweir sal_Bool bResult = sal_False;
720cdf0e10cSrcweir
721*23d8f725SOliver-Rainer Wittmann if ( !IsMultiSelection()
722*23d8f725SOliver-Rainer Wittmann && !HasSelection()
723*23d8f725SOliver-Rainer Wittmann && ( !bChkStart || IsSttPara() ) )
724cdf0e10cSrcweir {
725*23d8f725SOliver-Rainer Wittmann const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode();
726*23d8f725SOliver-Rainer Wittmann if ( pTxtNd != NULL )
727cdf0e10cSrcweir {
728*23d8f725SOliver-Rainer Wittmann bResult = !pTxtNd->IsCountedInList();
729cdf0e10cSrcweir }
730cdf0e10cSrcweir }
731cdf0e10cSrcweir
732cdf0e10cSrcweir return bResult;
733cdf0e10cSrcweir }
734cdf0e10cSrcweir
GetNumLevel() const735cdf0e10cSrcweir sal_uInt8 SwEditShell::GetNumLevel() const
736cdf0e10cSrcweir {
73769a74367SOliver-Rainer Wittmann // gebe die akt. Ebene zurueck, auf der sich der Point vom Cursor befindet
73869a74367SOliver-Rainer Wittmann //sal_uInt8 nLevel = NO_NUMBERING; //#outline level,zhaojianwei
73969a74367SOliver-Rainer Wittmann sal_uInt8 nLevel = MAXLEVEL; //end,zhaojianwei
740cdf0e10cSrcweir
74169a74367SOliver-Rainer Wittmann SwPaM* pCrsr = GetCrsr();
74269a74367SOliver-Rainer Wittmann const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
743cdf0e10cSrcweir
744*23d8f725SOliver-Rainer Wittmann ASSERT( pTxtNd != NULL, "GetNumLevel() without text node" )
745*23d8f725SOliver-Rainer Wittmann if ( pTxtNd == NULL )
746cdf0e10cSrcweir return nLevel;
747cdf0e10cSrcweir
74869a74367SOliver-Rainer Wittmann const SwNumRule* pRule = pTxtNd->GetNumRule();
749*23d8f725SOliver-Rainer Wittmann if ( pRule != NULL )
75069a74367SOliver-Rainer Wittmann {
751cdf0e10cSrcweir const int nListLevelOfTxtNode( pTxtNd->GetActualListLevel() );
752cdf0e10cSrcweir if ( nListLevelOfTxtNode >= 0 )
753cdf0e10cSrcweir {
754cdf0e10cSrcweir nLevel = static_cast<sal_uInt8>( nListLevelOfTxtNode );
755cdf0e10cSrcweir }
75669a74367SOliver-Rainer Wittmann }
757cdf0e10cSrcweir
75869a74367SOliver-Rainer Wittmann return nLevel;
759cdf0e10cSrcweir }
760cdf0e10cSrcweir
GetCurNumRule() const761cdf0e10cSrcweir const SwNumRule* SwEditShell::GetCurNumRule() const
762cdf0e10cSrcweir {
763cdf0e10cSrcweir return GetDoc()->GetCurrNumRule( *GetCrsr()->GetPoint() );
764cdf0e10cSrcweir }
765cdf0e10cSrcweir
766cdf0e10cSrcweir // OD 2008-02-08 #newlistlevelattrs# - add handling of parameter <bResetIndentAttrs>
767cdf0e10cSrcweir // --> OD 2008-03-17 #refactorlists#
SetCurNumRule(const SwNumRule & rRule,const bool bCreateNewList,const String sContinuedListId,const bool bResetIndentAttrs)768cdf0e10cSrcweir void SwEditShell::SetCurNumRule( const SwNumRule& rRule,
769cdf0e10cSrcweir const bool bCreateNewList,
770cdf0e10cSrcweir const String sContinuedListId,
771cdf0e10cSrcweir const bool bResetIndentAttrs )
772cdf0e10cSrcweir {
77369a74367SOliver-Rainer Wittmann StartAllAction();
774cdf0e10cSrcweir
775cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
776cdf0e10cSrcweir
77769a74367SOliver-Rainer Wittmann SwPaM* pCrsr = GetCrsr();
778*23d8f725SOliver-Rainer Wittmann if( IsMultiSelection() )
779cdf0e10cSrcweir {
78069a74367SOliver-Rainer Wittmann SwPamRanges aRangeArr( *pCrsr );
78169a74367SOliver-Rainer Wittmann SwPaM aPam( *pCrsr->GetPoint() );
78269a74367SOliver-Rainer Wittmann for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
78369a74367SOliver-Rainer Wittmann {
78469a74367SOliver-Rainer Wittmann aRangeArr.SetPam( n, aPam );
785cdf0e10cSrcweir GetDoc()->SetNumRule( aPam, rRule,
786cdf0e10cSrcweir bCreateNewList, sContinuedListId,
787cdf0e10cSrcweir sal_True, bResetIndentAttrs );
78869a74367SOliver-Rainer Wittmann GetDoc()->SetCounted( aPam, true );
78969a74367SOliver-Rainer Wittmann }
790cdf0e10cSrcweir }
791cdf0e10cSrcweir else
792cdf0e10cSrcweir {
793cdf0e10cSrcweir GetDoc()->SetNumRule( *pCrsr, rRule,
794cdf0e10cSrcweir bCreateNewList, sContinuedListId,
795cdf0e10cSrcweir sal_True, bResetIndentAttrs );
796cdf0e10cSrcweir GetDoc()->SetCounted( *pCrsr, true );
797cdf0e10cSrcweir }
798cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
799cdf0e10cSrcweir
80069a74367SOliver-Rainer Wittmann EndAllAction();
801cdf0e10cSrcweir }
802cdf0e10cSrcweir
GetUniqueNumRuleName(const String * pChkStr,sal_Bool bAutoNum) const803cdf0e10cSrcweir String SwEditShell::GetUniqueNumRuleName( const String* pChkStr, sal_Bool bAutoNum ) const
804cdf0e10cSrcweir {
805cdf0e10cSrcweir return GetDoc()->GetUniqueNumRuleName( pChkStr, bAutoNum );
806cdf0e10cSrcweir }
807cdf0e10cSrcweir
ChgNumRuleFmts(const SwNumRule & rRule)808cdf0e10cSrcweir void SwEditShell::ChgNumRuleFmts( const SwNumRule& rRule )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir StartAllAction();
811cdf0e10cSrcweir GetDoc()->ChgNumRuleFmts( rRule );
812cdf0e10cSrcweir EndAllAction();
813cdf0e10cSrcweir }
814cdf0e10cSrcweir
ReplaceNumRule(const String & rOldRule,const String & rNewRule)815cdf0e10cSrcweir sal_Bool SwEditShell::ReplaceNumRule( const String& rOldRule, const String& rNewRule )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir StartAllAction();
818cdf0e10cSrcweir sal_Bool bRet = GetDoc()->ReplaceNumRule( *GetCrsr()->GetPoint(), rOldRule, rNewRule );
819cdf0e10cSrcweir EndAllAction();
820cdf0e10cSrcweir return bRet;
821cdf0e10cSrcweir }
822cdf0e10cSrcweir
SetNumRuleStart(sal_Bool bFlag)823cdf0e10cSrcweir void SwEditShell::SetNumRuleStart( sal_Bool bFlag )
824cdf0e10cSrcweir {
825cdf0e10cSrcweir StartAllAction();
826cdf0e10cSrcweir
827cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
828cdf0e10cSrcweir if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
829cdf0e10cSrcweir {
830cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
831cdf0e10cSrcweir SwPamRanges aRangeArr( *pCrsr );
832cdf0e10cSrcweir SwPaM aPam( *pCrsr->GetPoint() );
833cdf0e10cSrcweir for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
834cdf0e10cSrcweir GetDoc()->SetNumRuleStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), bFlag );
835cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
836cdf0e10cSrcweir }
837cdf0e10cSrcweir else
838cdf0e10cSrcweir GetDoc()->SetNumRuleStart( *pCrsr->GetPoint(), bFlag );
839cdf0e10cSrcweir
840cdf0e10cSrcweir EndAllAction();
841cdf0e10cSrcweir }
842cdf0e10cSrcweir
IsNumRuleStart() const843cdf0e10cSrcweir sal_Bool SwEditShell::IsNumRuleStart() const
844cdf0e10cSrcweir {
845cdf0e10cSrcweir sal_Bool bResult = sal_False;
846cdf0e10cSrcweir const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode();
847cdf0e10cSrcweir if( pTxtNd )
848cdf0e10cSrcweir bResult = pTxtNd->IsListRestart() ? sal_True : sal_False;
849cdf0e10cSrcweir return bResult;
850cdf0e10cSrcweir }
851cdf0e10cSrcweir
SetNodeNumStart(sal_uInt16 nStt)852cdf0e10cSrcweir void SwEditShell::SetNodeNumStart( sal_uInt16 nStt )
853cdf0e10cSrcweir {
854cdf0e10cSrcweir StartAllAction();
855cdf0e10cSrcweir
856cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
857cdf0e10cSrcweir if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
858cdf0e10cSrcweir {
859cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
860cdf0e10cSrcweir SwPamRanges aRangeArr( *pCrsr );
861cdf0e10cSrcweir SwPaM aPam( *pCrsr->GetPoint() );
862cdf0e10cSrcweir for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
863cdf0e10cSrcweir GetDoc()->SetNodeNumStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), nStt );
864cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
865cdf0e10cSrcweir }
866cdf0e10cSrcweir else
867cdf0e10cSrcweir GetDoc()->SetNodeNumStart( *pCrsr->GetPoint(), nStt );
868cdf0e10cSrcweir
869cdf0e10cSrcweir EndAllAction();
870cdf0e10cSrcweir }
871cdf0e10cSrcweir
GetNodeNumStart() const872cdf0e10cSrcweir sal_uInt16 SwEditShell::GetNodeNumStart() const
873cdf0e10cSrcweir {
874cdf0e10cSrcweir const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode();
875cdf0e10cSrcweir // --> OD 2008-02-28 #refactorlists#
876cdf0e10cSrcweir // correction: check, if list restart value is set at text node and
877cdf0e10cSrcweir // use new method <SwTxtNode::GetAttrListRestartValue()>.
878cdf0e10cSrcweir // return USHRT_MAX, if no list restart value is found.
879cdf0e10cSrcweir if ( pTxtNd && pTxtNd->HasAttrListRestartValue() )
880cdf0e10cSrcweir {
881cdf0e10cSrcweir return static_cast<sal_uInt16>(pTxtNd->GetAttrListRestartValue());
882cdf0e10cSrcweir }
883cdf0e10cSrcweir return USHRT_MAX;
884cdf0e10cSrcweir // <--
885cdf0e10cSrcweir }
886cdf0e10cSrcweir
887cdf0e10cSrcweir /*-- 26.08.2005 14:47:17---------------------------------------------------
888cdf0e10cSrcweir
889cdf0e10cSrcweir -----------------------------------------------------------------------*/
890cdf0e10cSrcweir // --> OD 2008-03-18 #refactorlists#
SearchNumRule(const bool bForward,const bool bNum,const bool bOutline,int nNonEmptyAllowed,String & sListId)891cdf0e10cSrcweir const SwNumRule * SwEditShell::SearchNumRule( const bool bForward,
892cdf0e10cSrcweir const bool bNum,
893cdf0e10cSrcweir const bool bOutline,
894cdf0e10cSrcweir int nNonEmptyAllowed,
895cdf0e10cSrcweir String& sListId )
896cdf0e10cSrcweir {
897cdf0e10cSrcweir return GetDoc()->SearchNumRule( *(bForward ? GetCrsr()->End() : GetCrsr()->Start()),
898cdf0e10cSrcweir bForward, bNum, bOutline, nNonEmptyAllowed,
899cdf0e10cSrcweir sListId );
900cdf0e10cSrcweir }
901cdf0e10cSrcweir // <--
902