[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-chained-text-boxes' - include/svx svx/source

matteocam matteo.campanelli at gmail.com
Mon Jun 29 01:35:14 PDT 2015


 include/svx/svdotext.hxx                    |    8 -
 svx/source/svdraw/svdotext.cxx              |  110 --------------
 svx/source/svdraw/svdotextdecomposition.cxx |  211 ----------------------------
 3 files changed, 6 insertions(+), 323 deletions(-)

New commits:
commit ac2de02674bd624064a4875894d4f1e18134e420
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jun 29 04:33:56 2015 -0400

    Cleaned text transferring code in SdrTextObj class
    
    Change-Id: I9dbd71749bce1643bbdbd119463dd584cb235156

diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 6e81767..dee2912 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -326,10 +326,6 @@ protected:
 
     virtual ~SdrTextObj();
 
-    virtual void onOverflowStatusEvent( );
-    virtual void onUnderflowStatusEvent( );
-
-
 public:
     TYPEINFO_OVERRIDE();
 
@@ -622,10 +618,6 @@ public:
         const drawinglayer::primitive2d::SdrChainedTextPrimitive2D& rSdrChainedTextPrimitive,
         const drawinglayer::geometry::ViewInformation2D& aViewInformation) const;
 
-    void impMoveChainedTextToNextLink(SdrOutliner *pOutliner, SdrTextObj *pNextTextObj) const;
-    OutlinerParaObject *impGetOverflowingParaObject(SdrOutliner *pOutliner, SdrTextObj *pNextTextObj) const;
-    void impLeaveOnlyNonOverflowingText(SdrOutliner *pOutliner) const;
-    OutlinerParaObject *impGetNonOverflowingParaObject(SdrOutliner *pOutliner) const;
 
     // timing generators
     void impGetBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const;
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index b3b7332..d0443fa 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1966,82 +1966,8 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
     }
 }
 
