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

matteocam matteo.campanelli at gmail.com
Tue Jun 30 13:37:52 PDT 2015


 editeng/source/outliner/overflowingtxt.cxx |   73 ++++++++++++++++++-----------
 include/editeng/overflowingtxt.hxx         |    7 +-
 2 files changed, 50 insertions(+), 30 deletions(-)

New commits:
commit 7dc421a02393f091b741f160e3895b884866cb06
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Tue Jun 30 16:36:45 2015 -0400

    Moved and commented code to get ParaObject in NonOverflowingText
    
    Change-Id: I8a011c3c0143d2f074281b9327398082a8053dc8

diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx
index 533be0d..6565a44 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -23,6 +23,51 @@
 #include <editeng/overflowingtxt.hxx>
 #include <editeng/outliner.hxx>
 
+OutlinerParaObject *NonOverflowingText::ToParaObject(Outliner *pOutliner) const
+{
+
+    // 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();
+}
 
 OUString OverflowingText::GetEndingLines() const
 {
@@ -120,33 +165,7 @@ OutlinerParaObject *OFlowChainedText::CreateNonOverflowingParaObject(Outliner *p
     if (mpNonOverflowingTxt == NULL)
         return NULL;
 
-    if (mpNonOverflowingTxt->mPreOverflowingTxt == "" &&
-        mpNonOverflowingTxt->mpHeadParas != NULL) {
-        // Only (possibly empty) paragraphs before overflowing one
-        pOutliner->SetText(*mpNonOverflowingTxt->mpHeadParas);
-    } else { // 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(mpNonOverflowingTxt->mPreOverflowingTxt, pTmpPara0);
-        OutlinerParaObject *pPObj = pOutliner->CreateParaObject();
-        //pOutliner->Clear();
-        //pOutliner->SetStyleSheet( 0, pEdtOutl->GetStyleSheet(0));
-
-        if (mpNonOverflowingTxt->mpHeadParas != NULL) {
-            pOutliner->SetText(*mpNonOverflowingTxt->mpHeadParas);
-            pOutliner->AddText(*pPObj);
-         } else  if (mpNonOverflowingTxt->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();
+    return mpNonOverflowingTxt->ToParaObject(pOutliner);
 }
 
 
diff --git a/include/editeng/overflowingtxt.hxx b/include/editeng/overflowingtxt.hxx
index 58ff247..8f67004 100644
--- a/include/editeng/overflowingtxt.hxx
+++ b/include/editeng/overflowingtxt.hxx
@@ -74,13 +74,14 @@ class EDITENG_DLLPUBLIC NonOverflowingText {
                     if (pHeadParas == NULL) // Redundant line for debugging
                         DBG_ASSERT( pHeadParas != NULL, "pHeadParas is null?! All text is overflowing then" );
                 }
+
+        OutlinerParaObject *ToParaObject(Outliner *) const;
 };
 
-// XXX: Do we also need a class for Underflow here?
 
 /*
- * classes ?FlowChainedText:
- * contains and handles the state of a text broken _after_ a flow event.
+ * classes OFlowChainedText and UFlowChainedText:
+ * contain and handle the state of a broken up text _after_ a flow event.
  *
 */
 


More information about the Libreoffice-commits mailing list