svx/source/svdraw/svdotextdecomposition.cxx | 72 +++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 6 deletions(-)
New commits: commit 50d8c0b1aabd184742cf1ea3ceaa3a65b7419205 Author: matteocam <matteo.campane...@gmail.com> Date: Mon Jun 1 14:50:11 2015 -0400 Does copying in the right way. Still detached from source text Change-Id: I458062225d0270e05deb68c54911921483352d54 diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 36fa13d..6f29f26 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -745,18 +745,78 @@ void SdrTextObj::impCopyTextInTextObj2(SdrTextObj *pNextTextObj) const rOutliner.SetStatusEventHdl1(LINK(this,SdrTextObj,ImpDecomposeChainedText)); struct OverflowingText { - OUString headTxt; - OutlinerParaObject *tailParas; + OUString mHeadTxt; + const OutlinerParaObject *mpMidParas; + OUString mTailTxt; + // NOTE: mpMidParas and mTailTxt might be empty + + // Constructor + OverflowingText( + const OUString &headTxt, + const OutlinerParaObject *pMidParas = NULL, + const OUString &tailTxt = "") + : mHeadTxt(headTxt), + mpMidParas(pMidParas), + mTailTxt(tailTxt) + { } }; + OverflowingText aOverflowingTxt = + OverflowingText("headTxt (On its own) ", NULL, "I'm Appended to #"); + if (mpOverflowingText) { - // get first para of destination box - // XXX: Check it exists + // XXX: Not sure if necessary + rOutliner.Clear(); + + OutlinerParaObject *pCurTxt = pNextTextObj->GetOutlinerParaObject(); + rOutliner.SetText(*pCurTxt); + + // Get text of first paragraph of destination box + Paragraph *pOldPara0 = rOutliner.GetParagraph(0); + OUString aOldPara0Txt; + if (pOldPara0) + aOldPara0Txt = rOutliner.GetText(pOldPara0); + + // Get other paras of destination box (from second on) + OutlinerParaObject *pOldParasTail = + rOutliner.CreateParaObject(1); - // Get other paras of destination box - // XXX: Check they exist + // Create ParaObject appending old first para in the dest. box + // to last part of overflowing text + Paragraph *pTmpPara0 = NULL; + OutlinerParaObject *pJoiningPara = NULL; + + if (pOldPara0) { + rOutliner.Clear(); + + pTmpPara0 = rOutliner.GetParagraph(0); + rOutliner.SetText(aOverflowingTxt.mTailTxt + aOldPara0Txt, pTmpPara0); + pJoiningPara = rOutliner.CreateParaObject(); + } + // start actual composition + rOutliner.Clear(); + // Set headText at the beginning of box + Paragraph *pNewPara0 = rOutliner.GetParagraph(0); + rOutliner.SetText(aOverflowingTxt.mHeadTxt, pNewPara0); + + // Set all the intermediate Paras + if (aOverflowingTxt.mpMidParas) + rOutliner.AddText(*aOverflowingTxt.mpMidParas); + + // Append old first para in the destination box to + // last part of overflowing text + if (pJoiningPara) + rOutliner.AddText(*pJoiningPara); + + // Append all other old paras + if (pOldParasTail) + rOutliner.AddText(*pOldParasTail); + + // Draw everything + OutlinerParaObject *pNewText = rOutliner.CreateParaObject(); + pNextTextObj->NbcSetOutlinerParaObject(pNewText); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits