From 5b04c453cc03c0d2c6067625242f07deb8f78ba0 Mon Sep 17 00:00:00 2001 From: matteocam Date: Mon, 7 Sep 2015 12:44:37 +0200 Subject: chained editeng: Change EndTextEdit behavior to support recursive overflow Change-Id: I14009fa2e91b19a850e45484de7cd234e872689a --- svx/source/svdraw/svdotxed.cxx | 51 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx index c68b085bb43e..4e070276ae6d 100644 --- a/svx/source/svdraw/svdotxed.cxx +++ b/svx/source/svdraw/svdotxed.cxx @@ -23,10 +23,12 @@ #include #include #include +#include #include #include #include #include +#include bool SdrTextObj::HasTextEdit() const @@ -126,6 +128,19 @@ bool SdrTextObj::BegTextEdit(SdrOutliner& rOutl) return true; } +void ImpUpdateOutlParamsForOverflow(SdrOutliner *pOutl, SdrTextObj *pTextObj) +{ + // Code from ImpSetTextEditParams + Size aPaperMin; + Size aPaperMax; + Rectangle aEditArea; + pTextObj->TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,NULL); + + pOutl->SetMinAutoPaperSize(aPaperMin); + pOutl->SetMaxAutoPaperSize(aPaperMax); + pOutl->SetPaperSize(Size()); +} + void SdrTextObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const { bool bFitToSize(IsFitToSize()); @@ -263,9 +278,10 @@ void SdrTextObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* p void SdrTextObj::EndTextEdit(SdrOutliner& rOutl) { + OutlinerParaObject* pNewText = NULL; + if(rOutl.IsModified()) { - OutlinerParaObject* pNewText = NULL; // to make the gray field background vanish again rOutl.UpdateFields(); @@ -277,8 +293,39 @@ void SdrTextObj::EndTextEdit(SdrOutliner& rOutl) // uses GetCurrentBoundRect() which needs to take the text into account // to work correct mbInEditMode = false; - SetOutlinerParaObject(pNewText); + + // We don't want broadcasting if we are merely trying to move to next box (this prevents infinite loops) + if (IsChainable() && GetTextChain()->GetSwitchingToNextBox(this)) { + GetTextChain()->SetSwitchingToNextBox(this, false); + if( getActiveText() ) + getActiveText()->SetOutlinerParaObject( pNewText); + } else { // If we are not doing in-chaining switching just set the ParaObject + SetOutlinerParaObject(pNewText); + } + } + + /* Beginning Chaining-related code */ + rOutl.ClearOverflowingParaNum(); + + /* Flush overflow for next textbox - Necessary for recursive chaining */ + if (false && + IsChainable() && + GetNextLinkInChain() && + GetTextChain()->GetPendingOverflowCheck(GetNextLinkInChain()) ) + { + GetTextChain()->SetPendingOverflowCheck(GetNextLinkInChain(), false); + + SdrOutliner rDrawOutl = GetNextLinkInChain()->ImpGetDrawOutliner(); + // Prepare Outliner for overflow check + ImpUpdateOutlParamsForOverflow(&rDrawOutl, GetNextLinkInChain()); + const OutlinerParaObject *pObj = GetNextLinkInChain()->GetOutlinerParaObject(); + rDrawOutl.SetText(*pObj); + + rDrawOutl.SetUpdateMode(true); + // XXX: Change name of method below to impHandleChainingEventsNonEditMode + GetNextLinkInChain()->impHandleChainingEventsDuringDecomposition(rDrawOutl); } + /* End Chaining-related code */ pEdtOutl = NULL; rOutl.Clear(); -- cgit