LibreOffice Module editeng (master) 1
outlvw.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <memory>
21#include <com/sun/star/i18n/WordType.hpp>
22
23#include <svl/itempool.hxx>
24#include <editeng/editeng.hxx>
25#include <editeng/editview.hxx>
26#include <editeng/editdata.hxx>
27
28#include <svl/style.hxx>
31
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>
49
50using namespace ::com::sun::star;
51
52
54{
55 pOwner = pOut;
56 pEditView.reset( new EditView( pOut->pEditEngine.get(), pWin ) );
57}
58
60{
61}
62
63void OutlinerView::Paint( const tools::Rectangle& rRect, OutputDevice* pTargetDevice )
64{
65 // For the first Paint/KeyInput/Drop an empty Outliner is turned into
66 // an Outliner with exactly one paragraph.
68 pOwner->Insert( OUString() );
69
70 pEditView->Paint( rRect, pTargetDevice );
71}
72
73bool OutlinerView::PostKeyEvent( const KeyEvent& rKEvt, vcl::Window const * pFrameWin )
74{
75 // For the first Paint/KeyInput/Drop an empty Outliner is turned into
76 // an Outliner with exactly one paragraph.
78 pOwner->Insert( OUString() );
79
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();
87
88 if( bSelection && ( nCode != KEY_TAB ) && EditEngine::DoesKeyChangeText( rKEvt ) )
89 {
90 if ( ImpCalcSelectedPages( false ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
91 return true;
92 }
93
94 if ( eFunc != KeyFuncType::DONTKNOW )
95 {
96 switch ( eFunc )
97 {
98 case KeyFuncType::CUT:
99 {
100 if ( !bReadOnly )
101 {
102 Cut();
103 bKeyProcessed = true;
104 }
105 }
106 break;
107 case KeyFuncType::COPY:
108 {
109 Copy();
110 bKeyProcessed = true;
111 }
112 break;
113 case KeyFuncType::PASTE:
114 {
115 if ( !bReadOnly )
116 {
117 PasteSpecial();
118 bKeyProcessed = true;
119 }
120 }
121 break;
122 case KeyFuncType::DELETE:
123 {
124 if( !bReadOnly && !bSelection && ( pOwner->GetOutlinerMode() != OutlinerMode::TextObject ) )
125 {
126 if( aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
127 {
128 Paragraph* pNext = pOwner->pParaList->GetParagraph( aSel.nEndPara+1 );
129 if( pNext && pNext->HasFlag(ParaFlag::ISPAGE) )
130 {
131 if( !pOwner->ImpCanDeleteSelectedPages( this, aSel.nEndPara, 1 ) )
132 return false;
133 }
134 }
135 }
136 }
137 break;
138 default: // is then possibly edited below.
139 eFunc = KeyFuncType::DONTKNOW;
140 }
141 }
142 if ( eFunc == KeyFuncType::DONTKNOW )
143 {
144 switch ( nCode )
145 {
146 case KEY_TAB:
147 {
148 if ( !bReadOnly && !aKeyCode.IsMod1() && !aKeyCode.IsMod2() )
149 {
152 ( bSelection || !aSel.nStartPos ) )
153 {
154 Indent( aKeyCode.IsShift() ? -1 : +1 );
155 bKeyProcessed = true;
156 }
157 else if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) &&
158 !bSelection && !aSel.nEndPos && pOwner->ImplHasNumberFormat( aSel.nEndPara ) )
159 {
160 Indent( aKeyCode.IsShift() ? -1 : +1 );
161 bKeyProcessed = true;
162 }
163 }
164 }
165 break;
166 case KEY_BACKSPACE:
167 {
168 if( !bReadOnly && !bSelection && aSel.nEndPara && !aSel.nEndPos )
169 {
170 Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
171 Paragraph* pPrev = pOwner->pParaList->GetParagraph( aSel.nEndPara-1 );
172 if( !pPrev->IsVisible() )
173 return true;
174 if( !pPara->GetDepth() )
175 {
176 if(!pOwner->ImpCanDeleteSelectedPages(this, aSel.nEndPara , 1 ) )
177 return true;
178 }
179 }
180 }
181 break;
182 case KEY_RETURN:
183 {
184 if ( !bReadOnly )
185 {
186 // Special treatment: hard return at the end of a paragraph,
187 // which has collapsed subparagraphs.
188 Paragraph* pPara = pOwner->pParaList->GetParagraph( aSel.nEndPara );
189
190 if( !aKeyCode.IsShift() )
191 {
192 // ImpGetCursor again???
193 if( !bSelection &&
194 aSel.nEndPos == pOwner->pEditEngine->GetTextLen( aSel.nEndPara ) )
195 {
196 sal_Int32 nChildren = pOwner->pParaList->GetChildCount(pPara);
197 if( nChildren && !pOwner->pParaList->HasVisibleChildren(pPara))
198 {
200 sal_Int32 nTemp = aSel.nEndPara;
201 nTemp += nChildren;
202 nTemp++; // insert above next Non-Child
203 SAL_WARN_IF( nTemp < 0, "editeng", "OutlinerView::PostKeyEvent - overflow");
204 if (nTemp >= 0)
205 {
206 pOwner->Insert( OUString(),nTemp,pPara->GetDepth());
207 // Position the cursor
208 ESelection aTmpSel(nTemp,0,nTemp,0);
209 pEditView->SetSelection( aTmpSel );
210 }
211 pEditView->ShowCursor();
213 bKeyProcessed = true;
214 }
215 }
216 }
217 if( !bKeyProcessed && !bSelection &&
218 !aKeyCode.IsShift() && aKeyCode.IsMod1() &&
219 ( aSel.nEndPos == pOwner->pEditEngine->GetTextLen(aSel.nEndPara) ) )
220 {
222 sal_Int32 nTemp = aSel.nEndPara;
223 nTemp++;
224 pOwner->Insert( OUString(), nTemp, pPara->GetDepth()+1 );
225
226 // Position the cursor
227 ESelection aTmpSel(nTemp,0,nTemp,0);
228 pEditView->SetSelection( aTmpSel );
229 pEditView->ShowCursor();
231 bKeyProcessed = true;
232 }
233 }
234 }
235 break;
236 }
237 }
238
239 return bKeyProcessed || pEditView->PostKeyEvent( rKEvt, pFrameWin );
240}
241
242sal_Int32 OutlinerView::ImpCheckMousePos(const Point& rPosPix, MouseTarget& reTarget)
243{
244 sal_Int32 nPara = EE_PARA_NOT_FOUND;
245
246 Point aMousePosWin = pEditView->GetOutputDevice().PixelToLogic( rPosPix );
247 if( !pEditView->GetOutputArea().Contains( aMousePosWin ) )
248 {
249 reTarget = MouseTarget::Outside;
250 }
251 else
252 {
253 reTarget = MouseTarget::Text;
254
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() );
262
263 bool bBullet;
264 if ( pOwner->IsTextPos( aPaperPos, 0, &bBullet ) )
265 {
266 Point aDocPos = pOwner->GetDocPos( aPaperPos );
267 nPara = pOwner->pEditEngine->FindParagraph( aDocPos.Y() );
268
269 if ( bBullet )
270 {
271 reTarget = MouseTarget::Bullet;
272 }
273 else
274 {
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;
279 }
280 }
281 }
282 return nPara;
283}
284
286{
287 if( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->GetEditEngine()->IsInSelectionMode())
288 return pEditView->MouseMove( rMEvt );
289
290 Point aMousePosWin( pEditView->GetOutputDevice().PixelToLogic( rMEvt.GetPosPixel() ) );
291 if( !pEditView->GetOutputArea().Contains( aMousePosWin ) )
292 return false;
293
294 PointerStyle aPointer = GetPointer( rMEvt.GetPosPixel() );
295 pEditView->GetWindow()->SetPointer( aPointer );
296 return pEditView->MouseMove( rMEvt );
297}
298
299
301{
302 if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->GetEditEngine()->IsInSelectionMode() )
303 return pEditView->MouseButtonDown( rMEvt );
304
305 Point aMousePosWin( pEditView->GetOutputDevice().PixelToLogic( rMEvt.GetPosPixel() ) );
306 if( !pEditView->GetOutputArea().Contains( aMousePosWin ) )
307 return false;
308
309 PointerStyle aPointer = GetPointer( rMEvt.GetPosPixel() );
310 pEditView->GetWindow()->SetPointer( aPointer );
311
312 MouseTarget eTarget;
313 sal_Int32 nPara = ImpCheckMousePos( rMEvt.GetPosPixel(), eTarget );
314 if ( eTarget == MouseTarget::Bullet )
315 {
316 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
317 bool bHasChildren = (pPara && pOwner->pParaList->HasChildren(pPara));
318 if( rMEvt.GetClicks() == 1 )
319 {
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 );
326 }
327 else if( rMEvt.GetClicks() == 2 && bHasChildren )
328 ImpToggleExpand( pPara );
329
330 return true;
331 }
332
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) )
335 {
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) )
340 {
341 ImpToggleExpand( pPara );
342 }
343 }
344 return pEditView->MouseButtonDown( rMEvt );
345}
346
347
349{
350 if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->GetEditEngine()->IsInSelectionMode() )
351 return pEditView->MouseButtonUp( rMEvt );
352
353 Point aMousePosWin( pEditView->GetOutputDevice().PixelToLogic( rMEvt.GetPosPixel() ) );
354 if( !pEditView->GetOutputArea().Contains( aMousePosWin ) )
355 return false;
356
357 PointerStyle aPointer = GetPointer( rMEvt.GetPosPixel() );
358 pEditView->GetWindow()->SetPointer( aPointer );
359
360 return pEditView->MouseButtonUp( rMEvt );
361}
362
364{
365 pEditView->ReleaseMouse();
366}
367
369{
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();
374}
375
376void OutlinerView::Select( Paragraph const * pParagraph, bool bSelect )
377{
378 sal_Int32 nPara = pOwner->pParaList->GetAbsPos( pParagraph );
379 sal_Int32 nEnd = 0;
380 if ( bSelect )
381 nEnd = SAL_MAX_INT32;
382
383 ESelection aSel( nPara, 0, nPara, nEnd );
384 pEditView->SetSelection( aSel );
385}
386
387
389{
390 bool bUpdate = pOwner->pEditEngine->SetUpdateLayout( false );
391
392 if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
394
395 ParaRange aSel = ImpGetSelectedParagraphs( false );
396
397 pEditView->SetAttribs( rAttrs );
398
399 // Update Bullet text
400 for( sal_Int32 nPara= aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
401 {
403 pOwner->ImplCalcBulletText( nPara, false, false );
404
405 if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
406 pOwner->InsertUndo( std::make_unique<OutlinerUndoCheckPara>( pOwner, nPara ) );
407 }
408
409 if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
411
412 pEditView->SetEditEngineUpdateLayout( bUpdate );
413}
414
416{
417 ESelection aSel = pEditView->GetSelection();
418 ParaRange aParas( aSel.nStartPara, aSel.nEndPara );
419 aParas.Adjust();
420
421 // Record the invisible Children of the last Parents in the selection
422 if ( bIncludeHiddenChildren )
423 {
424 Paragraph* pLast = pOwner->pParaList->GetParagraph( aParas.nEndPara );
425 if ( pOwner->pParaList->HasHiddenChildren( pLast ) )
426 aParas.nEndPara = aParas.nEndPara + pOwner->pParaList->GetChildCount( pLast );
427 }
428 return aParas;
429}
430
431// TODO: Name should be changed!
433{
434 Indent( nDX );
435}
436
437void OutlinerView::Indent( short nDiff )
438{
439 if( !nDiff || ( ( nDiff > 0 ) && ImpCalcSelectedPages( true ) && !pOwner->ImpCanIndentSelectedPages( this ) ) )
440 return;
441
442 const bool bOutlinerView = bool(pOwner->pEditEngine->GetControlWord() & EEControlBits::OUTLINER);
443 bool bUpdate = pOwner->pEditEngine->SetUpdateLayout( false );
444
445 bool bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
446
447 if( bUndo )
449
450 sal_Int16 nMinDepth = -1; // Optimization: avoid recalculate too many paragraphs if not really needed.
451
452 ParaRange aSel = ImpGetSelectedParagraphs( true );
453 for ( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
454 {
455 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
456
457 sal_Int16 nOldDepth = pPara->GetDepth();
458 sal_Int16 nNewDepth = nOldDepth + nDiff;
459
460 if( bOutlinerView && nPara )
461 {
462 const bool bPage = pPara->HasFlag(ParaFlag::ISPAGE);
463 if( (bPage && (nDiff == +1)) || (!bPage && (nDiff == -1) && (nOldDepth <= 0)) )
464 {
465 // Notify App
467 ParaFlag nPrevFlags = pPara->nFlags;
468
469 if( bPage )
471 else
472 pPara->SetFlag( ParaFlag::ISPAGE );
473
474 pOwner->DepthChangedHdl(pPara, nPrevFlags);
475 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
476
477 if( bUndo )
478 pOwner->InsertUndo( std::make_unique<OutlinerUndoChangeParaFlags>( pOwner, nPara, nPrevFlags, pPara->nFlags ) );
479
480 continue;
481 }
482 }
483
484 // do not switch off numeration with tab
485 if( (nOldDepth == 0) && (nNewDepth == -1) )
486 continue;
487
488 // do not indent if there is no numeration enabled
489 if( nOldDepth == -1 )
490 continue;
491
492 if ( nNewDepth < Outliner::gnMinDepth )
493 nNewDepth = Outliner::gnMinDepth;
494 if ( nNewDepth > pOwner->nMaxDepth )
495 nNewDepth = pOwner->nMaxDepth;
496
497 if( nOldDepth < nMinDepth )
498 nMinDepth = nOldDepth;
499 if( nNewDepth < nMinDepth )
500 nMinDepth = nNewDepth;
501
502 if( nOldDepth != nNewDepth )
503 {
504 if ( ( nPara == aSel.nStartPara ) && aSel.nStartPara && ( pOwner->GetOutlinerMode() != OutlinerMode::TextObject ))
505 {
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.
510#ifdef DBG_UTIL
511 Paragraph* _pPara = pOwner->pParaList->GetParagraph( aSel.nStartPara );
512 DBG_ASSERT(_pPara->IsVisible(),"Selected Paragraph invisible ?!");
513#endif
514 Paragraph* pPrev= pOwner->pParaList->GetParagraph( aSel.nStartPara-1 );
515
516 if( !pPrev->IsVisible() && ( pPrev->GetDepth() == nNewDepth ) )
517 {
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 );
523
524 pOwner->Expand( pPrev );
525 pOwner->InvalidateBullet(pOwner->pParaList->GetAbsPos(pPrev));
526 }
527 }
528
530 ParaFlag nPrevFlags = pPara->nFlags;
531
532 pOwner->ImplInitDepth( nPara, nNewDepth, true );
533 pOwner->ImplCalcBulletText( nPara, false, false );
534
537
538 // Notify App
539 pOwner->DepthChangedHdl(pPara, nPrevFlags);
540 }
541 else
542 {
543 // Needs at least a repaint...
544 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
545 }
546 }
547
548 sal_Int32 nParas = pOwner->pParaList->GetParagraphCount();
549 for ( sal_Int32 n = aSel.nEndPara+1; n < nParas; n++ )
550 {
551 Paragraph* pPara = pOwner->pParaList->GetParagraph( n );
552 if ( pPara->GetDepth() < nMinDepth )
553 break;
554 pOwner->ImplCalcBulletText( n, false, false );
555 }
556
557 if ( bUpdate )
558 {
559 pEditView->SetEditEngineUpdateLayout( true );
560 pEditView->ShowCursor();
561 }
562
563 if( bUndo )
565}
566
568{
569 pEditView->MoveParagraphs( nDY );
570}
571
573{
574 return pEditView->GetVisArea();
575}
576
578{
579 ParaRange aParas = ImpGetSelectedParagraphs( false );
580 ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, true );
581}
582
583
585{
586 ParaRange aParas = ImpGetSelectedParagraphs( false );
587 ImplExpandOrCollaps( aParas.nStartPara, aParas.nEndPara, false );
588}
589
590
592{
593 ImplExpandOrCollaps( 0, pOwner->pParaList->GetParagraphCount()-1, true );
594}
595
596
598{
599 ImplExpandOrCollaps( 0, pOwner->pParaList->GetParagraphCount()-1, false );
600}
601
602void OutlinerView::ImplExpandOrCollaps( sal_Int32 nStartPara, sal_Int32 nEndPara, bool bExpand )
603{
604 bool bUpdate = pOwner->SetUpdateLayout( false );
605
606 bool bUndo = !pOwner->IsInUndo() && pOwner->IsUndoEnabled();
607 if( bUndo )
609
610 for ( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
611 {
612 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
613 bool bDone = bExpand ? pOwner->Expand( pPara ) : pOwner->Collapse( pPara );
614 if( bDone )
615 {
616 // The line under the paragraph should disappear ...
617 pOwner->pEditEngine->QuickMarkToBeRepainted( nPara );
618 }
619 }
620
621 if( bUndo )
623
624 if ( bUpdate )
625 {
626 pOwner->SetUpdateLayout( true );
627 pEditView->ShowCursor();
628 }
629}
630
632{
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.
641
642 if ( ImpCalcSelectedPages( false ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
643 return;
644
646
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 );
654
656
657 pEditView->ShowCursor();
658}
659
660
662{
663 if ( !ImpCalcSelectedPages( false ) || pOwner->ImpCanDeleteSelectedPages( this ) ) {
664 pEditView->Cut();
665 // Chaining handling
666 aEndCutPasteLink.Call(nullptr);
667 }
668}
669
671{
672 Paste( true );
673}
674
675void OutlinerView::Paste( bool bUseSpecial )
676{
677 if ( ImpCalcSelectedPages( false ) && !pOwner->ImpCanDeleteSelectedPages( this ) )
678 return;
679
681
682 const bool bPrevUpdateLayout = pOwner->pEditEngine->SetUpdateLayout( false );
683 pOwner->bPasting = true;
684
685 if ( bUseSpecial )
686 pEditView->PasteSpecial();
687 else
688 pEditView->Paste();
689
691 {
692 const sal_Int32 nParaCount = pOwner->pEditEngine->GetParagraphCount();
693
694 for( sal_Int32 nPara = 0; nPara < nParaCount; nPara++ )
696 }
697
698 pEditView->SetEditEngineUpdateLayout( bPrevUpdateLayout );
700 pEditView->ShowCursor();
701
702 // Chaining handling
703 // NOTE: We need to do this last because it pEditView may be deleted if a switch of box occurs
704 aEndCutPasteLink.Call(nullptr);
705}
706
707void OutlinerView::CreateSelectionList (std::vector<Paragraph*> &aSelList)
708{
709 ParaRange aParas = ImpGetSelectedParagraphs( true );
710
711 for ( sal_Int32 nPara = aParas.nStartPara; nPara <= aParas.nEndPara; nPara++ )
712 {
713 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
714 aSelList.push_back(pPara);
715 }
716}
717
718void OutlinerView::SetStyleSheet(const OUString& rStyleName)
719{
720 ParaRange aParas = ImpGetSelectedParagraphs(false);
721
722 auto pStyle = pOwner->GetStyleSheetPool()->Find(rStyleName, SfxStyleFamily::Para);
723 if (!pStyle)
724 return;
725
726 for (sal_Int32 nPara = aParas.nStartPara; nPara <= aParas.nEndPara; nPara++)
727 pOwner->SetStyleSheet(nPara, static_cast<SfxStyleSheet*>(pStyle));
728}
729
731{
732 return pEditView->GetStyleSheet();
733}
734
736{
737 return pEditView->GetStyleSheet();
738}
739
741{
742 MouseTarget eTarget;
743 ImpCheckMousePos( rPosPixel, eTarget );
744
745 PointerStyle ePointerStyle = PointerStyle::Arrow;
746 if ( eTarget == MouseTarget::Text )
747 {
748 ePointerStyle = GetOutliner()->IsVertical() ? PointerStyle::TextVertical : PointerStyle::Text;
749 }
750 else if ( eTarget == MouseTarget::Hypertext )
751 {
752 ePointerStyle = PointerStyle::RefHand;
753 }
754 else if ( eTarget == MouseTarget::Bullet )
755 {
756 ePointerStyle = PointerStyle::Move;
757 }
758
759 return ePointerStyle;
760}
761
762
763sal_Int32 OutlinerView::ImpInitPaste( sal_Int32& rStart )
764{
765 pOwner->bPasting = true;
766 ESelection aSelection( pEditView->GetSelection() );
767 aSelection.Adjust();
768 rStart = aSelection.nStartPara;
769 sal_Int32 nSize = aSelection.nEndPara - aSelection.nStartPara + 1;
770 return nSize;
771}
772
773
774void OutlinerView::ImpPasted( sal_Int32 nStart, sal_Int32 nPrevParaCount, sal_Int32 nSize)
775{
776 pOwner->bPasting = false;
777 sal_Int32 nCurParaCount = pOwner->pEditEngine->GetParagraphCount();
778 if( nCurParaCount < nPrevParaCount )
779 nSize = nSize - ( nPrevParaCount - nCurParaCount );
780 else
781 nSize = nSize + ( nCurParaCount - nPrevParaCount );
782 pOwner->ImpTextPasted( nStart, nSize );
783}
784
786{
787 return pEditView->Command(rCEvt);
788}
789
790void OutlinerView::SelectRange( sal_Int32 nFirst, sal_Int32 nCount )
791{
792 sal_Int32 nLast = nFirst+nCount;
793 nCount = pOwner->pParaList->GetParagraphCount();
794 if( nLast <= nCount )
795 nLast = nCount - 1;
796 ESelection aSel( nFirst, 0, nLast, EE_TEXTPOS_ALL );
797 pEditView->SetSelection( aSel );
798}
799
800
801sal_Int32 OutlinerView::ImpCalcSelectedPages( bool bIncludeFirstSelected )
802{
803 ESelection aSel( pEditView->GetSelection() );
804 aSel.Adjust();
805
806 sal_Int32 nPages = 0;
807 sal_Int32 nFirstPage = EE_PARA_MAX_COUNT;
808 sal_Int32 nStartPara = aSel.nStartPara;
809 if ( !bIncludeFirstSelected )
810 nStartPara++; // All paragraphs after StartPara will be deleted
811 for ( sal_Int32 nPara = nStartPara; nPara <= aSel.nEndPara; nPara++ )
812 {
813 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
814 DBG_ASSERT(pPara, "ImpCalcSelectedPages: invalid Selection? ");
815 if( pPara->HasFlag(ParaFlag::ISPAGE) )
816 {
817 nPages++;
818 if( nFirstPage == EE_PARA_MAX_COUNT )
819 nFirstPage = nPara;
820 }
821 }
822
823 if( nPages )
824 {
826 pOwner->mnFirstSelPage = nFirstPage;
827 }
828
829 return nPages;
830}
831
832
834{
836
837 ESelection aSel( pEditView->GetSelection() );
838 aSel.Adjust();
839
840 const bool bUpdate = pOwner->pEditEngine->SetUpdateLayout( false );
841
842 sal_Int16 nNewDepth = -2;
843 const SvxNumRule* pDefaultBulletNumRule = nullptr;
844
845 for ( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
846 {
847 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
848 DBG_ASSERT(pPara, "OutlinerView::ToggleBullets(), illegal selection?");
849
850 if( pPara )
851 {
852 if( nNewDepth == -2 )
853 {
854 nNewDepth = (pOwner->GetDepth(nPara) == -1) ? 0 : -1;
855 if ( nNewDepth == 0 )
856 {
857 // determine default numbering rule for bullets
858 const ESelection aSelection(nPara, 0);
859 const SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection));
860 const SfxPoolItem& rPoolItem = aTmpSet.GetPool()->GetDefaultItem( EE_PARA_NUMBULLET );
861 const SvxNumBulletItem* pNumBulletItem = dynamic_cast< const SvxNumBulletItem* >(&rPoolItem);
862 pDefaultBulletNumRule = pNumBulletItem ? &pNumBulletItem->GetNumRule() : nullptr;
863 }
864 }
865
866 pOwner->SetDepth( pPara, nNewDepth );
867
868 if( nNewDepth == -1 )
869 {
870 const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara );
871 if ( rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SfxItemState::SET )
872 {
873 SfxItemSet aAttrs(rAttrs);
875 pOwner->SetParaAttribs( nPara, aAttrs );
876 }
877 }
878 else
879 {
880 if ( pDefaultBulletNumRule )
881 {
882 const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat( nPara );
883 if ( !pFmt
884 || ( pFmt->GetNumberingType() != SVX_NUM_BITMAP
885 && pFmt->GetNumberingType() != SVX_NUM_CHAR_SPECIAL ) )
886 {
887 SfxItemSet aAttrs( pOwner->GetParaAttribs( nPara ) );
888 SvxNumRule aNewNumRule( *pDefaultBulletNumRule );
889 aAttrs.Put( SvxNumBulletItem( std::move(aNewNumRule), EE_PARA_NUMBULLET ) );
890 pOwner->SetParaAttribs( nPara, aAttrs );
891 }
892 }
893 }
894 }
895 }
896
897 const sal_Int32 nParaCount = pOwner->pParaList->GetParagraphCount();
898 pOwner->ImplCheckParagraphs( aSel.nStartPara, nParaCount );
899
900 sal_Int32 nEndPara = (nParaCount > 0) ? nParaCount-1 : nParaCount;
901 pOwner->pEditEngine->QuickMarkInvalid( ESelection( aSel.nStartPara, 0, nEndPara, 0 ) );
902
903 pOwner->pEditEngine->SetUpdateLayout( bUpdate );
904
906}
907
908
910 const bool bToggle,
911 const bool bHandleBullets,
912 const SvxNumRule* pNumRule )
913{
914 ESelection aSel( pEditView->GetSelection() );
915 aSel.Adjust();
916
917 bool bToggleOn = true;
918 if ( bToggle )
919 {
920 bToggleOn = false;
921 const sal_Int16 nBulletNumberingStatus( pOwner->GetBulletsNumberingStatus( aSel.nStartPara, aSel.nEndPara ) );
922 if ( nBulletNumberingStatus != 0 && bHandleBullets )
923 {
924 // not all paragraphs have bullets and method called to toggle bullets --> bullets on
925 bToggleOn = true;
926 }
927 else if ( nBulletNumberingStatus != 1 && !bHandleBullets )
928 {
929 // not all paragraphs have numbering and method called to toggle numberings --> numberings on
930 bToggleOn = true;
931 }
932 }
933 if ( bToggleOn )
934 {
935 // apply bullets/numbering for selected paragraphs
936 ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle, true );
937 }
938 else
939 {
940 // switch off bullets/numbering for selected paragraphs
942 }
943}
944
946{
948
949 ESelection aSel(pEditView->GetSelection());
950 aSel.Adjust();
951
952 const bool bUpdate = pOwner->pEditEngine->IsUpdateLayout();
953 pOwner->pEditEngine->SetUpdateLayout(false);
954
955 for (sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++)
956 {
957 Paragraph* pPara = pOwner->pParaList->GetParagraph(nPara);
958 DBG_ASSERT(pPara, "OutlinerView::EnableBullets(), illegal selection?");
959
960 if (pPara && pOwner->GetDepth(nPara) == -1)
961 pOwner->SetDepth(pPara, 0);
962 }
963
964 sal_Int32 nParaCount = pOwner->pParaList->GetParagraphCount();
965 pOwner->ImplCheckParagraphs(aSel.nStartPara, nParaCount);
966
967 const sal_Int32 nEndPara = (nParaCount > 0) ? nParaCount-1 : nParaCount;
968 pOwner->pEditEngine->QuickMarkInvalid(ESelection(aSel.nStartPara, 0, nEndPara, 0));
969
970 pOwner->pEditEngine->SetUpdateLayout(bUpdate);
971
973}
974
976 const bool bHandleBullets,
977 const SvxNumRule* pNewNumRule,
978 const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule,
979 const bool bAtSelection )
980{
982 {
983 return;
984 }
985
987 const bool bUpdate = pOwner->pEditEngine->SetUpdateLayout(false);
988
989 sal_Int32 nStartPara = 0;
990 sal_Int32 nEndPara = 0;
991 if ( bAtSelection )
992 {
993 ESelection aSel( pEditView->GetSelection() );
994 aSel.Adjust();
995 nStartPara = aSel.nStartPara;
996 nEndPara = aSel.nEndPara;
997 }
998 else
999 {
1000 nStartPara = 0;
1001 nEndPara = pOwner->pParaList->GetParagraphCount() - 1;
1002 }
1003
1004 for (sal_Int32 nPara = nStartPara; nPara <= nEndPara; ++nPara)
1005 {
1006 Paragraph* pPara = pOwner->pParaList->GetParagraph(nPara);
1007 DBG_ASSERT(pPara, "OutlinerView::ApplyBulletsNumbering(..), illegal selection?");
1008
1009 if (pPara)
1010 {
1011 const sal_Int16 nDepth = pOwner->GetDepth(nPara);
1012 if ( nDepth == -1 )
1013 {
1014 pOwner->SetDepth( pPara, 0 );
1015 }
1016
1017 const SfxItemSet& rAttrs = pOwner->GetParaAttribs(nPara);
1018 SfxItemSet aAttrs(rAttrs);
1019 aAttrs.Put(SfxBoolItem(EE_PARA_BULLETSTATE, true));
1020
1021 // apply new numbering rule
1022 if ( pNewNumRule )
1023 {
1024 bool bApplyNumRule = false;
1025 if ( !bCheckCurrentNumRuleBeforeApplyingNewNumRule )
1026 {
1027 bApplyNumRule = true;
1028 }
1029 else
1030 {
1031 const SvxNumberFormat* pFmt = pOwner ->GetNumberFormat(nPara);
1032 if (!pFmt)
1033 {
1034 bApplyNumRule = true;
1035 }
1036 else
1037 {
1038 sal_Int16 nNumType = pFmt->GetNumberingType();
1039 if ( bHandleBullets
1041 {
1042 // Set to Normal bullet, old bullet type is Numbering bullet.
1043 bApplyNumRule = true;
1044 }
1045 else if ( !bHandleBullets
1047 {
1048 // Set to Numbering bullet, old bullet type is Normal bullet.
1049 bApplyNumRule = true;
1050 }
1051 }
1052 }
1053
1054 if ( bApplyNumRule )
1055 {
1056 SvxNumRule aNewRule(*pNewNumRule);
1057
1058 // Get old bullet space.
1059 {
1060 const SvxNumBulletItem* pNumBulletItem = rAttrs.GetItemIfSet(EE_PARA_NUMBULLET, false);
1061 if (pNumBulletItem)
1062 {
1063 // Use default value when has not contain bullet item.
1064 ESelection aSelection(nPara, 0);
1065 SfxItemSet aTmpSet(pOwner->pEditEngine->GetAttribs(aSelection));
1066 pNumBulletItem = aTmpSet.GetItem(EE_PARA_NUMBULLET);
1067 }
1068
1069 if (pNumBulletItem)
1070 {
1071 const sal_uInt16 nLevelCnt = std::min(pNumBulletItem->GetNumRule().GetLevelCount(), aNewRule.GetLevelCount());
1072 for ( sal_uInt16 nLevel = 0; nLevel < nLevelCnt; ++nLevel )
1073 {
1074 const SvxNumberFormat* pOldFmt = pNumBulletItem->GetNumRule().Get(nLevel);
1075 const SvxNumberFormat* pNewFmt = aNewRule.Get(nLevel);
1076 if (pOldFmt && pNewFmt && (pOldFmt->GetFirstLineOffset() != pNewFmt->GetFirstLineOffset() || pOldFmt->GetAbsLSpace() != pNewFmt->GetAbsLSpace()))
1077 {
1078 SvxNumberFormat aNewFmtClone(*pNewFmt);
1079 aNewFmtClone.SetFirstLineOffset(pOldFmt->GetFirstLineOffset());
1080 aNewFmtClone.SetAbsLSpace(pOldFmt->GetAbsLSpace());
1081 aNewRule.SetLevel(nLevel, &aNewFmtClone);
1082 }
1083 }
1084 }
1085 }
1086
1087 aAttrs.Put(SvxNumBulletItem(std::move(aNewRule), EE_PARA_NUMBULLET));
1088 }
1089 }
1090 pOwner->SetParaAttribs(nPara, aAttrs);
1091 }
1092 }
1093
1094 const sal_uInt16 nParaCount = static_cast<sal_uInt16>(pOwner->pParaList->GetParagraphCount());
1095 pOwner->ImplCheckParagraphs( nStartPara, nParaCount );
1096 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nStartPara, 0, nParaCount, 0 ) );
1097
1098 pOwner->pEditEngine->SetUpdateLayout( bUpdate );
1099
1101}
1102
1103
1105 const bool bAtSelection )
1106{
1107 sal_Int32 nStartPara = 0;
1108 sal_Int32 nEndPara = 0;
1109 if ( bAtSelection )
1110 {
1111 ESelection aSel( pEditView->GetSelection() );
1112 aSel.Adjust();
1113 nStartPara = aSel.nStartPara;
1114 nEndPara = aSel.nEndPara;
1115 }
1116 else
1117 {
1118 nStartPara = 0;
1119 nEndPara = pOwner->pParaList->GetParagraphCount() - 1;
1120 }
1121
1123 const bool bUpdate = pOwner->pEditEngine->SetUpdateLayout( false );
1124
1125 for ( sal_Int32 nPara = nStartPara; nPara <= nEndPara; ++nPara )
1126 {
1127 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1128 DBG_ASSERT(pPara, "OutlinerView::SwitchOffBulletsNumbering(...), illegal paragraph index?");
1129
1130 if( pPara )
1131 {
1132 pOwner->SetDepth( pPara, -1 );
1133
1134 const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara );
1135 if (rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SfxItemState::SET)
1136 {
1137 SfxItemSet aAttrs(rAttrs);
1139 pOwner->SetParaAttribs( nPara, aAttrs );
1140 }
1141 }
1142 }
1143
1144 const sal_uInt16 nParaCount = static_cast<sal_uInt16>(pOwner->pParaList->GetParagraphCount());
1145 pOwner->ImplCheckParagraphs( nStartPara, nParaCount );
1146 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nStartPara, 0, nParaCount, 0 ) );
1147
1148 pOwner->pEditEngine->SetUpdateLayout( bUpdate );
1150}
1151
1152
1153void OutlinerView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs )
1154{
1155 RemoveAttribs( bRemoveParaAttribs, true /*keep language attribs*/ );
1156}
1157
1158void OutlinerView::RemoveAttribs( bool bRemoveParaAttribs, bool bKeepLanguages )
1159{
1160 bool bUpdate = pOwner->SetUpdateLayout( false );
1162 if (bKeepLanguages)
1163 pEditView->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
1164 else
1165 pEditView->RemoveAttribs( bRemoveParaAttribs );
1166 if ( bRemoveParaAttribs )
1167 {
1168 // Loop through all paragraphs and set indentation and level
1169 ESelection aSel = pEditView->GetSelection();
1170 aSel.Adjust();
1171 for ( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1172 {
1173 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
1174 pOwner->ImplInitDepth( nPara, pPara->GetDepth(), false );
1175 }
1176 }
1178 pOwner->SetUpdateLayout( bUpdate );
1179}
1180
1181
1182// ====================== Simple pass-through =======================
1183
1184
1185void OutlinerView::InsertText( const OUString& rNew, bool bSelect )
1186{
1188 pOwner->Insert( OUString() );
1189 pEditView->InsertText( rNew, bSelect );
1190}
1191
1193{
1194 pEditView->SetVisArea( rRect );
1195}
1196
1197
1199{
1200 pEditView->SetSelection( rSel );
1201}
1202
1203void OutlinerView::GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) const
1204{
1205 pEditView->GetSelectionRectangles(rLogicRects);
1206}
1207
1208void OutlinerView::SetReadOnly( bool bReadOnly )
1209{
1210 pEditView->SetReadOnly( bReadOnly );
1211}
1212
1214{
1215 return pEditView->IsReadOnly();
1216}
1217
1219{
1220 return pEditView->HasSelection();
1221}
1222
1223void OutlinerView::ShowCursor( bool bGotoCursor, bool bActivate )
1224{
1225 pEditView->ShowCursor( bGotoCursor, /*bForceVisCursor=*/true, bActivate );
1226}
1227
1228void OutlinerView::HideCursor(bool bDeactivate)
1229{
1230 pEditView->HideCursor(bDeactivate);
1231}
1232
1234{
1235 pEditView->SetWindow( pWin );
1236}
1237
1239{
1240 return pEditView->GetWindow();
1241}
1242
1244{
1245 pEditView->SetOutputArea( rRect );
1246}
1247
1249{
1250 return pEditView->GetOutputArea();
1251}
1252
1254{
1255 return pEditView->GetSelected();
1256}
1257
1259{
1260 pEditView->StartSpeller(pDialogParent);
1261}
1262
1264{
1265 return pEditView->StartThesaurus(pDialogParent);
1266}
1267
1269 LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont,
1270 sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc )
1271{
1272 if (
1273 (LANGUAGE_KOREAN == nSrcLang && LANGUAGE_KOREAN == nDestLang) ||
1274 (LANGUAGE_CHINESE_SIMPLIFIED == nSrcLang && LANGUAGE_CHINESE_TRADITIONAL == nDestLang) ||
1275 (LANGUAGE_CHINESE_TRADITIONAL == nSrcLang && LANGUAGE_CHINESE_SIMPLIFIED == nDestLang)
1276 )
1277 {
1278 pEditView->StartTextConversion(pDialogParent, nSrcLang, nDestLang, pDestFont, nOptions, bIsInteractive, bMultipleDoc);
1279 }
1280 else
1281 {
1282 OSL_FAIL( "unexpected language" );
1283 }
1284}
1285
1286
1288{
1289 return pEditView->StartSearchAndReplace( rSearchItem );
1290}
1291
1293{
1294 pEditView->TransliterateText( nTransliterationMode );
1295}
1296
1298{
1299 return pEditView->GetSelection();
1300}
1301
1302
1303void OutlinerView::Scroll( tools::Long nHorzScroll, tools::Long nVertScroll )
1304{
1305 pEditView->Scroll( nHorzScroll, nVertScroll );
1306}
1307
1309{
1310 pEditView->SetControlWord( nWord );
1311}
1312
1314{
1315 return pEditView->GetControlWord();
1316}
1317
1319{
1320 pEditView->SetAnchorMode( eMode );
1321}
1322
1324{
1325 return pEditView->GetAnchorMode();
1326}
1327
1329{
1330 pEditView->Copy();
1331}
1332
1334{
1335 pEditView->InsertField( rFld );
1336}
1337
1339{
1340 return pEditView->GetFieldUnderMousePointer();
1341}
1342
1344{
1345 return pEditView->GetFieldAtSelection();
1346}
1347
1349{
1350 return pEditView->GetFieldAtCursor();
1351}
1352
1354{
1355 pEditView->SelectFieldAtCursor();
1356}
1357
1358void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel )
1359{
1360 pEditView->SetInvalidateMore( nPixel );
1361}
1362
1363
1365{
1366 return pEditView->GetInvalidateMore();
1367}
1368
1369
1371{
1372 return pEditView->IsCursorAtWrongSpelledWord();
1373}
1374
1375
1377{
1378 return pEditView->IsWrongSpelledWordAtPos( rPosPixel, /*bMarkIfWrong*/false );
1379}
1380
1382{
1383 pEditView->ExecuteSpellPopup(rPosPixel, rStartDlg);
1384}
1385
1386void OutlinerView::Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs )
1387{
1388 sal_Int32 nOldParaCount = pEditView->GetEditEngine()->GetParagraphCount();
1389 ESelection aOldSel = pEditView->GetSelection();
1390 aOldSel.Adjust();
1391
1392 pEditView->Read( rInput, eFormat, pHTTPHeaderAttrs );
1393
1394 tools::Long nParaDiff = pEditView->GetEditEngine()->GetParagraphCount() - nOldParaCount;
1395 sal_Int32 nChangesStart = aOldSel.nStartPara;
1396 sal_Int32 nChangesEnd = nChangesStart + nParaDiff + (aOldSel.nEndPara-aOldSel.nStartPara);
1397
1398 for ( sal_Int32 n = nChangesStart; n <= nChangesEnd; n++ )
1399 {
1402 }
1403
1404 pOwner->ImpFilterIndents( nChangesStart, nChangesEnd );
1405}
1406
1408{
1409 pEditView->SetBackgroundColor( rColor );
1410}
1411
1413{
1414 pEditView->RegisterViewShell(pViewShell);
1415}
1416
1418{
1419 return pEditView->GetBackgroundColor();
1420}
1421
1423{
1424 return pEditView->GetAttribs();
1425}
1426
1428{
1429 return pEditView->GetSelectedScriptType();
1430}
1431
1433{
1434 return pEditView->GetSurroundingText();
1435}
1436
1438{
1439 return pEditView->GetSurroundingTextSelection();
1440}
1441
1443{
1444 return pEditView->DeleteSurroundingText(rSelection);
1445}
1446
1447// ===== some code for thesaurus sub menu within context menu
1448
1449namespace {
1450
1451bool isSingleScriptType( SvtScriptType nScriptType )
1452{
1453 sal_uInt8 nScriptCount = 0;
1454
1455 if (nScriptType & SvtScriptType::LATIN)
1456 ++nScriptCount;
1457 if (nScriptType & SvtScriptType::ASIAN)
1458 ++nScriptCount;
1459 if (nScriptType & SvtScriptType::COMPLEX)
1460 ++nScriptCount;
1461
1462 return nScriptCount == 1;
1463}
1464
1465}
1466
1467// returns: true if a word for thesaurus look-up was found at the current cursor position.
1468// The status string will be word + iso language string (e.g. "light#en-US")
1470 OUString &rStatusVal,
1471 LanguageType &rLang,
1472 const EditView &rEditView )
1473{
1474 // get text and locale for thesaurus look up
1475 OUString aText;
1476 EditEngine *pEditEngine = rEditView.GetEditEngine();
1477 ESelection aTextSel( rEditView.GetSelection() );
1478 if (!aTextSel.HasRange())
1479 aTextSel = pEditEngine->GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD );
1480 aText = pEditEngine->GetText( aTextSel );
1481 aTextSel.Adjust();
1482
1483 if (!isSingleScriptType(pEditEngine->GetScriptType(aTextSel)))
1484 return false;
1485
1486 LanguageType nLang = pEditEngine->GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos ).nLang;
1487 OUString aLangText( LanguageTag::convertToBcp47( nLang ) );
1488
1489 // set word and locale to look up as status value
1490 rStatusVal = aText + "#" + aLangText;
1491 rLang = nLang;
1492
1493 return aText.getLength() > 0;
1494}
1495
1496
1497void ReplaceTextWithSynonym( EditView &rEditView, const OUString &rSynonmText )
1498{
1499 // get selection to use
1500 ESelection aCurSel( rEditView.GetSelection() );
1501 if (!rEditView.HasSelection())
1502 {
1503 // select the same word that was used in GetStatusValueForThesaurusFromContext by calling GetWord.
1504 // (In the end both functions will call ImpEditEngine::SelectWord)
1505 rEditView.SelectCurrentWord( i18n::WordType::DICTIONARY_WORD );
1506 aCurSel = rEditView.GetSelection();
1507 }
1508
1509 // replace word ...
1510 rEditView.InsertText( rSynonmText );
1511 rEditView.ShowCursor( true, false );
1512}
1513
1514
1515/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetWord(sal_Int32 nPara, sal_Int32 nIndex)
Definition: editeng.cxx:663
OUString GetText(LineEnd eEnd=LINEEND_LF) const
Definition: editeng.cxx:573
editeng::LanguageSpan GetLanguage(const EditPaM &rPaM) const
Definition: editeng.cxx:482
SvtScriptType GetScriptType(const ESelection &rSelection) const
Definition: editeng.cxx:476
static bool DoesKeyChangeText(const KeyEvent &rKeyEvent)
Definition: editeng.cxx:2742
ESelection GetSelection() const
Definition: editview.cxx:301
void SelectCurrentWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES)
Definition: editview.cxx:1279
bool HasSelection() const
Definition: editview.cxx:314
void InsertText(const OUString &rNew, bool bSelect=false, bool bLOKShowSelect=true)
Definition: editview.cxx:436
void ShowCursor(bool bGotoCursor=true, bool bForceVisCursor=true, bool bActivate=false)
Definition: editview.cxx:508
EditEngine * GetEditEngine() const
Definition: editview.cxx:178
const vcl::KeyCode & GetKeyCode() const
static OUString convertToBcp47(LanguageType nLangID)
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
const EditTextObject & GetTextObject() const
Definition: outlobj.cxx:189
Interface class to not depend on SfxViewShell in editeng.
Definition: outliner.hxx:372
EDITENG_DLLPRIVATE void ImpPasted(sal_Int32 nStart, sal_Int32 nPrevParaCount, sal_Int32 nSize)
Definition: outlvw.cxx:774
void ReleaseMouse()
Definition: outlvw.cxx:363
bool MouseMove(const MouseEvent &)
Definition: outlvw.cxx:285
~OutlinerView()
Definition: outlvw.cxx:59
bool Command(const CommandEvent &rCEvt)
Definition: outlvw.cxx:785
void ToggleBullets()
enables bullets for the selected paragraphs if the bullets/numbering of the first paragraph is off or...
Definition: outlvw.cxx:833
void ToggleBulletsNumbering(const bool bToggle, const bool bHandleBullets, const SvxNumRule *pNumRule)
Definition: outlvw.cxx:909
void AdjustDepth(short nDX)
Definition: outlvw.cxx:432
void ApplyBulletsNumbering(const bool bHandleBullets, const SvxNumRule *pNewNumRule, const bool bCheckCurrentNumRuleBeforeApplyingNewNumRule, const bool bAtSelection=false)
apply bullets/numbering for paragraphs
Definition: outlvw.cxx:975
void CollapseAll()
Definition: outlvw.cxx:597
void SetStyleSheet(const OUString &rStyleName)
Definition: outlvw.cxx:718
void SetSelection(const ESelection &)
Definition: outlvw.cxx:1198
SvtScriptType GetSelectedScriptType() const
Definition: outlvw.cxx:1427
void SelectFieldAtCursor()
Select the field at the current cursor position.
Definition: outlvw.cxx:1353
void StartTextConversion(weld::Widget *pDialogParent, LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc)
Definition: outlvw.cxx:1268
void PasteSpecial()
Definition: outlvw.cxx:670
void Paint(const tools::Rectangle &rRect, OutputDevice *pTargetDevice=nullptr)
Definition: outlvw.cxx:63
std::unique_ptr< EditView > pEditView
Definition: outliner.hxx:184
bool IsReadOnly() const
Definition: outlvw.cxx:1213
void SetControlWord(EVControlBits nWord)
Definition: outlvw.cxx:1308
void GetSelectionRectangles(std::vector< tools::Rectangle > &rLogicRects) const
Definition: outlvw.cxx:1203
bool HasSelection() const
Definition: outlvw.cxx:1218
EDITENG_DLLPRIVATE sal_Int32 ImpCalcSelectedPages(bool bIncludeFirstSelected)
Definition: outlvw.cxx:801
void InsertField(const SvxFieldItem &rFld)
Definition: outlvw.cxx:1333
void EnsureNumberingIsOn()
enables numbering for the selected paragraphs that are not enabled and ignore all selected paragraphs...
Definition: outlvw.cxx:945
EDITENG_DLLPRIVATE ParaRange ImpGetSelectedParagraphs(bool bIncludeHiddenChildren)
Definition: outlvw.cxx:415
bool IsWrongSpelledWordAtPos(const Point &rPosPixel)
Definition: outlvw.cxx:1376
void SetReadOnly(bool bReadOnly)
Definition: outlvw.cxx:1208
EDITENG_DLLPRIVATE void ImpToggleExpand(Paragraph const *pParentPara)
Definition: outlvw.cxx:368
sal_Int32 StartSearchAndReplace(const SvxSearchItem &rSearchItem)
Definition: outlvw.cxx:1287
void ExpandAll()
Definition: outlvw.cxx:591
void Read(SvStream &rInput, EETextFormat eFormat, SvKeyValueIterator *pHTTPHeaderAttrs)
Definition: outlvw.cxx:1386
void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll)
Definition: outlvw.cxx:1303
const SvxFieldItem * GetFieldAtSelection() const
Definition: outlvw.cxx:1343
void Indent(short nDiff)
Definition: outlvw.cxx:437
bool MouseButtonUp(const MouseEvent &)
Definition: outlvw.cxx:348
void RegisterViewShell(OutlinerViewShell *pViewShell)
Informs this edit view about which view shell contains it.
Definition: outlvw.cxx:1412
void Expand()
Definition: outlvw.cxx:577
void InsertText(const OUString &rNew, bool bSelect=false)
Definition: outlvw.cxx:1185
void SwitchOffBulletsNumbering(const bool bAtSelection=false)
switch off bullets/numbering for paragraphs
Definition: outlvw.cxx:1104
void SetOutputArea(const tools::Rectangle &rRect)
Definition: outlvw.cxx:1243
void TransliterateText(TransliterationFlags nTransliterationMode)
Definition: outlvw.cxx:1292
EDITENG_DLLPRIVATE void ImplExpandOrCollaps(sal_Int32 nStartPara, sal_Int32 nEndPara, bool bExpand)
Definition: outlvw.cxx:602
void SetBackgroundColor(const Color &rColor)
Definition: outlvw.cxx:1407
OUString GetSurroundingText() const
Definition: outlvw.cxx:1432
void SetVisArea(const tools::Rectangle &rRect)
Definition: outlvw.cxx:1192
vcl::Window * GetWindow() const
Definition: outlvw.cxx:1238
void RemoveAttribs(bool bRemoveParaAttribs, bool bKeepLanguages=false)
Definition: outlvw.cxx:1158
const SfxStyleSheet * GetStyleSheet() const
Definition: outlvw.cxx:730
tools::Rectangle const & GetOutputArea() const
Definition: outlvw.cxx:1248
void Collapse()
Definition: outlvw.cxx:584
void CreateSelectionList(std::vector< Paragraph * > &aSelList)
Definition: outlvw.cxx:707
tools::Rectangle GetVisArea() const
Definition: outlvw.cxx:572
EESpellState StartThesaurus(weld::Widget *pDialogParent)
Definition: outlvw.cxx:1263
void HideCursor(bool bDeactivate=false)
Definition: outlvw.cxx:1228
ESelection GetSelection() const
Definition: outlvw.cxx:1297
bool PostKeyEvent(const KeyEvent &rKEvt, vcl::Window const *pFrameWin=nullptr)
Definition: outlvw.cxx:73
const SvxFieldData * GetFieldAtCursor() const
Return the field at the current cursor position or nullptr if no field found.
Definition: outlvw.cxx:1348
Outliner * pOwner
Definition: outliner.hxx:183
void AdjustHeight(tools::Long nDY)
Definition: outlvw.cxx:567
const SvxFieldItem * GetFieldUnderMousePointer() const
Definition: outlvw.cxx:1338
EVControlBits GetControlWord() const
Definition: outlvw.cxx:1313
void Paste(bool bUseSpecial=false)
Definition: outlvw.cxx:675
EEAnchorMode GetAnchorMode() const
Definition: outlvw.cxx:1323
SfxItemSet GetAttribs()
Definition: outlvw.cxx:1422
void SetWindow(vcl::Window *pWindow)
Definition: outlvw.cxx:1233
void ExecuteSpellPopup(const Point &rPosPixel, const Link< SpellCallbackInfo &, void > &rCallBack)
Definition: outlvw.cxx:1381
OutlinerView(Outliner *pOut, vcl::Window *pWindow)
Definition: outlvw.cxx:53
Outliner * GetOutliner() const
Definition: outliner.hxx:223
void SetAttribs(const SfxItemSet &)
Definition: outlvw.cxx:388
bool MouseButtonDown(const MouseEvent &)
Definition: outlvw.cxx:300
void RemoveAttribsKeepLanguages(bool bRemoveParaAttribs)
Definition: outlvw.cxx:1153
sal_uInt16 GetInvalidateMore() const
Definition: outlvw.cxx:1364
EDITENG_DLLPRIVATE sal_Int32 ImpInitPaste(sal_Int32 &rStart)
Definition: outlvw.cxx:763
Link< LinkParamNone *, void > aEndCutPasteLink
Definition: outliner.hxx:203
OUString GetSelected() const
Definition: outlvw.cxx:1253
Selection GetSurroundingTextSelection() const
Definition: outlvw.cxx:1437
bool IsCursorAtWrongSpelledWord()
Definition: outlvw.cxx:1370
PointerStyle GetPointer(const Point &rPosPixel)
Definition: outlvw.cxx:740
void Cut()
Definition: outlvw.cxx:661
void SetAnchorMode(EEAnchorMode eMode)
Definition: outlvw.cxx:1318
void StartSpeller(weld::Widget *pDialogParent)
Definition: outlvw.cxx:1258
void SetInvalidateMore(sal_uInt16 nPixel)
Definition: outlvw.cxx:1358
void Copy()
Definition: outlvw.cxx:1328
void Select(Paragraph const *pParagraph, bool bSelect=true)
Definition: outlvw.cxx:376
void SelectRange(sal_Int32 nFirst, sal_Int32 nCount)
Definition: outlvw.cxx:790
Color const & GetBackgroundColor() const
Definition: outlvw.cxx:1417
EDITENG_DLLPRIVATE sal_Int32 ImpCheckMousePos(const Point &rPosPixel, MouseTarget &reTarget)
Definition: outlvw.cxx:242
bool DeleteSurroundingText(const Selection &rRange)
Definition: outlvw.cxx:1442
void ShowCursor(bool bGotoCursor=true, bool bActivate=false)
Definition: outlvw.cxx:1223
bool Expand(Paragraph const *)
Definition: outliner.cxx:760
SfxStyleSheetPool * GetStyleSheetPool()
Definition: outlin2.cxx:256
void ImplCheckParagraphs(sal_Int32 nStart, sal_Int32 nEnd)
Definition: outliner.cxx:1417
bool IsTextPos(const Point &rPaperPos, sal_uInt16 nBorder)
Definition: outlin2.cxx:417
bool bPasting
Definition: outliner.hxx:616
OutlinerMode GetOutlinerMode() const
Definition: outliner.hxx:952
const SvxNumberFormat * GetNumberFormat(sal_Int32 nPara) const
Definition: outliner.cxx:1360
sal_Int16 nMaxDepth
Definition: outliner.hxx:608
sal_Int16 GetDepth(sal_Int32 nPara) const
Definition: outliner.cxx:229
void SetStyleSheet(sal_Int32 nPara, SfxStyleSheet *pStyle)
Definition: outliner.cxx:666
std::unique_ptr< OutlinerEditEng > pEditEngine
Definition: outliner.hxx:587
bool ImplHasNumberFormat(sal_Int32 nPara) const
Definition: outliner.cxx:1355
void InsertUndo(std::unique_ptr< EditUndo > pUndo)
Definition: outlin2.cxx:306
bool SetUpdateLayout(bool bUpdate)
Definition: outlin2.cxx:44
void SetDepth(Paragraph *pParagraph, sal_Int16 nNewDepth)
Definition: outliner.cxx:236
void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &)
Definition: outliner.cxx:749
void ImplCalcBulletText(sal_Int32 nPara, bool bRecalcLevel, bool bRecalcChildren)
Definition: outliner.cxx:1810
void ImplCheckNumBulletItem(sal_Int32 nPara)
Definition: outliner.cxx:676
sal_Int32 GetBulletsNumberingStatus(const sal_Int32 nParaStart, const sal_Int32 nParaEnd) const
determine the bullets/numbering status of the given paragraphs
Definition: outliner.cxx:305
bool IsUndoEnabled() const
Definition: outlin2.cxx:65
void ImpTextPasted(sal_Int32 nStartPara, sal_Int32 nCount)
Definition: outliner.cxx:1155
bool bFirstParaIsEmpty
Definition: outliner.hxx:613
bool Collapse(Paragraph const *)
Definition: outliner.cxx:783
void UndoActionStart(sal_uInt16 nId)
Definition: outlin2.cxx:296
std::unique_ptr< ParagraphList > pParaList
Definition: outliner.hxx:589
static constexpr sal_Int16 gnMinDepth
Definition: outliner.hxx:609
bool ImpCanDeleteSelectedPages(OutlinerView *pCurView)
Definition: outliner.cxx:1227
sal_Int32 mnFirstSelPage
Definition: outliner.hxx:592
void ImplSetLevelDependentStyleSheet(sal_Int32 nPara)
Definition: outliner.cxx:683
SfxItemSet const & GetParaAttribs(sal_Int32 nPara) const
Definition: outliner.cxx:1699
void DepthChangedHdl(Paragraph *, ParaFlag nPrevFlags)
Definition: outliner.cxx:1327
void ImplInitDepth(sal_Int32 nPara, sal_Int16 nDepth, bool bCreateUndo)
Definition: outliner.cxx:715
void ImpFilterIndents(sal_Int32 nFirstPara, sal_Int32 nLastPara)
Definition: outliner.cxx:1118
bool IsVertical() const
Definition: outlin2.cxx:530
sal_Int32 nDepthChangedHdlPrevDepth
Definition: outliner.hxx:607
bool ImpCanIndentSelectedPages(OutlinerView *pCurView)
Definition: outliner.cxx:1209
Paragraph * Insert(const OUString &rText, sal_Int32 nAbsPos=EE_PARA_APPEND, sal_Int16 nDepth=0)
Definition: outliner.cxx:69
Point GetDocPos(const Point &rPaperPos) const
Definition: outlin2.cxx:412
bool IsInUndo() const
Definition: outlin2.cxx:311
void InvalidateBullet(sal_Int32 nPara)
Definition: outliner.cxx:1069
void UndoActionEnd()
Definition: outlin2.cxx:301
sal_Int16 GetDepth() const
Definition: outliner.hxx:145
bool HasFlag(ParaFlag nFlag) const
Definition: outliner.hxx:155
void RemoveFlag(ParaFlag nFlag)
Definition: outliner.hxx:154
ParaFlag nFlags
Definition: outliner.hxx:132
void SetFlag(ParaFlag nFlag)
Definition: outliner.hxx:153
bool IsVisible() const
Definition: outliner.hxx:135
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
const SvxFieldData * GetField() const
Definition: flditem.hxx:81
const SvxNumRule & GetNumRule() const
Definition: numitem.hxx:325
sal_uInt16 GetLevelCount() const
Definition: numitem.hxx:298
const SvxNumberFormat * Get(sal_uInt16 nLevel) const
Definition: numitem.cxx:919
void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat &rFmt, bool bIsValid=true)
Definition: numitem.cxx:943
void SetAbsLSpace(sal_Int32 nSet)
Definition: numitem.hxx:209
sal_Int32 GetFirstLineOffset() const
Definition: numitem.cxx:484
sal_Int32 GetAbsLSpace() const
Definition: numitem.cxx:478
void SetFirstLineOffset(sal_Int32 nSet)
Definition: numitem.hxx:211
SvxNumType GetNumberingType() const
Definition: numitem.hxx:73
constexpr tools::Long Top() const
constexpr tools::Long Left() const
bool IsMod1() const
sal_uInt16 GetCode() const
KeyFuncType GetFunction() const
bool IsShift() const
bool IsMod2() const
int nCount
#define DBG_ASSERT(sCon, aError)
#define EE_PARA_NOT_FOUND
Definition: editdata.hxx:48
EETextFormat
Definition: editdata.hxx:35
EESpellState
Definition: editdata.hxx:40
#define EE_PARA_MAX_COUNT
Definition: editdata.hxx:51
EEAnchorMode
Definition: editdata.hxx:41
#define EE_TEXTPOS_ALL
Definition: editdata.hxx:54
EVControlBits
Definition: editstat.hxx:61
constexpr TypedWhichId< SfxBoolItem > EE_PARA_BULLETSTATE(EE_PARA_START+9)
constexpr TypedWhichId< SvxNumBulletItem > EE_PARA_NUMBULLET(EE_PARA_START+5)
bool bReadOnly
Mode eMode
sal_Int64 n
KeyFuncType
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_BACKSPACE
#define LANGUAGE_CHINESE_TRADITIONAL
#define LANGUAGE_CHINESE_SIMPLIFIED
#define LANGUAGE_KOREAN
SvtScriptType
sal_Int16 nNumType
#define SAL_WARN_IF(condition, area, stream)
long Long
#define OLUNDO_INSERT
Definition: outliner.hxx:114
ParaFlag
Definition: outliner.hxx:97
#define OLUNDO_DEPTH
Definition: outliner.hxx:108
#define OLUNDO_COLLAPSE
Definition: outliner.hxx:111
#define OLUNDO_EXPAND
Definition: outliner.hxx:110
#define OLUNDO_ATTR
Definition: outliner.hxx:113
void ReplaceTextWithSynonym(EditView &rEditView, const OUString &rSynonmText)
Definition: outlvw.cxx:1497
bool GetStatusValueForThesaurusFromContext(OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView)
Definition: outlvw.cxx:1469
PointerStyle
#define nPixel
bool HasRange() const
Definition: editdata.hxx:151
sal_Int32 nStartPara
Definition: editdata.hxx:113
sal_Int32 nEndPos
Definition: editdata.hxx:116
sal_Int32 nStartPos
Definition: editdata.hxx:114
void Adjust()
Definition: editdata.hxx:184
sal_Int32 nEndPara
Definition: editdata.hxx:115
sal_Int32 nStartPara
Definition: outliner.hxx:163
sal_Int32 nEndPara
Definition: outliner.hxx:164
void Adjust()
Definition: outliner.hxx:171
LanguageType nLang
Definition: editdata.hxx:350
@ SVX_NUM_BITMAP
Definition: svxenum.hxx:153
@ SVX_NUM_CHAR_SPECIAL
Definition: svxenum.hxx:151
TransliterationFlags
unsigned char sal_uInt8
#define SAL_MAX_INT32
oslFileHandle & pOut