xref: /trunk/main/svtools/source/edit/xtextedt.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5900e8ecSAndrew Rist  * distributed with this work for additional information
6*5900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*5900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*5900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist  * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*5900e8ecSAndrew Rist  * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*5900e8ecSAndrew Rist  *************************************************************/
21*5900e8ecSAndrew Rist 
22*5900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svtools/xtextedt.hxx>
28cdf0e10cSrcweir #include <vcl/svapp.hxx>  // International
29cdf0e10cSrcweir #include <unotools/textsearch.hxx>
30cdf0e10cSrcweir #include <com/sun/star/util/SearchOptions.hpp>
31cdf0e10cSrcweir #include <com/sun/star/util/SearchFlags.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir using namespace ::com::sun::star;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir // -------------------------------------------------------------------------
38cdf0e10cSrcweir // class ExtTextEngine
39cdf0e10cSrcweir // -------------------------------------------------------------------------
ExtTextEngine()40cdf0e10cSrcweir ExtTextEngine::ExtTextEngine() : maGroupChars( String::CreateFromAscii( "(){}[]", 6 ) )
41cdf0e10cSrcweir {
42cdf0e10cSrcweir }
43cdf0e10cSrcweir 
~ExtTextEngine()44cdf0e10cSrcweir ExtTextEngine::~ExtTextEngine()
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir 
MatchGroup(const TextPaM & rCursor) const48cdf0e10cSrcweir TextSelection ExtTextEngine::MatchGroup( const TextPaM& rCursor ) const
49cdf0e10cSrcweir {
50cdf0e10cSrcweir     TextSelection aSel( rCursor );
51cdf0e10cSrcweir     sal_uInt16 nPos = rCursor.GetIndex();
52cdf0e10cSrcweir     sal_uLong nPara = rCursor.GetPara();
53cdf0e10cSrcweir     sal_uLong nParas = GetParagraphCount();
54cdf0e10cSrcweir     if ( ( nPara < nParas ) && ( nPos < GetTextLen( nPara ) ) )
55cdf0e10cSrcweir     {
56cdf0e10cSrcweir         sal_uInt16 nMatchChar = maGroupChars.Search( GetText( rCursor.GetPara() ).GetChar( nPos ) );
57cdf0e10cSrcweir         if ( nMatchChar != STRING_NOTFOUND )
58cdf0e10cSrcweir         {
59cdf0e10cSrcweir             if ( ( nMatchChar % 2 ) == 0 )
60cdf0e10cSrcweir             {
61cdf0e10cSrcweir                 // Vorwaerts suchen...
62cdf0e10cSrcweir                 sal_Unicode nSC = maGroupChars.GetChar( nMatchChar );
63cdf0e10cSrcweir                 sal_Unicode nEC = maGroupChars.GetChar( nMatchChar+1 );
64cdf0e10cSrcweir 
65cdf0e10cSrcweir                 sal_uInt16 nCur = nPos+1;
66cdf0e10cSrcweir                 sal_uInt16 nLevel = 1;
67cdf0e10cSrcweir                 while ( nLevel && ( nPara < nParas ) )
68cdf0e10cSrcweir                 {
69cdf0e10cSrcweir                     XubString aStr = GetText( nPara );
70cdf0e10cSrcweir                     while ( nCur < aStr.Len() )
71cdf0e10cSrcweir                     {
72cdf0e10cSrcweir                         if ( aStr.GetChar( nCur ) == nSC )
73cdf0e10cSrcweir                             nLevel++;
74cdf0e10cSrcweir                         else if ( aStr.GetChar( nCur ) == nEC )
75cdf0e10cSrcweir                         {
76cdf0e10cSrcweir                             nLevel--;
77cdf0e10cSrcweir                             if ( !nLevel )
78cdf0e10cSrcweir                                 break;  // while nCur...
79cdf0e10cSrcweir                         }
80cdf0e10cSrcweir                         nCur++;
81cdf0e10cSrcweir                     }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir                     if ( nLevel )
84cdf0e10cSrcweir                     {
85cdf0e10cSrcweir                         nPara++;
86cdf0e10cSrcweir                         nCur = 0;
87cdf0e10cSrcweir                     }
88cdf0e10cSrcweir                 }
89cdf0e10cSrcweir                 if ( nLevel == 0 )  // gefunden
90cdf0e10cSrcweir                 {
91cdf0e10cSrcweir                     aSel.GetStart() = rCursor;
92cdf0e10cSrcweir                     aSel.GetEnd() = TextPaM( nPara, nCur+1 );
93cdf0e10cSrcweir                 }
94cdf0e10cSrcweir             }
95cdf0e10cSrcweir             else
96cdf0e10cSrcweir             {
97cdf0e10cSrcweir                 // Rueckwaerts suchen...
98cdf0e10cSrcweir                 xub_Unicode nEC = maGroupChars.GetChar( nMatchChar );
99cdf0e10cSrcweir                 xub_Unicode nSC = maGroupChars.GetChar( nMatchChar-1 );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir                 sal_uInt16 nCur = rCursor.GetIndex()-1;
102cdf0e10cSrcweir                 sal_uInt16 nLevel = 1;
103cdf0e10cSrcweir                 while ( nLevel )
104cdf0e10cSrcweir                 {
105cdf0e10cSrcweir                     if ( GetTextLen( nPara ) )
106cdf0e10cSrcweir                     {
107cdf0e10cSrcweir                         XubString aStr = GetText( nPara );
108cdf0e10cSrcweir                         while ( nCur )
109cdf0e10cSrcweir                         {
110cdf0e10cSrcweir                             if ( aStr.GetChar( nCur ) == nSC )
111cdf0e10cSrcweir                             {
112cdf0e10cSrcweir                                 nLevel--;
113cdf0e10cSrcweir                                 if ( !nLevel )
114cdf0e10cSrcweir                                     break;  // while nCur...
115cdf0e10cSrcweir                             }
116cdf0e10cSrcweir                             else if ( aStr.GetChar( nCur ) == nEC )
117cdf0e10cSrcweir                                 nLevel++;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir                             nCur--;
120cdf0e10cSrcweir                         }
121cdf0e10cSrcweir                     }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir                     if ( nLevel )
124cdf0e10cSrcweir                     {
125cdf0e10cSrcweir                         if ( nPara )
126cdf0e10cSrcweir                         {
127cdf0e10cSrcweir                             nPara--;
128cdf0e10cSrcweir                             nCur = GetTextLen( nPara )-1;   // egal ob negativ, weil if Len()
129cdf0e10cSrcweir                         }
130cdf0e10cSrcweir                         else
131cdf0e10cSrcweir                             break;
132cdf0e10cSrcweir                     }
133cdf0e10cSrcweir                 }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir                 if ( nLevel == 0 )  // gefunden
136cdf0e10cSrcweir                 {
137cdf0e10cSrcweir                     aSel.GetStart() = rCursor;
138cdf0e10cSrcweir                     aSel.GetStart().GetIndex()++;   // hinter das Zeichen
139cdf0e10cSrcweir                     aSel.GetEnd() = TextPaM( nPara, nCur );
140cdf0e10cSrcweir                 }
141cdf0e10cSrcweir             }
142cdf0e10cSrcweir         }
143cdf0e10cSrcweir     }
144cdf0e10cSrcweir     return aSel;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
Search(TextSelection & rSel,const util::SearchOptions & rSearchOptions,sal_Bool bForward)147cdf0e10cSrcweir sal_Bool ExtTextEngine::Search( TextSelection& rSel, const util::SearchOptions& rSearchOptions, sal_Bool bForward )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     TextSelection aSel( rSel );
150cdf0e10cSrcweir     aSel.Justify();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     sal_Bool bSearchInSelection = (0 != (rSearchOptions.searchFlag & util::SearchFlags::REG_NOT_BEGINOFLINE) );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     TextPaM aStartPaM( aSel.GetEnd() );
155cdf0e10cSrcweir     if ( aSel.HasRange() && ( ( bSearchInSelection && bForward ) || ( !bSearchInSelection && !bForward ) ) )
156cdf0e10cSrcweir     {
157cdf0e10cSrcweir         aStartPaM = aSel.GetStart();
158cdf0e10cSrcweir     }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     bool bFound = false;
161cdf0e10cSrcweir     sal_uLong nStartNode, nEndNode;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     if ( bSearchInSelection )
164cdf0e10cSrcweir         nEndNode = bForward ? aSel.GetEnd().GetPara() : aSel.GetStart().GetPara();
165cdf0e10cSrcweir     else
166cdf0e10cSrcweir         nEndNode = bForward ? (GetParagraphCount()-1) : 0;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     nStartNode = aStartPaM.GetPara();
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     util::SearchOptions aOptions( rSearchOptions );
171cdf0e10cSrcweir     aOptions.Locale = Application::GetSettings().GetLocale();
172cdf0e10cSrcweir     utl::TextSearch aSearcher( rSearchOptions );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     // ueber die Absaetze iterieren...
175cdf0e10cSrcweir     for ( sal_uLong nNode = nStartNode;
176cdf0e10cSrcweir             bForward ?  ( nNode <= nEndNode) : ( nNode >= nEndNode );
177cdf0e10cSrcweir             bForward ? nNode++ : nNode-- )
178cdf0e10cSrcweir     {
179cdf0e10cSrcweir         String aText = GetText( nNode );
180cdf0e10cSrcweir         sal_uInt16 nStartPos = 0;
181cdf0e10cSrcweir         sal_uInt16 nEndPos = aText.Len();
182cdf0e10cSrcweir         if ( nNode == nStartNode )
183cdf0e10cSrcweir         {
184cdf0e10cSrcweir             if ( bForward )
185cdf0e10cSrcweir                 nStartPos = aStartPaM.GetIndex();
186cdf0e10cSrcweir             else
187cdf0e10cSrcweir                 nEndPos = aStartPaM.GetIndex();
188cdf0e10cSrcweir         }
189cdf0e10cSrcweir         if ( ( nNode == nEndNode ) && bSearchInSelection )
190cdf0e10cSrcweir         {
191cdf0e10cSrcweir             if ( bForward )
192cdf0e10cSrcweir                 nEndPos = aSel.GetEnd().GetIndex();
193cdf0e10cSrcweir             else
194cdf0e10cSrcweir                 nStartPos = aSel.GetStart().GetIndex();
195cdf0e10cSrcweir         }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir         if ( bForward )
198cdf0e10cSrcweir             bFound = aSearcher.SearchFrwrd( aText, &nStartPos, &nEndPos );
199cdf0e10cSrcweir         else
200cdf0e10cSrcweir             bFound = aSearcher.SearchBkwrd( aText, &nEndPos, &nStartPos );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir         if ( bFound )
203cdf0e10cSrcweir         {
204cdf0e10cSrcweir             rSel.GetStart().GetPara() = nNode;
205cdf0e10cSrcweir             rSel.GetStart().GetIndex() = nStartPos;
206cdf0e10cSrcweir             rSel.GetEnd().GetPara() = nNode;
207cdf0e10cSrcweir             rSel.GetEnd().GetIndex() = nEndPos;
208cdf0e10cSrcweir             // Ueber den Absatz selektieren?
209cdf0e10cSrcweir             // Select over the paragraph?
210cdf0e10cSrcweir             // FIXME  This should be max long...
211cdf0e10cSrcweir             if( nEndPos == sal::static_int_cast<sal_uInt16>(-1) ) // sal_uInt16 for 0 and -1 !
212cdf0e10cSrcweir             {
213cdf0e10cSrcweir                 if ( (rSel.GetEnd().GetPara()+1) < GetParagraphCount() )
214cdf0e10cSrcweir                 {
215cdf0e10cSrcweir                     rSel.GetEnd().GetPara()++;
216cdf0e10cSrcweir                     rSel.GetEnd().GetIndex() = 0;
217cdf0e10cSrcweir                 }
218cdf0e10cSrcweir                 else
219cdf0e10cSrcweir                 {
220cdf0e10cSrcweir                     rSel.GetEnd().GetIndex() = nStartPos;
221cdf0e10cSrcweir                     bFound = false;
222cdf0e10cSrcweir                 }
223cdf0e10cSrcweir             }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir             break;
226cdf0e10cSrcweir         }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir         if ( !bForward && !nNode )  // Bei rueckwaertsuche, wenn nEndNode = 0:
229cdf0e10cSrcweir             break;
230cdf0e10cSrcweir     }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     return bFound;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 
236cdf0e10cSrcweir // -------------------------------------------------------------------------
237cdf0e10cSrcweir // class ExtTextView
238cdf0e10cSrcweir // -------------------------------------------------------------------------
ExtTextView(ExtTextEngine * pEng,Window * pWindow)239cdf0e10cSrcweir ExtTextView::ExtTextView( ExtTextEngine* pEng, Window* pWindow )
240cdf0e10cSrcweir     : TextView( pEng, pWindow )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
~ExtTextView()244cdf0e10cSrcweir ExtTextView::~ExtTextView()
245cdf0e10cSrcweir {
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
MatchGroup()248cdf0e10cSrcweir sal_Bool ExtTextView::MatchGroup()
249cdf0e10cSrcweir {
250cdf0e10cSrcweir     TextSelection aTmpSel( GetSelection() );
251cdf0e10cSrcweir     aTmpSel.Justify();
252cdf0e10cSrcweir     if ( ( aTmpSel.GetStart().GetPara() != aTmpSel.GetEnd().GetPara() ) ||
253cdf0e10cSrcweir          ( ( aTmpSel.GetEnd().GetIndex() - aTmpSel.GetStart().GetIndex() ) > 1 ) )
254cdf0e10cSrcweir     {
255cdf0e10cSrcweir         return sal_False;
256cdf0e10cSrcweir     }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir     TextSelection aMatchSel = ((ExtTextEngine*)GetTextEngine())->MatchGroup( aTmpSel.GetStart() );
259cdf0e10cSrcweir     if ( aMatchSel.HasRange() )
260cdf0e10cSrcweir         SetSelection( aMatchSel );
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     return aMatchSel.HasRange() ? sal_True : sal_False;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
Search(const util::SearchOptions & rSearchOptions,sal_Bool bForward)265cdf0e10cSrcweir sal_Bool ExtTextView::Search( const util::SearchOptions& rSearchOptions, sal_Bool bForward )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir     sal_Bool bFound = sal_False;
268cdf0e10cSrcweir     TextSelection aSel( GetSelection() );
269cdf0e10cSrcweir     if ( ((ExtTextEngine*)GetTextEngine())->Search( aSel, rSearchOptions, bForward ) )
270cdf0e10cSrcweir     {
271cdf0e10cSrcweir         bFound = sal_True;
272cdf0e10cSrcweir         // Erstmal den Anfang des Wortes als Selektion einstellen,
273cdf0e10cSrcweir         // damit das ganze Wort in den sichtbaren Bereich kommt.
274cdf0e10cSrcweir         SetSelection( aSel.GetStart() );
275cdf0e10cSrcweir         ShowCursor( sal_True, sal_False );
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir     else
278cdf0e10cSrcweir     {
279cdf0e10cSrcweir         aSel = GetSelection().GetEnd();
280cdf0e10cSrcweir     }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir     SetSelection( aSel );
283cdf0e10cSrcweir     ShowCursor();
284cdf0e10cSrcweir 
285cdf0e10cSrcweir     return bFound;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir 
Replace(const util::SearchOptions & rSearchOptions,sal_Bool bAll,sal_Bool bForward)288cdf0e10cSrcweir sal_uInt16 ExtTextView::Replace( const util::SearchOptions& rSearchOptions, sal_Bool bAll, sal_Bool bForward )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir     sal_uInt16 nFound = 0;
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     if ( !bAll )
293cdf0e10cSrcweir     {
294cdf0e10cSrcweir         if ( GetSelection().HasRange() )
295cdf0e10cSrcweir         {
296cdf0e10cSrcweir             InsertText( rSearchOptions.replaceString );
297cdf0e10cSrcweir             nFound = 1;
298cdf0e10cSrcweir             Search( rSearchOptions, bForward ); // gleich zum naechsten
299cdf0e10cSrcweir         }
300cdf0e10cSrcweir         else
301cdf0e10cSrcweir         {
302cdf0e10cSrcweir             if( Search( rSearchOptions, bForward ) )
303cdf0e10cSrcweir                 nFound = 1;
304cdf0e10cSrcweir         }
305cdf0e10cSrcweir     }
306cdf0e10cSrcweir     else
307cdf0e10cSrcweir     {
308cdf0e10cSrcweir         // Der Writer ersetzt alle, vom Anfang bis Ende...
309cdf0e10cSrcweir 
310cdf0e10cSrcweir         ExtTextEngine* pTextEngine = (ExtTextEngine*)GetTextEngine();
311cdf0e10cSrcweir 
312cdf0e10cSrcweir         // HideSelection();
313cdf0e10cSrcweir         TextSelection aSel;
314cdf0e10cSrcweir 
315cdf0e10cSrcweir         sal_Bool bSearchInSelection = (0 != (rSearchOptions.searchFlag & util::SearchFlags::REG_NOT_BEGINOFLINE) );
316cdf0e10cSrcweir         if ( bSearchInSelection )
317cdf0e10cSrcweir         {
318cdf0e10cSrcweir             aSel = GetSelection();
319cdf0e10cSrcweir             aSel.Justify();
320cdf0e10cSrcweir         }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir         TextSelection aSearchSel( aSel );
323cdf0e10cSrcweir 
324cdf0e10cSrcweir         sal_Bool bFound = pTextEngine->Search( aSel, rSearchOptions, sal_True );
325cdf0e10cSrcweir         if ( bFound )
326cdf0e10cSrcweir             pTextEngine->UndoActionStart();
327cdf0e10cSrcweir         while ( bFound )
328cdf0e10cSrcweir         {
329cdf0e10cSrcweir             nFound++;
330cdf0e10cSrcweir 
331cdf0e10cSrcweir             TextPaM aNewStart = pTextEngine->ImpInsertText( aSel, rSearchOptions.replaceString );
332cdf0e10cSrcweir             aSel = aSearchSel;
333cdf0e10cSrcweir             aSel.GetStart() = aNewStart;
334cdf0e10cSrcweir             bFound = pTextEngine->Search( aSel, rSearchOptions, sal_True );
335cdf0e10cSrcweir         }
336cdf0e10cSrcweir         if ( nFound )
337cdf0e10cSrcweir         {
338cdf0e10cSrcweir             SetSelection( aSel.GetStart() );
339cdf0e10cSrcweir             pTextEngine->FormatAndUpdate( this );
340cdf0e10cSrcweir             pTextEngine->UndoActionEnd();
341cdf0e10cSrcweir         }
342cdf0e10cSrcweir     }
343cdf0e10cSrcweir     return nFound;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
ImpIndentBlock(sal_Bool bRight)346cdf0e10cSrcweir sal_Bool ExtTextView::ImpIndentBlock( sal_Bool bRight )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir     sal_Bool bDone = sal_False;
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     TextSelection aSel = GetSelection();
351cdf0e10cSrcweir     aSel.Justify();
352cdf0e10cSrcweir 
353cdf0e10cSrcweir     HideSelection();
354cdf0e10cSrcweir     GetTextEngine()->UndoActionStart();
355cdf0e10cSrcweir 
356cdf0e10cSrcweir     sal_uLong nStartPara = aSel.GetStart().GetPara();
357cdf0e10cSrcweir     sal_uLong nEndPara = aSel.GetEnd().GetPara();
358cdf0e10cSrcweir     if ( aSel.HasRange() && !aSel.GetEnd().GetIndex() )
359cdf0e10cSrcweir     {
360cdf0e10cSrcweir         nEndPara--; // den dann nicht einruecken...
361cdf0e10cSrcweir     }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir     for ( sal_uLong nPara = nStartPara; nPara <= nEndPara; nPara++ )
364cdf0e10cSrcweir     {
365cdf0e10cSrcweir         if ( bRight )
366cdf0e10cSrcweir         {
367cdf0e10cSrcweir             // Tabs hinzufuegen
368cdf0e10cSrcweir             GetTextEngine()->ImpInsertText( TextPaM( nPara, 0 ), '\t' );
369cdf0e10cSrcweir             bDone = sal_True;
370cdf0e10cSrcweir         }
371cdf0e10cSrcweir         else
372cdf0e10cSrcweir         {
373cdf0e10cSrcweir             // Tabs/Blanks entfernen
374cdf0e10cSrcweir             String aText = GetTextEngine()->GetText( nPara );
375cdf0e10cSrcweir             if ( aText.Len() && (
376cdf0e10cSrcweir                     ( aText.GetChar( 0 ) == '\t' ) ||
377cdf0e10cSrcweir                     ( aText.GetChar( 0 ) == ' ' ) ) )
378cdf0e10cSrcweir             {
379cdf0e10cSrcweir                 GetTextEngine()->ImpDeleteText( TextSelection( TextPaM( nPara, 0 ), TextPaM( nPara, 1 ) ) );
380cdf0e10cSrcweir                 bDone = sal_True;
381cdf0e10cSrcweir             }
382cdf0e10cSrcweir         }
383cdf0e10cSrcweir     }
384cdf0e10cSrcweir 
385cdf0e10cSrcweir     GetTextEngine()->UndoActionEnd();
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     sal_Bool bRange = aSel.HasRange();
388cdf0e10cSrcweir     if ( bRight )
389cdf0e10cSrcweir     {
390cdf0e10cSrcweir         aSel.GetStart().GetIndex()++;
391cdf0e10cSrcweir         if ( bRange && ( aSel.GetEnd().GetPara() == nEndPara ) )
392cdf0e10cSrcweir             aSel.GetEnd().GetIndex()++;
393cdf0e10cSrcweir     }
394cdf0e10cSrcweir     else
395cdf0e10cSrcweir     {
396cdf0e10cSrcweir         if ( aSel.GetStart().GetIndex() )
397cdf0e10cSrcweir             aSel.GetStart().GetIndex()--;
398cdf0e10cSrcweir         if ( bRange && aSel.GetEnd().GetIndex() )
399cdf0e10cSrcweir             aSel.GetEnd().GetIndex()--;
400cdf0e10cSrcweir     }
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     ImpSetSelection( aSel );
403cdf0e10cSrcweir     GetTextEngine()->FormatAndUpdate( this );
404cdf0e10cSrcweir 
405cdf0e10cSrcweir     return bDone;
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
IndentBlock()408cdf0e10cSrcweir sal_Bool ExtTextView::IndentBlock()
409cdf0e10cSrcweir {
410cdf0e10cSrcweir     return ImpIndentBlock( sal_True );
411cdf0e10cSrcweir }
412cdf0e10cSrcweir 
UnindentBlock()413cdf0e10cSrcweir sal_Bool ExtTextView::UnindentBlock()
414cdf0e10cSrcweir {
415cdf0e10cSrcweir     return ImpIndentBlock( sal_False );
416cdf0e10cSrcweir }
417