xref: /aoo42x/main/editeng/source/outliner/outlvw.cxx (revision 190118d0)
1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*190118d0SAndrew Rist  * distributed with this work for additional information
6*190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*190118d0SAndrew Rist  *
11*190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*190118d0SAndrew Rist  *
13*190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist  * software distributed under the License is distributed on an
15*190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*190118d0SAndrew Rist  * specific language governing permissions and limitations
18*190118d0SAndrew Rist  * under the License.
19*190118d0SAndrew Rist  *
20*190118d0SAndrew Rist  *************************************************************/
21*190118d0SAndrew Rist 
22*190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "precompiled_editeng.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/i18n/WordType.hpp>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <svl/intitem.hxx>
31cdf0e10cSrcweir #include <editeng/editeng.hxx>
32cdf0e10cSrcweir #include <editeng/editview.hxx>
33cdf0e10cSrcweir #include <editeng/editdata.hxx>
34cdf0e10cSrcweir #include <editeng/eerdll.hxx>
35cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
36cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <svl/style.hxx>
39cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #define _OUTLINER_CXX
42cdf0e10cSrcweir #include <editeng/outliner.hxx>
43cdf0e10cSrcweir #include <outleeng.hxx>
44cdf0e10cSrcweir #include <paralist.hxx>
45cdf0e10cSrcweir #include <outlundo.hxx>
46cdf0e10cSrcweir #include <editeng/outlobj.hxx>
47cdf0e10cSrcweir #include <editeng/flditem.hxx>
48cdf0e10cSrcweir #include <editeng/flditem.hxx>
49cdf0e10cSrcweir #include <editeng/eeitem.hxx>
50cdf0e10cSrcweir #include <editeng/numitem.hxx>
51cdf0e10cSrcweir #include <vcl/window.hxx>
52cdf0e10cSrcweir #include <svl/itemset.hxx>
53cdf0e10cSrcweir #include <editeng/editstat.hxx>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // Breite der Randzonen innerhalb derer beim D&D gescrollt wird
57cdf0e10cSrcweir #define OL_SCROLL_LRBORDERWIDTHPIX	10
58cdf0e10cSrcweir #define OL_SCROLL_TBBORDERWIDTHPIX	10
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // Wert, um den Fensterinhalt beim D&D gescrollt wird
61cdf0e10cSrcweir #define OL_SCROLL_HOROFFSET			20  /* in % von VisibleSize.Width */
62cdf0e10cSrcweir #define OL_SCROLL_VEROFFSET			20  /* in % von VisibleSize.Height */
63cdf0e10cSrcweir 
64cdf0e10cSrcweir using namespace ::com::sun::star;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir DBG_NAME(OutlinerView)
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
69cdf0e10cSrcweir OutlinerView::OutlinerView( Outliner* pOut, Window* pWin )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	DBG_CTOR( OutlinerView, 0 );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	pOwner						= pOut;
74cdf0e10cSrcweir 	bDDCursorVisible			= sal_False;
75cdf0e10cSrcweir 	bInDragMode 				= sal_False;
76cdf0e10cSrcweir 	nDDScrollLRBorderWidthWin 	= 0;
77cdf0e10cSrcweir 	nDDScrollTBBorderWidthWin 	= 0;
78cdf0e10cSrcweir 	pHorTabArrDoc				= 0;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	pEditView = new EditView( pOut->pEditEngine, pWin );
81cdf0e10cSrcweir 	pEditView->SetSelectionMode( EE_SELMODE_TXTONLY );
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir OutlinerView::~OutlinerView()
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	DBG_DTOR(OutlinerView,0);
87cdf0e10cSrcweir 	delete pEditView;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir void OutlinerView::Paint( const Rectangle& rRect )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	// beim ersten Paint/KeyInput/Drop wird aus einem leeren Outliner ein
95cdf0e10cSrcweir 	// Outliner mit genau einem Absatz
96cdf0e10cSrcweir 	if( pOwner->bFirstParaIsEmpty )
97cdf0e10cSrcweir 		pOwner->Insert( String() );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	pEditView->Paint( rRect );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir sal_Bool OutlinerView::PostKeyEvent( const KeyEvent& rKEvt )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 	DBG_CHKTHIS( OutlinerView, 0 );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	// beim ersten Paint/KeyInput/Drop wird aus einem leeren Outliner ein
107cdf0e10cSrcweir 	// Outliner mit genau einem Absatz
108cdf0e10cSrcweir 	if( pOwner->bFirstParaIsEmpty )
109cdf0e10cSrcweir 		pOwner->Insert( String() );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	sal_Bool bKeyProcessed = sal_False;
113cdf0e10cSrcweir 	ESelection aSel( pEditView->GetSelection() );
114cdf0e10cSrcweir 	sal_Bool bSelection = aSel.HasRange();
115cdf0e10cSrcweir 	KeyCode aKeyCode = rKEvt.GetKeyCode();
116cdf0e10cSrcweir 	KeyFuncType eFunc = aKeyCode.GetFunction();
117cdf0e10cSrcweir 	sal_uInt16 nCode = aKeyCode.GetCode();
118cdf0e10cSrcweir 	sal_Bool bReadOnly = IsReadOnly();
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 	if( bSelection && ( nCode != KEY_TAB ) && EditEngine::DoesKeyChangeText( rKEvt ) )
121cdf0e10cSrcweir 	{
122cdf0e10cSrcweir 		if ( ImpCalcSelectedPages( sal_False ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
123cdf0e10cSrcweir 			return sal_True;
124cdf0e10cSrcweir 	}
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	if ( eFunc != KEYFUNC_DONTKNOW )
127cdf0e10cSrcweir 	{
128cdf0e10cSrcweir 		switch ( eFunc )
129cdf0e10cSrcweir 		{
130cdf0e10cSrcweir 			case KEYFUNC_CUT:
131cdf0e10cSrcweir 			{
132cdf0e10cSrcweir 				if ( !bReadOnly )
133cdf0e10cSrcweir 				{
134cdf0e10cSrcweir 					Cut();
135cdf0e10cSrcweir 					bKeyProcessed = sal_True;
136cdf0e10cSrcweir 				}
137cdf0e10cSrcweir 			}
138cdf0e10cSrcweir 			break;
139cdf0e10cSrcweir 			case KEYFUNC_COPY:
140cdf0e10cSrcweir 			{
141cdf0e10cSrcweir 				Copy();
142cdf0e10cSrcweir 				bKeyProcessed = sal_True;
143cdf0e10cSrcweir 			}
144cdf0e10cSrcweir 			break;
145cdf0e10cSrcweir 			case KEYFUNC_PASTE:
146cdf0e10cSrcweir 			{
147cdf0e10cSrcweir 				if ( !bReadOnly )
148cdf0e10cSrcweir 				{
149cdf0e10cSrcweir                     PasteSpecial();
150cdf0e10cSrcweir 					bKeyProcessed = sal_True;
151cdf0e10cSrcweir 				}
152cdf0e10cSrcweir 			}
153cdf0e10cSrcweir 			break;
154cdf0e10cSrcweir 			case KEYFUNC_DELETE:
155cdf0e10cSrcweir 			{
156cdf0e10cSrcweir 				if( !bReadOnly && !bSelection && ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) )
157cdf0e10cSrcweir 				{
158cdf0e10cSrcweir 					if( aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
159cdf0e10cSrcweir 					{
160cdf0e10cSrcweir 						Paragraph* pNext = pOwner->pParaList->GetParagraph( aSel.nEndPara+1 );
161cdf0e10cSrcweir 						if( pNext && pNext->HasFlag(PARAFLAG_ISPAGE) )
162cdf0e10cSrcweir 						{
163cdf0e10cSrcweir 							if( !pOwner->ImpCanDeleteSelectedPages( this, aSel.nEndPara, 1 ) )
164cdf0e10cSrcweir 								return sal_False;
165cdf0e10cSrcweir 						}
166cdf0e10cSrcweir 					}
167cdf0e10cSrcweir 				}
168cdf0e10cSrcweir 			}
169cdf0e10cSrcweir 			break;
170cdf0e10cSrcweir 			default:	// wird dann evtl. unten bearbeitet.
171cdf0e10cSrcweir 						eFunc = KEYFUNC_DONTKNOW;
172cdf0e10cSrcweir 		}
173cdf0e10cSrcweir 	}
174cdf0e10cSrcweir 	if ( eFunc == KEYFUNC_DONTKNOW )
175cdf0e10cSrcweir 	{
176cdf0e10cSrcweir 		switch ( nCode )
177cdf0e10cSrcweir 		{
178cdf0e10cSrcweir 			case KEY_TAB:
179cdf0e10cSrcweir 			{
180cdf0e10cSrcweir 				if ( !bReadOnly && !aKeyCode.IsMod1() && !aKeyCode.IsMod2() )
181cdf0e10cSrcweir 				{
182cdf0e10cSrcweir 					if ( ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) &&
183cdf0e10cSrcweir 						 ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TITLEOBJECT ) &&
184cdf0e10cSrcweir 						 ( bSelection || !aSel.nStartPos ) )
185cdf0e10cSrcweir 					{
186cdf0e10cSrcweir 						Indent( aKeyCode.IsShift() ? (-1) : (+1) );
187cdf0e10cSrcweir 						bKeyProcessed = sal_True;
188cdf0e10cSrcweir 					}
189cdf0e10cSrcweir 					else if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) &&
190cdf0e10cSrcweir 							  !bSelection && !aSel.nEndPos && pOwner->ImplHasBullet( aSel.nEndPara ) )
191cdf0e10cSrcweir 					{
192cdf0e10cSrcweir 						Indent( aKeyCode.IsShift() ? (-1) : (+1) );
193cdf0e10cSrcweir 						bKeyProcessed = sal_True;
194cdf0e10cSrcweir 					}
195cdf0e10cSrcweir 				}
196cdf0e10cSrcweir 			}
197cdf0e10cSrcweir 			break;
198cdf0e10cSrcweir 			case KEY_BACKSPACE:
199cdf0e10cSrcweir 			{
200cdf0e10cSrcweir 				if( !bReadOnly && !bSelection && aSel.nEndPara && !aSel.nEndPos )
201cdf0e10cSrcweir 				{
202cdf0e10cSrcweir 					Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
203cdf0e10cSrcweir 					Paragraph* pPrev = pOwner->pParaList->GetParagraph( aSel.nEndPara-1 );
204cdf0e10cSrcweir 					if( !pPrev->IsVisible()  )
205cdf0e10cSrcweir 						return sal_True;
206cdf0e10cSrcweir 					if( !pPara->GetDepth() )
207cdf0e10cSrcweir 					{
208cdf0e10cSrcweir 						if(!pOwner->ImpCanDeleteSelectedPages(this, aSel.nEndPara , 1 ) )
209cdf0e10cSrcweir 							return sal_True;
210cdf0e10cSrcweir 					}
211cdf0e10cSrcweir 				}
212cdf0e10cSrcweir 			}
213cdf0e10cSrcweir 			break;
214cdf0e10cSrcweir 			case KEY_RETURN:
215cdf0e10cSrcweir 			{
216cdf0e10cSrcweir 				if ( !bReadOnly )
217cdf0e10cSrcweir 				{
218cdf0e10cSrcweir 					// Sonderbehandlung: Hartes Return am Ende eines Absatzes,
219cdf0e10cSrcweir 					// der eingeklappte Unterabsaetze besitzt
220cdf0e10cSrcweir 					Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 					if( !aKeyCode.IsShift() )
223cdf0e10cSrcweir 					{
224cdf0e10cSrcweir 						// Nochmal ImpGetCursor ???
225cdf0e10cSrcweir 						if( !bSelection &&
226cdf0e10cSrcweir 								aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
227cdf0e10cSrcweir 						{
228cdf0e10cSrcweir 							sal_uLong nChilds =	pOwner->pParaList->GetChildCount(pPara);
229cdf0e10cSrcweir 							if( nChilds && !pOwner->pParaList->HasVisibleChilds(pPara))
230cdf0e10cSrcweir 							{
231cdf0e10cSrcweir 								pOwner->UndoActionStart( OLUNDO_INSERT );
232cdf0e10cSrcweir 								sal_uLong nTemp = aSel.nEndPara;
233cdf0e10cSrcweir 								nTemp += nChilds;
234cdf0e10cSrcweir 								nTemp++; // einfuegen ueber naechstem Non-Child
235cdf0e10cSrcweir 								pOwner->Insert( String(),nTemp,pPara->GetDepth());
236cdf0e10cSrcweir 								// Cursor positionieren
237cdf0e10cSrcweir 								ESelection aTmpSel((sal_uInt16)nTemp,0,(sal_uInt16)nTemp,0);
238cdf0e10cSrcweir 								pEditView->SetSelection( aTmpSel );
239cdf0e10cSrcweir 								pEditView->ShowCursor( sal_True, sal_True );
240cdf0e10cSrcweir 								pOwner->UndoActionEnd( OLUNDO_INSERT );
241cdf0e10cSrcweir 								bKeyProcessed = sal_True;
242cdf0e10cSrcweir 							}
243cdf0e10cSrcweir 						}
244cdf0e10cSrcweir 					}
245cdf0e10cSrcweir 					if( !bKeyProcessed && !bSelection &&
246cdf0e10cSrcweir 								!aKeyCode.IsShift() && aKeyCode.IsMod1() &&
247cdf0e10cSrcweir 							( aSel.nEndPos == pOwner->pEditEngine->GetTextLen(aSel.nEndPara) ) )
248cdf0e10cSrcweir 					{
249cdf0e10cSrcweir 						pOwner->UndoActionStart( OLUNDO_INSERT );
250cdf0e10cSrcweir 						sal_uLong nTemp = aSel.nEndPara;
251cdf0e10cSrcweir 						nTemp++;
252cdf0e10cSrcweir 						pOwner->Insert( String(), nTemp, pPara->GetDepth()+1 );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 						// Cursor positionieren
255cdf0e10cSrcweir 						ESelection aTmpSel((sal_uInt16)nTemp,0,(sal_uInt16)nTemp,0);
256cdf0e10cSrcweir 						pEditView->SetSelection( aTmpSel );
257cdf0e10cSrcweir 						pEditView->ShowCursor( sal_True, sal_True );
258cdf0e10cSrcweir 						pOwner->UndoActionEnd( OLUNDO_INSERT );
259cdf0e10cSrcweir 						bKeyProcessed = sal_True;
260cdf0e10cSrcweir 					}
261cdf0e10cSrcweir 				}
262cdf0e10cSrcweir 			}
263cdf0e10cSrcweir 			break;
264cdf0e10cSrcweir 		}
265cdf0e10cSrcweir 	}
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	return bKeyProcessed ? sal_True : pEditView->PostKeyEvent( rKEvt );
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 
271cdf0e10cSrcweir sal_uLong OutlinerView::ImpCheckMousePos(const Point& rPosPix, MouseTarget& reTarget)
272cdf0e10cSrcweir {
273cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
274cdf0e10cSrcweir 	sal_uLong nPara = EE_PARA_NOT_FOUND;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	Point aMousePosWin = pEditView->GetWindow()->PixelToLogic( rPosPix );
277cdf0e10cSrcweir 	if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
278cdf0e10cSrcweir     {
279cdf0e10cSrcweir 		reTarget = MouseOutside;
280cdf0e10cSrcweir     }
281cdf0e10cSrcweir 	else
282cdf0e10cSrcweir 	{
283cdf0e10cSrcweir 		reTarget = MouseText;
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 		Point aPaperPos( aMousePosWin );
286cdf0e10cSrcweir 		Rectangle aOutArea = pEditView->GetOutputArea();
287cdf0e10cSrcweir 		Rectangle aVisArea = pEditView->GetVisArea();
288cdf0e10cSrcweir 		aPaperPos.X() -= aOutArea.Left();
289cdf0e10cSrcweir 		aPaperPos.X() += aVisArea.Left();
290cdf0e10cSrcweir 		aPaperPos.Y() -= aOutArea.Top();
291cdf0e10cSrcweir 		aPaperPos.Y() += aVisArea.Top();
292cdf0e10cSrcweir 
293cdf0e10cSrcweir         sal_Bool bBullet;
294cdf0e10cSrcweir         if ( pOwner->IsTextPos( aPaperPos, 0, &bBullet ) )
295cdf0e10cSrcweir         {
296cdf0e10cSrcweir 		    Point aDocPos = pOwner->GetDocPos( aPaperPos );
297cdf0e10cSrcweir 		    nPara = pOwner->pEditEngine->FindParagraph( aDocPos.Y() );
298cdf0e10cSrcweir 
299cdf0e10cSrcweir             if ( bBullet )
300cdf0e10cSrcweir             {
301cdf0e10cSrcweir                 reTarget = MouseBullet;
302cdf0e10cSrcweir             }
303cdf0e10cSrcweir             else
304cdf0e10cSrcweir             {
305cdf0e10cSrcweir                 // Check for hyperlink
306cdf0e10cSrcweir 	            const SvxFieldItem* pFieldItem = pEditView->GetField( aMousePosWin );
307cdf0e10cSrcweir 	            if ( pFieldItem && pFieldItem->GetField() && pFieldItem->GetField()->ISA( SvxURLField ) )
308cdf0e10cSrcweir 		            reTarget = MouseHypertext;
309cdf0e10cSrcweir             }
310cdf0e10cSrcweir         }
311cdf0e10cSrcweir     }
312cdf0e10cSrcweir 	return nPara;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir sal_Bool __EXPORT OutlinerView::MouseMove( const MouseEvent& rMEvt )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     if( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode())
320cdf0e10cSrcweir 		return pEditView->MouseMove( rMEvt );
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
323cdf0e10cSrcweir 	if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
324cdf0e10cSrcweir         return sal_False;
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
327cdf0e10cSrcweir     pEditView->GetWindow()->SetPointer( aPointer );
328cdf0e10cSrcweir     return pEditView->MouseMove( rMEvt );
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 
332cdf0e10cSrcweir sal_Bool __EXPORT OutlinerView::MouseButtonDown( const MouseEvent& rMEvt )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
335cdf0e10cSrcweir 	if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode() )
336cdf0e10cSrcweir 		return pEditView->MouseButtonDown( rMEvt );
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 	Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
339cdf0e10cSrcweir 	if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
340cdf0e10cSrcweir         return sal_False;
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 	Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
343cdf0e10cSrcweir     pEditView->GetWindow()->SetPointer( aPointer );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	MouseTarget eTarget;
346cdf0e10cSrcweir 	sal_uLong nPara = ImpCheckMousePos( rMEvt.GetPosPixel(), eTarget );
347cdf0e10cSrcweir     if ( eTarget == MouseBullet )
348cdf0e10cSrcweir 	{
349cdf0e10cSrcweir 		Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
350cdf0e10cSrcweir 		sal_Bool bHasChilds = (pPara && pOwner->pParaList->HasChilds(pPara));
351cdf0e10cSrcweir 		if( rMEvt.GetClicks() == 1 )
352cdf0e10cSrcweir 		{
353cdf0e10cSrcweir 			sal_uLong nEndPara = nPara;
354cdf0e10cSrcweir 			if ( bHasChilds && pOwner->pParaList->HasVisibleChilds(pPara) )
355cdf0e10cSrcweir 				nEndPara += pOwner->pParaList->GetChildCount( pPara );
356cdf0e10cSrcweir 			// umgekehrt rum selektieren, damit EditEngine nicht scrollt
357cdf0e10cSrcweir 			ESelection aSel((sal_uInt16)nEndPara, 0xffff,(sal_uInt16)nPara, 0 );
358cdf0e10cSrcweir 			pEditView->SetSelection( aSel );
359cdf0e10cSrcweir         }
360cdf0e10cSrcweir 		else if( rMEvt.GetClicks() == 2 && bHasChilds )
361cdf0e10cSrcweir 			ImpToggleExpand( pPara );
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 		aDDStartPosPix = rMEvt.GetPosPixel();
364cdf0e10cSrcweir 		aDDStartPosRef=pEditView->GetWindow()->PixelToLogic( aDDStartPosPix,pOwner->GetRefMapMode());
365cdf0e10cSrcweir 		return sal_True;
366cdf0e10cSrcweir 	}
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	// special case for outliner view in impress, check if double click hits the page icon for toggle
369cdf0e10cSrcweir 	if( (nPara == EE_PARA_NOT_FOUND) && (pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEVIEW) && (eTarget == MouseText) && (rMEvt.GetClicks() == 2) )
370cdf0e10cSrcweir 	{
371cdf0e10cSrcweir         ESelection aSel( pEditView->GetSelection() );
372cdf0e10cSrcweir 	    nPara = aSel.nStartPara;
373cdf0e10cSrcweir 	    Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
374cdf0e10cSrcweir 	    if( (pPara && pOwner->pParaList->HasChilds(pPara)) && pPara->HasFlag(PARAFLAG_ISPAGE) )
375cdf0e10cSrcweir 	    {
376cdf0e10cSrcweir 	        ImpToggleExpand( pPara );
377cdf0e10cSrcweir 	    }
378cdf0e10cSrcweir 	}
379cdf0e10cSrcweir 	return pEditView->MouseButtonDown( rMEvt );
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 
383cdf0e10cSrcweir sal_Bool __EXPORT OutlinerView::MouseButtonUp( const MouseEvent& rMEvt )
384cdf0e10cSrcweir {
385cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
386cdf0e10cSrcweir 	if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode() )
387cdf0e10cSrcweir 		return pEditView->MouseButtonUp( rMEvt );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
390cdf0e10cSrcweir 	if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
391cdf0e10cSrcweir         return sal_False;
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
394cdf0e10cSrcweir     pEditView->GetWindow()->SetPointer( aPointer );
395cdf0e10cSrcweir 
396cdf0e10cSrcweir     return pEditView->MouseButtonUp( rMEvt );
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir void OutlinerView::ImpHideDDCursor()
400cdf0e10cSrcweir {
401cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
402cdf0e10cSrcweir 	if ( bDDCursorVisible )
403cdf0e10cSrcweir 	{
404cdf0e10cSrcweir 		bDDCursorVisible = sal_False;
405cdf0e10cSrcweir 		ImpPaintDDCursor();
406cdf0e10cSrcweir 	}
407cdf0e10cSrcweir }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir void OutlinerView::ImpShowDDCursor()
410cdf0e10cSrcweir {
411cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
412cdf0e10cSrcweir 	if ( !bDDCursorVisible )
413cdf0e10cSrcweir 	{
414cdf0e10cSrcweir 		bDDCursorVisible = sal_True;
415cdf0e10cSrcweir 		ImpPaintDDCursor();
416cdf0e10cSrcweir 	}
417cdf0e10cSrcweir }
418cdf0e10cSrcweir 
419cdf0e10cSrcweir void OutlinerView::ImpPaintDDCursor()
420cdf0e10cSrcweir {
421cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 	Window* pWindow = pEditView->GetWindow();
424cdf0e10cSrcweir 	RasterOp eOldOp = pWindow->GetRasterOp();
425cdf0e10cSrcweir 	pWindow->SetRasterOp( ROP_INVERT );
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 	const Color& rOldLineColor = pWindow->GetLineColor();
428cdf0e10cSrcweir 	pWindow->SetLineColor( Color( COL_BLACK ) );
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 	Point aStartPointWin, aEndPointWin;
431cdf0e10cSrcweir 	Rectangle aOutputArWin = pEditView->GetOutputArea();
432cdf0e10cSrcweir 	Rectangle aVisAreaRef = pEditView->GetVisArea();
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 	if( bDDChangingDepth )
435cdf0e10cSrcweir 	{
436cdf0e10cSrcweir 		aStartPointWin.X() = pHorTabArrDoc[ nDDCurDepth ];
437cdf0e10cSrcweir 		aStartPointWin.X() += aOutputArWin.Left();
438cdf0e10cSrcweir 		aStartPointWin.Y() = aOutputArWin.Top();
439cdf0e10cSrcweir 		aEndPointWin.X() = aStartPointWin.X();
440cdf0e10cSrcweir 		aEndPointWin.Y() = aOutputArWin.Bottom();
441cdf0e10cSrcweir 	}
442cdf0e10cSrcweir 	else
443cdf0e10cSrcweir 	{
444cdf0e10cSrcweir 		sal_uLong nPara = nDDCurPara;
445cdf0e10cSrcweir 		if ( nDDCurPara == LIST_APPEND )
446cdf0e10cSrcweir 		{
447cdf0e10cSrcweir 			Paragraph* pTemp = pOwner->pParaList->LastVisible();
448cdf0e10cSrcweir 			nPara = pOwner->pParaList->GetAbsPos( pTemp );
449cdf0e10cSrcweir 		}
450cdf0e10cSrcweir 		aStartPointWin = pEditView->GetWindowPosTopLeft((sal_uInt16) nPara );
451cdf0e10cSrcweir 		if ( nDDCurPara == LIST_APPEND )
452cdf0e10cSrcweir 		{
453cdf0e10cSrcweir 			long nHeight = pOwner->pEditEngine->GetTextHeight((sal_uInt16)nPara );
454cdf0e10cSrcweir 			aStartPointWin.Y() += nHeight;
455cdf0e10cSrcweir 		}
456cdf0e10cSrcweir 		aStartPointWin.X() = aOutputArWin.Left();
457cdf0e10cSrcweir 		aEndPointWin.Y() = aStartPointWin.Y();
458cdf0e10cSrcweir 		aEndPointWin.X() = aOutputArWin.Right();
459cdf0e10cSrcweir 	}
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 	pWindow->DrawLine( aStartPointWin, aEndPointWin );
462cdf0e10cSrcweir 	pWindow->SetLineColor( rOldLineColor );
463cdf0e10cSrcweir 	pWindow->SetRasterOp( eOldOp );
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir // Berechnet, ueber welchem Absatz eingefuegt werden muss
467cdf0e10cSrcweir 
468cdf0e10cSrcweir sal_uLong OutlinerView::ImpGetInsertionPara( const Point& rPosPixel  )
469cdf0e10cSrcweir {
470cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
471cdf0e10cSrcweir 	sal_uLong nCurPara = pEditView->GetParagraph( rPosPixel );
472cdf0e10cSrcweir 	ParagraphList* pParaList = pOwner->pParaList;
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 	if ( nCurPara == EE_PARA_NOT_FOUND )
475cdf0e10cSrcweir 		nCurPara = LIST_APPEND;
476cdf0e10cSrcweir 	else
477cdf0e10cSrcweir 	{
478cdf0e10cSrcweir 		Point aPosWin = pEditView->GetWindow()->PixelToLogic( rPosPixel );
479cdf0e10cSrcweir 		Point aParaPosWin = pEditView->GetWindowPosTopLeft((sal_uInt16)nCurPara);
480cdf0e10cSrcweir 		long nHeightRef = pOwner->pEditEngine->GetTextHeight((sal_uInt16)nCurPara);
481cdf0e10cSrcweir 		long nParaYOffs = aPosWin.Y() - aParaPosWin.Y();
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 		if ( nParaYOffs > nHeightRef / 2  )
484cdf0e10cSrcweir 		{
485cdf0e10cSrcweir 			Paragraph* p = pParaList->GetParagraph( nCurPara );
486cdf0e10cSrcweir 			p = pParaList->NextVisible( p );
487cdf0e10cSrcweir 			nCurPara = p ? pParaList->GetAbsPos( p ) : LIST_APPEND;
488cdf0e10cSrcweir 		}
489cdf0e10cSrcweir 	}
490cdf0e10cSrcweir 	return nCurPara;
491cdf0e10cSrcweir }
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 
494cdf0e10cSrcweir void OutlinerView::ImpToggleExpand( Paragraph* pPara )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 	sal_uInt16 nPara = (sal_uInt16) pOwner->pParaList->GetAbsPos( pPara );
499cdf0e10cSrcweir 	pEditView->SetSelection( ESelection( nPara, 0, nPara, 0 ) );
500cdf0e10cSrcweir 	ImplExpandOrCollaps( nPara, nPara, !pOwner->pParaList->HasVisibleChilds( pPara ) );
501cdf0e10cSrcweir 	pEditView->ShowCursor();
502cdf0e10cSrcweir }
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 
505cdf0e10cSrcweir void OutlinerView::SetOutliner( Outliner* pOutliner )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
508cdf0e10cSrcweir 	pOwner = pOutliner;
509cdf0e10cSrcweir 	pEditView->SetEditEngine( pOutliner->pEditEngine );
510cdf0e10cSrcweir }
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 
514cdf0e10cSrcweir sal_uLong OutlinerView::Select( Paragraph* pParagraph, sal_Bool bSelect,
515cdf0e10cSrcweir 	sal_Bool bWithChilds )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 	sal_uLong nPara = pOwner->pParaList->GetAbsPos( pParagraph );
520cdf0e10cSrcweir 	sal_uInt16 nEnd = 0;
521cdf0e10cSrcweir 	if ( bSelect )
522cdf0e10cSrcweir 		nEnd = 0xffff;
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 	sal_uLong nChildCount = 0;
525cdf0e10cSrcweir 	if ( bWithChilds )
526cdf0e10cSrcweir 		nChildCount = pOwner->pParaList->GetChildCount( pParagraph );
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 	ESelection aSel( (sal_uInt16)nPara, 0,(sal_uInt16)(nPara+nChildCount), nEnd );
529cdf0e10cSrcweir 	pEditView->SetSelection( aSel );
530cdf0e10cSrcweir 	return nChildCount+1;
531cdf0e10cSrcweir }
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 
534cdf0e10cSrcweir void OutlinerView::SetAttribs( const SfxItemSet& rAttrs )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 	sal_Bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
539cdf0e10cSrcweir 	pOwner->pEditEngine->SetUpdateMode( sal_False );
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 	if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
542cdf0e10cSrcweir 		pOwner->UndoActionStart( OLUNDO_ATTR );
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 	ParaRange aSel = ImpGetSelectedParagraphs( sal_False );
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 	pEditView->SetAttribs( rAttrs );
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 	// Bullet-Texte aktualisieren
549cdf0e10cSrcweir 	for( sal_uInt16 nPara= aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
550cdf0e10cSrcweir 	{
551cdf0e10cSrcweir 		pOwner->ImplCheckNumBulletItem( nPara );
552cdf0e10cSrcweir 		pOwner->ImplCalcBulletText( nPara, sal_False, sal_False );
553cdf0e10cSrcweir 
554cdf0e10cSrcweir 		if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
555cdf0e10cSrcweir 			pOwner->InsertUndo( new OutlinerUndoCheckPara( pOwner, nPara ) );
556cdf0e10cSrcweir 	}
557cdf0e10cSrcweir 
558cdf0e10cSrcweir 	if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
559cdf0e10cSrcweir 		pOwner->UndoActionEnd( OLUNDO_ATTR );
560cdf0e10cSrcweir 
561cdf0e10cSrcweir 	pEditView->SetEditEngineUpdateMode( bUpdate );
562cdf0e10cSrcweir }
563cdf0e10cSrcweir 
564cdf0e10cSrcweir ParaRange OutlinerView::ImpGetSelectedParagraphs( sal_Bool bIncludeHiddenChilds )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir 	DBG_CHKTHIS( OutlinerView, 0 );
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 	ESelection aSel = pEditView->GetSelection();
569cdf0e10cSrcweir 	ParaRange aParas( aSel.nStartPara, aSel.nEndPara );
570cdf0e10cSrcweir 	aParas.Adjust();
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 	// unsichtbare Childs des letzten Parents in Selektion mit aufnehmen
573cdf0e10cSrcweir 	if ( bIncludeHiddenChilds )
574cdf0e10cSrcweir 	{
575cdf0e10cSrcweir 		Paragraph* pLast = pOwner->pParaList->GetParagraph( aParas.nEndPara );
576cdf0e10cSrcweir 		if ( pOwner->pParaList->HasHiddenChilds( pLast ) )
577cdf0e10cSrcweir 			aParas.nEndPara =
578cdf0e10cSrcweir                 sal::static_int_cast< sal_uInt16 >(
579cdf0e10cSrcweir                     aParas.nEndPara +
580cdf0e10cSrcweir                     pOwner->pParaList->GetChildCount( pLast ) );
581cdf0e10cSrcweir 	}
582cdf0e10cSrcweir 	return aParas;
583cdf0e10cSrcweir }
584cdf0e10cSrcweir 
585cdf0e10cSrcweir // MT: Name sollte mal geaendert werden!
586cdf0e10cSrcweir void OutlinerView::AdjustDepth( short nDX )
587cdf0e10cSrcweir {
588cdf0e10cSrcweir 	Indent( nDX );
589cdf0e10cSrcweir }
590cdf0e10cSrcweir 
591cdf0e10cSrcweir void OutlinerView::Indent( short nDiff )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir 	DBG_CHKTHIS( OutlinerView, 0 );
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 	if( !nDiff || ( ( nDiff > 0 ) && ImpCalcSelectedPages( sal_True ) && !pOwner->ImpCanIndentSelectedPages( this ) ) )
596cdf0e10cSrcweir 		return;
597cdf0e10cSrcweir 
598cdf0e10cSrcweir 	const bool bOutlinerView = pOwner->pEditEngine->GetControlWord() & EE_CNTRL_OUTLINER;
599cdf0e10cSrcweir 	sal_Bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
600cdf0e10cSrcweir 	pOwner->pEditEngine->SetUpdateMode( sal_False );
601cdf0e10cSrcweir 
602cdf0e10cSrcweir 	sal_Bool bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 	if( bUndo )
605cdf0e10cSrcweir 		pOwner->UndoActionStart( OLUNDO_DEPTH );
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 	sal_Int16 nMinDepth = -1;	// Optimierung: Nicht unnoetig viele Absatze neu berechnen
608cdf0e10cSrcweir 
609cdf0e10cSrcweir 	ParaRange aSel = ImpGetSelectedParagraphs( sal_True );
610cdf0e10cSrcweir 	for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
611cdf0e10cSrcweir 	{
612cdf0e10cSrcweir 		Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
613cdf0e10cSrcweir 
614cdf0e10cSrcweir 		sal_Int16 nOldDepth = pPara->GetDepth();
615cdf0e10cSrcweir 		sal_Int16 nNewDepth = nOldDepth + nDiff;
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 		if( bOutlinerView && nPara )
618cdf0e10cSrcweir 		{
619cdf0e10cSrcweir 			const bool bPage = pPara->HasFlag(PARAFLAG_ISPAGE);
620cdf0e10cSrcweir 			if( (bPage && (nDiff == +1)) || (!bPage && (nDiff == -1) && (nOldDepth <= 0))  )
621cdf0e10cSrcweir 			{
622cdf0e10cSrcweir 				// App benachrichtigen
623cdf0e10cSrcweir 				pOwner->nDepthChangedHdlPrevDepth = (sal_Int16)nOldDepth;
624cdf0e10cSrcweir 				pOwner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
625cdf0e10cSrcweir 				pOwner->pHdlParagraph = pPara;
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 				if( bPage )
628cdf0e10cSrcweir 					pPara->RemoveFlag( PARAFLAG_ISPAGE );
629cdf0e10cSrcweir 				else
630cdf0e10cSrcweir 					pPara->SetFlag( PARAFLAG_ISPAGE );
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 				pOwner->DepthChangedHdl();
633cdf0e10cSrcweir 				pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 				if( bUndo )
636cdf0e10cSrcweir 					pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nPara, pOwner->mnDepthChangeHdlPrevFlags, pPara->nFlags ) );
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 				continue;
639cdf0e10cSrcweir 			}
640cdf0e10cSrcweir 		}
641cdf0e10cSrcweir 
642cdf0e10cSrcweir         // do not switch off numeration with tab
643cdf0e10cSrcweir         if( (nOldDepth == 0) && (nNewDepth == -1) )
644cdf0e10cSrcweir             continue;
645cdf0e10cSrcweir 
646cdf0e10cSrcweir 		// do not indent if there is no numeration enabled
647cdf0e10cSrcweir 		if( nOldDepth == -1 )
648cdf0e10cSrcweir 			continue;
649cdf0e10cSrcweir 
650cdf0e10cSrcweir 		if ( nNewDepth < pOwner->nMinDepth )
651cdf0e10cSrcweir 			nNewDepth = pOwner->nMinDepth;
652cdf0e10cSrcweir 		if ( nNewDepth > pOwner->nMaxDepth )
653cdf0e10cSrcweir 			nNewDepth = pOwner->nMaxDepth;
654cdf0e10cSrcweir 
655cdf0e10cSrcweir 		if( nOldDepth < nMinDepth )
656cdf0e10cSrcweir 			nMinDepth = nOldDepth;
657cdf0e10cSrcweir 		if( nNewDepth < nMinDepth )
658cdf0e10cSrcweir 			nMinDepth = nNewDepth;
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 		if( nOldDepth != nNewDepth )
661cdf0e10cSrcweir 		{
662cdf0e10cSrcweir 			if ( ( nPara == aSel.nStartPara ) && aSel.nStartPara && ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ))
663cdf0e10cSrcweir 			{
664cdf0e10cSrcweir 				// Sonderfall: Der Vorgaenger eines eingerueckten Absatzes ist
665cdf0e10cSrcweir 				// unsichtbar und steht jetzt auf der gleichen Ebene wie der
666cdf0e10cSrcweir 				// sichtbare Absatz. In diesem Fall wird der naechste sichtbare
667cdf0e10cSrcweir 				// Absatz gesucht und aufgeplustert.
668cdf0e10cSrcweir #ifdef DBG_UTIL
669cdf0e10cSrcweir 				Paragraph* _pPara = pOwner->pParaList->GetParagraph( aSel.nStartPara );
670cdf0e10cSrcweir 				DBG_ASSERT(_pPara->IsVisible(),"Selected Paragraph invisible ?!");
671cdf0e10cSrcweir #endif
672cdf0e10cSrcweir 				Paragraph* pPrev= pOwner->pParaList->GetParagraph( aSel.nStartPara-1 );
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 				if( !pPrev->IsVisible() && ( pPrev->GetDepth() == nNewDepth ) )
675cdf0e10cSrcweir 				{
676cdf0e10cSrcweir 					// Vorgaenger ist eingeklappt und steht auf gleicher Ebene
677cdf0e10cSrcweir 					// => naechsten sichtbaren Absatz suchen und expandieren
678cdf0e10cSrcweir 					pPrev = pOwner->pParaList->GetParent( pPrev );
679cdf0e10cSrcweir 					while( !pPrev->IsVisible() )
680cdf0e10cSrcweir 						pPrev = pOwner->pParaList->GetParent( pPrev );
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 					pOwner->Expand( pPrev );
683cdf0e10cSrcweir 					pOwner->InvalidateBullet( pPrev, pOwner->pParaList->GetAbsPos( pPrev ) );
684cdf0e10cSrcweir 				}
685cdf0e10cSrcweir 			}
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 			pOwner->nDepthChangedHdlPrevDepth = (sal_Int16)nOldDepth;
688cdf0e10cSrcweir 			pOwner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
689cdf0e10cSrcweir 			pOwner->pHdlParagraph = pPara;
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 			pOwner->ImplInitDepth( nPara, nNewDepth, sal_True, sal_False );
692cdf0e10cSrcweir 			pOwner->ImplCalcBulletText( nPara, sal_False, sal_False );
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 			if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
695cdf0e10cSrcweir 				pOwner->ImplSetLevelDependendStyleSheet( nPara );
696cdf0e10cSrcweir 
697cdf0e10cSrcweir 			// App benachrichtigen
698cdf0e10cSrcweir 			pOwner->DepthChangedHdl();
699cdf0e10cSrcweir 		}
700cdf0e10cSrcweir         else
701cdf0e10cSrcweir         {
702cdf0e10cSrcweir             // Needs at least a repaint...
703cdf0e10cSrcweir             pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
704cdf0e10cSrcweir         }
705cdf0e10cSrcweir 	}
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 	// MT 19.08.99: War mal fuer Optimierung (outliner.cxx#1.193),
708cdf0e10cSrcweir 	// hat aber zu zuviel Wartungsaufwand / doppelten Funktionen gefuehrt
709cdf0e10cSrcweir 	// und zu wenig gebracht:
710cdf0e10cSrcweir 	// pOwner->ImpSetBulletTextsFrom( aSel.nStartPara+1, nMinDepth );
711cdf0e10cSrcweir 	// Wird jetzt direkt in Schleife mit ImplCalcBulletText() erledigt.
712cdf0e10cSrcweir 	// Jetzt fehlen nur noch die folgenden Ansaetze, die davon betroffen sind.
713cdf0e10cSrcweir 	sal_uInt16 nParas = (sal_uInt16)pOwner->pParaList->GetParagraphCount();
714cdf0e10cSrcweir 	for ( sal_uInt16 n = aSel.nEndPara+1; n < nParas; n++ )
715cdf0e10cSrcweir 	{
716cdf0e10cSrcweir 		Paragraph* pPara = pOwner->pParaList->GetParagraph( n );
717cdf0e10cSrcweir 		if ( pPara->GetDepth() < nMinDepth )
718cdf0e10cSrcweir 			break;
719cdf0e10cSrcweir 		pOwner->ImplCalcBulletText( n, sal_False, sal_False );
720cdf0e10cSrcweir 	}
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 	if ( bUpdate )
723cdf0e10cSrcweir 	{
724cdf0e10cSrcweir 		pEditView->SetEditEngineUpdateMode( sal_True );
725cdf0e10cSrcweir 		pEditView->ShowCursor();
726cdf0e10cSrcweir 	}
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 	if( bUndo )
729cdf0e10cSrcweir 		pOwner->UndoActionEnd( OLUNDO_DEPTH );
730cdf0e10cSrcweir }
731cdf0e10cSrcweir 
732cdf0e10cSrcweir sal_Bool OutlinerView::AdjustHeight( long nDY )
733cdf0e10cSrcweir {
734cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
735cdf0e10cSrcweir     pEditView->MoveParagraphs( nDY );
736cdf0e10cSrcweir     return sal_True;    // remove return value...
737cdf0e10cSrcweir }
738cdf0e10cSrcweir 
739cdf0e10cSrcweir void OutlinerView::AdjustDepth( Paragraph* pPara, short nDX, sal_Bool bWithChilds)
740cdf0e10cSrcweir {
741cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
742cdf0e10cSrcweir 	sal_uLong nStartPara = pOwner->pParaList->GetAbsPos( pPara );
743cdf0e10cSrcweir 	sal_uLong nEndPara = nStartPara;
744cdf0e10cSrcweir 	if ( bWithChilds )
745cdf0e10cSrcweir 		nEndPara += pOwner->pParaList->GetChildCount( pPara );
746cdf0e10cSrcweir 	ESelection aSel((sal_uInt16)nStartPara, 0,(sal_uInt16)nEndPara, 0xffff );
747cdf0e10cSrcweir 	pEditView->SetSelection( aSel );
748cdf0e10cSrcweir 	AdjustDepth( nDX );
749cdf0e10cSrcweir }
750cdf0e10cSrcweir 
751cdf0e10cSrcweir void OutlinerView::AdjustHeight( Paragraph* pPara, long nDY, sal_Bool bWithChilds )
752cdf0e10cSrcweir {
753cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
754cdf0e10cSrcweir 	sal_uLong nStartPara = pOwner->pParaList->GetAbsPos( pPara );
755cdf0e10cSrcweir 	sal_uLong nEndPara = nStartPara;
756cdf0e10cSrcweir 	if ( bWithChilds )
757cdf0e10cSrcweir 		nEndPara += pOwner->pParaList->GetChildCount( pPara );
758cdf0e10cSrcweir 	ESelection aSel( (sal_uInt16)nStartPara, 0, (sal_uInt16)nEndPara, 0xffff );
759cdf0e10cSrcweir 	pEditView->SetSelection( aSel );
760cdf0e10cSrcweir 	AdjustHeight( nDY );
761cdf0e10cSrcweir }
762cdf0e10cSrcweir 
763cdf0e10cSrcweir 
764cdf0e10cSrcweir Rectangle OutlinerView::GetVisArea() const
765cdf0e10cSrcweir {
766cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
767cdf0e10cSrcweir 	return pEditView->GetVisArea();
768cdf0e10cSrcweir }
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 
771cdf0e10cSrcweir Point OutlinerView::ImpGetDocPos( const Point& rPosPixel )
772cdf0e10cSrcweir {
773cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
774cdf0e10cSrcweir 	Rectangle aOutArWin = GetOutputArea();
775cdf0e10cSrcweir 	// Position in der OutputArea berechnen
776cdf0e10cSrcweir 	Point aCurPosDoc( rPosPixel );
777cdf0e10cSrcweir 	aCurPosDoc = pEditView->GetWindow()->PixelToLogic( aCurPosDoc );
778cdf0e10cSrcweir 	aCurPosDoc -= aOutArWin.TopLeft();
779cdf0e10cSrcweir 	aCurPosDoc += pEditView->GetVisArea().TopLeft();
780cdf0e10cSrcweir 	return aCurPosDoc;
781cdf0e10cSrcweir }
782cdf0e10cSrcweir 
783cdf0e10cSrcweir // MT 05/00: Wofuer dies ImpXXXScroll, sollte das nicht die EditEngine machen???
784cdf0e10cSrcweir 
785cdf0e10cSrcweir void OutlinerView::ImpDragScroll( const Point& rPosPix )
786cdf0e10cSrcweir {
787cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
788cdf0e10cSrcweir 	Point aPosWin = pEditView->GetWindow()->PixelToLogic( rPosPix );
789cdf0e10cSrcweir 	Rectangle aOutputArWin = pEditView->GetOutputArea();
790cdf0e10cSrcweir 	if ( aPosWin.X() <= aOutputArWin.Left() + nDDScrollLRBorderWidthWin)
791cdf0e10cSrcweir 		ImpScrollLeft();
792cdf0e10cSrcweir 	else if( aPosWin.X() >= aOutputArWin.Right()- nDDScrollLRBorderWidthWin)
793cdf0e10cSrcweir 		ImpScrollRight();
794cdf0e10cSrcweir 	else if( aPosWin.Y() <= aOutputArWin.Top() + nDDScrollTBBorderWidthWin)
795cdf0e10cSrcweir 		ImpScrollUp();
796cdf0e10cSrcweir 	else if(aPosWin.Y() >= aOutputArWin.Bottom() - nDDScrollTBBorderWidthWin)
797cdf0e10cSrcweir 		ImpScrollDown();
798cdf0e10cSrcweir }
799cdf0e10cSrcweir 
800cdf0e10cSrcweir 
801cdf0e10cSrcweir void OutlinerView::ImpScrollLeft()
802cdf0e10cSrcweir {
803cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
804cdf0e10cSrcweir 	Rectangle aVisArea( pEditView->GetVisArea() );
805cdf0e10cSrcweir 	long nMaxScrollOffs = aVisArea.Left();
806cdf0e10cSrcweir 	if ( !nMaxScrollOffs )
807cdf0e10cSrcweir 		return;
808cdf0e10cSrcweir 	long nScrollOffsRef = (aVisArea.GetWidth() * OL_SCROLL_HOROFFSET) / 100;
809cdf0e10cSrcweir 	if ( !nScrollOffsRef )
810cdf0e10cSrcweir 		nScrollOffsRef = 1;
811cdf0e10cSrcweir 	if ( nScrollOffsRef > nMaxScrollOffs )
812cdf0e10cSrcweir 		nScrollOffsRef = nMaxScrollOffs;
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 	ImpHideDDCursor();
815cdf0e10cSrcweir 	Scroll( -nScrollOffsRef, 0 );
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 	EditStatus aScrollStat;
818cdf0e10cSrcweir 	aScrollStat.GetStatusWord() = EE_STAT_HSCROLL;
819cdf0e10cSrcweir 	pOwner->pEditEngine->GetStatusEventHdl().Call( &aScrollStat );
820cdf0e10cSrcweir }
821cdf0e10cSrcweir 
822cdf0e10cSrcweir 
823cdf0e10cSrcweir void OutlinerView::ImpScrollRight()
824cdf0e10cSrcweir {
825cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
826cdf0e10cSrcweir 	Rectangle aVisArea( pEditView->GetVisArea() );
827cdf0e10cSrcweir 	long nMaxScrollOffs = pOwner->pEditEngine->GetPaperSize().Width() -
828cdf0e10cSrcweir 						  aVisArea.Right();
829cdf0e10cSrcweir 	if ( !nMaxScrollOffs )
830cdf0e10cSrcweir 		return;
831cdf0e10cSrcweir 	long nScrollOffsRef = (aVisArea.GetWidth() * OL_SCROLL_HOROFFSET) / 100;
832cdf0e10cSrcweir 	if ( !nScrollOffsRef )
833cdf0e10cSrcweir 		nScrollOffsRef = 1;
834cdf0e10cSrcweir 	if ( nScrollOffsRef > nMaxScrollOffs )
835cdf0e10cSrcweir 		nScrollOffsRef = nMaxScrollOffs;
836cdf0e10cSrcweir 
837cdf0e10cSrcweir 	ImpHideDDCursor();
838cdf0e10cSrcweir 	Scroll( nScrollOffsRef, 0 );
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 	EditStatus aScrollStat;
841cdf0e10cSrcweir 	aScrollStat.GetStatusWord() = EE_STAT_HSCROLL;
842cdf0e10cSrcweir 	pOwner->pEditEngine->GetStatusEventHdl().Call( &aScrollStat );
843cdf0e10cSrcweir }
844cdf0e10cSrcweir 
845cdf0e10cSrcweir 
846cdf0e10cSrcweir void OutlinerView::ImpScrollDown()
847cdf0e10cSrcweir {
848cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
849cdf0e10cSrcweir 	Rectangle aVisArea( pEditView->GetVisArea() );
850cdf0e10cSrcweir 	Size aDocSize( 0, (long)pOwner->pEditEngine->GetTextHeight() );
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 	long nMaxScrollOffs = aDocSize.Height();
853cdf0e10cSrcweir 	nMaxScrollOffs -= aVisArea.Top();
854cdf0e10cSrcweir 	nMaxScrollOffs -= aVisArea.GetHeight();
855cdf0e10cSrcweir 	if ( !nMaxScrollOffs )
856cdf0e10cSrcweir 		return;
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 	long nScrollOffsRef = (aVisArea.GetHeight() * OL_SCROLL_VEROFFSET) / 100;
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 	if ( nScrollOffsRef > nMaxScrollOffs )
861cdf0e10cSrcweir 		nScrollOffsRef = nMaxScrollOffs;
862cdf0e10cSrcweir 	if ( !nScrollOffsRef )
863cdf0e10cSrcweir 		nScrollOffsRef = 1;
864cdf0e10cSrcweir 
865cdf0e10cSrcweir 	ImpHideDDCursor();
866cdf0e10cSrcweir 	Scroll( 0, -nScrollOffsRef );
867cdf0e10cSrcweir 
868cdf0e10cSrcweir 	EditStatus aScrollStat;
869cdf0e10cSrcweir 	aScrollStat.GetStatusWord() = EE_STAT_VSCROLL;
870cdf0e10cSrcweir 	pOwner->pEditEngine->GetStatusEventHdl().Call( &aScrollStat );
871cdf0e10cSrcweir }
872cdf0e10cSrcweir 
873cdf0e10cSrcweir 
874cdf0e10cSrcweir void OutlinerView::ImpScrollUp()
875cdf0e10cSrcweir {
876cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
877cdf0e10cSrcweir 	Rectangle aVisArea( pEditView->GetVisArea() );
878cdf0e10cSrcweir 	long nMaxScrollOffs = aVisArea.Top();
879cdf0e10cSrcweir 	if ( !nMaxScrollOffs )
880cdf0e10cSrcweir 		return;
881cdf0e10cSrcweir 	long nScrollOffsRef = (aVisArea.GetHeight() * OL_SCROLL_VEROFFSET) / 100;
882cdf0e10cSrcweir 
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 	if ( nScrollOffsRef > nMaxScrollOffs )
885cdf0e10cSrcweir 		nScrollOffsRef = nMaxScrollOffs;
886cdf0e10cSrcweir 	if ( !nScrollOffsRef )
887cdf0e10cSrcweir 		nScrollOffsRef = 1;
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 	ImpHideDDCursor();
890cdf0e10cSrcweir 	Scroll( 0, nScrollOffsRef );
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 	EditStatus aScrollStat;
893cdf0e10cSrcweir 	aScrollStat.GetStatusWord() = EE_STAT_VSCROLL;
894cdf0e10cSrcweir 	pOwner->pEditEngine->GetStatusEventHdl().Call( &aScrollStat );
895cdf0e10cSrcweir }
896cdf0e10cSrcweir 
897cdf0e10cSrcweir 
898cdf0e10cSrcweir void OutlinerView::Expand()
899cdf0e10cSrcweir {
900cdf0e10cSrcweir 	DBG_CHKTHIS( OutlinerView, 0 );
901cdf0e10cSrcweir 	ParaRange aParas = ImpGetSelectedParagraphs( sal_False );
902cdf0e10cSrcweir 	ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, sal_True );
903cdf0e10cSrcweir }
904cdf0e10cSrcweir 
905cdf0e10cSrcweir 
906cdf0e10cSrcweir void OutlinerView::Collapse()
907cdf0e10cSrcweir {
908cdf0e10cSrcweir 	DBG_CHKTHIS( OutlinerView, 0 );
909cdf0e10cSrcweir 	ParaRange aParas = ImpGetSelectedParagraphs( sal_False );
910cdf0e10cSrcweir 	ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, sal_False );
911cdf0e10cSrcweir }
912cdf0e10cSrcweir 
913cdf0e10cSrcweir 
914cdf0e10cSrcweir void OutlinerView::ExpandAll()
915cdf0e10cSrcweir {
916cdf0e10cSrcweir 	DBG_CHKTHIS( OutlinerView, 0 );
917cdf0e10cSrcweir 	ImplExpandOrCollaps( 0, (sal_uInt16)(pOwner->pParaList->GetParagraphCount()-1), sal_True );
918cdf0e10cSrcweir }
919cdf0e10cSrcweir 
920cdf0e10cSrcweir 
921cdf0e10cSrcweir void OutlinerView::CollapseAll()
922cdf0e10cSrcweir {
923cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
924cdf0e10cSrcweir 	ImplExpandOrCollaps( 0, (sal_uInt16)(pOwner->pParaList->GetParagraphCount()-1), sal_False );
925cdf0e10cSrcweir }
926cdf0e10cSrcweir 
927cdf0e10cSrcweir void OutlinerView::ImplExpandOrCollaps( sal_uInt16 nStartPara, sal_uInt16 nEndPara, sal_Bool bExpand )
928cdf0e10cSrcweir {
929cdf0e10cSrcweir 	DBG_CHKTHIS( OutlinerView, 0 );
930cdf0e10cSrcweir 
931cdf0e10cSrcweir 	sal_Bool bUpdate = pOwner->GetUpdateMode();
932cdf0e10cSrcweir 	pOwner->SetUpdateMode( sal_False );
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 	sal_Bool bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
935cdf0e10cSrcweir 	if( bUndo )
936cdf0e10cSrcweir 		pOwner->UndoActionStart( bExpand ? OLUNDO_EXPAND : OLUNDO_COLLAPSE );
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 	for ( sal_uInt16 nPara = nStartPara; nPara <= nEndPara; nPara++ )
939cdf0e10cSrcweir 	{
940cdf0e10cSrcweir 		Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
941cdf0e10cSrcweir 		sal_Bool bDone = bExpand ? pOwner->Expand( pPara ) : pOwner->Collapse( pPara );
942cdf0e10cSrcweir 		if( bDone )
943cdf0e10cSrcweir 		{
944cdf0e10cSrcweir 			// Der Strich unter dem Absatz muss verschwinden...
945cdf0e10cSrcweir 			pOwner->pEditEngine->QuickMarkToBeRepainted( nPara );
946cdf0e10cSrcweir 		}
947cdf0e10cSrcweir 	}
948cdf0e10cSrcweir 
949cdf0e10cSrcweir 	if( bUndo )
950cdf0e10cSrcweir 		pOwner->UndoActionEnd( bExpand ? OLUNDO_EXPAND : OLUNDO_COLLAPSE );
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 	if ( bUpdate )
953cdf0e10cSrcweir 	{
954cdf0e10cSrcweir 		pOwner->SetUpdateMode( sal_True );
955cdf0e10cSrcweir 		pEditView->ShowCursor();
956cdf0e10cSrcweir 	}
957cdf0e10cSrcweir }
958cdf0e10cSrcweir 
959cdf0e10cSrcweir 
960cdf0e10cSrcweir void OutlinerView::Expand( Paragraph* pPara)
961cdf0e10cSrcweir {
962cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
963cdf0e10cSrcweir 	pOwner->Expand( pPara );
964cdf0e10cSrcweir }
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 
967cdf0e10cSrcweir void OutlinerView::Collapse( Paragraph* pPara)
968cdf0e10cSrcweir {
969cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
970cdf0e10cSrcweir 	pOwner->Collapse( pPara );
971cdf0e10cSrcweir }
972cdf0e10cSrcweir 
973cdf0e10cSrcweir void OutlinerView::InsertText( const OutlinerParaObject& rParaObj )
974cdf0e10cSrcweir {
975cdf0e10cSrcweir 	// MT: Wie Paste, nur EditView::Insert, statt EditView::Paste.
976cdf0e10cSrcweir 	// Eigentlich nicht ganz richtig, das evtl. Einrueckungen
977cdf0e10cSrcweir 	// korrigiert werden muessen, aber das kommt spaeter durch ein
978cdf0e10cSrcweir 	// allgemeingueltiges Import.
979cdf0e10cSrcweir 	// Dann wird im Inserted gleich ermittelt, was f�r eine Einrueckebene
980cdf0e10cSrcweir 	// Moegliche Struktur:
981cdf0e10cSrcweir 	// pImportInfo mit DestPara, DestPos, nFormat, pParaObj...
982cdf0e10cSrcweir 	// Evtl. Problematisch:
983cdf0e10cSrcweir 	// EditEngine, RTF => Absplittung des Bereichs, spaeter
984cdf0e10cSrcweir 	// zusammenfuehrung
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
987cdf0e10cSrcweir 
988cdf0e10cSrcweir 	if ( ImpCalcSelectedPages( sal_False ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
989cdf0e10cSrcweir 		return;
990cdf0e10cSrcweir 
991cdf0e10cSrcweir 	pOwner->UndoActionStart( OLUNDO_INSERT );
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 	pOwner->pEditEngine->SetUpdateMode( sal_False );
994cdf0e10cSrcweir 	sal_uLong nStart, nParaCount;
995cdf0e10cSrcweir 	nParaCount = pOwner->pEditEngine->GetParagraphCount();
996cdf0e10cSrcweir 	sal_uInt16 nSize = ImpInitPaste( nStart );
997cdf0e10cSrcweir 	pEditView->InsertText( rParaObj.GetTextObject() );
998cdf0e10cSrcweir 	ImpPasted( nStart, nParaCount, nSize);
999cdf0e10cSrcweir 	pEditView->SetEditEngineUpdateMode( sal_True );
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 	pOwner->UndoActionEnd( OLUNDO_INSERT );
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir 	pEditView->ShowCursor( sal_True, sal_True );
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir void OutlinerView::Cut()
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1011cdf0e10cSrcweir 	if ( !ImpCalcSelectedPages( sal_False ) || pOwner->ImpCanDeleteSelectedPages( this ) )
1012cdf0e10cSrcweir 		pEditView->Cut();
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir void OutlinerView::Paste()
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1018cdf0e10cSrcweir     PasteSpecial(); // HACK(SD ruft nicht PasteSpecial auf)
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir void OutlinerView::PasteSpecial()
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1024cdf0e10cSrcweir 	if ( !ImpCalcSelectedPages( sal_False ) || pOwner->ImpCanDeleteSelectedPages( this ) )
1025cdf0e10cSrcweir 	{
1026cdf0e10cSrcweir 		pOwner->UndoActionStart( OLUNDO_INSERT );
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 		pOwner->pEditEngine->SetUpdateMode( sal_False );
1029cdf0e10cSrcweir         pOwner->bPasting = sal_True;
1030cdf0e10cSrcweir         pEditView->PasteSpecial();
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir 		if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
1033cdf0e10cSrcweir 		{
1034cdf0e10cSrcweir         	const sal_uInt16 nParaCount = pOwner->pEditEngine->GetParagraphCount();
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir 		    for( sal_uInt16 nPara = 0; nPara < nParaCount; nPara++ )
1037cdf0e10cSrcweir 			    pOwner->ImplSetLevelDependendStyleSheet( nPara );
1038cdf0e10cSrcweir 	    }
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir         pEditView->SetEditEngineUpdateMode( sal_True );
1041cdf0e10cSrcweir 		pOwner->UndoActionEnd( OLUNDO_INSERT );
1042cdf0e10cSrcweir 		pEditView->ShowCursor( sal_True, sal_True );
1043cdf0e10cSrcweir 	}
1044cdf0e10cSrcweir }
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir List* OutlinerView::CreateSelectionList()
1047cdf0e10cSrcweir {
1048cdf0e10cSrcweir 	DBG_CHKTHIS( OutlinerView, 0 );
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir 	ParaRange aParas = ImpGetSelectedParagraphs( sal_True );
1051cdf0e10cSrcweir 	List* pSelList = new List;
1052cdf0e10cSrcweir 	for ( sal_uInt16 nPara = aParas.nStartPara; nPara <= aParas.nEndPara; nPara++ )
1053cdf0e10cSrcweir 	{
1054cdf0e10cSrcweir 		Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1055cdf0e10cSrcweir 		pSelList->Insert( pPara, LIST_APPEND );
1056cdf0e10cSrcweir 	}
1057cdf0e10cSrcweir 	return pSelList;
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir SfxStyleSheet* OutlinerView::GetStyleSheet() const
1061cdf0e10cSrcweir {
1062cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1063cdf0e10cSrcweir 	return pEditView->GetStyleSheet();
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir void OutlinerView::SetStyleSheet( SfxStyleSheet* pStyle )
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1069cdf0e10cSrcweir 	pEditView->SetStyleSheet( pStyle );
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir 	ParaRange aSel = ImpGetSelectedParagraphs( sal_True );
1072cdf0e10cSrcweir 	for( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1073cdf0e10cSrcweir 	{
1074cdf0e10cSrcweir 		pOwner->ImplCheckNumBulletItem( nPara );
1075cdf0e10cSrcweir 		pOwner->ImplCalcBulletText( nPara, sal_False, sal_False );
1076cdf0e10cSrcweir 	}
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir Pointer OutlinerView::GetPointer( const Point& rPosPixel )
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir     MouseTarget eTarget;
1084cdf0e10cSrcweir 	ImpCheckMousePos( rPosPixel, eTarget );
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir     PointerStyle ePointerStyle = POINTER_ARROW;
1087cdf0e10cSrcweir     if ( eTarget == MouseText )
1088cdf0e10cSrcweir     {
1089cdf0e10cSrcweir         ePointerStyle = GetOutliner()->IsVertical() ? POINTER_TEXT_VERTICAL : POINTER_TEXT;
1090cdf0e10cSrcweir     }
1091cdf0e10cSrcweir     else if ( eTarget == MouseHypertext )
1092cdf0e10cSrcweir     {
1093cdf0e10cSrcweir         ePointerStyle = POINTER_REFHAND;
1094cdf0e10cSrcweir     }
1095cdf0e10cSrcweir     else if ( eTarget == MouseBullet )
1096cdf0e10cSrcweir     {
1097cdf0e10cSrcweir         ePointerStyle = POINTER_MOVE;
1098cdf0e10cSrcweir     }
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir     return Pointer( ePointerStyle );
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir sal_uInt16 OutlinerView::ImpInitPaste( sal_uLong& rStart )
1105cdf0e10cSrcweir {
1106cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1107cdf0e10cSrcweir 	pOwner->bPasting = sal_True;
1108cdf0e10cSrcweir 	ESelection aSelection( pEditView->GetSelection() );
1109cdf0e10cSrcweir 	aSelection.Adjust();
1110cdf0e10cSrcweir 	rStart = aSelection.nStartPara;
1111cdf0e10cSrcweir 	sal_uInt16 nSize = aSelection.nEndPara - aSelection.nStartPara + 1;
1112cdf0e10cSrcweir 	return nSize;
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir void OutlinerView::ImpPasted( sal_uLong nStart, sal_uLong nPrevParaCount, sal_uInt16 nSize)
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1119cdf0e10cSrcweir 	pOwner->bPasting = sal_False;
1120cdf0e10cSrcweir 	sal_uLong nCurParaCount = (sal_uLong)pOwner->pEditEngine->GetParagraphCount();
1121cdf0e10cSrcweir 	if( nCurParaCount < nPrevParaCount )
1122cdf0e10cSrcweir 		nSize = sal::static_int_cast< sal_uInt16 >(
1123cdf0e10cSrcweir             nSize - ( nPrevParaCount - nCurParaCount ) );
1124cdf0e10cSrcweir 	else
1125cdf0e10cSrcweir 		nSize = sal::static_int_cast< sal_uInt16 >(
1126cdf0e10cSrcweir             nSize + ( nCurParaCount - nPrevParaCount ) );
1127cdf0e10cSrcweir 	pOwner->ImpTextPasted( nStart, nSize );
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir void OutlinerView::Command( const CommandEvent& rCEvt )
1132cdf0e10cSrcweir {
1133cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1134cdf0e10cSrcweir 	pEditView->Command( rCEvt );
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir void OutlinerView::SelectRange( sal_uLong nFirst, sal_uInt16 nCount )
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1141cdf0e10cSrcweir 	sal_uLong nLast = nFirst+nCount;
1142cdf0e10cSrcweir 	nCount = (sal_uInt16)pOwner->pParaList->GetParagraphCount();
1143cdf0e10cSrcweir 	if( nLast <= nCount )
1144cdf0e10cSrcweir 		nLast = nCount - 1;
1145cdf0e10cSrcweir 	ESelection aSel( (sal_uInt16)nFirst, 0, (sal_uInt16)nLast, 0xffff );
1146cdf0e10cSrcweir 	pEditView->SetSelection( aSel );
1147cdf0e10cSrcweir }
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir sal_uInt16 OutlinerView::ImpCalcSelectedPages( sal_Bool bIncludeFirstSelected )
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir 	ESelection aSel( pEditView->GetSelection() );
1155cdf0e10cSrcweir 	aSel.Adjust();
1156cdf0e10cSrcweir 
1157cdf0e10cSrcweir 	sal_uInt16 nPages = 0;
1158cdf0e10cSrcweir 	sal_uInt16 nFirstPage = 0xFFFF;
1159cdf0e10cSrcweir 	sal_uInt16 nStartPara = aSel.nStartPara;
1160cdf0e10cSrcweir 	if ( !bIncludeFirstSelected )
1161cdf0e10cSrcweir 		nStartPara++;	// alle nach StartPara kommenden Absaetze werden geloescht
1162cdf0e10cSrcweir 	for ( sal_uInt16 nPara = nStartPara; nPara <= aSel.nEndPara; nPara++ )
1163cdf0e10cSrcweir 	{
1164cdf0e10cSrcweir 		Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1165cdf0e10cSrcweir 		DBG_ASSERT(pPara, "ImpCalcSelectedPages: ungueltige Selection? ");
1166cdf0e10cSrcweir 		if( pPara->HasFlag(PARAFLAG_ISPAGE) )
1167cdf0e10cSrcweir 		{
1168cdf0e10cSrcweir 			nPages++;
1169cdf0e10cSrcweir 			if( nFirstPage == 0xFFFF )
1170cdf0e10cSrcweir 				nFirstPage = nPara;
1171cdf0e10cSrcweir 		}
1172cdf0e10cSrcweir 	}
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 	if( nPages )
1175cdf0e10cSrcweir 	{
1176cdf0e10cSrcweir 		pOwner->nDepthChangedHdlPrevDepth = nPages;
1177cdf0e10cSrcweir 		pOwner->pHdlParagraph = 0;
1178cdf0e10cSrcweir 		pOwner->mnFirstSelPage = nFirstPage;
1179cdf0e10cSrcweir 	}
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 	return nPages;
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir 
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir void OutlinerView::ToggleBullets()
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir 	pOwner->UndoActionStart( OLUNDO_DEPTH );
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir 	ESelection aSel( pEditView->GetSelection() );
1190cdf0e10cSrcweir 	aSel.Adjust();
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir 	const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
1193cdf0e10cSrcweir 	pOwner->pEditEngine->SetUpdateMode( sal_False );
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir 	sal_Int16 nDepth = -2;
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir 	for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1198cdf0e10cSrcweir 	{
1199cdf0e10cSrcweir 		Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1200cdf0e10cSrcweir 		DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?");
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir 		if( pPara )
1203cdf0e10cSrcweir 		{
1204cdf0e10cSrcweir 			if( nDepth == -2 )
1205cdf0e10cSrcweir 				nDepth = (pOwner->GetDepth(nPara) == -1) ? 0 : -1;
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir 			pOwner->SetDepth( pPara, nDepth );
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir             if( nDepth == -1 )
1210cdf0e10cSrcweir             {
1211cdf0e10cSrcweir     			const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara );
1212cdf0e10cSrcweir                 if(rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SFX_ITEM_SET)
1213cdf0e10cSrcweir                 {
1214cdf0e10cSrcweir                     SfxItemSet aAttrs(rAttrs);
1215cdf0e10cSrcweir                     aAttrs.ClearItem( EE_PARA_BULLETSTATE );
1216cdf0e10cSrcweir                     pOwner->SetParaAttribs( nPara, aAttrs );
1217cdf0e10cSrcweir                 }
1218cdf0e10cSrcweir             }
1219cdf0e10cSrcweir 		}
1220cdf0e10cSrcweir 	}
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir     // --> OD 2009-03-10 #i100014#
1223cdf0e10cSrcweir     // It is not a good idea to substract 1 from a count and cast the result
1224cdf0e10cSrcweir     // to sal_uInt16 without check, if the count is 0.
1225cdf0e10cSrcweir     sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount());
1226cdf0e10cSrcweir     // <--
1227cdf0e10cSrcweir     pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount );
1228cdf0e10cSrcweir     pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) );
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir 	pOwner->pEditEngine->SetUpdateMode( bUpdate );
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir 	pOwner->UndoActionEnd( OLUNDO_DEPTH );
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir void OutlinerView::EnableBullets()
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir 	pOwner->UndoActionStart( OLUNDO_DEPTH );
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir 	ESelection aSel( pEditView->GetSelection() );
1240cdf0e10cSrcweir 	aSel.Adjust();
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir 	const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
1243cdf0e10cSrcweir 	pOwner->pEditEngine->SetUpdateMode( sal_False );
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir 	for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1246cdf0e10cSrcweir 	{
1247cdf0e10cSrcweir 		Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1248cdf0e10cSrcweir 		DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?");
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir 		if( pPara && (pOwner->GetDepth(nPara) == -1) )
1251cdf0e10cSrcweir 		{
1252cdf0e10cSrcweir 			pOwner->SetDepth( pPara, 0 );
1253cdf0e10cSrcweir 		}
1254cdf0e10cSrcweir 	}
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir     // --> OD 2009-03-10 #i100014#
1257cdf0e10cSrcweir     // It is not a good idea to substract 1 from a count and cast the result
1258cdf0e10cSrcweir     // to sal_uInt16 without check, if the count is 0.
1259cdf0e10cSrcweir     sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount());
1260cdf0e10cSrcweir     // <--
1261cdf0e10cSrcweir     pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount );
1262cdf0e10cSrcweir     pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) );
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir 	pOwner->pEditEngine->SetUpdateMode( bUpdate );
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir 	pOwner->UndoActionEnd( OLUNDO_DEPTH );
1267cdf0e10cSrcweir }
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir void OutlinerView::RemoveAttribsKeepLanguages( sal_Bool bRemoveParaAttribs )
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir     RemoveAttribs( bRemoveParaAttribs, 0, sal_True /*keep language attribs*/ );
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir void OutlinerView::RemoveAttribs( sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich, sal_Bool bKeepLanguages )
1276cdf0e10cSrcweir {
1277cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1278cdf0e10cSrcweir 	sal_Bool bUpdate = pOwner->GetUpdateMode();
1279cdf0e10cSrcweir 	pOwner->SetUpdateMode( sal_False );
1280cdf0e10cSrcweir 	pOwner->UndoActionStart( OLUNDO_ATTR );
1281cdf0e10cSrcweir     if (bKeepLanguages)
1282cdf0e10cSrcweir         pEditView->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
1283cdf0e10cSrcweir     else
1284cdf0e10cSrcweir         pEditView->RemoveAttribs( bRemoveParaAttribs, nWhich );
1285cdf0e10cSrcweir 	if ( bRemoveParaAttribs )
1286cdf0e10cSrcweir 	{
1287cdf0e10cSrcweir 		// Ueber alle Absaetze, und Einrueckung und Level einstellen
1288cdf0e10cSrcweir 		ESelection aSel = pEditView->GetSelection();
1289cdf0e10cSrcweir 		aSel.Adjust();
1290cdf0e10cSrcweir 		for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1291cdf0e10cSrcweir 		{
1292cdf0e10cSrcweir 			Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1293cdf0e10cSrcweir             pOwner->ImplInitDepth( nPara, pPara->GetDepth(), sal_False, sal_False );
1294cdf0e10cSrcweir 		}
1295cdf0e10cSrcweir 	}
1296cdf0e10cSrcweir 	pOwner->UndoActionEnd( OLUNDO_ATTR );
1297cdf0e10cSrcweir 	pOwner->SetUpdateMode( bUpdate );
1298cdf0e10cSrcweir }
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir // =====================================================================
1303cdf0e10cSrcweir // ======================   Einfache Durchreicher =======================
1304cdf0e10cSrcweir // ======================================================================
1305cdf0e10cSrcweir 
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir void OutlinerView::InsertText( const XubString& rNew, sal_Bool bSelect )
1308cdf0e10cSrcweir {
1309cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1310cdf0e10cSrcweir 	if( pOwner->bFirstParaIsEmpty )
1311cdf0e10cSrcweir 		pOwner->Insert( String() );
1312cdf0e10cSrcweir 	pEditView->InsertText( rNew, bSelect );
1313cdf0e10cSrcweir }
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir void OutlinerView::SetVisArea( const Rectangle& rRec )
1316cdf0e10cSrcweir {
1317cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1318cdf0e10cSrcweir 	pEditView->SetVisArea( rRec );
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir void OutlinerView::SetSelection( const ESelection& rSel )
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1325cdf0e10cSrcweir 	pEditView->SetSelection( rSel );
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir void OutlinerView::SetReadOnly( sal_Bool bReadOnly )
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1331cdf0e10cSrcweir 	pEditView->SetReadOnly( bReadOnly );
1332cdf0e10cSrcweir }
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir sal_Bool OutlinerView::IsReadOnly() const
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1337cdf0e10cSrcweir 	return pEditView->IsReadOnly();
1338cdf0e10cSrcweir }
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir sal_Bool OutlinerView::HasSelection() const
1341cdf0e10cSrcweir {
1342cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1343cdf0e10cSrcweir 	return pEditView->HasSelection();
1344cdf0e10cSrcweir }
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir void OutlinerView::ShowCursor( sal_Bool bGotoCursor )
1348cdf0e10cSrcweir {
1349cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1350cdf0e10cSrcweir 	pEditView->ShowCursor( bGotoCursor );
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir 
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir void OutlinerView::HideCursor()
1355cdf0e10cSrcweir {
1356cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1357cdf0e10cSrcweir 	pEditView->HideCursor();
1358cdf0e10cSrcweir }
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir void OutlinerView::SetWindow( Window* pWin )
1362cdf0e10cSrcweir {
1363cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1364cdf0e10cSrcweir 	pEditView->SetWindow( pWin );
1365cdf0e10cSrcweir }
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir Window* OutlinerView::GetWindow() const
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1371cdf0e10cSrcweir 	return pEditView->GetWindow();
1372cdf0e10cSrcweir }
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir void OutlinerView::SetOutputArea( const Rectangle& rRect )
1376cdf0e10cSrcweir {
1377cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1378cdf0e10cSrcweir 	pEditView->SetOutputArea( rRect );
1379cdf0e10cSrcweir }
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir 
1382cdf0e10cSrcweir Rectangle OutlinerView::GetOutputArea() const
1383cdf0e10cSrcweir {
1384cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1385cdf0e10cSrcweir 	return pEditView->GetOutputArea();
1386cdf0e10cSrcweir }
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir XubString OutlinerView::GetSelected() const
1390cdf0e10cSrcweir {
1391cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1392cdf0e10cSrcweir 	return pEditView->GetSelected();
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir void OutlinerView::RemoveCharAttribs( sal_uLong nPara, sal_uInt16 nWhich)
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1399cdf0e10cSrcweir 	pEditView->RemoveCharAttribs( (sal_uInt16)nPara, nWhich);
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir 
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir void OutlinerView::CompleteAutoCorrect()
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1406cdf0e10cSrcweir 	pEditView->CompleteAutoCorrect();
1407cdf0e10cSrcweir }
1408cdf0e10cSrcweir 
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir EESpellState OutlinerView::StartSpeller( sal_Bool bMultiDoc )
1411cdf0e10cSrcweir {
1412cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1413cdf0e10cSrcweir 	return pEditView->StartSpeller( bMultiDoc );
1414cdf0e10cSrcweir }
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir EESpellState OutlinerView::StartThesaurus()
1418cdf0e10cSrcweir {
1419cdf0e10cSrcweir     DBG_CHKTHIS(OutlinerView,0);
1420cdf0e10cSrcweir     return pEditView->StartThesaurus();
1421cdf0e10cSrcweir }
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir 
1424cdf0e10cSrcweir void OutlinerView::StartTextConversion(
1425cdf0e10cSrcweir     LanguageType nSrcLang, LanguageType nDestLang, const Font *pDestFont,
1426cdf0e10cSrcweir     sal_Int32 nOptions, sal_Bool bIsInteractive, sal_Bool bMultipleDoc )
1427cdf0e10cSrcweir {
1428cdf0e10cSrcweir     DBG_CHKTHIS(OutlinerView,0);
1429cdf0e10cSrcweir     if (
1430cdf0e10cSrcweir         (LANGUAGE_KOREAN == nSrcLang && LANGUAGE_KOREAN == nDestLang) ||
1431cdf0e10cSrcweir         (LANGUAGE_CHINESE_SIMPLIFIED  == nSrcLang && LANGUAGE_CHINESE_TRADITIONAL == nDestLang) ||
1432cdf0e10cSrcweir         (LANGUAGE_CHINESE_TRADITIONAL == nSrcLang && LANGUAGE_CHINESE_SIMPLIFIED  == nDestLang)
1433cdf0e10cSrcweir        )
1434cdf0e10cSrcweir     {
1435cdf0e10cSrcweir         pEditView->StartTextConversion( nSrcLang, nDestLang, pDestFont, nOptions, bIsInteractive, bMultipleDoc );
1436cdf0e10cSrcweir     }
1437cdf0e10cSrcweir     else
1438cdf0e10cSrcweir     {
1439cdf0e10cSrcweir         DBG_ERROR( "unexpected language" );
1440cdf0e10cSrcweir     }
1441cdf0e10cSrcweir }
1442cdf0e10cSrcweir 
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir sal_uInt16 OutlinerView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1447cdf0e10cSrcweir 	return pEditView->StartSearchAndReplace( rSearchItem );
1448cdf0e10cSrcweir }
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir void OutlinerView::TransliterateText( sal_Int32 nTransliterationMode )
1451cdf0e10cSrcweir {
1452cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1453cdf0e10cSrcweir 	pEditView->TransliterateText( nTransliterationMode );
1454cdf0e10cSrcweir }
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir ESelection OutlinerView::GetSelection()
1459cdf0e10cSrcweir {
1460cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1461cdf0e10cSrcweir 	return pEditView->GetSelection();
1462cdf0e10cSrcweir }
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir 
1465cdf0e10cSrcweir void OutlinerView::Scroll( long nHorzScroll, long nVertScroll )
1466cdf0e10cSrcweir {
1467cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1468cdf0e10cSrcweir 	pEditView->Scroll( nHorzScroll, nVertScroll );
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir void OutlinerView::SetControlWord( sal_uLong nWord )
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1475cdf0e10cSrcweir 	pEditView->SetControlWord( nWord );
1476cdf0e10cSrcweir }
1477cdf0e10cSrcweir 
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir sal_uLong OutlinerView::GetControlWord() const
1480cdf0e10cSrcweir {
1481cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1482cdf0e10cSrcweir 	return pEditView->GetControlWord();
1483cdf0e10cSrcweir }
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir void OutlinerView::SetAnchorMode( EVAnchorMode eMode )
1487cdf0e10cSrcweir {
1488cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1489cdf0e10cSrcweir 	pEditView->SetAnchorMode( eMode );
1490cdf0e10cSrcweir }
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir EVAnchorMode OutlinerView::GetAnchorMode() const
1494cdf0e10cSrcweir {
1495cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1496cdf0e10cSrcweir 	return pEditView->GetAnchorMode();
1497cdf0e10cSrcweir }
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir void OutlinerView::Undo()
1501cdf0e10cSrcweir {
1502cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1503cdf0e10cSrcweir 	pEditView->Undo();
1504cdf0e10cSrcweir }
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir void OutlinerView::Redo()
1508cdf0e10cSrcweir {
1509cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1510cdf0e10cSrcweir 	pEditView->Redo();
1511cdf0e10cSrcweir }
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir 
1514cdf0e10cSrcweir void OutlinerView::EnablePaste( sal_Bool bEnable )
1515cdf0e10cSrcweir {
1516cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1517cdf0e10cSrcweir 	pEditView->EnablePaste( bEnable );
1518cdf0e10cSrcweir }
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir 
1521cdf0e10cSrcweir void OutlinerView::Copy()
1522cdf0e10cSrcweir {
1523cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1524cdf0e10cSrcweir 	pEditView->Copy();
1525cdf0e10cSrcweir }
1526cdf0e10cSrcweir 
1527cdf0e10cSrcweir 
1528cdf0e10cSrcweir void OutlinerView::InsertField( const SvxFieldItem& rFld )
1529cdf0e10cSrcweir {
1530cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1531cdf0e10cSrcweir 	pEditView->InsertField( rFld );
1532cdf0e10cSrcweir }
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir const SvxFieldItem* OutlinerView::GetFieldUnderMousePointer() const
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1538cdf0e10cSrcweir 	return pEditView->GetFieldUnderMousePointer();
1539cdf0e10cSrcweir }
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir const SvxFieldItem* OutlinerView::GetFieldUnderMousePointer( sal_uInt16& nPara, sal_uInt16& nPos ) const
1543cdf0e10cSrcweir {
1544cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1545cdf0e10cSrcweir 	return pEditView->GetFieldUnderMousePointer( nPara, nPos );
1546cdf0e10cSrcweir }
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir const SvxFieldItem* OutlinerView::GetFieldAtSelection() const
1550cdf0e10cSrcweir {
1551cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1552cdf0e10cSrcweir 	return pEditView->GetFieldAtSelection();
1553cdf0e10cSrcweir }
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel )
1556cdf0e10cSrcweir {
1557cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1558cdf0e10cSrcweir 	pEditView->SetInvalidateMore( nPixel );
1559cdf0e10cSrcweir }
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir 
1562cdf0e10cSrcweir sal_uInt16 OutlinerView::GetInvalidateMore() const
1563cdf0e10cSrcweir {
1564cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1565cdf0e10cSrcweir 	return pEditView->GetInvalidateMore();
1566cdf0e10cSrcweir }
1567cdf0e10cSrcweir 
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir sal_Bool OutlinerView::IsCursorAtWrongSpelledWord( sal_Bool bMarkIfWrong )
1570cdf0e10cSrcweir {
1571cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1572cdf0e10cSrcweir 	return pEditView->IsCursorAtWrongSpelledWord( bMarkIfWrong );
1573cdf0e10cSrcweir }
1574cdf0e10cSrcweir 
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir sal_Bool OutlinerView::IsWrongSpelledWordAtPos( const Point& rPosPixel, sal_Bool bMarkIfWrong )
1577cdf0e10cSrcweir {
1578cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1579cdf0e10cSrcweir 	return pEditView->IsWrongSpelledWordAtPos( rPosPixel, bMarkIfWrong );
1580cdf0e10cSrcweir }
1581cdf0e10cSrcweir 
1582cdf0e10cSrcweir 
1583cdf0e10cSrcweir void OutlinerView::SpellIgnoreWord()
1584cdf0e10cSrcweir {
1585cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1586cdf0e10cSrcweir 	pEditView->SpellIgnoreWord();
1587cdf0e10cSrcweir }
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir 
1590cdf0e10cSrcweir void OutlinerView::ExecuteSpellPopup( const Point& rPosPixel, Link* pStartDlg )
1591cdf0e10cSrcweir {
1592cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1593cdf0e10cSrcweir 	pEditView->ExecuteSpellPopup( rPosPixel, pStartDlg );
1594cdf0e10cSrcweir }
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir sal_uLong OutlinerView::Read( SvStream& rInput,  const String& rBaseURL, EETextFormat eFormat, sal_Bool bSelect, SvKeyValueIterator* pHTTPHeaderAttrs )
1597cdf0e10cSrcweir {
1598cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1599cdf0e10cSrcweir 	sal_uInt16 nOldParaCount = pEditView->GetEditEngine()->GetParagraphCount();
1600cdf0e10cSrcweir 	ESelection aOldSel = pEditView->GetSelection();
1601cdf0e10cSrcweir 	aOldSel.Adjust();
1602cdf0e10cSrcweir 
1603cdf0e10cSrcweir     sal_uLong nRet = pEditView->Read( rInput, rBaseURL, eFormat, bSelect, pHTTPHeaderAttrs );
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir 	// MT 08/00: Hier sollte eigentlich das gleiche wie in PasteSpecial passieren!
1606cdf0e10cSrcweir 	// Mal anpassen, wenn dieses ImplInitPaste und ImpPasted-Geraffel ueberarbeitet ist.
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir 	long nParaDiff = pEditView->GetEditEngine()->GetParagraphCount() - nOldParaCount;
1609cdf0e10cSrcweir 	sal_uInt16 nChangesStart = aOldSel.nStartPara;
1610cdf0e10cSrcweir 	sal_uInt16 nChangesEnd = sal::static_int_cast< sal_uInt16 >(nChangesStart + nParaDiff + (aOldSel.nEndPara-aOldSel.nStartPara));
1611cdf0e10cSrcweir 
1612cdf0e10cSrcweir 	for ( sal_uInt16 n = nChangesStart; n <= nChangesEnd; n++ )
1613cdf0e10cSrcweir 	{
1614cdf0e10cSrcweir 		if ( eFormat == EE_FORMAT_BIN )
1615cdf0e10cSrcweir 		{
1616cdf0e10cSrcweir 			sal_uInt16 nDepth = 0;
1617cdf0e10cSrcweir 			const SfxItemSet& rAttrs = pOwner->GetParaAttribs( n );
1618cdf0e10cSrcweir 			const SfxInt16Item& rLevel = (const SfxInt16Item&) rAttrs.Get( EE_PARA_OUTLLEVEL );
1619cdf0e10cSrcweir 			nDepth = rLevel.GetValue();
1620cdf0e10cSrcweir 			pOwner->ImplInitDepth( n, nDepth, sal_False );
1621cdf0e10cSrcweir 		}
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir 		if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
1624cdf0e10cSrcweir 			pOwner->ImplSetLevelDependendStyleSheet( n );
1625cdf0e10cSrcweir 	}
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir 	if ( eFormat != EE_FORMAT_BIN )
1628cdf0e10cSrcweir 	{
1629cdf0e10cSrcweir 		pOwner->ImpFilterIndents( nChangesStart, nChangesEnd );
1630cdf0e10cSrcweir 	}
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir 	return nRet;
1633cdf0e10cSrcweir }
1634cdf0e10cSrcweir 
1635cdf0e10cSrcweir sal_uLong OutlinerView::Write( SvStream& rOutput, EETextFormat eFormat )
1636cdf0e10cSrcweir {
1637cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1638cdf0e10cSrcweir 	return pEditView->Write( rOutput, eFormat );
1639cdf0e10cSrcweir }
1640cdf0e10cSrcweir 
1641cdf0e10cSrcweir void OutlinerView::SetBackgroundColor( const Color& rColor )
1642cdf0e10cSrcweir {
1643cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1644cdf0e10cSrcweir 	pEditView->SetBackgroundColor( rColor );
1645cdf0e10cSrcweir }
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir Color OutlinerView::GetBackgroundColor()
1649cdf0e10cSrcweir {
1650cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1651cdf0e10cSrcweir 	return pEditView->GetBackgroundColor();
1652cdf0e10cSrcweir }
1653cdf0e10cSrcweir 
1654cdf0e10cSrcweir SfxItemSet OutlinerView::GetAttribs()
1655cdf0e10cSrcweir {
1656cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1657cdf0e10cSrcweir 	return pEditView->GetAttribs();
1658cdf0e10cSrcweir }
1659cdf0e10cSrcweir 
1660cdf0e10cSrcweir sal_uInt16 OutlinerView::GetSelectedScriptType() const
1661cdf0e10cSrcweir {
1662cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1663cdf0e10cSrcweir 	return pEditView->GetSelectedScriptType();
1664cdf0e10cSrcweir }
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir String OutlinerView::GetSurroundingText() const
1667cdf0e10cSrcweir {
1668cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1669cdf0e10cSrcweir 	return pEditView->GetSurroundingText();
1670cdf0e10cSrcweir }
1671cdf0e10cSrcweir 
1672cdf0e10cSrcweir Selection OutlinerView::GetSurroundingTextSelection() const
1673cdf0e10cSrcweir {
1674cdf0e10cSrcweir 	DBG_CHKTHIS(OutlinerView,0);
1675cdf0e10cSrcweir 	return pEditView->GetSurroundingTextSelection();
1676cdf0e10cSrcweir }
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir 
1679cdf0e10cSrcweir // ======================================================================
1680cdf0e10cSrcweir // ===== some code for thesaurus sub menu within context menu
1681cdf0e10cSrcweir // ======================================================================
1682cdf0e10cSrcweir 
1683cdf0e10cSrcweir // returns: true if a word for thesaurus look-up was found at the current cursor position.
1684cdf0e10cSrcweir // The status string will be word + iso language string (e.g. "light#en-US")
1685cdf0e10cSrcweir bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext(
1686cdf0e10cSrcweir     String &rStatusVal,
1687cdf0e10cSrcweir     LanguageType &rLang,
1688cdf0e10cSrcweir     const EditView &rEditView )
1689cdf0e10cSrcweir {
1690cdf0e10cSrcweir     // get text and locale for thesaurus look up
1691cdf0e10cSrcweir     String aText;
1692cdf0e10cSrcweir     EditEngine *pEditEngine = rEditView.GetEditEngine();
1693cdf0e10cSrcweir     ESelection aTextSel( rEditView.GetSelection() );
1694cdf0e10cSrcweir     if (!aTextSel.HasRange())
1695cdf0e10cSrcweir         aTextSel = pEditEngine->GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD );
1696cdf0e10cSrcweir     aText = pEditEngine->GetText( aTextSel );
1697cdf0e10cSrcweir     aTextSel.Adjust();
1698cdf0e10cSrcweir     LanguageType nLang = pEditEngine->GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos );
1699cdf0e10cSrcweir     String aLangText( MsLangId::convertLanguageToIsoString( nLang ) );
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir     // set word and locale to look up as status value
1702cdf0e10cSrcweir     String aStatusVal( aText );
1703cdf0e10cSrcweir     aStatusVal.AppendAscii( "#" );
1704cdf0e10cSrcweir     aStatusVal += aLangText;
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir     rStatusVal  = aStatusVal;
1707cdf0e10cSrcweir     rLang       = nLang;
1708cdf0e10cSrcweir 
1709cdf0e10cSrcweir     return aText.Len() > 0;
1710cdf0e10cSrcweir }
1711cdf0e10cSrcweir 
1712cdf0e10cSrcweir 
1713cdf0e10cSrcweir void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const String &rSynonmText )
1714cdf0e10cSrcweir {
1715cdf0e10cSrcweir     // get selection to use
1716cdf0e10cSrcweir     ESelection aCurSel( rEditView.GetSelection() );
1717cdf0e10cSrcweir     if (!rEditView.HasSelection())
1718cdf0e10cSrcweir     {
1719cdf0e10cSrcweir         // select the same word that was used in GetStatusValueForThesaurusFromContext by calling GetWord.
1720cdf0e10cSrcweir         // (In the end both functions will call ImpEditEngine::SelectWord)
1721cdf0e10cSrcweir         rEditView.SelectCurrentWord( i18n::WordType::DICTIONARY_WORD );
1722cdf0e10cSrcweir         aCurSel = rEditView.GetSelection();
1723cdf0e10cSrcweir     }
1724cdf0e10cSrcweir 
1725cdf0e10cSrcweir     // replace word ...
1726cdf0e10cSrcweir     rEditView.InsertText( rSynonmText );
1727cdf0e10cSrcweir     rEditView.ShowCursor( sal_True, sal_False );
1728cdf0e10cSrcweir }
1729cdf0e10cSrcweir 
1730cdf0e10cSrcweir 
1731