update dev300-m58
[ooovba.git] / svx / source / outliner / outlvw.cxx
blob323fcc47fcc1fd4af8c6b0a7c75634c41bacc4ef
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outlvw.cxx,v $
10 * $Revision: 1.34.150.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <outl_pch.hxx>
34 #include <svtools/style.hxx>
36 #define _OUTLINER_CXX
37 #include <svx/outliner.hxx>
38 #include <outleeng.hxx>
39 #include <paralist.hxx>
40 #include <outlundo.hxx>
41 #include <svx/outlobj.hxx>
42 #include <svx/flditem.hxx>
43 #include <svx/flditem.hxx>
44 #include <svx/eeitem.hxx>
45 #include <svx/numitem.hxx>
46 #include <vcl/window.hxx>
47 #include <svtools/itemset.hxx>
48 #include <editstat.hxx>
51 // Breite der Randzonen innerhalb derer beim D&D gescrollt wird
52 #define OL_SCROLL_LRBORDERWIDTHPIX 10
53 #define OL_SCROLL_TBBORDERWIDTHPIX 10
55 // Wert, um den Fensterinhalt beim D&D gescrollt wird
56 #define OL_SCROLL_HOROFFSET 20 /* in % von VisibleSize.Width */
57 #define OL_SCROLL_VEROFFSET 20 /* in % von VisibleSize.Height */
59 DBG_NAME(OutlinerView)
62 OutlinerView::OutlinerView( Outliner* pOut, Window* pWin )
64 DBG_CTOR( OutlinerView, 0 );
66 pOwner = pOut;
67 bDDCursorVisible = FALSE;
68 bInDragMode = FALSE;
69 nDDScrollLRBorderWidthWin = 0;
70 nDDScrollTBBorderWidthWin = 0;
71 pHorTabArrDoc = 0;
73 pEditView = new EditView( pOut->pEditEngine, pWin );
74 pEditView->SetSelectionMode( EE_SELMODE_TXTONLY );
77 OutlinerView::~OutlinerView()
79 DBG_DTOR(OutlinerView,0);
80 delete pEditView;
83 void OutlinerView::Paint( const Rectangle& rRect )
85 DBG_CHKTHIS(OutlinerView,0);
87 // beim ersten Paint/KeyInput/Drop wird aus einem leeren Outliner ein
88 // Outliner mit genau einem Absatz
89 if( pOwner->bFirstParaIsEmpty )
90 pOwner->Insert( String() );
92 pEditView->Paint( rRect );
95 BOOL OutlinerView::PostKeyEvent( const KeyEvent& rKEvt, Window* pFrameWin )
97 DBG_CHKTHIS( OutlinerView, 0 );
99 // beim ersten Paint/KeyInput/Drop wird aus einem leeren Outliner ein
100 // Outliner mit genau einem Absatz
101 if( pOwner->bFirstParaIsEmpty )
102 pOwner->Insert( String() );
105 BOOL bKeyProcessed = FALSE;
106 ESelection aSel( pEditView->GetSelection() );
107 BOOL bSelection = aSel.HasRange();
108 KeyCode aKeyCode = rKEvt.GetKeyCode();
109 KeyFuncType eFunc = aKeyCode.GetFunction();
110 USHORT nCode = aKeyCode.GetCode();
111 BOOL bReadOnly = IsReadOnly();
113 if( bSelection && ( nCode != KEY_TAB ) && EditEngine::DoesKeyChangeText( rKEvt ) )
115 if ( ImpCalcSelectedPages( FALSE ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
116 return TRUE;
119 if ( eFunc != KEYFUNC_DONTKNOW )
121 switch ( eFunc )
123 case KEYFUNC_CUT:
125 if ( !bReadOnly )
127 Cut();
128 bKeyProcessed = TRUE;
131 break;
132 case KEYFUNC_COPY:
134 Copy();
135 bKeyProcessed = TRUE;
137 break;
138 case KEYFUNC_PASTE:
140 if ( !bReadOnly )
142 PasteSpecial();
143 bKeyProcessed = TRUE;
146 break;
147 case KEYFUNC_DELETE:
149 if( !bReadOnly && !bSelection && ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) )
151 if( aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
153 Paragraph* pNext = pOwner->pParaList->GetParagraph( aSel.nEndPara+1 );
154 if( pNext && pNext->HasFlag(PARAFLAG_ISPAGE) )
156 if( !pOwner->ImpCanDeleteSelectedPages( this, aSel.nEndPara, 1 ) )
157 return FALSE;
162 break;
163 default: // wird dann evtl. unten bearbeitet.
164 eFunc = KEYFUNC_DONTKNOW;
167 if ( eFunc == KEYFUNC_DONTKNOW )
169 switch ( nCode )
171 case KEY_TAB:
173 if ( !bReadOnly && !aKeyCode.IsMod1() && !aKeyCode.IsMod2() )
175 if ( ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ) &&
176 ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TITLEOBJECT ) &&
177 ( bSelection || !aSel.nStartPos ) )
179 Indent( aKeyCode.IsShift() ? (-1) : (+1) );
180 bKeyProcessed = TRUE;
182 else if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) &&
183 !bSelection && !aSel.nEndPos && pOwner->ImplHasBullet( aSel.nEndPara ) )
185 Indent( aKeyCode.IsShift() ? (-1) : (+1) );
186 bKeyProcessed = TRUE;
190 break;
191 case KEY_BACKSPACE:
193 if( !bReadOnly && !bSelection && aSel.nEndPara && !aSel.nEndPos )
195 Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
196 Paragraph* pPrev = pOwner->pParaList->GetParagraph( aSel.nEndPara-1 );
197 if( !pPrev->IsVisible() )
198 return TRUE;
199 if( !pPara->GetDepth() )
201 if(!pOwner->ImpCanDeleteSelectedPages(this, aSel.nEndPara , 1 ) )
202 return TRUE;
206 break;
207 case KEY_RETURN:
209 if ( !bReadOnly )
211 // Sonderbehandlung: Hartes Return am Ende eines Absatzes,
212 // der eingeklappte Unterabsaetze besitzt
213 Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
215 if( !aKeyCode.IsShift() )
217 // Nochmal ImpGetCursor ???
218 if( !bSelection &&
219 aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
221 ULONG nChilds = pOwner->pParaList->GetChildCount(pPara);
222 if( nChilds && !pOwner->pParaList->HasVisibleChilds(pPara))
224 pOwner->UndoActionStart( OLUNDO_INSERT );
225 ULONG nTemp = aSel.nEndPara;
226 nTemp += nChilds;
227 nTemp++; // einfuegen ueber naechstem Non-Child
228 pOwner->Insert( String(),nTemp,pPara->GetDepth());
229 // Cursor positionieren
230 ESelection aTmpSel((USHORT)nTemp,0,(USHORT)nTemp,0);
231 pEditView->SetSelection( aTmpSel );
232 pEditView->ShowCursor( TRUE, TRUE );
233 pOwner->UndoActionEnd( OLUNDO_INSERT );
234 bKeyProcessed = TRUE;
238 if( !bKeyProcessed && !bSelection &&
239 !aKeyCode.IsShift() && aKeyCode.IsMod1() &&
240 ( aSel.nEndPos == pOwner->pEditEngine->GetTextLen(aSel.nEndPara) ) )
242 pOwner->UndoActionStart( OLUNDO_INSERT );
243 ULONG nTemp = aSel.nEndPara;
244 nTemp++;
245 pOwner->Insert( String(), nTemp, pPara->GetDepth()+1 );
247 // Cursor positionieren
248 ESelection aTmpSel((USHORT)nTemp,0,(USHORT)nTemp,0);
249 pEditView->SetSelection( aTmpSel );
250 pEditView->ShowCursor( TRUE, TRUE );
251 pOwner->UndoActionEnd( OLUNDO_INSERT );
252 bKeyProcessed = TRUE;
256 break;
260 return bKeyProcessed ? TRUE : pEditView->PostKeyEvent( rKEvt, pFrameWin );
264 ULONG OutlinerView::ImpCheckMousePos(const Point& rPosPix, MouseTarget& reTarget)
266 DBG_CHKTHIS(OutlinerView,0);
267 ULONG nPara = EE_PARA_NOT_FOUND;
269 Point aMousePosWin = pEditView->GetWindow()->PixelToLogic( rPosPix );
270 if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
272 reTarget = MouseOutside;
274 else
276 reTarget = MouseText;
278 Point aPaperPos( aMousePosWin );
279 Rectangle aOutArea = pEditView->GetOutputArea();
280 Rectangle aVisArea = pEditView->GetVisArea();
281 aPaperPos.X() -= aOutArea.Left();
282 aPaperPos.X() += aVisArea.Left();
283 aPaperPos.Y() -= aOutArea.Top();
284 aPaperPos.Y() += aVisArea.Top();
286 BOOL bBullet;
287 if ( pOwner->IsTextPos( aPaperPos, 0, &bBullet ) )
289 Point aDocPos = pOwner->GetDocPos( aPaperPos );
290 nPara = pOwner->pEditEngine->FindParagraph( aDocPos.Y() );
292 if ( bBullet )
294 reTarget = MouseBullet;
296 else
298 // Check for hyperlink
299 const SvxFieldItem* pFieldItem = pEditView->GetField( aMousePosWin );
300 if ( pFieldItem && pFieldItem->GetField() && pFieldItem->GetField()->ISA( SvxURLField ) )
301 reTarget = MouseHypertext;
305 return nPara;
308 BOOL __EXPORT OutlinerView::MouseMove( const MouseEvent& rMEvt )
310 DBG_CHKTHIS(OutlinerView,0);
312 if( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode())
313 return pEditView->MouseMove( rMEvt );
315 Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
316 if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
317 return FALSE;
319 Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
320 pEditView->GetWindow()->SetPointer( aPointer );
321 return pEditView->MouseMove( rMEvt );
325 BOOL __EXPORT OutlinerView::MouseButtonDown( const MouseEvent& rMEvt )
327 DBG_CHKTHIS(OutlinerView,0);
328 if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode() )
329 return pEditView->MouseButtonDown( rMEvt );
331 Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
332 if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
333 return FALSE;
335 Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
336 pEditView->GetWindow()->SetPointer( aPointer );
338 MouseTarget eTarget;
339 ULONG nPara = ImpCheckMousePos( rMEvt.GetPosPixel(), eTarget );
340 if ( eTarget == MouseBullet )
342 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
343 BOOL bHasChilds = (pPara && pOwner->pParaList->HasChilds(pPara));
344 if( rMEvt.GetClicks() == 1 )
346 ULONG nEndPara = nPara;
347 if ( bHasChilds && pOwner->pParaList->HasVisibleChilds(pPara) )
348 nEndPara += pOwner->pParaList->GetChildCount( pPara );
349 // umgekehrt rum selektieren, damit EditEngine nicht scrollt
350 ESelection aSel((USHORT)nEndPara, 0xffff,(USHORT)nPara, 0 );
351 pEditView->SetSelection( aSel );
353 else if( rMEvt.GetClicks() == 2 && bHasChilds )
354 ImpToggleExpand( pPara );
356 aDDStartPosPix = rMEvt.GetPosPixel();
357 aDDStartPosRef=pEditView->GetWindow()->PixelToLogic( aDDStartPosPix,pOwner->GetRefMapMode());
358 return TRUE;
360 return pEditView->MouseButtonDown( rMEvt );
364 BOOL __EXPORT OutlinerView::MouseButtonUp( const MouseEvent& rMEvt )
366 DBG_CHKTHIS(OutlinerView,0);
367 if ( ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) || pEditView->GetEditEngine()->IsInSelectionMode() )
368 return pEditView->MouseButtonUp( rMEvt );
370 Point aMousePosWin( pEditView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ) );
371 if( !pEditView->GetOutputArea().IsInside( aMousePosWin ) )
372 return FALSE;
374 Pointer aPointer = GetPointer( rMEvt.GetPosPixel() );
375 pEditView->GetWindow()->SetPointer( aPointer );
377 return pEditView->MouseButtonUp( rMEvt );
380 void OutlinerView::ImpHideDDCursor()
382 DBG_CHKTHIS(OutlinerView,0);
383 if ( bDDCursorVisible )
385 bDDCursorVisible = FALSE;
386 ImpPaintDDCursor();
390 void OutlinerView::ImpShowDDCursor()
392 DBG_CHKTHIS(OutlinerView,0);
393 if ( !bDDCursorVisible )
395 bDDCursorVisible = TRUE;
396 ImpPaintDDCursor();
400 void OutlinerView::ImpPaintDDCursor()
402 DBG_CHKTHIS(OutlinerView,0);
404 Window* pWindow = pEditView->GetWindow();
405 RasterOp eOldOp = pWindow->GetRasterOp();
406 pWindow->SetRasterOp( ROP_INVERT );
408 const Color& rOldLineColor = pWindow->GetLineColor();
409 pWindow->SetLineColor( Color( COL_BLACK ) );
411 Point aStartPointWin, aEndPointWin;
412 Rectangle aOutputArWin = pEditView->GetOutputArea();
413 Rectangle aVisAreaRef = pEditView->GetVisArea();
415 if( bDDChangingDepth )
417 aStartPointWin.X() = pHorTabArrDoc[ nDDCurDepth ];
418 aStartPointWin.X() += aOutputArWin.Left();
419 aStartPointWin.Y() = aOutputArWin.Top();
420 aEndPointWin.X() = aStartPointWin.X();
421 aEndPointWin.Y() = aOutputArWin.Bottom();
423 else
425 ULONG nPara = nDDCurPara;
426 if ( nDDCurPara == LIST_APPEND )
428 Paragraph* pTemp = pOwner->pParaList->LastVisible();
429 nPara = pOwner->pParaList->GetAbsPos( pTemp );
431 aStartPointWin = pEditView->GetWindowPosTopLeft((USHORT) nPara );
432 if ( nDDCurPara == LIST_APPEND )
434 long nHeight = pOwner->pEditEngine->GetTextHeight((USHORT)nPara );
435 aStartPointWin.Y() += nHeight;
437 aStartPointWin.X() = aOutputArWin.Left();
438 aEndPointWin.Y() = aStartPointWin.Y();
439 aEndPointWin.X() = aOutputArWin.Right();
442 pWindow->DrawLine( aStartPointWin, aEndPointWin );
443 pWindow->SetLineColor( rOldLineColor );
444 pWindow->SetRasterOp( eOldOp );
447 // Berechnet, ueber welchem Absatz eingefuegt werden muss
449 ULONG OutlinerView::ImpGetInsertionPara( const Point& rPosPixel )
451 DBG_CHKTHIS(OutlinerView,0);
452 ULONG nCurPara = pEditView->GetParagraph( rPosPixel );
453 ParagraphList* pParaList = pOwner->pParaList;
455 if ( nCurPara == EE_PARA_NOT_FOUND )
456 nCurPara = LIST_APPEND;
457 else
459 Point aPosWin = pEditView->GetWindow()->PixelToLogic( rPosPixel );
460 Point aParaPosWin = pEditView->GetWindowPosTopLeft((USHORT)nCurPara);
461 long nHeightRef = pOwner->pEditEngine->GetTextHeight((USHORT)nCurPara);
462 long nParaYOffs = aPosWin.Y() - aParaPosWin.Y();
464 if ( nParaYOffs > nHeightRef / 2 )
466 Paragraph* p = pParaList->GetParagraph( nCurPara );
467 p = pParaList->NextVisible( p );
468 nCurPara = p ? pParaList->GetAbsPos( p ) : LIST_APPEND;
471 return nCurPara;
475 void OutlinerView::ImpToggleExpand( Paragraph* pPara )
477 DBG_CHKTHIS(OutlinerView,0);
479 USHORT nPara = (USHORT) pOwner->pParaList->GetAbsPos( pPara );
480 pEditView->SetSelection( ESelection( nPara, 0, nPara, 0 ) );
481 ImplExpandOrCollaps( nPara, nPara, !pOwner->pParaList->HasVisibleChilds( pPara ) );
482 pEditView->ShowCursor();
486 void OutlinerView::SetOutliner( Outliner* pOutliner )
488 DBG_CHKTHIS(OutlinerView,0);
489 pOwner = pOutliner;
490 pEditView->SetEditEngine( pOutliner->pEditEngine );
495 ULONG OutlinerView::Select( Paragraph* pParagraph, BOOL bSelect,
496 BOOL bWithChilds )
498 DBG_CHKTHIS(OutlinerView,0);
500 ULONG nPara = pOwner->pParaList->GetAbsPos( pParagraph );
501 USHORT nEnd = 0;
502 if ( bSelect )
503 nEnd = 0xffff;
505 ULONG nChildCount = 0;
506 if ( bWithChilds )
507 nChildCount = pOwner->pParaList->GetChildCount( pParagraph );
509 ESelection aSel( (USHORT)nPara, 0,(USHORT)(nPara+nChildCount), nEnd );
510 pEditView->SetSelection( aSel );
511 return nChildCount+1;
515 void OutlinerView::SetAttribs( const SfxItemSet& rAttrs )
517 DBG_CHKTHIS(OutlinerView,0);
519 BOOL bUpdate = pOwner->pEditEngine->GetUpdateMode();
520 pOwner->pEditEngine->SetUpdateMode( FALSE );
522 if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
523 pOwner->UndoActionStart( OLUNDO_ATTR );
525 ParaRange aSel = ImpGetSelectedParagraphs( FALSE );
527 pEditView->SetAttribs( rAttrs );
529 // Bullet-Texte aktualisieren
530 for( USHORT nPara= aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
532 pOwner->ImplCheckNumBulletItem( nPara );
533 // update following paras as well, numbering depends on
534 // previous paras
535 pOwner->ImplCalcBulletText( nPara, TRUE, FALSE );
537 if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
538 pOwner->InsertUndo( new OutlinerUndoCheckPara( pOwner, nPara ) );
541 if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
542 pOwner->UndoActionEnd( OLUNDO_ATTR );
544 pEditView->SetEditEngineUpdateMode( bUpdate );
547 ParaRange OutlinerView::ImpGetSelectedParagraphs( BOOL bIncludeHiddenChilds )
549 DBG_CHKTHIS( OutlinerView, 0 );
551 ESelection aSel = pEditView->GetSelection();
552 ParaRange aParas( aSel.nStartPara, aSel.nEndPara );
553 aParas.Adjust();
555 // unsichtbare Childs des letzten Parents in Selektion mit aufnehmen
556 if ( bIncludeHiddenChilds )
558 Paragraph* pLast = pOwner->pParaList->GetParagraph( aParas.nEndPara );
559 if ( pOwner->pParaList->HasHiddenChilds( pLast ) )
560 aParas.nEndPara =
561 sal::static_int_cast< USHORT >(
562 aParas.nEndPara +
563 pOwner->pParaList->GetChildCount( pLast ) );
565 return aParas;
568 // MT: Name sollte mal geaendert werden!
569 void OutlinerView::AdjustDepth( short nDX )
571 Indent( nDX );
574 void OutlinerView::Indent( short nDiff )
576 DBG_CHKTHIS( OutlinerView, 0 );
578 if( !nDiff || ( ( nDiff > 0 ) && ImpCalcSelectedPages( TRUE ) && !pOwner->ImpCanIndentSelectedPages( this ) ) )
579 return;
581 const bool bOutlinerView = pOwner->pEditEngine->GetControlWord() & EE_CNTRL_OUTLINER;
582 BOOL bUpdate = pOwner->pEditEngine->GetUpdateMode();
583 pOwner->pEditEngine->SetUpdateMode( FALSE );
585 BOOL bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
587 if( bUndo )
588 pOwner->UndoActionStart( OLUNDO_DEPTH );
590 sal_Int16 nMinDepth = -1; // Optimierung: Nicht unnoetig viele Absatze neu berechnen
592 ParaRange aSel = ImpGetSelectedParagraphs( TRUE );
593 for ( USHORT nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
595 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
597 sal_Int16 nOldDepth = pPara->GetDepth();
598 sal_Int16 nNewDepth = nOldDepth + nDiff;
600 if( bOutlinerView && nPara )
602 const bool bPage = pPara->HasFlag(PARAFLAG_ISPAGE);
603 if( (bPage && (nDiff == +1)) || (!bPage && (nDiff == -1) && (nOldDepth <= 0)) )
605 // App benachrichtigen
606 pOwner->nDepthChangedHdlPrevDepth = (sal_Int16)nOldDepth;
607 pOwner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
608 pOwner->pHdlParagraph = pPara;
610 if( bPage )
611 pPara->RemoveFlag( PARAFLAG_ISPAGE );
612 else
613 pPara->SetFlag( PARAFLAG_ISPAGE );
615 pOwner->DepthChangedHdl();
616 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
618 if( bUndo )
619 pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nPara, pOwner->mnDepthChangeHdlPrevFlags, pPara->nFlags ) );
621 continue;
625 // do not switch off numeration with tab
626 if( (nOldDepth == 0) && (nNewDepth == -1) )
627 continue;
629 // do not indent if there is no numeration enabled
630 if( nOldDepth == -1 )
631 continue;
633 if ( nNewDepth < pOwner->nMinDepth )
634 nNewDepth = pOwner->nMinDepth;
635 if ( nNewDepth > pOwner->nMaxDepth )
636 nNewDepth = pOwner->nMaxDepth;
638 if( nOldDepth < nMinDepth )
639 nMinDepth = nOldDepth;
640 if( nNewDepth < nMinDepth )
641 nMinDepth = nNewDepth;
643 if( nOldDepth != nNewDepth )
645 if ( ( nPara == aSel.nStartPara ) && aSel.nStartPara && ( pOwner->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT ))
647 // Sonderfall: Der Vorgaenger eines eingerueckten Absatzes ist
648 // unsichtbar und steht jetzt auf der gleichen Ebene wie der
649 // sichtbare Absatz. In diesem Fall wird der naechste sichtbare
650 // Absatz gesucht und aufgeplustert.
651 #ifdef DBG_UTIL
652 Paragraph* _pPara = pOwner->pParaList->GetParagraph( aSel.nStartPara );
653 DBG_ASSERT(_pPara->IsVisible(),"Selected Paragraph invisible ?!");
654 #endif
655 Paragraph* pPrev= pOwner->pParaList->GetParagraph( aSel.nStartPara-1 );
657 if( !pPrev->IsVisible() && ( pPrev->GetDepth() == nNewDepth ) )
659 // Vorgaenger ist eingeklappt und steht auf gleicher Ebene
660 // => naechsten sichtbaren Absatz suchen und expandieren
661 pPrev = pOwner->pParaList->GetParent( pPrev );
662 while( !pPrev->IsVisible() )
663 pPrev = pOwner->pParaList->GetParent( pPrev );
665 pOwner->Expand( pPrev );
666 pOwner->InvalidateBullet( pPrev, pOwner->pParaList->GetAbsPos( pPrev ) );
670 pOwner->nDepthChangedHdlPrevDepth = (sal_Int16)nOldDepth;
671 pOwner->mnDepthChangeHdlPrevFlags = pPara->nFlags;
672 pOwner->pHdlParagraph = pPara;
674 pOwner->ImplInitDepth( nPara, nNewDepth, TRUE, FALSE );
675 pOwner->ImplCalcBulletText( nPara, FALSE, FALSE );
677 if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
678 pOwner->ImplSetLevelDependendStyleSheet( nPara );
680 // App benachrichtigen
681 pOwner->DepthChangedHdl();
683 else
685 // Needs at least a repaint...
686 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
690 // MT 19.08.99: War mal fuer Optimierung (outliner.cxx#1.193),
691 // hat aber zu zuviel Wartungsaufwand / doppelten Funktionen gefuehrt
692 // und zu wenig gebracht:
693 // pOwner->ImpSetBulletTextsFrom( aSel.nStartPara+1, nMinDepth );
694 // Wird jetzt direkt in Schleife mit ImplCalcBulletText() erledigt.
695 // Jetzt fehlen nur noch die folgenden Ansaetze, die davon betroffen sind.
696 USHORT nParas = (USHORT)pOwner->pParaList->GetParagraphCount();
697 for ( USHORT n = aSel.nEndPara+1; n < nParas; n++ )
699 Paragraph* pPara = pOwner->pParaList->GetParagraph( n );
700 if ( pPara->GetDepth() < nMinDepth )
701 break;
702 pOwner->ImplCalcBulletText( n, FALSE, FALSE );
705 if ( bUpdate )
707 pEditView->SetEditEngineUpdateMode( TRUE );
708 pEditView->ShowCursor();
711 if( bUndo )
712 pOwner->UndoActionEnd( OLUNDO_DEPTH );
715 BOOL OutlinerView::AdjustHeight( long nDY )
717 DBG_CHKTHIS(OutlinerView,0);
718 pEditView->MoveParagraphs( nDY );
719 return TRUE; // remove return value...
722 void OutlinerView::AdjustDepth( Paragraph* pPara, short nDX, BOOL bWithChilds)
724 DBG_CHKTHIS(OutlinerView,0);
725 ULONG nStartPara = pOwner->pParaList->GetAbsPos( pPara );
726 ULONG nEndPara = nStartPara;
727 if ( bWithChilds )
728 nEndPara += pOwner->pParaList->GetChildCount( pPara );
729 ESelection aSel((USHORT)nStartPara, 0,(USHORT)nEndPara, 0xffff );
730 pEditView->SetSelection( aSel );
731 AdjustDepth( nDX );
734 void OutlinerView::AdjustHeight( Paragraph* pPara, long nDY, BOOL bWithChilds )
736 DBG_CHKTHIS(OutlinerView,0);
737 ULONG nStartPara = pOwner->pParaList->GetAbsPos( pPara );
738 ULONG nEndPara = nStartPara;
739 if ( bWithChilds )
740 nEndPara += pOwner->pParaList->GetChildCount( pPara );
741 ESelection aSel( (USHORT)nStartPara, 0, (USHORT)nEndPara, 0xffff );
742 pEditView->SetSelection( aSel );
743 AdjustHeight( nDY );
747 Rectangle OutlinerView::GetVisArea() const
749 DBG_CHKTHIS(OutlinerView,0);
750 return pEditView->GetVisArea();
754 Point OutlinerView::ImpGetDocPos( const Point& rPosPixel )
756 DBG_CHKTHIS(OutlinerView,0);
757 Rectangle aOutArWin = GetOutputArea();
758 // Position in der OutputArea berechnen
759 Point aCurPosDoc( rPosPixel );
760 aCurPosDoc = pEditView->GetWindow()->PixelToLogic( aCurPosDoc );
761 aCurPosDoc -= aOutArWin.TopLeft();
762 aCurPosDoc += pEditView->GetVisArea().TopLeft();
763 return aCurPosDoc;
766 // MT 05/00: Wofuer dies ImpXXXScroll, sollte das nicht die EditEngine machen???
768 void OutlinerView::ImpDragScroll( const Point& rPosPix )
770 DBG_CHKTHIS(OutlinerView,0);
771 Point aPosWin = pEditView->GetWindow()->PixelToLogic( rPosPix );
772 Rectangle aOutputArWin = pEditView->GetOutputArea();
773 if ( aPosWin.X() <= aOutputArWin.Left() + nDDScrollLRBorderWidthWin)
774 ImpScrollLeft();
775 else if( aPosWin.X() >= aOutputArWin.Right()- nDDScrollLRBorderWidthWin)
776 ImpScrollRight();
777 else if( aPosWin.Y() <= aOutputArWin.Top() + nDDScrollTBBorderWidthWin)
778 ImpScrollUp();
779 else if(aPosWin.Y() >= aOutputArWin.Bottom() - nDDScrollTBBorderWidthWin)
780 ImpScrollDown();
784 void OutlinerView::ImpScrollLeft()
786 DBG_CHKTHIS(OutlinerView,0);
787 Rectangle aVisArea( pEditView->GetVisArea() );
788 long nMaxScrollOffs = aVisArea.Left();
789 if ( !nMaxScrollOffs )
790 return;
791 long nScrollOffsRef = (aVisArea.GetWidth() * OL_SCROLL_HOROFFSET) / 100;
792 if ( !nScrollOffsRef )
793 nScrollOffsRef = 1;
794 if ( nScrollOffsRef > nMaxScrollOffs )
795 nScrollOffsRef = nMaxScrollOffs;
797 ImpHideDDCursor();
798 Scroll( -nScrollOffsRef, 0 );
800 EditStatus aScrollStat;
801 aScrollStat.GetStatusWord() = EE_STAT_HSCROLL;
802 pOwner->pEditEngine->GetStatusEventHdl().Call( &aScrollStat );
806 void OutlinerView::ImpScrollRight()
808 DBG_CHKTHIS(OutlinerView,0);
809 Rectangle aVisArea( pEditView->GetVisArea() );
810 long nMaxScrollOffs = pOwner->pEditEngine->GetPaperSize().Width() -
811 aVisArea.Right();
812 if ( !nMaxScrollOffs )
813 return;
814 long nScrollOffsRef = (aVisArea.GetWidth() * OL_SCROLL_HOROFFSET) / 100;
815 if ( !nScrollOffsRef )
816 nScrollOffsRef = 1;
817 if ( nScrollOffsRef > nMaxScrollOffs )
818 nScrollOffsRef = nMaxScrollOffs;
820 ImpHideDDCursor();
821 Scroll( nScrollOffsRef, 0 );
823 EditStatus aScrollStat;
824 aScrollStat.GetStatusWord() = EE_STAT_HSCROLL;
825 pOwner->pEditEngine->GetStatusEventHdl().Call( &aScrollStat );
829 void OutlinerView::ImpScrollDown()
831 DBG_CHKTHIS(OutlinerView,0);
832 Rectangle aVisArea( pEditView->GetVisArea() );
833 Size aDocSize( 0, (long)pOwner->pEditEngine->GetTextHeight() );
835 long nMaxScrollOffs = aDocSize.Height();
836 nMaxScrollOffs -= aVisArea.Top();
837 nMaxScrollOffs -= aVisArea.GetHeight();
838 if ( !nMaxScrollOffs )
839 return;
841 long nScrollOffsRef = (aVisArea.GetHeight() * OL_SCROLL_VEROFFSET) / 100;
843 if ( nScrollOffsRef > nMaxScrollOffs )
844 nScrollOffsRef = nMaxScrollOffs;
845 if ( !nScrollOffsRef )
846 nScrollOffsRef = 1;
848 ImpHideDDCursor();
849 Scroll( 0, -nScrollOffsRef );
851 EditStatus aScrollStat;
852 aScrollStat.GetStatusWord() = EE_STAT_VSCROLL;
853 pOwner->pEditEngine->GetStatusEventHdl().Call( &aScrollStat );
857 void OutlinerView::ImpScrollUp()
859 DBG_CHKTHIS(OutlinerView,0);
860 Rectangle aVisArea( pEditView->GetVisArea() );
861 long nMaxScrollOffs = aVisArea.Top();
862 if ( !nMaxScrollOffs )
863 return;
864 long nScrollOffsRef = (aVisArea.GetHeight() * OL_SCROLL_VEROFFSET) / 100;
867 if ( nScrollOffsRef > nMaxScrollOffs )
868 nScrollOffsRef = nMaxScrollOffs;
869 if ( !nScrollOffsRef )
870 nScrollOffsRef = 1;
872 ImpHideDDCursor();
873 Scroll( 0, nScrollOffsRef );
875 EditStatus aScrollStat;
876 aScrollStat.GetStatusWord() = EE_STAT_VSCROLL;
877 pOwner->pEditEngine->GetStatusEventHdl().Call( &aScrollStat );
881 void OutlinerView::Expand()
883 DBG_CHKTHIS( OutlinerView, 0 );
884 ParaRange aParas = ImpGetSelectedParagraphs( FALSE );
885 ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, TRUE );
889 void OutlinerView::Collapse()
891 DBG_CHKTHIS( OutlinerView, 0 );
892 ParaRange aParas = ImpGetSelectedParagraphs( FALSE );
893 ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, FALSE );
897 void OutlinerView::ExpandAll()
899 DBG_CHKTHIS( OutlinerView, 0 );
900 ImplExpandOrCollaps( 0, (USHORT)(pOwner->pParaList->GetParagraphCount()-1), TRUE );
904 void OutlinerView::CollapseAll()
906 DBG_CHKTHIS(OutlinerView,0);
907 ImplExpandOrCollaps( 0, (USHORT)(pOwner->pParaList->GetParagraphCount()-1), FALSE );
910 void OutlinerView::ImplExpandOrCollaps( USHORT nStartPara, USHORT nEndPara, BOOL bExpand )
912 DBG_CHKTHIS( OutlinerView, 0 );
914 BOOL bUpdate = pOwner->GetUpdateMode();
915 pOwner->SetUpdateMode( FALSE );
917 BOOL bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
918 if( bUndo )
919 pOwner->UndoActionStart( bExpand ? OLUNDO_EXPAND : OLUNDO_COLLAPSE );
921 for ( USHORT nPara = nStartPara; nPara <= nEndPara; nPara++ )
923 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
924 BOOL bDone = bExpand ? pOwner->Expand( pPara ) : pOwner->Collapse( pPara );
925 if( bDone )
927 // Der Strich unter dem Absatz muss verschwinden...
928 pOwner->pEditEngine->QuickMarkToBeRepainted( nPara );
932 if( bUndo )
933 pOwner->UndoActionEnd( bExpand ? OLUNDO_EXPAND : OLUNDO_COLLAPSE );
935 if ( bUpdate )
937 pOwner->SetUpdateMode( TRUE );
938 pEditView->ShowCursor();
943 void OutlinerView::Expand( Paragraph* pPara)
945 DBG_CHKTHIS(OutlinerView,0);
946 pOwner->Expand( pPara );
950 void OutlinerView::Collapse( Paragraph* pPara)
952 DBG_CHKTHIS(OutlinerView,0);
953 pOwner->Collapse( pPara );
956 void OutlinerView::InsertText( const OutlinerParaObject& rParaObj )
958 // MT: Wie Paste, nur EditView::Insert, statt EditView::Paste.
959 // Eigentlich nicht ganz richtig, das evtl. Einrueckungen
960 // korrigiert werden muessen, aber das kommt spaeter durch ein
961 // allgemeingueltiges Import.
962 // Dann wird im Inserted gleich ermittelt, was f�r eine Einrueckebene
963 // Moegliche Struktur:
964 // pImportInfo mit DestPara, DestPos, nFormat, pParaObj...
965 // Evtl. Problematisch:
966 // EditEngine, RTF => Absplittung des Bereichs, spaeter
967 // zusammenfuehrung
969 DBG_CHKTHIS(OutlinerView,0);
971 if ( ImpCalcSelectedPages( FALSE ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
972 return;
974 pOwner->UndoActionStart( OLUNDO_INSERT );
976 pOwner->pEditEngine->SetUpdateMode( FALSE );
977 ULONG nStart, nParaCount;
978 nParaCount = pOwner->pEditEngine->GetParagraphCount();
979 USHORT nSize = ImpInitPaste( nStart );
980 pEditView->InsertText( rParaObj.GetTextObject() );
981 ImpPasted( nStart, nParaCount, nSize);
982 pEditView->SetEditEngineUpdateMode( TRUE );
984 pOwner->UndoActionEnd( OLUNDO_INSERT );
986 pEditView->ShowCursor( TRUE, TRUE );
991 void OutlinerView::Cut()
993 DBG_CHKTHIS(OutlinerView,0);
994 if ( !ImpCalcSelectedPages( FALSE ) || pOwner->ImpCanDeleteSelectedPages( this ) )
995 pEditView->Cut();
998 void OutlinerView::Paste()
1000 DBG_CHKTHIS(OutlinerView,0);
1001 PasteSpecial(); // HACK(SD ruft nicht PasteSpecial auf)
1004 void OutlinerView::PasteSpecial()
1006 DBG_CHKTHIS(OutlinerView,0);
1007 if ( !ImpCalcSelectedPages( FALSE ) || pOwner->ImpCanDeleteSelectedPages( this ) )
1009 pOwner->UndoActionStart( OLUNDO_INSERT );
1011 pOwner->pEditEngine->SetUpdateMode( FALSE );
1012 pOwner->bPasting = TRUE;
1013 pEditView->PasteSpecial();
1015 pEditView->SetEditEngineUpdateMode( TRUE );
1016 pOwner->UndoActionEnd( OLUNDO_INSERT );
1017 pEditView->ShowCursor( TRUE, TRUE );
1021 List* OutlinerView::CreateSelectionList()
1023 DBG_CHKTHIS( OutlinerView, 0 );
1025 ParaRange aParas = ImpGetSelectedParagraphs( TRUE );
1026 List* pSelList = new List;
1027 for ( USHORT nPara = aParas.nStartPara; nPara <= aParas.nEndPara; nPara++ )
1029 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1030 pSelList->Insert( pPara, LIST_APPEND );
1032 return pSelList;
1035 SfxStyleSheet* OutlinerView::GetStyleSheet() const
1037 DBG_CHKTHIS(OutlinerView,0);
1038 return pEditView->GetStyleSheet();
1041 void OutlinerView::SetStyleSheet( SfxStyleSheet* pStyle )
1043 DBG_CHKTHIS(OutlinerView,0);
1044 pEditView->SetStyleSheet( pStyle );
1046 ParaRange aSel = ImpGetSelectedParagraphs( TRUE );
1047 for( USHORT nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1049 pOwner->ImplCheckNumBulletItem( nPara );
1050 pOwner->ImplCalcBulletText( nPara, FALSE, FALSE );
1054 Pointer OutlinerView::GetPointer( const Point& rPosPixel )
1056 DBG_CHKTHIS(OutlinerView,0);
1058 MouseTarget eTarget;
1059 ImpCheckMousePos( rPosPixel, eTarget );
1061 PointerStyle ePointerStyle = POINTER_ARROW;
1062 if ( eTarget == MouseText )
1064 ePointerStyle = GetOutliner()->IsVertical() ? POINTER_TEXT_VERTICAL : POINTER_TEXT;
1066 else if ( eTarget == MouseHypertext )
1068 ePointerStyle = POINTER_REFHAND;
1070 else if ( eTarget == MouseBullet )
1072 ePointerStyle = POINTER_MOVE;
1075 return Pointer( ePointerStyle );
1079 USHORT OutlinerView::ImpInitPaste( ULONG& rStart )
1081 DBG_CHKTHIS(OutlinerView,0);
1082 pOwner->bPasting = TRUE;
1083 ESelection aSelection( pEditView->GetSelection() );
1084 aSelection.Adjust();
1085 rStart = aSelection.nStartPara;
1086 USHORT nSize = aSelection.nEndPara - aSelection.nStartPara + 1;
1087 return nSize;
1091 void OutlinerView::ImpPasted( ULONG nStart, ULONG nPrevParaCount, USHORT nSize)
1093 DBG_CHKTHIS(OutlinerView,0);
1094 pOwner->bPasting = FALSE;
1095 ULONG nCurParaCount = (ULONG)pOwner->pEditEngine->GetParagraphCount();
1096 if( nCurParaCount < nPrevParaCount )
1097 nSize = sal::static_int_cast< USHORT >(
1098 nSize - ( nPrevParaCount - nCurParaCount ) );
1099 else
1100 nSize = sal::static_int_cast< USHORT >(
1101 nSize + ( nCurParaCount - nPrevParaCount ) );
1102 pOwner->ImpTextPasted( nStart, nSize );
1106 void OutlinerView::Command( const CommandEvent& rCEvt )
1108 DBG_CHKTHIS(OutlinerView,0);
1109 pEditView->Command( rCEvt );
1113 void OutlinerView::SelectRange( ULONG nFirst, USHORT nCount )
1115 DBG_CHKTHIS(OutlinerView,0);
1116 ULONG nLast = nFirst+nCount;
1117 nCount = (USHORT)pOwner->pParaList->GetParagraphCount();
1118 if( nLast <= nCount )
1119 nLast = nCount - 1;
1120 ESelection aSel( (USHORT)nFirst, 0, (USHORT)nLast, 0xffff );
1121 pEditView->SetSelection( aSel );
1125 USHORT OutlinerView::ImpCalcSelectedPages( BOOL bIncludeFirstSelected )
1127 DBG_CHKTHIS(OutlinerView,0);
1129 ESelection aSel( pEditView->GetSelection() );
1130 aSel.Adjust();
1132 USHORT nPages = 0;
1133 USHORT nFirstPage = 0xFFFF;
1134 USHORT nStartPara = aSel.nStartPara;
1135 if ( !bIncludeFirstSelected )
1136 nStartPara++; // alle nach StartPara kommenden Absaetze werden geloescht
1137 for ( USHORT nPara = nStartPara; nPara <= aSel.nEndPara; nPara++ )
1139 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1140 DBG_ASSERT(pPara, "ImpCalcSelectedPages: ungueltige Selection? ");
1141 if( pPara->HasFlag(PARAFLAG_ISPAGE) )
1143 nPages++;
1144 if( nFirstPage == 0xFFFF )
1145 nFirstPage = nPara;
1149 if( nPages )
1151 pOwner->nDepthChangedHdlPrevDepth = nPages;
1152 pOwner->pHdlParagraph = 0;
1153 pOwner->mnFirstSelPage = nFirstPage;
1156 return nPages;
1160 void OutlinerView::ToggleBullets()
1162 pOwner->UndoActionStart( OLUNDO_DEPTH );
1164 ESelection aSel( pEditView->GetSelection() );
1165 aSel.Adjust();
1167 const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
1168 pOwner->pEditEngine->SetUpdateMode( FALSE );
1170 sal_Int16 nDepth = -2;
1172 for ( USHORT nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1174 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1175 DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?");
1177 if( pPara )
1179 if( nDepth == -2 )
1180 nDepth = (pOwner->GetDepth(nPara) == -1) ? 0 : -1;
1182 pOwner->SetDepth( pPara, nDepth );
1184 if( nDepth == -1 )
1186 const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara );
1187 if(rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SFX_ITEM_SET)
1189 SfxItemSet aAttrs(rAttrs);
1190 aAttrs.ClearItem( EE_PARA_BULLETSTATE );
1191 pOwner->SetParaAttribs( nPara, aAttrs );
1197 // --> OD 2009-03-10 #i100014#
1198 // It is not a good idea to substract 1 from a count and cast the result
1199 // to USHORT without check, if the count is 0.
1200 USHORT nParaCount = (USHORT) (pOwner->pParaList->GetParagraphCount());
1201 // <--
1202 pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount );
1203 pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) );
1205 pOwner->pEditEngine->SetUpdateMode( bUpdate );
1207 pOwner->UndoActionEnd( OLUNDO_DEPTH );
1210 void OutlinerView::EnableBullets()
1212 pOwner->UndoActionStart( OLUNDO_DEPTH );
1214 ESelection aSel( pEditView->GetSelection() );
1215 aSel.Adjust();
1217 const bool bUpdate = pOwner->pEditEngine->GetUpdateMode();
1218 pOwner->pEditEngine->SetUpdateMode( FALSE );
1220 for ( USHORT nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1222 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1223 DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?");
1225 if( pPara && (pOwner->GetDepth(nPara) == -1) )
1227 pOwner->SetDepth( pPara, 0 );
1231 // --> OD 2009-03-10 #i100014#
1232 // It is not a good idea to substract 1 from a count and cast the result
1233 // to USHORT without check, if the count is 0.
1234 USHORT nParaCount = (USHORT) (pOwner->pParaList->GetParagraphCount());
1235 // <--
1236 pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount );
1237 pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nParaCount, 0 ) );
1239 pOwner->pEditEngine->SetUpdateMode( bUpdate );
1241 pOwner->UndoActionEnd( OLUNDO_DEPTH );
1245 void OutlinerView::RemoveAttribsKeepLanguages( BOOL bRemoveParaAttribs )
1247 RemoveAttribs( bRemoveParaAttribs, 0, TRUE /*keep language attribs*/ );
1250 void OutlinerView::RemoveAttribs( BOOL bRemoveParaAttribs, USHORT nWhich, BOOL bKeepLanguages )
1252 DBG_CHKTHIS(OutlinerView,0);
1253 BOOL bUpdate = pOwner->GetUpdateMode();
1254 pOwner->SetUpdateMode( FALSE );
1255 pOwner->UndoActionStart( OLUNDO_ATTR );
1256 if (bKeepLanguages)
1257 pEditView->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
1258 else
1259 pEditView->RemoveAttribs( bRemoveParaAttribs, nWhich );
1260 if ( bRemoveParaAttribs )
1262 // Ueber alle Absaetze, und Einrueckung und Level einstellen
1263 ESelection aSel = pEditView->GetSelection();
1264 aSel.Adjust();
1265 for ( USHORT nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1267 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1268 pOwner->ImplInitDepth( nPara, pPara->GetDepth(), FALSE, FALSE );
1271 pOwner->UndoActionEnd( OLUNDO_ATTR );
1272 pOwner->SetUpdateMode( bUpdate );
1277 \f// =====================================================================
1278 // ====================== Einfache Durchreicher =======================
1279 // ======================================================================
1282 void OutlinerView::InsertText( const XubString& rNew, BOOL bSelect )
1284 DBG_CHKTHIS(OutlinerView,0);
1285 if( pOwner->bFirstParaIsEmpty )
1286 pOwner->Insert( String() );
1287 pEditView->InsertText( rNew, bSelect );
1290 void OutlinerView::SetVisArea( const Rectangle& rRec )
1292 DBG_CHKTHIS(OutlinerView,0);
1293 pEditView->SetVisArea( rRec );
1297 void OutlinerView::SetSelection( const ESelection& rSel )
1299 DBG_CHKTHIS(OutlinerView,0);
1300 pEditView->SetSelection( rSel );
1303 void OutlinerView::SetReadOnly( BOOL bReadOnly )
1305 DBG_CHKTHIS(OutlinerView,0);
1306 pEditView->SetReadOnly( bReadOnly );
1309 BOOL OutlinerView::IsReadOnly() const
1311 DBG_CHKTHIS(OutlinerView,0);
1312 return pEditView->IsReadOnly();
1315 BOOL OutlinerView::HasSelection() const
1317 DBG_CHKTHIS(OutlinerView,0);
1318 return pEditView->HasSelection();
1322 void OutlinerView::ShowCursor( BOOL bGotoCursor )
1324 DBG_CHKTHIS(OutlinerView,0);
1325 pEditView->ShowCursor( bGotoCursor );
1329 void OutlinerView::HideCursor()
1331 DBG_CHKTHIS(OutlinerView,0);
1332 pEditView->HideCursor();
1336 void OutlinerView::SetWindow( Window* pWin )
1338 DBG_CHKTHIS(OutlinerView,0);
1339 pEditView->SetWindow( pWin );
1343 Window* OutlinerView::GetWindow() const
1345 DBG_CHKTHIS(OutlinerView,0);
1346 return pEditView->GetWindow();
1350 void OutlinerView::SetOutputArea( const Rectangle& rRect )
1352 DBG_CHKTHIS(OutlinerView,0);
1353 pEditView->SetOutputArea( rRect );
1357 Rectangle OutlinerView::GetOutputArea() const
1359 DBG_CHKTHIS(OutlinerView,0);
1360 return pEditView->GetOutputArea();
1364 XubString OutlinerView::GetSelected() const
1366 DBG_CHKTHIS(OutlinerView,0);
1367 return pEditView->GetSelected();
1371 void OutlinerView::RemoveCharAttribs( ULONG nPara, USHORT nWhich)
1373 DBG_CHKTHIS(OutlinerView,0);
1374 pEditView->RemoveCharAttribs( (USHORT)nPara, nWhich);
1378 void OutlinerView::CompleteAutoCorrect()
1380 DBG_CHKTHIS(OutlinerView,0);
1381 pEditView->CompleteAutoCorrect();
1385 EESpellState OutlinerView::StartSpeller( BOOL bMultiDoc )
1387 DBG_CHKTHIS(OutlinerView,0);
1388 return pEditView->StartSpeller( bMultiDoc );
1392 EESpellState OutlinerView::StartThesaurus()
1394 DBG_CHKTHIS(OutlinerView,0);
1395 return pEditView->StartThesaurus();
1399 void OutlinerView::StartTextConversion(
1400 LanguageType nSrcLang, LanguageType nDestLang, const Font *pDestFont,
1401 INT32 nOptions, BOOL bIsInteractive, BOOL bMultipleDoc )
1403 DBG_CHKTHIS(OutlinerView,0);
1404 if (
1405 (LANGUAGE_KOREAN == nSrcLang && LANGUAGE_KOREAN == nDestLang) ||
1406 (LANGUAGE_CHINESE_SIMPLIFIED == nSrcLang && LANGUAGE_CHINESE_TRADITIONAL == nDestLang) ||
1407 (LANGUAGE_CHINESE_TRADITIONAL == nSrcLang && LANGUAGE_CHINESE_SIMPLIFIED == nDestLang)
1410 pEditView->StartTextConversion( nSrcLang, nDestLang, pDestFont, nOptions, bIsInteractive, bMultipleDoc );
1412 else
1414 DBG_ERROR( "unexpected language" );
1419 USHORT OutlinerView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
1421 DBG_CHKTHIS(OutlinerView,0);
1422 return pEditView->StartSearchAndReplace( rSearchItem );
1425 void OutlinerView::TransliterateText( sal_Int32 nTransliterationMode )
1427 DBG_CHKTHIS(OutlinerView,0);
1428 pEditView->TransliterateText( nTransliterationMode );
1433 ESelection OutlinerView::GetSelection()
1435 DBG_CHKTHIS(OutlinerView,0);
1436 return pEditView->GetSelection();
1440 void OutlinerView::Scroll( long nHorzScroll, long nVertScroll )
1442 DBG_CHKTHIS(OutlinerView,0);
1443 pEditView->Scroll( nHorzScroll, nVertScroll );
1447 void OutlinerView::SetControlWord( ULONG nWord )
1449 DBG_CHKTHIS(OutlinerView,0);
1450 pEditView->SetControlWord( nWord );
1454 ULONG OutlinerView::GetControlWord() const
1456 DBG_CHKTHIS(OutlinerView,0);
1457 return pEditView->GetControlWord();
1461 void OutlinerView::SetAnchorMode( EVAnchorMode eMode )
1463 DBG_CHKTHIS(OutlinerView,0);
1464 pEditView->SetAnchorMode( eMode );
1468 EVAnchorMode OutlinerView::GetAnchorMode() const
1470 DBG_CHKTHIS(OutlinerView,0);
1471 return pEditView->GetAnchorMode();
1475 void OutlinerView::Undo()
1477 DBG_CHKTHIS(OutlinerView,0);
1478 pEditView->Undo();
1482 void OutlinerView::Redo()
1484 DBG_CHKTHIS(OutlinerView,0);
1485 pEditView->Redo();
1489 void OutlinerView::EnablePaste( BOOL bEnable )
1491 DBG_CHKTHIS(OutlinerView,0);
1492 pEditView->EnablePaste( bEnable );
1496 void OutlinerView::Copy()
1498 DBG_CHKTHIS(OutlinerView,0);
1499 pEditView->Copy();
1503 void OutlinerView::InsertField( const SvxFieldItem& rFld )
1505 DBG_CHKTHIS(OutlinerView,0);
1506 pEditView->InsertField( rFld );
1510 const SvxFieldItem* OutlinerView::GetFieldUnderMousePointer() const
1512 DBG_CHKTHIS(OutlinerView,0);
1513 return pEditView->GetFieldUnderMousePointer();
1517 const SvxFieldItem* OutlinerView::GetFieldUnderMousePointer( USHORT& nPara, USHORT& nPos ) const
1519 DBG_CHKTHIS(OutlinerView,0);
1520 return pEditView->GetFieldUnderMousePointer( nPara, nPos );
1524 const SvxFieldItem* OutlinerView::GetFieldAtSelection() const
1526 DBG_CHKTHIS(OutlinerView,0);
1527 return pEditView->GetFieldAtSelection();
1530 void OutlinerView::SetInvalidateMore( USHORT nPixel )
1532 DBG_CHKTHIS(OutlinerView,0);
1533 pEditView->SetInvalidateMore( nPixel );
1537 USHORT OutlinerView::GetInvalidateMore() const
1539 DBG_CHKTHIS(OutlinerView,0);
1540 return pEditView->GetInvalidateMore();
1544 BOOL OutlinerView::IsCursorAtWrongSpelledWord( BOOL bMarkIfWrong )
1546 DBG_CHKTHIS(OutlinerView,0);
1547 return pEditView->IsCursorAtWrongSpelledWord( bMarkIfWrong );
1551 BOOL OutlinerView::IsWrongSpelledWordAtPos( const Point& rPosPixel, BOOL bMarkIfWrong )
1553 DBG_CHKTHIS(OutlinerView,0);
1554 return pEditView->IsWrongSpelledWordAtPos( rPosPixel, bMarkIfWrong );
1558 void OutlinerView::SpellIgnoreWord()
1560 DBG_CHKTHIS(OutlinerView,0);
1561 pEditView->SpellIgnoreWord();
1565 void OutlinerView::ExecuteSpellPopup( const Point& rPosPixel, Link* pStartDlg )
1567 DBG_CHKTHIS(OutlinerView,0);
1568 pEditView->ExecuteSpellPopup( rPosPixel, pStartDlg );
1571 ULONG OutlinerView::Read( SvStream& rInput, const String& rBaseURL, EETextFormat eFormat, BOOL bSelect, SvKeyValueIterator* pHTTPHeaderAttrs )
1573 DBG_CHKTHIS(OutlinerView,0);
1574 USHORT nOldParaCount = pEditView->GetEditEngine()->GetParagraphCount();
1575 ESelection aOldSel = pEditView->GetSelection();
1576 aOldSel.Adjust();
1578 ULONG nRet = pEditView->Read( rInput, rBaseURL, eFormat, bSelect, pHTTPHeaderAttrs );
1580 // MT 08/00: Hier sollte eigentlich das gleiche wie in PasteSpecial passieren!
1581 // Mal anpassen, wenn dieses ImplInitPaste und ImpPasted-Geraffel ueberarbeitet ist.
1583 long nParaDiff = pEditView->GetEditEngine()->GetParagraphCount() - nOldParaCount;
1584 USHORT nChangesStart = aOldSel.nStartPara;
1585 USHORT nChangesEnd = sal::static_int_cast< USHORT >(nChangesStart + nParaDiff + (aOldSel.nEndPara-aOldSel.nStartPara));
1587 for ( USHORT n = nChangesStart; n <= nChangesEnd; n++ )
1589 if ( eFormat == EE_FORMAT_BIN )
1591 USHORT nDepth = 0;
1592 const SfxItemSet& rAttrs = pOwner->GetParaAttribs( n );
1593 const SfxInt16Item& rLevel = (const SfxInt16Item&) rAttrs.Get( EE_PARA_OUTLLEVEL );
1594 nDepth = rLevel.GetValue();
1595 pOwner->ImplInitDepth( n, nDepth, FALSE );
1598 if ( pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT )
1599 pOwner->ImplSetLevelDependendStyleSheet( n );
1602 if ( eFormat != EE_FORMAT_BIN )
1604 pOwner->ImpFilterIndents( nChangesStart, nChangesEnd );
1607 return nRet;
1610 ULONG OutlinerView::Write( SvStream& rOutput, EETextFormat eFormat )
1612 DBG_CHKTHIS(OutlinerView,0);
1613 return pEditView->Write( rOutput, eFormat );
1616 void OutlinerView::SetBackgroundColor( const Color& rColor )
1618 DBG_CHKTHIS(OutlinerView,0);
1619 pEditView->SetBackgroundColor( rColor );
1623 Color OutlinerView::GetBackgroundColor()
1625 DBG_CHKTHIS(OutlinerView,0);
1626 return pEditView->GetBackgroundColor();
1629 SfxItemSet OutlinerView::GetAttribs()
1631 DBG_CHKTHIS(OutlinerView,0);
1632 return pEditView->GetAttribs();
1635 USHORT OutlinerView::GetSelectedScriptType() const
1637 DBG_CHKTHIS(OutlinerView,0);
1638 return pEditView->GetSelectedScriptType();
1641 String OutlinerView::GetSurroundingText() const
1643 DBG_CHKTHIS(OutlinerView,0);
1644 return pEditView->GetSurroundingText();
1647 Selection OutlinerView::GetSurroundingTextSelection() const
1649 DBG_CHKTHIS(OutlinerView,0);
1650 return pEditView->GetSurroundingTextSelection();