summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-09-05 15:01:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-20 19:20:54 +0200
commite1972743d692c8d8611912c31aae2cb08ae7636d (patch)
tree65817acedf6f17ab8af8df33b2f7abe80fe363d7 /editeng
parenteb830ad284f245165b6ab5e8647d48834622f2d5 (diff)
be more disciplined with SetUpdateLayout on editengine
save/restore in more places, and check in more places before doing layout, so we dont waste time on expensive layout Change-Id: I311f1f7f97a508da296078e936cb3704938dfdc3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121687 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editeng.cxx20
-rw-r--r--editeng/source/editeng/editundo.cxx6
-rw-r--r--editeng/source/editeng/editview.cxx24
-rw-r--r--editeng/source/editeng/impedit2.cxx10
-rw-r--r--editeng/source/editeng/impedit4.cxx8
-rw-r--r--editeng/source/editeng/impedit5.cxx9
-rw-r--r--editeng/source/outliner/outlvw.cxx8
7 files changed, 53 insertions, 32 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index e9f19cbd3194..d22c74ade973 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1637,7 +1637,8 @@ void EditEngine::RemoveParagraph( sal_Int32 nPara )
pImpEditEngine->ImpRemoveParagraph( nPara );
pImpEditEngine->InvalidateFromParagraph( nPara );
pImpEditEngine->UpdateSelections();
- pImpEditEngine->FormatAndLayout();
+ if (pImpEditEngine->IsUpdateLayout())
+ pImpEditEngine->FormatAndLayout();
}
}
@@ -1712,7 +1713,8 @@ void EditEngine::InsertParagraph( sal_Int32 nPara, const EditTextObject& rTxtObj
pImpEditEngine->UndoActionEnd();
- pImpEditEngine->FormatAndLayout();
+ if (pImpEditEngine->IsUpdateLayout())
+ pImpEditEngine->FormatAndLayout();
}
void EditEngine::InsertParagraph(sal_Int32 nPara, const OUString& rTxt)
@@ -1730,7 +1732,8 @@ void EditEngine::InsertParagraph(sal_Int32 nPara, const OUString& rTxt)
pImpEditEngine->RemoveCharAttribs( nPara );
pImpEditEngine->UndoActionEnd();
pImpEditEngine->ImpInsertText( EditSelection( aPaM, aPaM ), rTxt );
- pImpEditEngine->FormatAndLayout();
+ if (pImpEditEngine->IsUpdateLayout())
+ pImpEditEngine->FormatAndLayout();
}
void EditEngine::SetText(sal_Int32 nPara, const OUString& rTxt)
@@ -1741,7 +1744,8 @@ void EditEngine::SetText(sal_Int32 nPara, const OUString& rTxt)
pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
pImpEditEngine->ImpInsertText( *pSel, rTxt );
pImpEditEngine->UndoActionEnd();
- pImpEditEngine->FormatAndLayout();
+ if (pImpEditEngine->IsUpdateLayout())
+ pImpEditEngine->FormatAndLayout();
}
}
@@ -1773,7 +1777,8 @@ void EditEngine::SetCharAttribs(sal_Int32 nPara, const SfxItemSet& rSet)
// This is called by sd::View::OnBeginPasteOrDrop(), updating the cursor position on undo is not
// wanted.
pImpEditEngine->SetAttribs(aSel, rSet, /*nSpecial=*/SetAttribsMode::NONE, /*bSetSelection=*/false);
- pImpEditEngine->FormatAndLayout();
+ if (pImpEditEngine->IsUpdateLayout())
+ pImpEditEngine->FormatAndLayout();
}
void EditEngine::GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const
@@ -1803,7 +1808,8 @@ void EditEngine::RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAt
EditSelection aSel( pImpEditEngine->ConvertSelection( rSelection.nStartPara, rSelection.nStartPos, rSelection.nEndPara, rSelection.nEndPos ) );
pImpEditEngine->RemoveCharAttribs( aSel, eMode, nWhich );
pImpEditEngine->UndoActionEnd();
- pImpEditEngine->FormatAndLayout();
+ if (pImpEditEngine->IsUpdateLayout())
+ pImpEditEngine->FormatAndLayout();
}
vcl::Font EditEngine::GetStandardFont( sal_Int32 nPara )
@@ -2327,7 +2333,7 @@ EFieldInfo EditEngine::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const
bool EditEngine::UpdateFields()
{
bool bChanges = pImpEditEngine->UpdateFields();
- if ( bChanges )
+ if ( bChanges && pImpEditEngine->IsUpdateLayout())
pImpEditEngine->FormatAndLayout();
return bChanges;
}
diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx
index 8df80a629a1d..dc9c3a104b6c 100644
--- a/editeng/source/editeng/editundo.cxx
+++ b/editeng/source/editeng/editundo.cxx
@@ -75,7 +75,8 @@ bool EditUndoManager::Undo()
aNewSel.Min() = aNewSel.Max();
mpEditEngine->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
- mpEditEngine->FormatAndLayout( mpEditEngine->GetActiveView(), true );
+ if (mpEditEngine->IsUpdateLayout())
+ mpEditEngine->FormatAndLayout( mpEditEngine->GetActiveView(), true );
return bDone;
}
@@ -110,7 +111,8 @@ bool EditUndoManager::Redo()
aNewSel.Min() = aNewSel.Max();
mpEditEngine->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
- mpEditEngine->FormatAndLayout( mpEditEngine->GetActiveView() );
+ if (mpEditEngine->IsUpdateLayout())
+ mpEditEngine->FormatAndLayout( mpEditEngine->GetActiveView() );
return bDone;
}
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 59969fca90cb..8fc2b83523c4 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -555,7 +555,8 @@ void EditView::SetAttribs( const SfxItemSet& rSet )
pImpEditView->DrawSelectionXOR();
pImpEditView->pEditEngine->SetAttribs( pImpEditView->GetEditSelection(), rSet, SetAttribsMode::WholeWord );
- pImpEditView->pEditEngine->FormatAndLayout( this );
+ if (pImpEditView->pEditEngine->IsUpdateLayout())
+ pImpEditView->pEditEngine->FormatAndLayout( this );
}
void EditView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs )
@@ -575,7 +576,8 @@ void EditView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs )
}
pImpEditView->pEditEngine->UndoActionEnd();
- pImpEditView->pEditEngine->FormatAndLayout( this );
+ if (pImpEditView->pEditEngine->IsUpdateLayout())
+ pImpEditView->pEditEngine->FormatAndLayout( this );
}
void EditView::RemoveAttribs( bool bRemoveParaAttribs, sal_uInt16 nWhich )
@@ -590,7 +592,8 @@ void EditView::RemoveAttribs( EERemoveParaAttribsMode eMode, sal_uInt16 nWhich )
pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
pImpEditView->pEditEngine->RemoveCharAttribs( pImpEditView->GetEditSelection(), eMode, nWhich );
pImpEditView->pEditEngine->UndoActionEnd();
- pImpEditView->pEditEngine->FormatAndLayout( this );
+ if (pImpEditView->pEditEngine->IsUpdateLayout())
+ pImpEditView->pEditEngine->FormatAndLayout( this );
}
void EditView::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich )
@@ -598,7 +601,8 @@ void EditView::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich )
pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
pImpEditView->pEditEngine->RemoveCharAttribs( nPara, nWhich );
pImpEditView->pEditEngine->UndoActionEnd();
- pImpEditView->pEditEngine->FormatAndLayout( this );
+ if (pImpEditView->pEditEngine->IsUpdateLayout())
+ pImpEditView->pEditEngine->FormatAndLayout( this );
}
SfxItemSet EditView::GetAttribs()
@@ -749,7 +753,8 @@ void EditView::InsertText( const EditTextObject& rTextObject )
aTextSel.Min() = aTextSel.Max(); // Selection not retained.
pImpEditView->SetEditSelection( aTextSel );
- pImpEditView->pEditEngine->FormatAndLayout( this );
+ if (pImpEditView->pEditEngine->IsUpdateLayout())
+ pImpEditView->pEditEngine->FormatAndLayout( this );
}
void EditView::InsertText( css::uno::Reference< css::datatransfer::XTransferable > const & xDataObj, const OUString& rBaseURL, bool bUseSpecial )
@@ -762,7 +767,8 @@ void EditView::InsertText( css::uno::Reference< css::datatransfer::XTransferable
aTextSel.Min() = aTextSel.Max(); // Selection not retained.
pImpEditView->SetEditSelection( aTextSel );
- pImpEditView->pEditEngine->FormatAndLayout( this );
+ if (pImpEditView->pEditEngine->IsUpdateLayout())
+ pImpEditView->pEditEngine->FormatAndLayout( this );
}
bool EditView::SetEditEngineUpdateLayout( bool bUpdate )
@@ -1285,7 +1291,8 @@ void EditView::InsertParaBreak()
EditPaM aPaM(pImpEditView->pEditEngine->InsertParaBreak(pImpEditView->GetEditSelection()));
pImpEditView->pEditEngine->UndoActionEnd();
pImpEditView->SetEditSelection(EditSelection(aPaM, aPaM));
- pImpEditView->pEditEngine->FormatAndLayout(this);
+ if (pImpEditView->pEditEngine->IsUpdateLayout())
+ pImpEditView->pEditEngine->FormatAndLayout(this);
}
void EditView::InsertField( const SvxFieldItem& rFld )
@@ -1297,7 +1304,8 @@ void EditView::InsertField( const SvxFieldItem& rFld )
pEE->UndoActionEnd();
pImpEditView->SetEditSelection( EditSelection( aPaM, aPaM ) );
pEE->UpdateFields();
- pEE->FormatAndLayout( this );
+ if (pImpEditView->pEditEngine->IsUpdateLayout())
+ pEE->FormatAndLayout( this );
}
const SvxFieldItem* EditView::GetFieldUnderMousePointer() const
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 6d27b50dfd68..41985b874a85 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3066,7 +3066,7 @@ tools::Rectangle ImpEditEngine::GetEditCursor(const ParaPortion* pPortion, const
tools::Rectangle ImpEditEngine::PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nFlags )
{
- OSL_ENSURE( IsUpdateLayout(), "Must not be reached when Update=FALSE: PaMtoEditCursor" );
+ assert( IsUpdateLayout() && "Must not be reached when Update=FALSE: PaMtoEditCursor" );
tools::Rectangle aEditCursor;
const sal_Int32 nIndex = aPaM.GetIndex();
@@ -3235,7 +3235,7 @@ ImpEditEngine::GetPortionAndLine(Point aDocPos)
EditPaM ImpEditEngine::GetPaM( Point aDocPos, bool bSmart )
{
- OSL_ENSURE( IsUpdateLayout(), "Must not be reached when Update=FALSE: GetPaM" );
+ assert( IsUpdateLayout() && "Must not be reached when Update=FALSE: GetPaM" );
if (const auto& [pPortion, pLine, nLineStartX] = GetPortionAndLine(aDocPos); pPortion)
{
@@ -3268,7 +3268,7 @@ bool ImpEditEngine::IsTextPos(const Point& rDocPos, sal_uInt16 nBorder)
sal_uInt32 ImpEditEngine::GetTextHeight() const
{
- OSL_ENSURE( IsUpdateLayout(), "Should not be used for Update=FALSE: GetTextHeight" );
+ assert( IsUpdateLayout() && "Should not be used for Update=FALSE: GetTextHeight" );
OSL_ENSURE( IsFormatted() || IsFormatting(), "GetTextHeight: Not formatted" );
return nCurTextHeight;
}
@@ -3402,7 +3402,7 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
sal_uInt32 ImpEditEngine::GetTextHeightNTP() const
{
- DBG_ASSERT( IsUpdateLayout(), "Should not be used for Update=FALSE: GetTextHeight" );
+ assert( IsUpdateLayout() && "Should not be used for Update=FALSE: GetTextHeight" );
DBG_ASSERT( IsFormatted() || IsFormatting(), "GetTextHeight: Not formatted" );
return nCurTextHeightNTP;
}
@@ -3432,7 +3432,7 @@ tools::Long ImpEditEngine::Calc1ColumnTextHeight(tools::Long* pHeightNTP)
tools::Long ImpEditEngine::CalcTextHeight(tools::Long* pHeightNTP)
{
- OSL_ENSURE( IsUpdateLayout(), "Should not be used when Update=FALSE: CalcTextHeight" );
+ assert( IsUpdateLayout() && "Should not be used when Update=FALSE: CalcTextHeight" );
if (mnColumns <= 1)
return Calc1ColumnTextHeight(pHeightNTP); // All text fits into a single column - done!
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 2336155b2dd7..879274a2a667 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -276,7 +276,7 @@ void ImpEditEngine::WriteXML(SvStream& rOutput, const EditSelection& rSel)
ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
{
- DBG_ASSERT( IsUpdateLayout(), "WriteRTF for UpdateMode = sal_False!" );
+ assert( IsUpdateLayout() && "WriteRTF for UpdateMode = sal_False!" );
CheckIdleFormatter();
if ( !IsFormatted() )
FormatDoc();
@@ -2168,7 +2168,8 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView,
}
rEditView.pImpEditView->SetEditSelection( aNext );
- FormatAndLayout();
+ if (IsUpdateLayout())
+ FormatAndLayout();
aEditDoc.SetModified(true);
}
@@ -2954,7 +2955,8 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
SetModifyFlag( true );
if ( bLenChanged )
UpdateSelections();
- FormatAndLayout();
+ if (IsUpdateLayout())
+ FormatAndLayout();
}
return aNewSel;
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 69eeae09f515..6a5842d61886 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -88,7 +88,8 @@ void ImpEditEngine::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle )
StartListening(*pStyle, DuplicateHandling::Prevent);
ParaAttribsChanged( pNode );
}
- FormatAndLayout();
+ if (IsUpdateLayout())
+ FormatAndLayout();
}
void ImpEditEngine::UpdateParagraphsWithStyleSheet( SfxStyleSheet* pStyle )
@@ -114,7 +115,8 @@ void ImpEditEngine::UpdateParagraphsWithStyleSheet( SfxStyleSheet* pStyle )
if ( bUsed )
{
GetEditEnginePtr()->StyleSheetChanged( pStyle );
- FormatAndLayout();
+ if (IsUpdateLayout())
+ FormatAndLayout();
}
}
@@ -129,7 +131,8 @@ void ImpEditEngine::RemoveStyleFromParagraphs( SfxStyleSheet const * pStyle )
ParaAttribsChanged( pNode );
}
}
- FormatAndLayout();
+ if (IsUpdateLayout())
+ FormatAndLayout();
}
void ImpEditEngine::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 3e910db125aa..e607698d5efe 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -644,13 +644,13 @@ void OutlinerView::InsertText( const OutlinerParaObject& rParaObj )
pOwner->UndoActionStart( OLUNDO_INSERT );
- pOwner->pEditEngine->SetUpdateLayout( false );
+ const bool bPrevUpdateLayout = pOwner->pEditEngine->SetUpdateLayout( false );
sal_Int32 nStart, nParaCount;
nParaCount = pOwner->pEditEngine->GetParagraphCount();
sal_uInt16 nSize = ImpInitPaste( nStart );
pEditView->InsertText( rParaObj.GetTextObject() );
ImpPasted( nStart, nParaCount, nSize);
- pEditView->SetEditEngineUpdateLayout( true );
+ pEditView->SetEditEngineUpdateLayout( bPrevUpdateLayout );
pOwner->UndoActionEnd();
@@ -679,7 +679,7 @@ void OutlinerView::Paste( bool bUseSpecial )
pOwner->UndoActionStart( OLUNDO_INSERT );
- pOwner->pEditEngine->SetUpdateLayout( false );
+ const bool bPrevUpdateLayout = pOwner->pEditEngine->SetUpdateLayout( false );
pOwner->bPasting = true;
if ( bUseSpecial )
@@ -695,7 +695,7 @@ void OutlinerView::Paste( bool bUseSpecial )
pOwner->ImplSetLevelDependentStyleSheet( nPara );
}
- pEditView->SetEditEngineUpdateLayout( true );
+ pEditView->SetEditEngineUpdateLayout( bPrevUpdateLayout );
pOwner->UndoActionEnd();
pEditView->ShowCursor();