editeng/source/outliner/overflowingtxt.cxx |   78 +++++++++++++++++++++++------
 include/editeng/overflowingtxt.hxx         |    3 +
 2 files changed, 65 insertions(+), 16 deletions(-)

New commits:
commit d35ecc609fa55835f3942656dcd9330c24dc4521
Author: matteocam <matteo.campane...@gmail.com>
Date:   Mon Jul 13 14:08:00 2015 -0400

    Add impGetDeeplyMergedParaObject. But with juxtaposition semantics
    
    Change-Id: Idd8d8d39d7ddabc9bdfe416250c6611b21f74e11

diff --git a/editeng/source/outliner/overflowingtxt.cxx 
b/editeng/source/outliner/overflowingtxt.cxx
index eb6bfe5..6a73775 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -26,7 +26,7 @@
 #include <editeng/editobj.hxx>
 
 
-// Helper function for *OverflowingText classes
+/* Helper functions for *OverflowingText classes  */
 
 ESelection getLastPositionSel(const EditTextObject *pTObj)
 {
@@ -40,6 +40,34 @@ ESelection getLastPositionSel(const EditTextObject *pTObj)
     return aEndPos;
 }
 
+// Put a para next to each other in the same OutlinerParaObject
+OutlinerParaObject *impGetJuxtaposedParaObject(Outliner *pOutl,
+                                               OutlinerParaObject *pPObj1,
+                                               OutlinerParaObject *pPObj2)
+{
+    assert(pOutl && pPObj1 &&  pPObj2);
+
+    pOutl->SetText(*pPObj1);
+    pOutl->AddText(*pPObj2);
+    OutlinerParaObject *pPObj = pOutl->CreateParaObject();
+
+    return pPObj;
+}
+
+OutlinerParaObject *impGetDeeplyMergedParaObject(Outliner *pOutl,
+                                               OutlinerParaObject *pPObj1,
+                                               OutlinerParaObject *pPObj2)
+{ // XXX: For now just the same
+
+    assert(pOutl && pPObj1 &&  pPObj2);
+
+    pOutl->SetText(*pPObj1);
+    pOutl->AddText(*pPObj2);
+    OutlinerParaObject *pPObj = pOutl->CreateParaObject();
+
+    return pPObj;
+}
+
 // class OverflowingText
 
 OverflowingText::OverflowingText(EditTextObject *pTObj)
@@ -89,24 +117,35 @@ OutlinerParaObject 
*OverflowingText::GetJuxtaposedParaObject(Outliner *pOutl, Ou
         return NULL;
     }
 
-    // Simply Juxtaposing; no within-para merging
     OutlinerParaObject *pOverflowingPObj = new 
OutlinerParaObject(*mpContentTextObj);
     // the OutlinerParaObject constr. at the prev line gives no valid outliner 
mode, so we set it
     pOverflowingPObj->SetOutlinerMode(pOutl->GetOutlinerMode());
 
-    /* Actual Text Setting */
-    pOutl->SetText(*pOverflowingPObj);
+    // Simply Juxtaposing; no within-para merging
+    return impGetJuxtaposedParaObject(pOutl, pOverflowingPObj, pNextPObj);
+}
 
-    // Set selection position between new and old text
-    //maInsertionPointSel = impGetEndSelection(pOutl);  // XXX: Maybe setting 
in the constructor is just right
+OutlinerParaObject *OverflowingText::impMakeOverflowingParaObject(Outliner 
*pOutliner)
+{
+    if (mpContentTextObj == NULL) {
+        fprintf(stderr, "[Chaining] OverflowingText's mpContentTextObj is 
NULL!\n");
+        return NULL;
+    }
+
+    // Simply Juxtaposing; no within-para merging
+    OutlinerParaObject *pOverflowingPObj = new 
OutlinerParaObject(*mpContentTextObj);
+    // the OutlinerParaObject constr. at the prev line gives no valid outliner 
mode, so we set it
+    pOverflowingPObj->SetOutlinerMode(pOutliner->GetOutlinerMode());
 
-    pOutl->AddText(*pNextPObj);
+    return pOverflowingPObj;
+}
 
-    // End Text Setting
 
-    OutlinerParaObject *pPObj = pOutl->CreateParaObject();
-    //pPObj->SetOutlinerMode(pOutl->GetOutlinerMode());
-    return pPObj;
+OutlinerParaObject *OverflowingText::GetDeeplyMergedParaObject(Outliner 
*pOutliner, OutlinerParaObject *pNextPObj)
+{
+    OutlinerParaObject *pOverflowingPObj = 
impMakeOverflowingParaObject(pOutliner);
+
+    return impGetDeeplyMergedParaObject(pOutliner, pOverflowingPObj, 
pNextPObj);
 }
 
 // class OFlowChainedText
@@ -135,9 +174,13 @@ OutlinerParaObject 
*OFlowChainedText::CreateOverflowingParaObject(Outliner *pOut
     if (mpOverflowingTxt == NULL || pTextToBeMerged == NULL)
         return NULL;
 
-    return mpOverflowingTxt->GetJuxtaposedParaObject(pOutliner, 
pTextToBeMerged );
+    if (mbIsDeepMerge)
+        return mpOverflowingTxt->GetJuxtaposedParaObject(pOutliner, 
pTextToBeMerged );
+    else
+        return mpOverflowingTxt->GetDeeplyMergedParaObject(pOutliner, 
pTextToBeMerged );
 }
 
+
 OutlinerParaObject *OFlowChainedText::CreateNonOverflowingParaObject(Outliner 
*pOutliner)
 {
     if (mpNonOverflowingTxt == NULL)
@@ -162,12 +205,15 @@ UFlowChainedText::UFlowChainedText(Outliner *pOutl, bool 
bIsDeepMerge)
 
 OutlinerParaObject *UFlowChainedText::CreateMergedUnderflowParaObject(Outliner 
*pOutl, OutlinerParaObject *pNextLinkWholeText)
 {
+    OutlinerParaObject *pNewText = NULL;
     OutlinerParaObject *pCurText = mpUnderflowPObj;
 
-    // NewTextForCurBox = Txt(CurBox) ++ Txt(NextBox)
-    pOutl->SetText(*pCurText);
-    pOutl->AddText(*pNextLinkWholeText);
-    OutlinerParaObject *pNewText = pOutl->CreateParaObject();
+    if (mbIsDeepMerge) {
+        pNewText = impGetDeeplyMergedParaObject(pOutl, pCurText, 
pNextLinkWholeText);
+    } else {
+        // NewTextForCurBox = Txt(CurBox) ++ Txt(NextBox)
+        pNewText = impGetJuxtaposedParaObject(pOutl, pCurText, 
pNextLinkWholeText);
+    }
 
     return pNewText;
 
diff --git a/include/editeng/overflowingtxt.hxx 
b/include/editeng/overflowingtxt.hxx
index 345daa8..ae9b39e 100644
--- a/include/editeng/overflowingtxt.hxx
+++ b/include/editeng/overflowingtxt.hxx
@@ -42,6 +42,7 @@ class OverflowingText
 
 public:
         OutlinerParaObject *GetJuxtaposedParaObject(Outliner *, 
OutlinerParaObject *);
+        OutlinerParaObject *GetDeeplyMergedParaObject(Outliner *, 
OutlinerParaObject *);
         ESelection GetInsertionPointSel() const;
 
         //OUString GetHeadingLines() const;
@@ -53,6 +54,8 @@ private:
     // Constructor
     OverflowingText(EditTextObject *pTObj);
 
+    OutlinerParaObject *impMakeOverflowingParaObject(Outliner *pOutliner);
+
     const EditTextObject *mpContentTextObj;
 };
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to