-void SdrTextObj::onOverflowStatusEvent( )
-{
-    // Pushes text in next link on the fly
-    if ( mbToBeChained ) {
-        SdrOutliner &aDrawOutliner = ImpGetDrawOutliner();
-
-       if (pEdtOutl != NULL)
-            mpOverflowingText = pEdtOutl->GetOverflowingText();
-        else {
-            assert(0); // Should never happen. FIXME(matteocam)
-        }
-
-        SdrTextObj *pNextTextObj = GetNextLinkInChain();
-
-        impLeaveOnlyNonOverflowingText(&aDrawOutliner);
-
-        // Transfer overflowing text
-        impMoveChainedTextToNextLink(&aDrawOutliner, pNextTextObj);
-    }
-}
-
-void SdrTextObj::onUnderflowStatusEvent( )
-{
-    SdrTextObj *pNextLink = GetNextLinkInChain();
-    SdrOutliner &aDrawOutliner = ImpGetDrawOutliner();
-
-    if (!pNextLink->HasText())
-        return;
-
-    //  Get the text of the other guy and add it to the last paragraph
-    // XXX: For now it's not merging anything just adding the while thing as a separate para
-    OutlinerParaObject *pNextLinkWholeText = pNextLink->GetOutlinerParaObject();
-    if (!pNextLinkWholeText)
-        return;
-
-    OutlinerParaObject *pCurText;
-
-    pCurText = pEdtOutl->CreateParaObject();
-
-    // NewTextForCurBox = Txt(CurBox) ++ Txt(NextBox)
-    // prepare for checking overflow
-    aDrawOutliner.SetUpdateMode(true);
-    aDrawOutliner.SetMaxAutoPaperSize(pEdtOutl->GetMaxAutoPaperSize());
-    aDrawOutliner.SetMinAutoPaperSize(pEdtOutl->GetMinAutoPaperSize());
-    aDrawOutliner.SetPaperSize(pEdtOutl->GetPaperSize());
-    aDrawOutliner.SetText(*pCurText);
-    aDrawOutliner.AddText(*pNextLinkWholeText);
-
-    bool bIsOverflowFromUnderflow = aDrawOutliner.IsPageOverflow();
-    // Save mpOverflowingText (important for overflow handlers below) // XXX: Change the wayt this is done?
-    if (bIsOverflowFromUnderflow)
-        mpOverflowingText = aDrawOutliner.GetOverflowingText();
-
-    OutlinerParaObject *pNewText = aDrawOutliner.CreateParaObject();
-
-    // Set the other box empty so if overflow does not occur we are fine
-    pNextLink->NbcSetOutlinerParaObject(aDrawOutliner.GetEmptyParaObject());
-
-    // handle overflow
-    if (bIsOverflowFromUnderflow) {
-        // prevents infinite loops when setting text for editing outliner
-        GetTextChain()->SetNilChainingEvent(const_cast<SdrTextObj*>(this), true);
-
-        impLeaveOnlyNonOverflowingText(&aDrawOutliner);
-        impMoveChainedTextToNextLink(&aDrawOutliner, pNextLink);
-    } else {
-        // No overflow: set the whole thing
-        const_cast<SdrTextObj*>(this)->SetOutlinerParaObject(pNewText);
-    }
-}
-
-
 void SdrTextObj::onChainingEvent()
 {
-
-
     if (!IsChainable() || GetNextLinkInChain() == NULL)
         return;
 
@@ -2057,56 +1983,28 @@ void SdrTextObj::onChainingEvent()
     // Outliner for text transfer
     SdrOutliner &aDrawOutliner = ImpGetDrawOutliner();
 
-    // XXX: Specializing the class?
-    // OBS: you don't need all the "setting parameters" crap for underflow with this
     EditingTextChainFlow aTxtChainFlow(this);
     aTxtChainFlow.CheckForFlowEvents(pEdtOutl);
 
 
     if (aTxtChainFlow.IsOverflow()) {
-        fprintf(stderr, "Overflow going on\n");
-
+        fprintf(stderr, "[CHAINING] Overflow going on\n");
         // One outliner is for non-overflowing text, the other for overflowing text
         // In this case they can both be the drawing outliner
         aTxtChainFlow.ExecuteOverflow(&aDrawOutliner, &aDrawOutliner);
     } else if (aTxtChainFlow.IsUnderflow()) {
-        fprintf(stderr, "Underflow going on\n");
+        fprintf(stderr, "[CHAINING] Underflow going on\n");
         // underflow-induced overflow
         aTxtChainFlow.ExecuteUnderflow(&aDrawOutliner);
         bool bIsOverflowFromUnderflow = aTxtChainFlow.IsOverflow();
-
         // handle overflow
         if (bIsOverflowFromUnderflow) {
-            fprintf(stderr, "Overflow going on (underflow induced)\n");
+            fprintf(stderr, "[CHAINING] Overflow going on (underflow induced)\n");
             // prevents infinite loops when setting text for editing outliner
             GetTextChain()->SetNilChainingEvent(const_cast<SdrTextObj*>(this), true);
 
             aTxtChainFlow.ExecuteOverflow(&aDrawOutliner, &aDrawOutliner);
-        } // XXX: For the code below
-        // Probably not necessary
-        //else {
-        //    // No overflow: set the whole thing
-        //    const_cast<SdrTextObj*>(this)->SetOutlinerParaObject(pNewText);
-        //}
-    }
-
-    return;
-
-    // Begin old code
-
-    bool bIsPageOverflow;
-
-    bIsPageOverflow = pEdtOutl->IsPageOverflow();
-
-    // Propagates the need for change
-    SetToBeChained( bIsPageOverflow );
-    fprintf(stderr, "[CHAINING] Need for Chaining is %s\n",
-        bIsPageOverflow ? "TRUE" : "FALSE");
-
-    if ( bIsPageOverflow ) {
-        onOverflowStatusEvent();
-    } else {
-        onUnderflowStatusEvent();
+        }
     }
 }
 
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index cd107d5..5b6bdba 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -678,11 +678,6 @@ namespace
     }
 } // end of anonymous namespace
 
-void impSetOutlinerToEmptyTxt(SdrOutliner *pOutliner)
-{
-    OutlinerParaObject *pEmptyTxt = pOutliner->GetEmptyParaObject();
-    pOutliner->SetText(*pEmptyTxt);
-}
 
 // primitive decompositions
 
@@ -736,152 +731,6 @@ void SdrTextObj::impDecomposeContourTextPrimitive(
     rTarget = aConverter.getPrimitive2DSequence();
 }
 
