diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-01-20 15:04:43 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-01-21 00:54:54 +0100 |
commit | 049bbd95c190e0844da3a8dd88b1ce7a9ccf83b7 (patch) | |
tree | bd19faddc850498494539d1899c6a7b9e848ad3a /editeng | |
parent | 06aea80b0482c03e8f0a5f735d3a31ec816a07fe (diff) |
editeng: change EditEngine getter to ref in {Imp}EditView
{Imp}EditView always needs to have EditEngine set (or it would
crash otherwise), so we can change the getter to return a referece
instead of a pointer. This simplifies things a bit because we get
rid of all the nullptr checks and makes the interface more clear.
Also change direct access to mpEditEngine in {Imp}EditView to use
getEditEngine() and getImpEditEngine() (returning a reference)
instead.
Change-Id: Ib8f9c565b8364144bb9c35c3093c4975af1970c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162333
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 5 | ||||
-rw-r--r-- | editeng/source/editeng/editundo.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/editview.cxx | 270 | ||||
-rw-r--r-- | editeng/source/editeng/edtspell.cxx | 36 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 347 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 6 | ||||
-rw-r--r-- | editeng/source/editeng/textconv.cxx | 40 | ||||
-rw-r--r-- | editeng/source/misc/urlfieldhelper.cxx | 2 | ||||
-rw-r--r-- | editeng/source/outliner/outlvw.cxx | 20 |
9 files changed, 368 insertions, 360 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index c55ace752c2b..26e8fe3099b4 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -88,6 +88,11 @@ static bool bDebugPaint = false; static rtl::Reference<SfxItemPool> pGlobalPool; +ImpEditEngine& EditEngine::getImpl() +{ + return *pImpEditEngine; +} + EditEngine::EditEngine( SfxItemPool* pItemPool ) { pImpEditEngine.reset( new ImpEditEngine( this, pItemPool ) ); diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx index 378e1f8f268e..b13ff7109791 100644 --- a/editeng/source/editeng/editundo.cxx +++ b/editeng/source/editeng/editundo.cxx @@ -29,7 +29,7 @@ static void lcl_DoSetSelection( EditView const * pView, sal_uInt16 nPara ) { EPaM aEPaM( nPara, 0 ); - EditPaM aPaM( pView->GetImpEditEngine()->CreateEditPaM( aEPaM ) ); + EditPaM aPaM = pView->getImpEditEngine().CreateEditPaM(aEPaM); aPaM.SetIndex( aPaM.GetNode()->Len() ); EditSelection aSel( aPaM, aPaM ); pView->GetImpEditView()->SetEditSelection( aSel ); diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index ff979af96698..c8a974df8ec1 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -151,9 +151,10 @@ EditViewCallbacks::~EditViewCallbacks() { } -EditView::EditView( EditEngine* pEng, vcl::Window* pWindow ) +EditView::EditView(EditEngine* pEditEngine, vcl::Window* pWindow) + : pImpEditView(new ImpEditView(this, pEditEngine, pWindow)) { - pImpEditView.reset( new ImpEditView( this, pEng, pWindow ) ); + assert(pEditEngine); } EditView::~EditView() @@ -170,14 +171,14 @@ EditViewCallbacks* EditView::getEditViewCallbacks() const return pImpEditView->getEditViewCallbacks(); } -ImpEditEngine* EditView::GetImpEditEngine() const +ImpEditEngine& EditView::getImpEditEngine() const { - return pImpEditView->pEditEngine->pImpEditEngine.get(); + return pImpEditView->getImpEditEngine(); } -EditEngine* EditView::GetEditEngine() const +EditEngine& EditView::getEditEngine() const { - return pImpEditView->pEditEngine; + return pImpEditView->getEditEngine(); } tools::Rectangle EditView::GetInvalidateRect() const @@ -264,29 +265,28 @@ void EditView::SetSelection( const ESelection& rESel ) { // tdf#113591 Get node from EditDoc, as the selection might have a pointer to an // already deleted node. - const ContentNode* pNode(pImpEditView->pEditEngine->GetEditDoc().GetEndPaM().GetNode()); + const ContentNode* pNode(getEditEngine().GetEditDoc().GetEndPaM().GetNode()); if (nullptr != pNode) pNode->checkAndDeleteEmptyAttribs(); } - EditSelection aNewSelection( pImpEditView->pEditEngine->pImpEditEngine->ConvertSelection( - rESel.nStartPara, rESel.nStartPos, rESel.nEndPara, rESel.nEndPos ) ); + EditSelection aNewSelection(getImpEditEngine().ConvertSelection(rESel.nStartPara, rESel.nStartPos, rESel.nEndPara, rESel.nEndPos)); // If the selection is manipulated after a KeyInput: - pImpEditView->pEditEngine->CheckIdleFormatter(); + getEditEngine().CheckIdleFormatter(); // Selection may not start/end at an invisible paragraph: - const ParaPortion* pPortion = pImpEditView->pEditEngine->FindParaPortion( aNewSelection.Min().GetNode() ); + const ParaPortion* pPortion = getEditEngine().FindParaPortion( aNewSelection.Min().GetNode() ); if ( !pPortion->IsVisible() ) { - pPortion = pImpEditView->pEditEngine->GetPrevVisPortion( pPortion ); - ContentNode* pNode = pPortion ? pPortion->GetNode() : pImpEditView->pEditEngine->GetEditDoc().GetObject( 0 ); + pPortion = getEditEngine().GetPrevVisPortion( pPortion ); + ContentNode* pNode = pPortion ? pPortion->GetNode() : getEditEngine().GetEditDoc().GetObject( 0 ); aNewSelection.Min() = EditPaM( pNode, pNode->Len() ); } - pPortion = pImpEditView->pEditEngine->FindParaPortion( aNewSelection.Max().GetNode() ); + pPortion = getEditEngine().FindParaPortion( aNewSelection.Max().GetNode() ); if ( !pPortion->IsVisible() ) { - pPortion = pImpEditView->pEditEngine->GetPrevVisPortion( pPortion ); - ContentNode* pNode = pPortion ? pPortion->GetNode() : pImpEditView->pEditEngine->GetEditDoc().GetObject( 0 ); + pPortion = getEditEngine().GetPrevVisPortion( pPortion ); + ContentNode* pNode = pPortion ? pPortion->GetNode() : getEditEngine().GetEditDoc().GetObject( 0 ); aNewSelection.Max() = EditPaM( pNode, pNode->Len() ); } @@ -306,8 +306,8 @@ ESelection EditView::GetSelection() const { ESelection aSelection; - aSelection.nStartPara = pImpEditView->pEditEngine->GetEditDoc().GetPos( pImpEditView->GetEditSelection().Min().GetNode() ); - aSelection.nEndPara = pImpEditView->pEditEngine->GetEditDoc().GetPos( pImpEditView->GetEditSelection().Max().GetNode() ); + aSelection.nStartPara = getEditEngine().GetEditDoc().GetPos( pImpEditView->GetEditSelection().Min().GetNode() ); + aSelection.nEndPara = getEditEngine().GetEditDoc().GetPos( pImpEditView->GetEditSelection().Max().GetNode() ); aSelection.nStartPos = pImpEditView->GetEditSelection().Min().GetIndex(); aSelection.nEndPos = pImpEditView->GetEditSelection().Max().GetIndex(); @@ -342,7 +342,7 @@ void EditView::DeleteSelected() SvtScriptType EditView::GetSelectedScriptType() const { - return pImpEditView->pEditEngine->GetScriptType( pImpEditView->GetEditSelection() ); + return getEditEngine().GetScriptType( pImpEditView->GetEditSelection() ); } void EditView::GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects) const @@ -352,20 +352,22 @@ void EditView::GetSelectionRectangles(std::vector<tools::Rectangle>& rLogicRects void EditView::Paint( const tools::Rectangle& rRect, OutputDevice* pTargetDevice ) { - pImpEditView->pEditEngine->pImpEditEngine->Paint( pImpEditView.get(), rRect, pTargetDevice ); + getImpEditEngine().Paint( pImpEditView.get(), rRect, pTargetDevice ); } -void EditView::SetEditEngine( EditEngine* pEditEng ) +void EditView::setEditEngine(EditEngine* pEditEngine) { - pImpEditView->pEditEngine = pEditEng; - EditSelection aStartSel = pImpEditView->pEditEngine->GetEditDoc().GetStartPaM(); + assert(pEditEngine); + + pImpEditView->mpEditEngine = pEditEngine; + EditSelection aStartSel = getEditEngine().GetEditDoc().GetStartPaM(); pImpEditView->SetEditSelection( aStartSel ); } void EditView::SetWindow( vcl::Window* pWin ) { pImpEditView->pOutWin = pWin; - pImpEditView->pEditEngine->pImpEditEngine->GetSelEngine().Reset(); + getImpEditEngine().GetSelEngine().Reset(); } vcl::Window* EditView::GetWindow() const @@ -427,7 +429,7 @@ void EditView::SetOutputArea( const tools::Rectangle& rRect ) // the rest here only if it is an API call: pImpEditView->CalcAnchorPoint(); - if ( pImpEditView->pEditEngine->pImpEditEngine->GetStatus().AutoPageSize() ) + if (getImpEditEngine().GetStatus().AutoPageSize() ) pImpEditView->RecalcOutputArea(); pImpEditView->ShowCursor( false, false ); } @@ -450,7 +452,7 @@ vcl::Cursor* EditView::GetCursor() const void EditView::InsertText( const OUString& rStr, bool bSelect, bool bLOKShowSelect ) { - EditEngine* pEE = pImpEditView->pEditEngine; + EditEngine& rEditEngine = getEditEngine(); if (bLOKShowSelect) pImpEditView->DrawSelectionXOR(); @@ -459,24 +461,24 @@ void EditView::InsertText( const OUString& rStr, bool bSelect, bool bLOKShowSele if ( bSelect ) { EditSelection aTmpSel( pImpEditView->GetEditSelection() ); - aTmpSel.Adjust( pEE->GetEditDoc() ); + aTmpSel.Adjust(rEditEngine.GetEditDoc()); aPaM1 = aTmpSel.Min(); } - pEE->UndoActionStart( EDITUNDO_INSERT ); - EditPaM aPaM2( pEE->InsertText( pImpEditView->GetEditSelection(), rStr ) ); - pEE->UndoActionEnd(); + rEditEngine.UndoActionStart( EDITUNDO_INSERT ); + EditPaM aPaM2(rEditEngine.InsertText( pImpEditView->GetEditSelection(), rStr ) ); + rEditEngine.UndoActionEnd(); if ( bSelect ) { - DBG_ASSERT( !aPaM1.DbgIsBuggy( pEE->GetEditDoc() ), "Insert: PaM broken" ); + DBG_ASSERT( !aPaM1.DbgIsBuggy(rEditEngine.GetEditDoc()), "Insert: PaM broken" ); pImpEditView->SetEditSelection( EditSelection( aPaM1, aPaM2 ) ); } else pImpEditView->SetEditSelection( EditSelection( aPaM2, aPaM2 ) ); if (bLOKShowSelect) - pEE->FormatAndLayout( this ); + rEditEngine.FormatAndLayout( this ); } bool EditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * pFrameWin ) @@ -521,7 +523,7 @@ tools::Rectangle EditView::GetEditCursor() const void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bActivate ) { - if ( !pImpEditView->pEditEngine->HasView( this ) ) + if (!getEditEngine().HasView(this)) return; // The control word is more important: @@ -568,7 +570,7 @@ Pair EditView::Scroll( tools::Long ndX, tools::Long ndY, ScrollRangeCheck nRange const SfxItemSet& EditView::GetEmptyItemSet() const { - return pImpEditView->pEditEngine->GetEmptyItemSet(); + return getEditEngine().GetEmptyItemSet(); } void EditView::SetAttribs( const SfxItemSet& rSet ) @@ -576,16 +578,16 @@ void EditView::SetAttribs( const SfxItemSet& rSet ) DBG_ASSERT( !pImpEditView->aEditSelection.IsInvalid(), "Blind Selection in..." ); pImpEditView->DrawSelectionXOR(); - pImpEditView->pEditEngine->SetAttribs( pImpEditView->GetEditSelection(), rSet, SetAttribsMode::WholeWord ); - if (pImpEditView->pEditEngine->IsUpdateLayout()) - pImpEditView->pEditEngine->FormatAndLayout( this ); + getEditEngine().SetAttribs( pImpEditView->GetEditSelection(), rSet, SetAttribsMode::WholeWord ); + if (getEditEngine().IsUpdateLayout()) + getEditEngine().FormatAndLayout( this ); } void EditView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs ) { pImpEditView->DrawSelectionXOR(); - pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS ); + getEditEngine().UndoActionStart( EDITUNDO_RESETATTRIBS ); EditSelection aSelection( pImpEditView->GetEditSelection() ); for (sal_uInt16 nWID = EE_ITEMS_START; nWID <= EE_ITEMS_END; ++nWID) @@ -594,12 +596,12 @@ void EditView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs ) EE_CHAR_LANGUAGE_CJK == nWID || EE_CHAR_LANGUAGE_CTL == nWID; if (!bIsLang) - pImpEditView->pEditEngine->RemoveCharAttribs( aSelection, bRemoveParaAttribs, nWID ); + getEditEngine().RemoveCharAttribs( aSelection, bRemoveParaAttribs, nWID ); } - pImpEditView->pEditEngine->UndoActionEnd(); - if (pImpEditView->pEditEngine->IsUpdateLayout()) - pImpEditView->pEditEngine->FormatAndLayout( this ); + getEditEngine().UndoActionEnd(); + if (getEditEngine().IsUpdateLayout()) + getEditEngine().FormatAndLayout( this ); } void EditView::RemoveAttribs( bool bRemoveParaAttribs, sal_uInt16 nWhich ) @@ -611,45 +613,45 @@ void EditView::RemoveAttribs( bool bRemoveParaAttribs, sal_uInt16 nWhich ) void EditView::RemoveAttribs( EERemoveParaAttribsMode eMode, sal_uInt16 nWhich ) { pImpEditView->DrawSelectionXOR(); - pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS ); - pImpEditView->pEditEngine->RemoveCharAttribs( pImpEditView->GetEditSelection(), eMode, nWhich ); - pImpEditView->pEditEngine->UndoActionEnd(); - if (pImpEditView->pEditEngine->IsUpdateLayout()) - pImpEditView->pEditEngine->FormatAndLayout( this ); + getEditEngine().UndoActionStart( EDITUNDO_RESETATTRIBS ); + getEditEngine().RemoveCharAttribs( pImpEditView->GetEditSelection(), eMode, nWhich ); + getEditEngine().UndoActionEnd(); + if (getEditEngine().IsUpdateLayout()) + getEditEngine().FormatAndLayout( this ); } void EditView::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich ) { - pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS ); - pImpEditView->pEditEngine->RemoveCharAttribs( nPara, nWhich ); - pImpEditView->pEditEngine->UndoActionEnd(); - if (pImpEditView->pEditEngine->IsUpdateLayout()) - pImpEditView->pEditEngine->FormatAndLayout( this ); + getEditEngine().UndoActionStart( EDITUNDO_RESETATTRIBS ); + getEditEngine().RemoveCharAttribs( nPara, nWhich ); + getEditEngine().UndoActionEnd(); + if (getEditEngine().IsUpdateLayout()) + getEditEngine().FormatAndLayout( this ); } SfxItemSet EditView::GetAttribs() { DBG_ASSERT( !pImpEditView->aEditSelection.IsInvalid(), "Blind Selection in..." ); - return pImpEditView->pEditEngine->pImpEditEngine->GetAttribs( pImpEditView->GetEditSelection() ); + return getImpEditEngine().GetAttribs( pImpEditView->GetEditSelection() ); } void EditView::Undo() { - pImpEditView->pEditEngine->Undo( this ); + getEditEngine().Undo( this ); } void EditView::Redo() { - pImpEditView->pEditEngine->Redo( this ); + getEditEngine().Redo( this ); } ErrCode EditView::Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs ) { EditSelection aOldSel( pImpEditView->GetEditSelection() ); pImpEditView->DrawSelectionXOR(); - pImpEditView->pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_READ ); - EditPaM aEndPaM = pImpEditView->pEditEngine->pImpEditEngine->Read( rInput, "", eFormat, aOldSel, pHTTPHeaderAttrs ); - pImpEditView->pEditEngine->pImpEditEngine->UndoActionEnd(); + getImpEditEngine().UndoActionStart( EDITUNDO_READ ); + EditPaM aEndPaM = getImpEditEngine().Read( rInput, "", eFormat, aOldSel, pHTTPHeaderAttrs ); + getImpEditEngine().UndoActionEnd(); EditSelection aNewSel( aEndPaM, aEndPaM ); pImpEditView->SetEditSelection( aNewSel ); @@ -672,8 +674,7 @@ Reference<css::datatransfer::clipboard::XClipboard> EditView::GetClipboard() con css::uno::Reference< css::datatransfer::XTransferable > EditView::GetTransferable() const { - uno::Reference< datatransfer::XTransferable > xData = - GetEditEngine()->CreateTransferable( pImpEditView->GetEditSelection() ); + uno::Reference< datatransfer::XTransferable > xData = getEditEngine().CreateTransferable( pImpEditView->GetEditSelection() ); return xData; } @@ -697,7 +698,7 @@ void EditView::PasteSpecial(SotClipboardFormatId format) Point EditView::GetWindowPosTopLeft( sal_Int32 nParagraph ) { - Point aDocPos( pImpEditView->pEditEngine->GetDocPosTopLeft( nParagraph ) ); + Point aDocPos(getEditEngine().GetDocPosTopLeft(nParagraph)); return pImpEditView->GetWindowPos( aDocPos ); } @@ -708,14 +709,14 @@ void EditView::SetSelectionMode( EESelectionMode eMode ) OUString EditView::GetSelected() const { - return pImpEditView->pEditEngine->pImpEditEngine->GetSelected( pImpEditView->GetEditSelection() ); + return getImpEditEngine().GetSelected( pImpEditView->GetEditSelection() ); } void EditView::MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos ) { - pImpEditView->pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_MOVEPARAS ); - pImpEditView->pEditEngine->pImpEditEngine->MoveParagraphs( aParagraphs, nNewPos, this ); - pImpEditView->pEditEngine->pImpEditEngine->UndoActionEnd(); + getImpEditEngine().UndoActionStart( EDITUNDO_MOVEPARAS ); + getImpEditEngine().MoveParagraphs( aParagraphs, nNewPos, this ); + getImpEditEngine().UndoActionEnd(); } void EditView::MoveParagraphs( tools::Long nDiff ) @@ -726,14 +727,14 @@ void EditView::MoveParagraphs( tools::Long nDiff ) tools::Long nDest = ( nDiff > 0 ? aRange.Max() : aRange.Min() ) + nDiff; if ( nDiff > 0 ) nDest++; - DBG_ASSERT( ( nDest >= 0 ) && ( nDest <= pImpEditView->pEditEngine->GetParagraphCount() ), "MoveParagraphs - wrong Parameters!" ); + DBG_ASSERT( ( nDest >= 0 ) && ( nDest <= getEditEngine().GetParagraphCount() ), "MoveParagraphs - wrong Parameters!" ); MoveParagraphs( aRange, sal::static_int_cast< sal_Int32 >( nDest ) ); } void EditView::SetBackgroundColor( const Color& rColor ) { pImpEditView->SetBackgroundColor( rColor ); - pImpEditView->pEditEngine->SetBackgroundColor( rColor ); + getEditEngine().SetBackgroundColor( rColor ); } Color const & EditView::GetBackgroundColor() const @@ -763,58 +764,58 @@ EVControlBits EditView::GetControlWord() const std::unique_ptr<EditTextObject> EditView::CreateTextObject() { - return pImpEditView->pEditEngine->pImpEditEngine->CreateTextObject( pImpEditView->GetEditSelection() ); + return getImpEditEngine().CreateTextObject( pImpEditView->GetEditSelection() ); } void EditView::InsertText( const EditTextObject& rTextObject ) { pImpEditView->DrawSelectionXOR(); - pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_INSERT ); - EditSelection aTextSel( pImpEditView->pEditEngine->InsertText( rTextObject, pImpEditView->GetEditSelection() ) ); - pImpEditView->pEditEngine->UndoActionEnd(); + getEditEngine().UndoActionStart( EDITUNDO_INSERT ); + EditSelection aTextSel(getEditEngine().InsertText(rTextObject, pImpEditView->GetEditSelection())); + getEditEngine().UndoActionEnd(); aTextSel.Min() = aTextSel.Max(); // Selection not retained. pImpEditView->SetEditSelection( aTextSel ); - if (pImpEditView->pEditEngine->IsUpdateLayout()) - pImpEditView->pEditEngine->FormatAndLayout( this ); + if (getEditEngine().IsUpdateLayout()) + getEditEngine().FormatAndLayout( this ); } void EditView::InsertText( css::uno::Reference< css::datatransfer::XTransferable > const & xDataObj, const OUString& rBaseURL, bool bUseSpecial ) { - pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_INSERT ); + getEditEngine().UndoActionStart( EDITUNDO_INSERT ); pImpEditView->DeleteSelected(); EditSelection aTextSel = - pImpEditView->pEditEngine->InsertText(xDataObj, rBaseURL, pImpEditView->GetEditSelection().Max(), bUseSpecial); - pImpEditView->pEditEngine->UndoActionEnd(); + getEditEngine().InsertText(xDataObj, rBaseURL, pImpEditView->GetEditSelection().Max(), bUseSpecial); + getEditEngine().UndoActionEnd(); aTextSel.Min() = aTextSel.Max(); // Selection not retained. pImpEditView->SetEditSelection( aTextSel ); - if (pImpEditView->pEditEngine->IsUpdateLayout()) - pImpEditView->pEditEngine->FormatAndLayout( this ); + if (getEditEngine().IsUpdateLayout()) + getEditEngine().FormatAndLayout( this ); } bool EditView::SetEditEngineUpdateLayout( bool bUpdate ) { - return pImpEditView->pEditEngine->pImpEditEngine->SetUpdateLayout( bUpdate, this ); + return getImpEditEngine().SetUpdateLayout( bUpdate, this ); } void EditView::ForceLayoutCalculation() { - pImpEditView->pEditEngine->pImpEditEngine->SetUpdateLayout( true, this, true ); + getImpEditEngine().SetUpdateLayout( true, this, true ); } SfxStyleSheet* EditView::GetStyleSheet() { EditSelection aSel( pImpEditView->GetEditSelection() ); - aSel.Adjust( pImpEditView->pEditEngine->GetEditDoc() ); - sal_Int32 nStartPara = pImpEditView->pEditEngine->GetEditDoc().GetPos( aSel.Min().GetNode() ); - sal_Int32 nEndPara = pImpEditView->pEditEngine->GetEditDoc().GetPos( aSel.Max().GetNode() ); + aSel.Adjust(getEditEngine().GetEditDoc()); + sal_Int32 nStartPara = getEditEngine().GetEditDoc().GetPos( aSel.Min().GetNode() ); + sal_Int32 nEndPara = getEditEngine().GetEditDoc().GetPos( aSel.Max().GetNode() ); SfxStyleSheet* pStyle = nullptr; for ( sal_Int32 n = nStartPara; n <= nEndPara; n++ ) { - SfxStyleSheet* pTmpStyle = pImpEditView->pEditEngine->GetStyleSheet( n ); + SfxStyleSheet* pTmpStyle = getEditEngine().GetStyleSheet( n ); if ( ( n != nStartPara ) && ( pStyle != pTmpStyle ) ) return nullptr; // Not unique. pStyle = pTmpStyle; @@ -850,7 +851,7 @@ EEAnchorMode EditView::GetAnchorMode() const void EditView::TransliterateText( TransliterationFlags nTransliterationMode ) { EditSelection aOldSel( pImpEditView->GetEditSelection() ); - EditSelection aNewSel = pImpEditView->pEditEngine->TransliterateText( pImpEditView->GetEditSelection(), nTransliterationMode ); + EditSelection aNewSel = getEditEngine().TransliterateText( pImpEditView->GetEditSelection(), nTransliterationMode ); if ( aNewSel != aOldSel ) { pImpEditView->DrawSelectionXOR(); @@ -861,44 +862,44 @@ void EditView::TransliterateText( TransliterationFlags nTransliterationMode ) void EditView::CompleteAutoCorrect( vcl::Window const * pFrameWin ) { - if ( !HasSelection() && pImpEditView->pEditEngine->pImpEditEngine->GetStatus().DoAutoCorrect() ) + if ( !HasSelection() && getImpEditEngine().GetStatus().DoAutoCorrect() ) { pImpEditView->DrawSelectionXOR(); EditSelection aSel = pImpEditView->GetEditSelection(); - aSel = pImpEditView->pEditEngine->EndOfWord( aSel.Max() ); - aSel = pImpEditView->pEditEngine->pImpEditEngine->AutoCorrect( aSel, 0, !IsInsertMode(), pFrameWin ); + aSel = getEditEngine().EndOfWord( aSel.Max() ); + aSel = getImpEditEngine().AutoCorrect( aSel, 0, !IsInsertMode(), pFrameWin ); pImpEditView->SetEditSelection( aSel ); - if ( pImpEditView->pEditEngine->IsModified() ) - pImpEditView->pEditEngine->FormatAndLayout( this ); + if (getEditEngine().IsModified()) + getEditEngine().FormatAndLayout( this ); } } EESpellState EditView::StartSpeller(weld::Widget* pDialogParent, bool bMultipleDoc) { - if ( !pImpEditView->pEditEngine->pImpEditEngine->GetSpeller().is() ) + if (!getImpEditEngine().GetSpeller().is()) return EESpellState::NoSpeller; - return pImpEditView->pEditEngine->pImpEditEngine->Spell(this, pDialogParent, bMultipleDoc); + return getImpEditEngine().Spell(this, pDialogParent, bMultipleDoc); } EESpellState EditView::StartThesaurus(weld::Widget* pDialogParent) { - if ( !pImpEditView->pEditEngine->pImpEditEngine->GetSpeller().is() ) + if (!getImpEditEngine().GetSpeller().is()) return EESpellState::NoSpeller; - return pImpEditView->pEditEngine->pImpEditEngine->StartThesaurus(this, pDialogParent); + return getImpEditEngine().StartThesaurus(this, pDialogParent); } void EditView::StartTextConversion(weld::Widget* pDialogParent, LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc ) { - pImpEditView->pEditEngine->pImpEditEngine->Convert(this, pDialogParent, nSrcLang, nDestLang, pDestFont, nOptions, bIsInteractive, bMultipleDoc); + getImpEditEngine().Convert(this, pDialogParent, nSrcLang, nDestLang, pDestFont, nOptions, bIsInteractive, bMultipleDoc); } sal_Int32 EditView::StartSearchAndReplace( const SvxSearchItem& rSearchItem ) { - return pImpEditView->pEditEngine->pImpEditEngine->StartSearchAndReplace( this, rSearchItem ); + return getImpEditEngine().StartSearchAndReplace( this, rSearchItem ); } bool EditView::IsCursorAtWrongSpelledWord() @@ -916,7 +917,7 @@ bool EditView::IsWrongSpelledWordAtPos( const Point& rPosPixel, bool bMarkIfWron { Point aPos(pImpEditView->GetOutputDevice().PixelToLogic(rPosPixel)); aPos = pImpEditView->GetDocPos( aPos ); - EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aPos, false); + EditPaM aPaM = getEditEngine().GetPaM(aPos, false); return pImpEditView->IsWrongSpelledWord( aPaM , bMarkIfWrong ); } @@ -998,14 +999,14 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac OutputDevice& rDevice = pImpEditView->GetOutputDevice(); Point aPos(rDevice.PixelToLogic(rPosPixel)); aPos = pImpEditView->GetDocPos( aPos ); - EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aPos, false); - Reference< linguistic2::XSpellChecker1 > xSpeller( pImpEditView->pEditEngine->pImpEditEngine->GetSpeller() ); + EditPaM aPaM = getEditEngine().GetPaM(aPos, false); + Reference< linguistic2::XSpellChecker1 > xSpeller(getImpEditEngine().GetSpeller()); ESelection aOldSel = GetSelection(); if ( !(xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, true )) ) return false; // PaMtoEditCursor returns Logical units - tools::Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly ); + tools::Rectangle aTempRect = getImpEditEngine().PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly ); // GetWindowPos works in Logical units aTempRect = pImpEditView->GetWindowPos(aTempRect); // Convert to pixels @@ -1037,7 +1038,7 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac // Are there any replace suggestions? Reference< linguistic2::XSpellAlternatives > xSpellAlt = - xSpeller->spell( aSelected, static_cast<sal_uInt16>(pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ).nLang), aPropVals ); + xSpeller->spell( aSelected, static_cast<sal_uInt16>(getImpEditEngine().GetLanguage( aPaM2 ).nLang), aPropVals ); Reference< linguistic2::XLanguageGuessing > xLangGuesser( EditDLL::Get().GetGlobalData()->GetLanguageGuesser() ); @@ -1118,7 +1119,7 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac aDics = xDicList->getDictionaries(); pDic = aDics.getConstArray(); - LanguageType nCheckedLanguage = pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ).nLang; + LanguageType nCheckedLanguage = getImpEditEngine().GetLanguage( aPaM2 ).nLang; sal_uInt16 nDicCount = static_cast<sal_uInt16>(aDics.getLength()); for (sal_uInt16 i = 0; i < nDicCount; i++) { @@ -1174,8 +1175,8 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac //because the loss of focus in the current editeng causes writer //annotations to save their contents, making the pContent of the //current EditPams invalid - EPaM aP = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM); - EPaM aP2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEPaM(aPaM2); + EPaM aP = getImpEditEngine().CreateEPaM(aPaM); + EPaM aP2 = getImpEditEngine().CreateEPaM(aPaM2); if (comphelper::LibreOfficeKit::isActive()) { @@ -1188,8 +1189,8 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac OUString sId = xPopupMenu->popup_at_rect(pPopupParent, aTempRect); - aPaM2 = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP2); - aPaM = pImpEditView->pEditEngine->pImpEditEngine->CreateEditPaM(aP); + aPaM2 = getImpEditEngine().CreateEditPaM(aP2); + aPaM = getImpEditEngine().CreateEditPaM(aP); if (sId == "ignore") { @@ -1203,7 +1204,7 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac LanguageType nLangToUse = (sId == "wordlanguage") ? nGuessLangWord : nGuessLangPara; SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse ); - SfxItemSet aAttrs = GetEditEngine()->GetEmptyItemSet(); + SfxItemSet aAttrs = getEditEngine().GetEmptyItemSet(); if (nScriptType == SvtScriptType::LATIN) aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) ); if (nScriptType == SvtScriptType::COMPLEX) @@ -1218,7 +1219,7 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac SetSelection( aSel ); } SetAttribs( aAttrs ); - pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer(); + getImpEditEngine().StartOnlineSpellTimer(); SpellCallbackInfo aInf((sId == "wordlanguage") ? SpellCallbackCommand::WORDLANGUAGE : SpellCallbackCommand::PARALANGUAGE); rCallBack.Call(aInf); @@ -1258,7 +1259,7 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac xSavDic->store(); aPaM.GetNode()->GetWrongList()->ResetInvalidRange(0, aPaM.GetNode()->Len()); - pImpEditView->pEditEngine->pImpEditEngine->StartOnlineSpellTimer(); + getImpEditEngine().StartOnlineSpellTimer(); SpellCallbackInfo aInf( SpellCallbackCommand::ADDTODICTIONARY, aSelected ); rCallBack.Call(aInf); @@ -1270,7 +1271,7 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCallbac OUString aWord = pAlt[sId.toInt32() - MN_AUTOSTART]; SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); if ( pAutoCorrect ) - pAutoCorrect->PutText( aSelected, aWord, pImpEditView->pEditEngine->pImpEditEngine->GetLanguage( aPaM2 ).nLang ); + pAutoCorrect->PutText( aSelected, aWord, getImpEditEngine().GetLanguage( aPaM2 ).nLang ); InsertText( aWord ); } else if ( sId.toInt32() >= MN_ALTSTART ) // Replace @@ -1295,7 +1296,7 @@ void EditView::SelectCurrentWord( sal_Int16 nWordType ) { EditSelection aCurSel( pImpEditView->GetEditSelection() ); pImpEditView->DrawSelectionXOR(); - aCurSel = pImpEditView->pEditEngine->SelectWord(aCurSel.Max(), nWordType); + aCurSel = getEditEngine().SelectWord(aCurSel.Max(), nWordType); pImpEditView->SetEditSelection( aCurSel ); pImpEditView->DrawSelectionXOR(); ShowCursor( true, false ); @@ -1303,26 +1304,26 @@ void EditView::SelectCurrentWord( sal_Int16 nWordType ) void EditView::InsertParaBreak() { - pImpEditView->pEditEngine->UndoActionStart(EDITUNDO_INSERT); + getEditEngine().UndoActionStart(EDITUNDO_INSERT); pImpEditView->DeleteSelected(); - EditPaM aPaM(pImpEditView->pEditEngine->InsertParaBreak(pImpEditView->GetEditSelection())); - pImpEditView->pEditEngine->UndoActionEnd(); + EditPaM aPaM(getEditEngine().InsertParaBreak(pImpEditView->GetEditSelection())); + getEditEngine().UndoActionEnd(); pImpEditView->SetEditSelection(EditSelection(aPaM, aPaM)); - if (pImpEditView->pEditEngine->IsUpdateLayout()) - pImpEditView->pEditEngine->FormatAndLayout(this); + if (getEditEngine().IsUpdateLayout()) + getEditEngine().FormatAndLayout(this); } void EditView::InsertField( const SvxFieldItem& rFld ) { - EditEngine* pEE = pImpEditView->pEditEngine; + EditEngine& rEditEngine = pImpEditView->getEditEngine(); pImpEditView->DrawSelectionXOR(); - pEE->UndoActionStart( EDITUNDO_INSERT ); - EditPaM aPaM( pEE->InsertField( pImpEditView->GetEditSelection(), rFld ) ); - pEE->UndoActionEnd(); + rEditEngine.UndoActionStart( EDITUNDO_INSERT ); + EditPaM aPaM(rEditEngine.InsertField(pImpEditView->GetEditSelection(), rFld)); + rEditEngine.UndoActionEnd(); pImpEditView->SetEditSelection( EditSelection( aPaM, aPaM ) ); - pEE->UpdateFields(); - if (pImpEditView->pEditEngine->IsUpdateLayout()) - pEE->FormatAndLayout( this ); + rEditEngine.UpdateFields(); + if (rEditEngine.IsUpdateLayout()) + rEditEngine.FormatAndLayout( this ); } const SvxFieldItem* EditView::GetFieldUnderMousePointer() const @@ -1366,7 +1367,7 @@ const SvxFieldItem* EditView::GetFieldAtSelection(bool* pIsBeforeCursor) const return nullptr; // normalize: min < max - aSel.Adjust( pImpEditView->pEditEngine->GetEditDoc() ); + aSel.Adjust(getEditEngine().GetEditDoc()); const sal_Int32 nMinIndex = aSel.Min().GetIndex(); const sal_Int32 nMaxIndex = aSel.Max().GetIndex(); @@ -1440,18 +1441,17 @@ const SvxFieldData* EditView::GetFieldUnderMouseOrInSelectionOrAtCursor(bool bAl sal_Int32 EditView::countFieldsOffsetSum(sal_Int32 nPara, sal_Int32 nPos, bool bCanOverflow) const { - if (!pImpEditView || !pImpEditView->pEditEngine) + if (!pImpEditView) return 0; int nOffset = 0; for (int nCurrentPara = 0; nCurrentPara <= nPara; nCurrentPara++) { - int nFields = pImpEditView->pEditEngine->GetFieldCount( nCurrentPara ); + int nFields = getEditEngine().GetFieldCount( nCurrentPara ); for (int nField = 0; nField < nFields; nField++) { - EFieldInfo aFieldInfo - = pImpEditView->pEditEngine->GetFieldInfo( nCurrentPara, nField ); + EFieldInfo aFieldInfo = getEditEngine().GetFieldInfo( nCurrentPara, nField ); bool bLastPara = nCurrentPara == nPara; sal_Int32 nFieldPos = aFieldInfo.aPosition.nIndex; @@ -1513,7 +1513,7 @@ static void ChangeFontSizeImpl( EditView* pEditView, bool bGrow, const ESelectio void EditView::ChangeFontSize( bool bGrow, const FontList* pFontList ) { - EditEngine& rEditEngine = *pImpEditView->pEditEngine; + EditEngine& rEditEngine = getEditEngine(); ESelection aSel( GetSelection() ); ESelection aOldSelection( aSel ); @@ -1649,11 +1649,11 @@ bool EditView::ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFo OUString EditView::GetSurroundingText() const { EditSelection aSel( pImpEditView->GetEditSelection() ); - aSel.Adjust( pImpEditView->pEditEngine->GetEditDoc() ); + aSel.Adjust(getEditEngine().GetEditDoc()); if( HasSelection() ) { - OUString aStr = pImpEditView->pEditEngine->GetSelected(aSel); + OUString aStr = getEditEngine().GetSelected(aSel); // Stop reconversion if the selected text includes a line break. if ( aStr.indexOf( 0x0A ) == -1 ) @@ -1665,7 +1665,7 @@ OUString EditView::GetSurroundingText() const { aSel.Min().SetIndex( 0 ); aSel.Max().SetIndex( aSel.Max().GetNode()->Len() ); - return pImpEditView->pEditEngine->GetSelected(aSel); + return getEditEngine().GetSelected(aSel); } } @@ -1677,8 +1677,8 @@ Selection EditView::GetSurroundingTextSelection() const if( HasSelection() ) { EditSelection aSel( pImpEditView->GetEditSelection() ); - aSel.Adjust( pImpEditView->pEditEngine->GetEditDoc() ); - OUString aStr = pImpEditView->pEditEngine->GetSelected(aSel); + aSel.Adjust(getEditEngine().GetEditDoc()); + OUString aStr = getEditEngine().GetSelected(aSel); // Stop reconversion if the selected text includes a line break. if ( aStr.indexOf( 0x0A ) == -1 ) @@ -1706,7 +1706,7 @@ bool EditView::DeleteSurroundingText(const Selection& rRange) void EditView::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark) { Point aDocPos(pImpEditView->GetDocPos(rPosition)); - EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aDocPos); + EditPaM aPaM = getEditEngine().GetPaM(aDocPos); EditSelection aSelection(pImpEditView->GetEditSelection()); // Explicitly create or delete the selection. diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx index 36e9f5fd84ae..8fbeefcf3908 100644 --- a/editeng/source/editeng/edtspell.cxx +++ b/editeng/source/editeng/edtspell.cxx @@ -49,9 +49,9 @@ EditSpellWrapper::EditSpellWrapper(weld::Widget* pWindow, void EditSpellWrapper::SpellStart( SvxSpellArea eArea ) { - EditEngine* pEE = pEditView->GetEditEngine(); - ImpEditEngine* pImpEE = pEditView->GetImpEditEngine(); - SpellInfo* pSpellInfo = pImpEE->GetSpellInfo(); + EditEngine& rEditEngine = pEditView->getEditEngine(); + ImpEditEngine& rImpEditEngine = pEditView->getImpEditEngine(); + SpellInfo* pSpellInfo = rImpEditEngine.GetSpellInfo(); if ( eArea == SvxSpellArea::BodyStart ) { @@ -63,13 +63,13 @@ void EditSpellWrapper::SpellStart( SvxSpellArea eArea ) pSpellInfo->bSpellToEnd = false; pSpellInfo->aSpellTo = pSpellInfo->aSpellStart; pEditView->GetImpEditView()->SetEditSelection( - pEE->GetEditDoc().GetStartPaM() ); + rEditEngine.GetEditDoc().GetStartPaM() ); } else { pSpellInfo->bSpellToEnd = true; - pSpellInfo->aSpellTo = pImpEE->CreateEPaM( - pEE->GetEditDoc().GetStartPaM() ); + pSpellInfo->aSpellTo = rImpEditEngine.CreateEPaM( + rEditEngine.GetEditDoc().GetStartPaM() ); } } else if ( eArea == SvxSpellArea::BodyEnd ) @@ -80,15 +80,15 @@ void EditSpellWrapper::SpellStart( SvxSpellArea eArea ) if ( !IsStartDone() ) { pSpellInfo->bSpellToEnd = true; - pSpellInfo->aSpellTo = pImpEE->CreateEPaM( - pEE->GetEditDoc().GetEndPaM() ); + pSpellInfo->aSpellTo = rImpEditEngine.CreateEPaM( + rEditEngine.GetEditDoc().GetEndPaM() ); } else { pSpellInfo->bSpellToEnd = false; pSpellInfo->aSpellTo = pSpellInfo->aSpellStart; pEditView->GetImpEditView()->SetEditSelection( - pEE->GetEditDoc().GetEndPaM() ); + rEditEngine.GetEditDoc().GetEndPaM() ); } } else if ( eArea == SvxSpellArea::Body ) @@ -103,24 +103,24 @@ void EditSpellWrapper::SpellStart( SvxSpellArea eArea ) void EditSpellWrapper::SpellContinue() { - SetLast( pEditView->GetImpEditEngine()->ImpSpell( pEditView ) ); + SetLast(pEditView->getImpEditEngine().ImpSpell(pEditView)); } bool EditSpellWrapper::SpellMore() { - EditEngine* pEE = pEditView->GetEditEngine(); - ImpEditEngine* pImpEE = pEditView->GetImpEditEngine(); - SpellInfo* pSpellInfo = pImpEE->GetSpellInfo(); + EditEngine& rEditEngine = pEditView->getEditEngine(); + ImpEditEngine& rImpEditEngine = pEditView->getImpEditEngine(); + SpellInfo* pSpellInfo = rImpEditEngine.GetSpellInfo(); bool bMore = false; if ( pSpellInfo->bMultipleDoc ) { - bMore = pEE->SpellNextDocument(); + bMore = rEditEngine.SpellNextDocument(); if ( bMore ) { // The text has been entered into the engine, when backwards then // it must be behind the selection. pEditView->GetImpEditView()->SetEditSelection( - pEE->GetEditDoc().GetStartPaM() ); + rEditEngine.GetEditDoc().GetStartPaM() ); } } return bMore; @@ -135,10 +135,10 @@ void EditSpellWrapper::ReplaceAll( const OUString &rNewText ) void EditSpellWrapper::CheckSpellTo() { - ImpEditEngine* pImpEE = pEditView->GetImpEditEngine(); - SpellInfo* pSpellInfo = pImpEE->GetSpellInfo(); + ImpEditEngine& rImpEditEngine = pEditView->getImpEditEngine(); + SpellInfo* pSpellInfo = rImpEditEngine.GetSpellInfo(); EditPaM aPaM( pEditView->GetImpEditView()->GetEditSelection().Max() ); - EPaM aEPaM = pImpEE->CreateEPaM( aPaM ); + EPaM aEPaM = rImpEditEngine.CreateEPaM( aPaM ); if ( aEPaM.nPara == pSpellInfo->aSpellTo.nPara ) { // Check if SpellToEnd still has a valid Index, if replace has been diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 598a4c68d1b3..1808b6678cdd 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -178,11 +178,11 @@ Point LOKSpecialPositioning::GetRefPoint() const // class ImpEditView -ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindow ) : +ImpEditView::ImpEditView( EditView* pView, EditEngine* pEditEngine, vcl::Window* pWindow ) : pEditView(pView), mpViewShell(nullptr), mpOtherShell(nullptr), - pEditEngine(pEng), + mpEditEngine(pEditEngine), pOutWin(pWindow), nInvMore(1), nControl(EVControlBits::AUTOSCROLL | EVControlBits::ENABLEPASTE), @@ -193,7 +193,7 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo bReadOnly(false), bClickedInSelection(false), bActiveDragAndDropListener(false), - aOutArea( Point(), pEng->GetPaperSize() ), + aOutArea( Point(), mpEditEngine->GetPaperSize() ), eSelectionMode(EESelectionMode::Std), eAnchorMode(EEAnchorMode::TopLeft), mpEditViewCallbacks(nullptr), @@ -201,8 +201,8 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo mbSuppressLOKMessages(false), mbNegativeX(false) { - aEditSelection.Min() = pEng->GetEditDoc().GetStartPaM(); - aEditSelection.Max() = pEng->GetEditDoc().GetEndPaM(); + aEditSelection.Min() = mpEditEngine->GetEditDoc().GetStartPaM(); + aEditSelection.Max() = mpEditEngine->GetEditDoc().GetEndPaM(); SelectionChanged(); } @@ -248,12 +248,14 @@ void ImpEditView::SetEditSelection( const EditSelection& rEditSelection ) SelectionChanged(); if (comphelper::LibreOfficeKit::isActive()) + { // Tiled rendering: selections are only painted when we are in selection mode. - pEditEngine->SetInSelectionMode(aEditSelection.HasRange()); + getEditEngine().SetInSelectionMode(aEditSelection.HasRange()); + } - if ( pEditEngine->pImpEditEngine->GetNotifyHdl().IsSet() ) + if (getImpEditEngine().GetNotifyHdl().IsSet() ) { - const EditDoc& rDoc = pEditEngine->GetEditDoc(); + const EditDoc& rDoc = getEditEngine().GetEditDoc(); const EditPaM pmEnd = rDoc.GetEndPaM(); EENotifyType eNotifyType; if (rDoc.Count() > 1 && @@ -267,12 +269,13 @@ void ImpEditView::SetEditSelection( const EditSelection& rEditSelection ) eNotifyType = EE_NOTIFY_TEXTVIEWSELECTIONCHANGED; } EENotify aNotify( eNotifyType ); - pEditEngine->pImpEditEngine->GetNotifyHdl().Call( aNotify ); + getImpEditEngine().GetNotifyHdl().Call( aNotify ); } - if(pEditEngine->pImpEditEngine->IsFormatted()) + + if (getImpEditEngine().IsFormatted()) { EENotify aNotify(EE_NOTIFY_PROCESSNOTIFICATIONS); - pEditEngine->pImpEditEngine->GetNotifyHdl().Call(aNotify); + getImpEditEngine().GetNotifyHdl().Call(aNotify); } } @@ -489,9 +492,9 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, if ( !pRegion && !comphelper::LibreOfficeKit::isActive()) { - if ( !pEditEngine->pImpEditEngine->IsUpdateLayout() ) + if (!getImpEditEngine().IsUpdateLayout()) return; - if ( pEditEngine->pImpEditEngine->IsInUndo() ) + if (getImpEditEngine().IsInUndo()) return; if ( !aTmpSel.HasRange() ) @@ -500,8 +503,8 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, // aTmpOutArea: if OutputArea > Paper width and // Text > Paper width ( over large fields ) tools::Rectangle aTmpOutArea( aOutArea ); - if ( aTmpOutArea.GetWidth() > pEditEngine->pImpEditEngine->GetPaperSize().Width() ) - aTmpOutArea.SetRight( aTmpOutArea.Left() + pEditEngine->pImpEditEngine->GetPaperSize().Width() ); + if ( aTmpOutArea.GetWidth() > getImpEditEngine().GetPaperSize().Width() ) + aTmpOutArea.SetRight( aTmpOutArea.Left() + getImpEditEngine().GetPaperSize().Width() ); rTarget.IntersectClipRegion( aTmpOutArea ); if (pOutWin && pOutWin->GetCursor()) @@ -511,20 +514,20 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, if (comphelper::LibreOfficeKit::isActive() || pRegion) pPolyPoly = tools::PolyPolygon(); - DBG_ASSERT( !pEditEngine->IsIdleFormatterActive(), "DrawSelectionXOR: Not formatted!" ); - aTmpSel.Adjust( pEditEngine->GetEditDoc() ); + DBG_ASSERT(!getEditEngine().IsIdleFormatterActive(), "DrawSelectionXOR: Not formatted!"); + aTmpSel.Adjust(getEditEngine().GetEditDoc()); ContentNode* pStartNode = aTmpSel.Min().GetNode(); ContentNode* pEndNode = aTmpSel.Max().GetNode(); - const sal_Int32 nStartPara = pEditEngine->GetEditDoc().GetPos(pStartNode); - const sal_Int32 nEndPara = pEditEngine->GetEditDoc().GetPos(pEndNode); + const sal_Int32 nStartPara = getEditEngine().GetEditDoc().GetPos(pStartNode); + const sal_Int32 nEndPara = getEditEngine().GetEditDoc().GetPos(pEndNode); if (nStartPara == EE_PARA_NOT_FOUND || nEndPara == EE_PARA_NOT_FOUND) return; bool bStartHandleVisible = false; bool bEndHandleVisible = false; bool bLOKCalcRTL = mpLOKSpecialPositioning && - (mpLOKSpecialPositioning->IsLayoutRTL() || pEditEngine->IsRightToLeft(nStartPara)); + (mpLOKSpecialPositioning->IsLayoutRTL() || getEditEngine().IsRightToLeft(nStartPara)); auto DrawHighlight = [&, nStartLine = sal_Int32(0), nEndLine = sal_Int32(0)]( const ImpEditEngine::LineAreaInfo& rInfo) mutable { @@ -575,9 +578,9 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, if (nEndIndex < nStartIndex) nEndIndex = nStartIndex; - tools::Rectangle aTmpRect(pEditEngine->pImpEditEngine->GetEditCursor( + tools::Rectangle aTmpRect(getImpEditEngine().GetEditCursor( rInfo.rPortion, *rInfo.pLine, nStartIndex, GetCursorFlags::NONE)); - const Size aLineOffset = pEditEngine->pImpEditEngine->getTopLeftDocOffset(rInfo.aArea); + const Size aLineOffset = getImpEditEngine().getTopLeftDocOffset(rInfo.aArea); aTmpRect.Move(0, aLineOffset.Height()); // Only paint if in the visible range ... @@ -595,7 +598,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, // Now that we have Bidi, the first/last index doesn't have to be the 'most outside' position if (!bPartOfLine) { - Range aLineXPosStartEnd = pEditEngine->GetLineXPosStartEnd(rInfo.rPortion, *rInfo.pLine); + Range aLineXPosStartEnd = getEditEngine().GetLineXPosStartEnd(rInfo.rPortion, *rInfo.pLine); aTmpRect.SetLeft(aLineXPosStartEnd.Min()); aTmpRect.SetRight(aLineXPosStartEnd.Max()); aTmpRect.Move(aLineOffset.Width(), 0); @@ -609,15 +612,15 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, while (nTmpStartIndex < nEndIndex) { - pEditEngine->pImpEditEngine->GetRightToLeft(rInfo.nPortion, nTmpStartIndex + 1, + getImpEditEngine().GetRightToLeft(rInfo.nPortion, nTmpStartIndex + 1, &nWritingDirStart, &nTmpEndIndex); if (nTmpEndIndex > nEndIndex) nTmpEndIndex = nEndIndex; DBG_ASSERT(nTmpEndIndex > nTmpStartIndex, "DrawSelectionXOR, Start >= End?"); - tools::Long nX1 = pEditEngine->GetXPos(rInfo.rPortion, *rInfo.pLine, nTmpStartIndex, true); - tools::Long nX2 = pEditEngine->GetXPos(rInfo.rPortion, *rInfo.pLine, nTmpEndIndex); + tools::Long nX1 = getEditEngine().GetXPos(rInfo.rPortion, *rInfo.pLine, nTmpStartIndex, true); + tools::Long nX2 = getEditEngine().GetXPos(rInfo.rPortion, *rInfo.pLine, nTmpEndIndex); aTmpRect.SetLeft(std::min(nX1, nX2)); aTmpRect.SetRight(std::max(nX1, nX2)); @@ -631,7 +634,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion, } return ImpEditEngine::CallbackResult::Continue; }; - pEditEngine->pImpEditEngine->IterateLineAreas(DrawHighlight, ImpEditEngine::IterFlag::none); + getImpEditEngine().IterateLineAreas(DrawHighlight, ImpEditEngine::IterFlag::none); if (comphelper::LibreOfficeKit::isActive() && mpViewShell && pOutWin) lokSelectionCallback(pPolyPoly, bStartHandleVisible, bEndHandleVisible); @@ -742,12 +745,12 @@ void ImpEditView::ImplDrawHighlightRect( OutputDevice& rTarget, const Point& rDo bool ImpEditView::IsVertical() const { - return pEditEngine->pImpEditEngine->IsEffectivelyVertical(); + return getImpEditEngine().IsEffectivelyVertical(); } bool ImpEditView::IsTopToBottom() const { - return pEditEngine->pImpEditEngine->IsTopToBottom(); + return getImpEditEngine().IsTopToBottom(); } tools::Rectangle ImpEditView::GetVisDocArea() const @@ -760,14 +763,14 @@ Point ImpEditView::GetDocPos( const Point& rWindowPos ) const // Window Position => Position Document Point aPoint; - if ( !pEditEngine->pImpEditEngine->IsEffectivelyVertical() ) + if (!getImpEditEngine().IsEffectivelyVertical()) { aPoint.setX( rWindowPos.X() - aOutArea.Left() + GetVisDocLeft() ); aPoint.setY( rWindowPos.Y() - aOutArea.Top() + GetVisDocTop() ); } else { - if (pEditEngine->pImpEditEngine->IsTopToBottom()) + if (getImpEditEngine().IsTopToBottom()) { aPoint.setX( rWindowPos.Y() - aOutArea.Top() + GetVisDocLeft() ); aPoint.setY( aOutArea.Right() - rWindowPos.X() + GetVisDocTop() ); @@ -787,14 +790,14 @@ Point ImpEditView::GetWindowPos( const Point& rDocPos ) const // Document position => window position Point aPoint; - if ( !pEditEngine->pImpEditEngine->IsEffectivelyVertical() ) + if (!getImpEditEngine().IsEffectivelyVertical()) { aPoint.setX( rDocPos.X() + aOutArea.Left() - GetVisDocLeft() ); aPoint.setY( rDocPos.Y() + aOutArea.Top() - GetVisDocTop() ); } else { - if (pEditEngine->pImpEditEngine->IsTopToBottom()) + if (getImpEditEngine().IsTopToBottom()) { aPoint.setX( aOutArea.Right() - rDocPos.Y() + GetVisDocTop() ); aPoint.setY( rDocPos.X() + aOutArea.Top() - GetVisDocLeft() ); @@ -815,7 +818,7 @@ tools::Rectangle ImpEditView::GetWindowPos( const tools::Rectangle& rDocRect ) c Point aPos( GetWindowPos( rDocRect.TopLeft() ) ); Size aSz = rDocRect.GetSize(); tools::Rectangle aRect; - if ( !pEditEngine->pImpEditEngine->IsEffectivelyVertical() ) + if (!getImpEditEngine().IsEffectivelyVertical()) { aRect = tools::Rectangle( aPos, aSz ); } @@ -906,7 +909,7 @@ void ImpEditView::ResetOutputArea( const tools::Rectangle& rRect ) SetOutputArea(rRect); // invalidate surrounding areas if update is true - if(aOldArea.IsEmpty() || !pEditEngine->pImpEditEngine->IsUpdateLayout()) + if(aOldArea.IsEmpty() || !getImpEditEngine().IsUpdateLayout()) return; // #i119885# use grown area if needed; do when getting bigger OR smaller @@ -965,8 +968,8 @@ void ImpEditView::RecalcOutputArea() // X: if ( DoAutoWidth() ) { - if ( pEditEngine->pImpEditEngine->GetStatus().AutoPageWidth() ) - aNewSz.setWidth( pEditEngine->pImpEditEngine->GetPaperSize().Width() ); + if (getImpEditEngine().GetStatus().AutoPageWidth()) + aNewSz.setWidth(getImpEditEngine().GetPaperSize().Width()); switch ( eAnchorMode ) { case EEAnchorMode::TopLeft: @@ -996,8 +999,8 @@ void ImpEditView::RecalcOutputArea() // Y: if ( DoAutoHeight() ) { - if ( pEditEngine->pImpEditEngine->GetStatus().AutoPageHeight() ) - aNewSz.setHeight( pEditEngine->pImpEditEngine->GetPaperSize().Height() ); + if (getImpEditEngine().GetStatus().AutoPageHeight()) + aNewSz.setHeight(getImpEditEngine().GetPaperSize().Height()); switch ( eAnchorMode ) { case EEAnchorMode::TopLeft: @@ -1105,13 +1108,13 @@ boost::property_tree::ptree getHyperlinkPropTree(const OUString& sText, const OU tools::Rectangle ImpEditView::ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags nShowCursorFlags, sal_Int32& nTextPortionStart, ParaPortion const& rParaPortion) const { - tools::Rectangle aEditCursor = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, nShowCursorFlags ); + tools::Rectangle aEditCursor = getImpEditEngine().PaMtoEditCursor( aPaM, nShowCursorFlags ); if ( !IsInsertMode() && !aEditSelection.HasRange() ) { if ( aPaM.GetNode()->Len() && ( aPaM.GetIndex() < aPaM.GetNode()->Len() ) ) { // If we are behind a portion, and the next portion has other direction, we must change position... - aEditCursor.SetLeft( pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly|GetCursorFlags::PreferPortionStart ).Left() ); + aEditCursor.SetLeft(getImpEditEngine().PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly|GetCursorFlags::PreferPortionStart ).Left() ); aEditCursor.SetRight( aEditCursor.Left() ); sal_Int32 nTextPortion = rParaPortion.GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true ); @@ -1122,10 +1125,10 @@ tools::Rectangle ImpEditView::ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags nS } else { - EditPaM aNext = pEditEngine->CursorRight( aPaM ); - tools::Rectangle aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GetCursorFlags::TextOnly ); + EditPaM aNext = getEditEngine().CursorRight( aPaM ); + tools::Rectangle aTmpRect = getImpEditEngine().PaMtoEditCursor( aNext, GetCursorFlags::TextOnly ); if ( aTmpRect.Top() != aEditCursor.Top() ) - aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GetCursorFlags::TextOnly|GetCursorFlags::EndOfLine ); + aTmpRect = getImpEditEngine().PaMtoEditCursor( aNext, GetCursorFlags::TextOnly|GetCursorFlags::EndOfLine ); aEditCursor.SetRight( aTmpRect.Left() ); } } @@ -1145,11 +1148,11 @@ tools::Rectangle ImpEditView::GetEditCursor() const EditPaM aPaM( aEditSelection.Max() ); sal_Int32 nTextPortionStart = 0; - sal_Int32 nPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() ); + sal_Int32 nPara = getEditEngine().GetEditDoc().GetPos( aPaM.GetNode() ); if (nPara == EE_PARA_NOT_FOUND) // #i94322 return tools::Rectangle(); - ParaPortion const& rParaPortion = pEditEngine->GetParaPortions().getRef(nPara); + ParaPortion const& rParaPortion = getEditEngine().GetParaPortions().getRef(nPara); GetCursorFlags nShowCursorFlags = nExtraCursorFlags | GetCursorFlags::TextOnly; @@ -1173,17 +1176,17 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) if ( ( aOutArea.Left() >= aOutArea.Right() ) && ( aOutArea.Top() >= aOutArea.Bottom() ) ) return; - pEditEngine->CheckIdleFormatter(); - if (!pEditEngine->IsFormatted()) - pEditEngine->pImpEditEngine->FormatDoc(); + getEditEngine().CheckIdleFormatter(); + if (!getEditEngine().IsFormatted()) + getImpEditEngine().FormatDoc(); // For some reasons I end up here during the formatting, if the Outliner // is initialized in Paint, because no SetPool(); - if ( pEditEngine->pImpEditEngine->IsFormatting() ) + if (getImpEditEngine().IsFormatting()) return; - if ( !pEditEngine->pImpEditEngine->IsUpdateLayout() ) + if (!getImpEditEngine().IsUpdateLayout()) return; - if ( pEditEngine->pImpEditEngine->IsInUndo() ) + if (getImpEditEngine().IsInUndo()) return; if (pOutWin && pOutWin->GetCursor() != GetCursor()) @@ -1192,11 +1195,11 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) EditPaM aPaM( aEditSelection.Max() ); sal_Int32 nTextPortionStart = 0; - sal_Int32 nPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() ); + sal_Int32 nPara = getEditEngine().GetEditDoc().GetPos( aPaM.GetNode() ); if (nPara == EE_PARA_NOT_FOUND) // #i94322 return; - ParaPortion const& rParaPortion = pEditEngine->GetParaPortions().getRef(nPara); + ParaPortion const& rParaPortion = getEditEngine().GetParaPortions().getRef(nPara); GetCursorFlags nShowCursorFlags = nExtraCursorFlags | GetCursorFlags::TextOnly; @@ -1211,7 +1214,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) tools::Rectangle aEditCursor = ImplGetEditCursor(aPaM, nShowCursorFlags, nTextPortionStart, rParaPortion); - if ( bGotoCursor ) // && (!pEditEngine->pImpEditEngine->GetStatus().AutoPageSize() ) ) + if ( bGotoCursor ) // && (!getImpEditEngine().GetStatus().AutoPageSize() ) ) { // check if scrolling is necessary... // if scrolling, then update () and Scroll ()! @@ -1221,7 +1224,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) tools::Rectangle aTmpVisArea( GetVisDocArea() ); // aTmpOutArea: if OutputArea > Paper width and // Text > Paper width ( over large fields ) - tools::Long nMaxTextWidth = !IsVertical() ? pEditEngine->pImpEditEngine->GetPaperSize().Width() : pEditEngine->pImpEditEngine->GetPaperSize().Height(); + tools::Long nMaxTextWidth = !IsVertical() ? getImpEditEngine().GetPaperSize().Width() : getImpEditEngine().GetPaperSize().Height(); if ( aTmpVisArea.GetWidth() > nMaxTextWidth ) aTmpVisArea.SetRight( aTmpVisArea.Left() + nMaxTextWidth ); @@ -1275,11 +1278,11 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) tools::Long nDiffY = !IsVertical() ? nDocDiffY : (IsTopToBottom() ? nDocDiffX : -nDocDiffX); if ( nDiffX ) - pEditEngine->GetInternalEditStatus().GetStatusWord() = pEditEngine->GetInternalEditStatus().GetStatusWord() | EditStatusFlags::HSCROLL; + getEditEngine().GetInternalEditStatus().GetStatusWord() = getEditEngine().GetInternalEditStatus().GetStatusWord() | EditStatusFlags::HSCROLL; if ( nDiffY ) - pEditEngine->GetInternalEditStatus().GetStatusWord() = pEditEngine->GetInternalEditStatus().GetStatusWord() | EditStatusFlags::VSCROLL; + getEditEngine().GetInternalEditStatus().GetStatusWord() = getEditEngine().GetInternalEditStatus().GetStatusWord() | EditStatusFlags::VSCROLL; Scroll( -nDiffX, -nDiffY ); - pEditEngine->pImpEditEngine->DelayedCallStatusHdl(); + getImpEditEngine().DelayedCallStatusHdl(); } } @@ -1351,7 +1354,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) Point aRefPointLogical = GetOutputArea().TopLeft(); // Get the relative coordinates w.r.t refpoint in display hmm. aCursorRectPureLogical.Move(-aRefPointLogical.X(), -aRefPointLogical.Y()); - if (pEditEngine->IsRightToLeft(nPara) || mpLOKSpecialPositioning->IsLayoutRTL()) + if (getEditEngine().IsRightToLeft(nPara) || mpLOKSpecialPositioning->IsLayoutRTL()) { tools::Long nMirrorW = GetOutputArea().GetWidth(); tools::Long nLeft = aCursorRectPureLogical.Left(), nRight = aCursorRectPureLogical.Right(); @@ -1410,7 +1413,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) else { // is cursor at a misspelled word ? - uno::Reference<linguistic2::XSpellChecker1> xSpeller( pEditEngine->pImpEditEngine->GetSpeller() ); + uno::Reference<linguistic2::XSpellChecker1> xSpeller(getImpEditEngine().GetSpeller()); bool bIsWrong = xSpeller.is() && IsWrongSpelledWord(aPaM, /*bMarkIfWrong*/ false); EditView* pActiveView = GetEditViewPtr(); @@ -1454,7 +1457,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) } CursorDirection nCursorDir = CursorDirection::NONE; - if ( IsInsertMode() && !aEditSelection.HasRange() && ( pEditEngine->pImpEditEngine->HasDifferentRTLLevels( aPaM.GetNode() ) ) ) + if ( IsInsertMode() && !aEditSelection.HasRange() && (getImpEditEngine().HasDifferentRTLLevels(aPaM.GetNode()) ) ) { sal_uInt16 nTextPortion = rParaPortion.GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, bool(nShowCursorFlags & GetCursorFlags::PreferPortionStart) ); const TextPortion& rTextPortion = rParaPortion.GetTextPortions()[nTextPortion]; @@ -1470,7 +1473,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) GetCursor()->Show(); { SvxFont aFont; - pEditEngine->SeekCursor( aPaM.GetNode(), aPaM.GetIndex()+1, aFont ); + getEditEngine().SeekCursor( aPaM.GetNode(), aPaM.GetIndex()+1, aFont ); InputContext aInputContext(std::move(aFont), InputContextFlags::Text | InputContextFlags::ExtText); if (EditViewCallbacks* pCallbacks = getEditViewCallbacks()) @@ -1481,7 +1484,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) } else { - pEditEngine->pImpEditEngine->GetStatus().GetStatusWord() = pEditEngine->pImpEditEngine->GetStatus().GetStatusWord() | EditStatusFlags::CURSOROUT; + getImpEditEngine().GetStatus().GetStatusWord() = getImpEditEngine().GetStatus().GetStatusWord() | EditStatusFlags::CURSOROUT; GetCursor()->Hide(); GetCursor()->SetPos( Point( -1, -1 ) ); GetCursor()->SetSize( Size( 0, 0 ) ); @@ -1499,7 +1502,7 @@ void ImpEditView::ScrollStateChange() Pair ImpEditView::Scroll( tools::Long ndX, tools::Long ndY, ScrollRangeCheck nRangeCheck ) { - DBG_ASSERT( pEditEngine->pImpEditEngine->IsFormatted(), "Scroll: Not formatted!" ); + DBG_ASSERT(getImpEditEngine().IsFormatted(), "Scroll: Not formatted!"); if ( !ndX && !ndY ) return Pair( 0, 0 ); @@ -1533,10 +1536,10 @@ Pair ImpEditView::Scroll( tools::Long ndX, tools::Long ndY, ScrollRangeCheck nRa aNewVisArea.AdjustBottom( -ndX ); } } - if ( ( nRangeCheck == ScrollRangeCheck::PaperWidthTextSize ) && ( aNewVisArea.Bottom() > static_cast<tools::Long>(pEditEngine->pImpEditEngine->GetTextHeight()) ) ) + if ( ( nRangeCheck == ScrollRangeCheck::PaperWidthTextSize ) && ( aNewVisArea.Bottom() > static_cast<tools::Long>(getImpEditEngine().GetTextHeight()) ) ) { // GetTextHeight still optimizing! - tools::Long nDiff = pEditEngine->pImpEditEngine->GetTextHeight() - aNewVisArea.Bottom(); // negative + tools::Long nDiff = getImpEditEngine().GetTextHeight() - aNewVisArea.Bottom(); // negative aNewVisArea.Move( 0, nDiff ); // could end up in the negative area... } if ( aNewVisArea.Top() < 0 ) @@ -1561,9 +1564,9 @@ Pair ImpEditView::Scroll( tools::Long ndX, tools::Long ndY, ScrollRangeCheck nRa aNewVisArea.AdjustRight(ndY ); } } - if ( ( nRangeCheck == ScrollRangeCheck::PaperWidthTextSize ) && ( aNewVisArea.Right() > static_cast<tools::Long>(pEditEngine->pImpEditEngine->CalcTextWidth( false )) ) ) + if ( ( nRangeCheck == ScrollRangeCheck::PaperWidthTextSize ) && ( aNewVisArea.Right() > static_cast<tools::Long>(getImpEditEngine().CalcTextWidth( false )) ) ) { - tools::Long nDiff = pEditEngine->pImpEditEngine->CalcTextWidth( false ) - aNewVisArea.Right(); // negative + tools::Long nDiff = getImpEditEngine().CalcTextWidth( false ) - aNewVisArea.Right(); // negative aNewVisArea.Move( nDiff, 0 ); // could end up in the negative area... } if ( aNewVisArea.Left() < 0 ) @@ -1624,10 +1627,10 @@ Pair ImpEditView::Scroll( tools::Long ndX, tools::Long ndY, ScrollRangeCheck nRa pCrsr->Show(); } - if ( pEditEngine->pImpEditEngine->GetNotifyHdl().IsSet() ) + if (getImpEditEngine().GetNotifyHdl().IsSet()) { EENotify aNotify( EE_NOTIFY_TEXTVIEWSCROLLED ); - pEditEngine->pImpEditEngine->GetNotifyHdl().Call( aNotify ); + getImpEditEngine().GetNotifyHdl().Call( aNotify ); } if (EditViewCallbacks* pCallbacks = getEditViewCallbacks()) @@ -1682,10 +1685,10 @@ bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * p { if ( !bReadOnly && IsPasteEnabled() ) { - pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_PASTE ); + getImpEditEngine().UndoActionStart( EDITUNDO_PASTE ); uno::Reference<datatransfer::clipboard::XClipboard> aClipBoard(GetClipboard()); - Paste( aClipBoard, pEditEngine->pImpEditEngine->GetStatus().AllowPasteSpecial() ); - pEditEngine->pImpEditEngine->UndoActionEnd(); + Paste( aClipBoard, getImpEditEngine().GetStatus().AllowPasteSpecial() ); + getImpEditEngine().UndoActionEnd(); bDone = true; } } @@ -1696,7 +1699,7 @@ bool ImpEditView::PostKeyEvent( const KeyEvent& rKeyEvent, vcl::Window const * p } if( !bDone ) - bDone = pEditEngine->PostKeyEvent( rKeyEvent, GetEditViewPtr(), pFrameWin ); + bDone = getEditEngine().PostKeyEvent( rKeyEvent, GetEditViewPtr(), pFrameWin ); return bDone; } @@ -1720,36 +1723,36 @@ bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent ) CutCopy( aClipBoard, false ); } - return pEditEngine->pImpEditEngine->MouseButtonUp( rMouseEvent, GetEditViewPtr() ); + return getImpEditEngine().MouseButtonUp( rMouseEvent, GetEditViewPtr() ); } void ImpEditView::ReleaseMouse() { - pEditEngine->pImpEditEngine->ReleaseMouse(); + getImpEditEngine().ReleaseMouse(); } bool ImpEditView::MouseButtonDown( const MouseEvent& rMouseEvent ) { - pEditEngine->CheckIdleFormatter(); // If fast typing and mouse button downs + getEditEngine().CheckIdleFormatter(); // If fast typing and mouse button downs nTravelXPos = TRAVEL_X_DONTKNOW; nExtraCursorFlags = GetCursorFlags::NONE; nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW; - bool bPrevUpdateLayout = pEditEngine->pImpEditEngine->SetUpdateLayout(true); + bool bPrevUpdateLayout = getImpEditEngine().SetUpdateLayout(true); bClickedInSelection = IsSelectionAtPoint( rMouseEvent.GetPosPixel() ); - bool bRet = pEditEngine->pImpEditEngine->MouseButtonDown( rMouseEvent, GetEditViewPtr() ); - pEditEngine->pImpEditEngine->SetUpdateLayout(bPrevUpdateLayout); + bool bRet = getImpEditEngine().MouseButtonDown( rMouseEvent, GetEditViewPtr() ); + getImpEditEngine().SetUpdateLayout(bPrevUpdateLayout); return bRet; } bool ImpEditView::MouseMove( const MouseEvent& rMouseEvent ) { - return pEditEngine->pImpEditEngine->MouseMove( rMouseEvent, GetEditViewPtr() ); + return getImpEditEngine().MouseMove( rMouseEvent, GetEditViewPtr() ); } bool ImpEditView::Command(const CommandEvent& rCEvt) { - pEditEngine->CheckIdleFormatter(); // If fast typing and mouse button down - return pEditEngine->pImpEditEngine->Command(rCEvt, GetEditViewPtr()); + getEditEngine().CheckIdleFormatter(); // If fast typing and mouse button down + return getImpEditEngine().Command(rCEvt, GetEditViewPtr()); } @@ -1767,7 +1770,7 @@ bool ImpEditView::IsWrongSpelledWord( const EditPaM& rPaM, bool bMarkIfWrong ) bool bIsWrong = false; if ( rPaM.GetNode()->GetWrongList() ) { - EditSelection aSel = pEditEngine->SelectWord( rPaM, css::i18n::WordType::DICTIONARY_WORD ); + EditSelection aSel = getEditEngine().SelectWord( rPaM, css::i18n::WordType::DICTIONARY_WORD ); bIsWrong = rPaM.GetNode()->GetWrongList()->HasWrong( aSel.Min().GetIndex(), aSel.Max().GetIndex() ); if ( bIsWrong && bMarkIfWrong ) { @@ -1782,17 +1785,17 @@ bool ImpEditView::IsWrongSpelledWord( const EditPaM& rPaM, bool bMarkIfWrong ) OUString ImpEditView::SpellIgnoreWord() { OUString aWord; - if ( pEditEngine->pImpEditEngine->GetSpeller().is() ) + if (getImpEditEngine().GetSpeller().is()) { EditPaM aPaM = GetEditSelection().Max(); if ( !HasSelection() ) { - EditSelection aSel = pEditEngine->SelectWord(aPaM); - aWord = pEditEngine->pImpEditEngine->GetSelected( aSel ); + EditSelection aSel = getEditEngine().SelectWord(aPaM); + aWord = getImpEditEngine().GetSelected( aSel ); } else { - aWord = pEditEngine->pImpEditEngine->GetSelected( GetEditSelection() ); + aWord = getImpEditEngine().GetSelected( GetEditSelection() ); // And deselect DrawSelectionXOR(); SetEditSelection( EditSelection( aPaM, aPaM ) ); @@ -1804,15 +1807,15 @@ OUString ImpEditView::SpellIgnoreWord() uno::Reference<linguistic2::XDictionary> xDic = LinguMgr::GetIgnoreAllList(); if (xDic.is()) xDic->add( aWord, false, OUString() ); - EditDoc& rDoc = pEditEngine->GetEditDoc(); + EditDoc& rDoc = getEditEngine().GetEditDoc(); sal_Int32 nNodes = rDoc.Count(); for ( sal_Int32 n = 0; n < nNodes; n++ ) { ContentNode* pNode = rDoc.GetObject( n ); pNode->GetWrongList()->MarkWrongsInvalid(); } - pEditEngine->pImpEditEngine->DoOnlineSpelling( aPaM.GetNode() ); - pEditEngine->pImpEditEngine->StartOnlineSpellTimer(); + getImpEditEngine().DoOnlineSpelling( aPaM.GetNode() ); + getImpEditEngine().StartOnlineSpellTimer(); } } return aWord; @@ -1822,17 +1825,17 @@ void ImpEditView::DeleteSelected() { DrawSelectionXOR(); - pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_DELETE ); + getImpEditEngine().UndoActionStart( EDITUNDO_DELETE ); - EditPaM aPaM = pEditEngine->pImpEditEngine->DeleteSelected( GetEditSelection() ); + EditPaM aPaM = getImpEditEngine().DeleteSelected( GetEditSelection() ); - pEditEngine->pImpEditEngine->UndoActionEnd(); + getImpEditEngine().UndoActionEnd(); SetEditSelection( EditSelection( aPaM, aPaM ) ); DrawSelectionXOR(); - pEditEngine->pImpEditEngine->FormatAndLayout( GetEditViewPtr() ); + getImpEditEngine().FormatAndLayout( GetEditViewPtr() ); ShowCursor( DoAutoScroll(), true ); } @@ -1842,7 +1845,7 @@ const SvxFieldItem* ImpEditView::GetField( const Point& rPos, sal_Int32* pPara, return nullptr; Point aDocPos( GetDocPos( rPos ) ); - EditPaM aPaM = pEditEngine->GetPaM(aDocPos, false); + EditPaM aPaM = getEditEngine().GetPaM(aDocPos, false); if (!aPaM) return nullptr; @@ -1863,7 +1866,7 @@ const SvxFieldItem* ImpEditView::GetField( const Point& rPos, sal_Int32* pPara, { DBG_ASSERT(dynamic_cast<const SvxFieldItem*>(rAttr.GetItem()), "No FieldItem..."); if ( pPara ) - *pPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() ); + *pPara = getEditEngine().GetEditDoc().GetPos( aPaM.GetNode() ); if ( pPos ) *pPos = rAttr.GetStart(); return static_cast<const SvxFieldItem*>(rAttr.GetItem()); @@ -1882,16 +1885,16 @@ bool ImpEditView::IsBulletArea( const Point& rPos, sal_Int32* pPara ) return false; Point aDocPos( GetDocPos( rPos ) ); - EditPaM aPaM = pEditEngine->GetPaM(aDocPos, false); + EditPaM aPaM = getEditEngine().GetPaM(aDocPos, false); if (!aPaM) return false; if ( aPaM.GetIndex() == 0 ) { - sal_Int32 nPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() ); - tools::Rectangle aBulletArea = pEditEngine->GetBulletArea( nPara ); - tools::Long nY = pEditEngine->GetDocPosTopLeft( nPara ).Y(); - ParaPortion const& rParaPortion = pEditEngine->GetParaPortions().getRef(nPara); + sal_Int32 nPara = getEditEngine().GetEditDoc().GetPos( aPaM.GetNode() ); + tools::Rectangle aBulletArea = getEditEngine().GetBulletArea( nPara ); + tools::Long nY = getEditEngine().GetDocPosTopLeft( nPara ).Y(); + ParaPortion const& rParaPortion = getEditEngine().GetParaPortions().getRef(nPara); nY += rParaPortion.GetFirstLineOffset(); if ( ( aDocPos.Y() > ( nY + aBulletArea.Top() ) ) && ( aDocPos.Y() < ( nY + aBulletArea.Bottom() ) ) && @@ -1912,7 +1915,7 @@ void ImpEditView::CutCopy(uno::Reference<datatransfer::clipboard::XClipboard> co if ( !(rxClipboard.is() && HasSelection()) ) return; - uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable( GetEditSelection() ); + uno::Reference<datatransfer::XTransferable> xData = getEditEngine().CreateTransferable( GetEditSelection() ); { SolarMutexReleaser aReleaser; @@ -1934,9 +1937,9 @@ void ImpEditView::CutCopy(uno::Reference<datatransfer::clipboard::XClipboard> co if (bCut) { - pEditEngine->pImpEditEngine->UndoActionStart(EDITUNDO_CUT); + getImpEditEngine().UndoActionStart(EDITUNDO_CUT); DeleteSelected(); - pEditEngine->pImpEditEngine->UndoActionEnd(); + getImpEditEngine().UndoActionEnd(); } } @@ -1959,18 +1962,18 @@ void ImpEditView::Paste(uno::Reference<datatransfer::clipboard::XClipboard> cons if ( !xDataObj.is() || !EditEngine::HasValidData( xDataObj ) ) return; - pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_PASTE ); + getImpEditEngine().UndoActionStart( EDITUNDO_PASTE ); EditSelection aSel( GetEditSelection() ); if ( aSel.HasRange() ) { DrawSelectionXOR(); - aSel = pEditEngine->DeleteSelection(aSel); + aSel = getEditEngine().DeleteSelection(aSel); } PasteOrDropInfos aPasteOrDropInfos; - aPasteOrDropInfos.nStartPara = pEditEngine->GetEditDoc().GetPos( aSel.Min().GetNode() ); - pEditEngine->HandleBeginPasteOrDrop(aPasteOrDropInfos); + aPasteOrDropInfos.nStartPara = getEditEngine().GetEditDoc().GetPos( aSel.Min().GetNode() ); + getEditEngine().HandleBeginPasteOrDrop(aPasteOrDropInfos); if ( DoSingleLinePaste() ) { @@ -1985,7 +1988,7 @@ void ImpEditView::Paste(uno::Reference<datatransfer::clipboard::XClipboard> cons aData >>= aTmpText; OUString aText(convertLineEnd(aTmpText, LINEEND_LF)); aText = aText.replaceAll( OUStringChar(LINE_SEP), " " ); - aSel = pEditEngine->InsertText(aSel, aText); + aSel = getEditEngine().InsertText(aSel, aText); } catch( ... ) { @@ -1998,18 +2001,18 @@ void ImpEditView::Paste(uno::Reference<datatransfer::clipboard::XClipboard> cons // Prevent notifications of paragraph inserts et al that would trigger // a11y to format content in a half-ready state when obtaining // paragraphs. Collect and broadcast when done instead. - aSel = pEditEngine->InsertText( + aSel = getEditEngine().InsertText( xDataObj, OUString(), aSel.Min(), - bUseSpecial && pEditEngine->GetInternalEditStatus().AllowPasteSpecial(), format); + bUseSpecial && getEditEngine().GetInternalEditStatus().AllowPasteSpecial(), format); } - aPasteOrDropInfos.nEndPara = pEditEngine->GetEditDoc().GetPos( aSel.Max().GetNode() ); - pEditEngine->HandleEndPasteOrDrop(aPasteOrDropInfos); + aPasteOrDropInfos.nEndPara = getEditEngine().GetEditDoc().GetPos( aSel.Max().GetNode() ); + getEditEngine().HandleEndPasteOrDrop(aPasteOrDropInfos); - pEditEngine->pImpEditEngine->UndoActionEnd(); + getImpEditEngine().UndoActionEnd(); SetEditSelection( aSel ); - pEditEngine->pImpEditEngine->UpdateSelections(); - pEditEngine->pImpEditEngine->FormatAndLayout( GetEditViewPtr() ); + getImpEditEngine().UpdateSelections(); + getImpEditEngine().FormatAndLayout( GetEditViewPtr() ); ShowCursor( DoAutoScroll(), true ); } @@ -2020,11 +2023,11 @@ bool ImpEditView::IsInSelection( const EditPaM& rPaM ) if ( !aSel.HasRange() ) return false; - aSel.Adjust( pEditEngine->GetEditDoc() ); + aSel.Adjust(getEditEngine().GetEditDoc()); - sal_Int32 nStartNode = pEditEngine->GetEditDoc().GetPos( aSel.Min().GetNode() ); - sal_Int32 nEndNode = pEditEngine->GetEditDoc().GetPos( aSel.Max().GetNode() ); - sal_Int32 nCurNode = pEditEngine->GetEditDoc().GetPos( rPaM.GetNode() ); + sal_Int32 nStartNode = getEditEngine().GetEditDoc().GetPos( aSel.Min().GetNode() ); + sal_Int32 nEndNode = getEditEngine().GetEditDoc().GetPos( aSel.Max().GetNode() ); + sal_Int32 nCurNode = getEditEngine().GetEditDoc().GetPos( rPaM.GetNode() ); if ( ( nCurNode > nStartNode ) && ( nCurNode < nEndNode ) ) return true; @@ -2068,7 +2071,7 @@ bool ImpEditView::IsSelectionInSinglePara() const void ImpEditView::CreateAnchor() { - pEditEngine->SetInSelectionMode(true); + getEditEngine().SetInSelectionMode(true); EditSelection aNewSelection(GetEditSelection()); aNewSelection.Min() = aNewSelection.Max(); SetEditSelection(aNewSelection); @@ -2077,7 +2080,7 @@ void ImpEditView::CreateAnchor() void ImpEditView::DeselectAll() { - pEditEngine->SetInSelectionMode(false); + getEditEngine().SetInSelectionMode(false); DrawSelectionXOR(); EditSelection aNewSelection(GetEditSelection()); aNewSelection.Min() = aNewSelection.Max(); @@ -2106,19 +2109,19 @@ bool ImpEditView::IsSelectionAtPoint( const Point& rPosPixel ) const OutputDevice& rOutDev = GetOutputDevice(); Point aMousePos = rOutDev.PixelToLogic(rPosPixel); - if ( ( !GetOutputArea().Contains( aMousePos ) ) && !pEditEngine->pImpEditEngine->IsInSelectionMode() ) + if ( ( !GetOutputArea().Contains( aMousePos ) ) && !getImpEditEngine().IsInSelectionMode() ) { return false; } Point aDocPos( GetDocPos( aMousePos ) ); - EditPaM aPaM = pEditEngine->GetPaM(aDocPos, false); + EditPaM aPaM = getEditEngine().GetPaM(aDocPos, false); return IsInSelection( aPaM ); } bool ImpEditView::SetCursorAtPoint( const Point& rPointPixel ) { - pEditEngine->CheckIdleFormatter(); + getEditEngine().CheckIdleFormatter(); Point aMousePos( rPointPixel ); @@ -2126,7 +2129,7 @@ bool ImpEditView::SetCursorAtPoint( const Point& rPointPixel ) const OutputDevice& rOutDev = GetOutputDevice(); aMousePos = rOutDev.PixelToLogic( aMousePos ); - if ( ( !GetOutputArea().Contains( aMousePos ) ) && !pEditEngine->pImpEditEngine->IsInSelectionMode() ) + if ( ( !GetOutputArea().Contains( aMousePos ) ) && !getImpEditEngine().IsInSelectionMode() ) { return false; } @@ -2136,7 +2139,7 @@ bool ImpEditView::SetCursorAtPoint( const Point& rPointPixel ) // Can be optimized: first go through the lines within a paragraph for PAM, // then again with the PaM for the Rect, even though the line is already // known... This must not be, though! - EditPaM aPaM = pEditEngine->GetPaM(aDocPos); + EditPaM aPaM = getEditEngine().GetPaM(aDocPos); bool bGotoCursor = DoAutoScroll(); // aTmpNewSel: Diff between old and new, not the new selection, unless for tiled rendering @@ -2147,7 +2150,7 @@ bool ImpEditView::SetCursorAtPoint( const Point& rPointPixel ) EditSelection aNewEditSelection( GetEditSelection() ); aNewEditSelection.Max() = aPaM; - if (!pEditEngine->GetSelectionEngine().HasAnchor()) + if (!getEditEngine().GetSelectionEngine().HasAnchor()) { if ( aNewEditSelection.Min() != aPaM ) { @@ -2168,7 +2171,7 @@ bool ImpEditView::SetCursorAtPoint( const Point& rPointPixel ) SetEditSelection( aNewEditSelection ); } - bool bForceCursor = pDragAndDropInfo == nullptr && !pEditEngine->pImpEditEngine->IsInSelectionMode(); + bool bForceCursor = pDragAndDropInfo == nullptr && !getImpEditEngine().IsInSelectionMode(); ShowCursor( bGotoCursor, bForceCursor ); return true; } @@ -2245,7 +2248,7 @@ void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestur Point aMousePosPixel( rDGE.DragOriginX, rDGE.DragOriginY ); EditSelection aCopySel( GetEditSelection() ); - aCopySel.Adjust( pEditEngine->GetEditDoc() ); + aCopySel.Adjust(getEditEngine().GetEditDoc()); if ( HasSelection() && bClickedInSelection ) { @@ -2262,7 +2265,7 @@ void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestur { pDragAndDropInfo.reset(new DragAndDropInfo()); pDragAndDropInfo->pField = pField; - ContentNode* pNode = pEditEngine->GetEditDoc().GetObject( nPara ); + ContentNode* pNode = getEditEngine().GetEditDoc().GetObject( nPara ); aCopySel = EditSelection( EditPaM( pNode, nPos ), EditPaM( pNode, nPos+1 ) ); SetEditSelection(aCopySel); DrawSelectionXOR(); @@ -2273,15 +2276,15 @@ void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestur { pDragAndDropInfo.reset(new DragAndDropInfo()); pDragAndDropInfo->bOutlinerMode = true; - EditPaM aStartPaM( pEditEngine->GetEditDoc().GetObject( nPara ), 0 ); + EditPaM aStartPaM(getEditEngine().GetEditDoc().GetObject(nPara), 0); EditPaM aEndPaM( aStartPaM ); - const SfxInt16Item& rLevel = pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL ); - for ( sal_Int32 n = nPara +1; n < pEditEngine->GetEditDoc().Count(); n++ ) + const SfxInt16Item& rLevel = getEditEngine().GetParaAttrib(nPara, EE_PARA_OUTLLEVEL); + for ( sal_Int32 n = nPara +1; n < getEditEngine().GetEditDoc().Count(); n++ ) { - const SfxInt16Item& rL = pEditEngine->GetParaAttrib( n, EE_PARA_OUTLLEVEL ); + const SfxInt16Item& rL = getEditEngine().GetParaAttrib( n, EE_PARA_OUTLLEVEL ); if ( rL.GetValue() > rLevel.GetValue() ) { - aEndPaM.SetNode( pEditEngine->GetEditDoc().GetObject( n ) ); + aEndPaM.SetNode( getEditEngine().GetEditDoc().GetObject( n ) ); } else { @@ -2304,9 +2307,9 @@ void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestur aSz = GetOutputDevice().PixelToLogic( aSz ); pDragAndDropInfo->nSensibleRange = static_cast<sal_uInt16>(aSz.Width()); pDragAndDropInfo->nCursorWidth = static_cast<sal_uInt16>(aSz.Width()) / 2; - pDragAndDropInfo->aBeginDragSel = pEditEngine->pImpEditEngine->CreateESel( aCopySel ); + pDragAndDropInfo->aBeginDragSel = getImpEditEngine().CreateESel( aCopySel ); - uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable(aCopySel); + uno::Reference<datatransfer::XTransferable> xData = getEditEngine().CreateTransferable(aCopySel); sal_Int8 nActions = bReadOnly ? datatransfer::dnd::DNDConstants::ACTION_COPY : datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE; @@ -2379,32 +2382,32 @@ void ImpEditView::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent } DrawSelectionXOR(); - EditSelection aDelSel( pEditEngine->pImpEditEngine->CreateSel( aToBeDelSel ) ); - DBG_ASSERT( !aDelSel.DbgIsBuggy( pEditEngine->GetEditDoc() ), "ToBeDel is buggy!" ); - pEditEngine->DeleteSelection(aDelSel); + EditSelection aDelSel(getImpEditEngine().CreateSel(aToBeDelSel)); + DBG_ASSERT( !aDelSel.DbgIsBuggy(getEditEngine().GetEditDoc()), "ToBeDel is buggy!"); + getEditEngine().DeleteSelection(aDelSel); if ( !bBeforeSelection ) { - DBG_ASSERT( !pEditEngine->pImpEditEngine->CreateSel( aNewSel ).DbgIsBuggy(pEditEngine->GetEditDoc()), "Bad" ); - SetEditSelection( pEditEngine->pImpEditEngine->CreateSel( aNewSel ) ); + DBG_ASSERT(!getImpEditEngine().CreateSel(aNewSel).DbgIsBuggy(getEditEngine().GetEditDoc()), "Bad"); + SetEditSelection(getImpEditEngine().CreateSel(aNewSel)); } - pEditEngine->pImpEditEngine->FormatAndLayout( pEditEngine->pImpEditEngine->GetActiveView() ); + getImpEditEngine().FormatAndLayout(getImpEditEngine().GetActiveView()); DrawSelectionXOR(); } else { // other EditEngine ... - if (pEditEngine->HasText()) // #88630# SC is removing the content when switching the task + if (getEditEngine().HasText()) // #88630# SC is removing the content when switching the task DeleteSelected(); } } if ( pDragAndDropInfo->bUndoAction ) - pEditEngine->pImpEditEngine->UndoActionEnd(); + getImpEditEngine().UndoActionEnd(); HideDDCursor(); ShowCursor( DoAutoScroll(), true ); pDragAndDropInfo.reset(); - pEditEngine->GetEndDropHdl().Call(GetEditViewPtr()); + getEditEngine().GetEndDropHdl().Call(GetEditViewPtr()); } void ImpEditView::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE ) @@ -2416,14 +2419,14 @@ void ImpEditView::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE if ( !(pDragAndDropInfo && pDragAndDropInfo->bDragAccepted) ) return; - pEditEngine->GetBeginDropHdl().Call(GetEditViewPtr()); + getEditEngine().GetBeginDropHdl().Call(GetEditViewPtr()); bool bChanges = false; HideDDCursor(); if ( pDragAndDropInfo->bStarterOfDD ) { - pEditEngine->pImpEditEngine->UndoActionStart( EDITUNDO_DRAGANDDROP ); + getImpEditEngine().UndoActionStart( EDITUNDO_DRAGANDDROP ); pDragAndDropInfo->bUndoAction = true; } @@ -2443,23 +2446,23 @@ void ImpEditView::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE EditPaM aPaM( pDragAndDropInfo->aDropDest ); PasteOrDropInfos aPasteOrDropInfos; - aPasteOrDropInfos.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() ); - pEditEngine->HandleBeginPasteOrDrop(aPasteOrDropInfos); + aPasteOrDropInfos.nStartPara = getEditEngine().GetEditDoc().GetPos( aPaM.GetNode() ); + getEditEngine().HandleBeginPasteOrDrop(aPasteOrDropInfos); - EditSelection aNewSel = pEditEngine->InsertText( - xDataObj, OUString(), aPaM, pEditEngine->GetInternalEditStatus().AllowPasteSpecial()); + EditSelection aNewSel = getEditEngine().InsertText( + xDataObj, OUString(), aPaM, getEditEngine().GetInternalEditStatus().AllowPasteSpecial()); - aPasteOrDropInfos.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() ); - pEditEngine->HandleEndPasteOrDrop(aPasteOrDropInfos); + aPasteOrDropInfos.nEndPara = getEditEngine().GetEditDoc().GetPos( aNewSel.Max().GetNode() ); + getEditEngine().HandleEndPasteOrDrop(aPasteOrDropInfos); SetEditSelection( aNewSel ); - pEditEngine->pImpEditEngine->FormatAndLayout( pEditEngine->pImpEditEngine->GetActiveView() ); + getImpEditEngine().FormatAndLayout(getImpEditEngine().GetActiveView()); if ( pDragAndDropInfo->bStarterOfDD ) { // Only set if the same engine! - pDragAndDropInfo->aDropSel.nStartPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() ); + pDragAndDropInfo->aDropSel.nStartPara = getEditEngine().GetEditDoc().GetPos( aPaM.GetNode() ); pDragAndDropInfo->aDropSel.nStartPos = aPaM.GetIndex(); - pDragAndDropInfo->aDropSel.nEndPara = pEditEngine->GetEditDoc().GetPos( aNewSel.Max().GetNode() ); + pDragAndDropInfo->aDropSel.nEndPara = getEditEngine().GetEditDoc().GetPos( aNewSel.Max().GetNode() ); pDragAndDropInfo->aDropSel.nEndPos = aNewSel.Max().GetIndex(); pDragAndDropInfo->bDroppedInMe = true; } @@ -2559,15 +2562,15 @@ void ImpEditView::dragOver(const css::datatransfer::dnd::DropTargetDragEvent& rD } Point aDocPos( GetDocPos( aMousePos ) ); - EditPaM aPaM = pEditEngine->GetPaM( aDocPos ); + EditPaM aPaM = getEditEngine().GetPaM( aDocPos ); pDragAndDropInfo->aDropDest = aPaM; if ( pDragAndDropInfo->bOutlinerMode ) { - sal_Int32 nPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() ); - ParaPortion* pPPortion = pEditEngine->GetParaPortions().SafeGetObject( nPara ); + sal_Int32 nPara = getEditEngine().GetEditDoc().GetPos( aPaM.GetNode() ); + ParaPortion* pPPortion = getEditEngine().GetParaPortions().SafeGetObject( nPara ); if (pPPortion) { - tools::Long nDestParaStartY = pEditEngine->GetParaPortions().GetYOffset( pPPortion ); + tools::Long nDestParaStartY = getEditEngine().GetParaPortions().GetYOffset( pPPortion ); tools::Long nRel = aDocPos.Y() - nDestParaStartY; if ( nRel < ( pPPortion->GetHeight() / 2 ) ) { @@ -2588,9 +2591,9 @@ void ImpEditView::dragOver(const css::datatransfer::dnd::DropTargetDragEvent& rD else if ( HasSelection() ) { // it must not be dropped into a selection - EPaM aP = pEditEngine->pImpEditEngine->CreateEPaM( aPaM ); + EPaM aP = getImpEditEngine().CreateEPaM( aPaM ); ESelection aDestSel( aP.nPara, aP.nIndex, aP.nPara, aP.nIndex); - ESelection aCurSel = pEditEngine->pImpEditEngine->CreateESel( GetEditSelection() ); + ESelection aCurSel = getImpEditEngine().CreateESel( GetEditSelection() ); aCurSel.Adjust(); if ( !(aDestSel < aCurSel) && !(aDestSel > aCurSel) ) { @@ -2603,22 +2606,22 @@ void ImpEditView::dragOver(const css::datatransfer::dnd::DropTargetDragEvent& rD if ( pDragAndDropInfo->bOutlinerMode ) { tools::Long nDDYPos(0); - if ( pDragAndDropInfo->nOutlinerDropDest < pEditEngine->GetEditDoc().Count() ) + if ( pDragAndDropInfo->nOutlinerDropDest < getEditEngine().GetEditDoc().Count() ) { - ParaPortion* pPPortion = pEditEngine->GetParaPortions().SafeGetObject( pDragAndDropInfo->nOutlinerDropDest ); + ParaPortion* pPPortion = getEditEngine().GetParaPortions().SafeGetObject( pDragAndDropInfo->nOutlinerDropDest ); if (pPPortion) - nDDYPos = pEditEngine->GetParaPortions().GetYOffset( pPPortion ); + nDDYPos = getEditEngine().GetParaPortions().GetYOffset( pPPortion ); } else { - nDDYPos = pEditEngine->pImpEditEngine->GetTextHeight(); + nDDYPos = getImpEditEngine().GetTextHeight(); } Point aStartPos( 0, nDDYPos ); aStartPos = GetWindowPos( aStartPos ); Point aEndPos( GetOutputArea().GetWidth(), nDDYPos ); aEndPos = GetWindowPos( aEndPos ); aEditCursor = rOutDev.LogicToPixel( tools::Rectangle( aStartPos, aEndPos ) ); - if ( !pEditEngine->IsEffectivelyVertical() ) + if (!getEditEngine().IsEffectivelyVertical()) { aEditCursor.AdjustTop( -1 ); aEditCursor.AdjustBottom( 1 ); @@ -2640,7 +2643,7 @@ void ImpEditView::dragOver(const css::datatransfer::dnd::DropTargetDragEvent& rD } else { - aEditCursor = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM ); + aEditCursor = getImpEditEngine().PaMtoEditCursor( aPaM ); Point aTopLeft( GetWindowPos( aEditCursor.TopLeft() ) ); aEditCursor.SetPos( aTopLeft ); aEditCursor.SetRight( aEditCursor.Left() + pDragAndDropInfo->nCursorWidth ); diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index b55d91dda690..9a011e90e53c 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -270,7 +270,7 @@ private: OutlinerViewShell* mpViewShell; /// Another shell, just listening to our state, if any. OutlinerViewShell* mpOtherShell; - EditEngine* pEditEngine; + EditEngine* mpEditEngine; VclPtr<vcl::Window> pOutWin; EditView::OutWindowSet aOutWindowSet; std::optional<PointerStyle> mxPointer; @@ -352,6 +352,10 @@ public: EditView* GetEditViewPtr() { return pEditView; } + EditEngine& getEditEngine() const { return *mpEditEngine; } + ImpEditEngine& getImpEditEngine() const { return getEditEngine().getImpl(); } + + sal_uInt16 GetScrollDiffX() const { return nScrollDiffX; } void SetScrollDiffX( sal_uInt16 n ) { nScrollDiffX = n; } diff --git a/editeng/source/editeng/textconv.cxx b/editeng/source/editeng/textconv.cxx index e97be254d6d3..e7d3f1574ce4 100644 --- a/editeng/source/editeng/textconv.cxx +++ b/editeng/source/editeng/textconv.cxx @@ -122,17 +122,17 @@ bool TextConvWrapper::ConvMore_impl() // modified version of SvxSpellWrapper::SpellMore bool bMore = false; - EditEngine* pEE = m_pEditView->GetEditEngine(); - ImpEditEngine* pImpEE = m_pEditView->GetImpEditEngine(); - ConvInfo* pConvInfo = pImpEE->GetConvInfo(); + EditEngine& rEditEngine = m_pEditView->getEditEngine(); + ImpEditEngine& rImpEditEngine = m_pEditView->getImpEditEngine(); + ConvInfo* pConvInfo = rImpEditEngine.GetConvInfo(); if ( pConvInfo->bMultipleDoc ) { - bMore = pEE->ConvertNextDocument(); + bMore = rEditEngine.ConvertNextDocument(); if ( bMore ) { // The text has been entered in this engine ... m_pEditView->GetImpEditView()->SetEditSelection( - pEE->GetEditDoc().GetStartPaM() ); + rEditEngine.GetEditDoc().GetStartPaM() ); } } return bMore; @@ -143,9 +143,9 @@ void TextConvWrapper::ConvStart_impl( SvxSpellArea eArea ) { // modified version of EditSpellWrapper::SpellStart - EditEngine* pEE = m_pEditView->GetEditEngine(); - ImpEditEngine* pImpEE = m_pEditView->GetImpEditEngine(); - ConvInfo* pConvInfo = pImpEE->GetConvInfo(); + EditEngine& rEditEngine = m_pEditView->getEditEngine(); + ImpEditEngine& rImpEditEngine = m_pEditView->getImpEditEngine(); + ConvInfo* pConvInfo = rImpEditEngine.GetConvInfo(); if ( eArea == SvxSpellArea::BodyStart ) { @@ -156,13 +156,12 @@ void TextConvWrapper::ConvStart_impl( SvxSpellArea eArea ) pConvInfo->aConvTo = pConvInfo->aConvStart; pConvInfo->aConvContinue = EPaM( 0, 0 ); m_pEditView->GetImpEditView()->SetEditSelection( - pEE->GetEditDoc().GetStartPaM() ); + rEditEngine.GetEditDoc().GetStartPaM() ); } else { pConvInfo->bConvToEnd = true; - pConvInfo->aConvTo = pImpEE->CreateEPaM( - pEE->GetEditDoc().GetStartPaM() ); + pConvInfo->aConvTo = rImpEditEngine.CreateEPaM(rEditEngine.GetEditDoc().GetStartPaM() ); } } else if ( eArea == SvxSpellArea::BodyEnd ) @@ -179,16 +178,14 @@ void TextConvWrapper::ConvStart_impl( SvxSpellArea eArea ) else { // nothing selected: convert to end of document - pConvInfo->aConvTo = pImpEE->CreateEPaM( - pEE->GetEditDoc().GetEndPaM() ); + pConvInfo->aConvTo = rImpEditEngine.CreateEPaM(rEditEngine.GetEditDoc().GetEndPaM() ); } } else if ( eArea == SvxSpellArea::Body ) { // called by ConvNext_impl... pConvInfo->aConvContinue = pConvInfo->aConvStart; - pConvInfo->aConvTo = pImpEE->CreateEPaM( - pEE->GetEditDoc().GetEndPaM() ); + pConvInfo->aConvTo = rImpEditEngine.CreateEPaM(rEditEngine.GetEditDoc().GetEndPaM() ); } else { @@ -204,7 +201,7 @@ bool TextConvWrapper::ConvContinue_impl() // get next convertible text portion and its language m_aConvText.clear(); m_nConvTextLang = LANGUAGE_NONE; - m_pEditView->GetImpEditEngine()->ImpConvert( m_aConvText, m_nConvTextLang, + m_pEditView->getImpEditEngine().ImpConvert( m_aConvText, m_nConvTextLang, m_pEditView, GetSourceLanguage(), m_aConvSel, m_bAllowChange, GetTargetLanguage(), GetTargetFont() ); return !m_aConvText.isEmpty(); @@ -341,15 +338,15 @@ void TextConvWrapper::ReplaceUnit( m_nUnitOffset = m_nUnitOffset + nUnitStart + aNewTxt.getLength(); // remember current original language for later use - ImpEditEngine *pImpEditEng = m_pEditView->GetImpEditEngine(); + ImpEditEngine& rImpEditEngine = m_pEditView->getImpEditEngine(); ESelection aOldSel = m_pEditView->GetSelection(); //EditSelection aOldEditSel = pEditView->GetImpEditView()->GetEditSelection(); #ifdef DBG_UTIL - LanguageType nOldLang = pImpEditEng->GetLanguage( pImpEditEng->CreateSel( aOldSel ).Min() ).nLang; + LanguageType nOldLang = rImpEditEngine.GetLanguage(rImpEditEngine.CreateSel( aOldSel ).Min() ).nLang; #endif - pImpEditEng->UndoActionStart( EDITUNDO_INSERT ); + rImpEditEngine.UndoActionStart( EDITUNDO_INSERT ); // according to FT we should currently not bother about keeping // attributes in Hangul/Hanja conversion and leave that untouched. @@ -380,11 +377,10 @@ void TextConvWrapper::ReplaceUnit( } } - pImpEditEng->UndoActionEnd(); + rImpEditEngine.UndoActionEnd(); // adjust ConvContinue / ConvTo if necessary - ImpEditEngine* pImpEE = m_pEditView->GetImpEditEngine(); - ConvInfo* pConvInfo = pImpEE->GetConvInfo(); + ConvInfo* pConvInfo = rImpEditEngine.GetConvInfo(); sal_Int32 nDelta = aNewTxt.getLength() - aOrigTxt.getLength(); if (nDelta != 0) { diff --git a/editeng/source/misc/urlfieldhelper.cxx b/editeng/source/misc/urlfieldhelper.cxx index 57f2a042c6b5..16303c064d50 100644 --- a/editeng/source/misc/urlfieldhelper.cxx +++ b/editeng/source/misc/urlfieldhelper.cxx @@ -21,7 +21,7 @@ void URLFieldHelper::RemoveURLField(EditView& pEditView) if (auto pUrlField = dynamic_cast<const SvxURLField*>(pField)) { ESelection aSel = pEditView.GetSelection(); - pEditView.GetEditEngine()->QuickInsertText(pUrlField->GetRepresentation(), aSel); + pEditView.getEditEngine().QuickInsertText(pUrlField->GetRepresentation(), aSel); pEditView.Invalidate(); } } diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx index 136ecd776c26..4fdf36470252 100644 --- a/editeng/source/outliner/outlvw.cxx +++ b/editeng/source/outliner/outlvw.cxx @@ -284,7 +284,7 @@ sal_Int32 OutlinerView::ImpCheckMousePos(const Point& rPosPix, MouseTarget& reTa bool OutlinerView::MouseMove( const MouseEvent& rMEvt ) { - if( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->GetEditEngine()->IsInSelectionMode()) + if( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->getEditEngine().IsInSelectionMode()) return pEditView->MouseMove( rMEvt ); Point aMousePosWin( pEditView->GetOutputDevice().PixelToLogic( rMEvt.GetPosPixel() ) ); @@ -299,7 +299,7 @@ bool OutlinerView::MouseMove( const MouseEvent& rMEvt ) bool OutlinerView::MouseButtonDown( const MouseEvent& rMEvt ) { - if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->GetEditEngine()->IsInSelectionMode() ) + if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->getEditEngine().IsInSelectionMode() ) return pEditView->MouseButtonDown( rMEvt ); Point aMousePosWin( pEditView->GetOutputDevice().PixelToLogic( rMEvt.GetPosPixel() ) ); @@ -347,7 +347,7 @@ bool OutlinerView::MouseButtonDown( const MouseEvent& rMEvt ) bool OutlinerView::MouseButtonUp( const MouseEvent& rMEvt ) { - if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->GetEditEngine()->IsInSelectionMode() ) + if ( ( pOwner->GetOutlinerMode() == OutlinerMode::TextObject ) || pEditView->getEditEngine().IsInSelectionMode() ) return pEditView->MouseButtonUp( rMEvt ); Point aMousePosWin( pEditView->GetOutputDevice().PixelToLogic( rMEvt.GetPosPixel() ) ); @@ -1380,13 +1380,13 @@ void OutlinerView::ExecuteSpellPopup(const Point& rPosPixel, const Link<SpellCal void OutlinerView::Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs ) { - sal_Int32 nOldParaCount = pEditView->GetEditEngine()->GetParagraphCount(); + sal_Int32 nOldParaCount = pEditView->getEditEngine().GetParagraphCount(); ESelection aOldSel = pEditView->GetSelection(); aOldSel.Adjust(); pEditView->Read( rInput, eFormat, pHTTPHeaderAttrs ); - tools::Long nParaDiff = pEditView->GetEditEngine()->GetParagraphCount() - nOldParaCount; + tools::Long nParaDiff = pEditView->getEditEngine().GetParagraphCount() - nOldParaCount; sal_Int32 nChangesStart = aOldSel.nStartPara; sal_Int32 nChangesEnd = nChangesStart + nParaDiff + (aOldSel.nEndPara-aOldSel.nStartPara); @@ -1468,17 +1468,17 @@ bool GetStatusValueForThesaurusFromContext( { // get text and locale for thesaurus look up OUString aText; - EditEngine *pEditEngine = rEditView.GetEditEngine(); + EditEngine& rEditEngine = rEditView.getEditEngine(); ESelection aTextSel( rEditView.GetSelection() ); if (!aTextSel.HasRange()) - aTextSel = pEditEngine->GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD ); - aText = pEditEngine->GetText( aTextSel ); + aTextSel = rEditEngine.GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD ); + aText = rEditEngine.GetText( aTextSel ); aTextSel.Adjust(); - if (!isSingleScriptType(pEditEngine->GetScriptType(aTextSel))) + if (!isSingleScriptType(rEditEngine.GetScriptType(aTextSel))) return false; - LanguageType nLang = pEditEngine->GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos ).nLang; + LanguageType nLang = rEditEngine.GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos ).nLang; OUString aLangText( LanguageTag::convertToBcp47( nLang ) ); // set word and locale to look up as status value |