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 .
21 #include <com/sun/star/i18n/WordType.hpp>
23 #include <svl/itempool.hxx>
24 #include <editeng/editeng.hxx>
25 #include <editeng/editview.hxx>
26 #include <editeng/editdata.hxx>
28 #include <svl/style.hxx>
29 #include <svl/languageoptions.hxx>
30 #include <i18nlangtag/languagetag.hxx>
32 #include <editeng/outliner.hxx>
33 #include <outleeng.hxx>
34 #include "paralist.hxx"
35 #include "outlundo.hxx"
36 #include <editeng/outlobj.hxx>
37 #include <editeng/flditem.hxx>
38 #include <editeng/eeitem.hxx>
39 #include <editeng/numitem.hxx>
40 #include <vcl/window.hxx>
41 #include <vcl/event.hxx>
42 #include <vcl/ptrstyle.hxx>
43 #include <svl/itemset.hxx>
44 #include <svl/eitem.hxx>
45 #include <editeng/editstat.hxx>
46 #include <sal/log.hxx>
47 #include <osl/diagnose.h>
48 #include <tools/debug.hxx>
50 using namespace ::com::sun::star
;
53 OutlinerView::OutlinerView( Outliner
* pOut
, vcl::Window
* pWin
)
56 pEditView
.reset( new EditView( pOut
->pEditEngine
.get(), pWin
) );
59 OutlinerView::~OutlinerView()
63 void OutlinerView::Paint( const tools::Rectangle
& rRect
, OutputDevice
* pTargetDevice
)
65 // For the first Paint/KeyInput/Drop an empty Outliner is turned into
66 // an Outliner with exactly one paragraph.
67 if( pOwner
->bFirstParaIsEmpty
)
68 pOwner
->Insert( OUString() );
70 pEditView
->Paint( rRect
, pTargetDevice
);
73 bool OutlinerView::PostKeyEvent( const KeyEvent
& rKEvt
, vcl::Window
const * pFrameWin
)
75 // For the first Paint/KeyInput/Drop an empty Outliner is turned into
76 // an Outliner with exactly one paragraph.
77 if( pOwner
->bFirstParaIsEmpty
)
78 pOwner
->Insert( OUString() );
80 bool bKeyProcessed
= false;
81 ESelection
aSel( pEditView
->GetSelection() );
82 bool bSelection
= aSel
.HasRange();
83 vcl::KeyCode aKeyCode
= rKEvt
.GetKeyCode();
84 KeyFuncType eFunc
= aKeyCode
.GetFunction();
85 sal_uInt16 nCode
= aKeyCode
.GetCode();
86 bool bReadOnly
= IsReadOnly();
88 if( bSelection
&& ( nCode
!= KEY_TAB
) && EditEngine::DoesKeyChangeText( rKEvt
) )
90 if ( ImpCalcSelectedPages( false ) && !pOwner
->ImpCanDeleteSelectedPages( this ) )
94 if ( eFunc
!= KeyFuncType::DONTKNOW
)
98 case KeyFuncType::CUT
:
103 bKeyProcessed
= true;
107 case KeyFuncType::COPY
:
110 bKeyProcessed
= true;
113 case KeyFuncType::PASTE
:
118 bKeyProcessed
= true;
122 case KeyFuncType::DELETE
:
124 if( !bReadOnly
&& !bSelection
&& ( pOwner
->GetOutlinerMode() != OutlinerMode::TextObject
) )
126 if( aSel
.nEndPos
== pOwner
->pEditEngine
->GetTextLen( aSel
.nEndPara
) )
128 Paragraph
* pNext
= pOwner
->pParaList
->GetParagraph( aSel
.nEndPara
+1 );
129 if( pNext
&& pNext
->HasFlag(ParaFlag::ISPAGE
) )
131 if( !pOwner
->ImpCanDeleteSelectedPages( this, aSel
.nEndPara
, 1 ) )
138 default: // is then possibly edited below.
139 eFunc
= KeyFuncType::DONTKNOW
;
142 if ( eFunc
== KeyFuncType::DONTKNOW
)
148 if ( !bReadOnly
&& !aKeyCode
.IsMod1() && !aKeyCode
.IsMod2() )
150 if ( ( pOwner
->GetOutlinerMode() != OutlinerMode::TextObject
) &&
151 ( pOwner
->GetOutlinerMode() != OutlinerMode::TitleObject
) &&
152 ( bSelection
|| !aSel
.nStartPos
) )
154 Indent( aKeyCode
.IsShift() ? -1 : +1 );
155 bKeyProcessed
= true;
157 else if ( ( pOwner
->GetOutlinerMode() == OutlinerMode::TextObject
) &&
158 !bSelection
&& !aSel
.nEndPos
&& pOwner
->ImplHasNumberFormat( aSel
.nEndPara
) )
160 Indent( aKeyCode
.IsShift() ? -1 : +1 );
161 bKeyProcessed
= true;
168 if( !bReadOnly
&& !bSelection
&& aSel
.nEndPara
&& !aSel
.nEndPos
)
170 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( aSel
.nEndPara
);
171 Paragraph
* pPrev
= pOwner
->pParaList
->GetParagraph( aSel
.nEndPara
-1 );
172 if( !pPrev
->IsVisible() )
174 if( !pPara
->GetDepth() )
176 if(!pOwner
->ImpCanDeleteSelectedPages(this, aSel
.nEndPara
, 1 ) )
186 // Special treatment: hard return at the end of a paragraph,
187 // which has collapsed subparagraphs.
188 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( aSel
.nEndPara
);
190 if( !aKeyCode
.IsShift() )
192 // ImpGetCursor again???
194 aSel
.nEndPos
== pOwner
->pEditEngine
->GetTextLen( aSel
.nEndPara
) )
196 sal_Int32 nChildren
= pOwner
->pParaList
->GetChildCount(pPara
);
197 if( nChildren
&& !pOwner
->pParaList
->HasVisibleChildren(pPara
))
199 pOwner
->UndoActionStart( OLUNDO_INSERT
);
200 sal_Int32 nTemp
= aSel
.nEndPara
;
202 nTemp
++; // insert above next Non-Child
203 SAL_WARN_IF( nTemp
< 0, "editeng", "OutlinerView::PostKeyEvent - overflow");
206 pOwner
->Insert( OUString(),nTemp
,pPara
->GetDepth());
207 // Position the cursor
208 ESelection
aTmpSel(nTemp
,0,nTemp
,0);
209 pEditView
->SetSelection( aTmpSel
);
211 pEditView
->ShowCursor();
212 pOwner
->UndoActionEnd();
213 bKeyProcessed
= true;
217 if( !bKeyProcessed
&& !bSelection
&&
218 !aKeyCode
.IsShift() && aKeyCode
.IsMod1() &&
219 ( aSel
.nEndPos
== pOwner
->pEditEngine
->GetTextLen(aSel
.nEndPara
) ) )
221 pOwner
->UndoActionStart( OLUNDO_INSERT
);
222 sal_Int32 nTemp
= aSel
.nEndPara
;
224 pOwner
->Insert( OUString(), nTemp
, pPara
->GetDepth()+1 );
226 // Position the cursor
227 ESelection
aTmpSel(nTemp
,0,nTemp
,0);
228 pEditView
->SetSelection( aTmpSel
);
229 pEditView
->ShowCursor();
230 pOwner
->UndoActionEnd();
231 bKeyProcessed
= true;
239 return bKeyProcessed
|| pEditView
->PostKeyEvent( rKEvt
, pFrameWin
);
242 sal_Int32
OutlinerView::ImpCheckMousePos(const Point
& rPosPix
, MouseTarget
& reTarget
)
244 sal_Int32 nPara
= EE_PARA_NOT_FOUND
;
246 Point aMousePosWin
= pEditView
->GetOutputDevice().PixelToLogic( rPosPix
);
247 if( !pEditView
->GetOutputArea().Contains( aMousePosWin
) )
249 reTarget
= MouseTarget::Outside
;
253 reTarget
= MouseTarget::Text
;
255 Point
aPaperPos( aMousePosWin
);
256 tools::Rectangle aOutArea
= pEditView
->GetOutputArea();
257 tools::Rectangle aVisArea
= pEditView
->GetVisArea();
258 aPaperPos
.AdjustX( -(aOutArea
.Left()) );
259 aPaperPos
.AdjustX(aVisArea
.Left() );
260 aPaperPos
.AdjustY( -(aOutArea
.Top()) );
261 aPaperPos
.AdjustY(aVisArea
.Top() );
264 if ( pOwner
->IsTextPos( aPaperPos
, 0, &bBullet
) )
266 Point aDocPos
= pOwner
->GetDocPos( aPaperPos
);
267 nPara
= pOwner
->pEditEngine
->FindParagraph( aDocPos
.Y() );
271 reTarget
= MouseTarget::Bullet
;
275 // Check for hyperlink
276 const SvxFieldItem
* pFieldItem
= pEditView
->GetField( aMousePosWin
);
277 if ( pFieldItem
&& pFieldItem
->GetField() && dynamic_cast< const SvxURLField
* >(pFieldItem
->GetField()) != nullptr )
278 reTarget
= MouseTarget::Hypertext
;
285 bool OutlinerView::MouseMove( const MouseEvent
& rMEvt
)
287 if( ( pOwner
->GetOutlinerMode() == OutlinerMode::TextObject
) || pEditView
->GetEditEngine()->IsInSelectionMode())
288 return pEditView
->MouseMove( rMEvt
);
290 Point
aMousePosWin( pEditView
->GetOutputDevice().PixelToLogic( rMEvt
.GetPosPixel() ) );
291 if( !pEditView
->GetOutputArea().Contains( aMousePosWin
) )
294 PointerStyle aPointer
= GetPointer( rMEvt
.GetPosPixel() );
295 pEditView
->GetWindow()->SetPointer( aPointer
);
296 return pEditView
->MouseMove( rMEvt
);
300 bool OutlinerView::MouseButtonDown( const MouseEvent
& rMEvt
)
302 if ( ( pOwner
->GetOutlinerMode() == OutlinerMode::TextObject
) || pEditView
->GetEditEngine()->IsInSelectionMode() )
303 return pEditView
->MouseButtonDown( rMEvt
);
305 Point
aMousePosWin( pEditView
->GetOutputDevice().PixelToLogic( rMEvt
.GetPosPixel() ) );
306 if( !pEditView
->GetOutputArea().Contains( aMousePosWin
) )
309 PointerStyle aPointer
= GetPointer( rMEvt
.GetPosPixel() );
310 pEditView
->GetWindow()->SetPointer( aPointer
);
313 sal_Int32 nPara
= ImpCheckMousePos( rMEvt
.GetPosPixel(), eTarget
);
314 if ( eTarget
== MouseTarget::Bullet
)
316 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
317 bool bHasChildren
= (pPara
&& pOwner
->pParaList
->HasChildren(pPara
));
318 if( rMEvt
.GetClicks() == 1 )
320 sal_Int32 nEndPara
= nPara
;
321 if ( bHasChildren
&& pOwner
->pParaList
->HasVisibleChildren(pPara
) )
322 nEndPara
+= pOwner
->pParaList
->GetChildCount( pPara
);
323 // The selection is inverted, so that EditEngine does not scroll
324 ESelection
aSel(nEndPara
, EE_TEXTPOS_ALL
, nPara
, 0 );
325 pEditView
->SetSelection( aSel
);
327 else if( rMEvt
.GetClicks() == 2 && bHasChildren
)
328 ImpToggleExpand( pPara
);
333 // special case for outliner view in impress, check if double click hits the page icon for toggle
334 if( (nPara
== EE_PARA_NOT_FOUND
) && (pOwner
->GetOutlinerMode() == OutlinerMode::OutlineView
) && (eTarget
== MouseTarget::Text
) && (rMEvt
.GetClicks() == 2) )
336 ESelection
aSel( pEditView
->GetSelection() );
337 nPara
= aSel
.nStartPara
;
338 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
339 if( (pPara
&& pOwner
->pParaList
->HasChildren(pPara
)) && pPara
->HasFlag(ParaFlag::ISPAGE
) )
341 ImpToggleExpand( pPara
);
344 return pEditView
->MouseButtonDown( rMEvt
);
348 bool OutlinerView::MouseButtonUp( const MouseEvent
& rMEvt
)
350 if ( ( pOwner
->GetOutlinerMode() == OutlinerMode::TextObject
) || pEditView
->GetEditEngine()->IsInSelectionMode() )
351 return pEditView
->MouseButtonUp( rMEvt
);
353 Point
aMousePosWin( pEditView
->GetOutputDevice().PixelToLogic( rMEvt
.GetPosPixel() ) );
354 if( !pEditView
->GetOutputArea().Contains( aMousePosWin
) )
357 PointerStyle aPointer
= GetPointer( rMEvt
.GetPosPixel() );
358 pEditView
->GetWindow()->SetPointer( aPointer
);
360 return pEditView
->MouseButtonUp( rMEvt
);
363 void OutlinerView::ReleaseMouse()
365 pEditView
->ReleaseMouse();
368 void OutlinerView::ImpToggleExpand( Paragraph
const * pPara
)
370 sal_Int32 nPara
= pOwner
->pParaList
->GetAbsPos( pPara
);
371 pEditView
->SetSelection( ESelection( nPara
, 0, nPara
, 0 ) );
372 ImplExpandOrCollaps( nPara
, nPara
, !pOwner
->pParaList
->HasVisibleChildren( pPara
) );
373 pEditView
->ShowCursor();
376 void OutlinerView::Select( Paragraph
const * pParagraph
, bool bSelect
)
378 sal_Int32 nPara
= pOwner
->pParaList
->GetAbsPos( pParagraph
);
381 nEnd
= SAL_MAX_INT32
;
383 ESelection
aSel( nPara
, 0, nPara
, nEnd
);
384 pEditView
->SetSelection( aSel
);
388 void OutlinerView::SetAttribs( const SfxItemSet
& rAttrs
)
390 bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout( false );
392 if( !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled() )
393 pOwner
->UndoActionStart( OLUNDO_ATTR
);
395 ParaRange aSel
= ImpGetSelectedParagraphs( false );
397 pEditView
->SetAttribs( rAttrs
);
399 // Update Bullet text
400 for( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
402 pOwner
->ImplCheckNumBulletItem( nPara
);
403 pOwner
->ImplCalcBulletText( nPara
, false, false );
405 if( !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled() )
406 pOwner
->InsertUndo( std::make_unique
<OutlinerUndoCheckPara
>( pOwner
, nPara
) );
409 if( !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled() )
410 pOwner
->UndoActionEnd();
412 pEditView
->SetEditEngineUpdateLayout( bUpdate
);
415 ParaRange
OutlinerView::ImpGetSelectedParagraphs( bool bIncludeHiddenChildren
)
417 ESelection aSel
= pEditView
->GetSelection();
418 ParaRange
aParas( aSel
.nStartPara
, aSel
.nEndPara
);
421 // Record the invisible Children of the last Parents in the selection
422 if ( bIncludeHiddenChildren
)
424 Paragraph
* pLast
= pOwner
->pParaList
->GetParagraph( aParas
.nEndPara
);
425 if ( pOwner
->pParaList
->HasHiddenChildren( pLast
) )
426 aParas
.nEndPara
= aParas
.nEndPara
+ pOwner
->pParaList
->GetChildCount( pLast
);
431 // TODO: Name should be changed!
432 void OutlinerView::AdjustDepth( short nDX
)
437 void OutlinerView::Indent( short nDiff
)
439 if( !nDiff
|| ( ( nDiff
> 0 ) && ImpCalcSelectedPages( true ) && !pOwner
->ImpCanIndentSelectedPages( this ) ) )
442 const bool bOutlinerView
= bool(pOwner
->pEditEngine
->GetControlWord() & EEControlBits::OUTLINER
);
443 bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout( false );
445 bool bUndo
= !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled();
448 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
450 sal_Int16 nMinDepth
= -1; // Optimization: avoid recalculate too many paragraphs if not really needed.
452 ParaRange aSel
= ImpGetSelectedParagraphs( true );
453 for ( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
455 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
457 sal_Int16 nOldDepth
= pPara
->GetDepth();
458 sal_Int16 nNewDepth
= nOldDepth
+ nDiff
;
460 if( bOutlinerView
&& nPara
)
462 const bool bPage
= pPara
->HasFlag(ParaFlag::ISPAGE
);
463 if( (bPage
&& (nDiff
== +1)) || (!bPage
&& (nDiff
== -1) && (nOldDepth
<= 0)) )
466 pOwner
->nDepthChangedHdlPrevDepth
= nOldDepth
;
467 ParaFlag nPrevFlags
= pPara
->nFlags
;
470 pPara
->RemoveFlag( ParaFlag::ISPAGE
);
472 pPara
->SetFlag( ParaFlag::ISPAGE
);
474 pOwner
->DepthChangedHdl(pPara
, nPrevFlags
);
475 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nPara
, 0, nPara
, 0 ) );
478 pOwner
->InsertUndo( std::make_unique
<OutlinerUndoChangeParaFlags
>( pOwner
, nPara
, nPrevFlags
, pPara
->nFlags
) );
484 // do not switch off numeration with tab
485 if( (nOldDepth
== 0) && (nNewDepth
== -1) )
488 // do not indent if there is no numeration enabled
489 if( nOldDepth
== -1 )
492 if ( nNewDepth
< Outliner::gnMinDepth
)
493 nNewDepth
= Outliner::gnMinDepth
;
494 if ( nNewDepth
> pOwner
->nMaxDepth
)
495 nNewDepth
= pOwner
->nMaxDepth
;
497 if( nOldDepth
< nMinDepth
)
498 nMinDepth
= nOldDepth
;
499 if( nNewDepth
< nMinDepth
)
500 nMinDepth
= nNewDepth
;
502 if( nOldDepth
!= nNewDepth
)
504 if ( ( nPara
== aSel
.nStartPara
) && aSel
.nStartPara
&& ( pOwner
->GetOutlinerMode() != OutlinerMode::TextObject
))
506 // Special case: the predecessor of an indented paragraph is
507 // invisible and is now on the same level as the visible
508 // paragraph. In this case, the next visible paragraph is
509 // searched for and fluffed.
511 Paragraph
* _pPara
= pOwner
->pParaList
->GetParagraph( aSel
.nStartPara
);
512 DBG_ASSERT(_pPara
->IsVisible(),"Selected Paragraph invisible ?!");
514 Paragraph
* pPrev
= pOwner
->pParaList
->GetParagraph( aSel
.nStartPara
-1 );
516 if( !pPrev
->IsVisible() && ( pPrev
->GetDepth() == nNewDepth
) )
518 // Predecessor is collapsed and is on the same level
519 // => find next visible paragraph and expand it
520 pPrev
= pOwner
->pParaList
->GetParent( pPrev
);
521 while( !pPrev
->IsVisible() )
522 pPrev
= pOwner
->pParaList
->GetParent( pPrev
);
524 pOwner
->Expand( pPrev
);
525 pOwner
->InvalidateBullet(pOwner
->pParaList
->GetAbsPos(pPrev
));
529 pOwner
->nDepthChangedHdlPrevDepth
= nOldDepth
;
530 ParaFlag nPrevFlags
= pPara
->nFlags
;
532 pOwner
->ImplInitDepth( nPara
, nNewDepth
, true );
533 pOwner
->ImplCalcBulletText( nPara
, false, false );
535 if ( pOwner
->GetOutlinerMode() == OutlinerMode::OutlineObject
)
536 pOwner
->ImplSetLevelDependentStyleSheet( nPara
);
539 pOwner
->DepthChangedHdl(pPara
, nPrevFlags
);
543 // Needs at least a repaint...
544 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nPara
, 0, nPara
, 0 ) );
548 sal_Int32 nParas
= pOwner
->pParaList
->GetParagraphCount();
549 for ( sal_Int32 n
= aSel
.nEndPara
+1; n
< nParas
; n
++ )
551 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( n
);
552 if ( pPara
->GetDepth() < nMinDepth
)
554 pOwner
->ImplCalcBulletText( n
, false, false );
559 pEditView
->SetEditEngineUpdateLayout( true );
560 pEditView
->ShowCursor();
564 pOwner
->UndoActionEnd();
567 void OutlinerView::AdjustHeight( tools::Long nDY
)
569 pEditView
->MoveParagraphs( nDY
);
572 tools::Rectangle
OutlinerView::GetVisArea() const
574 return pEditView
->GetVisArea();
577 void OutlinerView::Expand()
579 ParaRange aParas
= ImpGetSelectedParagraphs( false );
580 ImplExpandOrCollaps( aParas
.nStartPara
, aParas
.nEndPara
, true );
584 void OutlinerView::Collapse()
586 ParaRange aParas
= ImpGetSelectedParagraphs( false );
587 ImplExpandOrCollaps( aParas
.nStartPara
, aParas
.nEndPara
, false );
591 void OutlinerView::ExpandAll()
593 ImplExpandOrCollaps( 0, pOwner
->pParaList
->GetParagraphCount()-1, true );
597 void OutlinerView::CollapseAll()
599 ImplExpandOrCollaps( 0, pOwner
->pParaList
->GetParagraphCount()-1, false );
602 void OutlinerView::ImplExpandOrCollaps( sal_Int32 nStartPara
, sal_Int32 nEndPara
, bool bExpand
)
604 bool bUpdate
= pOwner
->SetUpdateLayout( false );
606 bool bUndo
= !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled();
608 pOwner
->UndoActionStart( bExpand
? OLUNDO_EXPAND
: OLUNDO_COLLAPSE
);
610 for ( sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; nPara
++ )
612 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
613 bool bDone
= bExpand
? pOwner
->Expand( pPara
) : pOwner
->Collapse( pPara
);
616 // The line under the paragraph should disappear ...
617 pOwner
->pEditEngine
->QuickMarkToBeRepainted( nPara
);
622 pOwner
->UndoActionEnd();
626 pOwner
->SetUpdateLayout( true );
627 pEditView
->ShowCursor();
631 void OutlinerView::InsertText( const OutlinerParaObject
& rParaObj
)
633 // Like Paste, only EditView::Insert, instead of EditView::Paste.
634 // Actually not quite true that possible indentations must be corrected,
635 // but that comes later by a universal import. The indentation level is
636 // then determined right in the Inserted method.
637 // Possible structure:
638 // pImportInfo with DestPara, DestPos, nFormat, pParaObj...
639 // Possibly problematic:
640 // EditEngine, RTF => Splitting the area, later join together.
642 if ( ImpCalcSelectedPages( false ) && !pOwner
->ImpCanDeleteSelectedPages( this ) )
645 pOwner
->UndoActionStart( OLUNDO_INSERT
);
647 const bool bPrevUpdateLayout
= pOwner
->pEditEngine
->SetUpdateLayout( false );
648 sal_Int32 nStart
, nParaCount
;
649 nParaCount
= pOwner
->pEditEngine
->GetParagraphCount();
650 sal_uInt16 nSize
= ImpInitPaste( nStart
);
651 pEditView
->InsertText( rParaObj
.GetTextObject() );
652 ImpPasted( nStart
, nParaCount
, nSize
);
653 pEditView
->SetEditEngineUpdateLayout( bPrevUpdateLayout
);
655 pOwner
->UndoActionEnd();
657 pEditView
->ShowCursor();
661 void OutlinerView::Cut()
663 if ( !ImpCalcSelectedPages( false ) || pOwner
->ImpCanDeleteSelectedPages( this ) ) {
666 aEndCutPasteLink
.Call(nullptr);
670 void OutlinerView::PasteSpecial()
675 void OutlinerView::Paste( bool bUseSpecial
)
677 if ( ImpCalcSelectedPages( false ) && !pOwner
->ImpCanDeleteSelectedPages( this ) )
680 pOwner
->UndoActionStart( OLUNDO_INSERT
);
682 const bool bPrevUpdateLayout
= pOwner
->pEditEngine
->SetUpdateLayout( false );
683 pOwner
->bPasting
= true;
686 pEditView
->PasteSpecial();
690 if ( pOwner
->GetOutlinerMode() == OutlinerMode::OutlineObject
)
692 const sal_Int32 nParaCount
= pOwner
->pEditEngine
->GetParagraphCount();
694 for( sal_Int32 nPara
= 0; nPara
< nParaCount
; nPara
++ )
695 pOwner
->ImplSetLevelDependentStyleSheet( nPara
);
698 pEditView
->SetEditEngineUpdateLayout( bPrevUpdateLayout
);
699 pOwner
->UndoActionEnd();
700 pEditView
->ShowCursor();
703 // NOTE: We need to do this last because it pEditView may be deleted if a switch of box occurs
704 aEndCutPasteLink
.Call(nullptr);
707 void OutlinerView::CreateSelectionList (std::vector
<Paragraph
*> &aSelList
)
709 ParaRange aParas
= ImpGetSelectedParagraphs( true );
711 for ( sal_Int32 nPara
= aParas
.nStartPara
; nPara
<= aParas
.nEndPara
; nPara
++ )
713 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
714 aSelList
.push_back(pPara
);
718 const SfxStyleSheet
* OutlinerView::GetStyleSheet() const
720 return pEditView
->GetStyleSheet();
723 SfxStyleSheet
* OutlinerView::GetStyleSheet()
725 return pEditView
->GetStyleSheet();
728 PointerStyle
OutlinerView::GetPointer( const Point
& rPosPixel
)
731 ImpCheckMousePos( rPosPixel
, eTarget
);
733 PointerStyle ePointerStyle
= PointerStyle::Arrow
;
734 if ( eTarget
== MouseTarget::Text
)
736 ePointerStyle
= GetOutliner()->IsVertical() ? PointerStyle::TextVertical
: PointerStyle::Text
;
738 else if ( eTarget
== MouseTarget::Hypertext
)
740 ePointerStyle
= PointerStyle::RefHand
;
742 else if ( eTarget
== MouseTarget::Bullet
)
744 ePointerStyle
= PointerStyle::Move
;
747 return ePointerStyle
;
751 sal_Int32
OutlinerView::ImpInitPaste( sal_Int32
& rStart
)
753 pOwner
->bPasting
= true;
754 ESelection
aSelection( pEditView
->GetSelection() );
756 rStart
= aSelection
.nStartPara
;
757 sal_Int32 nSize
= aSelection
.nEndPara
- aSelection
.nStartPara
+ 1;
762 void OutlinerView::ImpPasted( sal_Int32 nStart
, sal_Int32 nPrevParaCount
, sal_Int32 nSize
)
764 pOwner
->bPasting
= false;
765 sal_Int32 nCurParaCount
= pOwner
->pEditEngine
->GetParagraphCount();
766 if( nCurParaCount
< nPrevParaCount
)
767 nSize
= nSize
- ( nPrevParaCount
- nCurParaCount
);
769 nSize
= nSize
+ ( nCurParaCount
- nPrevParaCount
);
770 pOwner
->ImpTextPasted( nStart
, nSize
);
773 bool OutlinerView::Command(const CommandEvent
& rCEvt
)
775 return pEditView
->Command(rCEvt
);
778 void OutlinerView::SelectRange( sal_Int32 nFirst
, sal_Int32 nCount
)
780 sal_Int32 nLast
= nFirst
+nCount
;
781 nCount
= pOwner
->pParaList
->GetParagraphCount();
782 if( nLast
<= nCount
)
784 ESelection
aSel( nFirst
, 0, nLast
, EE_TEXTPOS_ALL
);
785 pEditView
->SetSelection( aSel
);
789 sal_Int32
OutlinerView::ImpCalcSelectedPages( bool bIncludeFirstSelected
)
791 ESelection
aSel( pEditView
->GetSelection() );
794 sal_Int32 nPages
= 0;
795 sal_Int32 nFirstPage
= EE_PARA_MAX_COUNT
;
796 sal_Int32 nStartPara
= aSel
.nStartPara
;
797 if ( !bIncludeFirstSelected
)
798 nStartPara
++; // All paragraphs after StartPara will be deleted
799 for ( sal_Int32 nPara
= nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
801 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
802 DBG_ASSERT(pPara
, "ImpCalcSelectedPages: invalid Selection? ");
803 if( pPara
->HasFlag(ParaFlag::ISPAGE
) )
806 if( nFirstPage
== EE_PARA_MAX_COUNT
)
813 pOwner
->nDepthChangedHdlPrevDepth
= nPages
;
814 pOwner
->mnFirstSelPage
= nFirstPage
;
821 void OutlinerView::ToggleBullets()
823 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
825 ESelection
aSel( pEditView
->GetSelection() );
828 const bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout( false );
830 sal_Int16 nNewDepth
= -2;
831 const SvxNumRule
* pDefaultBulletNumRule
= nullptr;
833 for ( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
835 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
836 DBG_ASSERT(pPara
, "OutlinerView::ToggleBullets(), illegal selection?");
840 if( nNewDepth
== -2 )
842 nNewDepth
= (pOwner
->GetDepth(nPara
) == -1) ? 0 : -1;
843 if ( nNewDepth
== 0 )
845 // determine default numbering rule for bullets
846 const ESelection
aSelection(nPara
, 0);
847 const SfxItemSet
aTmpSet(pOwner
->pEditEngine
->GetAttribs(aSelection
));
848 const SfxPoolItem
& rPoolItem
= aTmpSet
.GetPool()->GetDefaultItem( EE_PARA_NUMBULLET
);
849 const SvxNumBulletItem
* pNumBulletItem
= dynamic_cast< const SvxNumBulletItem
* >(&rPoolItem
);
850 pDefaultBulletNumRule
= pNumBulletItem
? &pNumBulletItem
->GetNumRule() : nullptr;
854 pOwner
->SetDepth( pPara
, nNewDepth
);
856 if( nNewDepth
== -1 )
858 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs( nPara
);
859 if ( rAttrs
.GetItemState( EE_PARA_BULLETSTATE
) == SfxItemState::SET
)
861 SfxItemSet
aAttrs(rAttrs
);
862 aAttrs
.ClearItem( EE_PARA_BULLETSTATE
);
863 pOwner
->SetParaAttribs( nPara
, aAttrs
);
868 if ( pDefaultBulletNumRule
)
870 const SvxNumberFormat
* pFmt
= pOwner
->GetNumberFormat( nPara
);
872 || ( pFmt
->GetNumberingType() != SVX_NUM_BITMAP
873 && pFmt
->GetNumberingType() != SVX_NUM_CHAR_SPECIAL
) )
875 SfxItemSet
aAttrs( pOwner
->GetParaAttribs( nPara
) );
876 SvxNumRule
aNewNumRule( *pDefaultBulletNumRule
);
877 aAttrs
.Put( SvxNumBulletItem( std::move(aNewNumRule
), EE_PARA_NUMBULLET
) );
878 pOwner
->SetParaAttribs( nPara
, aAttrs
);
885 const sal_Int32 nParaCount
= pOwner
->pParaList
->GetParagraphCount();
886 pOwner
->ImplCheckParagraphs( aSel
.nStartPara
, nParaCount
);
888 sal_Int32 nEndPara
= (nParaCount
> 0) ? nParaCount
-1 : nParaCount
;
889 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( aSel
.nStartPara
, 0, nEndPara
, 0 ) );
891 pOwner
->pEditEngine
->SetUpdateLayout( bUpdate
);
893 pOwner
->UndoActionEnd();
897 void OutlinerView::ToggleBulletsNumbering(
899 const bool bHandleBullets
,
900 const SvxNumRule
* pNumRule
)
902 ESelection
aSel( pEditView
->GetSelection() );
905 bool bToggleOn
= true;
909 const sal_Int16
nBulletNumberingStatus( pOwner
->GetBulletsNumberingStatus( aSel
.nStartPara
, aSel
.nEndPara
) );
910 if ( nBulletNumberingStatus
!= 0 && bHandleBullets
)
912 // not all paragraphs have bullets and method called to toggle bullets --> bullets on
915 else if ( nBulletNumberingStatus
!= 1 && !bHandleBullets
)
917 // not all paragraphs have numbering and method called to toggle numberings --> numberings on
923 // apply bullets/numbering for selected paragraphs
924 ApplyBulletsNumbering( bHandleBullets
, pNumRule
, bToggle
, true );
928 // switch off bullets/numbering for selected paragraphs
929 SwitchOffBulletsNumbering( true );
933 void OutlinerView::EnsureNumberingIsOn()
935 pOwner
->UndoActionStart(OLUNDO_DEPTH
);
937 ESelection
aSel(pEditView
->GetSelection());
940 const bool bUpdate
= pOwner
->pEditEngine
->IsUpdateLayout();
941 pOwner
->pEditEngine
->SetUpdateLayout(false);
943 for (sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++)
945 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph(nPara
);
946 DBG_ASSERT(pPara
, "OutlinerView::EnableBullets(), illegal selection?");
948 if (pPara
&& pOwner
->GetDepth(nPara
) == -1)
949 pOwner
->SetDepth(pPara
, 0);
952 sal_Int32 nParaCount
= pOwner
->pParaList
->GetParagraphCount();
953 pOwner
->ImplCheckParagraphs(aSel
.nStartPara
, nParaCount
);
955 const sal_Int32 nEndPara
= (nParaCount
> 0) ? nParaCount
-1 : nParaCount
;
956 pOwner
->pEditEngine
->QuickMarkInvalid(ESelection(aSel
.nStartPara
, 0, nEndPara
, 0));
958 pOwner
->pEditEngine
->SetUpdateLayout(bUpdate
);
960 pOwner
->UndoActionEnd();
963 void OutlinerView::ApplyBulletsNumbering(
964 const bool bHandleBullets
,
965 const SvxNumRule
* pNewNumRule
,
966 const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule
,
967 const bool bAtSelection
)
969 if (!pOwner
|| !pOwner
->pEditEngine
|| !pOwner
->pParaList
)
974 pOwner
->UndoActionStart(OLUNDO_DEPTH
);
975 const bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout(false);
977 sal_Int32 nStartPara
= 0;
978 sal_Int32 nEndPara
= 0;
981 ESelection
aSel( pEditView
->GetSelection() );
983 nStartPara
= aSel
.nStartPara
;
984 nEndPara
= aSel
.nEndPara
;
989 nEndPara
= pOwner
->pParaList
->GetParagraphCount() - 1;
992 for (sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; ++nPara
)
994 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph(nPara
);
995 DBG_ASSERT(pPara
, "OutlinerView::ApplyBulletsNumbering(..), illegal selection?");
999 const sal_Int16 nDepth
= pOwner
->GetDepth(nPara
);
1002 pOwner
->SetDepth( pPara
, 0 );
1005 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs(nPara
);
1006 SfxItemSet
aAttrs(rAttrs
);
1007 aAttrs
.Put(SfxBoolItem(EE_PARA_BULLETSTATE
, true));
1009 // apply new numbering rule
1012 bool bApplyNumRule
= false;
1013 if ( !bCheckCurrentNumRuleBeforeApplyingNewNumRule
)
1015 bApplyNumRule
= true;
1019 const SvxNumberFormat
* pFmt
= pOwner
->GetNumberFormat(nPara
);
1022 bApplyNumRule
= true;
1026 sal_Int16 nNumType
= pFmt
->GetNumberingType();
1028 && nNumType
!= SVX_NUM_BITMAP
&& nNumType
!= SVX_NUM_CHAR_SPECIAL
)
1030 // Set to Normal bullet, old bullet type is Numbering bullet.
1031 bApplyNumRule
= true;
1033 else if ( !bHandleBullets
1034 && (nNumType
== SVX_NUM_BITMAP
|| nNumType
== SVX_NUM_CHAR_SPECIAL
))
1036 // Set to Numbering bullet, old bullet type is Normal bullet.
1037 bApplyNumRule
= true;
1042 if ( bApplyNumRule
)
1044 SvxNumRule
aNewRule(*pNewNumRule
);
1046 // Get old bullet space.
1048 const SvxNumBulletItem
* pNumBulletItem
= rAttrs
.GetItemIfSet(EE_PARA_NUMBULLET
, false);
1051 // Use default value when has not contain bullet item.
1052 ESelection
aSelection(nPara
, 0);
1053 SfxItemSet
aTmpSet(pOwner
->pEditEngine
->GetAttribs(aSelection
));
1054 pNumBulletItem
= aTmpSet
.GetItem(EE_PARA_NUMBULLET
);
1059 const sal_uInt16 nLevelCnt
= std::min(pNumBulletItem
->GetNumRule().GetLevelCount(), aNewRule
.GetLevelCount());
1060 for ( sal_uInt16 nLevel
= 0; nLevel
< nLevelCnt
; ++nLevel
)
1062 const SvxNumberFormat
* pOldFmt
= pNumBulletItem
->GetNumRule().Get(nLevel
);
1063 const SvxNumberFormat
* pNewFmt
= aNewRule
.Get(nLevel
);
1064 if (pOldFmt
&& pNewFmt
&& (pOldFmt
->GetFirstLineOffset() != pNewFmt
->GetFirstLineOffset() || pOldFmt
->GetAbsLSpace() != pNewFmt
->GetAbsLSpace()))
1066 SvxNumberFormat
aNewFmtClone(*pNewFmt
);
1067 aNewFmtClone
.SetFirstLineOffset(pOldFmt
->GetFirstLineOffset());
1068 aNewFmtClone
.SetAbsLSpace(pOldFmt
->GetAbsLSpace());
1069 aNewRule
.SetLevel(nLevel
, &aNewFmtClone
);
1075 aAttrs
.Put(SvxNumBulletItem(std::move(aNewRule
), EE_PARA_NUMBULLET
));
1078 pOwner
->SetParaAttribs(nPara
, aAttrs
);
1082 const sal_uInt16 nParaCount
= static_cast<sal_uInt16
>(pOwner
->pParaList
->GetParagraphCount());
1083 pOwner
->ImplCheckParagraphs( nStartPara
, nParaCount
);
1084 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nStartPara
, 0, nParaCount
, 0 ) );
1086 pOwner
->pEditEngine
->SetUpdateLayout( bUpdate
);
1088 pOwner
->UndoActionEnd();
1092 void OutlinerView::SwitchOffBulletsNumbering(
1093 const bool bAtSelection
)
1095 sal_Int32 nStartPara
= 0;
1096 sal_Int32 nEndPara
= 0;
1099 ESelection
aSel( pEditView
->GetSelection() );
1101 nStartPara
= aSel
.nStartPara
;
1102 nEndPara
= aSel
.nEndPara
;
1107 nEndPara
= pOwner
->pParaList
->GetParagraphCount() - 1;
1110 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
1111 const bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout( false );
1113 for ( sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; ++nPara
)
1115 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
1116 DBG_ASSERT(pPara
, "OutlinerView::SwitchOffBulletsNumbering(...), illegal paragraph index?");
1120 pOwner
->SetDepth( pPara
, -1 );
1122 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs( nPara
);
1123 if (rAttrs
.GetItemState( EE_PARA_BULLETSTATE
) == SfxItemState::SET
)
1125 SfxItemSet
aAttrs(rAttrs
);
1126 aAttrs
.ClearItem( EE_PARA_BULLETSTATE
);
1127 pOwner
->SetParaAttribs( nPara
, aAttrs
);
1132 const sal_uInt16 nParaCount
= static_cast<sal_uInt16
>(pOwner
->pParaList
->GetParagraphCount());
1133 pOwner
->ImplCheckParagraphs( nStartPara
, nParaCount
);
1134 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nStartPara
, 0, nParaCount
, 0 ) );
1136 pOwner
->pEditEngine
->SetUpdateLayout( bUpdate
);
1137 pOwner
->UndoActionEnd();
1141 void OutlinerView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs
)
1143 RemoveAttribs( bRemoveParaAttribs
, true /*keep language attribs*/ );
1146 void OutlinerView::RemoveAttribs( bool bRemoveParaAttribs
, bool bKeepLanguages
)
1148 bool bUpdate
= pOwner
->SetUpdateLayout( false );
1149 pOwner
->UndoActionStart( OLUNDO_ATTR
);
1151 pEditView
->RemoveAttribsKeepLanguages( bRemoveParaAttribs
);
1153 pEditView
->RemoveAttribs( bRemoveParaAttribs
);
1154 if ( bRemoveParaAttribs
)
1156 // Loop through all paragraphs and set indentation and level
1157 ESelection aSel
= pEditView
->GetSelection();
1159 for ( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
1161 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
1162 pOwner
->ImplInitDepth( nPara
, pPara
->GetDepth(), false );
1165 pOwner
->UndoActionEnd();
1166 pOwner
->SetUpdateLayout( bUpdate
);
1170 // ====================== Simple pass-through =======================
1173 void OutlinerView::InsertText( const OUString
& rNew
, bool bSelect
)
1175 if( pOwner
->bFirstParaIsEmpty
)
1176 pOwner
->Insert( OUString() );
1177 pEditView
->InsertText( rNew
, bSelect
);
1180 void OutlinerView::SetVisArea( const tools::Rectangle
& rRect
)
1182 pEditView
->SetVisArea( rRect
);
1186 void OutlinerView::SetSelection( const ESelection
& rSel
)
1188 pEditView
->SetSelection( rSel
);
1191 void OutlinerView::GetSelectionRectangles(std::vector
<tools::Rectangle
>& rLogicRects
) const
1193 pEditView
->GetSelectionRectangles(rLogicRects
);
1196 void OutlinerView::SetReadOnly( bool bReadOnly
)
1198 pEditView
->SetReadOnly( bReadOnly
);
1201 bool OutlinerView::IsReadOnly() const
1203 return pEditView
->IsReadOnly();
1206 bool OutlinerView::HasSelection() const
1208 return pEditView
->HasSelection();
1211 void OutlinerView::ShowCursor( bool bGotoCursor
, bool bActivate
)
1213 pEditView
->ShowCursor( bGotoCursor
, /*bForceVisCursor=*/true, bActivate
);
1216 void OutlinerView::HideCursor(bool bDeactivate
)
1218 pEditView
->HideCursor(bDeactivate
);
1221 void OutlinerView::SetWindow( vcl::Window
* pWin
)
1223 pEditView
->SetWindow( pWin
);
1226 vcl::Window
* OutlinerView::GetWindow() const
1228 return pEditView
->GetWindow();
1231 void OutlinerView::SetOutputArea( const tools::Rectangle
& rRect
)
1233 pEditView
->SetOutputArea( rRect
);
1236 tools::Rectangle
const & OutlinerView::GetOutputArea() const
1238 return pEditView
->GetOutputArea();
1241 OUString
OutlinerView::GetSelected() const
1243 return pEditView
->GetSelected();
1246 void OutlinerView::StartSpeller(weld::Widget
* pDialogParent
)
1248 pEditView
->StartSpeller(pDialogParent
);
1251 EESpellState
OutlinerView::StartThesaurus(weld::Widget
* pDialogParent
)
1253 return pEditView
->StartThesaurus(pDialogParent
);
1256 void OutlinerView::StartTextConversion(weld::Widget
* pDialogParent
,
1257 LanguageType nSrcLang
, LanguageType nDestLang
, const vcl::Font
*pDestFont
,
1258 sal_Int32 nOptions
, bool bIsInteractive
, bool bMultipleDoc
)
1261 (LANGUAGE_KOREAN
== nSrcLang
&& LANGUAGE_KOREAN
== nDestLang
) ||
1262 (LANGUAGE_CHINESE_SIMPLIFIED
== nSrcLang
&& LANGUAGE_CHINESE_TRADITIONAL
== nDestLang
) ||
1263 (LANGUAGE_CHINESE_TRADITIONAL
== nSrcLang
&& LANGUAGE_CHINESE_SIMPLIFIED
== nDestLang
)
1266 pEditView
->StartTextConversion(pDialogParent
, nSrcLang
, nDestLang
, pDestFont
, nOptions
, bIsInteractive
, bMultipleDoc
);
1270 OSL_FAIL( "unexpected language" );
1275 sal_Int32
OutlinerView::StartSearchAndReplace( const SvxSearchItem
& rSearchItem
)
1277 return pEditView
->StartSearchAndReplace( rSearchItem
);
1280 void OutlinerView::TransliterateText( TransliterationFlags nTransliterationMode
)
1282 pEditView
->TransliterateText( nTransliterationMode
);
1285 ESelection
OutlinerView::GetSelection() const
1287 return pEditView
->GetSelection();
1291 void OutlinerView::Scroll( tools::Long nHorzScroll
, tools::Long nVertScroll
)
1293 pEditView
->Scroll( nHorzScroll
, nVertScroll
);
1296 void OutlinerView::SetControlWord( EVControlBits nWord
)
1298 pEditView
->SetControlWord( nWord
);
1301 EVControlBits
OutlinerView::GetControlWord() const
1303 return pEditView
->GetControlWord();
1306 void OutlinerView::SetAnchorMode( EEAnchorMode eMode
)
1308 pEditView
->SetAnchorMode( eMode
);
1311 EEAnchorMode
OutlinerView::GetAnchorMode() const
1313 return pEditView
->GetAnchorMode();
1316 void OutlinerView::Copy()
1321 void OutlinerView::InsertField( const SvxFieldItem
& rFld
)
1323 pEditView
->InsertField( rFld
);
1326 const SvxFieldItem
* OutlinerView::GetFieldUnderMousePointer() const
1328 return pEditView
->GetFieldUnderMousePointer();
1331 const SvxFieldItem
* OutlinerView::GetFieldAtSelection() const
1333 return pEditView
->GetFieldAtSelection();
1336 const SvxFieldData
* OutlinerView::GetFieldAtCursor() const
1338 return pEditView
->GetFieldAtCursor();
1341 void OutlinerView::SelectFieldAtCursor()
1343 pEditView
->SelectFieldAtCursor();
1346 void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel
)
1348 pEditView
->SetInvalidateMore( nPixel
);
1352 sal_uInt16
OutlinerView::GetInvalidateMore() const
1354 return pEditView
->GetInvalidateMore();
1358 bool OutlinerView::IsCursorAtWrongSpelledWord()
1360 return pEditView
->IsCursorAtWrongSpelledWord();
1364 bool OutlinerView::IsWrongSpelledWordAtPos( const Point
& rPosPixel
)
1366 return pEditView
->IsWrongSpelledWordAtPos( rPosPixel
, /*bMarkIfWrong*/false );
1369 void OutlinerView::ExecuteSpellPopup(const Point
& rPosPixel
, const Link
<SpellCallbackInfo
&,void>& rStartDlg
)
1371 pEditView
->ExecuteSpellPopup(rPosPixel
, rStartDlg
);
1374 void OutlinerView::Read( SvStream
& rInput
, EETextFormat eFormat
, SvKeyValueIterator
* pHTTPHeaderAttrs
)
1376 sal_Int32 nOldParaCount
= pEditView
->GetEditEngine()->GetParagraphCount();
1377 ESelection aOldSel
= pEditView
->GetSelection();
1380 pEditView
->Read( rInput
, eFormat
, pHTTPHeaderAttrs
);
1382 tools::Long nParaDiff
= pEditView
->GetEditEngine()->GetParagraphCount() - nOldParaCount
;
1383 sal_Int32 nChangesStart
= aOldSel
.nStartPara
;
1384 sal_Int32 nChangesEnd
= nChangesStart
+ nParaDiff
+ (aOldSel
.nEndPara
-aOldSel
.nStartPara
);
1386 for ( sal_Int32 n
= nChangesStart
; n
<= nChangesEnd
; n
++ )
1388 if ( pOwner
->GetOutlinerMode() == OutlinerMode::OutlineObject
)
1389 pOwner
->ImplSetLevelDependentStyleSheet( n
);
1392 pOwner
->ImpFilterIndents( nChangesStart
, nChangesEnd
);
1395 void OutlinerView::SetBackgroundColor( const Color
& rColor
)
1397 pEditView
->SetBackgroundColor( rColor
);
1400 void OutlinerView::RegisterViewShell(OutlinerViewShell
* pViewShell
)
1402 pEditView
->RegisterViewShell(pViewShell
);
1405 Color
const & OutlinerView::GetBackgroundColor() const
1407 return pEditView
->GetBackgroundColor();
1410 SfxItemSet
OutlinerView::GetAttribs()
1412 return pEditView
->GetAttribs();
1415 SvtScriptType
OutlinerView::GetSelectedScriptType() const
1417 return pEditView
->GetSelectedScriptType();
1420 OUString
OutlinerView::GetSurroundingText() const
1422 return pEditView
->GetSurroundingText();
1425 Selection
OutlinerView::GetSurroundingTextSelection() const
1427 return pEditView
->GetSurroundingTextSelection();
1430 bool OutlinerView::DeleteSurroundingText(const Selection
& rSelection
)
1432 return pEditView
->DeleteSurroundingText(rSelection
);
1435 // ===== some code for thesaurus sub menu within context menu
1439 bool isSingleScriptType( SvtScriptType nScriptType
)
1441 sal_uInt8 nScriptCount
= 0;
1443 if (nScriptType
& SvtScriptType::LATIN
)
1445 if (nScriptType
& SvtScriptType::ASIAN
)
1447 if (nScriptType
& SvtScriptType::COMPLEX
)
1450 return nScriptCount
== 1;
1455 // returns: true if a word for thesaurus look-up was found at the current cursor position.
1456 // The status string will be word + iso language string (e.g. "light#en-US")
1457 bool GetStatusValueForThesaurusFromContext(
1458 OUString
&rStatusVal
,
1459 LanguageType
&rLang
,
1460 const EditView
&rEditView
)
1462 // get text and locale for thesaurus look up
1464 EditEngine
*pEditEngine
= rEditView
.GetEditEngine();
1465 ESelection
aTextSel( rEditView
.GetSelection() );
1466 if (!aTextSel
.HasRange())
1467 aTextSel
= pEditEngine
->GetWord( aTextSel
, i18n::WordType::DICTIONARY_WORD
);
1468 aText
= pEditEngine
->GetText( aTextSel
);
1471 if (!isSingleScriptType(pEditEngine
->GetScriptType(aTextSel
)))
1474 LanguageType nLang
= pEditEngine
->GetLanguage( aTextSel
.nStartPara
, aTextSel
.nStartPos
).nLang
;
1475 OUString
aLangText( LanguageTag::convertToBcp47( nLang
) );
1477 // set word and locale to look up as status value
1478 rStatusVal
= aText
+ "#" + aLangText
;
1481 return aText
.getLength() > 0;
1485 void ReplaceTextWithSynonym( EditView
&rEditView
, const OUString
&rSynonmText
)
1487 // get selection to use
1488 ESelection
aCurSel( rEditView
.GetSelection() );
1489 if (!rEditView
.HasSelection())
1491 // select the same word that was used in GetStatusValueForThesaurusFromContext by calling GetWord.
1492 // (In the end both functions will call ImpEditEngine::SelectWord)
1493 rEditView
.SelectCurrentWord( i18n::WordType::DICTIONARY_WORD
);
1494 aCurSel
= rEditView
.GetSelection();
1498 rEditView
.InsertText( rSynonmText
);
1499 rEditView
.ShowCursor( true, false );
1503 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */