1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/i18n/WordType.hpp>
22 #include <svl/intitem.hxx>
23 #include <svl/itempool.hxx>
24 #include <editeng/editeng.hxx>
25 #include <editeng/editview.hxx>
26 #include <editeng/editdata.hxx>
27 #include <editeng/eerdll.hxx>
28 #include <editeng/lrspitem.hxx>
29 #include <editeng/fhgtitem.hxx>
31 #include <svl/style.hxx>
32 #include <svl/languageoptions.hxx>
33 #include <i18nlangtag/languagetag.hxx>
35 #include <editeng/outliner.hxx>
36 #include <outleeng.hxx>
37 #include <paralist.hxx>
38 #include <outlundo.hxx>
39 #include <editeng/outlobj.hxx>
40 #include <editeng/flditem.hxx>
41 #include <editeng/eeitem.hxx>
42 #include <editeng/numitem.hxx>
43 #include <vcl/window.hxx>
44 #include <svl/itemset.hxx>
45 #include <svl/eitem.hxx>
46 #include <editeng/editstat.hxx>
48 using namespace ::com::sun::star
;
50 DBG_NAME(OutlinerView
)
53 OutlinerView::OutlinerView( Outliner
* pOut
, Window
* pWin
)
55 DBG_CTOR( OutlinerView
, 0 );
58 bDDCursorVisible
= sal_False
;
59 bInDragMode
= sal_False
;
60 nDDScrollLRBorderWidthWin
= 0;
61 nDDScrollTBBorderWidthWin
= 0;
64 pEditView
= new EditView( pOut
->pEditEngine
, pWin
);
65 pEditView
->SetSelectionMode( EE_SELMODE_TXTONLY
);
68 OutlinerView::~OutlinerView()
70 DBG_DTOR(OutlinerView
,0);
74 void OutlinerView::Paint( const Rectangle
& rRect
, OutputDevice
* pTargetDevice
)
76 DBG_CHKTHIS(OutlinerView
,0);
78 // For the first Paint/KeyInput/Drop an emty Outliner is turned into
79 // an Outliner with exactly one paragraph.
80 if( pOwner
->bFirstParaIsEmpty
)
81 pOwner
->Insert( String() );
83 pEditView
->Paint( rRect
, pTargetDevice
);
86 sal_Bool
OutlinerView::PostKeyEvent( const KeyEvent
& rKEvt
, Window
* pFrameWin
)
88 DBG_CHKTHIS( OutlinerView
, 0 );
90 // For the first Paint/KeyInput/Drop an emty Outliner is turned into
91 // an Outliner with exactly one paragraph.
92 if( pOwner
->bFirstParaIsEmpty
)
93 pOwner
->Insert( String() );
96 sal_Bool bKeyProcessed
= sal_False
;
97 ESelection
aSel( pEditView
->GetSelection() );
98 sal_Bool bSelection
= aSel
.HasRange();
99 KeyCode aKeyCode
= rKEvt
.GetKeyCode();
100 KeyFuncType eFunc
= aKeyCode
.GetFunction();
101 sal_uInt16 nCode
= aKeyCode
.GetCode();
102 sal_Bool bReadOnly
= IsReadOnly();
104 if( bSelection
&& ( nCode
!= KEY_TAB
) && EditEngine::DoesKeyChangeText( rKEvt
) )
106 if ( ImpCalcSelectedPages( sal_False
) && !pOwner
->ImpCanDeleteSelectedPages( this ) )
110 if ( eFunc
!= KEYFUNC_DONTKNOW
)
119 bKeyProcessed
= sal_True
;
126 bKeyProcessed
= sal_True
;
134 bKeyProcessed
= sal_True
;
140 if( !bReadOnly
&& !bSelection
&& ( pOwner
->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT
) )
142 if( aSel
.nEndPos
== pOwner
->pEditEngine
->GetTextLen( aSel
.nEndPara
) )
144 Paragraph
* pNext
= pOwner
->pParaList
->GetParagraph( aSel
.nEndPara
+1 );
145 if( pNext
&& pNext
->HasFlag(PARAFLAG_ISPAGE
) )
147 if( !pOwner
->ImpCanDeleteSelectedPages( this, aSel
.nEndPara
, 1 ) )
154 default: // is then possibly edited below.
155 eFunc
= KEYFUNC_DONTKNOW
;
158 if ( eFunc
== KEYFUNC_DONTKNOW
)
164 if ( !bReadOnly
&& !aKeyCode
.IsMod1() && !aKeyCode
.IsMod2() )
166 if ( ( pOwner
->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT
) &&
167 ( pOwner
->ImplGetOutlinerMode() != OUTLINERMODE_TITLEOBJECT
) &&
168 ( bSelection
|| !aSel
.nStartPos
) )
170 Indent( aKeyCode
.IsShift() ? (-1) : (+1) );
171 bKeyProcessed
= sal_True
;
173 else if ( ( pOwner
->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT
) &&
174 !bSelection
&& !aSel
.nEndPos
&& pOwner
->ImplHasNumberFormat( aSel
.nEndPara
) )
176 Indent( aKeyCode
.IsShift() ? (-1) : (+1) );
177 bKeyProcessed
= sal_True
;
184 if( !bReadOnly
&& !bSelection
&& aSel
.nEndPara
&& !aSel
.nEndPos
)
186 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( aSel
.nEndPara
);
187 Paragraph
* pPrev
= pOwner
->pParaList
->GetParagraph( aSel
.nEndPara
-1 );
188 if( !pPrev
->IsVisible() )
190 if( !pPara
->GetDepth() )
192 if(!pOwner
->ImpCanDeleteSelectedPages(this, aSel
.nEndPara
, 1 ) )
202 // Special treatment: hard return at the end of a paragraph,
203 // which has collapsed subparagraphs.
204 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( aSel
.nEndPara
);
206 if( !aKeyCode
.IsShift() )
208 // ImpGetCursor again???
210 aSel
.nEndPos
== pOwner
->pEditEngine
->GetTextLen( aSel
.nEndPara
) )
212 sal_Int32 nChildren
= pOwner
->pParaList
->GetChildCount(pPara
);
213 if( nChildren
&& !pOwner
->pParaList
->HasVisibleChildren(pPara
))
215 pOwner
->UndoActionStart( OLUNDO_INSERT
);
216 sal_Int32 nTemp
= aSel
.nEndPara
;
218 nTemp
++; // insert above next Non-Child
219 SAL_WARN_IF( nTemp
< 0, "editeng", "OutlinerView::PostKeyEvent - overflow");
222 pOwner
->Insert( String(),nTemp
,pPara
->GetDepth());
223 // Position the cursor
224 ESelection
aTmpSel(nTemp
,0,nTemp
,0);
225 pEditView
->SetSelection( aTmpSel
);
227 pEditView
->ShowCursor( sal_True
, sal_True
);
228 pOwner
->UndoActionEnd( OLUNDO_INSERT
);
229 bKeyProcessed
= sal_True
;
233 if( !bKeyProcessed
&& !bSelection
&&
234 !aKeyCode
.IsShift() && aKeyCode
.IsMod1() &&
235 ( aSel
.nEndPos
== pOwner
->pEditEngine
->GetTextLen(aSel
.nEndPara
) ) )
237 pOwner
->UndoActionStart( OLUNDO_INSERT
);
238 sal_Int32 nTemp
= aSel
.nEndPara
;
240 pOwner
->Insert( String(), nTemp
, pPara
->GetDepth()+1 );
242 // Position the cursor
243 ESelection
aTmpSel(nTemp
,0,nTemp
,0);
244 pEditView
->SetSelection( aTmpSel
);
245 pEditView
->ShowCursor( sal_True
, sal_True
);
246 pOwner
->UndoActionEnd( OLUNDO_INSERT
);
247 bKeyProcessed
= sal_True
;
255 return bKeyProcessed
? sal_True
: pEditView
->PostKeyEvent( rKEvt
, pFrameWin
);
260 sal_Int32
OutlinerView::ImpCheckMousePos(const Point
& rPosPix
, MouseTarget
& reTarget
)
262 DBG_CHKTHIS(OutlinerView
,0);
263 sal_Int32 nPara
= EE_PARA_NOT_FOUND
;
265 Point aMousePosWin
= pEditView
->GetWindow()->PixelToLogic( rPosPix
);
266 if( !pEditView
->GetOutputArea().IsInside( aMousePosWin
) )
268 reTarget
= MouseOutside
;
272 reTarget
= MouseText
;
274 Point
aPaperPos( aMousePosWin
);
275 Rectangle aOutArea
= pEditView
->GetOutputArea();
276 Rectangle aVisArea
= pEditView
->GetVisArea();
277 aPaperPos
.X() -= aOutArea
.Left();
278 aPaperPos
.X() += aVisArea
.Left();
279 aPaperPos
.Y() -= aOutArea
.Top();
280 aPaperPos
.Y() += aVisArea
.Top();
283 if ( pOwner
->IsTextPos( aPaperPos
, 0, &bBullet
) )
285 Point aDocPos
= pOwner
->GetDocPos( aPaperPos
);
286 nPara
= pOwner
->pEditEngine
->FindParagraph( aDocPos
.Y() );
290 reTarget
= MouseBullet
;
294 // Check for hyperlink
295 const SvxFieldItem
* pFieldItem
= pEditView
->GetField( aMousePosWin
);
296 if ( pFieldItem
&& pFieldItem
->GetField() && pFieldItem
->GetField()->ISA( SvxURLField
) )
297 reTarget
= MouseHypertext
;
304 sal_Bool
OutlinerView::MouseMove( const MouseEvent
& rMEvt
)
306 DBG_CHKTHIS(OutlinerView
,0);
308 if( ( pOwner
->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT
) || pEditView
->GetEditEngine()->IsInSelectionMode())
309 return pEditView
->MouseMove( rMEvt
);
311 Point
aMousePosWin( pEditView
->GetWindow()->PixelToLogic( rMEvt
.GetPosPixel() ) );
312 if( !pEditView
->GetOutputArea().IsInside( aMousePosWin
) )
315 Pointer aPointer
= GetPointer( rMEvt
.GetPosPixel() );
316 pEditView
->GetWindow()->SetPointer( aPointer
);
317 return pEditView
->MouseMove( rMEvt
);
321 sal_Bool
OutlinerView::MouseButtonDown( const MouseEvent
& rMEvt
)
323 DBG_CHKTHIS(OutlinerView
,0);
324 if ( ( pOwner
->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT
) || pEditView
->GetEditEngine()->IsInSelectionMode() )
325 return pEditView
->MouseButtonDown( rMEvt
);
327 Point
aMousePosWin( pEditView
->GetWindow()->PixelToLogic( rMEvt
.GetPosPixel() ) );
328 if( !pEditView
->GetOutputArea().IsInside( aMousePosWin
) )
331 Pointer aPointer
= GetPointer( rMEvt
.GetPosPixel() );
332 pEditView
->GetWindow()->SetPointer( aPointer
);
335 sal_Int32 nPara
= ImpCheckMousePos( rMEvt
.GetPosPixel(), eTarget
);
336 if ( eTarget
== MouseBullet
)
338 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
339 sal_Bool bHasChildren
= (pPara
&& pOwner
->pParaList
->HasChildren(pPara
));
340 if( rMEvt
.GetClicks() == 1 )
342 sal_Int32 nEndPara
= nPara
;
343 if ( bHasChildren
&& pOwner
->pParaList
->HasVisibleChildren(pPara
) )
344 nEndPara
+= pOwner
->pParaList
->GetChildCount( pPara
);
345 // The selection is inverted, so that EditEngine does not scroll
346 ESelection
aSel(nEndPara
, EE_TEXTPOS_ALL
, nPara
, 0 );
347 pEditView
->SetSelection( aSel
);
349 else if( rMEvt
.GetClicks() == 2 && bHasChildren
)
350 ImpToggleExpand( pPara
);
352 aDDStartPosPix
= rMEvt
.GetPosPixel();
353 aDDStartPosRef
=pEditView
->GetWindow()->PixelToLogic( aDDStartPosPix
,pOwner
->GetRefMapMode());
357 // special case for outliner view in impress, check if double click hits the page icon for toggle
358 if( (nPara
== EE_PARA_NOT_FOUND
) && (pOwner
->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEVIEW
) && (eTarget
== MouseText
) && (rMEvt
.GetClicks() == 2) )
360 ESelection
aSel( pEditView
->GetSelection() );
361 nPara
= aSel
.nStartPara
;
362 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
363 if( (pPara
&& pOwner
->pParaList
->HasChildren(pPara
)) && pPara
->HasFlag(PARAFLAG_ISPAGE
) )
365 ImpToggleExpand( pPara
);
368 return pEditView
->MouseButtonDown( rMEvt
);
372 sal_Bool
OutlinerView::MouseButtonUp( const MouseEvent
& rMEvt
)
374 DBG_CHKTHIS(OutlinerView
,0);
375 if ( ( pOwner
->ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT
) || pEditView
->GetEditEngine()->IsInSelectionMode() )
376 return pEditView
->MouseButtonUp( rMEvt
);
378 Point
aMousePosWin( pEditView
->GetWindow()->PixelToLogic( rMEvt
.GetPosPixel() ) );
379 if( !pEditView
->GetOutputArea().IsInside( aMousePosWin
) )
382 Pointer aPointer
= GetPointer( rMEvt
.GetPosPixel() );
383 pEditView
->GetWindow()->SetPointer( aPointer
);
385 return pEditView
->MouseButtonUp( rMEvt
);
388 void OutlinerView::ImpToggleExpand( Paragraph
* pPara
)
390 DBG_CHKTHIS(OutlinerView
,0);
392 sal_Int32 nPara
= pOwner
->pParaList
->GetAbsPos( pPara
);
393 pEditView
->SetSelection( ESelection( nPara
, 0, nPara
, 0 ) );
394 ImplExpandOrCollaps( nPara
, nPara
, !pOwner
->pParaList
->HasVisibleChildren( pPara
) );
395 pEditView
->ShowCursor();
398 sal_Int32
OutlinerView::Select( Paragraph
* pParagraph
, sal_Bool bSelect
,
399 sal_Bool bWithChildren
)
401 DBG_CHKTHIS(OutlinerView
,0);
403 sal_Int32 nPara
= pOwner
->pParaList
->GetAbsPos( pParagraph
);
408 sal_Int32 nChildCount
= 0;
410 nChildCount
= pOwner
->pParaList
->GetChildCount( pParagraph
);
412 ESelection
aSel( nPara
, 0,nPara
+nChildCount
, nEnd
);
413 pEditView
->SetSelection( aSel
);
414 return nChildCount
+1;
418 void OutlinerView::SetAttribs( const SfxItemSet
& rAttrs
)
420 DBG_CHKTHIS(OutlinerView
,0);
422 sal_Bool bUpdate
= pOwner
->pEditEngine
->GetUpdateMode();
423 pOwner
->pEditEngine
->SetUpdateMode( sal_False
);
425 if( !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled() )
426 pOwner
->UndoActionStart( OLUNDO_ATTR
);
428 ParaRange aSel
= ImpGetSelectedParagraphs( sal_False
);
430 pEditView
->SetAttribs( rAttrs
);
432 // Update Bullet text
433 for( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
435 pOwner
->ImplCheckNumBulletItem( nPara
);
436 pOwner
->ImplCalcBulletText( nPara
, sal_False
, sal_False
);
438 if( !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled() )
439 pOwner
->InsertUndo( new OutlinerUndoCheckPara( pOwner
, nPara
) );
442 if( !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled() )
443 pOwner
->UndoActionEnd( OLUNDO_ATTR
);
445 pEditView
->SetEditEngineUpdateMode( bUpdate
);
448 ParaRange
OutlinerView::ImpGetSelectedParagraphs( sal_Bool bIncludeHiddenChildren
)
450 DBG_CHKTHIS( OutlinerView
, 0 );
452 ESelection aSel
= pEditView
->GetSelection();
453 ParaRange
aParas( aSel
.nStartPara
, aSel
.nEndPara
);
456 // Record the invisible Children of the last Parents in the selection
457 if ( bIncludeHiddenChildren
)
459 Paragraph
* pLast
= pOwner
->pParaList
->GetParagraph( aParas
.nEndPara
);
460 if ( pOwner
->pParaList
->HasHiddenChildren( pLast
) )
461 aParas
.nEndPara
= aParas
.nEndPara
+ pOwner
->pParaList
->GetChildCount( pLast
);
466 // TODO: Name should be changed!
467 void OutlinerView::AdjustDepth( short nDX
)
472 void OutlinerView::Indent( short nDiff
)
474 DBG_CHKTHIS( OutlinerView
, 0 );
476 if( !nDiff
|| ( ( nDiff
> 0 ) && ImpCalcSelectedPages( sal_True
) && !pOwner
->ImpCanIndentSelectedPages( this ) ) )
479 const bool bOutlinerView
= pOwner
->pEditEngine
->GetControlWord() & EE_CNTRL_OUTLINER
;
480 sal_Bool bUpdate
= pOwner
->pEditEngine
->GetUpdateMode();
481 pOwner
->pEditEngine
->SetUpdateMode( sal_False
);
483 sal_Bool bUndo
= !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled();
486 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
488 sal_Int16 nMinDepth
= -1; // Optimization: Not to recalculate to manny parargaphs when not really needed.
490 ParaRange aSel
= ImpGetSelectedParagraphs( sal_True
);
491 for ( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
493 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
495 sal_Int16 nOldDepth
= pPara
->GetDepth();
496 sal_Int16 nNewDepth
= nOldDepth
+ nDiff
;
498 if( bOutlinerView
&& nPara
)
500 const bool bPage
= pPara
->HasFlag(PARAFLAG_ISPAGE
);
501 if( (bPage
&& (nDiff
== +1)) || (!bPage
&& (nDiff
== -1) && (nOldDepth
<= 0)) )
504 pOwner
->nDepthChangedHdlPrevDepth
= nOldDepth
;
505 pOwner
->mnDepthChangeHdlPrevFlags
= pPara
->nFlags
;
506 pOwner
->pHdlParagraph
= pPara
;
509 pPara
->RemoveFlag( PARAFLAG_ISPAGE
);
511 pPara
->SetFlag( PARAFLAG_ISPAGE
);
513 pOwner
->DepthChangedHdl();
514 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nPara
, 0, nPara
, 0 ) );
517 pOwner
->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner
, nPara
, pOwner
->mnDepthChangeHdlPrevFlags
, pPara
->nFlags
) );
523 // do not switch off numeration with tab
524 if( (nOldDepth
== 0) && (nNewDepth
== -1) )
527 // do not indent if there is no numeration enabled
528 if( nOldDepth
== -1 )
531 if ( nNewDepth
< pOwner
->nMinDepth
)
532 nNewDepth
= pOwner
->nMinDepth
;
533 if ( nNewDepth
> pOwner
->nMaxDepth
)
534 nNewDepth
= pOwner
->nMaxDepth
;
536 if( nOldDepth
< nMinDepth
)
537 nMinDepth
= nOldDepth
;
538 if( nNewDepth
< nMinDepth
)
539 nMinDepth
= nNewDepth
;
541 if( nOldDepth
!= nNewDepth
)
543 if ( ( nPara
== aSel
.nStartPara
) && aSel
.nStartPara
&& ( pOwner
->ImplGetOutlinerMode() != OUTLINERMODE_TEXTOBJECT
))
545 // Special case: the predecessor of an indented paragraph is
546 // invisible and is now on the same level as the visible
547 // paragraph. In this case, the next visible paragraph is
548 // searched for and fluffed.
550 Paragraph
* _pPara
= pOwner
->pParaList
->GetParagraph( aSel
.nStartPara
);
551 DBG_ASSERT(_pPara
->IsVisible(),"Selected Paragraph invisible ?!");
553 Paragraph
* pPrev
= pOwner
->pParaList
->GetParagraph( aSel
.nStartPara
-1 );
555 if( !pPrev
->IsVisible() && ( pPrev
->GetDepth() == nNewDepth
) )
557 // Predecessor is collapsed and is on the same level
558 // => find next visible paragraph and expand it
559 pPrev
= pOwner
->pParaList
->GetParent( pPrev
);
560 while( !pPrev
->IsVisible() )
561 pPrev
= pOwner
->pParaList
->GetParent( pPrev
);
563 pOwner
->Expand( pPrev
);
564 pOwner
->InvalidateBullet( pPrev
, pOwner
->pParaList
->GetAbsPos( pPrev
) );
568 pOwner
->nDepthChangedHdlPrevDepth
= nOldDepth
;
569 pOwner
->mnDepthChangeHdlPrevFlags
= pPara
->nFlags
;
570 pOwner
->pHdlParagraph
= pPara
;
572 pOwner
->ImplInitDepth( nPara
, nNewDepth
, sal_True
, sal_False
);
573 pOwner
->ImplCalcBulletText( nPara
, sal_False
, sal_False
);
575 if ( pOwner
->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT
)
576 pOwner
->ImplSetLevelDependendStyleSheet( nPara
);
579 pOwner
->DepthChangedHdl();
583 // Needs at least a repaint...
584 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nPara
, 0, nPara
, 0 ) );
588 sal_Int32 nParas
= pOwner
->pParaList
->GetParagraphCount();
589 for ( sal_Int32 n
= aSel
.nEndPara
+1; n
< nParas
; n
++ )
591 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( n
);
592 if ( pPara
->GetDepth() < nMinDepth
)
594 pOwner
->ImplCalcBulletText( n
, sal_False
, sal_False
);
599 pEditView
->SetEditEngineUpdateMode( sal_True
);
600 pEditView
->ShowCursor();
604 pOwner
->UndoActionEnd( OLUNDO_DEPTH
);
607 sal_Bool
OutlinerView::AdjustHeight( long nDY
)
609 DBG_CHKTHIS(OutlinerView
,0);
610 pEditView
->MoveParagraphs( nDY
);
611 return sal_True
; // remove return value...
614 Rectangle
OutlinerView::GetVisArea() const
616 DBG_CHKTHIS(OutlinerView
,0);
617 return pEditView
->GetVisArea();
620 void OutlinerView::Expand()
622 DBG_CHKTHIS( OutlinerView
, 0 );
623 ParaRange aParas
= ImpGetSelectedParagraphs( sal_False
);
624 ImplExpandOrCollaps( aParas
.nStartPara
, aParas
.nEndPara
, sal_True
);
628 void OutlinerView::Collapse()
630 DBG_CHKTHIS( OutlinerView
, 0 );
631 ParaRange aParas
= ImpGetSelectedParagraphs( sal_False
);
632 ImplExpandOrCollaps( aParas
.nStartPara
, aParas
.nEndPara
, sal_False
);
636 void OutlinerView::ExpandAll()
638 DBG_CHKTHIS( OutlinerView
, 0 );
639 ImplExpandOrCollaps( 0, pOwner
->pParaList
->GetParagraphCount()-1, sal_True
);
643 void OutlinerView::CollapseAll()
645 DBG_CHKTHIS(OutlinerView
,0);
646 ImplExpandOrCollaps( 0, pOwner
->pParaList
->GetParagraphCount()-1, sal_False
);
649 void OutlinerView::ImplExpandOrCollaps( sal_Int32 nStartPara
, sal_Int32 nEndPara
, sal_Bool bExpand
)
651 DBG_CHKTHIS( OutlinerView
, 0 );
653 sal_Bool bUpdate
= pOwner
->GetUpdateMode();
654 pOwner
->SetUpdateMode( sal_False
);
656 sal_Bool bUndo
= !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled();
658 pOwner
->UndoActionStart( bExpand
? OLUNDO_EXPAND
: OLUNDO_COLLAPSE
);
660 for ( sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; nPara
++ )
662 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
663 sal_Bool bDone
= bExpand
? pOwner
->Expand( pPara
) : pOwner
->Collapse( pPara
);
666 // The line under the paragraph should disappear ...
667 pOwner
->pEditEngine
->QuickMarkToBeRepainted( nPara
);
672 pOwner
->UndoActionEnd( bExpand
? OLUNDO_EXPAND
: OLUNDO_COLLAPSE
);
676 pOwner
->SetUpdateMode( sal_True
);
677 pEditView
->ShowCursor();
681 void OutlinerView::InsertText( const OutlinerParaObject
& rParaObj
)
683 // Like Paste, only EditView::Insert, instead of EditView::Paste.
684 // Actually not quite true that possible indentations must be corrected,
685 // but that comes later by a universal import. The indentation level is
686 // then determined right in the Inserted method.
687 // Possible structure:
688 // pImportInfo with DestPara, DestPos, nFormat, pParaObj...
689 // Possibly problematic:
690 // EditEngine, RTF => Splitting the area, later join together.
692 DBG_CHKTHIS(OutlinerView
,0);
694 if ( ImpCalcSelectedPages( sal_False
) && !pOwner
->ImpCanDeleteSelectedPages( this ) )
697 pOwner
->UndoActionStart( OLUNDO_INSERT
);
699 pOwner
->pEditEngine
->SetUpdateMode( sal_False
);
700 sal_Int32 nStart
, nParaCount
;
701 nParaCount
= pOwner
->pEditEngine
->GetParagraphCount();
702 sal_uInt16 nSize
= ImpInitPaste( nStart
);
703 pEditView
->InsertText( rParaObj
.GetTextObject() );
704 ImpPasted( nStart
, nParaCount
, nSize
);
705 pEditView
->SetEditEngineUpdateMode( sal_True
);
707 pOwner
->UndoActionEnd( OLUNDO_INSERT
);
709 pEditView
->ShowCursor( sal_True
, sal_True
);
714 void OutlinerView::Cut()
716 DBG_CHKTHIS(OutlinerView
,0);
717 if ( !ImpCalcSelectedPages( sal_False
) || pOwner
->ImpCanDeleteSelectedPages( this ) )
721 void OutlinerView::Paste()
723 DBG_CHKTHIS(OutlinerView
,0);
724 PasteSpecial(); // HACK(SD does not call PasteSpecial)
727 void OutlinerView::PasteSpecial()
729 DBG_CHKTHIS(OutlinerView
,0);
730 if ( !ImpCalcSelectedPages( sal_False
) || pOwner
->ImpCanDeleteSelectedPages( this ) )
732 pOwner
->UndoActionStart( OLUNDO_INSERT
);
734 pOwner
->pEditEngine
->SetUpdateMode( sal_False
);
735 pOwner
->bPasting
= sal_True
;
736 pEditView
->PasteSpecial();
738 if ( pOwner
->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT
)
740 const sal_Int32 nParaCount
= pOwner
->pEditEngine
->GetParagraphCount();
742 for( sal_Int32 nPara
= 0; nPara
< nParaCount
; nPara
++ )
743 pOwner
->ImplSetLevelDependendStyleSheet( nPara
);
746 pEditView
->SetEditEngineUpdateMode( sal_True
);
747 pOwner
->UndoActionEnd( OLUNDO_INSERT
);
748 pEditView
->ShowCursor( sal_True
, sal_True
);
752 void OutlinerView::CreateSelectionList (std::vector
<Paragraph
*> &aSelList
)
754 DBG_CHKTHIS( OutlinerView
, 0 );
756 ParaRange aParas
= ImpGetSelectedParagraphs( sal_True
);
758 for ( sal_Int32 nPara
= aParas
.nStartPara
; nPara
<= aParas
.nEndPara
; nPara
++ )
760 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
761 aSelList
.push_back(pPara
);
765 const SfxStyleSheet
* OutlinerView::GetStyleSheet() const
767 DBG_CHKTHIS(OutlinerView
,0);
768 return pEditView
->GetStyleSheet();
771 SfxStyleSheet
* OutlinerView::GetStyleSheet()
773 DBG_CHKTHIS(OutlinerView
,0);
774 return pEditView
->GetStyleSheet();
777 Pointer
OutlinerView::GetPointer( const Point
& rPosPixel
)
779 DBG_CHKTHIS(OutlinerView
,0);
782 ImpCheckMousePos( rPosPixel
, eTarget
);
784 PointerStyle ePointerStyle
= POINTER_ARROW
;
785 if ( eTarget
== MouseText
)
787 ePointerStyle
= GetOutliner()->IsVertical() ? POINTER_TEXT_VERTICAL
: POINTER_TEXT
;
789 else if ( eTarget
== MouseHypertext
)
791 ePointerStyle
= POINTER_REFHAND
;
793 else if ( eTarget
== MouseBullet
)
795 ePointerStyle
= POINTER_MOVE
;
798 return Pointer( ePointerStyle
);
802 sal_Int32
OutlinerView::ImpInitPaste( sal_Int32
& rStart
)
804 DBG_CHKTHIS(OutlinerView
,0);
805 pOwner
->bPasting
= sal_True
;
806 ESelection
aSelection( pEditView
->GetSelection() );
808 rStart
= aSelection
.nStartPara
;
809 sal_Int32 nSize
= aSelection
.nEndPara
- aSelection
.nStartPara
+ 1;
814 void OutlinerView::ImpPasted( sal_Int32 nStart
, sal_Int32 nPrevParaCount
, sal_Int32 nSize
)
816 DBG_CHKTHIS(OutlinerView
,0);
817 pOwner
->bPasting
= sal_False
;
818 sal_Int32 nCurParaCount
= pOwner
->pEditEngine
->GetParagraphCount();
819 if( nCurParaCount
< nPrevParaCount
)
820 nSize
= nSize
- ( nPrevParaCount
- nCurParaCount
);
822 nSize
= nSize
+ ( nCurParaCount
- nPrevParaCount
);
823 pOwner
->ImpTextPasted( nStart
, nSize
);
827 void OutlinerView::Command( const CommandEvent
& rCEvt
)
829 DBG_CHKTHIS(OutlinerView
,0);
830 pEditView
->Command( rCEvt
);
834 void OutlinerView::SelectRange( sal_Int32 nFirst
, sal_Int32 nCount
)
836 DBG_CHKTHIS(OutlinerView
,0);
837 sal_Int32 nLast
= nFirst
+nCount
;
838 nCount
= pOwner
->pParaList
->GetParagraphCount();
839 if( nLast
<= nCount
)
841 ESelection
aSel( nFirst
, 0, nLast
, EE_TEXTPOS_ALL
);
842 pEditView
->SetSelection( aSel
);
846 sal_Int32
OutlinerView::ImpCalcSelectedPages( sal_Bool bIncludeFirstSelected
)
848 DBG_CHKTHIS(OutlinerView
,0);
850 ESelection
aSel( pEditView
->GetSelection() );
853 sal_Int32 nPages
= 0;
854 sal_Int32 nFirstPage
= EE_PARA_MAX_COUNT
;
855 sal_Int32 nStartPara
= aSel
.nStartPara
;
856 if ( !bIncludeFirstSelected
)
857 nStartPara
++; // All paragraphs after StartPara will be deleted
858 for ( sal_Int32 nPara
= nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
860 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
861 DBG_ASSERT(pPara
, "ImpCalcSelectedPages: invalid Selection? ");
862 if( pPara
->HasFlag(PARAFLAG_ISPAGE
) )
865 if( nFirstPage
== EE_PARA_MAX_COUNT
)
872 pOwner
->nDepthChangedHdlPrevDepth
= nPages
;
873 pOwner
->pHdlParagraph
= 0;
874 pOwner
->mnFirstSelPage
= nFirstPage
;
881 void OutlinerView::ToggleBullets()
883 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
885 ESelection
aSel( pEditView
->GetSelection() );
888 const bool bUpdate
= pOwner
->pEditEngine
->GetUpdateMode();
889 pOwner
->pEditEngine
->SetUpdateMode( sal_False
);
891 sal_Int16 nNewDepth
= -2;
892 const SvxNumRule
* pDefaultBulletNumRule
= 0;
894 for ( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
896 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
897 DBG_ASSERT(pPara
, "OutlinerView::ToggleBullets(), illegal selection?");
901 if( nNewDepth
== -2 )
903 nNewDepth
= (pOwner
->GetDepth(nPara
) == -1) ? 0 : -1;
904 if ( nNewDepth
== 0 )
906 // determine default numbering rule for bullets
907 const ESelection
aSelection(nPara
, 0);
908 const SfxItemSet
aTmpSet(pOwner
->pEditEngine
->GetAttribs(aSelection
));
909 const SfxPoolItem
& rPoolItem
= aTmpSet
.GetPool()->GetDefaultItem( EE_PARA_NUMBULLET
);
910 const SvxNumBulletItem
* pNumBulletItem
= dynamic_cast< const SvxNumBulletItem
* >(&rPoolItem
);
911 pDefaultBulletNumRule
= pNumBulletItem
? pNumBulletItem
->GetNumRule() : 0;
915 pOwner
->SetDepth( pPara
, nNewDepth
);
917 if( nNewDepth
== -1 )
919 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs( nPara
);
920 if ( rAttrs
.GetItemState( EE_PARA_BULLETSTATE
) == SFX_ITEM_SET
)
922 SfxItemSet
aAttrs(rAttrs
);
923 aAttrs
.ClearItem( EE_PARA_BULLETSTATE
);
924 pOwner
->SetParaAttribs( nPara
, aAttrs
);
929 if ( pDefaultBulletNumRule
)
931 const SvxNumberFormat
* pFmt
= pOwner
->GetNumberFormat( nPara
);
933 || ( pFmt
->GetNumberingType() != SVX_NUM_BITMAP
934 && pFmt
->GetNumberingType() != SVX_NUM_CHAR_SPECIAL
) )
936 SfxItemSet
aAttrs( pOwner
->GetParaAttribs( nPara
) );
937 SvxNumRule
aNewNumRule( *pDefaultBulletNumRule
);
938 aAttrs
.Put( SvxNumBulletItem( aNewNumRule
), EE_PARA_NUMBULLET
);
939 pOwner
->SetParaAttribs( nPara
, aAttrs
);
946 const sal_Int32 nParaCount
= pOwner
->pParaList
->GetParagraphCount();
947 pOwner
->ImplCheckParagraphs( aSel
.nStartPara
, nParaCount
);
949 sal_Int32 nEndPara
= (nParaCount
> 0) ? nParaCount
-1 : nParaCount
;
950 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( aSel
.nStartPara
, 0, nEndPara
, 0 ) );
952 pOwner
->pEditEngine
->SetUpdateMode( bUpdate
);
954 pOwner
->UndoActionEnd( OLUNDO_DEPTH
);
958 void OutlinerView::ToggleBulletsNumbering(
960 const bool bHandleBullets
,
961 const SvxNumRule
* pNumRule
)
963 ESelection
aSel( pEditView
->GetSelection() );
966 bool bToggleOn
= true;
970 const sal_Int16
nBulletNumberingStatus( pOwner
->GetBulletsNumberingStatus( aSel
.nStartPara
, aSel
.nEndPara
) );
971 if ( nBulletNumberingStatus
!= 0 && bHandleBullets
)
973 // not all paragraphs have bullets and method called to toggle bullets --> bullets on
976 else if ( nBulletNumberingStatus
!= 1 && !bHandleBullets
)
978 // not all paragraphs have numbering and method called to toggle numberings --> numberings on
984 // apply bullets/numbering for selected paragraphs
985 ApplyBulletsNumbering( bHandleBullets
, pNumRule
, bToggle
, true );
989 // switch off bullets/numbering for selected paragraphs
990 SwitchOffBulletsNumbering( true );
997 void OutlinerView::EnableBullets()
999 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
1001 ESelection
aSel( pEditView
->GetSelection() );
1004 const bool bUpdate
= pOwner
->pEditEngine
->GetUpdateMode();
1005 pOwner
->pEditEngine
->SetUpdateMode( sal_False
);
1007 for ( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
1009 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
1010 DBG_ASSERT(pPara
, "OutlinerView::EnableBullets(), illegal selection?");
1012 if( pPara
&& (pOwner
->GetDepth(nPara
) == -1) )
1014 pOwner
->SetDepth( pPara
, 0 );
1018 sal_Int32 nParaCount
= pOwner
->pParaList
->GetParagraphCount();
1019 pOwner
->ImplCheckParagraphs( aSel
.nStartPara
, nParaCount
);
1021 sal_Int32 nEndPara
= (nParaCount
> 0) ? nParaCount
-1 : nParaCount
;
1022 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( aSel
.nStartPara
, 0, nEndPara
, 0 ) );
1024 pOwner
->pEditEngine
->SetUpdateMode( bUpdate
);
1026 pOwner
->UndoActionEnd( OLUNDO_DEPTH
);
1030 void OutlinerView::ApplyBulletsNumbering(
1031 const bool bHandleBullets
,
1032 const SvxNumRule
* pNewNumRule
,
1033 const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule
,
1034 const bool bAtSelection
)
1036 if (!pOwner
|| !pOwner
->pEditEngine
|| !pOwner
->pParaList
)
1041 pOwner
->UndoActionStart(OLUNDO_DEPTH
);
1042 const sal_Bool bUpdate
= pOwner
->pEditEngine
->GetUpdateMode();
1043 pOwner
->pEditEngine
->SetUpdateMode(sal_False
);
1045 sal_Int32 nStartPara
= 0;
1046 sal_Int32 nEndPara
= 0;
1049 ESelection
aSel( pEditView
->GetSelection() );
1051 nStartPara
= aSel
.nStartPara
;
1052 nEndPara
= aSel
.nEndPara
;
1057 nEndPara
= pOwner
->pParaList
->GetParagraphCount() - 1;
1060 for (sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; ++nPara
)
1062 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph(nPara
);
1063 DBG_ASSERT(pPara
, "OutlinerView::ApplyBulletsNumbering(..), illegal selection?");
1067 const sal_Int16 nDepth
= pOwner
->GetDepth(nPara
);
1070 pOwner
->SetDepth( pPara
, 0 );
1073 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs(nPara
);
1074 SfxItemSet
aAttrs(rAttrs
);
1075 aAttrs
.Put(SfxBoolItem(EE_PARA_BULLETSTATE
, true));
1077 // apply new numbering rule
1080 bool bApplyNumRule
= false;
1081 if ( !bCheckCurrentNumRuleBeforeApplyingNewNumRule
)
1083 bApplyNumRule
= true;
1087 const SvxNumberFormat
* pFmt
= pOwner
->GetNumberFormat(nPara
);
1090 bApplyNumRule
= true;
1094 sal_Int16 nNumType
= pFmt
->GetNumberingType();
1096 && nNumType
!= SVX_NUM_BITMAP
&& nNumType
!= SVX_NUM_CHAR_SPECIAL
)
1098 // Set to Normal bullet, old bullet type is Numbering bullet.
1099 bApplyNumRule
= true;
1101 else if ( !bHandleBullets
1102 && (nNumType
== SVX_NUM_BITMAP
|| nNumType
== SVX_NUM_CHAR_SPECIAL
))
1104 // Set to Numbering bullet, old bullet type is Normal bullet.
1105 bApplyNumRule
= true;
1110 if ( bApplyNumRule
)
1112 SvxNumRule
aNewRule(*pNewNumRule
);
1114 // Get old bullet space.
1116 const SfxPoolItem
* pPoolItem
=NULL
;
1117 SfxItemState eState
= rAttrs
.GetItemState(EE_PARA_NUMBULLET
, sal_False
, &pPoolItem
);
1118 if (eState
!= SFX_ITEM_SET
)
1120 // Use default value when has not contain bullet item.
1121 ESelection
aSelection(nPara
, 0);
1122 SfxItemSet
aTmpSet(pOwner
->pEditEngine
->GetAttribs(aSelection
));
1123 pPoolItem
= aTmpSet
.GetItem(EE_PARA_NUMBULLET
);
1126 const SvxNumBulletItem
* pNumBulletItem
= dynamic_cast< const SvxNumBulletItem
* >(pPoolItem
);
1129 const sal_uInt16 nLevelCnt
= std::min(pNumBulletItem
->GetNumRule()->GetLevelCount(), aNewRule
.GetLevelCount());
1130 for ( sal_uInt16 nLevel
= 0; nLevel
< nLevelCnt
; ++nLevel
)
1132 const SvxNumberFormat
* pOldFmt
= pNumBulletItem
->GetNumRule()->Get(nLevel
);
1133 const SvxNumberFormat
* pNewFmt
= aNewRule
.Get(nLevel
);
1134 if (pOldFmt
&& pNewFmt
&& (pOldFmt
->GetFirstLineOffset() != pNewFmt
->GetFirstLineOffset() || pOldFmt
->GetAbsLSpace() != pNewFmt
->GetAbsLSpace()))
1136 SvxNumberFormat
* pNewFmtClone
= new SvxNumberFormat(*pNewFmt
);
1137 pNewFmtClone
->SetFirstLineOffset(pOldFmt
->GetFirstLineOffset());
1138 pNewFmtClone
->SetAbsLSpace(pOldFmt
->GetAbsLSpace());
1139 aNewRule
.SetLevel(nLevel
, pNewFmtClone
);
1140 delete pNewFmtClone
;
1146 aAttrs
.Put(SvxNumBulletItem(aNewRule
), EE_PARA_NUMBULLET
);
1149 pOwner
->SetParaAttribs(nPara
, aAttrs
);
1153 const sal_uInt16 nParaCount
= (sal_uInt16
) (pOwner
->pParaList
->GetParagraphCount());
1154 pOwner
->ImplCheckParagraphs( nStartPara
, nParaCount
);
1155 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nStartPara
, 0, nParaCount
, 0 ) );
1157 pOwner
->pEditEngine
->SetUpdateMode( bUpdate
);
1159 pOwner
->UndoActionEnd( OLUNDO_DEPTH
);
1165 void OutlinerView::SwitchOffBulletsNumbering(
1166 const bool bAtSelection
)
1168 sal_Int32 nStartPara
= 0;
1169 sal_Int32 nEndPara
= 0;
1172 ESelection
aSel( pEditView
->GetSelection() );
1174 nStartPara
= aSel
.nStartPara
;
1175 nEndPara
= aSel
.nEndPara
;
1180 nEndPara
= pOwner
->pParaList
->GetParagraphCount() - 1;
1183 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
1184 const bool bUpdate
= pOwner
->pEditEngine
->GetUpdateMode();
1185 pOwner
->pEditEngine
->SetUpdateMode( sal_False
);
1187 for ( sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; ++nPara
)
1189 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
1190 DBG_ASSERT(pPara
, "OutlinerView::SwitchOffBulletsNumbering(...), illegal paragraph index?");
1194 pOwner
->SetDepth( pPara
, -1 );
1196 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs( nPara
);
1197 if (rAttrs
.GetItemState( EE_PARA_BULLETSTATE
) == SFX_ITEM_SET
)
1199 SfxItemSet
aAttrs(rAttrs
);
1200 aAttrs
.ClearItem( EE_PARA_BULLETSTATE
);
1201 pOwner
->SetParaAttribs( nPara
, aAttrs
);
1206 const sal_uInt16 nParaCount
= (sal_uInt16
) (pOwner
->pParaList
->GetParagraphCount());
1207 pOwner
->ImplCheckParagraphs( nStartPara
, nParaCount
);
1208 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nStartPara
, 0, nParaCount
, 0 ) );
1210 pOwner
->pEditEngine
->SetUpdateMode( bUpdate
);
1211 pOwner
->UndoActionEnd( OLUNDO_DEPTH
);
1215 void OutlinerView::RemoveAttribsKeepLanguages( sal_Bool bRemoveParaAttribs
)
1217 RemoveAttribs( bRemoveParaAttribs
, 0, sal_True
/*keep language attribs*/ );
1220 void OutlinerView::RemoveAttribs( sal_Bool bRemoveParaAttribs
, sal_uInt16 nWhich
, sal_Bool bKeepLanguages
)
1222 DBG_CHKTHIS(OutlinerView
,0);
1223 sal_Bool bUpdate
= pOwner
->GetUpdateMode();
1224 pOwner
->SetUpdateMode( sal_False
);
1225 pOwner
->UndoActionStart( OLUNDO_ATTR
);
1227 pEditView
->RemoveAttribsKeepLanguages( bRemoveParaAttribs
);
1229 pEditView
->RemoveAttribs( bRemoveParaAttribs
, nWhich
);
1230 if ( bRemoveParaAttribs
)
1232 // Loop through all paragraphs and set indentation and level
1233 ESelection aSel
= pEditView
->GetSelection();
1235 for ( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
1237 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
1238 pOwner
->ImplInitDepth( nPara
, pPara
->GetDepth(), sal_False
, sal_False
);
1241 pOwner
->UndoActionEnd( OLUNDO_ATTR
);
1242 pOwner
->SetUpdateMode( bUpdate
);
1247 // ======================================================================
1248 // ====================== Simple pass-through =======================
1249 // ======================================================================
1252 void OutlinerView::InsertText( const XubString
& rNew
, sal_Bool bSelect
)
1254 DBG_CHKTHIS(OutlinerView
,0);
1255 if( pOwner
->bFirstParaIsEmpty
)
1256 pOwner
->Insert( String() );
1257 pEditView
->InsertText( rNew
, bSelect
);
1260 void OutlinerView::SetVisArea( const Rectangle
& rRect
)
1262 DBG_CHKTHIS(OutlinerView
,0);
1263 pEditView
->SetVisArea( rRect
);
1267 void OutlinerView::SetSelection( const ESelection
& rSel
)
1269 DBG_CHKTHIS(OutlinerView
,0);
1270 pEditView
->SetSelection( rSel
);
1273 void OutlinerView::SetReadOnly( sal_Bool bReadOnly
)
1275 DBG_CHKTHIS(OutlinerView
,0);
1276 pEditView
->SetReadOnly( bReadOnly
);
1279 sal_Bool
OutlinerView::IsReadOnly() const
1281 DBG_CHKTHIS(OutlinerView
,0);
1282 return pEditView
->IsReadOnly();
1285 sal_Bool
OutlinerView::HasSelection() const
1287 DBG_CHKTHIS(OutlinerView
,0);
1288 return pEditView
->HasSelection();
1292 void OutlinerView::ShowCursor( sal_Bool bGotoCursor
)
1294 DBG_CHKTHIS(OutlinerView
,0);
1295 pEditView
->ShowCursor( bGotoCursor
);
1299 void OutlinerView::HideCursor()
1301 DBG_CHKTHIS(OutlinerView
,0);
1302 pEditView
->HideCursor();
1306 void OutlinerView::SetWindow( Window
* pWin
)
1308 DBG_CHKTHIS(OutlinerView
,0);
1309 pEditView
->SetWindow( pWin
);
1313 Window
* OutlinerView::GetWindow() const
1315 DBG_CHKTHIS(OutlinerView
,0);
1316 return pEditView
->GetWindow();
1320 void OutlinerView::SetOutputArea( const Rectangle
& rRect
)
1322 DBG_CHKTHIS(OutlinerView
,0);
1323 pEditView
->SetOutputArea( rRect
);
1327 Rectangle
OutlinerView::GetOutputArea() const
1329 DBG_CHKTHIS(OutlinerView
,0);
1330 return pEditView
->GetOutputArea();
1334 XubString
OutlinerView::GetSelected() const
1336 DBG_CHKTHIS(OutlinerView
,0);
1337 return pEditView
->GetSelected();
1340 EESpellState
OutlinerView::StartSpeller( sal_Bool bMultiDoc
)
1342 DBG_CHKTHIS(OutlinerView
,0);
1343 return pEditView
->StartSpeller( bMultiDoc
);
1346 EESpellState
OutlinerView::StartThesaurus()
1348 DBG_CHKTHIS(OutlinerView
,0);
1349 return pEditView
->StartThesaurus();
1353 void OutlinerView::StartTextConversion(
1354 LanguageType nSrcLang
, LanguageType nDestLang
, const Font
*pDestFont
,
1355 sal_Int32 nOptions
, sal_Bool bIsInteractive
, sal_Bool bMultipleDoc
)
1357 DBG_CHKTHIS(OutlinerView
,0);
1359 (LANGUAGE_KOREAN
== nSrcLang
&& LANGUAGE_KOREAN
== nDestLang
) ||
1360 (LANGUAGE_CHINESE_SIMPLIFIED
== nSrcLang
&& LANGUAGE_CHINESE_TRADITIONAL
== nDestLang
) ||
1361 (LANGUAGE_CHINESE_TRADITIONAL
== nSrcLang
&& LANGUAGE_CHINESE_SIMPLIFIED
== nDestLang
)
1364 pEditView
->StartTextConversion( nSrcLang
, nDestLang
, pDestFont
, nOptions
, bIsInteractive
, bMultipleDoc
);
1368 OSL_FAIL( "unexpected language" );
1373 sal_uInt16
OutlinerView::StartSearchAndReplace( const SvxSearchItem
& rSearchItem
)
1375 DBG_CHKTHIS(OutlinerView
,0);
1376 return pEditView
->StartSearchAndReplace( rSearchItem
);
1379 void OutlinerView::TransliterateText( sal_Int32 nTransliterationMode
)
1381 DBG_CHKTHIS(OutlinerView
,0);
1382 pEditView
->TransliterateText( nTransliterationMode
);
1387 ESelection
OutlinerView::GetSelection()
1389 DBG_CHKTHIS(OutlinerView
,0);
1390 return pEditView
->GetSelection();
1394 void OutlinerView::Scroll( long nHorzScroll
, long nVertScroll
)
1396 DBG_CHKTHIS(OutlinerView
,0);
1397 pEditView
->Scroll( nHorzScroll
, nVertScroll
);
1401 void OutlinerView::SetControlWord( sal_uLong nWord
)
1403 DBG_CHKTHIS(OutlinerView
,0);
1404 pEditView
->SetControlWord( nWord
);
1408 sal_uLong
OutlinerView::GetControlWord() const
1410 DBG_CHKTHIS(OutlinerView
,0);
1411 return pEditView
->GetControlWord();
1415 void OutlinerView::SetAnchorMode( EVAnchorMode eMode
)
1417 DBG_CHKTHIS(OutlinerView
,0);
1418 pEditView
->SetAnchorMode( eMode
);
1422 EVAnchorMode
OutlinerView::GetAnchorMode() const
1424 DBG_CHKTHIS(OutlinerView
,0);
1425 return pEditView
->GetAnchorMode();
1428 void OutlinerView::Copy()
1430 DBG_CHKTHIS(OutlinerView
,0);
1435 void OutlinerView::InsertField( const SvxFieldItem
& rFld
)
1437 DBG_CHKTHIS(OutlinerView
,0);
1438 pEditView
->InsertField( rFld
);
1441 const SvxFieldItem
* OutlinerView::GetFieldUnderMousePointer() const
1443 DBG_CHKTHIS(OutlinerView
,0);
1444 return pEditView
->GetFieldUnderMousePointer();
1447 const SvxFieldItem
* OutlinerView::GetFieldAtSelection() const
1449 DBG_CHKTHIS(OutlinerView
,0);
1450 return pEditView
->GetFieldAtSelection();
1453 void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel
)
1455 DBG_CHKTHIS(OutlinerView
,0);
1456 pEditView
->SetInvalidateMore( nPixel
);
1460 sal_uInt16
OutlinerView::GetInvalidateMore() const
1462 DBG_CHKTHIS(OutlinerView
,0);
1463 return pEditView
->GetInvalidateMore();
1467 sal_Bool
OutlinerView::IsCursorAtWrongSpelledWord( sal_Bool bMarkIfWrong
)
1469 DBG_CHKTHIS(OutlinerView
,0);
1470 return pEditView
->IsCursorAtWrongSpelledWord( bMarkIfWrong
);
1474 sal_Bool
OutlinerView::IsWrongSpelledWordAtPos( const Point
& rPosPixel
, sal_Bool bMarkIfWrong
)
1476 DBG_CHKTHIS(OutlinerView
,0);
1477 return pEditView
->IsWrongSpelledWordAtPos( rPosPixel
, bMarkIfWrong
);
1480 void OutlinerView::ExecuteSpellPopup( const Point
& rPosPixel
, Link
* pStartDlg
)
1482 DBG_CHKTHIS(OutlinerView
,0);
1483 pEditView
->ExecuteSpellPopup( rPosPixel
, pStartDlg
);
1486 sal_uLong
OutlinerView::Read( SvStream
& rInput
, const String
& rBaseURL
, EETextFormat eFormat
, sal_Bool bSelect
, SvKeyValueIterator
* pHTTPHeaderAttrs
)
1488 DBG_CHKTHIS(OutlinerView
,0);
1489 sal_Int32 nOldParaCount
= pEditView
->GetEditEngine()->GetParagraphCount();
1490 ESelection aOldSel
= pEditView
->GetSelection();
1493 sal_uLong nRet
= pEditView
->Read( rInput
, rBaseURL
, eFormat
, bSelect
, pHTTPHeaderAttrs
);
1495 long nParaDiff
= pEditView
->GetEditEngine()->GetParagraphCount() - nOldParaCount
;
1496 sal_Int32 nChangesStart
= aOldSel
.nStartPara
;
1497 sal_Int32 nChangesEnd
= nChangesStart
+ nParaDiff
+ (aOldSel
.nEndPara
-aOldSel
.nStartPara
);
1499 for ( sal_Int32 n
= nChangesStart
; n
<= nChangesEnd
; n
++ )
1501 if ( eFormat
== EE_FORMAT_BIN
)
1503 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs( n
);
1504 const SfxInt16Item
& rLevel
= (const SfxInt16Item
&) rAttrs
.Get( EE_PARA_OUTLLEVEL
);
1505 sal_uInt16 nDepth
= rLevel
.GetValue();
1506 pOwner
->ImplInitDepth( n
, nDepth
, sal_False
);
1509 if ( pOwner
->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEOBJECT
)
1510 pOwner
->ImplSetLevelDependendStyleSheet( n
);
1513 if ( eFormat
!= EE_FORMAT_BIN
)
1515 pOwner
->ImpFilterIndents( nChangesStart
, nChangesEnd
);
1521 void OutlinerView::SetBackgroundColor( const Color
& rColor
)
1523 DBG_CHKTHIS(OutlinerView
,0);
1524 pEditView
->SetBackgroundColor( rColor
);
1528 Color
OutlinerView::GetBackgroundColor()
1530 DBG_CHKTHIS(OutlinerView
,0);
1531 return pEditView
->GetBackgroundColor();
1534 SfxItemSet
OutlinerView::GetAttribs()
1536 DBG_CHKTHIS(OutlinerView
,0);
1537 return pEditView
->GetAttribs();
1540 sal_uInt16
OutlinerView::GetSelectedScriptType() const
1542 DBG_CHKTHIS(OutlinerView
,0);
1543 return pEditView
->GetSelectedScriptType();
1546 String
OutlinerView::GetSurroundingText() const
1548 DBG_CHKTHIS(OutlinerView
,0);
1549 return pEditView
->GetSurroundingText();
1552 Selection
OutlinerView::GetSurroundingTextSelection() const
1554 DBG_CHKTHIS(OutlinerView
,0);
1555 return pEditView
->GetSurroundingTextSelection();
1559 // ======================================================================
1560 // ===== some code for thesaurus sub menu within context menu
1561 // ======================================================================
1565 bool isSingleScriptType( sal_uInt16 nScriptType
)
1567 sal_uInt8 nScriptCount
= 0;
1569 if (nScriptType
& SCRIPTTYPE_LATIN
)
1571 if (nScriptType
& SCRIPTTYPE_ASIAN
)
1573 if (nScriptType
& SCRIPTTYPE_COMPLEX
)
1576 return nScriptCount
== 1;
1581 // returns: true if a word for thesaurus look-up was found at the current cursor position.
1582 // The status string will be word + iso language string (e.g. "light#en-US")
1583 bool EDITENG_DLLPUBLIC
GetStatusValueForThesaurusFromContext(
1585 LanguageType
&rLang
,
1586 const EditView
&rEditView
)
1588 // get text and locale for thesaurus look up
1590 EditEngine
*pEditEngine
= rEditView
.GetEditEngine();
1591 ESelection
aTextSel( rEditView
.GetSelection() );
1592 if (!aTextSel
.HasRange())
1593 aTextSel
= pEditEngine
->GetWord( aTextSel
, i18n::WordType::DICTIONARY_WORD
);
1594 aText
= pEditEngine
->GetText( aTextSel
);
1597 if (!isSingleScriptType(pEditEngine
->GetScriptType(aTextSel
)))
1600 LanguageType nLang
= pEditEngine
->GetLanguage( aTextSel
.nStartPara
, aTextSel
.nStartPos
);
1601 OUString
aLangText( LanguageTag( nLang
).getBcp47() );
1603 // set word and locale to look up as status value
1604 OUString aStatusVal
= aText
+ "#" + aLangText
;
1606 rStatusVal
= aStatusVal
;
1609 return aText
.getLength() > 0;
1613 void EDITENG_DLLPUBLIC
ReplaceTextWithSynonym( EditView
&rEditView
, const String
&rSynonmText
)
1615 // get selection to use
1616 ESelection
aCurSel( rEditView
.GetSelection() );
1617 if (!rEditView
.HasSelection())
1619 // select the same word that was used in GetStatusValueForThesaurusFromContext by calling GetWord.
1620 // (In the end both functions will call ImpEditEngine::SelectWord)
1621 rEditView
.SelectCurrentWord( i18n::WordType::DICTIONARY_WORD
);
1622 aCurSel
= rEditView
.GetSelection();
1626 rEditView
.InsertText( rSynonmText
);
1627 rEditView
.ShowCursor( sal_True
, sal_False
);
1631 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */