LibreOffice Module editeng (master) 1
editview.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
21#include <memory>
22#include <vcl/image.hxx>
23
24#include <com/sun/star/i18n/WordType.hpp>
25#include <com/sun/star/i18n/ScriptType.hpp>
26
30#include <svtools/ctrltool.hxx>
31#include <svtools/langtab.hxx>
32#include <tools/stream.hxx>
33
34#include <svl/srchitem.hxx>
35
36#include "impedit.hxx"
38#include <editeng/editeng.hxx>
39#include <editeng/editview.hxx>
40#include <editeng/flditem.hxx>
41#include <editeng/svxacorr.hxx>
42#include <editeng/langitem.hxx>
43#include <editeng/fhgtitem.hxx>
44#include <editeng/eerdll.hxx>
45#include <eerdll2.hxx>
46#include <editeng/editrids.hrc>
47#include <editeng.hxx>
48#include <i18nlangtag/lang.h>
49#include <vcl/window.hxx>
50#include <editeng/acorrcfg.hxx>
51#include <editeng/unolingu.hxx>
52#include <unotools/lingucfg.hxx>
53
54#include <com/sun/star/frame/XStorable.hpp>
55#include <com/sun/star/linguistic2/XDictionary.hpp>
56#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
58#include <vcl/settings.hxx>
59#include <vcl/svapp.hxx>
60#include <LibreOfficeKit/LibreOfficeKitEnums.h>
61#include <comphelper/lok.hxx>
62#include <sfx2/viewsh.hxx>
63#include <osl/diagnose.h>
64#include <boost/property_tree/json_parser.hpp>
65
66#include <com/sun/star/lang/XServiceInfo.hpp>
67
68using namespace com::sun::star;
69using namespace com::sun::star::uno;
70using namespace com::sun::star::beans;
71
72
73// static
75 const OUString &rText,
78 bool bIsParaText )
79{
81 if (bIsParaText) // check longer texts with language-guessing...
82 {
83 if (!xLangGuess.is())
84 return nLang;
85
86 LanguageTag aGuessTag( xLangGuess->guessPrimaryLanguage( rText, 0, rText.getLength()) );
87
88 // If the result from language guessing does not provide a 'Country'
89 // part, try to get it by looking up the locale setting of the office,
90 // "Tools/Options - Language Settings - Languages: Locale setting", if
91 // the language matches.
92 if ( aGuessTag.getCountry().isEmpty() )
93 {
94 const LanguageTag& rAppLocaleTag = Application::GetSettings().GetLanguageTag();
95 if (rAppLocaleTag.getLanguage() == aGuessTag.getLanguage())
96 nLang = rAppLocaleTag.getLanguageType();
97 }
98 if (nLang == LANGUAGE_NONE) // language not found by looking up the system language...
99 nLang = aGuessTag.makeFallback().getLanguageType(); // best known locale match
100 if (nLang == LANGUAGE_SYSTEM)
102 if (nLang == LANGUAGE_DONTKNOW)
103 nLang = LANGUAGE_NONE;
104 }
105 else // check single word
106 {
107 if (!xSpell.is())
108 return nLang;
109
110
111 // build list of languages to check
112
113 LanguageType aLangList[4];
114 const AllSettings& rSettings = Application::GetSettings();
115 SvtLinguOptions aLinguOpt;
116 SvtLinguConfig().GetOptions( aLinguOpt );
117 // The default document language from "Tools/Options - Language Settings - Languages: Western"
119 css::i18n::ScriptType::LATIN);
120 // The one from "Tools/Options - Language Settings - Languages: User interface"
121 aLangList[1] = rSettings.GetUILanguageTag().getLanguageType();
122 // The one from "Tools/Options - Language Settings - Languages: Locale setting"
123 aLangList[2] = rSettings.GetLanguageTag().getLanguageType();
124 // en-US
125 aLangList[3] = LANGUAGE_ENGLISH_US;
126#ifdef DEBUG
127 lang::Locale a0( LanguageTag::convertToLocale( aLangList[0] ) );
128 lang::Locale a1( LanguageTag::convertToLocale( aLangList[1] ) );
129 lang::Locale a2( LanguageTag::convertToLocale( aLangList[2] ) );
130 lang::Locale a3( LanguageTag::convertToLocale( aLangList[3] ) );
131#endif
132
133 for (const LanguageType& nTmpLang : aLangList)
134 {
135 if (nTmpLang != LANGUAGE_NONE && nTmpLang != LANGUAGE_DONTKNOW)
136 {
137 if (xSpell->hasLanguage( static_cast<sal_uInt16>(nTmpLang) ) &&
138 xSpell->isValid( rText, static_cast<sal_uInt16>(nTmpLang), Sequence< PropertyValue >() ))
139 {
140 nLang = nTmpLang;
141 break;
142 }
143 }
144 }
145 }
146
147 return nLang;
148}
149
151{
152}
153
155{
156 pImpEditView.reset( new ImpEditView( this, pEng, pWindow ) );
157}
158
160{
161}
162
164{
165 pImpEditView->setEditViewCallbacks(pEditViewCallbacks);
166}
167
169{
170 return pImpEditView->getEditViewCallbacks();
171}
172
174{
175 return pImpEditView->pEditEngine->pImpEditEngine.get();
176}
177
179{
180 return pImpEditView->pEditEngine;
181}
182
184{
185 if ( !pImpEditView->DoInvalidateMore() )
186 return pImpEditView->aOutArea;
187 else
188 {
189 tools::Rectangle aRect( pImpEditView->aOutArea );
190 tools::Long nMore = pImpEditView->GetOutputDevice().PixelToLogic( Size( pImpEditView->GetInvalidateMore(), 0 ) ).Width();
191 aRect.AdjustLeft( -nMore );
192 aRect.AdjustRight(nMore );
193 aRect.AdjustTop( -nMore );
194 aRect.AdjustBottom(nMore );
195 return aRect;
196 }
197}
198
199namespace {
200
201tools::Rectangle lcl_negateRectX(const tools::Rectangle& rRect)
202{
203 return tools::Rectangle(-rRect.Right(), rRect.Top(), -rRect.Left(), rRect.Bottom());
204}
205
206}
207
209{
210 bool bNegativeX = IsNegativeX();
211 if (EditViewCallbacks* pEditViewCallbacks = pImpEditView->getEditViewCallbacks())
212 {
213 // do not invalidate and trigger a global repaint, but forward
214 // the need for change to the applied EditViewCallback, can e.g.
215 // be used to visualize the active edit text in an OverlayObject
216 pEditViewCallbacks->EditViewInvalidate(bNegativeX ? lcl_negateRectX(rClipRect) : rClipRect);
217 }
218 else
219 {
220 // classic mode: invalidate and trigger full repaint
221 // of the changed area
222 GetWindow()->Invalidate(bNegativeX ? lcl_negateRectX(rClipRect) : rClipRect);
223 }
224}
225
227{
229 {
230 bool bNegativeX = IsNegativeX();
231 for (auto& pWin : pImpEditView->aOutWindowSet)
232 {
233 if (pWin)
234 pWin->Invalidate( bNegativeX ? lcl_negateRectX(rInvRect) : rInvRect );
235 }
236 }
237}
238
240{
241 const tools::Rectangle& rInvRect = GetInvalidateRect();
242 pImpEditView->InvalidateAtWindow(rInvRect);
244}
245
246void EditView::SetReadOnly( bool bReadOnly )
247{
248 pImpEditView->bReadOnly = bReadOnly;
249}
250
252{
253 return pImpEditView->bReadOnly;
254}
255
257{
258 // If someone has just left an empty attribute, and then the outliner manipulates the
259 // selection, call the CursorMoved method so that empty attributes get cleaned up.
260 if ( !HasSelection() )
261 {
262 // tdf#113591 Get node from EditDoc, as the selection might have a pointer to an
263 // already deleted node.
264 const ContentNode* pNode = pImpEditView->pEditEngine->GetEditDoc().GetEndPaM().GetNode();
265 pImpEditView->pEditEngine->CursorMoved( pNode );
266 }
267 EditSelection aNewSelection( pImpEditView->pEditEngine->pImpEditEngine->ConvertSelection(
268 rESel.nStartPara, rESel.nStartPos, rESel.nEndPara, rESel.nEndPos ) );
269
270 // If the selection is manipulated after a KeyInput:
271 pImpEditView->pEditEngine->CheckIdleFormatter();
272
273 // Selection may not start/end at an invisible paragraph:
274 const ParaPortion* pPortion = pImpEditView->pEditEngine->FindParaPortion( aNewSelection.Min().GetNode() );
275 if ( !pPortion->IsVisible() )
276 {
277 pPortion = pImpEditView->pEditEngine->GetPrevVisPortion( pPortion );
278 ContentNode* pNode = pPortion ? pPortion->GetNode() : pImpEditView->pEditEngine->GetEditDoc().GetObject( 0 );
279 aNewSelection.Min() = EditPaM( pNode, pNode->Len() );
280 }
281 pPortion = pImpEditView->pEditEngine->FindParaPortion( aNewSelection.Max().GetNode() );
282 if ( !pPortion->IsVisible() )
283 {
284 pPortion = pImpEditView->pEditEngine->GetPrevVisPortion( pPortion );
285 ContentNode* pNode = pPortion ? pPortion->GetNode() : pImpEditView->pEditEngine->GetEditDoc().GetObject( 0 );
286 aNewSelection.Max() = EditPaM( pNode, pNode->Len() );
287 }
288
289 pImpEditView->DrawSelectionXOR();
290 pImpEditView->SetEditSelection( aNewSelection );
291 pImpEditView->DrawSelectionXOR();
292 bool bGotoCursor = pImpEditView->DoAutoScroll();
293
294 // comments section in Writer:
295 // don't scroll to the selection if it is
296 // out of visible area of comment canvas.
297 if (HasSelection())
298 ShowCursor( bGotoCursor );
299}
300
302{
303 ESelection aSelection;
304
305 aSelection.nStartPara = pImpEditView->pEditEngine->GetEditDoc().GetPos( pImpEditView->GetEditSelection().Min().GetNode() );
306 aSelection.nEndPara = pImpEditView->pEditEngine->GetEditDoc().GetPos( pImpEditView->GetEditSelection().Max().GetNode() );
307
308 aSelection.nStartPos = pImpEditView->GetEditSelection().Min().GetIndex();
309 aSelection.nEndPos = pImpEditView->GetEditSelection().Max().GetIndex();
310
311 return aSelection;
312}
313
315{
316 return pImpEditView->HasSelection();
317}
318
319bool EditView::IsSelectionAtPoint(const Point& rPointPixel)
320{
321 return pImpEditView->IsSelectionAtPoint(rPointPixel);
322}
323
325{
326 pImpEditView->DeleteSelected();
327}
328
330{
331 return pImpEditView->pEditEngine->GetScriptType( pImpEditView->GetEditSelection() );
332}
333
334void EditView::GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) const
335{
336 return pImpEditView->GetSelectionRectangles(pImpEditView->GetEditSelection(), rLogicRects);
337}
338
339void EditView::Paint( const tools::Rectangle& rRect, OutputDevice* pTargetDevice )
340{
341 pImpEditView->pEditEngine->pImpEditEngine->Paint( pImpEditView.get(), rRect, pTargetDevice );
342}
343
345{
346 pImpEditView->pEditEngine = pEditEng;
347 EditSelection aStartSel = pImpEditView->pEditEngine->GetEditDoc().GetStartPaM();
348 pImpEditView->SetEditSelection( aStartSel );
349}
350
352{
353 pImpEditView->pOutWin = pWin;
354 pImpEditView->pEditEngine->pImpEditEngine->GetSelEngine().Reset();
355}
356
358{
359 return pImpEditView->pOutWin;
360}
361
363{
364 return pImpEditView->GetOutputDevice();
365}
366
368{
369 // it might make sense to add this to getEditViewCallbacks
370 if (const vcl::Window* pWindow = GetWindow())
371 return pWindow->GetInputLanguage();
372 return LANGUAGE_DONTKNOW;
373}
374
376{
377 OutWindowSet& rOutWindowSet = pImpEditView->aOutWindowSet;
378 auto found = std::find(rOutWindowSet.begin(), rOutWindowSet.end(), pWin);
379 return (found != rOutWindowSet.end());
380}
381
383{
384 if (HasOtherViewWindow(pWin))
385 return false;
386 pImpEditView->aOutWindowSet.emplace_back(pWin);
387 return true;
388}
389
391{
392 OutWindowSet& rOutWindowSet = pImpEditView->aOutWindowSet;
393 auto found = std::find(rOutWindowSet.begin(), rOutWindowSet.end(), pWin);
394 if (found == rOutWindowSet.end())
395 return false;
396 rOutWindowSet.erase(found);
397 return true;
398}
399
401{
402 pImpEditView->SetVisDocStartPos( rRect.TopLeft() );
403}
404
406{
407 return pImpEditView->GetVisDocArea();
408}
409
411{
412 pImpEditView->SetOutputArea( rRect );
413
414 // the rest here only if it is an API call:
415 pImpEditView->CalcAnchorPoint();
416 if ( pImpEditView->pEditEngine->pImpEditEngine->GetStatus().AutoPageSize() )
417 pImpEditView->RecalcOutputArea();
418 pImpEditView->ShowCursor( false, false );
419}
420
422{
423 return pImpEditView->GetOutputArea();
424}
425
427{
428 return pImpEditView->GetPointer();
429}
430
432{
433 return pImpEditView->pCursor.get();
434}
435
436void EditView::InsertText( const OUString& rStr, bool bSelect, bool bLOKShowSelect )
437{
438
439 EditEngine* pEE = pImpEditView->pEditEngine;
440
441 if (bLOKShowSelect)
442 pImpEditView->DrawSelectionXOR();
443
444 EditPaM aPaM1;
445 if ( bSelect )
446 {
447 EditSelection aTmpSel( pImpEditView->GetEditSelection() );
448 aTmpSel.Adjust( pEE->GetEditDoc() );
449 aPaM1 = aTmpSel.Min();
450 }
451
453 EditPaM aPaM2( pEE->InsertText( pImpEditView->GetEditSelection(), rStr ) );
454 pEE->UndoActionEnd();
455
456 if ( bSelect )
457 {
458 DBG_ASSERT( !aPaM1.DbgIsBuggy( pEE->GetEditDoc() ), "Insert: PaM broken" );
459 pImpEditView->SetEditSelection( EditSelection( aPaM1, aPaM2 ) );
460 }
461 else
462 pImpEditView->SetEditSelection( EditSelection( aPaM2, aPaM2 ) );
463
464 if (bLOKShowSelect)
465 pEE->FormatAndLayout( this );
466}
467
468bool EditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * pFrameWin )
469{
470 return pImpEditView->PostKeyEvent( rKeyEvent, pFrameWin );
471}
472
473bool EditView::MouseButtonUp( const MouseEvent& rMouseEvent )
474{
475 return pImpEditView->MouseButtonUp( rMouseEvent );
476}
477
479{
480 return pImpEditView->ReleaseMouse();
481}
482
483bool EditView::MouseButtonDown( const MouseEvent& rMouseEvent )
484{
485 return pImpEditView->MouseButtonDown( rMouseEvent );
486}
487
488bool EditView::MouseMove( const MouseEvent& rMouseEvent )
489{
490 return pImpEditView->MouseMove( rMouseEvent );
491}
492
494{
495 return pImpEditView->Command(rCEvt);
496}
497
499{
500 pImpEditView->SetBroadcastLOKViewCursor(bSet);
501}
502
504{
505 return pImpEditView->GetEditCursor();
506}
507
508void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bActivate )
509{
510 if ( !pImpEditView->pEditEngine->HasView( this ) )
511 return;
512
513 // The control word is more important:
514 if ( !pImpEditView->DoAutoScroll() )
515 bGotoCursor = false;
516 pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
517
518 if (pImpEditView->mpViewShell && !bActivate)
519 {
520 if (!pImpEditView->pOutWin)
521 return;
522 VclPtr<vcl::Window> pParent = pImpEditView->pOutWin->GetParentWithLOKNotifier();
523 if (pParent && pParent->GetLOKWindowId() != 0)
524 return;
525
526 static const OString aPayload = OString::boolean(true);
527 pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload);
528 pImpEditView->mpViewShell->NotifyOtherViews(LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
529 }
530}
531
532void EditView::HideCursor(bool bDeactivate)
533{
534 pImpEditView->GetCursor()->Hide();
535
536 if (pImpEditView->mpViewShell && !bDeactivate)
537 {
538 if (!pImpEditView->pOutWin)
539 return;
540 VclPtr<vcl::Window> pParent = pImpEditView->pOutWin->GetParentWithLOKNotifier();
541 if (pParent && pParent->GetLOKWindowId() != 0)
542 return;
543
544 OString aPayload = OString::boolean(false);
545 pImpEditView->mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE, aPayload);
546 pImpEditView->mpViewShell->NotifyOtherViews(LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", aPayload);
547 }
548}
549
551{
552 return pImpEditView->Scroll( ndX, ndY, nRangeCheck );
553}
554
556{
557 return pImpEditView->pEditEngine->GetEmptyItemSet();
558}
559
561{
562 DBG_ASSERT( !pImpEditView->aEditSelection.IsInvalid(), "Blind Selection in..." );
563
564 pImpEditView->DrawSelectionXOR();
565 pImpEditView->pEditEngine->SetAttribs( pImpEditView->GetEditSelection(), rSet, SetAttribsMode::WholeWord );
566 if (pImpEditView->pEditEngine->IsUpdateLayout())
567 pImpEditView->pEditEngine->FormatAndLayout( this );
568}
569
570void EditView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs )
571{
572
573 pImpEditView->DrawSelectionXOR();
574 pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
575 EditSelection aSelection( pImpEditView->GetEditSelection() );
576
577 for (sal_uInt16 nWID = EE_ITEMS_START; nWID <= EE_ITEMS_END; ++nWID)
578 {
579 bool bIsLang = EE_CHAR_LANGUAGE == nWID ||
580 EE_CHAR_LANGUAGE_CJK == nWID ||
581 EE_CHAR_LANGUAGE_CTL == nWID;
582 if (!bIsLang)
583 pImpEditView->pEditEngine->RemoveCharAttribs( aSelection, bRemoveParaAttribs, nWID );
584 }
585
586 pImpEditView->pEditEngine->UndoActionEnd();
587 if (pImpEditView->pEditEngine->IsUpdateLayout())
588 pImpEditView->pEditEngine->FormatAndLayout( this );
589}
590
591void EditView::RemoveAttribs( bool bRemoveParaAttribs, sal_uInt16 nWhich )
592{
595}
596
597void EditView::RemoveAttribs( EERemoveParaAttribsMode eMode, sal_uInt16 nWhich )
598{
599 pImpEditView->DrawSelectionXOR();
600 pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
601 pImpEditView->pEditEngine->RemoveCharAttribs( pImpEditView->GetEditSelection(), eMode, nWhich );
602 pImpEditView->pEditEngine->UndoActionEnd();
603 if (pImpEditView->pEditEngine->IsUpdateLayout())
604 pImpEditView->pEditEngine->FormatAndLayout( this );
605}
606
607void EditView::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich )
608{
609 pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
610 pImpEditView->pEditEngine->RemoveCharAttribs( nPara, nWhich );
611 pImpEditView->pEditEngine->UndoActionEnd();
612 if (pImpEditView->pEditEngine->IsUpdateLayout())
613 pImpEditView->pEditEngine->FormatAndLayout( this );
614}
615
617{
618 DBG_ASSERT( !pImpEditView->aEditSelection.IsInvalid(), "Blind Selection in..." );
619 return pImpEditView->pEditEngine->pImpEditEngine->GetAttribs( pImpEditView->GetEditSelection() );
620}
621
623{
624 pImpEditView->pEditEngine->Undo( this );
625}
626
628{
629 pImpEditView->pEditEngine->Redo( this );
630}
631
632ErrCode EditView::Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs )
633{
634 EditSelection aOldSel( pImpEditView->GetEditSelection() );
635 pImpEditView->DrawSelectionXOR();
636 pImpEditView->pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_READ );
637 EditPaM aEndPaM = pImpEditView->pEditEngine->pImpEditEngine->Read( rInput, "", eFormat, aOldSel, pHTTPHeaderAttrs );
638 pImpEditView->pEditEngine->pImpEditEngine->UndoActionEnd();
639 EditSelection aNewSel( aEndPaM, aEndPaM );
640
641 pImpEditView->SetEditSelection( aNewSel );
642 bool bGotoCursor = pImpEditView->DoAutoScroll();
643 ShowCursor( bGotoCursor );
644
645 return rInput.GetError();
646}
647
649{
651 pImpEditView->CutCopy( aClipBoard, true );
652}
653
655{
656 return pImpEditView->GetClipboard();
657}
658
659css::uno::Reference< css::datatransfer::XTransferable > EditView::GetTransferable() const
660{
661 uno::Reference< datatransfer::XTransferable > xData =
662 GetEditEngine()->CreateTransferable( pImpEditView->GetEditSelection() );
663 return xData;
664}
665
667{
669 pImpEditView->CutCopy( aClipBoard, false );
670}
671
673{
675 pImpEditView->Paste( aClipBoard );
676}
677
679{
681 pImpEditView->Paste(aClipBoard, true );
682}
683
685{
686 Point aDocPos( pImpEditView->pEditEngine->GetDocPosTopLeft( nParagraph ) );
687 return pImpEditView->GetWindowPos( aDocPos );
688}
689
691{
692 pImpEditView->SetSelectionMode( eMode );
693}
694
695OUString EditView::GetSelected() const
696{
697 return pImpEditView->pEditEngine->pImpEditEngine->GetSelected( pImpEditView->GetEditSelection() );
698}
699
700void EditView::MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos )
701{
702 pImpEditView->pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_MOVEPARAS );
703 pImpEditView->pEditEngine->pImpEditEngine->MoveParagraphs( aParagraphs, nNewPos, this );
704 pImpEditView->pEditEngine->pImpEditEngine->UndoActionEnd();
705}
706
708{
709 ESelection aSel = GetSelection();
710 Range aRange( aSel.nStartPara, aSel.nEndPara );
711 aRange.Normalize();
712 tools::Long nDest = ( nDiff > 0 ? aRange.Max() : aRange.Min() ) + nDiff;
713 if ( nDiff > 0 )
714 nDest++;
715 DBG_ASSERT( ( nDest >= 0 ) && ( nDest <= pImpEditView->pEditEngine->GetParagraphCount() ), "MoveParagraphs - wrong Parameters!" );
716 MoveParagraphs( aRange, sal::static_int_cast< sal_Int32 >( nDest ) );
717}
718
720{
721 pImpEditView->SetBackgroundColor( rColor );
722 pImpEditView->pEditEngine->SetBackgroundColor( rColor );
723}
724
726{
727 return pImpEditView->GetBackgroundColor();
728}
729
731{
732 pImpEditView->RegisterViewShell(pViewShell);
733}
734
736{
737 pImpEditView->RegisterOtherShell(pOtherShell);
738}
739
741{
742 pImpEditView->nControl = nWord;
743}
744
746{
747 return pImpEditView->nControl;
748}
749
750std::unique_ptr<EditTextObject> EditView::CreateTextObject()
751{
752 return pImpEditView->pEditEngine->pImpEditEngine->CreateTextObject( pImpEditView->GetEditSelection() );
753}
754
755void EditView::InsertText( const EditTextObject& rTextObject )
756{
757 pImpEditView->DrawSelectionXOR();
758
759 pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_INSERT );
760 EditSelection aTextSel( pImpEditView->pEditEngine->InsertText( rTextObject, pImpEditView->GetEditSelection() ) );
761 pImpEditView->pEditEngine->UndoActionEnd();
762
763 aTextSel.Min() = aTextSel.Max(); // Selection not retained.
764 pImpEditView->SetEditSelection( aTextSel );
765 if (pImpEditView->pEditEngine->IsUpdateLayout())
766 pImpEditView->pEditEngine->FormatAndLayout( this );
767}
768
769void EditView::InsertText( css::uno::Reference< css::datatransfer::XTransferable > const & xDataObj, const OUString& rBaseURL, bool bUseSpecial )
770{
771 pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_INSERT );
772 pImpEditView->DeleteSelected();
773 EditSelection aTextSel =
774 pImpEditView->pEditEngine->InsertText(xDataObj, rBaseURL, pImpEditView->GetEditSelection().Max(), bUseSpecial);
775 pImpEditView->pEditEngine->UndoActionEnd();
776
777 aTextSel.Min() = aTextSel.Max(); // Selection not retained.
778 pImpEditView->SetEditSelection( aTextSel );
779 if (pImpEditView->pEditEngine->IsUpdateLayout())
780 pImpEditView->pEditEngine->FormatAndLayout( this );
781}
782
784{
785 return pImpEditView->pEditEngine->pImpEditEngine->SetUpdateLayout( bUpdate, this );
786}
787
789{
790 pImpEditView->pEditEngine->pImpEditEngine->SetUpdateLayout( true, this, true );
791}
792
794{
795 EditSelection aSel( pImpEditView->GetEditSelection() );
796 aSel.Adjust( pImpEditView->pEditEngine->GetEditDoc() );
797 sal_Int32 nStartPara = pImpEditView->pEditEngine->GetEditDoc().GetPos( aSel.Min().GetNode() );
798 sal_Int32 nEndPara = pImpEditView->pEditEngine->GetEditDoc().GetPos( aSel.Max().GetNode() );
799
800 SfxStyleSheet* pStyle = nullptr;
801 for ( sal_Int32 n = nStartPara; n <= nEndPara; n++ )
802 {
803 SfxStyleSheet* pTmpStyle = pImpEditView->pEditEngine->GetStyleSheet( n );
804 if ( ( n != nStartPara ) && ( pStyle != pTmpStyle ) )
805 return nullptr; // Not unique.
806 pStyle = pTmpStyle;
807 }
808 return pStyle;
809}
810
812{
813 return const_cast< EditView* >( this )->GetStyleSheet();
814}
815
817{
818 return pImpEditView->IsInsertMode();
819}
820
821void EditView::SetInsertMode( bool bInsert )
822{
823 pImpEditView->SetInsertMode( bInsert );
824}
825
827{
828 pImpEditView->SetAnchorMode( eMode );
829}
830
832{
833 return pImpEditView->GetAnchorMode();
834}
835
837{
838 EditSelection aOldSel( pImpEditView->GetEditSelection() );
839 EditSelection aNewSel = pImpEditView->pEditEngine->TransliterateText( pImpEditView->GetEditSelection(), nTransliterationMode );
840 if ( aNewSel != aOldSel )
841 {
842 pImpEditView->DrawSelectionXOR();
843 pImpEditView->SetEditSelection( aNewSel );
844 pImpEditView->DrawSelectionXOR();
845 }
846}
847
849{
850 if ( !HasSelection() && pImpEditView->pEditEngine->pImpEditEngine->GetStatus().DoAutoCorrect() )
851 {
852 pImpEditView->DrawSelectionXOR();
853 EditSelection aSel = pImpEditView->GetEditSelection();
854 aSel = pImpEditView->pEditEngine->EndOfWord( aSel.Max() );
855 aSel = pImpEditView->pEditEngine->pImpEditEngine->AutoCorrect( aSel, 0, !IsInsertMode(), pFrameWin );
856 pImpEditView->SetEditSelection( aSel );
857 if ( pImpEditView->pEditEngine->IsModified() )
858 pImpEditView->pEditEngine->FormatAndLayout( this );
859 }
860}
861
862EESpellState EditView::StartSpeller(weld::Widget* pDialogParent, bool bMultipleDoc)
863{
864 if ( !pImpEditView->pEditEngine->pImpEditEngine->GetSpeller().is() )
866
867 return pImpEditView->pEditEngine->pImpEditEngine->Spell(this, pDialogParent, bMultipleDoc);
868}
869
871{
872 if ( !pImpEditView->pEditEngine->pImpEditEngine->GetSpeller().is() )
874
875 return pImpEditView->pEditEngine->pImpEditEngine->StartThesaurus(this, pDialogParent);
876}
877
879 LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont,
880 sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc )
881{
882 pImpEditView->pEditEngine->pImpEditEngine->Convert(this, pDialogParent, nSrcLang, nDestLang, pDestFont, nOptions, bIsInteractive, bMultipleDoc);
883}
884
885sal_Int32 EditView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
886{
887 return pImpEditView->pEditEngine->pImpEditEngine->StartSearchAndReplace( this, rSearchItem );
888}
889
891{
892 bool bIsWrong = false;
893 if ( !HasSelection() )
894 {
895 EditPaM aPaM = pImpEditView->GetEditSelection().Max();
896 bIsWrong = pImpEditView->IsWrongSpelledWord( aPaM, false/*bMarkIfWrong*/ );
897 }
898 return bIsWrong;
899}
900
901bool EditView::IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWrong )
902{
903 Point aPos(pImpEditView->GetOutputDevice().PixelToLogic(rPosPixel));
904 aPos = pImpEditView->GetDocPos( aPos );
905 EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aPos, false);
906 return pImpEditView->IsWrongSpelledWord( aPaM , bMarkIfWrong );
907}
908
909static void LOKSendSpellPopupMenu(const weld::Menu& rMenu, LanguageType nGuessLangWord,
910 LanguageType nGuessLangPara, sal_uInt16 nSuggestions)
911{
913 return;
914
915 // Generate the menu structure and send it to the client code.
916 SfxViewShell* pViewShell = SfxViewShell::Current();
917 if (!pViewShell)
918 return;
919
920 boost::property_tree::ptree aMenu;
921
922 boost::property_tree::ptree aItemTree;
923 if (nSuggestions)
924 {
925 for(int i = 0; i < nSuggestions; ++i)
926 {
927 OUString sItemId = OUString::number(MN_ALTSTART + i);
928 OUString sText = rMenu.get_label(sItemId);
929 aItemTree.put("text", sText.toUtf8().getStr());
930 aItemTree.put("type", "command");
931 OUString sCommandString = ".uno:SpellCheckApplySuggestion?ApplyRule:string=Spelling_" + sText;
932 aItemTree.put("command", sCommandString.toUtf8().getStr());
933 aItemTree.put("enabled", rMenu.get_sensitive(sItemId));
934 aMenu.push_back(std::make_pair("", aItemTree));
935 aItemTree.clear();
936 }
937
938 aItemTree.put("type", "separator");
939 aMenu.push_back(std::make_pair("", aItemTree));
940 aItemTree.clear();
941 }
942
943 // First we need to set item commands for the context menu.
944 OUString aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
945 OUString aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
946
947 aItemTree.put("text", rMenu.get_label("ignore").toUtf8().getStr());
948 aItemTree.put("type", "command");
949 aItemTree.put("command", ".uno:SpellCheckIgnoreAll?Type:string=Spelling");
950 aItemTree.put("enabled", rMenu.get_sensitive("ignore"));
951 aMenu.push_back(std::make_pair("", aItemTree));
952 aItemTree.clear();
953
954 aItemTree.put("type", "separator");
955 aMenu.push_back(std::make_pair("", aItemTree));
956 aItemTree.clear();
957
958 aItemTree.put("text", rMenu.get_label("wordlanguage").toUtf8().getStr());
959 aItemTree.put("type", "command");
960 OUString sCommandString = ".uno:LanguageStatus?Language:string=Current_" + aTmpWord;
961 aItemTree.put("command", sCommandString.toUtf8().getStr());
962 aItemTree.put("enabled", rMenu.get_sensitive("wordlanguage"));
963 aMenu.push_back(std::make_pair("", aItemTree));
964 aItemTree.clear();
965
966 aItemTree.put("text", rMenu.get_label("paralanguage").toUtf8().getStr());
967 aItemTree.put("type", "command");
968 sCommandString = ".uno:LanguageStatus?Language:string=Paragraph_" + aTmpPara;
969 aItemTree.put("command", sCommandString.toUtf8().getStr());
970 aItemTree.put("enabled", rMenu.get_sensitive("paralanguage"));
971 aMenu.push_back(std::make_pair("", aItemTree));
972 aItemTree.clear();
973
974 boost::property_tree::ptree aRoot;
975 aRoot.add_child("menu", aMenu);
976
977 std::stringstream aStream;
978 boost::property_tree::write_json(aStream, aRoot, true);
979 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, OString(aStream.str()));
980}
981
983{
984 OutputDevice& rDevice = pImpEditView->GetOutputDevice();
985 Point aPos(rDevice.PixelToLogic(rPosPixel));
986 aPos = pImpEditView->GetDocPos( aPos );
987 EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aPos, false);
988 Reference< linguistic2::XSpellChecker1 > xSpeller( pImpEditView->pEditEngine->pImpEditEngine->GetSpeller() );
989 ESelection aOldSel = GetSelection();
990 if ( !(xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, true )) )
991 return false;
992
993 // PaMtoEditCursor returns Logical units
994 tools::Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly );
995 // GetWindowPos works in Logical units
996 aTempRect = pImpEditView->GetWindowPos(aTempRect);
997 // Convert to pixels
998 aTempRect = rDevice.LogicToPixel(aTempRect);
999
1000 weld::Widget* pPopupParent = pImpEditView->GetPopupParent(aTempRect);
1001 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, "editeng/ui/spellmenu.ui"));
1002 std::unique_ptr<weld::Menu> xPopupMenu(xBuilder->weld_menu("editviewspellmenu"));
1003 std::unique_ptr<weld::Menu> xInsertMenu(xBuilder->weld_menu("insertmenu")); // add word to user-dictionaries
1004 std::unique_ptr<weld::Menu> xAutoMenu(xBuilder->weld_menu("automenu"));
1005
1006 EditPaM aPaM2( aPaM );
1007 aPaM2.SetIndex( aPaM2.GetIndex()+1 );
1008
1009 // Are there any replace suggestions?
1010 OUString aSelected( GetSelected() );
1011
1012 // restrict the maximal number of suggestions displayed
1013 // in the context menu.
1014 // Note: That could of course be done by clipping the
1015 // resulting sequence but the current third party
1016 // implementations result differs greatly if the number of
1017 // suggestions to be returned gets changed. Statistically
1018 // it gets much better if told to return e.g. only 7 strings
1019 // than returning e.g. 16 suggestions and using only the
1020 // first 7. Thus we hand down the value to use to that
1021 // implementation here by providing an additional parameter.
1023
1024 // Are there any replace suggestions?
1026 xSpeller->spell( aSelected, static_cast<sal_uInt16>(pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ).nLang), aPropVals );
1027
1028 Reference< linguistic2::XLanguageGuessing > xLangGuesser( EditDLL::Get().GetGlobalData()->GetLanguageGuesser() );
1029
1030 // check if text might belong to a different language...
1031 LanguageType nGuessLangWord = LANGUAGE_NONE;
1032 LanguageType nGuessLangPara = LANGUAGE_NONE;
1033 if (xSpellAlt.is() && xLangGuesser.is())
1034 {
1035 OUString aParaText;
1036 ContentNode *pNode = aPaM.GetNode();
1037 if (pNode)
1038 {
1039 aParaText = pNode->GetString();
1040 }
1041 else
1042 {
1043 OSL_FAIL( "content node is NULL" );
1044 }
1045
1046 nGuessLangWord = CheckLanguage( xSpellAlt->getWord(), xSpeller, xLangGuesser, false );
1047 nGuessLangPara = CheckLanguage( aParaText, xSpeller, xLangGuesser, true );
1048 }
1049 if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
1050 {
1051 // make sure LANGUAGE_NONE gets not used as menu entry
1052 if (nGuessLangWord == LANGUAGE_NONE)
1053 nGuessLangWord = nGuessLangPara;
1054 if (nGuessLangPara == LANGUAGE_NONE)
1055 nGuessLangPara = nGuessLangWord;
1056
1057 xPopupMenu->append_separator("separator1");
1058 OUString aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
1059 OUString aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
1060 OUString aWordStr( EditResId( RID_STR_WORD ) );
1061 aWordStr = aWordStr.replaceFirst( "%x", aTmpWord );
1062 OUString aParaStr( EditResId( RID_STR_PARAGRAPH ) );
1063 aParaStr = aParaStr.replaceFirst( "%x", aTmpPara );
1064 xPopupMenu->append("wordlanguage", aWordStr);
1065 xPopupMenu->append("paralanguage", aParaStr);
1066 }
1067
1068 // Replace suggestions...
1070 if (xSpellAlt.is())
1071 aAlt = xSpellAlt->getAlternatives();
1072 const OUString *pAlt = aAlt.getConstArray();
1073 sal_uInt16 nWords = static_cast<sal_uInt16>(aAlt.getLength());
1074 if ( nWords )
1075 {
1076 for ( sal_uInt16 nW = 0; nW < nWords; nW++ )
1077 {
1078 OUString aAlternate( pAlt[nW] );
1079 xPopupMenu->append(OUString::number(MN_ALTSTART + nW), aAlternate);
1080 xAutoMenu->append(OUString::number(MN_AUTOSTART + nW), aAlternate);
1081 }
1082 xPopupMenu->append_separator("separator2");
1083 }
1084 else
1085 {
1086 xAutoMenu.reset();
1087 xPopupMenu->remove("autocorrect");
1088 }
1089
1090 SvtLinguConfig aCfg;
1091
1094 if (xDicList.is())
1095 {
1096 const Reference< linguistic2::XDictionary > *pDic = nullptr;
1097 // add the default positive dictionary to dic-list (if not already done).
1098 // This is to ensure that there is at least one dictionary to which
1099 // words could be added.
1100 uno::Reference< linguistic2::XDictionary > xDic( LinguMgr::GetStandardDic() );
1101 if (xDic.is())
1102 xDic->setActive( true );
1103
1104 aDics = xDicList->getDictionaries();
1105 pDic = aDics.getConstArray();
1106 LanguageType nCheckedLanguage = pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ).nLang;
1107 sal_uInt16 nDicCount = static_cast<sal_uInt16>(aDics.getLength());
1108 for (sal_uInt16 i = 0; i < nDicCount; i++)
1109 {
1110 uno::Reference< linguistic2::XDictionary > xDicTmp = pDic[i];
1111 if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp)
1112 continue;
1113
1114 uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
1115 LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
1116 if( xDicTmp->isActive()
1117 && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
1118 && (nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
1119 && (!xStor.is() || !xStor->isReadonly()) )
1120 {
1121 OUString sImage;
1122
1123 uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
1124 if (xSvcInfo.is())
1125 {
1126 OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
1127 xSvcInfo->getImplementationName()) );
1128 if (!aDictionaryImageUrl.isEmpty() )
1129 sImage = aDictionaryImageUrl;
1130 }
1131
1132 if (sImage.isEmpty())
1133 {
1134 xInsertMenu->append(OUString::number(MN_DICTSTART + i), xDicTmp->getName());
1135 }
1136 else
1137 {
1138 Image aImage(sImage);
1139 ScopedVclPtr<VirtualDevice> xVirDev(pPopupParent->create_virtual_device());
1140 Size aSize(aImage.GetSizePixel());
1141 xVirDev->SetOutputSizePixel(aSize);
1142 xVirDev->DrawImage(Point(0, 0), aImage);
1143 xInsertMenu->append(OUString::number(MN_DICTSTART + i), xDicTmp->getName(), *xVirDev);
1144 }
1145 aDicNameSingle = xDicTmp->getName();
1146 }
1147 }
1148 }
1149
1150 if (xInsertMenu->n_children() != 1)
1151 xPopupMenu->remove("add");
1152 if (xInsertMenu->n_children() < 2)
1153 {
1154 xInsertMenu.reset();
1155 xPopupMenu->remove("insert");
1156 }
1157
1158 //tdf#106123 store and restore the EditPaM around the menu Execute
1159 //because the loss of focus in the current editeng causes writer
1160 //annotations to save their contents, making the pContent of the
1161 //current EditPams invalid
1162 EPaM aP = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM);
1163 EPaM aP2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM2);
1164
1166 {
1167 xPopupMenu->remove("autocorrect");
1168 xPopupMenu->remove("autocorrectdlg");
1169
1170 LOKSendSpellPopupMenu(*xPopupMenu, nGuessLangWord, nGuessLangPara, nWords);
1171 return true;
1172 }
1173
1174 OUString sId = xPopupMenu->popup_at_rect(pPopupParent, aTempRect);
1175
1176 aPaM2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP2);
1177 aPaM = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP);
1178
1179 if (sId == "ignore")
1180 {
1181 OUString aWord = pImpEditView->SpellIgnoreWord();
1183 rCallBack.Call(aInf);
1184 SetSelection( aOldSel );
1185 }
1186 else if (sId == "wordlanguage" || sId == "paralanguage")
1187 {
1188 LanguageType nLangToUse = (sId == "wordlanguage") ? nGuessLangWord : nGuessLangPara;
1190
1192 if (nScriptType == SvtScriptType::LATIN)
1193 aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
1194 if (nScriptType == SvtScriptType::COMPLEX)
1195 aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
1196 if (nScriptType == SvtScriptType::ASIAN)
1197 aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
1198 if (sId == "paralanguage")
1199 {
1200 ESelection aSel = GetSelection();
1201 aSel.nStartPos = 0;
1202 aSel.nEndPos = EE_TEXTPOS_ALL;
1203 SetSelection( aSel );
1204 }
1205 SetAttribs( aAttrs );
1206 pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
1207
1209 rCallBack.Call(aInf);
1210 SetSelection( aOldSel );
1211 }
1212 else if (sId == "check")
1213 {
1215 rCallBack.Call(aInf);
1216 }
1217 else if (sId == "autocorrectdlg")
1218 {
1220 rCallBack.Call(aInf);
1221 }
1222 else if ( sId.toInt32() >= MN_DICTSTART || sId == "add")
1223 {
1224 OUString aDicName;
1225 if (sId.toInt32() >= MN_DICTSTART)
1226 {
1227 assert(xInsertMenu && "this case only occurs when xInsertMenu exists");
1228 // strip_mnemonic is necessary to retrieve the correct dictionary name
1229 aDicName = pPopupParent->strip_mnemonic(xInsertMenu->get_label(sId));
1230 }
1231 else
1232 aDicName = aDicNameSingle;
1233
1234 uno::Reference< linguistic2::XDictionary > xDic;
1235 if (xDicList.is())
1236 xDic = xDicList->getDictionaryByName( aDicName );
1237
1238 if (xDic.is())
1239 xDic->add( aSelected, false, OUString() );
1240 // save modified user-dictionary if it is persistent
1241 Reference< frame::XStorable > xSavDic( xDic, UNO_QUERY );
1242 if (xSavDic.is())
1243 xSavDic->store();
1244
1245 aPaM.GetNode()->GetWrongList()->ResetInvalidRange(0, aPaM.GetNode()->Len());
1246 pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer();
1247
1249 rCallBack.Call(aInf);
1250 SetSelection( aOldSel );
1251 }
1252 else if ( sId.toInt32() >= MN_AUTOSTART )
1253 {
1254 DBG_ASSERT(sId.toInt32() - MN_AUTOSTART < aAlt.getLength(), "index out of range");
1255 OUString aWord = pAlt[sId.toInt32() - MN_AUTOSTART];
1257 if ( pAutoCorrect )
1258 pAutoCorrect->PutText( aSelected, aWord, pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ).nLang );
1259 InsertText( aWord );
1260 }
1261 else if ( sId.toInt32() >= MN_ALTSTART ) // Replace
1262 {
1263 DBG_ASSERT(sId.toInt32() - MN_ALTSTART < aAlt.getLength(), "index out of range");
1264 OUString aWord = pAlt[sId.toInt32() - MN_ALTSTART];
1265 InsertText( aWord );
1266 }
1267 else
1268 {
1269 SetSelection( aOldSel );
1270 }
1271 return true;
1272}
1273
1275{
1276 return pImpEditView->SpellIgnoreWord();
1277}
1278
1279void EditView::SelectCurrentWord( sal_Int16 nWordType )
1280{
1281 EditSelection aCurSel( pImpEditView->GetEditSelection() );
1282 pImpEditView->DrawSelectionXOR();
1283 aCurSel = pImpEditView->pEditEngine->SelectWord(aCurSel.Max(), nWordType);
1284 pImpEditView->SetEditSelection( aCurSel );
1285 pImpEditView->DrawSelectionXOR();
1286 ShowCursor( true, false );
1287}
1288
1290{
1291 pImpEditView->pEditEngine->UndoActionStart(EDITUNDO_INSERT);
1292 pImpEditView->DeleteSelected();
1293 EditPaM aPaM(pImpEditView->pEditEngine->InsertParaBreak(pImpEditView->GetEditSelection()));
1294 pImpEditView->pEditEngine->UndoActionEnd();
1295 pImpEditView->SetEditSelection(EditSelection(aPaM, aPaM));
1296 if (pImpEditView->pEditEngine->IsUpdateLayout())
1297 pImpEditView->pEditEngine->FormatAndLayout(this);
1298}
1299
1301{
1302 EditEngine* pEE = pImpEditView->pEditEngine;
1303 pImpEditView->DrawSelectionXOR();
1305 EditPaM aPaM( pEE->InsertField( pImpEditView->GetEditSelection(), rFld ) );
1306 pEE->UndoActionEnd();
1307 pImpEditView->SetEditSelection( EditSelection( aPaM, aPaM ) );
1308 pEE->UpdateFields();
1309 if (pImpEditView->pEditEngine->IsUpdateLayout())
1310 pEE->FormatAndLayout( this );
1311}
1312
1314{
1315 sal_Int32 nPara;
1316 sal_Int32 nPos;
1317 return GetFieldUnderMousePointer( nPara, nPos );
1318}
1319
1320const SvxFieldItem* EditView::GetField( const Point& rPos, sal_Int32* pPara, sal_Int32* pPos ) const
1321{
1322 return pImpEditView->GetField( rPos, pPara, pPos );
1323}
1324
1325const SvxFieldItem* EditView::GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const
1326{
1327 Point aPos;
1328 if (EditViewCallbacks* pEditViewCallbacks = pImpEditView->getEditViewCallbacks())
1329 aPos = pEditViewCallbacks->EditViewPointerPosPixel();
1330 else
1331 aPos = pImpEditView->GetWindow()->GetPointerPosPixel();
1332 OutputDevice& rDevice = pImpEditView->GetOutputDevice();
1333 aPos = rDevice.PixelToLogic(aPos);
1334 return GetField( aPos, &nPara, &nPos );
1335}
1336
1338{
1339 EditSelection aSel( pImpEditView->GetEditSelection() );
1340 aSel.Adjust( pImpEditView->pEditEngine->GetEditDoc() );
1341 // Only when cursor is in font of field, no selection,
1342 // or only selecting field
1343 if ( ( aSel.Min().GetNode() == aSel.Max().GetNode() ) &&
1344 ( ( aSel.Max().GetIndex() == aSel.Min().GetIndex() ) ||
1345 ( aSel.Max().GetIndex() == aSel.Min().GetIndex()+1 ) ) )
1346 {
1347 EditPaM aPaM = aSel.Min();
1349 const sal_Int32 nXPos = aPaM.GetIndex();
1350 for (size_t nAttr = rAttrs.size(); nAttr; )
1351 {
1352 const EditCharAttrib& rAttr = *rAttrs[--nAttr];
1353 if (rAttr.GetStart() == nXPos)
1354 if (rAttr.Which() == EE_FEATURE_FIELD)
1355 {
1356 DBG_ASSERT(dynamic_cast<const SvxFieldItem* >(rAttr.GetItem() ) != nullptr, "No FieldItem...");
1357 return static_cast<const SvxFieldItem*>(rAttr.GetItem());
1358 }
1359 }
1360 }
1361 return nullptr;
1362}
1363
1365{
1366 const SvxFieldItem* pFieldItem = GetFieldAtSelection();
1367 if (pFieldItem)
1368 {
1369 // Make sure the whole field is selected
1370 ESelection aSel = GetSelection();
1371 if (aSel.nStartPos == aSel.nEndPos)
1372 {
1373 aSel.nEndPos++;
1374 SetSelection(aSel);
1375 }
1376 }
1377 if (!pFieldItem)
1378 {
1379 // Cursor probably behind the field - extend selection to select the field
1380 ESelection aSel = GetSelection();
1381 if (aSel.nStartPos > 0 && aSel.nStartPos == aSel.nEndPos)
1382 {
1383 aSel.nStartPos--;
1384 SetSelection(aSel);
1385 }
1386 }
1387}
1388
1390{
1391 const SvxFieldItem* pFieldItem = GetFieldUnderMousePointer();
1392 if (!pFieldItem)
1393 pFieldItem = GetFieldAtSelection();
1394
1395 return pFieldItem ? pFieldItem->GetField() : nullptr;
1396}
1397
1398sal_Int32 EditView::countFieldsOffsetSum(sal_Int32 nPara, sal_Int32 nPos, bool bCanOverflow) const
1399{
1400 if (!pImpEditView || !pImpEditView->pEditEngine)
1401 return 0;
1402
1403 int nOffset = 0;
1404
1405 for (int nCurrentPara = 0; nCurrentPara <= nPara; nCurrentPara++)
1406 {
1407 int nFields = pImpEditView->pEditEngine->GetFieldCount( nCurrentPara );
1408 for (int nField = 0; nField < nFields; nField++)
1409 {
1410 EFieldInfo aFieldInfo
1411 = pImpEditView->pEditEngine->GetFieldInfo( nCurrentPara, nField );
1412
1413 bool bLastPara = nCurrentPara == nPara;
1414 sal_Int32 nFieldPos = aFieldInfo.aPosition.nIndex;
1415
1416 if (bLastPara && nFieldPos >= nPos)
1417 break;
1418
1419 sal_Int32 nFieldLen = aFieldInfo.aCurrentText.getLength();
1420
1421 // position in the middle of a field
1422 if (!bCanOverflow && bLastPara && nFieldPos + nFieldLen > nPos)
1423 nFieldLen = nPos - nFieldPos;
1424
1425 nOffset += nFieldLen - 1;
1426 }
1427 }
1428
1429 return nOffset;
1430}
1431
1432sal_Int32 EditView::GetPosNoField(sal_Int32 nPara, sal_Int32 nPos) const
1433{
1434 sal_Int32 nOffset = countFieldsOffsetSum(nPara, nPos, false);
1435 assert(nPos >= nOffset);
1436 return nPos - nOffset;
1437}
1438
1439sal_Int32 EditView::GetPosWithField(sal_Int32 nPara, sal_Int32 nPos) const
1440{
1441 sal_Int32 nOffset = countFieldsOffsetSum(nPara, nPos, true);
1442 return nPos + nOffset;
1443}
1444
1445void EditView::SetInvalidateMore( sal_uInt16 nPixel )
1446{
1447 pImpEditView->SetInvalidateMore( nPixel );
1448}
1449
1451{
1452 return pImpEditView->GetInvalidateMore();
1453}
1454
1455static void ChangeFontSizeImpl( EditView* pEditView, bool bGrow, const ESelection& rSel, const FontList* pFontList )
1456{
1457 pEditView->SetSelection( rSel );
1458
1459 SfxItemSet aSet( pEditView->GetAttribs() );
1460 if( EditView::ChangeFontSize( bGrow, aSet, pFontList ) )
1461 {
1462 SfxItemSet aNewSet( pEditView->GetEmptyItemSet() );
1463 aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT ) );
1464 aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
1465 aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
1466 pEditView->SetAttribs( aNewSet );
1467 }
1468}
1469
1470void EditView::ChangeFontSize( bool bGrow, const FontList* pFontList )
1471{
1472
1473 EditEngine& rEditEngine = *pImpEditView->pEditEngine;
1474
1475 ESelection aSel( GetSelection() );
1476 ESelection aOldSelection( aSel );
1477 aSel.Adjust();
1478
1479 if( !aSel.HasRange() )
1480 {
1481 aSel = rEditEngine.GetWord( aSel, css::i18n::WordType::DICTIONARY_WORD );
1482 }
1483
1484 if( aSel.HasRange() )
1485 {
1486 for( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
1487 {
1488 std::vector<sal_Int32> aPortions;
1489 rEditEngine.GetPortions( nPara, aPortions );
1490
1491 if( aPortions.empty() )
1492 aPortions.push_back( rEditEngine.GetTextLen(nPara) );
1493
1494 const sal_Int32 nBeginPos = (nPara == aSel.nStartPara) ? aSel.nStartPos : 0;
1495 const sal_Int32 nEndPos = (nPara == aSel.nEndPara) ? aSel.nEndPos : EE_TEXTPOS_ALL;
1496
1497 for ( size_t nPos = 0; nPos < aPortions.size(); ++nPos )
1498 {
1499 sal_Int32 nPortionEnd = aPortions[ nPos ];
1500 sal_Int32 nPortionStart = nPos > 0 ? aPortions[ nPos - 1 ] : 0;
1501
1502 if( (nPortionEnd < nBeginPos) || (nPortionStart > nEndPos) )
1503 continue;
1504
1505 if( nPortionStart < nBeginPos )
1506 nPortionStart = nBeginPos;
1507 if( nPortionEnd > nEndPos )
1508 nPortionEnd = nEndPos;
1509
1510 if( nPortionStart == nPortionEnd )
1511 continue;
1512
1513 ESelection aPortionSel( nPara, nPortionStart, nPara, nPortionEnd );
1514 ChangeFontSizeImpl( this, bGrow, aPortionSel, pFontList );
1515 }
1516 }
1517 }
1518 else
1519 {
1520 ChangeFontSizeImpl( this, bGrow, aSel, pFontList );
1521 }
1522
1523 SetSelection( aOldSelection );
1524}
1525
1526bool EditView::ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList )
1527{
1528 if (!pFontList)
1529 return false;
1530
1531 static const sal_uInt16 gFontSizeWichMap[] = { EE_CHAR_FONTHEIGHT, EE_CHAR_FONTHEIGHT_CJK, EE_CHAR_FONTHEIGHT_CTL, 0 };
1532 bool bRet = false;
1533
1534 const sal_uInt16* pWhich = gFontSizeWichMap;
1535 while( *pWhich )
1536 {
1537 SvxFontHeightItem aFontHeightItem( static_cast<const SvxFontHeightItem&>(rSet.Get( *pWhich )) );
1538 tools::Long nHeight = aFontHeightItem.GetHeight();
1539 const MapUnit eUnit = rSet.GetPool()->GetMetric( *pWhich );
1540 nHeight = OutputDevice::LogicToLogic(nHeight * 10, eUnit, MapUnit::MapPoint);
1541
1542 const int* pAry = FontList::GetStdSizeAry();
1543
1544 if( bGrow )
1545 {
1546 while( *pAry )
1547 {
1548 if( *pAry > nHeight )
1549 {
1550 nHeight = *pAry;
1551 break;
1552 }
1553 pAry++;
1554 }
1555
1556 if( *pAry == 0 )
1557 {
1558 nHeight += (nHeight + 5) / 10;
1559 if( nHeight > 9999 )
1560 nHeight = 9999;
1561 }
1562
1563 }
1564 else if( *pAry )
1565 {
1566 bool bFound = false;
1567 if( *pAry < nHeight )
1568 {
1569 pAry++;
1570 while( *pAry )
1571 {
1572 if( *pAry >= nHeight )
1573 {
1574 nHeight = pAry[-1];
1575 bFound = true;
1576 break;
1577 }
1578 pAry++;
1579 }
1580 }
1581
1582 if( !bFound )
1583 {
1584 nHeight -= (nHeight + 5) / 10;
1585 if( nHeight < 2 )
1586 nHeight = 2;
1587 }
1588 }
1589
1590 if( (nHeight >= 2) && (nHeight <= 9999 ) )
1591 {
1592 nHeight = OutputDevice::LogicToLogic( nHeight, MapUnit::MapPoint, eUnit ) / 10;
1593
1594 if( nHeight != static_cast<tools::Long>(aFontHeightItem.GetHeight()) )
1595 {
1596 aFontHeightItem.SetHeight( nHeight );
1597 rSet.Put( aFontHeightItem.CloneSetWhich(*pWhich) );
1598 bRet = true;
1599 }
1600 }
1601 pWhich++;
1602 }
1603 return bRet;
1604}
1605
1607{
1608 EditSelection aSel( pImpEditView->GetEditSelection() );
1609 aSel.Adjust( pImpEditView->pEditEngine->GetEditDoc() );
1610
1611 if( HasSelection() )
1612 {
1613 OUString aStr = pImpEditView->pEditEngine->GetSelected(aSel);
1614
1615 // Stop reconversion if the selected text includes a line break.
1616 if ( aStr.indexOf( 0x0A ) == -1 )
1617 return aStr;
1618 else
1619 return OUString();
1620 }
1621 else
1622 {
1623 aSel.Min().SetIndex( 0 );
1624 aSel.Max().SetIndex( aSel.Max().GetNode()->Len() );
1625 return pImpEditView->pEditEngine->GetSelected(aSel);
1626 }
1627}
1628
1630{
1631 ESelection aSelection( GetSelection() );
1632 aSelection.Adjust();
1633
1634 if( HasSelection() )
1635 {
1636 EditSelection aSel( pImpEditView->GetEditSelection() );
1637 aSel.Adjust( pImpEditView->pEditEngine->GetEditDoc() );
1638 OUString aStr = pImpEditView->pEditEngine->GetSelected(aSel);
1639
1640 // Stop reconversion if the selected text includes a line break.
1641 if ( aStr.indexOf( 0x0A ) == -1 )
1642 return Selection( 0, aSelection.nEndPos - aSelection.nStartPos );
1643 else
1644 return Selection( 0, 0 );
1645 }
1646 else
1647 {
1648 return Selection( aSelection.nStartPos, aSelection.nEndPos );
1649 }
1650}
1651
1653{
1654 ESelection aSel(GetSelection());
1655 aSel.nEndPara = aSel.nStartPara;
1656 aSel.nStartPos = rRange.Min();
1657 aSel.nEndPos = rRange.Max();
1658 SetSelection(aSel);
1660 return true;
1661}
1662
1663void EditView::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark)
1664{
1665 Point aDocPos(pImpEditView->GetDocPos(rPosition));
1666 EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aDocPos);
1667 EditSelection aSelection(pImpEditView->GetEditSelection());
1668
1669 // Explicitly create or delete the selection.
1670 if (bClearMark)
1671 {
1672 pImpEditView->DeselectAll();
1673 aSelection = pImpEditView->GetEditSelection();
1674 }
1675 else
1676 pImpEditView->CreateAnchor();
1677
1678 if (bPoint)
1679 aSelection.Max() = aPaM;
1680 else
1681 aSelection.Min() = aPaM;
1682
1683 if (pImpEditView->GetEditSelection().Min() != aSelection.Min())
1684 pImpEditView->pEditEngine->CursorMoved(pImpEditView->GetEditSelection().Min().GetNode());
1685 pImpEditView->DrawSelectionXOR(aSelection);
1686 if (pImpEditView->GetEditSelection() != aSelection)
1687 pImpEditView->SetEditSelection(aSelection);
1688 ShowCursor(/*bGotoCursor=*/false);
1689}
1690
1692{
1693 pImpEditView->RegisterOtherShell(pOtherShell);
1694 pImpEditView->DrawSelectionXOR();
1695 pImpEditView->RegisterOtherShell(nullptr);
1696}
1697
1699 const tools::Rectangle& rOutputArea,
1700 const Point& rVisDocStartPos)
1701{
1702 pImpEditView->InitLOKSpecialPositioning(eUnit, rOutputArea, rVisDocStartPos);
1703}
1704
1706{
1707 pImpEditView->SetLOKSpecialOutputArea(rOutputArea);
1708}
1709
1711{
1712 return pImpEditView->GetLOKSpecialOutputArea();
1713}
1714
1716{
1717 pImpEditView->SetLOKSpecialVisArea(rVisArea);
1718}
1719
1721{
1722 return pImpEditView->GetLOKSpecialVisArea();
1723}
1724
1726{
1727 return pImpEditView->HasLOKSpecialPositioning();
1728}
1729
1731{
1732 pImpEditView->SetLOKSpecialFlags(eFlags);
1733}
1734
1736{
1737 pImpEditView->SuppressLOKMessages(bSet);
1738}
1739
1741{
1742 return pImpEditView->IsSuppressLOKMessages();
1743}
1744
1746{
1747 pImpEditView->SetNegativeX(bSet);
1748}
1749
1751{
1752 return pImpEditView->IsNegativeX();
1753}
1754
1755/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const LanguageTag & GetLanguageTag() const
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
AttribsType & GetAttribs()
Definition: editdoc.hxx:222
std::vector< std::unique_ptr< EditCharAttrib > > AttribsType
Definition: editdoc.hxx:186
CharAttribList & GetCharAttribs()
Definition: editdoc.hxx:256
const OUString & GetString() const
Definition: editdoc.hxx:281
WrongList * GetWrongList()
Definition: editdoc.cxx:1777
sal_Int32 Len() const
Definition: editdoc.cxx:1615
sal_Int32 & GetStart()
Definition: editattr.hxx:87
const SfxPoolItem * GetItem() const
Definition: editattr.hxx:85
sal_uInt16 Which() const
Definition: editattr.hxx:84
static EditDLL & Get()
Definition: eerdll.cxx:71
void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList)
Definition: editeng.cxx:1841
OUString GetWord(sal_Int32 nPara, sal_Int32 nIndex)
Definition: editeng.cxx:663
EDITENG_DLLPRIVATE css::uno::Reference< css::datatransfer::XTransferable > CreateTransferable(const EditSelection &rSelection)
Definition: editeng.cxx:814
EditPaM InsertField(const EditSelection &rEditSelection, const SvxFieldItem &rFld)
Definition: editeng.cxx:835
sal_Int32 GetTextLen() const
Definition: editeng.cxx:584
EditSelection InsertText(css::uno::Reference< css::datatransfer::XTransferable > const &rxDataObj, const OUString &rBaseURL, const EditPaM &rPaM, bool bUseSpecial)
bool UpdateFields()
Definition: editeng.cxx:2364
const SfxItemSet & GetEmptyItemSet() const
Definition: editeng.cxx:199
void UndoActionStart(sal_uInt16 nId)
Definition: editeng.cxx:125
void FormatAndLayout(EditView *pCurView, bool bCalledFromUndo=false)
Definition: editeng.cxx:799
void UndoActionEnd()
Definition: editeng.cxx:137
EditDoc & GetEditDoc()
Definition: editeng.cxx:905
void SetIndex(sal_Int32 n)
Definition: editdoc.hxx:317
const ContentNode * GetNode() const
Definition: editdoc.hxx:312
sal_Int32 GetIndex() const
Definition: editdoc.hxx:316
bool DbgIsBuggy(EditDoc const &rDoc) const
Definition: editdoc.cxx:1127
EditPaM & Min()
Definition: editdoc.hxx:705
EditPaM & Max()
Definition: editdoc.hxx:706
void Adjust(const EditDoc &rNodes)
Definition: editdoc.cxx:1162
virtual ~EditViewCallbacks()
Definition: editview.cxx:150
void MoveParagraphs(Range aParagraphs, sal_Int32 nNewPos)
Definition: editview.cxx:700
bool IsCursorAtWrongSpelledWord()
Definition: editview.cxx:890
const SvxFieldItem * GetField(const Point &rPos, sal_Int32 *pnPara=nullptr, sal_Int32 *pnPos=nullptr) const
Definition: editview.cxx:1320
void SetLOKSpecialVisArea(const tools::Rectangle &rVisArea)
Definition: editview.cxx:1715
bool IsSelectionAtPoint(const Point &rPointPixel)
Definition: editview.cxx:319
void SetWindow(vcl::Window *pWin)
Definition: editview.cxx:351
bool DeleteSurroundingText(const Selection &rRange)
Definition: editview.cxx:1652
void DrawSelectionXOR(OutlinerViewShell *pOtherShell)
Trigger selection drawing callback in pOtherShell based on our shell's selection state.
Definition: editview.cxx:1691
bool IsNegativeX() const
Definition: editview.cxx:1750
bool IsReadOnly() const
Definition: editview.cxx:251
void SetControlWord(EVControlBits nWord)
Definition: editview.cxx:740
OUString GetSurroundingText() const
Definition: editview.cxx:1606
void SetBroadcastLOKViewCursor(bool bSet)
Definition: editview.cxx:498
bool IsWrongSpelledWordAtPos(const Point &rPosPixel, bool bMarkIfWrong=false)
Definition: editview.cxx:901
void InvalidateOtherViewWindows(const tools::Rectangle &rInvRect)
Definition: editview.cxx:226
bool MouseButtonUp(const MouseEvent &rMouseEvent)
Definition: editview.cxx:473
void SetSelectionMode(EESelectionMode eMode)
Definition: editview.cxx:690
void HideCursor(bool bDeactivate=false)
Definition: editview.cxx:532
bool IsInsertMode() const
Definition: editview.cxx:816
void RemoveCharAttribs(sal_Int32 nPara, sal_uInt16 nWhich)
Definition: editview.cxx:607
bool ExecuteSpellPopup(const Point &rPosPixel, const Link< SpellCallbackInfo &, void > &rCallBack)
Definition: editview.cxx:982
ESelection GetSelection() const
Definition: editview.cxx:301
void SelectCurrentWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES)
Definition: editview.cxx:1279
void RegisterViewShell(OutlinerViewShell *pViewShell)
Informs this edit view about which view shell contains it.
Definition: editview.cxx:730
std::unique_ptr< EditTextObject > CreateTextObject()
Definition: editview.cxx:750
void Copy()
Definition: editview.cxx:666
sal_uInt16 GetInvalidateMore() const
Definition: editview.cxx:1450
EESpellState StartSpeller(weld::Widget *pDialogParent, bool bMultipleDoc=false)
Definition: editview.cxx:862
bool MouseButtonDown(const MouseEvent &rMouseEvent)
Definition: editview.cxx:483
bool RemoveOtherViewWindow(vcl::Window *pWin)
Definition: editview.cxx:390
void InvalidateWindow(const tools::Rectangle &rClipRect)
Definition: editview.cxx:208
tools::Rectangle GetEditCursor() const
Definition: editview.cxx:503
void ChangeFontSize(bool bGrow, const FontList *pList)
Definition: editview.cxx:1470
EESpellState StartThesaurus(weld::Widget *pDialogParent)
Definition: editview.cxx:870
void SetReadOnly(bool bReadOnly)
Definition: editview.cxx:246
Selection GetSurroundingTextSelection() const
Definition: editview.cxx:1629
void SetOutputArea(const tools::Rectangle &rRect)
Definition: editview.cxx:410
css::uno::Reference< css::datatransfer::XTransferable > GetTransferable() const
Definition: editview.cxx:659
void RemoveAttribs(bool bRemoveParaAttribs=false, sal_uInt16 nWhich=0)
Definition: editview.cxx:591
void SetAnchorMode(EEAnchorMode eMode)
Definition: editview.cxx:826
tools::Rectangle GetVisArea() const
Definition: editview.cxx:405
void RegisterOtherShell(OutlinerViewShell *pOtherShell)
Informs this edit view about which other shell listens to it.
Definition: editview.cxx:735
sal_Int32 GetPosNoField(sal_Int32 nPara, sal_Int32 nPos) const
Converts position in paragraph to logical position without unfolding fields.
Definition: editview.cxx:1432
ErrCode Read(SvStream &rInput, EETextFormat eFormat, SvKeyValueIterator *pHTTPHeaderAttrs)
Definition: editview.cxx:632
void SetEditEngine(EditEngine *pEditEngine)
Definition: editview.cxx:344
void SuppressLOKMessages(bool bSet)
Definition: editview.cxx:1735
bool HasSelection() const
Definition: editview.cxx:314
void Undo()
Definition: editview.cxx:622
void SelectFieldAtCursor()
Definition: editview.cxx:1364
void Cut()
Definition: editview.cxx:648
void SetSelection(const ESelection &rNewSel)
Definition: editview.cxx:256
void Redo()
Definition: editview.cxx:627
const SfxStyleSheet * GetStyleSheet() const
Definition: editview.cxx:811
Color const & GetBackgroundColor() const
Definition: editview.cxx:725
OutputDevice & GetOutputDevice() const
Definition: editview.cxx:362
void InsertText(const OUString &rNew, bool bSelect=false, bool bLOKShowSelect=true)
Definition: editview.cxx:436
bool PostKeyEvent(const KeyEvent &rKeyEvent, vcl::Window const *pFrameWin=nullptr)
Definition: editview.cxx:468
SfxItemSet GetAttribs()
Definition: editview.cxx:616
sal_Int32 GetPosWithField(sal_Int32 nPara, sal_Int32 nPos) const
Converts logical position in paragraph to position with unfolded fields.
Definition: editview.cxx:1439
void SetLOKSpecialFlags(LOKSpecialFlags eFlags)
Definition: editview.cxx:1730
bool HasLOKSpecialPositioning() const
Definition: editview.cxx:1725
EditViewCallbacks * getEditViewCallbacks() const
Definition: editview.cxx:168
tools::Rectangle GetLOKSpecialVisArea() const
Definition: editview.cxx:1720
void ShowCursor(bool bGotoCursor=true, bool bForceVisCursor=true, bool bActivate=false)
Definition: editview.cxx:508
void SetNegativeX(bool bSet)
To inform editeng that negated x document coordinates are in use.
Definition: editview.cxx:1745
vcl::Cursor * GetCursor() const
Definition: editview.cxx:431
const SfxItemSet & GetEmptyItemSet() const
Definition: editview.cxx:555
SvtScriptType GetSelectedScriptType() const
Definition: editview.cxx:329
vcl::Window * GetWindow() const
Definition: editview.cxx:357
PointerStyle GetPointer() const
Definition: editview.cxx:426
void GetSelectionRectangles(std::vector< tools::Rectangle > &rLogicRects) const
Returns the rectangles of the current selection in TWIPs.
Definition: editview.cxx:334
const SvxFieldData * GetFieldAtCursor() const
Select and return the field at the current cursor position.
Definition: editview.cxx:1389
bool HasOtherViewWindow(vcl::Window *pWin)
Definition: editview.cxx:375
bool IsSuppressLOKMessages() const
Definition: editview.cxx:1740
OUString SpellIgnoreWord()
Definition: editview.cxx:1274
void DeleteSelected()
Definition: editview.cxx:324
OUString aDicNameSingle
Definition: editview.hxx:168
const SvxFieldItem * GetFieldAtSelection() const
Definition: editview.cxx:1337
EVControlBits GetControlWord() const
Definition: editview.cxx:745
void RemoveAttribsKeepLanguages(bool bRemoveParaAttribs)
Definition: editview.cxx:570
const SvxFieldItem * GetFieldUnderMousePointer() const
Definition: editview.cxx:1313
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard() const
Definition: editview.cxx:654
bool MouseMove(const MouseEvent &rMouseEvent)
Definition: editview.cxx:488
void SetBackgroundColor(const Color &rColor)
Definition: editview.cxx:719
void SetCursorLogicPosition(const Point &rPosition, bool bPoint, bool bClearMark)
Allows adjusting the point or mark of the selection to a document coordinate.
Definition: editview.cxx:1663
void CompleteAutoCorrect(vcl::Window const *pFrameWin=nullptr)
Definition: editview.cxx:848
LanguageType GetInputLanguage() const
Definition: editview.cxx:367
bool Command(const CommandEvent &rCEvt)
Definition: editview.cxx:493
EditEngine * GetEditEngine() const
Definition: editview.cxx:178
const tools::Rectangle & GetOutputArea() const
Definition: editview.cxx:421
void SetInsertMode(bool bInsert)
Definition: editview.cxx:821
sal_Int32 StartSearchAndReplace(const SvxSearchItem &rSearchItem)
Definition: editview.cxx:885
Point GetWindowPosTopLeft(sal_Int32 nParagraph)
Definition: editview.cxx:684
sal_Int32 countFieldsOffsetSum(sal_Int32 nPara, sal_Int32 nPo, bool bCanOverflow) const
Definition: editview.cxx:1398
void SetInvalidateMore(sal_uInt16 nPixel)
Definition: editview.cxx:1445
void TransliterateText(TransliterationFlags nTransliterationMode)
Definition: editview.cxx:836
void InsertField(const SvxFieldItem &rFld)
Definition: editview.cxx:1300
ImpEditEngine * GetImpEditEngine() const
Definition: editview.cxx:173
void Invalidate()
Definition: editview.cxx:239
OUString GetSelected() const
Definition: editview.cxx:695
void SetLOKSpecialOutputArea(const tools::Rectangle &rOutputArea)
Definition: editview.cxx:1705
void PasteSpecial()
Definition: editview.cxx:678
tools::Rectangle GetInvalidateRect() const
Definition: editview.cxx:183
void InsertParaBreak()
Definition: editview.cxx:1289
std::vector< VclPtr< vcl::Window > > OutWindowSet
Definition: editview.hxx:159
void SetAttribs(const SfxItemSet &rSet)
Definition: editview.cxx:560
void Paste()
Definition: editview.cxx:672
void Paint(const tools::Rectangle &rRect, OutputDevice *pTargetDevice=nullptr)
Definition: editview.cxx:339
bool AddOtherViewWindow(vcl::Window *pWin)
Definition: editview.cxx:382
void setEditViewCallbacks(EditViewCallbacks *pEditViewCallbacks)
Definition: editview.cxx:163
const tools::Rectangle & GetLOKSpecialOutputArea() const
Definition: editview.cxx:1710
void StartTextConversion(weld::Widget *pDialogParent, LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc)
Definition: editview.cxx:878
void ForceLayoutCalculation()
Definition: editview.cxx:788
EEAnchorMode GetAnchorMode() const
Definition: editview.cxx:831
::Pair Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollRangeCheck nRangeCheck=ScrollRangeCheck::NoNegative)
Definition: editview.cxx:550
EditView(const EditView &)=delete
void InitLOKSpecialPositioning(MapUnit eUnit, const tools::Rectangle &rOutputArea, const Point &rVisDocStartPos)
This is meant for Calc(LOK), but there may be other use-cases.
Definition: editview.cxx:1698
void SetVisArea(const tools::Rectangle &rRect)
Definition: editview.cxx:400
bool SetEditEngineUpdateLayout(bool bUpdate)
Definition: editview.cxx:783
void ReleaseMouse()
Definition: editview.cxx:478
std::unique_ptr< ImpEditView > pImpEditView
Definition: editview.hxx:167
static LanguageType CheckLanguage(const OUString &rText, const css::uno::Reference< css::linguistic2::XSpellChecker1 > &xSpell, const css::uno::Reference< css::linguistic2::XLanguageGuessing > &xLangGuess, bool bIsParaText)
Tries to determine the language of 'rText', returning a matching known locale if possible,...
Definition: editview.cxx:74
static const int * GetStdSizeAry()
Size GetSizePixel() const
LanguageType getLanguageType(bool bResolveSystem=true) const
OUString getLanguage() const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
LanguageTag & makeFallback()
OUString getCountry() const
static css::uno::Reference< css::linguistic2::XSearchableDictionaryList > GetDictionaryList()
Definition: unolingu.cxx:493
static css::uno::Reference< css::linguistic2::XDictionary > GetIgnoreAllList()
Definition: unolingu.cxx:511
static css::uno::Reference< css::linguistic2::XDictionary > GetStandardDic()
Definition: unolingu.cxx:503
static LanguageType resolveSystemLanguageByScriptType(LanguageType nLang, sal_Int16 nType)
Interface class to not depend on SfxViewShell in editeng.
Definition: outliner.hxx:372
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
ContentNode * GetNode() const
Definition: editdoc.hxx:645
bool IsVisible() const
Definition: editdoc.hxx:637
tools::Long Max() const
void Normalize()
tools::Long Min() const
tools::Long Min() const
tools::Long Max() const
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
ErrCode GetError() const
static OUString GetLanguageString(const LanguageType eType)
void GetOptions(SvtLinguOptions &rOptions) const
OUString GetSpellAndGrammarContextDictionaryImage(const OUString &rServiceImplName) const
SvxAutoCorrect * GetAutoCorrect()
Definition: acorrcfg.hxx:96
static SvxAutoCorrCfg & Get()
Definition: acorrcfg.cxx:688
virtual bool PutText(const css::uno::Reference< css::embed::XStorage > &rStg, const OUString &rFileName, const OUString &rShort, SfxObjectShell &, OUString &)
Definition: svxacorr.cxx:1926
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
const SvxFieldData * GetField() const
Definition: flditem.hxx:81
sal_uInt32 GetHeight() const
Definition: fhgtitem.hxx:74
void SetHeight(sal_uInt32 nNewHeight, const sal_uInt16 nNewProp=100, MapUnit eUnit=MapUnit::MapRelative)
Definition: textitem.cxx:893
void ResetInvalidRange(size_t nStart, size_t nEnd)
Definition: edtspell.cxx:178
constexpr tools::Long Top() const
constexpr Point TopLeft() const
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
virtual OUString get_label(const OUString &rIdent) const=0
virtual bool get_sensitive(const OUString &rIdent) const=0
virtual OUString strip_mnemonic(const OUString &rLabel) const=0
virtual VclPtr< VirtualDevice > create_virtual_device() const=0
#define DBG_ASSERT(sCon, aError)
ESelection aNewSelection(GetSelection())
#define EDITUNDO_MOVEPARAS
Definition: editdata.hxx:73
EETextFormat
Definition: editdata.hxx:35
EESpellState
Definition: editdata.hxx:40
#define EDITUNDO_RESETATTRIBS
Definition: editdata.hxx:80
#define EDITUNDO_READ
Definition: editdata.hxx:77
EERemoveParaAttribsMode
Definition: editdata.hxx:46
EEAnchorMode
Definition: editdata.hxx:41
#define EDITUNDO_INSERT
Definition: editdata.hxx:72
#define EE_TEXTPOS_ALL
Definition: editdata.hxx:54
EESelectionMode
Definition: editdata.hxx:37
#define MN_DICTSTART
#define MN_AUTOSTART
#define MN_ALTSTART
EVControlBits
Definition: editstat.hxx:61
static void LOKSendSpellPopupMenu(const weld::Menu &rMenu, LanguageType nGuessLangWord, LanguageType nGuessLangPara, sal_uInt16 nSuggestions)
Definition: editview.cxx:909
static void ChangeFontSizeImpl(EditView *pEditView, bool bGrow, const ESelection &rSel, const FontList *pFontList)
Definition: editview.cxx:1455
LOKSpecialFlags
Definition: editview.hxx:89
ScrollRangeCheck
Definition: editview.hxx:84
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
constexpr sal_uInt16 EE_ITEMS_END(EE_FEATURE_END)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
constexpr sal_uInt16 EE_ITEMS_START(OWN_ATTR_VALUE_END+1)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
OUString EditResId(TranslateId aId)
Definition: eerdll.cxx:192
bool bReadOnly
Mode eMode
sal_Int64 n
#define LANGUAGE_SYSTEM
#define LANGUAGE_NONE
#define LANGUAGE_DONTKNOW
#define LANGUAGE_ENGLISH_US
SvtScriptType
sal_uInt16 nPos
constexpr OUStringLiteral UPN_MAX_NUMBER_OF_SUGGESTIONS
MapUnit
aStr
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
int i
long Long
PointerStyle
static SfxItemSet & rSet
#define nPixel
EPosition aPosition
Definition: editdata.hxx:204
OUString aCurrentText
Definition: editdata.hxx:203
Definition: editdoc.hxx:56
sal_Int32 nIndex
Definition: editdata.hxx:91
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
LanguageType nDefaultLanguage
TransliterationFlags
OUString sId