editeng/source/outliner/outliner.cxx | 64 +++++------------------------ editeng/source/outliner/overflowingtxt.cxx | 56 ++----------------------- include/editeng/overflowingtxt.hxx | 31 +------------- 3 files changed, 22 insertions(+), 129 deletions(-)
New commits: commit d82ca32c357d35b3e00379273e695281dafc22e1 Author: matteocam <matteo.campane...@gmail.com> Date: Wed Jul 1 15:16:21 2015 -0400 All chaining code converted to EditTextObject approach Change-Id: I4a80b9424eafb7e14f9912e965caf03b42b42e65 diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 961f1bd..df1b54a 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -2113,7 +2113,6 @@ NonOverflowingText *Outliner::GetNonOverflowingText() const // last non-overflowing paragraph is before the first overflowing one sal_Int32 nCount = pEditEngine->GetOverflowingParaNum(); sal_Int32 nOverflowLine = pEditEngine->GetOverflowingLineNum(); - OUString aPreOverflowingTxt(""); // Defensive check: oveflowing para index beyond actual # of paragraphs? if ( nCount > GetParagraphCount()-1) { @@ -2124,20 +2123,23 @@ NonOverflowingText *Outliner::GetNonOverflowingText() const return NULL; } + if (nCount < 0) + { + fprintf(stderr, + "[Overflowing] No Overflowing text but GetNonOverflowinText called?!\n"); + return NULL; + } + // Only overflowing text, i.e. 1st line of 1st paragraph overflowing - if ( nCount == 0 && nOverflowLine == 0) + bool bItAllOverflew = nCount == 0 && nOverflowLine == 0; + if ( bItAllOverflew ) { - OutlinerParaObject* pEmptyPObj = GetEmptyParaObject(); - return new NonOverflowingText(pEmptyPObj, ""); - - } else if (nCount < 0) { // No overflowing Text: all para-s included - nCount = GetParagraphCount(); - // aPreOverflowingText == "" + ESelection aEmptySel(0,0,0,0); + EditTextObject *pTObj = pEditEngine->CreateTextObject(aEmptySel); + return new NonOverflowingText(pTObj); } else { // Get the lines that of the overflowing para fit in the box - // XXX: Is there a proper method to join lines in a single string? sal_Int32 nOverflowingPara = nCount; - OUString aWholeTxtHeadPara = GetText(GetParagraph(nOverflowingPara)); sal_uInt32 nLen = 0; for ( sal_Int32 nLine = 0; @@ -2153,7 +2155,7 @@ NonOverflowingText *Outliner::GetNonOverflowingText() const ESelection aNonOverflowingTextSelection; if (nLen == 0) { // XXX: What happens inside this case might be dependent on the joining paragraps or not-thingy - // Overflowing paragraph is empty: it's not "Non-Overflowing" text then + // Overflowing paragraph is empty or first line overflowing: it's not "Non-Overflowing" text then sal_Int32 nParaLen = GetText(GetParagraph(nOverflowingPara-1)).getLength(); aNonOverflowingTextSelection = ESelection(nStartPara, nStartPos, nOverflowingPara-1, nParaLen); @@ -2164,21 +2166,7 @@ NonOverflowingText *Outliner::GetNonOverflowingText() const } EditTextObject *pTObj = pEditEngine->CreateTextObject(aNonOverflowingTextSelection); return new NonOverflowingText(pTObj); - - - /* END Experiment with ESelection and EditTextobject */ - - // XXX: Any separator to be included? - aPreOverflowingTxt = aWholeTxtHeadPara.copy(0, nLen); } - - OutlinerParaObject *pHeadParas; - if (nCount == 0) // No text to save expect for the one in the overflowing para (i.e. aPreOverflowingTxt) - pHeadParas = NULL; - else - pHeadParas = CreateParaObject(0, nCount); - - return new NonOverflowingText(pHeadParas, aPreOverflowingTxt); } OutlinerParaObject *Outliner::GetEmptyParaObject() const @@ -2206,19 +2194,10 @@ OverflowingText *Outliner::GetOverflowingText() const return NULL; } - OUString aHeadTxt, aTailTxt(""); - OutlinerParaObject *pMidParas = NULL; sal_Int32 nHeadPara = pEditEngine->GetOverflowingParaNum(); sal_uInt32 nParaCount = GetParagraphCount(); - sal_Int32 nTailPara = nParaCount-1; - sal_Int32 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; @@ -2240,23 +2219,6 @@ OverflowingText *Outliner::GetOverflowingText() const /* END experiment ESel */ - // 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)); - } - - 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/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx index 666f53b..3e40b92 100644 --- a/editeng/source/outliner/overflowingtxt.cxx +++ b/editeng/source/outliner/overflowingtxt.cxx @@ -26,57 +26,12 @@ OutlinerParaObject *NonOverflowingText::ToParaObject(Outliner *pOutliner) const { - - if (mpContentTextObj) - { - OutlinerParaObject *pPObj = new OutlinerParaObject(*mpContentTextObj); - pPObj->SetOutlinerMode(pOutliner->GetOutlinerMode()); - return pPObj; - } - - // XXX: Possibility: let the NonUnderflowingParaObject just be a TextEditObject created by the Outliner (by means of a selection). - - /* The overflow in SdrTextObj can occur: - * (a) exactly at the end of a paragraph, or - * (b) in the middle of a paragraph. - * - * In case (a), a NonUnderflowingText object contains only the - * paragraphs occurred before the overflow. - * In case (b), a NonUnderflowingText contains also the text of the - * paragraph that was cut by overflow. - */ - - bool bOverflowOccurredAtEndOfPara = - (mPreOverflowingTxt == "") && - (mpHeadParas != NULL); - - if (bOverflowOccurredAtEndOfPara) { - // Case (a) above: - // Only (possibly empty) paragraphs before overflowing one. - pOutliner->SetText(*mpHeadParas); - } else { - // Case (b): some text is non included in any OutlinerParaObject. - // We have to include the non-overflowing lines from the overfl. para - - // first make a ParaObject for the strings - pOutliner->SetToEmptyText(); - Paragraph *pTmpPara0 = pOutliner->GetParagraph(0); - pOutliner->SetText(mPreOverflowingTxt, pTmpPara0); - OutlinerParaObject *pPObj = pOutliner->CreateParaObject(); - - if (mpHeadParas != NULL) { - pOutliner->SetText(*mpHeadParas); - pOutliner->AddText(*pPObj); - } else if (mPreOverflowingTxt != "") { // only preoverflowing txt - pOutliner->SetText(*pPObj); - } else { // no text // This case is redundant but it doesn't hurt for now - pOutliner->SetToEmptyText(); - } - } - - return pOutliner->CreateParaObject(); + OutlinerParaObject *pPObj = new OutlinerParaObject(*mpContentTextObj); + pPObj->SetOutlinerMode(pOutliner->GetOutlinerMode()); + return pPObj; } +/* OUString OverflowingText::GetEndingLines() const { // If the only overflowing part is some lines in a paragraph, @@ -91,6 +46,7 @@ OUString OverflowingText::GetHeadingLines() const { return mHeadTxt; } +* */ OutlinerParaObject *OverflowingText::GetJuxtaposedParaObject(Outliner *pOutl, OutlinerParaObject *pNextPObj) { @@ -99,7 +55,7 @@ OutlinerParaObject *OverflowingText::GetJuxtaposedParaObject(Outliner *pOutl, Ou return NULL; } - // Simply Juxtaposing; no within para-merging + // Simply Juxtaposing; no within-para merging OutlinerParaObject *pOverflowingPObj = new OutlinerParaObject(*mpContentTextObj); pOutl->SetText(*pOverflowingPObj); pOutl->AddText(*pNextPObj); diff --git a/include/editeng/overflowingtxt.hxx b/include/editeng/overflowingtxt.hxx index 3e9ce3a..797264b 100644 --- a/include/editeng/overflowingtxt.hxx +++ b/include/editeng/overflowingtxt.hxx @@ -35,20 +35,7 @@ class OverflowingText { public: - OUString mHeadTxt; - const OutlinerParaObject *mpMidParas; - OUString mTailTxt; - // NOTE: mpMidParas and mTailTxt might be empty - // Constructor - OverflowingText( - const OUString &headTxt, - const OutlinerParaObject *pMidParas, - const OUString &tailTxt) - : mHeadTxt(headTxt), - mpMidParas(pMidParas), - mTailTxt(tailTxt) - { } OverflowingText(EditTextObject *pTObj) : mpContentTextObj(pTObj) { @@ -56,9 +43,9 @@ public: OutlinerParaObject *GetJuxtaposedParaObject(Outliner *, OutlinerParaObject *); - OUString GetHeadingLines() const; - OUString GetEndingLines() const; - bool HasOtherParas() const { return !(mTailTxt == "" && mpMidParas == NULL); } + //OUString GetHeadingLines() const; + //OUString GetEndingLines() const; + //bool HasOtherParas() const { return !(mTailTxt == "" && mpMidParas == NULL); } private: const EditTextObject *mpContentTextObj; @@ -70,15 +57,6 @@ class NonOverflowingText { // NOTE: mPreOverflowingTxt might be empty // Constructor - NonOverflowingText(const OutlinerParaObject *pHeadParas, - const OUString &preOverflowingTxt) - : mpHeadParas(pHeadParas), - mPreOverflowingTxt(preOverflowingTxt), mpContentTextObj(NULL) - { - if (pHeadParas == NULL) // Redundant line for debugging - DBG_ASSERT( pHeadParas != NULL, "pHeadParas is null?! All text is overflowing then" ); - } - NonOverflowingText(const EditTextObject *pTObj) : mpContentTextObj(pTObj) { } @@ -86,9 +64,6 @@ class NonOverflowingText { OutlinerParaObject *ToParaObject(Outliner *) const; private: - const OutlinerParaObject *mpHeadParas; - OUString mPreOverflowingTxt; - const EditTextObject *mpContentTextObj; }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits