Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/i18n/WordType.hpp>
21 :
22 : #include <svl/intitem.hxx>
23 : #include <editeng/editeng.hxx>
24 : #include <editeng/editview.hxx>
25 : #include <editeng/editdata.hxx>
26 : #include <editeng/eerdll.hxx>
27 : #include <editeng/lrspitem.hxx>
28 : #include <editeng/fhgtitem.hxx>
29 :
30 : #include <svl/style.hxx>
31 : #include <i18npool/languagetag.hxx>
32 :
33 : #define _OUTLINER_CXX
34 : #include <editeng/outliner.hxx>
35 : #include <outleeng.hxx>
36 : #include <paralist.hxx>
37 : #include <outlundo.hxx>
38 : #include <editeng/outlobj.hxx>
39 : #include <editeng/flditem.hxx>
40 : #include <editeng/eeitem.hxx>
41 : #include <editeng/numitem.hxx>
42 : #include <vcl/window.hxx>
43 : #include <svl/itemset.hxx>
44 : #include <editeng/editstat.hxx>
45 :
46 : using namespace ::com::sun::star;
47 :
48 : DBG_NAME(OutlinerView)
49 :
50 :
51 6 : OutlinerView::OutlinerView( Outliner* pOut, Window* pWin )
52 : {
53 : DBG_CTOR( OutlinerView, 0 );
54 :
55 6 : pOwner = pOut;
56 6 : bDDCursorVisible = sal_False;
57 6 : bInDragMode = sal_False;
58 6 : nDDScrollLRBorderWidthWin = 0;
59 6 : nDDScrollTBBorderWidthWin = 0;
60 6 : pHorTabArrDoc = 0;
61 :
62 6 : pEditView = new EditView( pOut->pEditEngine, pWin );
63 6 : pEditView->SetSelectionMode( EE_SELMODE_TXTONLY );
64 6 : }
65 :
66 6 : OutlinerView::~OutlinerView()
67 : {
68 : DBG_DTOR(OutlinerView,0);
69 3 : delete pEditView;
70 6 : }
71 :
72 0 : void OutlinerView::Paint( const Rectangle& rRect )
73 : {
74 : DBG_CHKTHIS(OutlinerView,0);
75 :
76 : // For the first Paint/KeyInput/Drop an emty Outliner is turned into
77 : // an Outliner with exactly one paragraph.
78 0 : if( pOwner->bFirstParaIsEmpty )
79 0 : pOwner->Insert( String() );
80 :
81 0 : pEditView->Paint( rRect );
82 0 : }
83 :
84 0 : sal_Bool OutlinerView::PostKeyEvent( const KeyEvent& rKEvt, Window* pFrameWin )
85 : {
86 : DBG_CHKTHIS( OutlinerView, 0 );
87 :
88 : // For the first Paint/KeyInput/Drop an emty Outliner is turned into
89 : // an Outliner with exactly one paragraph.
90 0 : if( pOwner->bFirstParaIsEmpty )
91 0 : pOwner->Insert( String() );
92 :
93 :
94 0 : sal_Bool bKeyProcessed = sal_False;
95 0 : ESelection aSel( pEditView->GetSelection() );
96 0 : sal_Bool bSelection = aSel.HasRange();
97 0 : KeyCode aKeyCode = rKEvt.GetKeyCode();
98 0 : KeyFuncType eFunc = aKeyCode.GetFunction();
99 0 : sal_uInt16 nCode = aKeyCode.GetCode();
100 0 : sal_Bool bReadOnly = IsReadOnly();
101 :
102 0 : if( bSelection && ( nCode != KEY_TAB ) && EditEngine::DoesKeyChangeText( rKEvt ) )
103 : {
104 0 : if ( ImpCalcSelectedPages( sal_False ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
105 0 : return sal_True;
106 : }
107 :
108 0 : if ( eFunc != KEYFUNC_DONTKNOW )
109 : {
110 0 : switch ( eFunc )
111 : {
112 : case KEYFUNC_CUT:
113 : {
114 0 : if ( !bReadOnly )
115 : {
116 0 : Cut();
117 0 : bKeyProcessed = sal_True;
118 : }
119 : }
120 0 : break;
121 : case KEYFUNC_COPY:
122 : {
123 0 : Copy();
124 0 : bKeyProcessed = sal_True;
125 : }
126 0 : break;
127 : case KEYFUNC_PASTE:
128 : {
129 0 : if ( !bReadOnly )
130 : {
131 0 : PasteSpecial();
132 0 : bKeyProcessed = sal_True;
133 : }
134 : }
135 0 : break;
136 : case KEYFUNC_DELETE:
137 : {
138 0 : if( !bReadOnly && !bSelection && ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) )
139 : {
140 0 : if( aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
141 : {
142 0 : Paragraph* pNext = pOwner->pParaList->GetParagraph( aSel.nEndPara+1 );
143 0 : if( pNext && pNext->HasFlag(PARAFLAG_ISPAGE) )
144 : {
145 0 : if( !pOwner->ImpCanDeleteSelectedPages( this, aSel.nEndPara, 1 ) )
146 0 : return sal_False;
147 : }
148 : }
149 : }
150 : }
151 0 : break;
152 : default: // is then possibly edited below.
153 0 : eFunc = KEYFUNC_DONTKNOW;
154 : }
155 : }
156 0 : if ( eFunc == KEYFUNC_DONTKNOW )
157 : {
158 0 : switch ( nCode )
159 : {
160 : case KEY_TAB:
161 : {
162 0 : if ( !bReadOnly && !aKeyCode.IsMod1() && !aKeyCode.IsMod2() )
163 : {
164 0 : if ( ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) &&
165 0 : ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TITLEOBJECT ) &&
166 0 : ( bSelection || !aSel.nStartPos ) )
167 : {
168 0 : Indent( aKeyCode.IsShift() ? (-1) : (+1) );
169 0 : bKeyProcessed = sal_True;
170 : }
171 0 : else if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) &&
172 0 : !bSelection && !aSel.nEndPos && pOwner->ImplHasBullet( aSel.nEndPara ) )
173 : {
174 0 : Indent( aKeyCode.IsShift() ? (-1) : (+1) );
175 0 : bKeyProcessed = sal_True;
176 : }
177 : }
178 : }
179 0 : break;
180 : case KEY_BACKSPACE:
181 : {
182 0 : if( !bReadOnly && !bSelection && aSel.nEndPara && !aSel.nEndPos )
183 : {
184 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
185 0 : Paragraph* pPrev = pOwner->pParaList->GetParagraph( aSel.nEndPara-1 );
186 0 : if( !pPrev->IsVisible() )
187 0 : return sal_True;
188 0 : if( !pPara->GetDepth() )
189 : {
190 0 : if(!pOwner->ImpCanDeleteSelectedPages(this, aSel.nEndPara , 1 ) )
191 0 : return sal_True;
192 : }
193 : }
194 : }
195 0 : break;
196 : case KEY_RETURN:
197 : {
198 0 : if ( !bReadOnly )
199 : {
200 : // Special treatment: hard return at the end of a paragraph,
201 : // which has collapsed subparagraphs.
202 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
203 :
204 0 : if( !aKeyCode.IsShift() )
205 : {
206 : // ImpGetCursor again???
207 0 : if( !bSelection &&
208 0 : aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
209 : {
210 0 : sal_uLong nChildren = pOwner->pParaList->GetChildCount(pPara);
211 0 : if( nChildren && !pOwner->pParaList->HasVisibleChildren(pPara))
212 : {
213 0 : pOwner->UndoActionStart( OLUNDO_INSERT );
214 0 : sal_uLong nTemp = aSel.nEndPara;
215 0 : nTemp += nChildren;
216 0 : nTemp++; // insert above next Non-Child
217 0 : pOwner->Insert( String(),nTemp,pPara->GetDepth());
218 : // Position the cursor
219 0 : ESelection aTmpSel((sal_uInt16)nTemp,0,(sal_uInt16)nTemp,0);
220 0 : pEditView->SetSelection( aTmpSel );
221 0 : pEditView->ShowCursor( sal_True, sal_True );
222 0 : pOwner->UndoActionEnd( OLUNDO_INSERT );
223 0 : bKeyProcessed = sal_True;
224 : }
225 : }
226 : }
227 0 : if( !bKeyProcessed && !bSelection &&
228 0 : !aKeyCode.IsShift() && aKeyCode.IsMod1() &&
229 0 : ( aSel.nEndPos == pOwner->pEditEngine->GetTextLen(aSel.nEndPara) ) )
230 : {
231 0 : pOwner->UndoActionStart( OLUNDO_INSERT );
232 0 : sal_uLong nTemp = aSel.nEndPara;
233 0 : nTemp++;
234 0 : pOwner->Insert( String(), nTemp, pPara->GetDepth()+1 );
235 :
236 : // Position the cursor
237 0 : ESelection aTmpSel((sal_uInt16)nTemp,0,(sal_uInt16)nTemp,0);
238 0 : pEditView->SetSelection( aTmpSel );
239 0 : pEditView->ShowCursor( sal_True, sal_True );
240 0 : pOwner->UndoActionEnd( OLUNDO_INSERT );
241 0 : bKeyProcessed = sal_True;
242 : }
243 : }
244 : }
245 0 : break;
246 : }
247 : }
248 :
249 0 : return bKeyProcessed ? sal_True : pEditView->PostKeyEvent( rKEvt, pFrameWin );
250 :
251 : }
252 :
253 :
254 0 : sal_uLong OutlinerView::ImpCheckMousePos(const Point& rPosPix, MouseTarget& reTarget)
255 : {
256 : DBG_CHKTHIS(OutlinerView,0);
257 0 : sal_uLong nPara = EE_PARA_NOT_FOUND;
258 :
259 0 : Point aMousePosWin = pEditView->GetWindow()->PixelToLogic( rPosPix );
260 0 : if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
261 : {
262 0 : reTarget = MouseOutside;
263 : }
264 : else
265 : {
266 0 : reTarget = MouseText;
267 :
268 0 : Point aPaperPos( aMousePosWin );
269 0 : Rectangle aOutArea = pEditView->GetOutputArea();
270 0 : Rectangle aVisArea = pEditView->GetVisArea();
271 0 : aPaperPos.X() -= aOutArea.Left();
272 0 : aPaperPos.X() += aVisArea.Left();
273 0 : aPaperPos.Y() -= aOutArea.Top();
274 0 : aPaperPos.Y() += aVisArea.Top();
275 :
276 : sal_Bool bBullet;
277 0 : if ( pOwner->IsTextPos( aPaperPos, 0, &bBullet ) )
278 : {
279 0 : Point aDocPos = pOwner->GetDocPos( aPaperPos );
280 0 : nPara = pOwner->pEditEngine->FindParagraph( aDocPos.Y() );
281 :
282 0 : if ( bBullet )
283 : {
284 0 : reTarget = MouseBullet;
285 : }
286 : else
287 : {
288 : // Check for hyperlink
289 0 : const SvxFieldItem* pFieldItem = pEditView->GetField( aMousePosWin );
290 0 : if ( pFieldItem && pFieldItem->GetField() && pFieldItem->GetField()->ISA( SvxURLField ) )
291 0 : reTarget = MouseHypertext;
292 : }
293 : }
294 : }
295 0 : return nPara;
296 : }
297 :
298 0 : sal_Bool OutlinerView::MouseMove( const MouseEvent& rMEvt )
299 : {
300 : DBG_CHKTHIS(OutlinerView,0);
301 :
302 0 : if( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode())
303 0 : return pEditView->MouseMove( rMEvt );
304 :
305 0 : Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
306 0 : if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
307 0 : return sal_False;
308 :
309 0 : Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
310 0 : pEditView->GetWindow()->SetPointer( aPointer );
311 0 : return pEditView->MouseMove( rMEvt );
312 : }
313 :
314 :
315 0 : sal_Bool OutlinerView::MouseButtonDown( const MouseEvent& rMEvt )
316 : {
317 : DBG_CHKTHIS(OutlinerView,0);
318 0 : if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode() )
319 0 : return pEditView->MouseButtonDown( rMEvt );
320 :
321 0 : Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
322 0 : if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
323 0 : return sal_False;
324 :
325 0 : Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
326 0 : pEditView->GetWindow()->SetPointer( aPointer );
327 :
328 : MouseTarget eTarget;
329 0 : sal_uLong nPara = ImpCheckMousePos( rMEvt.GetPosPixel(), eTarget );
330 0 : if ( eTarget == MouseBullet )
331 : {
332 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
333 0 : sal_Bool bHasChildren = (pPara && pOwner->pParaList->HasChildren(pPara));
334 0 : if( rMEvt.GetClicks() == 1 )
335 : {
336 0 : sal_uLong nEndPara = nPara;
337 0 : if ( bHasChildren && pOwner->pParaList->HasVisibleChildren(pPara) )
338 0 : nEndPara += pOwner->pParaList->GetChildCount( pPara );
339 : // The selection is inverted, so that EditEngine does not scroll
340 0 : ESelection aSel((sal_uInt16)nEndPara, 0xffff,(sal_uInt16)nPara, 0 );
341 0 : pEditView->SetSelection( aSel );
342 : }
343 0 : else if( rMEvt.GetClicks() == 2 && bHasChildren )
344 0 : ImpToggleExpand( pPara );
345 :
346 0 : aDDStartPosPix = rMEvt.GetPosPixel();
347 0 : aDDStartPosRef=pEditView->GetWindow()->PixelToLogic( aDDStartPosPix,pOwner->GetRefMapMode());
348 0 : return sal_True;
349 : }
350 :
351 : // special case for outliner view in impress, check if double click hits the page icon for toggle
352 0 : if( (nPara == EE_PARA_NOT_FOUND) && (pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEVIEW) && (eTarget == MouseText) && (rMEvt.GetClicks() == 2) )
353 : {
354 0 : ESelection aSel( pEditView->GetSelection() );
355 0 : nPara = aSel.nStartPara;
356 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
357 0 : if( (pPara && pOwner->pParaList->HasChildren(pPara)) && pPara->HasFlag(PARAFLAG_ISPAGE) )
358 : {
359 0 : ImpToggleExpand( pPara );
360 : }
361 : }
362 0 : return pEditView->MouseButtonDown( rMEvt );
363 : }
364 :
365 :
366 0 : sal_Bool OutlinerView::MouseButtonUp( const MouseEvent& rMEvt )
367 : {
368 : DBG_CHKTHIS(OutlinerView,0);
369 0 : if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode() )
370 0 : return pEditView->MouseButtonUp( rMEvt );
371 :
372 0 : Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
373 0 : if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
374 0 : return sal_False;
375 :
376 0 : Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
377 0 : pEditView->GetWindow()->SetPointer( aPointer );
378 :
379 0 : return pEditView->MouseButtonUp( rMEvt );
380 : }
381 :
382 0 : void OutlinerView::ImpToggleExpand( Paragraph* pPara )
383 : {
384 : DBG_CHKTHIS(OutlinerView,0);
385 :
386 0 : sal_uInt16 nPara = (sal_uInt16) pOwner->pParaList->GetAbsPos( pPara );
387 0 : pEditView->SetSelection( ESelection( nPara, 0, nPara, 0 ) );
388 0 : ImplExpandOrCollaps( nPara, nPara, !pOwner->pParaList->HasVisibleChildren( pPara ) );
389 0 : pEditView->ShowCursor();
390 0 : }
391 :
392 0 : sal_uLong OutlinerView::Select( Paragraph* pParagraph, sal_Bool bSelect,
393 : sal_Bool bWithChildren )
394 : {
395 : DBG_CHKTHIS(OutlinerView,0);
396 :
397 0 : sal_uLong nPara = pOwner->pParaList->GetAbsPos( pParagraph );
398 0 : sal_uInt16 nEnd = 0;
399 0 : if ( bSelect )
400 0 : nEnd = 0xffff;
401 :
402 0 : sal_uLong nChildCount = 0;
403 0 : if ( bWithChildren )
404 0 : nChildCount = pOwner->pParaList->GetChildCount( pParagraph );
405 :
406 0 : ESelection aSel( (sal_uInt16)nPara, 0,(sal_uInt16)(nPara+nChildCount), nEnd );
407 0 : pEditView->SetSelection( aSel );
408 0 : return nChildCount+1;
409 : }
410 :
411 :
412 14 : void OutlinerView::SetAttribs( const SfxItemSet& rAttrs )
413 : {
414 : DBG_CHKTHIS(OutlinerView,0);
415 :
416 14 : sal_Bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
417 14 : pOwner->pEditEngine->SetUpdateMode( sal_False );
418 :
419 14 : if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
420 12 : pOwner->UndoActionStart( OLUNDO_ATTR );
421 :
422 14 : ParaRange aSel = ImpGetSelectedParagraphs( sal_False );
423 :
424 14 : pEditView->SetAttribs( rAttrs );
425 :
426 : // Update Bullet text
427 28 : for( sal_uInt16 nPara= aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
428 : {
429 14 : pOwner->ImplCheckNumBulletItem( nPara );
430 14 : pOwner->ImplCalcBulletText( nPara, sal_False, sal_False );
431 :
432 14 : if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
433 12 : pOwner->InsertUndo( new OutlinerUndoCheckPara( pOwner, nPara ) );
434 : }
435 :
436 14 : if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
437 12 : pOwner->UndoActionEnd( OLUNDO_ATTR );
438 :
439 14 : pEditView->SetEditEngineUpdateMode( bUpdate );
440 14 : }
441 :
442 14 : ParaRange OutlinerView::ImpGetSelectedParagraphs( sal_Bool bIncludeHiddenChildren )
443 : {
444 : DBG_CHKTHIS( OutlinerView, 0 );
445 :
446 14 : ESelection aSel = pEditView->GetSelection();
447 14 : ParaRange aParas( aSel.nStartPara, aSel.nEndPara );
448 14 : aParas.Adjust();
449 :
450 : // Record the invisible Children of the last Parents in the selection
451 14 : if ( bIncludeHiddenChildren )
452 : {
453 0 : Paragraph* pLast = pOwner->pParaList->GetParagraph( aParas.nEndPara );
454 0 : if ( pOwner->pParaList->HasHiddenChildren( pLast ) )
455 : aParas.nEndPara =
456 : sal::static_int_cast< sal_uInt16 >(
457 : aParas.nEndPara +
458 0 : pOwner->pParaList->GetChildCount( pLast ) );
459 : }
460 14 : return aParas;
461 : }
462 :
463 : // TODO: Name should be changed!
464 0 : void OutlinerView::AdjustDepth( short nDX )
465 : {
466 0 : Indent( nDX );
467 0 : }
468 :
469 0 : void OutlinerView::Indent( short nDiff )
470 : {
471 : DBG_CHKTHIS( OutlinerView, 0 );
472 :
473 0 : if( !nDiff || ( ( nDiff > 0 ) && ImpCalcSelectedPages( sal_True ) && !pOwner->ImpCanIndentSelectedPages( this ) ) )
474 0 : return;
475 :
476 0 : const bool bOutlinerView = pOwner->pEditEngine->GetControlWord() & EE_CNTRL_OUTLINER;
477 0 : sal_Bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
478 0 : pOwner->pEditEngine->SetUpdateMode( sal_False );
479 :
480 0 : sal_Bool bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
481 :
482 0 : if( bUndo )
483 0 : pOwner->UndoActionStart( OLUNDO_DEPTH );
484 :
485 0 : sal_Int16 nMinDepth = -1; // Optimization: Not to recalculate to manny parargaphs when not really needed.
486 :
487 0 : ParaRange aSel = ImpGetSelectedParagraphs( sal_True );
488 0 : for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
489 : {
490 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
491 :
492 0 : sal_Int16 nOldDepth = pPara->GetDepth();
493 0 : sal_Int16 nNewDepth = nOldDepth + nDiff;
494 :
495 0 : if( bOutlinerView && nPara )
496 : {
497 0 : const bool bPage = pPara->HasFlag(PARAFLAG_ISPAGE);
498 0 : if( (bPage && (nDiff == +1)) || (!bPage && (nDiff == -1) && (nOldDepth <= 0)) )
499 : {
500 : // Notify App
501 0 : pOwner->nDepthChangedHdlPrevDepth = (sal_Int16)nOldDepth;
502 0 : pOwner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
503 0 : pOwner->pHdlParagraph = pPara;
504 :
505 0 : if( bPage )
506 0 : pPara->RemoveFlag( PARAFLAG_ISPAGE );
507 : else
508 0 : pPara->SetFlag( PARAFLAG_ISPAGE );
509 :
510 0 : pOwner->DepthChangedHdl();
511 0 : pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
512 :
513 0 : if( bUndo )
514 0 : pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nPara, pOwner->mnDepthChangeHdlPrevFlags, pPara->nFlags ) );
515 :
516 0 : continue;
517 : }
518 : }
519 :
520 : // do not switch off numeration with tab
521 0 : if( (nOldDepth == 0) && (nNewDepth == -1) )
522 0 : continue;
523 :
524 : // do not indent if there is no numeration enabled
525 0 : if( nOldDepth == -1 )
526 0 : continue;
527 :
528 0 : if ( nNewDepth < pOwner->nMinDepth )
529 0 : nNewDepth = pOwner->nMinDepth;
530 0 : if ( nNewDepth > pOwner->nMaxDepth )
531 0 : nNewDepth = pOwner->nMaxDepth;
532 :
533 0 : if( nOldDepth < nMinDepth )
534 0 : nMinDepth = nOldDepth;
535 0 : if( nNewDepth < nMinDepth )
536 0 : nMinDepth = nNewDepth;
537 :
538 0 : if( nOldDepth != nNewDepth )
539 : {
540 0 : if ( ( nPara == aSel.nStartPara ) && aSel.nStartPara && ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ))
541 : {
542 : // Special case: the predecessor of an indented paragraph is
543 : // invisible and is now on the same level as the visible
544 : // paragraph. In this case, the next visible paragraph is
545 : // searched for and fluffed.
546 : #ifdef DBG_UTIL
547 : Paragraph* _pPara = pOwner->pParaList->GetParagraph( aSel.nStartPara );
548 : DBG_ASSERT(_pPara->IsVisible(),"Selected Paragraph invisible ?!");
549 : #endif
550 0 : Paragraph* pPrev= pOwner->pParaList->GetParagraph( aSel.nStartPara-1 );
551 :
552 0 : if( !pPrev->IsVisible() && ( pPrev->GetDepth() == nNewDepth ) )
553 : {
554 : // Predecessor is collapsed and is on the same level
555 : // => find next visible paragraph and expand it
556 0 : pPrev = pOwner->pParaList->GetParent( pPrev );
557 0 : while( !pPrev->IsVisible() )
558 0 : pPrev = pOwner->pParaList->GetParent( pPrev );
559 :
560 0 : pOwner->Expand( pPrev );
561 0 : pOwner->InvalidateBullet( pPrev, pOwner->pParaList->GetAbsPos( pPrev ) );
562 : }
563 : }
564 :
565 0 : pOwner->nDepthChangedHdlPrevDepth = (sal_Int16)nOldDepth;
566 0 : pOwner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
567 0 : pOwner->pHdlParagraph = pPara;
568 :
569 0 : pOwner->ImplInitDepth( nPara, nNewDepth, sal_True, sal_False );
570 0 : pOwner->ImplCalcBulletText( nPara, sal_False, sal_False );
571 :
572 0 : if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
573 0 : pOwner->ImplSetLevelDependendStyleSheet( nPara );
574 :
575 : // Notify App
576 0 : pOwner->DepthChangedHdl();
577 : }
578 : else
579 : {
580 : // Needs at least a repaint...
581 0 : pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
582 : }
583 : }
584 :
585 0 : sal_uInt16 nParas = (sal_uInt16)pOwner->pParaList->GetParagraphCount();
586 0 : for ( sal_uInt16 n = aSel.nEndPara+1; n < nParas; n++ )
587 : {
588 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( n );
589 0 : if ( pPara->GetDepth() < nMinDepth )
590 0 : break;
591 0 : pOwner->ImplCalcBulletText( n, sal_False, sal_False );
592 : }
593 :
594 0 : if ( bUpdate )
595 : {
596 0 : pEditView->SetEditEngineUpdateMode( sal_True );
597 0 : pEditView->ShowCursor();
598 : }
599 :
600 0 : if( bUndo )
601 0 : pOwner->UndoActionEnd( OLUNDO_DEPTH );
602 : }
603 :
604 0 : sal_Bool OutlinerView::AdjustHeight( long nDY )
605 : {
606 : DBG_CHKTHIS(OutlinerView,0);
607 0 : pEditView->MoveParagraphs( nDY );
608 0 : return sal_True; // remove return value...
609 : }
610 :
611 6 : Rectangle OutlinerView::GetVisArea() const
612 : {
613 : DBG_CHKTHIS(OutlinerView,0);
614 6 : return pEditView->GetVisArea();
615 : }
616 :
617 0 : void OutlinerView::Expand()
618 : {
619 : DBG_CHKTHIS( OutlinerView, 0 );
620 0 : ParaRange aParas = ImpGetSelectedParagraphs( sal_False );
621 0 : ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, sal_True );
622 0 : }
623 :
624 :
625 0 : void OutlinerView::Collapse()
626 : {
627 : DBG_CHKTHIS( OutlinerView, 0 );
628 0 : ParaRange aParas = ImpGetSelectedParagraphs( sal_False );
629 0 : ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, sal_False );
630 0 : }
631 :
632 :
633 0 : void OutlinerView::ExpandAll()
634 : {
635 : DBG_CHKTHIS( OutlinerView, 0 );
636 0 : ImplExpandOrCollaps( 0, (sal_uInt16)(pOwner->pParaList->GetParagraphCount()-1), sal_True );
637 0 : }
638 :
639 :
640 0 : void OutlinerView::CollapseAll()
641 : {
642 : DBG_CHKTHIS(OutlinerView,0);
643 0 : ImplExpandOrCollaps( 0, (sal_uInt16)(pOwner->pParaList->GetParagraphCount()-1), sal_False );
644 0 : }
645 :
646 0 : void OutlinerView::ImplExpandOrCollaps( sal_uInt16 nStartPara, sal_uInt16 nEndPara, sal_Bool bExpand )
647 : {
648 : DBG_CHKTHIS( OutlinerView, 0 );
649 :
650 0 : sal_Bool bUpdate = pOwner->GetUpdateMode();
651 0 : pOwner->SetUpdateMode( sal_False );
652 :
653 0 : sal_Bool bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
654 0 : if( bUndo )
655 0 : pOwner->UndoActionStart( bExpand ? OLUNDO_EXPAND : OLUNDO_COLLAPSE );
656 :
657 0 : for ( sal_uInt16 nPara = nStartPara; nPara <= nEndPara; nPara++ )
658 : {
659 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
660 0 : sal_Bool bDone = bExpand ? pOwner->Expand( pPara ) : pOwner->Collapse( pPara );
661 0 : if( bDone )
662 : {
663 : // The line under the paragraph should disappear ...
664 0 : pOwner->pEditEngine->QuickMarkToBeRepainted( nPara );
665 : }
666 : }
667 :
668 0 : if( bUndo )
669 0 : pOwner->UndoActionEnd( bExpand ? OLUNDO_EXPAND : OLUNDO_COLLAPSE );
670 :
671 0 : if ( bUpdate )
672 : {
673 0 : pOwner->SetUpdateMode( sal_True );
674 0 : pEditView->ShowCursor();
675 : }
676 0 : }
677 :
678 0 : void OutlinerView::InsertText( const OutlinerParaObject& rParaObj )
679 : {
680 : // Like Paste, only EditView::Insert, instead of EditView::Paste.
681 : // Actually not quite true that possible indentations must be corrected,
682 : // but that comes later by a universal import. The indentation level is
683 : // then determined right in the Inserted method.
684 : // Possible structure:
685 : // pImportInfo with DestPara, DestPos, nFormat, pParaObj...
686 : // Possibly problematic:
687 : // EditEngine, RTF => Splitting the area, later join together.
688 :
689 : DBG_CHKTHIS(OutlinerView,0);
690 :
691 0 : if ( ImpCalcSelectedPages( sal_False ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
692 0 : return;
693 :
694 0 : pOwner->UndoActionStart( OLUNDO_INSERT );
695 :
696 0 : pOwner->pEditEngine->SetUpdateMode( sal_False );
697 : sal_uLong nStart, nParaCount;
698 0 : nParaCount = pOwner->pEditEngine->GetParagraphCount();
699 0 : sal_uInt16 nSize = ImpInitPaste( nStart );
700 0 : pEditView->InsertText( rParaObj.GetTextObject() );
701 0 : ImpPasted( nStart, nParaCount, nSize);
702 0 : pEditView->SetEditEngineUpdateMode( sal_True );
703 :
704 0 : pOwner->UndoActionEnd( OLUNDO_INSERT );
705 :
706 0 : pEditView->ShowCursor( sal_True, sal_True );
707 : }
708 :
709 :
710 :
711 0 : void OutlinerView::Cut()
712 : {
713 : DBG_CHKTHIS(OutlinerView,0);
714 0 : if ( !ImpCalcSelectedPages( sal_False ) || pOwner->ImpCanDeleteSelectedPages( this ) )
715 0 : pEditView->Cut();
716 0 : }
717 :
718 0 : void OutlinerView::Paste()
719 : {
720 : DBG_CHKTHIS(OutlinerView,0);
721 0 : PasteSpecial(); // HACK(SD does not call PasteSpecial)
722 0 : }
723 :
724 0 : void OutlinerView::PasteSpecial()
725 : {
726 : DBG_CHKTHIS(OutlinerView,0);
727 0 : if ( !ImpCalcSelectedPages( sal_False ) || pOwner->ImpCanDeleteSelectedPages( this ) )
728 : {
729 0 : pOwner->UndoActionStart( OLUNDO_INSERT );
730 :
731 0 : pOwner->pEditEngine->SetUpdateMode( sal_False );
732 0 : pOwner->bPasting = sal_True;
733 0 : pEditView->PasteSpecial();
734 :
735 0 : if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
736 : {
737 0 : const sal_uInt16 nParaCount = pOwner->pEditEngine->GetParagraphCount();
738 :
739 0 : for( sal_uInt16 nPara = 0; nPara < nParaCount; nPara++ )
740 0 : pOwner->ImplSetLevelDependendStyleSheet( nPara );
741 : }
742 :
743 0 : pEditView->SetEditEngineUpdateMode( sal_True );
744 0 : pOwner->UndoActionEnd( OLUNDO_INSERT );
745 0 : pEditView->ShowCursor( sal_True, sal_True );
746 : }
747 0 : }
748 :
749 0 : void OutlinerView::CreateSelectionList (std::vector<Paragraph*> &aSelList)
750 : {
751 : DBG_CHKTHIS( OutlinerView, 0 );
752 :
753 0 : ParaRange aParas = ImpGetSelectedParagraphs( sal_True );
754 :
755 0 : for ( sal_uInt16 nPara = aParas.nStartPara; nPara <= aParas.nEndPara; nPara++ )
756 : {
757 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
758 0 : aSelList.push_back(pPara);
759 : }
760 0 : }
761 :
762 0 : const SfxStyleSheet* OutlinerView::GetStyleSheet() const
763 : {
764 : DBG_CHKTHIS(OutlinerView,0);
765 0 : return pEditView->GetStyleSheet();
766 : }
767 :
768 0 : SfxStyleSheet* OutlinerView::GetStyleSheet()
769 : {
770 : DBG_CHKTHIS(OutlinerView,0);
771 0 : return pEditView->GetStyleSheet();
772 : }
773 :
774 0 : Pointer OutlinerView::GetPointer( const Point& rPosPixel )
775 : {
776 : DBG_CHKTHIS(OutlinerView,0);
777 :
778 : MouseTarget eTarget;
779 0 : ImpCheckMousePos( rPosPixel, eTarget );
780 :
781 0 : PointerStyle ePointerStyle = POINTER_ARROW;
782 0 : if ( eTarget == MouseText )
783 : {
784 0 : ePointerStyle = GetOutliner()->IsVertical() ? POINTER_TEXT_VERTICAL : POINTER_TEXT;
785 : }
786 0 : else if ( eTarget == MouseHypertext )
787 : {
788 0 : ePointerStyle = POINTER_REFHAND;
789 : }
790 0 : else if ( eTarget == MouseBullet )
791 : {
792 0 : ePointerStyle = POINTER_MOVE;
793 : }
794 :
795 0 : return Pointer( ePointerStyle );
796 : }
797 :
798 :
799 0 : sal_uInt16 OutlinerView::ImpInitPaste( sal_uLong& rStart )
800 : {
801 : DBG_CHKTHIS(OutlinerView,0);
802 0 : pOwner->bPasting = sal_True;
803 0 : ESelection aSelection( pEditView->GetSelection() );
804 0 : aSelection.Adjust();
805 0 : rStart = aSelection.nStartPara;
806 0 : sal_uInt16 nSize = aSelection.nEndPara - aSelection.nStartPara + 1;
807 0 : return nSize;
808 : }
809 :
810 :
811 0 : void OutlinerView::ImpPasted( sal_uLong nStart, sal_uLong nPrevParaCount, sal_uInt16 nSize)
812 : {
813 : DBG_CHKTHIS(OutlinerView,0);
814 0 : pOwner->bPasting = sal_False;
815 0 : sal_uLong nCurParaCount = (sal_uLong)pOwner->pEditEngine->GetParagraphCount();
816 0 : if( nCurParaCount < nPrevParaCount )
817 : nSize = sal::static_int_cast< sal_uInt16 >(
818 0 : nSize - ( nPrevParaCount - nCurParaCount ) );
819 : else
820 : nSize = sal::static_int_cast< sal_uInt16 >(
821 0 : nSize + ( nCurParaCount - nPrevParaCount ) );
822 0 : pOwner->ImpTextPasted( nStart, nSize );
823 0 : }
824 :
825 :
826 0 : void OutlinerView::Command( const CommandEvent& rCEvt )
827 : {
828 : DBG_CHKTHIS(OutlinerView,0);
829 0 : pEditView->Command( rCEvt );
830 0 : }
831 :
832 :
833 0 : void OutlinerView::SelectRange( sal_uLong nFirst, sal_uInt16 nCount )
834 : {
835 : DBG_CHKTHIS(OutlinerView,0);
836 0 : sal_uLong nLast = nFirst+nCount;
837 0 : nCount = (sal_uInt16)pOwner->pParaList->GetParagraphCount();
838 0 : if( nLast <= nCount )
839 0 : nLast = nCount - 1;
840 0 : ESelection aSel( (sal_uInt16)nFirst, 0, (sal_uInt16)nLast, 0xffff );
841 0 : pEditView->SetSelection( aSel );
842 0 : }
843 :
844 :
845 0 : sal_uInt16 OutlinerView::ImpCalcSelectedPages( sal_Bool bIncludeFirstSelected )
846 : {
847 : DBG_CHKTHIS(OutlinerView,0);
848 :
849 0 : ESelection aSel( pEditView->GetSelection() );
850 0 : aSel.Adjust();
851 :
852 0 : sal_uInt16 nPages = 0;
853 0 : sal_uInt16 nFirstPage = 0xFFFF;
854 0 : sal_uInt16 nStartPara = aSel.nStartPara;
855 0 : if ( !bIncludeFirstSelected )
856 0 : nStartPara++; // All paragraphs after StartPara will be deleted
857 0 : for ( sal_uInt16 nPara = nStartPara; nPara <= aSel.nEndPara; nPara++ )
858 : {
859 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
860 : DBG_ASSERT(pPara, "ImpCalcSelectedPages: invalid Selection? ");
861 0 : if( pPara->HasFlag(PARAFLAG_ISPAGE) )
862 : {
863 0 : nPages++;
864 0 : if( nFirstPage == 0xFFFF )
865 0 : nFirstPage = nPara;
866 : }
867 : }
868 :
869 0 : if( nPages )
870 : {
871 0 : pOwner->nDepthChangedHdlPrevDepth = nPages;
872 0 : pOwner->pHdlParagraph = 0;
873 0 : pOwner->mnFirstSelPage = nFirstPage;
874 : }
875 :
876 0 : return nPages;
877 : }
878 :
879 :
880 0 : void OutlinerView::ToggleBullets()
881 : {
882 0 : pOwner->UndoActionStart( OLUNDO_DEPTH );
883 :
884 0 : ESelection aSel( pEditView->GetSelection() );
885 0 : aSel.Adjust();
886 :
887 0 : const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
888 0 : pOwner->pEditEngine->SetUpdateMode( sal_False );
889 :
890 0 : sal_Int16 nDepth = -2;
891 :
892 0 : for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
893 : {
894 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
895 : DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?");
896 :
897 0 : if( pPara )
898 : {
899 0 : if( nDepth == -2 )
900 0 : nDepth = (pOwner->GetDepth(nPara) == -1) ? 0 : -1;
901 :
902 0 : pOwner->SetDepth( pPara, nDepth );
903 :
904 0 : if( nDepth == -1 )
905 : {
906 0 : const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara );
907 0 : if(rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SFX_ITEM_SET)
908 : {
909 0 : SfxItemSet aAttrs(rAttrs);
910 0 : aAttrs.ClearItem( EE_PARA_BULLETSTATE );
911 0 : pOwner->SetParaAttribs( nPara, aAttrs );
912 0 : }
913 : }
914 : }
915 : }
916 :
917 : // #i100014#
918 : // It is not a good idea to substract 1 from a count and cast the result
919 : // to sal_uInt16 without check, if the count is 0.
920 0 : sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount());
921 0 : pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount );
922 0 : pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) );
923 :
924 0 : pOwner->pEditEngine->SetUpdateMode( bUpdate );
925 :
926 0 : pOwner->UndoActionEnd( OLUNDO_DEPTH );
927 0 : }
928 :
929 0 : void OutlinerView::EnableBullets()
930 : {
931 0 : pOwner->UndoActionStart( OLUNDO_DEPTH );
932 :
933 0 : ESelection aSel( pEditView->GetSelection() );
934 0 : aSel.Adjust();
935 :
936 0 : const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
937 0 : pOwner->pEditEngine->SetUpdateMode( sal_False );
938 :
939 0 : for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
940 : {
941 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
942 : DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?");
943 :
944 0 : if( pPara && (pOwner->GetDepth(nPara) == -1) )
945 : {
946 0 : pOwner->SetDepth( pPara, 0 );
947 : }
948 : }
949 :
950 : // #i100014#
951 : // It is not a good idea to substract 1 from a count and cast the result
952 : // to sal_uInt16 without check, if the count is 0.
953 0 : sal_uInt16 nParaCount = (sal_uInt16) (pOwner->pParaList->GetParagraphCount());
954 :
955 0 : pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount );
956 0 : pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) );
957 :
958 0 : pOwner->pEditEngine->SetUpdateMode( bUpdate );
959 :
960 0 : pOwner->UndoActionEnd( OLUNDO_DEPTH );
961 0 : }
962 :
963 :
964 0 : void OutlinerView::RemoveAttribsKeepLanguages( sal_Bool bRemoveParaAttribs )
965 : {
966 0 : RemoveAttribs( bRemoveParaAttribs, 0, sal_True /*keep language attribs*/ );
967 0 : }
968 :
969 0 : void OutlinerView::RemoveAttribs( sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich, sal_Bool bKeepLanguages )
970 : {
971 : DBG_CHKTHIS(OutlinerView,0);
972 0 : sal_Bool bUpdate = pOwner->GetUpdateMode();
973 0 : pOwner->SetUpdateMode( sal_False );
974 0 : pOwner->UndoActionStart( OLUNDO_ATTR );
975 0 : if (bKeepLanguages)
976 0 : pEditView->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
977 : else
978 0 : pEditView->RemoveAttribs( bRemoveParaAttribs, nWhich );
979 0 : if ( bRemoveParaAttribs )
980 : {
981 : // Loop through all paragraphs and set indentation and level
982 0 : ESelection aSel = pEditView->GetSelection();
983 0 : aSel.Adjust();
984 0 : for ( sal_uInt16 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
985 : {
986 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
987 0 : pOwner->ImplInitDepth( nPara, pPara->GetDepth(), sal_False, sal_False );
988 : }
989 : }
990 0 : pOwner->UndoActionEnd( OLUNDO_ATTR );
991 0 : pOwner->SetUpdateMode( bUpdate );
992 0 : }
993 :
994 :
995 :
996 : // ======================================================================
997 : // ====================== Simple pass-through =======================
998 : // ======================================================================
999 :
1000 :
1001 2 : void OutlinerView::InsertText( const XubString& rNew, sal_Bool bSelect )
1002 : {
1003 : DBG_CHKTHIS(OutlinerView,0);
1004 2 : if( pOwner->bFirstParaIsEmpty )
1005 2 : pOwner->Insert( String() );
1006 2 : pEditView->InsertText( rNew, bSelect );
1007 2 : }
1008 :
1009 6 : void OutlinerView::SetVisArea( const Rectangle& rRec )
1010 : {
1011 : DBG_CHKTHIS(OutlinerView,0);
1012 6 : pEditView->SetVisArea( rRec );
1013 6 : }
1014 :
1015 :
1016 12 : void OutlinerView::SetSelection( const ESelection& rSel )
1017 : {
1018 : DBG_CHKTHIS(OutlinerView,0);
1019 12 : pEditView->SetSelection( rSel );
1020 12 : }
1021 :
1022 6 : void OutlinerView::SetReadOnly( sal_Bool bReadOnly )
1023 : {
1024 : DBG_CHKTHIS(OutlinerView,0);
1025 6 : pEditView->SetReadOnly( bReadOnly );
1026 6 : }
1027 :
1028 0 : sal_Bool OutlinerView::IsReadOnly() const
1029 : {
1030 : DBG_CHKTHIS(OutlinerView,0);
1031 0 : return pEditView->IsReadOnly();
1032 : }
1033 :
1034 0 : sal_Bool OutlinerView::HasSelection() const
1035 : {
1036 : DBG_CHKTHIS(OutlinerView,0);
1037 0 : return pEditView->HasSelection();
1038 : }
1039 :
1040 :
1041 6 : void OutlinerView::ShowCursor( sal_Bool bGotoCursor )
1042 : {
1043 : DBG_CHKTHIS(OutlinerView,0);
1044 6 : pEditView->ShowCursor( bGotoCursor );
1045 6 : }
1046 :
1047 :
1048 0 : void OutlinerView::HideCursor()
1049 : {
1050 : DBG_CHKTHIS(OutlinerView,0);
1051 0 : pEditView->HideCursor();
1052 0 : }
1053 :
1054 :
1055 3 : void OutlinerView::SetWindow( Window* pWin )
1056 : {
1057 : DBG_CHKTHIS(OutlinerView,0);
1058 3 : pEditView->SetWindow( pWin );
1059 3 : }
1060 :
1061 :
1062 0 : Window* OutlinerView::GetWindow() const
1063 : {
1064 : DBG_CHKTHIS(OutlinerView,0);
1065 0 : return pEditView->GetWindow();
1066 : }
1067 :
1068 :
1069 12 : void OutlinerView::SetOutputArea( const Rectangle& rRect )
1070 : {
1071 : DBG_CHKTHIS(OutlinerView,0);
1072 12 : pEditView->SetOutputArea( rRect );
1073 12 : }
1074 :
1075 :
1076 0 : Rectangle OutlinerView::GetOutputArea() const
1077 : {
1078 : DBG_CHKTHIS(OutlinerView,0);
1079 0 : return pEditView->GetOutputArea();
1080 : }
1081 :
1082 :
1083 0 : XubString OutlinerView::GetSelected() const
1084 : {
1085 : DBG_CHKTHIS(OutlinerView,0);
1086 0 : return pEditView->GetSelected();
1087 : }
1088 :
1089 6 : EESpellState OutlinerView::StartSpeller( sal_Bool bMultiDoc )
1090 : {
1091 : DBG_CHKTHIS(OutlinerView,0);
1092 6 : return pEditView->StartSpeller( bMultiDoc );
1093 : }
1094 :
1095 0 : EESpellState OutlinerView::StartThesaurus()
1096 : {
1097 : DBG_CHKTHIS(OutlinerView,0);
1098 0 : return pEditView->StartThesaurus();
1099 : }
1100 :
1101 :
1102 0 : void OutlinerView::StartTextConversion(
1103 : LanguageType nSrcLang, LanguageType nDestLang, const Font *pDestFont,
1104 : sal_Int32 nOptions, sal_Bool bIsInteractive, sal_Bool bMultipleDoc )
1105 : {
1106 : DBG_CHKTHIS(OutlinerView,0);
1107 0 : if (
1108 : (LANGUAGE_KOREAN == nSrcLang && LANGUAGE_KOREAN == nDestLang) ||
1109 : (LANGUAGE_CHINESE_SIMPLIFIED == nSrcLang && LANGUAGE_CHINESE_TRADITIONAL == nDestLang) ||
1110 : (LANGUAGE_CHINESE_TRADITIONAL == nSrcLang && LANGUAGE_CHINESE_SIMPLIFIED == nDestLang)
1111 : )
1112 : {
1113 0 : pEditView->StartTextConversion( nSrcLang, nDestLang, pDestFont, nOptions, bIsInteractive, bMultipleDoc );
1114 : }
1115 : else
1116 : {
1117 : OSL_FAIL( "unexpected language" );
1118 : }
1119 0 : }
1120 :
1121 :
1122 0 : sal_uInt16 OutlinerView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
1123 : {
1124 : DBG_CHKTHIS(OutlinerView,0);
1125 0 : return pEditView->StartSearchAndReplace( rSearchItem );
1126 : }
1127 :
1128 0 : void OutlinerView::TransliterateText( sal_Int32 nTransliterationMode )
1129 : {
1130 : DBG_CHKTHIS(OutlinerView,0);
1131 0 : pEditView->TransliterateText( nTransliterationMode );
1132 0 : }
1133 :
1134 :
1135 :
1136 6 : ESelection OutlinerView::GetSelection()
1137 : {
1138 : DBG_CHKTHIS(OutlinerView,0);
1139 6 : return pEditView->GetSelection();
1140 : }
1141 :
1142 :
1143 0 : void OutlinerView::Scroll( long nHorzScroll, long nVertScroll )
1144 : {
1145 : DBG_CHKTHIS(OutlinerView,0);
1146 0 : pEditView->Scroll( nHorzScroll, nVertScroll );
1147 0 : }
1148 :
1149 :
1150 0 : void OutlinerView::SetControlWord( sal_uLong nWord )
1151 : {
1152 : DBG_CHKTHIS(OutlinerView,0);
1153 0 : pEditView->SetControlWord( nWord );
1154 0 : }
1155 :
1156 :
1157 0 : sal_uLong OutlinerView::GetControlWord() const
1158 : {
1159 : DBG_CHKTHIS(OutlinerView,0);
1160 0 : return pEditView->GetControlWord();
1161 : }
1162 :
1163 :
1164 0 : void OutlinerView::SetAnchorMode( EVAnchorMode eMode )
1165 : {
1166 : DBG_CHKTHIS(OutlinerView,0);
1167 0 : pEditView->SetAnchorMode( eMode );
1168 0 : }
1169 :
1170 :
1171 0 : EVAnchorMode OutlinerView::GetAnchorMode() const
1172 : {
1173 : DBG_CHKTHIS(OutlinerView,0);
1174 0 : return pEditView->GetAnchorMode();
1175 : }
1176 :
1177 0 : void OutlinerView::Copy()
1178 : {
1179 : DBG_CHKTHIS(OutlinerView,0);
1180 0 : pEditView->Copy();
1181 0 : }
1182 :
1183 :
1184 0 : void OutlinerView::InsertField( const SvxFieldItem& rFld )
1185 : {
1186 : DBG_CHKTHIS(OutlinerView,0);
1187 0 : pEditView->InsertField( rFld );
1188 0 : }
1189 :
1190 0 : const SvxFieldItem* OutlinerView::GetFieldUnderMousePointer() const
1191 : {
1192 : DBG_CHKTHIS(OutlinerView,0);
1193 0 : return pEditView->GetFieldUnderMousePointer();
1194 : }
1195 :
1196 0 : const SvxFieldItem* OutlinerView::GetFieldAtSelection() const
1197 : {
1198 : DBG_CHKTHIS(OutlinerView,0);
1199 0 : return pEditView->GetFieldAtSelection();
1200 : }
1201 :
1202 0 : void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel )
1203 : {
1204 : DBG_CHKTHIS(OutlinerView,0);
1205 0 : pEditView->SetInvalidateMore( nPixel );
1206 0 : }
1207 :
1208 :
1209 0 : sal_uInt16 OutlinerView::GetInvalidateMore() const
1210 : {
1211 : DBG_CHKTHIS(OutlinerView,0);
1212 0 : return pEditView->GetInvalidateMore();
1213 : }
1214 :
1215 :
1216 0 : sal_Bool OutlinerView::IsCursorAtWrongSpelledWord( sal_Bool bMarkIfWrong )
1217 : {
1218 : DBG_CHKTHIS(OutlinerView,0);
1219 0 : return pEditView->IsCursorAtWrongSpelledWord( bMarkIfWrong );
1220 : }
1221 :
1222 :
1223 0 : sal_Bool OutlinerView::IsWrongSpelledWordAtPos( const Point& rPosPixel, sal_Bool bMarkIfWrong )
1224 : {
1225 : DBG_CHKTHIS(OutlinerView,0);
1226 0 : return pEditView->IsWrongSpelledWordAtPos( rPosPixel, bMarkIfWrong );
1227 : }
1228 :
1229 0 : void OutlinerView::ExecuteSpellPopup( const Point& rPosPixel, Link* pStartDlg )
1230 : {
1231 : DBG_CHKTHIS(OutlinerView,0);
1232 0 : pEditView->ExecuteSpellPopup( rPosPixel, pStartDlg );
1233 0 : }
1234 :
1235 0 : sal_uLong OutlinerView::Read( SvStream& rInput, const String& rBaseURL, EETextFormat eFormat, sal_Bool bSelect, SvKeyValueIterator* pHTTPHeaderAttrs )
1236 : {
1237 : DBG_CHKTHIS(OutlinerView,0);
1238 0 : sal_uInt16 nOldParaCount = pEditView->GetEditEngine()->GetParagraphCount();
1239 0 : ESelection aOldSel = pEditView->GetSelection();
1240 0 : aOldSel.Adjust();
1241 :
1242 0 : sal_uLong nRet = pEditView->Read( rInput, rBaseURL, eFormat, bSelect, pHTTPHeaderAttrs );
1243 :
1244 0 : long nParaDiff = pEditView->GetEditEngine()->GetParagraphCount() - nOldParaCount;
1245 0 : sal_uInt16 nChangesStart = aOldSel.nStartPara;
1246 0 : sal_uInt16 nChangesEnd = sal::static_int_cast< sal_uInt16 >(nChangesStart + nParaDiff + (aOldSel.nEndPara-aOldSel.nStartPara));
1247 :
1248 0 : for ( sal_uInt16 n = nChangesStart; n <= nChangesEnd; n++ )
1249 : {
1250 0 : if ( eFormat == EE_FORMAT_BIN )
1251 : {
1252 0 : const SfxItemSet& rAttrs = pOwner->GetParaAttribs( n );
1253 0 : const SfxInt16Item& rLevel = (const SfxInt16Item&) rAttrs.Get( EE_PARA_OUTLLEVEL );
1254 0 : sal_uInt16 nDepth = rLevel.GetValue();
1255 0 : pOwner->ImplInitDepth( n, nDepth, sal_False );
1256 : }
1257 :
1258 0 : if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
1259 0 : pOwner->ImplSetLevelDependendStyleSheet( n );
1260 : }
1261 :
1262 0 : if ( eFormat != EE_FORMAT_BIN )
1263 : {
1264 0 : pOwner->ImpFilterIndents( nChangesStart, nChangesEnd );
1265 : }
1266 :
1267 0 : return nRet;
1268 : }
1269 :
1270 6 : void OutlinerView::SetBackgroundColor( const Color& rColor )
1271 : {
1272 : DBG_CHKTHIS(OutlinerView,0);
1273 6 : pEditView->SetBackgroundColor( rColor );
1274 6 : }
1275 :
1276 :
1277 0 : Color OutlinerView::GetBackgroundColor()
1278 : {
1279 : DBG_CHKTHIS(OutlinerView,0);
1280 0 : return pEditView->GetBackgroundColor();
1281 : }
1282 :
1283 6 : SfxItemSet OutlinerView::GetAttribs()
1284 : {
1285 : DBG_CHKTHIS(OutlinerView,0);
1286 6 : return pEditView->GetAttribs();
1287 : }
1288 :
1289 0 : sal_uInt16 OutlinerView::GetSelectedScriptType() const
1290 : {
1291 : DBG_CHKTHIS(OutlinerView,0);
1292 0 : return pEditView->GetSelectedScriptType();
1293 : }
1294 :
1295 0 : String OutlinerView::GetSurroundingText() const
1296 : {
1297 : DBG_CHKTHIS(OutlinerView,0);
1298 0 : return pEditView->GetSurroundingText();
1299 : }
1300 :
1301 0 : Selection OutlinerView::GetSurroundingTextSelection() const
1302 : {
1303 : DBG_CHKTHIS(OutlinerView,0);
1304 0 : return pEditView->GetSurroundingTextSelection();
1305 : }
1306 :
1307 :
1308 : // ======================================================================
1309 : // ===== some code for thesaurus sub menu within context menu
1310 : // ======================================================================
1311 :
1312 : // returns: true if a word for thesaurus look-up was found at the current cursor position.
1313 : // The status string will be word + iso language string (e.g. "light#en-US")
1314 0 : bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext(
1315 : String &rStatusVal,
1316 : LanguageType &rLang,
1317 : const EditView &rEditView )
1318 : {
1319 : // get text and locale for thesaurus look up
1320 0 : String aText;
1321 0 : EditEngine *pEditEngine = rEditView.GetEditEngine();
1322 0 : ESelection aTextSel( rEditView.GetSelection() );
1323 0 : if (!aTextSel.HasRange())
1324 0 : aTextSel = pEditEngine->GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD );
1325 0 : aText = pEditEngine->GetText( aTextSel );
1326 0 : aTextSel.Adjust();
1327 0 : LanguageType nLang = pEditEngine->GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos );
1328 0 : String aLangText( LanguageTag( nLang ).getBcp47() );
1329 :
1330 : // set word and locale to look up as status value
1331 0 : String aStatusVal( aText );
1332 0 : aStatusVal.AppendAscii( "#" );
1333 0 : aStatusVal += aLangText;
1334 :
1335 0 : rStatusVal = aStatusVal;
1336 0 : rLang = nLang;
1337 :
1338 0 : return aText.Len() > 0;
1339 : }
1340 :
1341 :
1342 0 : void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const String &rSynonmText )
1343 : {
1344 : // get selection to use
1345 0 : ESelection aCurSel( rEditView.GetSelection() );
1346 0 : if (!rEditView.HasSelection())
1347 : {
1348 : // select the same word that was used in GetStatusValueForThesaurusFromContext by calling GetWord.
1349 : // (In the end both functions will call ImpEditEngine::SelectWord)
1350 0 : rEditView.SelectCurrentWord( i18n::WordType::DICTIONARY_WORD );
1351 0 : aCurSel = rEditView.GetSelection();
1352 : }
1353 :
1354 : // replace word ...
1355 0 : rEditView.InsertText( rSynonmText );
1356 0 : rEditView.ShowCursor( sal_True, sal_False );
1357 0 : }
1358 :
1359 :
1360 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|