editeng/source/editeng/editeng.cxx | 5 + editeng/source/outliner/outliner.cxx | 78 +++++++++++++---------- include/editeng/editeng.hxx | 1 include/editeng/outliner.hxx | 3 include/svx/svdotext.hxx | 6 - svx/source/svdraw/svdotext.cxx | 4 - svx/source/svdraw/svdotextdecomposition.cxx | 94 ++++------------------------ svx/source/svdraw/svdotxed.cxx | 2 8 files changed, 71 insertions(+), 122 deletions(-)
New commits: commit fed813654b69ca34e6890ff85799af844206af95 Author: matteocam <matteo.campane...@gmail.com> Date: Mon Jun 1 19:20:05 2015 -0400 Making right overflowing line flow in dest box. Currently crashing Change-Id: Idfae9fa4f606b4f1314fd0eba0e509d3840aba95 diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 6193b98..a86e088 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -59,7 +59,6 @@ #include <editeng/emphasismarkitem.hxx> #include <editeng/charscaleitem.hxx> #include <editeng/charreliefitem.hxx> -#include <editeng/overflowingtxt.hxx> #include <sot/exchange.hxx> #include <sot/formats.hxx> @@ -2787,6 +2786,10 @@ sal_Int32 EditEngine::GetOverflowingParaNum() const { return pImpEditEngine->GetOverflowingParaNum(); } +sal_Int32 EditEngine::GetOverflowingLineNum() const { + return pImpEditEngine->GetOverflowingLineNum(); +} + void EditEngine::ClearOverflowingParaNum() { pImpEditEngine->ClearOverflowingParaNum(); } diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 909e821..a6b3a83 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -2099,7 +2099,6 @@ OutlinerParaObject *Outliner::GetNonOverflowingParaObject() const if ( GetParagraphCount() < 1 ) return NULL; - sal_Int32 nStartPara = 0; // last non-overflowing paragraph is before the first overflowing one sal_Int32 nCount = pEditEngine->GetOverflowingParaNum(); //sal_Int32 nCount = 1; @@ -2125,48 +2124,59 @@ OutlinerParaObject *Outliner::GetNonOverflowingParaObject() const } else if (nCount < 0) // No overflowing Text nCount = GetParagraphCount(); - // code inspired from Outliner::CreateParaObject + return CreateParaObject(0, nCount); +} - // we need a paragraph data vector and the actual text - ParagraphDataVector aParagraphDataVector(nCount); - const sal_Int32 nLastPara(nStartPara + nCount - 1); +OverflowingText *Outliner::GetOverflowingText() const +{ + if ( pEditEngine->GetOverflowingParaNum() < 0) + return NULL; - for(sal_Int32 nPara(nStartPara); nPara <= nLastPara; nPara++) - { - aParagraphDataVector[nPara-nStartPara] = *GetParagraph(nPara); + + // Defensive check: oveflowing para index beyond actual # of paragraphs? + if ( pEditEngine->GetOverflowingParaNum() > GetParagraphCount()-1) { + fprintf(stderr, + "[Overflowing] Ops, trying to retrieve para %d when max index is %d\n", + pEditEngine->GetOverflowingParaNum(), + GetParagraphCount()-1); + return NULL; } - EditTextObject* pText = pEditEngine->CreateTextObject( nStartPara, nCount ); - const bool bIsEditDoc(OUTLINERMODE_TEXTOBJECT == ImplGetOutlinerMode()); + OUString aHeadTxt, aTailTxt(""); + OutlinerParaObject *pMidParas = NULL; - OutlinerParaObject* pPObj = new OutlinerParaObject(*pText, aParagraphDataVector, bIsEditDoc); - pPObj->SetOutlinerMode(GetMode()); - delete pText; - return pPObj; -} -OutlinerParaObject *Outliner::GetOverflowingParaObject() const -{ - if ( pEditEngine->GetOverflowingParaNum() >= 0) { - // Defensive check: oveflowing para index beyond actual # of paragraphs? - if ( pEditEngine->GetOverflowingParaNum() > GetParagraphCount()-1) { - fprintf(stderr, - "[Overflowing] Ops, trying to retrieve para %d when max index is %d\n", - pEditEngine->GetOverflowingParaNum(), - GetParagraphCount()-1); - return NULL; + sal_uInt32 nHeadPara = pEditEngine->GetOverflowingParaNum(); + sal_uInt32 nParaCount = GetParagraphCount(); + sal_uInt32 nTailPara = nParaCount-1; + sal_uInt32 nMidParas = nTailPara-nHeadPara-1; + + // Set the head text + // XXX: Is there a proper method to join lines in a single string? + OUString aWholeTxtHeadPara = GetText(GetParagraph(nHeadPara)); + sal_uInt32 nLen = 0; + for ( sal_Int32 nLine = 0; + nLine < pEditEngine->GetOverflowingLineNum(); + nLine++) { + nLen += GetLineLen(nHeadPara, nLine); } - return CreateParaObject( pEditEngine->GetOverflowingParaNum() ); + // XXX: Any separator to be included? + aHeadTxt = aWholeTxtHeadPara.copy(nLen); + + + // If there is at least one more paragraph overflowing + if (nTailPara > nHeadPara) { + // Get text of last paragraph + aTailTxt = GetText(GetParagraph(nTailPara)); } - return NULL; - /* - // XXX: returns second paragraph if there is one, first otherwise - if ( GetParagraphCount() >= 2 ) - return CreateParaObject(1, 1); - else - return CreateParaObject(0, 1); - */ + if (nMidParas > 0) { + // Get everything between first and last overflowing para + pMidParas = CreateParaObject(nHeadPara+1, nMidParas); + } + + // XXX: Who deletes this? + return new OverflowingText(aHeadTxt, pMidParas, aTailTxt); } void Outliner::ClearOverflowingParaNum() diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index dda4e29..08c6522 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -599,6 +599,7 @@ public: bool Redo(EditView* pView); sal_Int32 GetOverflowingParaNum() const; + sal_Int32 GetOverflowingLineNum() const; void ClearOverflowingParaNum(); }; diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index 8889adf..c493a7c 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -44,6 +44,7 @@ class EditView; class EditUndo; class ParagraphList; class OutlinerParaObject; +class OverflowingText; class SvStream; class SvxBulletItem; class SvxFont; @@ -759,7 +760,7 @@ public: Link GetParaRemovingHdl() const { return aParaRemovingHdl; } OutlinerParaObject *GetNonOverflowingParaObject() const; - OutlinerParaObject *GetOverflowingParaObject() const; + OverflowingText *GetOverflowingText() const; void ClearOverflowingParaNum(); virtual void DepthChangedHdl(); diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 1e50a68..9144af4 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -38,6 +38,7 @@ class OutlinerParaObject; +class OverflowingText; class SdrOutliner; class SdrTextObj; class SvxFieldItem; @@ -215,7 +216,7 @@ public: void SetTextEditOffset(const Point& rNew) { maTextEditOffset = rNew; } // FIXME(matteocam) // XXX: move as protected - OutlinerParaObject *mpOverflowingText = NULL; + OverflowingText *mpOverflowingText = NULL; protected: @@ -604,8 +605,7 @@ public: const drawinglayer::primitive2d::SdrChainedTextPrimitive2D& rSdrChainedTextPrimitive, const drawinglayer::geometry::ViewInformation2D& aViewInformation) const; - void impCopyTextInTextObj(SdrTextObj *pNextTextObj) const; - void impCopyTextInTextObj2(SdrTextObj *pNextTextObj) const; + void impMoveChainedTextToNextLink(SdrTextObj *pNextTextObj) const; // Handler for Chained Text DECL_LINK(ImpDecomposeChainedText,EditStatus*); diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index c0b59e8..3d13ebb 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1964,9 +1964,9 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus ) // Pushes text in next link on the fly if ( pEditStatus->IsPageOverflow() ) { - mpOverflowingText = pEdtOutl->GetOverflowingParaObject(); + mpOverflowingText = pEdtOutl->GetOverflowingText(); SdrTextObj *pNextTextObj = GetNextLinkInChain(); - impCopyTextInTextObj2(pNextTextObj); + impMoveChainedTextToNextLink(pNextTextObj); } } diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 30f1fcc..0d57eff 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -733,9 +733,9 @@ void SdrTextObj::embedText() const } -// A new temporary implementation of impCopyTextInTextObj +// A new temporary implementation of impMoveChainedTextToNextLink // Should implement the whole logic -void SdrTextObj::impCopyTextInTextObj2(SdrTextObj *pNextTextObj) const +void SdrTextObj::impMoveChainedTextToNextLink(SdrTextObj *pNextTextObj) const { // prevent copying text in same box if ( this == pNextTextObj ) @@ -745,10 +745,7 @@ void SdrTextObj::impCopyTextInTextObj2(SdrTextObj *pNextTextObj) const rOutliner.SetStatusEventHdl1(LINK(this,SdrTextObj,ImpDecomposeChainedText)); - OverflowingText aOverflowingTxt = - OverflowingText("headTxt (On its own)", NULL, "I'm Appended to #"); - - if (mpOverflowingText) { + if (mpOverflowingText != NULL) { // XXX: Not sure if necessary rOutliner.Clear(); @@ -762,8 +759,9 @@ void SdrTextObj::impCopyTextInTextObj2(SdrTextObj *pNextTextObj) const aOldPara0Txt = rOutliner.GetText(pOldPara0); // Get other paras of destination box (from second on) - OutlinerParaObject *pOldParasTail = - rOutliner.CreateParaObject(1); + OutlinerParaObject *pOldParasTail = NULL; + if (rOutliner.GetParagraphCount() > 1) + pOldParasTail = rOutliner.CreateParaObject(1); // Create ParaObject appending old first para in the dest. box // to last part of overflowing text @@ -774,7 +772,7 @@ void SdrTextObj::impCopyTextInTextObj2(SdrTextObj *pNextTextObj) const rOutliner.Clear(); pTmpPara0 = rOutliner.GetParagraph(0); - rOutliner.SetText(aOverflowingTxt.mTailTxt + aOldPara0Txt, pTmpPara0); + rOutliner.SetText(mpOverflowingText->mTailTxt + aOldPara0Txt, pTmpPara0); pJoiningPara = rOutliner.CreateParaObject(); } @@ -783,11 +781,11 @@ void SdrTextObj::impCopyTextInTextObj2(SdrTextObj *pNextTextObj) const // Set headText at the beginning of box Paragraph *pNewPara0 = rOutliner.GetParagraph(0); - rOutliner.SetText(aOverflowingTxt.mHeadTxt, pNewPara0); + rOutliner.SetText(mpOverflowingText->mHeadTxt, pNewPara0); // Set all the intermediate Paras - if (aOverflowingTxt.mpMidParas) - rOutliner.AddText(*aOverflowingTxt.mpMidParas); + if (mpOverflowingText->mpMidParas) + rOutliner.AddText(*mpOverflowingText->mpMidParas); // Append old first para in the destination box to // last part of overflowing text @@ -803,70 +801,6 @@ void SdrTextObj::impCopyTextInTextObj2(SdrTextObj *pNextTextObj) const pNextTextObj->NbcSetOutlinerParaObject(pNewText); } -} - - -void SdrTextObj::impCopyTextInTextObj(SdrTextObj *pNextTextObj) const -{ - // prevent copying text in same box - if ( this == pNextTextObj ) - return; - - SdrOutliner &rOutliner = ImpGetDrawOutliner(); - - /* - // Code inspired by SvxOutlinerForwarder::AppendTextPortion - sal_Int32 nLen = 0; - - EditEngine& rEditEngine = const_cast< EditEngine& >( rOutliner.GetEditEngine() ); - sal_Int32 nParaCount = rEditEngine.GetParagraphCount(); - DBG_ASSERT( 0 <= nPara && nPara < nParaCount, "paragraph index out of bounds" ); - if (0 <= nPara && nPara < nParaCount) - { - nLen = rEditEngine.GetTextLen( nPara ); - rEditEngine.QuickInsertText( rText, ESelection( nPara, nLen, nPara, nLen ) ); - } - * */ - - rOutliner.SetStatusEventHdl1(LINK(this,SdrTextObj,ImpDecomposeChainedText)); - - // Push text through the chain if there's any - - // append a string in front of everything - // NOTE: Trying with set-text first - - if (mpOverflowingText) { - - /* Desired behavior: - * - take first overflowing word and paragraph from there - * - Outliner::GetOverflowingPara should return the second overflowing para - * - then these two should pasted together (as below?) - */ - - /* - * The goal is to have UpdateOverflowingParaNum be finer grained and - * work at level of lines instead of para-s - */ - - // Set new text first - rOutliner.SetText(*mpOverflowingText); - - /* - * We merge new text in front of the first paragraph - * so we get a pointer to it and its text. - */ - Paragraph *pFstPara = rOutliner.GetParagraph(0); - OUString aTxtFstPara = rOutliner.GetText(pFstPara); - - // - rOutliner.SetText("X" + aTxtFstPara, pFstPara); - // gets the whole thing - OutlinerParaObject *pNewText = rOutliner.CreateParaObject(); - // draws everything - result = "X" ++ overflowingText - pNextTextObj->NbcSetOutlinerParaObject(pNewText); - } - - rOutliner.SetStatusEventHdl1(Link()); } @@ -1573,21 +1507,21 @@ void SdrTextObj::impDecomposeChainedTextPrimitive( /* fprintf(stderr, "Object #0 = %p, Object #1 = %p\n", pPage->GetObj(0), pPage->GetObj(1)); */ - //impCopyTextInTextObj(pNextTextObj); // just do it + //impMoveChainedTextToNextLink(pNextTextObj); // just do it // put overflowing text in next text box if (mpOverflowingText != NULL) { SdrTextObj *pNextTextObj = GetNextLinkInChain(); assert (pNextTextObj); // NOTE: Commented because we do not need to do this anymore (maybe and for now) - //impCopyTextInTextObj(pNextTextObj); // XXX: it actually moves the overflowing text currently + //impMoveChainedTextToNextLink(pNextTextObj); // XXX: it actually moves the overflowing text currently // Chaining occurred. Let's reset the status const_cast<SdrTextObj*>(this)->SetToBeChained( false ); - //pNextTextObj->SetOutlinerParaObject( mpOverflowingText ); + //SdrOutliner rOutl = pNextTextObj->ImpGetDrawOutliner(); //pNextTextObj->BegTextEdit( rOutl ); - // XXX: Also, will all those calls currently in impCopyTextInTextObj be necessary too? + // XXX: Also, will all those calls currently in impMoveChainedTextToNextLink be necessary too? } drawinglayer::primitive2d::Primitive2DSequence aRetval(0); diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx index 1471711..1bebccf 100644 --- a/svx/source/svdraw/svdotxed.cxx +++ b/svx/source/svdraw/svdotxed.cxx @@ -278,7 +278,7 @@ void SdrTextObj::EndTextEdit(SdrOutliner& rOutl) // set non overflow part of text to current box pNewText = rOutl.GetNonOverflowingParaObject(); // empty text obj. if 1st para is overflowing // set overflowing text for SdrChainedTextPrimitive2D - mpOverflowingText = rOutl.GetOverflowingParaObject(); + mpOverflowingText = rOutl.GetOverflowingText(); // TODO: factor the lines of code above in a single function } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits