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

matteocam matteo.campanelli at gmail.com
Wed Jun 10 15:44:47 PDT 2015


 include/svx/svdotext.hxx                    |    7 -
 svx/source/svdraw/svdotext.cxx              |   12 +-
 svx/source/svdraw/svdotextdecomposition.cxx |  138 +++++++++++++++-------------
 svx/source/svdraw/svdotxed.cxx              |    2 
 4 files changed, 86 insertions(+), 73 deletions(-)

New commits:
commit 2e66cafe5bdef5a0c64c190b0b73a7db61dcc3a1
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Wed Jun 10 18:43:29 2015 -0400

    Passed right outliner around
    
    Change-Id: I7eeb193e53926093e91393667ab9c788ebebda9d

diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 964ee43..0552029 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -608,9 +608,10 @@ public:
         const drawinglayer::primitive2d::SdrChainedTextPrimitive2D& rSdrChainedTextPrimitive,
         const drawinglayer::geometry::ViewInformation2D& aViewInformation) const;
 
-    void impMoveChainedTextToNextLink(SdrTextObj *pNextTextObj) const;
-    OutlinerParaObject *impGetNonOverflowingParaObject() const;
-    void impLeaveOnlyNonOverflowingText() 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;
 
     // Handler for Chained Text
     DECL_LINK(ImpDecomposeChainedText,bool*);
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index bf46cb9..82b883f 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1958,11 +1958,10 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
 
 void SdrTextObj::onOverflowStatusEvent( bool bIsPageOverflow )
 {
-    // FIXME: Should have a IsChainable or something.
-    if (IsAutoGrowWidth() || IsAutoGrowHeight() || IsAutoFit())
+    if (!IsChainable())
         return;
 
-    if ( GetNextLinkInChain() != NULL ) // is this a chainable object?
+    if ( GetNextLinkInChain() != NULL ) // is there anything to transfer text to?
     {
         // set whether there is need for chaining
         // (used in EndTextEdit to crop the overflowing part)
@@ -1973,17 +1972,18 @@ void SdrTextObj::onOverflowStatusEvent( bool bIsPageOverflow )
 
         // Pushes text in next link on the fly
         if ( bIsPageOverflow ) {
+            SdrOutliner &aDrawOutliner = ImpGetDrawOutliner();
             if (pEdtOutl != NULL)
                 mpOverflowingText = pEdtOutl->GetOverflowingText();
             else
-                mpOverflowingText = ImpGetDrawOutliner().GetOverflowingText();
+                mpOverflowingText = aDrawOutliner.GetOverflowingText();
 
             SdrTextObj *pNextTextObj = GetNextLinkInChain();
 
-            impLeaveOnlyNonOverflowingText();
+            impLeaveOnlyNonOverflowingText(&aDrawOutliner);
 
             // Transfer overflowing text
-            impMoveChainedTextToNextLink(pNextTextObj);
+            impMoveChainedTextToNextLink(&aDrawOutliner, pNextTextObj);
         }
 
     }
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index 88f6136..9fff4c0 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -732,36 +732,36 @@ OutlinerParaObject *SdrTextObj::impGetNonOverflowingParaObject(SdrOutliner *pOut
 {
     NonOverflowingText *pNonOverflowingTxt;
     pNonOverflowingTxt =
-            rOutliner.GetNonOverflowingText();
+            pOutliner->GetNonOverflowingText();
 
-    pOutliner.Clear();
-    //pOutliner.SetStyleSheet( 0, pEdtOutl->GetStyleSheet(0));
+    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);
+        pOutliner->SetText(*pNonOverflowingTxt->mpHeadParas);
     } else { // We have to include the non-overflowing lines from the overfl. para
 
         // first make a ParaObject for the strings
-        Paragraph *pTmpPara0 = pOutliner.GetParagraph(0);
-        pOutliner.SetText(pNonOverflowingTxt->mPreOverflowingTxt, pTmpPara0);
-        OutlinerParaObject *pPObj = pOutliner.CreateParaObject();
-        pOutliner.Clear();
-        //pOutliner.SetStyleSheet( 0, pEdtOutl->GetStyleSheet(0));
+        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->SetText(*pNonOverflowingTxt->mpHeadParas);
 
-        pOutliner.AddText(*pPObj);
+        pOutliner->AddText(*pPObj);
     }
 
-     return pOutliner.CreateParaObject();
+     return pOutliner->CreateParaObject();
 }
 
 void SdrTextObj::impLeaveOnlyNonOverflowingText(SdrOutliner *pOutliner) const
 {
-    OutlinerParaObject *pNewText = impGetNonOverflowingParaObject();
+    OutlinerParaObject *pNewText = impGetNonOverflowingParaObject(pOutliner);
     // we need this when we are in editing mode
     if (pEdtOutl != NULL)
         pEdtOutl->SetText(*pNewText);
@@ -769,72 +769,83 @@ void SdrTextObj::impLeaveOnlyNonOverflowingText(SdrOutliner *pOutliner) const
     const_cast<SdrTextObj*>(this)->SetOutlinerParaObject(pNewText);
 }
 
+OutlinerParaObject *SdrTextObj::impGetOverflowingParaObject(SdrOutliner *pOutliner, SdrTextObj *pNextTextObj) const
+ {
 
-void SdrTextObj::impMoveChainedTextToNextLink(SdrOutliner *pOutliner, SdrTextObj *pNextTextObj) const
-{
-    // prevent copying text in same box
-    if ( this ==  pNextTextObj )
-        return;
+    if (mpOverflowingText == NULL)
+        return NULL;
 
-    //pOutliner.SetChainingEventHdl(LINK(this,SdrTextObj,ImpDecomposeChainedText));
+    // XXX: Not sure if necessary
+    pOutliner->Clear();
 
-    if (mpOverflowingText != NULL) {
-        // XXX: Not sure if necessary
-        pOutliner.Clear();
+    OutlinerParaObject *pCurTxt = pNextTextObj->GetOutlinerParaObject();
+    pOutliner->SetText(*pCurTxt);
 
-        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 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);
 
-        // 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;
 
-        // 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();
 
-        if (pOldPara0) {
-            pOutliner.Clear();
+        pTmpPara0 = pOutliner->GetParagraph(0);
+        pOutliner->SetText(mpOverflowingText->mTailTxt + aOldPara0Txt, pTmpPara0);
+        pJoiningPara = pOutliner->CreateParaObject();
+    }
 
-            pTmpPara0 = pOutliner.GetParagraph(0);
-            pOutliner.SetText(mpOverflowingText->mTailTxt + aOldPara0Txt, pTmpPara0);
-            pJoiningPara = pOutliner.CreateParaObject();
-        }
+    // start actual composition
+    pOutliner->Clear();
+
+    // Set headText at the beginning of box
+    Paragraph *pNewPara0 = pOutliner->GetParagraph(0);
+    pOutliner->SetText(mpOverflowingText->mHeadTxt, pNewPara0);
+
+    // Set all the intermediate Paras
+    if (mpOverflowingText->mpMidParas)
+        pOutliner->AddText(*mpOverflowingText->mpMidParas);
 
-        // start actual composition
-        pOutliner.Clear();
+    // Append old first para in the destination box to
+    //   last part of overflowing text
+    if (pJoiningPara)
+        pOutliner->AddText(*pJoiningPara);
 
-        // Set headText at the beginning of box
-        Paragraph *pNewPara0 = pOutliner.GetParagraph(0);
-        pOutliner.SetText(mpOverflowingText->mHeadTxt, pNewPara0);
+    // Append all other old paras
+    if (pOldParasTail)
+        pOutliner->AddText(*pOldParasTail);
 
-        // Set all the intermediate Paras
-        if (mpOverflowingText->mpMidParas)
-            pOutliner.AddText(*mpOverflowingText->mpMidParas);
+    // Draw everything
+    OutlinerParaObject *pNewText = pOutliner->CreateParaObject();
+    return pNewText;
+ }
 
-        // Append old first para in the destination box to
-        //   last part of overflowing text
-        if (pJoiningPara)
-            pOutliner.AddText(*pJoiningPara);
+void SdrTextObj::impMoveChainedTextToNextLink(SdrOutliner *pOutliner, SdrTextObj *pNextTextObj) const
+{
+    // prevent copying text in same box
+    if ( this ==  pNextTextObj )
+        return;
 
-        // Append all other old paras
-        if (pOldParasTail)
-            pOutliner.AddText(*pOldParasTail);
+    //pOutliner->SetChainingEventHdl(LINK(this,SdrTextObj,ImpDecomposeChainedText));
 
-        // Draw everything
-        OutlinerParaObject *pNewText = pOutliner.CreateParaObject();
+    if (mpOverflowingText == NULL)
+        return;
+
+    OutlinerParaObject *pNewText = impGetOverflowingParaObject(pOutliner, pNextTextObj);
+    if (pNewText)
         pNextTextObj->NbcSetOutlinerParaObject(pNewText);
-    }
 
-//    pOutliner.SetChainingEventHdl(Link());
+//    pOutliner->SetChainingEventHdl(Link());
 
 }
 
@@ -1624,8 +1635,9 @@ void SdrTextObj::impDecomposeChainedTextPrimitive(
 
     // If overflow occurs we have to cut the text at the right point
     if ( rOutliner.IsPageOverflow() ) {
-        const OutlinerParaObject *pNewTxt = impGetNonOverflowingParaObject();
+        const OutlinerParaObject *pNewTxt = impGetNonOverflowingParaObject(&rOutliner);
         rOutliner.SetText(*pNewTxt);
+
         // XXX: Order transfer of stuff in next link here
     }
 
diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx
index 570e284..4811606 100644
--- a/svx/source/svdraw/svdotxed.cxx
+++ b/svx/source/svdraw/svdotxed.cxx
@@ -288,7 +288,7 @@ void SdrTextObj::EndTextEdit(SdrOutliner& rOutl)
             // XXX: FRESHLY COMMENTED (5/6/15) // FIXME:matteocam
             //pNewText = rOutl.CreateParaObject( 0, nParaAnz );
 
-            pNewText = impGetNonOverflowingParaObject();
+            pNewText = impGetNonOverflowingParaObject(&rOutl);
 
             // set non overflow part of text to current box
 


More information about the Libreoffice-commits mailing list