-OutlinerParaObject *SdrTextObj::impGetNonOverflowingParaObject(SdrOutliner *pOutliner) const
-{
-    NonOverflowingText *pNonOverflowingTxt;
-    // We have to get text from the editing outliner if this is set (but not if this is part of an underflow process since pEdtOutl does not know much in that case)
-    bool bThereIsUnderflowGoingOn = GetTextChain()->GetNilChainingEvent(const_cast<SdrTextObj*>(this));
-    if (pEdtOutl != NULL
-        && !bThereIsUnderflowGoingOn) // this is equivalent to checking for not(underflow-caused overflow)
-        pNonOverflowingTxt =
-                pEdtOutl->GetNonOverflowingText();
-    else
-        pNonOverflowingTxt =
-                pOutliner->GetNonOverflowingText();
-
-    //pOutliner->Clear();
-    //pOutliner->SetStyleSheet( 0, pEdtOutl->GetStyleSheet(0));
-
-    if (pNonOverflowingTxt->mPreOverflowingTxt == "" &&
-        pNonOverflowingTxt->mpHeadParas != NULL) {
-        // Only (possibly empty) paragraphs before overflowing one
-        pOutliner->SetText(*pNonOverflowingTxt->mpHeadParas);
-    } else { // We have to include the non-overflowing lines from the overfl. para
-
-        // first make a ParaObject for the strings
-        impSetOutlinerToEmptyTxt(pOutliner);
-        Paragraph *pTmpPara0 = pOutliner->GetParagraph(0);
-        pOutliner->SetText(pNonOverflowingTxt->mPreOverflowingTxt, pTmpPara0);
-        OutlinerParaObject *pPObj = pOutliner->CreateParaObject();
-        //pOutliner->Clear();
-        //pOutliner->SetStyleSheet( 0, pEdtOutl->GetStyleSheet(0));
-
-        if (pNonOverflowingTxt->mpHeadParas != NULL) {
-            pOutliner->SetText(*pNonOverflowingTxt->mpHeadParas);
-            pOutliner->AddText(*pPObj);
-         } else  if (pNonOverflowingTxt->mPreOverflowingTxt != "") { // only preoverflowing txt
-            //OutlinerParaObject *pEmptyPObj = pOutliner->GetEmptyParaObject();
-            //pOutliner->SetText(*pEmptyPObj);
-            pOutliner->SetText(*pPObj);
-        } else { // no text // This case is redundant but it doesn't hurt for now
-            pOutliner->Clear();
-        }
-    }
-
-     return pOutliner->CreateParaObject();
-}
-
-/* Following function should not be called while decomposing static text */
-void SdrTextObj::impLeaveOnlyNonOverflowingText(SdrOutliner *pOutliner) const
-{
-    OutlinerParaObject *pNewText = impGetNonOverflowingParaObject(pOutliner);
-
-    if (pEdtOutl != NULL) {
-        pEdtOutl->SetText(*pNewText);
-    }
-    // adds it to current outliner anyway (useful in static decomposition)
-    pOutliner->SetText(*pNewText);
-    /*if (bInUnderflow) // must make a broadcast to reset underflow (XXX: can I reset it from here?)
-        const_cast<SdrTextObj*>(this)->SetOutlinerParaObject(pNewText);
-    else*/
-    const_cast<SdrTextObj*>(this)->NbcSetOutlinerParaObject(pNewText);
-}
-
-OutlinerParaObject *SdrTextObj::impGetOverflowingParaObject(SdrOutliner *pOutliner, SdrTextObj *pNextTextObj) const
- {
-
-    if (mpOverflowingText == NULL)
-        return NULL;
-
-    OutlinerParaObject *pCurTxt = pNextTextObj->GetOutlinerParaObject();
-    pOutliner->SetText(*pCurTxt);
-
-    // Get text of first paragraph of destination box
-    Paragraph *pOldPara0 = pOutliner->GetParagraph(0);
-    OUString aOldPara0Txt;
-    if (pOldPara0)
-        aOldPara0Txt = pOutliner->GetText(pOldPara0);
-
-    // Get other paras of destination box (from second on)
-    OutlinerParaObject *pOldParasTail = NULL;
-    if (pOutliner->GetParagraphCount() > 1)
-        pOldParasTail = pOutliner->CreateParaObject(1);
-
-    // Create ParaObject appending old first para in the dest. box
-    //   to last part of overflowing text
-    Paragraph *pTmpPara0 = NULL;
-    OutlinerParaObject *pJoiningPara = NULL;
-
-    if (pOldPara0) {
-        //pOutliner->Clear(); // you need a clear outliner here
-        impSetOutlinerToEmptyTxt(pOutliner);
-
-        pTmpPara0 = pOutliner->GetParagraph(0);
-        pOutliner->SetText(mpOverflowingText->GetEndingLines() + aOldPara0Txt, pTmpPara0);
-        pJoiningPara = pOutliner->CreateParaObject();
-    }
-
-    // start actual composition
-    //pOutliner->Clear();
-    impSetOutlinerToEmptyTxt(pOutliner);
-
-    // Set headText at the beginning of box
-    OUString aHeadTxt = mpOverflowingText->GetHeadingLines();
-    // If we haven't used heading text yet
-    if (mpOverflowingText->HasOtherParas()) {
-        Paragraph *pNewPara0 = pOutliner->GetParagraph(0);
-        pOutliner->SetText(aHeadTxt, pNewPara0);
-    }
-
-    // Set all the intermediate Paras
-    if (mpOverflowingText->mpMidParas)
-        pOutliner->AddText(*mpOverflowingText->mpMidParas);
-
-    // Append old first para in the destination box to
-    //   last part of overflowing text
-    if (pJoiningPara && mpOverflowingText->HasOtherParas())
-        pOutliner->AddText(*pJoiningPara);
-    // this second case is if there is to avoid getting an empty line before pJoiningPara
-    else if (pJoiningPara && !mpOverflowingText->HasOtherParas())
-        pOutliner->SetText(*pJoiningPara);
-
-    // Append all other old paras
-    if (pOldParasTail)
-        pOutliner->AddText(*pOldParasTail);
-
-    // Draw everything
-    OutlinerParaObject *pNewText = pOutliner->CreateParaObject();
-    return pNewText;
-}
-
-void SdrTextObj::impMoveChainedTextToNextLink(SdrOutliner *pOutliner, SdrTextObj *pNextTextObj) const
-{
-    // prevent copying text in same box
-    if ( this ==  pNextTextObj )
-        return;
-
-    //pOutliner->SetChainingEventHdl(LINK(this,SdrTextObj,ImpDecomposeChainedText));
-
-    if (mpOverflowingText == NULL)
-        return;
-
-    OutlinerParaObject *pNewText = impGetOverflowingParaObject(pOutliner, pNextTextObj);
-    if (pNewText)
-        pNextTextObj->NbcSetOutlinerParaObject(pNewText);
-
-//    pOutliner->SetChainingEventHdl(Link());
-
-}
 
 void SdrTextObj::impDecomposeAutoFitTextPrimitive(
     drawinglayer::primitive2d::Primitive2DSequence& rTarget,
@@ -1637,7 +1486,7 @@ void SdrTextObj::impDecomposeChainedTextPrimitive(
     // Sets original text
     rOutliner.SetText(*pOutlinerParaObject);
 
-    /* Begin underflow handling */
+    /* Begin overflow/underflow handling */
 
      // any parameter in the constructor?
      // We need the outliner we get the overflow info from as well as
@@ -1667,63 +1516,7 @@ void SdrTextObj::impDecomposeChainedTextPrimitive(
         aTxtChainFlow.ExecuteOverflow(&rOutliner, &rChainingOutl);
     }
 
-    /*
-
-    // Begin old code
-    bool bIsPageUnderflow = !rOutliner.IsPageOverflow() && !IsInEditMode();
-    if (bIsPageUnderflow) {
-
-        SdrTextObj *pNextLink = GetNextLinkInChain();
-        if (pNextLink && pNextLink->HasText()) {
-            OutlinerParaObject *pNextLinkWholeText = pNextLink->GetOutlinerParaObject();
-
-            // making whole text
-            OutlinerParaObject *pCurText;
-            pCurText = rOutliner.CreateParaObject(); // XXX: this is editing outliner in editing version
-
-            // NewTextForCurBox = Txt(CurBox) ++ Txt(NextBox)
-            rOutliner.SetText(*pCurText);
-            rOutliner.AddText(*pNextLinkWholeText);
-            OutlinerParaObject *pNewText = rOutliner.CreateParaObject();
-
-            // Set the other box empty so if overflow does not occur we are fine
-            if (!GetPreventChainable())
-                pNextLink->NbcSetOutlinerParaObject(rOutliner.GetEmptyParaObject());
-
-            const_cast<SdrTextObj*>(this)->NbcSetOutlinerParaObject(pNewText);
-        }
-    } // You might be done at this point, unless there is an overflow and that's handled in std way.
-    */
-    /* End underflow handling */
-
-
-    /* Begin overflow handling */ // might be caused from underflow handling above
-    /*
-    // If overflow occurs we have to cut the text at the right point
-    // If in edit mode ImpEditEngine should have taken care of this
-    if ( rOutliner.IsPageOverflow() && !IsInEditMode()) {
-        // Save the overflowing text before changing the outliner's state
-        const_cast<SdrTextObj*>(this)->mpOverflowingText = rOutliner.GetOverflowingText();
-
-        // Leave only non overflowing text
-        impLeaveOnlyNonOverflowingText(&rOutliner);
-
-        // Initialize Chaining Outliner
-        SdrOutliner &rChainingOutl = pModel->GetChainingOutliner(this);
-        ImpInitDrawOutliner( rChainingOutl );
-        rChainingOutl.SetUpdateMode(true);
-
-        // Transfer of text to next link
-        if (GetNextLinkInChain()
-            && !GetPreventChainable() ) // we don't transfer text while dragging because of resizing
-        {
-            impMoveChainedTextToNextLink(&rChainingOutl, GetNextLinkInChain());
-        }
-
-    }
-
-    */
-    /* End overflow handling */
+    /* End overflow/underflow handling */
 
     // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
     rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));


More information about the Libreoffice-commits mailing list