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
.end
.nIndex
== pOwner
->pEditEngine
->GetTextLen(aSel
.end
.nPara
))
128 Paragraph
* pNext
= pOwner
->pParaList
->GetParagraph(aSel
.end
.nPara
+ 1);
129 if( pNext
&& pNext
->HasFlag(ParaFlag::ISPAGE
) )
131 if (!pOwner
->ImpCanDeleteSelectedPages(this, aSel
.end
.nPara
, 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
.start
.nIndex
) )
154 Indent( aKeyCode
.IsShift() ? -1 : +1 );
155 bKeyProcessed
= true;
157 else if ( ( pOwner
->GetOutlinerMode() == OutlinerMode::TextObject
) &&
158 !bSelection
&& !aSel
.end
.nIndex
&& pOwner
->ImplHasNumberFormat( aSel
.end
.nPara
) )
160 Indent( aKeyCode
.IsShift() ? -1 : +1 );
161 bKeyProcessed
= true;
168 if (!bReadOnly
&& !bSelection
&& aSel
.end
.nPara
&& !aSel
.end
.nIndex
)
170 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph(aSel
.end
.nPara
);
171 Paragraph
* pPrev
= pOwner
->pParaList
->GetParagraph(aSel
.end
.nPara
- 1);
172 if( !pPrev
->IsVisible() )
174 if( !pPara
->GetDepth() )
176 if (!pOwner
->ImpCanDeleteSelectedPages(this, aSel
.end
.nPara
, 1))
186 // Special treatment: hard return at the end of a paragraph,
187 // which has collapsed subparagraphs.
188 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph(aSel
.end
.nPara
);
190 if( !aKeyCode
.IsShift() )
192 // Don't let insert empty paragraph with numbering. Instead end numbering.
193 if (pPara
->GetDepth() > -1 &&
194 pOwner
->pEditEngine
->GetTextLen( aSel
.end
.nPara
) == 0)
199 // ImpGetCursor again???
201 aSel
.end
.nIndex
== pOwner
->pEditEngine
->GetTextLen( aSel
.end
.nPara
) )
203 sal_Int32 nChildren
= pOwner
->pParaList
->GetChildCount(pPara
);
204 if( nChildren
&& !pOwner
->pParaList
->HasVisibleChildren(pPara
))
206 pOwner
->UndoActionStart( OLUNDO_INSERT
);
207 sal_Int32 nTemp
= aSel
.end
.nPara
;
209 nTemp
++; // insert above next Non-Child
210 SAL_WARN_IF( nTemp
< 0, "editeng", "OutlinerView::PostKeyEvent - overflow");
213 pOwner
->Insert( OUString(),nTemp
,pPara
->GetDepth());
214 // Position the cursor
215 ESelection
aTmpSel(nTemp
, 0);
216 pEditView
->SetSelection( aTmpSel
);
218 pEditView
->ShowCursor();
219 pOwner
->UndoActionEnd();
220 bKeyProcessed
= true;
224 if( !bKeyProcessed
&& !bSelection
&&
225 !aKeyCode
.IsShift() && aKeyCode
.IsMod1() &&
226 ( aSel
.end
.nIndex
== pOwner
->pEditEngine
->GetTextLen(aSel
.end
.nPara
) ) )
228 pOwner
->UndoActionStart( OLUNDO_INSERT
);
229 sal_Int32 nTemp
= aSel
.end
.nPara
;
231 pOwner
->Insert( OUString(), nTemp
, pPara
->GetDepth()+1 );
233 // Position the cursor
234 ESelection
aTmpSel(nTemp
, 0);
235 pEditView
->SetSelection( aTmpSel
);
236 pEditView
->ShowCursor();
237 pOwner
->UndoActionEnd();
238 bKeyProcessed
= true;
246 return bKeyProcessed
|| pEditView
->PostKeyEvent( rKEvt
, pFrameWin
);
249 sal_Int32
OutlinerView::ImpCheckMousePos(const Point
& rPosPix
, MouseTarget
& reTarget
)
251 sal_Int32 nPara
= EE_PARA_MAX
;
253 Point aMousePosWin
= pEditView
->GetOutputDevice().PixelToLogic( rPosPix
);
254 if( !pEditView
->GetOutputArea().Contains( aMousePosWin
) )
256 reTarget
= MouseTarget::Outside
;
260 reTarget
= MouseTarget::Text
;
262 Point
aPaperPos( aMousePosWin
);
263 tools::Rectangle aOutArea
= pEditView
->GetOutputArea();
264 tools::Rectangle aVisArea
= pEditView
->GetVisArea();
265 aPaperPos
.AdjustX( -(aOutArea
.Left()) );
266 aPaperPos
.AdjustX(aVisArea
.Left() );
267 aPaperPos
.AdjustY( -(aOutArea
.Top()) );
268 aPaperPos
.AdjustY(aVisArea
.Top() );
271 if ( pOwner
->IsTextPos( aPaperPos
, 0, &bBullet
) )
273 Point aDocPos
= pOwner
->GetDocPos( aPaperPos
);
274 nPara
= pOwner
->pEditEngine
->FindParagraph( aDocPos
.Y() );
278 reTarget
= MouseTarget::Bullet
;
282 // Check for hyperlink
283 const SvxFieldItem
* pFieldItem
= pEditView
->GetField( aMousePosWin
);
284 if ( pFieldItem
&& pFieldItem
->GetField() && dynamic_cast< const SvxURLField
* >(pFieldItem
->GetField()) != nullptr )
285 reTarget
= MouseTarget::Hypertext
;
292 bool OutlinerView::MouseMove( const MouseEvent
& rMEvt
)
294 if( ( pOwner
->GetOutlinerMode() == OutlinerMode::TextObject
) || pEditView
->getEditEngine().IsInSelectionMode())
295 return pEditView
->MouseMove( rMEvt
);
297 Point
aMousePosWin( pEditView
->GetOutputDevice().PixelToLogic( rMEvt
.GetPosPixel() ) );
298 if( !pEditView
->GetOutputArea().Contains( aMousePosWin
) )
301 PointerStyle aPointer
= GetPointer( rMEvt
.GetPosPixel() );
302 pEditView
->GetWindow()->SetPointer( aPointer
);
303 return pEditView
->MouseMove( rMEvt
);
307 bool OutlinerView::MouseButtonDown( const MouseEvent
& rMEvt
)
309 if ( ( pOwner
->GetOutlinerMode() == OutlinerMode::TextObject
) || pEditView
->getEditEngine().IsInSelectionMode() )
310 return pEditView
->MouseButtonDown( rMEvt
);
312 Point
aMousePosWin( pEditView
->GetOutputDevice().PixelToLogic( rMEvt
.GetPosPixel() ) );
313 if( !pEditView
->GetOutputArea().Contains( aMousePosWin
) )
316 PointerStyle aPointer
= GetPointer( rMEvt
.GetPosPixel() );
317 pEditView
->GetWindow()->SetPointer( aPointer
);
320 sal_Int32 nPara
= ImpCheckMousePos( rMEvt
.GetPosPixel(), eTarget
);
321 if ( eTarget
== MouseTarget::Bullet
)
323 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
324 bool bHasChildren
= (pPara
&& pOwner
->pParaList
->HasChildren(pPara
));
325 if( rMEvt
.GetClicks() == 1 )
327 sal_Int32 nEndPara
= nPara
;
328 if ( bHasChildren
&& pOwner
->pParaList
->HasVisibleChildren(pPara
) )
329 nEndPara
+= pOwner
->pParaList
->GetChildCount( pPara
);
330 // The selection is inverted, so that EditEngine does not scroll
331 ESelection
aSel(nEndPara
, EE_TEXTPOS_MAX
, nPara
, 0);
332 pEditView
->SetSelection( aSel
);
334 else if( rMEvt
.GetClicks() == 2 && bHasChildren
)
335 ImpToggleExpand( pPara
);
340 // special case for outliner view in impress, check if double click hits the page icon for toggle
341 if( (nPara
== EE_PARA_MAX
) && (pOwner
->GetOutlinerMode() == OutlinerMode::OutlineView
) && (eTarget
== MouseTarget::Text
) && (rMEvt
.GetClicks() == 2) )
343 ESelection
aSel( pEditView
->GetSelection() );
344 nPara
= aSel
.start
.nPara
;
345 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
346 if( (pPara
&& pOwner
->pParaList
->HasChildren(pPara
)) && pPara
->HasFlag(ParaFlag::ISPAGE
) )
348 ImpToggleExpand( pPara
);
351 return pEditView
->MouseButtonDown( rMEvt
);
355 bool OutlinerView::MouseButtonUp( const MouseEvent
& rMEvt
)
357 if ( ( pOwner
->GetOutlinerMode() == OutlinerMode::TextObject
) || pEditView
->getEditEngine().IsInSelectionMode() )
358 return pEditView
->MouseButtonUp( rMEvt
);
360 Point
aMousePosWin( pEditView
->GetOutputDevice().PixelToLogic( rMEvt
.GetPosPixel() ) );
361 if( !pEditView
->GetOutputArea().Contains( aMousePosWin
) )
364 PointerStyle aPointer
= GetPointer( rMEvt
.GetPosPixel() );
365 pEditView
->GetWindow()->SetPointer( aPointer
);
367 return pEditView
->MouseButtonUp( rMEvt
);
370 void OutlinerView::ReleaseMouse()
372 pEditView
->ReleaseMouse();
375 void OutlinerView::ImpToggleExpand( Paragraph
const * pPara
)
377 sal_Int32 nPara
= pOwner
->pParaList
->GetAbsPos( pPara
);
378 pEditView
->SetSelection(ESelection(nPara
, 0));
379 ImplExpandOrCollaps( nPara
, nPara
, !pOwner
->pParaList
->HasVisibleChildren( pPara
) );
380 pEditView
->ShowCursor();
383 void OutlinerView::Select( Paragraph
const * pParagraph
, bool bSelect
)
385 sal_Int32 nPara
= pOwner
->pParaList
->GetAbsPos( pParagraph
);
388 nEnd
= SAL_MAX_INT32
;
390 ESelection
aSel( nPara
, 0, nPara
, nEnd
);
391 pEditView
->SetSelection( aSel
);
394 void OutlinerView::SetDepth(sal_Int32 nParagraph
, sal_Int16 nDepth
)
396 Paragraph
* pParagraph
= pOwner
->GetParagraph(nParagraph
);
397 pOwner
->SetDepth(pParagraph
, nDepth
);
400 sal_Int16
OutlinerView::GetDepth() const
402 ESelection aESelection
= GetSelection();
403 aESelection
.Adjust();
404 sal_Int16 nDepth
= pOwner
->GetDepth(aESelection
.start
.nPara
);
405 for (sal_Int32 nPara
= aESelection
.start
.nPara
+ 1; nPara
<= aESelection
.end
.nPara
; ++nPara
)
407 if (nDepth
!= pOwner
->GetDepth(nPara
))
413 void OutlinerView::SetAttribs( const SfxItemSet
& rAttrs
)
415 bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout( false );
417 if( !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled() )
418 pOwner
->UndoActionStart( OLUNDO_ATTR
);
420 ParaRange aSel
= ImpGetSelectedParagraphs( false );
422 pEditView
->SetAttribs( rAttrs
);
424 // Update Bullet text
425 for( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
427 pOwner
->ImplCheckNumBulletItem( nPara
);
428 pOwner
->ImplCalcBulletText( nPara
, false, false );
430 if( !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled() )
431 pOwner
->InsertUndo( std::make_unique
<OutlinerUndoCheckPara
>( pOwner
, nPara
) );
434 if( !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled() )
435 pOwner
->UndoActionEnd();
437 pEditView
->SetEditEngineUpdateLayout( bUpdate
);
440 ParaRange
OutlinerView::ImpGetSelectedParagraphs( bool bIncludeHiddenChildren
)
442 ESelection aSel
= pEditView
->GetSelection();
443 ParaRange
aParas(aSel
.start
.nPara
, aSel
.end
.nPara
);
446 // Record the invisible Children of the last Parents in the selection
447 if ( bIncludeHiddenChildren
)
449 Paragraph
* pLast
= pOwner
->pParaList
->GetParagraph( aParas
.nEndPara
);
450 if ( pOwner
->pParaList
->HasHiddenChildren( pLast
) )
451 aParas
.nEndPara
= aParas
.nEndPara
+ pOwner
->pParaList
->GetChildCount( pLast
);
456 // TODO: Name should be changed!
457 void OutlinerView::AdjustDepth( short nDX
)
462 void OutlinerView::Indent( short nDiff
)
464 if( !nDiff
|| ( ( nDiff
> 0 ) && ImpCalcSelectedPages( true ) && !pOwner
->ImpCanIndentSelectedPages( this ) ) )
467 const bool bOutlinerView
= bool(pOwner
->pEditEngine
->GetControlWord() & EEControlBits::OUTLINER
);
468 bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout( false );
470 bool bUndo
= !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled();
473 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
475 sal_Int16 nMinDepth
= -1; // Optimization: avoid recalculate too many paragraphs if not really needed.
477 ParaRange aSel
= ImpGetSelectedParagraphs( true );
478 for ( sal_Int32 nPara
= aSel
.nStartPara
; nPara
<= aSel
.nEndPara
; nPara
++ )
480 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
482 sal_Int16 nOldDepth
= pPara
->GetDepth();
483 sal_Int16 nNewDepth
= nOldDepth
+ nDiff
;
485 if( bOutlinerView
&& nPara
)
487 const bool bPage
= pPara
->HasFlag(ParaFlag::ISPAGE
);
488 if( (bPage
&& (nDiff
== +1)) || (!bPage
&& (nDiff
== -1) && (nOldDepth
<= 0)) )
491 pOwner
->nDepthChangedHdlPrevDepth
= nOldDepth
;
492 ParaFlag nPrevFlags
= pPara
->nFlags
;
495 pPara
->RemoveFlag( ParaFlag::ISPAGE
);
497 pPara
->SetFlag( ParaFlag::ISPAGE
);
499 pOwner
->DepthChangedHdl(pPara
, nPrevFlags
);
500 pOwner
->pEditEngine
->QuickMarkInvalid(ESelection(nPara
, 0));
503 pOwner
->InsertUndo( std::make_unique
<OutlinerUndoChangeParaFlags
>( pOwner
, nPara
, nPrevFlags
, pPara
->nFlags
) );
509 // do not switch off numeration with tab
510 if( (nOldDepth
== 0) && (nNewDepth
== -1) )
513 // do not indent if there is no numeration enabled
514 if( nOldDepth
== -1 )
517 if ( nNewDepth
< Outliner::gnMinDepth
)
518 nNewDepth
= Outliner::gnMinDepth
;
519 if ( nNewDepth
> pOwner
->nMaxDepth
)
520 nNewDepth
= pOwner
->nMaxDepth
;
522 if( nOldDepth
< nMinDepth
)
523 nMinDepth
= nOldDepth
;
524 if( nNewDepth
< nMinDepth
)
525 nMinDepth
= nNewDepth
;
527 if( nOldDepth
!= nNewDepth
)
529 if ( ( nPara
== aSel
.nStartPara
) && aSel
.nStartPara
&& ( pOwner
->GetOutlinerMode() != OutlinerMode::TextObject
))
531 // Special case: the predecessor of an indented paragraph is
532 // invisible and is now on the same level as the visible
533 // paragraph. In this case, the next visible paragraph is
534 // searched for and fluffed.
536 Paragraph
* _pPara
= pOwner
->pParaList
->GetParagraph( aSel
.nStartPara
);
537 DBG_ASSERT(_pPara
->IsVisible(),"Selected Paragraph invisible ?!");
539 Paragraph
* pPrev
= pOwner
->pParaList
->GetParagraph( aSel
.nStartPara
-1 );
541 if( !pPrev
->IsVisible() && ( pPrev
->GetDepth() == nNewDepth
) )
543 // Predecessor is collapsed and is on the same level
544 // => find next visible paragraph and expand it
545 pPrev
= pOwner
->pParaList
->GetParent( pPrev
);
546 while( !pPrev
->IsVisible() )
547 pPrev
= pOwner
->pParaList
->GetParent( pPrev
);
549 pOwner
->Expand( pPrev
);
550 pOwner
->InvalidateBullet(pOwner
->pParaList
->GetAbsPos(pPrev
));
554 pOwner
->nDepthChangedHdlPrevDepth
= nOldDepth
;
555 ParaFlag nPrevFlags
= pPara
->nFlags
;
557 pOwner
->ImplInitDepth( nPara
, nNewDepth
, true );
558 pOwner
->ImplCalcBulletText( nPara
, false, false );
560 if ( pOwner
->GetOutlinerMode() == OutlinerMode::OutlineObject
)
561 pOwner
->ImplSetLevelDependentStyleSheet( nPara
);
564 pOwner
->DepthChangedHdl(pPara
, nPrevFlags
);
568 // Needs at least a repaint...
569 pOwner
->pEditEngine
->QuickMarkInvalid(ESelection(nPara
, 0));
573 sal_Int32 nParas
= pOwner
->pParaList
->GetParagraphCount();
574 for ( sal_Int32 n
= aSel
.nEndPara
+1; n
< nParas
; n
++ )
576 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( n
);
577 if ( pPara
->GetDepth() < nMinDepth
)
579 pOwner
->ImplCalcBulletText( n
, false, false );
584 pEditView
->SetEditEngineUpdateLayout( true );
585 pEditView
->ShowCursor();
589 pOwner
->UndoActionEnd();
592 void OutlinerView::AdjustHeight( tools::Long nDY
)
594 pEditView
->MoveParagraphs( nDY
);
597 tools::Rectangle
OutlinerView::GetVisArea() const
599 return pEditView
->GetVisArea();
602 void OutlinerView::Expand()
604 ParaRange aParas
= ImpGetSelectedParagraphs( false );
605 ImplExpandOrCollaps( aParas
.nStartPara
, aParas
.nEndPara
, true );
609 void OutlinerView::Collapse()
611 ParaRange aParas
= ImpGetSelectedParagraphs( false );
612 ImplExpandOrCollaps( aParas
.nStartPara
, aParas
.nEndPara
, false );
616 void OutlinerView::ExpandAll()
618 ImplExpandOrCollaps( 0, pOwner
->pParaList
->GetParagraphCount()-1, true );
622 void OutlinerView::CollapseAll()
624 ImplExpandOrCollaps( 0, pOwner
->pParaList
->GetParagraphCount()-1, false );
627 void OutlinerView::ImplExpandOrCollaps( sal_Int32 nStartPara
, sal_Int32 nEndPara
, bool bExpand
)
629 bool bUpdate
= pOwner
->SetUpdateLayout( false );
631 bool bUndo
= !pOwner
->IsInUndo() && pOwner
->IsUndoEnabled();
633 pOwner
->UndoActionStart( bExpand
? OLUNDO_EXPAND
: OLUNDO_COLLAPSE
);
635 for ( sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; nPara
++ )
637 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
638 bool bDone
= bExpand
? pOwner
->Expand( pPara
) : pOwner
->Collapse( pPara
);
641 // The line under the paragraph should disappear ...
642 pOwner
->pEditEngine
->QuickMarkToBeRepainted( nPara
);
647 pOwner
->UndoActionEnd();
651 pOwner
->SetUpdateLayout( true );
652 pEditView
->ShowCursor();
656 void OutlinerView::InsertText( const OutlinerParaObject
& rParaObj
)
658 // Like Paste, only EditView::Insert, instead of EditView::Paste.
659 // Actually not quite true that possible indentations must be corrected,
660 // but that comes later by a universal import. The indentation level is
661 // then determined right in the Inserted method.
662 // Possible structure:
663 // pImportInfo with DestPara, DestPos, nFormat, pParaObj...
664 // Possibly problematic:
665 // EditEngine, RTF => Splitting the area, later join together.
667 if ( ImpCalcSelectedPages( false ) && !pOwner
->ImpCanDeleteSelectedPages( this ) )
670 pOwner
->UndoActionStart( OLUNDO_INSERT
);
672 const bool bPrevUpdateLayout
= pOwner
->pEditEngine
->SetUpdateLayout( false );
673 sal_Int32 nStart
, nParaCount
;
674 nParaCount
= pOwner
->pEditEngine
->GetParagraphCount();
675 sal_uInt16 nSize
= ImpInitPaste( nStart
);
676 pEditView
->InsertText( rParaObj
.GetTextObject() );
677 ImpPasted( nStart
, nParaCount
, nSize
);
678 pEditView
->SetEditEngineUpdateLayout( bPrevUpdateLayout
);
680 pOwner
->UndoActionEnd();
682 pEditView
->ShowCursor();
686 void OutlinerView::Cut()
688 if ( !ImpCalcSelectedPages( false ) || pOwner
->ImpCanDeleteSelectedPages( this ) ) {
691 aEndCutPasteLink
.Call(nullptr);
695 void OutlinerView::PasteSpecial(SotClipboardFormatId format
)
697 Paste( true, format
);
700 void OutlinerView::Paste( bool bUseSpecial
, SotClipboardFormatId format
)
702 if ( ImpCalcSelectedPages( false ) && !pOwner
->ImpCanDeleteSelectedPages( this ) )
705 pOwner
->UndoActionStart( OLUNDO_INSERT
);
707 const bool bPrevUpdateLayout
= pOwner
->pEditEngine
->SetUpdateLayout( false );
708 pOwner
->bPasting
= true;
711 pEditView
->PasteSpecial(format
);
715 if ( pOwner
->GetOutlinerMode() == OutlinerMode::OutlineObject
)
717 const sal_Int32 nParaCount
= pOwner
->pEditEngine
->GetParagraphCount();
719 for( sal_Int32 nPara
= 0; nPara
< nParaCount
; nPara
++ )
720 pOwner
->ImplSetLevelDependentStyleSheet( nPara
);
723 pEditView
->SetEditEngineUpdateLayout( bPrevUpdateLayout
);
724 pOwner
->UndoActionEnd();
725 pEditView
->ShowCursor();
728 // NOTE: We need to do this last because it pEditView may be deleted if a switch of box occurs
729 aEndCutPasteLink
.Call(nullptr);
732 void OutlinerView::CreateSelectionList (std::vector
<Paragraph
*> &aSelList
)
734 ParaRange aParas
= ImpGetSelectedParagraphs( true );
736 for ( sal_Int32 nPara
= aParas
.nStartPara
; nPara
<= aParas
.nEndPara
; nPara
++ )
738 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
739 aSelList
.push_back(pPara
);
743 void OutlinerView::SetStyleSheet(const OUString
& rStyleName
)
745 ParaRange aParas
= ImpGetSelectedParagraphs(false);
747 auto pStyle
= pOwner
->GetStyleSheetPool()->Find(rStyleName
, SfxStyleFamily::Para
);
751 for (sal_Int32 nPara
= aParas
.nStartPara
; nPara
<= aParas
.nEndPara
; nPara
++)
752 pOwner
->SetStyleSheet(nPara
, static_cast<SfxStyleSheet
*>(pStyle
));
755 const SfxStyleSheet
* OutlinerView::GetStyleSheet() const
757 return pEditView
->GetStyleSheet();
760 SfxStyleSheet
* OutlinerView::GetStyleSheet()
762 return pEditView
->GetStyleSheet();
765 PointerStyle
OutlinerView::GetPointer( const Point
& rPosPixel
)
768 ImpCheckMousePos( rPosPixel
, eTarget
);
770 PointerStyle ePointerStyle
= PointerStyle::Arrow
;
771 if ( eTarget
== MouseTarget::Text
)
773 ePointerStyle
= GetOutliner()->IsVertical() ? PointerStyle::TextVertical
: PointerStyle::Text
;
775 else if ( eTarget
== MouseTarget::Hypertext
)
777 ePointerStyle
= PointerStyle::RefHand
;
779 else if ( eTarget
== MouseTarget::Bullet
)
781 ePointerStyle
= PointerStyle::Move
;
784 return ePointerStyle
;
788 sal_Int32
OutlinerView::ImpInitPaste( sal_Int32
& rStart
)
790 pOwner
->bPasting
= true;
791 ESelection
aSelection( pEditView
->GetSelection() );
793 rStart
= aSelection
.start
.nPara
;
794 sal_Int32 nSize
= aSelection
.end
.nPara
- aSelection
.start
.nPara
+ 1;
799 void OutlinerView::ImpPasted( sal_Int32 nStart
, sal_Int32 nPrevParaCount
, sal_Int32 nSize
)
801 pOwner
->bPasting
= false;
802 sal_Int32 nCurParaCount
= pOwner
->pEditEngine
->GetParagraphCount();
803 if( nCurParaCount
< nPrevParaCount
)
804 nSize
= nSize
- ( nPrevParaCount
- nCurParaCount
);
806 nSize
= nSize
+ ( nCurParaCount
- nPrevParaCount
);
807 pOwner
->ImpTextPasted( nStart
, nSize
);
810 bool OutlinerView::Command(const CommandEvent
& rCEvt
)
812 return pEditView
->Command(rCEvt
);
815 void OutlinerView::SelectRange( sal_Int32 nFirst
, sal_Int32 nCount
)
817 ESelection
aSel(nFirst
, 0, nFirst
+ nCount
, EE_TEXTPOS_MAX
);
818 pEditView
->SetSelection( aSel
);
822 sal_Int32
OutlinerView::ImpCalcSelectedPages( bool bIncludeFirstSelected
)
824 ESelection
aSel( pEditView
->GetSelection() );
827 sal_Int32 nPages
= 0;
828 sal_Int32 nFirstPage
= EE_PARA_MAX
;
829 sal_Int32 nStartPara
= aSel
.start
.nPara
;
830 if ( !bIncludeFirstSelected
)
831 nStartPara
++; // All paragraphs after StartPara will be deleted
832 for (sal_Int32 nPara
= nStartPara
; nPara
<= aSel
.end
.nPara
; nPara
++)
834 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
835 assert(pPara
&& "ImpCalcSelectedPages: invalid Selection?");
836 if( pPara
->HasFlag(ParaFlag::ISPAGE
) )
839 if (nFirstPage
== EE_PARA_MAX
)
846 pOwner
->nDepthChangedHdlPrevDepth
= nPages
;
847 pOwner
->mnFirstSelPage
= nFirstPage
;
854 void OutlinerView::ToggleBullets()
856 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
858 ESelection
aSel( pEditView
->GetSelection() );
861 const bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout( false );
863 sal_Int16 nNewDepth
= -2;
864 const SvxNumRule
* pDefaultBulletNumRule
= nullptr;
866 for (sal_Int32 nPara
= aSel
.start
.nPara
; nPara
<= aSel
.end
.nPara
; nPara
++)
868 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
869 DBG_ASSERT(pPara
, "OutlinerView::ToggleBullets(), illegal selection?");
873 if( nNewDepth
== -2 )
875 nNewDepth
= (pOwner
->GetDepth(nPara
) == -1) ? 0 : -1;
876 if ( nNewDepth
== 0 )
878 // determine default numbering rule for bullets
879 const ESelection
aSelection(nPara
, 0);
880 const SfxItemSet
aTmpSet(pOwner
->pEditEngine
->GetAttribs(aSelection
));
881 const SfxPoolItem
& rPoolItem
= aTmpSet
.GetPool()->GetUserOrPoolDefaultItem( EE_PARA_NUMBULLET
);
882 const SvxNumBulletItem
* pNumBulletItem
= dynamic_cast< const SvxNumBulletItem
* >(&rPoolItem
);
883 pDefaultBulletNumRule
= pNumBulletItem
? &pNumBulletItem
->GetNumRule() : nullptr;
887 pOwner
->SetDepth( pPara
, nNewDepth
);
889 if( nNewDepth
== -1 )
891 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs( nPara
);
892 if ( rAttrs
.GetItemState( EE_PARA_BULLETSTATE
) == SfxItemState::SET
)
894 SfxItemSet
aAttrs(rAttrs
);
895 aAttrs
.ClearItem( EE_PARA_BULLETSTATE
);
896 pOwner
->SetParaAttribs( nPara
, aAttrs
);
901 if ( pDefaultBulletNumRule
)
903 const SvxNumberFormat
* pFmt
= pOwner
->GetNumberFormat( nPara
);
905 || ( pFmt
->GetNumberingType() != SVX_NUM_BITMAP
906 && pFmt
->GetNumberingType() != SVX_NUM_CHAR_SPECIAL
) )
908 SfxItemSet
aAttrs( pOwner
->GetParaAttribs( nPara
) );
909 SvxNumRule
aNewNumRule( *pDefaultBulletNumRule
);
910 aAttrs
.Put( SvxNumBulletItem( std::move(aNewNumRule
), EE_PARA_NUMBULLET
) );
911 pOwner
->SetParaAttribs( nPara
, aAttrs
);
918 const sal_Int32 nParaCount
= pOwner
->pParaList
->GetParagraphCount();
919 pOwner
->ImplCheckParagraphs(aSel
.start
.nPara
, nParaCount
);
921 sal_Int32 nEndPara
= (nParaCount
> 0) ? nParaCount
-1 : nParaCount
;
922 pOwner
->pEditEngine
->QuickMarkInvalid(ESelection(aSel
.start
.nPara
, 0, nEndPara
, 0));
924 pOwner
->pEditEngine
->SetUpdateLayout( bUpdate
);
926 pOwner
->UndoActionEnd();
930 void OutlinerView::ToggleBulletsNumbering(
932 const bool bHandleBullets
,
933 const SvxNumRule
* pNumRule
)
935 ESelection
aSel( pEditView
->GetSelection() );
938 bool bToggleOn
= true;
942 const sal_Int16
nBulletNumberingStatus( pOwner
->GetBulletsNumberingStatus( aSel
.start
.nPara
, aSel
.end
.nPara
) );
943 if ( nBulletNumberingStatus
!= 0 && bHandleBullets
)
945 // not all paragraphs have bullets and method called to toggle bullets --> bullets on
948 else if ( nBulletNumberingStatus
!= 1 && !bHandleBullets
)
950 // not all paragraphs have numbering and method called to toggle numberings --> numberings on
956 // apply bullets/numbering for selected paragraphs
957 ApplyBulletsNumbering( bHandleBullets
, pNumRule
, bToggle
, true );
961 // switch off bullets/numbering for selected paragraphs
962 SwitchOffBulletsNumbering( true );
966 void OutlinerView::EnsureNumberingIsOn()
968 pOwner
->UndoActionStart(OLUNDO_DEPTH
);
970 ESelection
aSel(pEditView
->GetSelection());
973 const bool bUpdate
= pOwner
->pEditEngine
->IsUpdateLayout();
974 pOwner
->pEditEngine
->SetUpdateLayout(false);
976 for (sal_Int32 nPara
= aSel
.start
.nPara
; nPara
<= aSel
.end
.nPara
; nPara
++)
978 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph(nPara
);
979 DBG_ASSERT(pPara
, "OutlinerView::EnableBullets(), illegal selection?");
981 if (pPara
&& pOwner
->GetDepth(nPara
) == -1)
982 pOwner
->SetDepth(pPara
, 0);
985 sal_Int32 nParaCount
= pOwner
->pParaList
->GetParagraphCount();
986 pOwner
->ImplCheckParagraphs(aSel
.start
.nPara
, nParaCount
);
988 const sal_Int32 nEndPara
= (nParaCount
> 0) ? nParaCount
-1 : nParaCount
;
989 pOwner
->pEditEngine
->QuickMarkInvalid(ESelection(aSel
.start
.nPara
, 0, nEndPara
, 0));
991 pOwner
->pEditEngine
->SetUpdateLayout(bUpdate
);
993 pOwner
->UndoActionEnd();
996 void OutlinerView::ApplyBulletsNumbering(
997 const bool bHandleBullets
,
998 const SvxNumRule
* pNewNumRule
,
999 const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule
,
1000 const bool bAtSelection
)
1002 if (!pOwner
|| !pOwner
->pEditEngine
|| !pOwner
->pParaList
)
1007 pOwner
->UndoActionStart(OLUNDO_DEPTH
);
1008 const bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout(false);
1010 sal_Int32 nStartPara
= 0;
1011 sal_Int32 nEndPara
= 0;
1014 ESelection
aSel( pEditView
->GetSelection() );
1016 nStartPara
= aSel
.start
.nPara
;
1017 nEndPara
= aSel
.end
.nPara
;
1022 nEndPara
= pOwner
->pParaList
->GetParagraphCount() - 1;
1025 for (sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; ++nPara
)
1027 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph(nPara
);
1028 DBG_ASSERT(pPara
, "OutlinerView::ApplyBulletsNumbering(..), illegal selection?");
1032 const sal_Int16 nDepth
= pOwner
->GetDepth(nPara
);
1035 pOwner
->SetDepth( pPara
, 0 );
1038 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs(nPara
);
1039 SfxItemSet
aAttrs(rAttrs
);
1040 aAttrs
.Put(SfxBoolItem(EE_PARA_BULLETSTATE
, true));
1042 // apply new numbering rule
1045 bool bApplyNumRule
= false;
1046 if ( !bCheckCurrentNumRuleBeforeApplyingNewNumRule
)
1048 bApplyNumRule
= true;
1052 const SvxNumberFormat
* pFmt
= pOwner
->GetNumberFormat(nPara
);
1055 bApplyNumRule
= true;
1059 sal_Int16 nNumType
= pFmt
->GetNumberingType();
1061 && nNumType
!= SVX_NUM_BITMAP
&& nNumType
!= SVX_NUM_CHAR_SPECIAL
)
1063 // Set to Normal bullet, old bullet type is Numbering bullet.
1064 bApplyNumRule
= true;
1066 else if ( !bHandleBullets
1067 && (nNumType
== SVX_NUM_BITMAP
|| nNumType
== SVX_NUM_CHAR_SPECIAL
))
1069 // Set to Numbering bullet, old bullet type is Normal bullet.
1070 bApplyNumRule
= true;
1075 if ( bApplyNumRule
)
1077 SvxNumRule
aNewRule(*pNewNumRule
);
1079 // Get old bullet space.
1081 const SvxNumBulletItem
* pNumBulletItem
= rAttrs
.GetItemIfSet(EE_PARA_NUMBULLET
, false);
1084 // Use default value when has not contain bullet item.
1085 ESelection
aSelection(nPara
, 0);
1086 SfxItemSet
aTmpSet(pOwner
->pEditEngine
->GetAttribs(aSelection
));
1087 pNumBulletItem
= aTmpSet
.GetItem(EE_PARA_NUMBULLET
);
1092 const sal_uInt16 nLevelCnt
= std::min(pNumBulletItem
->GetNumRule().GetLevelCount(), aNewRule
.GetLevelCount());
1093 for ( sal_uInt16 nLevel
= 0; nLevel
< nLevelCnt
; ++nLevel
)
1095 const SvxNumberFormat
* pOldFmt
= pNumBulletItem
->GetNumRule().Get(nLevel
);
1096 const SvxNumberFormat
* pNewFmt
= aNewRule
.Get(nLevel
);
1097 if (pOldFmt
&& pNewFmt
&& (pOldFmt
->GetFirstLineOffset() != pNewFmt
->GetFirstLineOffset() || pOldFmt
->GetAbsLSpace() != pNewFmt
->GetAbsLSpace()))
1099 SvxNumberFormat
aNewFmtClone(*pNewFmt
);
1100 aNewFmtClone
.SetFirstLineOffset(pOldFmt
->GetFirstLineOffset());
1101 aNewFmtClone
.SetAbsLSpace(pOldFmt
->GetAbsLSpace());
1102 aNewRule
.SetLevel(nLevel
, &aNewFmtClone
);
1108 aAttrs
.Put(SvxNumBulletItem(std::move(aNewRule
), EE_PARA_NUMBULLET
));
1111 pOwner
->SetParaAttribs(nPara
, aAttrs
);
1115 const sal_uInt16 nParaCount
= static_cast<sal_uInt16
>(pOwner
->pParaList
->GetParagraphCount());
1116 pOwner
->ImplCheckParagraphs( nStartPara
, nParaCount
);
1117 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nStartPara
, 0, nParaCount
, 0 ) );
1119 pOwner
->pEditEngine
->SetUpdateLayout( bUpdate
);
1121 pOwner
->UndoActionEnd();
1125 void OutlinerView::SwitchOffBulletsNumbering(
1126 const bool bAtSelection
)
1128 sal_Int32 nStartPara
= 0;
1129 sal_Int32 nEndPara
= 0;
1132 ESelection
aSel( pEditView
->GetSelection() );
1134 nStartPara
= aSel
.start
.nPara
;
1135 nEndPara
= aSel
.end
.nPara
;
1140 nEndPara
= pOwner
->pParaList
->GetParagraphCount() - 1;
1143 pOwner
->UndoActionStart( OLUNDO_DEPTH
);
1144 const bool bUpdate
= pOwner
->pEditEngine
->SetUpdateLayout( false );
1146 for ( sal_Int32 nPara
= nStartPara
; nPara
<= nEndPara
; ++nPara
)
1148 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
1149 DBG_ASSERT(pPara
, "OutlinerView::SwitchOffBulletsNumbering(...), illegal paragraph index?");
1153 pOwner
->SetDepth( pPara
, -1 );
1155 const SfxItemSet
& rAttrs
= pOwner
->GetParaAttribs( nPara
);
1156 if (rAttrs
.GetItemState( EE_PARA_BULLETSTATE
) == SfxItemState::SET
)
1158 SfxItemSet
aAttrs(rAttrs
);
1159 aAttrs
.ClearItem( EE_PARA_BULLETSTATE
);
1160 pOwner
->SetParaAttribs( nPara
, aAttrs
);
1165 const sal_uInt16 nParaCount
= static_cast<sal_uInt16
>(pOwner
->pParaList
->GetParagraphCount());
1166 pOwner
->ImplCheckParagraphs( nStartPara
, nParaCount
);
1167 pOwner
->pEditEngine
->QuickMarkInvalid( ESelection( nStartPara
, 0, nParaCount
, 0 ) );
1169 pOwner
->pEditEngine
->SetUpdateLayout( bUpdate
);
1170 pOwner
->UndoActionEnd();
1174 void OutlinerView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs
)
1176 RemoveAttribs( bRemoveParaAttribs
, true /*keep language attribs*/ );
1179 void OutlinerView::RemoveAttribs( bool bRemoveParaAttribs
, bool bKeepLanguages
)
1181 bool bUpdate
= pOwner
->SetUpdateLayout( false );
1182 pOwner
->UndoActionStart( OLUNDO_ATTR
);
1184 pEditView
->RemoveAttribsKeepLanguages( bRemoveParaAttribs
);
1186 pEditView
->RemoveAttribs( bRemoveParaAttribs
);
1187 if ( bRemoveParaAttribs
)
1189 // Loop through all paragraphs and set indentation and level
1190 ESelection aSel
= pEditView
->GetSelection();
1192 for (sal_Int32 nPara
= aSel
.start
.nPara
; nPara
<= aSel
.end
.nPara
; nPara
++)
1194 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
1195 pOwner
->ImplInitDepth( nPara
, pPara
->GetDepth(), false );
1198 pOwner
->UndoActionEnd();
1199 pOwner
->SetUpdateLayout( bUpdate
);
1203 // ====================== Simple pass-through =======================
1206 void OutlinerView::InsertText( const OUString
& rNew
, bool bSelect
)
1208 if( pOwner
->bFirstParaIsEmpty
)
1209 pOwner
->Insert( OUString() );
1210 pEditView
->InsertText( rNew
, bSelect
);
1213 void OutlinerView::SetVisArea( const tools::Rectangle
& rRect
)
1215 pEditView
->SetVisArea( rRect
);
1219 void OutlinerView::SetSelection( const ESelection
& rSel
)
1221 pEditView
->SetSelection( rSel
);
1224 void OutlinerView::GetSelectionRectangles(std::vector
<tools::Rectangle
>& rLogicRects
) const
1226 pEditView
->GetSelectionRectangles(rLogicRects
);
1229 void OutlinerView::SetReadOnly( bool bReadOnly
)
1231 pEditView
->SetReadOnly( bReadOnly
);
1234 bool OutlinerView::IsReadOnly() const
1236 return pEditView
->IsReadOnly();
1239 bool OutlinerView::HasSelection() const
1241 return pEditView
->HasSelection();
1244 void OutlinerView::ShowCursor( bool bGotoCursor
, bool bActivate
)
1246 pEditView
->ShowCursor( bGotoCursor
, /*bForceVisCursor=*/true, bActivate
);
1249 void OutlinerView::HideCursor(bool bDeactivate
)
1251 pEditView
->HideCursor(bDeactivate
);
1254 bool OutlinerView::IsCursorVisible() const { return pEditView
->IsCursorVisible(); }
1256 void OutlinerView::SetWindow( vcl::Window
* pWin
)
1258 pEditView
->SetWindow( pWin
);
1261 vcl::Window
* OutlinerView::GetWindow() const
1263 return pEditView
->GetWindow();
1266 void OutlinerView::SetOutputArea( const tools::Rectangle
& rRect
)
1268 pEditView
->SetOutputArea( rRect
);
1271 tools::Rectangle
const & OutlinerView::GetOutputArea() const
1273 return pEditView
->GetOutputArea();
1276 OUString
OutlinerView::GetSelected() const
1278 return pEditView
->GetSelected();
1281 void OutlinerView::StartSpeller(weld::Widget
* pDialogParent
)
1283 pEditView
->StartSpeller(pDialogParent
);
1286 EESpellState
OutlinerView::StartThesaurus(weld::Widget
* pDialogParent
)
1288 return pEditView
->StartThesaurus(pDialogParent
);
1291 void OutlinerView::StartTextConversion(weld::Widget
* pDialogParent
,
1292 LanguageType nSrcLang
, LanguageType nDestLang
, const vcl::Font
*pDestFont
,
1293 sal_Int32 nOptions
, bool bIsInteractive
, bool bMultipleDoc
)
1296 (LANGUAGE_KOREAN
== nSrcLang
&& LANGUAGE_KOREAN
== nDestLang
) ||
1297 (LANGUAGE_CHINESE_SIMPLIFIED
== nSrcLang
&& LANGUAGE_CHINESE_TRADITIONAL
== nDestLang
) ||
1298 (LANGUAGE_CHINESE_TRADITIONAL
== nSrcLang
&& LANGUAGE_CHINESE_SIMPLIFIED
== nDestLang
)
1301 pEditView
->StartTextConversion(pDialogParent
, nSrcLang
, nDestLang
, pDestFont
, nOptions
, bIsInteractive
, bMultipleDoc
);
1305 OSL_FAIL( "unexpected language" );
1310 sal_Int32
OutlinerView::StartSearchAndReplace( const SvxSearchItem
& rSearchItem
)
1312 return pEditView
->StartSearchAndReplace( rSearchItem
);
1315 void OutlinerView::TransliterateText( TransliterationFlags nTransliterationMode
)
1317 pEditView
->TransliterateText( nTransliterationMode
);
1320 ESelection
OutlinerView::GetSelection() const
1322 return pEditView
->GetSelection();
1326 void OutlinerView::Scroll( tools::Long nHorzScroll
, tools::Long nVertScroll
)
1328 pEditView
->Scroll( nHorzScroll
, nVertScroll
);
1331 void OutlinerView::SetControlWord( EVControlBits nWord
)
1333 pEditView
->SetControlWord( nWord
);
1336 EVControlBits
OutlinerView::GetControlWord() const
1338 return pEditView
->GetControlWord();
1341 void OutlinerView::SetAnchorMode( EEAnchorMode eMode
)
1343 pEditView
->SetAnchorMode( eMode
);
1346 EEAnchorMode
OutlinerView::GetAnchorMode() const
1348 return pEditView
->GetAnchorMode();
1351 void OutlinerView::Copy()
1356 void OutlinerView::InsertField( const SvxFieldItem
& rFld
)
1358 pEditView
->InsertField( rFld
);
1361 const SvxFieldItem
* OutlinerView::GetFieldUnderMousePointer() const
1363 return pEditView
->GetFieldUnderMousePointer();
1366 const SvxFieldItem
* OutlinerView::GetFieldAtSelection(bool bAlsoCheckBeforeCursor
) const
1368 return pEditView
->GetFieldAtSelection(bAlsoCheckBeforeCursor
);
1371 void OutlinerView::SelectFieldAtCursor()
1373 pEditView
->SelectFieldAtCursor();
1376 void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel
)
1378 pEditView
->SetInvalidateMore( nPixel
);
1382 sal_uInt16
OutlinerView::GetInvalidateMore() const
1384 return pEditView
->GetInvalidateMore();
1388 bool OutlinerView::IsCursorAtWrongSpelledWord()
1390 return pEditView
->IsCursorAtWrongSpelledWord();
1394 bool OutlinerView::IsWrongSpelledWordAtPos( const Point
& rPosPixel
)
1396 return pEditView
->IsWrongSpelledWordAtPos( rPosPixel
, /*bMarkIfWrong*/false );
1399 void OutlinerView::ExecuteSpellPopup(const Point
& rPosPixel
, const Link
<SpellCallbackInfo
&,void>& rStartDlg
)
1401 pEditView
->ExecuteSpellPopup(rPosPixel
, rStartDlg
);
1404 void OutlinerView::Read( SvStream
& rInput
, EETextFormat eFormat
, SvKeyValueIterator
* pHTTPHeaderAttrs
)
1406 sal_Int32 nOldParaCount
= pEditView
->getEditEngine().GetParagraphCount();
1407 ESelection aOldSel
= pEditView
->GetSelection();
1410 pEditView
->Read( rInput
, eFormat
, pHTTPHeaderAttrs
);
1412 tools::Long nParaDiff
= pEditView
->getEditEngine().GetParagraphCount() - nOldParaCount
;
1413 sal_Int32 nChangesStart
= aOldSel
.start
.nPara
;
1414 sal_Int32 nChangesEnd
= nChangesStart
+ nParaDiff
+ (aOldSel
.end
.nPara
-aOldSel
.start
.nPara
);
1416 for ( sal_Int32 n
= nChangesStart
; n
<= nChangesEnd
; n
++ )
1418 if ( pOwner
->GetOutlinerMode() == OutlinerMode::OutlineObject
)
1419 pOwner
->ImplSetLevelDependentStyleSheet( n
);
1422 pOwner
->ImpFilterIndents( nChangesStart
, nChangesEnd
);
1425 void OutlinerView::SetBackgroundColor( const Color
& rColor
)
1427 pEditView
->SetBackgroundColor( rColor
);
1430 void OutlinerView::RegisterViewShell(OutlinerViewShell
* pViewShell
)
1432 pEditView
->RegisterViewShell(pViewShell
);
1435 Color
const & OutlinerView::GetBackgroundColor() const
1437 return pEditView
->GetBackgroundColor();
1440 SfxItemSet
OutlinerView::GetAttribs()
1442 return pEditView
->GetAttribs();
1445 SvtScriptType
OutlinerView::GetSelectedScriptType() const
1447 return pEditView
->GetSelectedScriptType();
1450 OUString
OutlinerView::GetSurroundingText() const
1452 return pEditView
->GetSurroundingText();
1455 Selection
OutlinerView::GetSurroundingTextSelection() const
1457 return pEditView
->GetSurroundingTextSelection();
1460 bool OutlinerView::DeleteSurroundingText(const Selection
& rSelection
)
1462 return pEditView
->DeleteSurroundingText(rSelection
);
1465 // ===== some code for thesaurus sub menu within context menu
1469 bool isSingleScriptType( SvtScriptType nScriptType
)
1471 sal_uInt8 nScriptCount
= 0;
1473 if (nScriptType
& SvtScriptType::LATIN
)
1475 if (nScriptType
& SvtScriptType::ASIAN
)
1477 if (nScriptType
& SvtScriptType::COMPLEX
)
1480 return nScriptCount
== 1;
1485 // returns: true if a word for thesaurus look-up was found at the current cursor position.
1486 // The status string will be word + iso language string (e.g. "light#en-US")
1487 bool GetStatusValueForThesaurusFromContext(
1488 OUString
&rStatusVal
,
1489 LanguageType
&rLang
,
1490 const EditView
&rEditView
)
1492 // get text and locale for thesaurus look up
1494 EditEngine
& rEditEngine
= rEditView
.getEditEngine();
1495 ESelection
aTextSel( rEditView
.GetSelection() );
1496 if (!aTextSel
.HasRange())
1497 aTextSel
= rEditEngine
.GetWord( aTextSel
, i18n::WordType::DICTIONARY_WORD
);
1498 aText
= rEditEngine
.GetText( aTextSel
);
1501 if (!isSingleScriptType(rEditEngine
.GetScriptType(aTextSel
)))
1504 LanguageType nLang
= rEditEngine
.GetLanguage(aTextSel
.start
.nPara
, aTextSel
.start
.nIndex
).nLang
;
1505 OUString
aLangText( LanguageTag::convertToBcp47( nLang
) );
1507 // set word and locale to look up as status value
1508 rStatusVal
= aText
+ "#" + aLangText
;
1511 return aText
.getLength() > 0;
1515 void ReplaceTextWithSynonym( EditView
&rEditView
, const OUString
&rSynonmText
)
1517 // get selection to use
1518 ESelection
aCurSel( rEditView
.GetSelection() );
1519 if (!rEditView
.HasSelection())
1521 // select the same word that was used in GetStatusValueForThesaurusFromContext by calling GetWord.
1522 // (In the end both functions will call ImpEditEngine::SelectWord)
1523 rEditView
.SelectCurrentWord( i18n::WordType::DICTIONARY_WORD
);
1524 aCurSel
= rEditView
.GetSelection();
1528 rEditView
.InsertText( rSynonmText
);
1529 rEditView
.ShowCursor( true, false );
1533 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */