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

matteocam matteo.campanelli at gmail.com
Thu Jul 9 11:35:37 PDT 2015


 editeng/source/outliner/overflowingtxt.cxx |  102 -----------------------------
 include/svx/textchain.hxx                  |    5 -
 include/svx/textchainflow.hxx              |    1 
 svx/source/svdraw/svdedxv.cxx              |   26 ++++---
 svx/source/svdraw/textchain.cxx            |    1 
 svx/source/svdraw/textchainflow.cxx        |   33 ++-------
 6 files changed, 32 insertions(+), 136 deletions(-)

New commits:
commit 8151008453e5fdac0ecf851274f916965acd7045
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 9 14:34:31 2015 -0400

    Don't set new position after tranferring cursor
    
    Change-Id: I3d3d716ed05c6ffac001306850a73fb2280a40bb

diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index d0e77dd..5e00942 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -549,7 +549,7 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
                 SdrBeginTextEdit(pNextLink);
                 // OutlinerView has changed, so we update the pointer
                 pOLV = GetTextEditOutlinerView();
-                pOLV->SetSelection(pTextChain->GetPostChainingSel(pTextObj));
+                //pOLV->SetSelection(pTextChain->GetPostChainingSel(pTextObj)); // XXX
 
                 break;
             case CursorChainingEvent::TO_PREV_LINK:
commit 1dde1fdd2f15cd8e010c18f14a3b6d6fce099aee
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 9 11:39:43 2015 -0400

    Fix cross initialization in switch
    
    Change-Id: Ifc41ae8ce8eb7c4a607790b29079f9a792ba1859

diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 9589d87..d0e77dd 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -549,8 +549,7 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
                 SdrBeginTextEdit(pNextLink);
                 // OutlinerView has changed, so we update the pointer
                 pOLV = GetTextEditOutlinerView();
-                ESelection aPostChainingSel(pTextChain->GetPostChainingSel(pTextObj));
-                pOLV->SetSelection(aPostChainingSel);
+                pOLV->SetSelection(pTextChain->GetPostChainingSel(pTextObj));
 
                 break;
             case CursorChainingEvent::TO_PREV_LINK:
commit 6445d4d5004396af69632bde1708714593af292d
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Wed Jul 8 23:56:24 2015 -0400

    Set Position of Cursor in Dest Box after chaining
    
    Change-Id: I399e4ab82cb1d6089043cfa801e9e6e948eca9f9

diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx
index 304e04b..868daa6 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -87,39 +87,6 @@ OutlinerParaObject *OverflowingText::GetJuxtaposedParaObject(Outliner *pOutl, Ou
     return pPObj;
 }
 
-/*
-ESelection OverflowingText::impGetEndSelection(Outliner *pOutl) const
-{
-    const sal_Int32 nParaCount = pOutl->GetParagraphCount();
-    const sal_Int32 nLastParaIndex = nParaCount > 1 ? nParaCount - 1 : 0;
-    Paragraph* pLastPara = pOutl->GetParagraph( nLastParaIndex);
-    const sal_Int32 nLenLastPara = pOutl->GetText(pLastPara).getLength();
-    // Selection at end of editing area
-    ESelection aEndSel(nLastParaIndex,nLenLastPara,nLastParaIndex,nLenLastPara);
-    return aEndSel;
-}
-* */
-
-/*
-OUString OverflowingText::GetEndingLines() const
-{
-    // If the only overflowing part is some lines in a paragraph,
-    // the end of the overflowing text is its head.
-    if (!HasOtherParas())
-        return mHeadTxt;
-
-    return mTailTxt;
-}
-
-OUString OverflowingText::GetHeadingLines() const
-{
-    return mHeadTxt;
-}
-* */
-
-
-
-
 OFlowChainedText::OFlowChainedText(Outliner *pOutl)
 {
     mpOverflowingTxt = pOutl->GetOverflowingText();
@@ -143,74 +110,6 @@ OutlinerParaObject *OFlowChainedText::CreateOverflowingParaObject(Outliner *pOut
         return NULL;
 
     return mpOverflowingTxt->GetJuxtaposedParaObject(pOutliner, pTextToBeMerged );
-
-    /*
-    if (mpOverflowingTxt == NULL || pTextToBeMerged == NULL)
-        return NULL;
-
-    pOutliner->SetText(*pTextToBeMerged);
-
-    // 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
-        pOutliner->SetToEmptyText();
-
-        pTmpPara0 = pOutliner->GetParagraph(0);
-        pOutliner->SetText(mpOverflowingTxt->GetEndingLines() + aOldPara0Txt, pTmpPara0);
-        pJoiningPara = pOutliner->CreateParaObject();
-    }
-
-    // Create a Para Object out of mpMidParas
-    // (in order to use the SfxItemPool of the current outliner
-    //  instead of the ones currently in mpMidParas)
-
-    // start actual composition
-    //pOutliner->Clear();
-    pOutliner->SetToEmptyText();
-
-    // Set headText at the beginning of box
-    OUString aHeadTxt = mpOverflowingTxt->GetHeadingLines();
-    // If we haven't used heading text yet
-    if (mpOverflowingTxt->HasOtherParas()) {
-        Paragraph *pNewPara0 = pOutliner->GetParagraph(0);
-        pOutliner->SetText(aHeadTxt, pNewPara0);
-    }
-
-    // Set all the intermediate Paras
-    if (mpOverflowingTxt->mpMidParas)
-        pOutliner->AddText(*mpOverflowingTxt->mpMidParas);
-
-    // Append old first para in the destination box to
-    //   last part of overflowing text
-    if (pJoiningPara && mpOverflowingTxt->HasOtherParas())
-        pOutliner->AddText(*pJoiningPara);
-    // this second case is if there is to avoid getting an empty line before pJoiningPara
-    else if (pJoiningPara && !mpOverflowingTxt->HasOtherParas())
-        pOutliner->SetText(*pJoiningPara);
-
-    // Append all other old paras
-    if (pOldParasTail)
-        pOutliner->AddText(*pOldParasTail);
-
-    // Draw everything
-    OutlinerParaObject *pNewText = pOutliner->CreateParaObject();
-    return pNewText;
-    * */
 }
 
 OutlinerParaObject *OFlowChainedText::CreateNonOverflowingParaObject(Outliner *pOutliner)
@@ -221,7 +120,6 @@ OutlinerParaObject *OFlowChainedText::CreateNonOverflowingParaObject(Outliner *p
     return mpNonOverflowingTxt->ToParaObject(pOutliner);
 }
 
-
 UFlowChainedText::UFlowChainedText(Outliner *pOutl)
 {
     mpUnderflowPObj = pOutl->CreateParaObject();
diff --git a/include/svx/textchain.hxx b/include/svx/textchain.hxx
index 7920a72..69b197e 100644
--- a/include/svx/textchain.hxx
+++ b/include/svx/textchain.hxx
@@ -116,6 +116,7 @@ class ImpChainLinkProperties
         INIT_CHAIN_PROP(NilChainingEvent, false)
         INIT_CHAIN_PROP(CursorEvent, CursorChainingEvent::NULL_EVENT)
         INIT_CHAIN_PROP(PreChainingSel, ESelection(0,0,0,0));
+        INIT_CHAIN_PROP(PostChainingSel, ESelection(0,0,0,0));
     }
 
     private:
@@ -123,6 +124,7 @@ class ImpChainLinkProperties
     DECL_CHAIN_PROP(NilChainingEvent, bool)
     DECL_CHAIN_PROP(CursorEvent, CursorChainingEvent)
     DECL_CHAIN_PROP(PreChainingSel, ESelection)
+    DECL_CHAIN_PROP(PostChainingSel, ESelection)
 
 };
 
@@ -144,8 +146,7 @@ class TextChain {
     DECL_CHAIN_PROP_INTERFACE(CursorEvent, CursorChainingEvent)
     DECL_CHAIN_PROP_INTERFACE(NilChainingEvent, bool)
     DECL_CHAIN_PROP_INTERFACE(PreChainingSel, ESelection)
-
-
+    DECL_CHAIN_PROP_INTERFACE(PostChainingSel, ESelection)
 
     // return whether a paragraph is split between the two links in the argument
     bool GetLinksHaveMergeableFirstPara(SdrTextObj *, SdrTextObj *);
diff --git a/include/svx/textchainflow.hxx b/include/svx/textchainflow.hxx
index 00a04f3..f96ce59 100644
--- a/include/svx/textchainflow.hxx
+++ b/include/svx/textchainflow.hxx
@@ -67,6 +67,7 @@ class TextChainFlow {
     bool mbPossiblyCursorOut;
     CursorChainingEvent maCursorEvent;
     ESelection maOverflowPosSel;
+    ESelection maPostChainingSel;
 
 
     void impCheckForFlowEvents(SdrOutliner *, SdrOutliner *);
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 16373c3..9589d87 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -539,17 +539,26 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
     switch ( pTextChain->GetCursorEvent(pTextObj) ) {
 
             case CursorChainingEvent::UNCHANGED:
-                    pOLV->SetSelection(pTextChain->GetPreChainingSel(pTextObj));
-                    break;
+                // Set same selection as before the chainging
+                // We need an explicit set because the Outliner is messed up
+                //    after text transfer and otherwise it brings us at arbitrary positions.
+                pOLV->SetSelection(pTextChain->GetPreChainingSel(pTextObj));
+                break;
             case CursorChainingEvent::TO_NEXT_LINK:
-                    SdrEndTextEdit();
-                    SdrBeginTextEdit(pNextLink);
-                    //SdrEndTextEdit(true);
-                    //SdrBeginTextEdit(pNextLink, nullptr, nullptr, false, nullptr, nullptr, true, true);
-                    break;
+                SdrEndTextEdit();
+                SdrBeginTextEdit(pNextLink);
+                // OutlinerView has changed, so we update the pointer
+                pOLV = GetTextEditOutlinerView();
+                ESelection aPostChainingSel(pTextChain->GetPostChainingSel(pTextObj));
+                pOLV->SetSelection(aPostChainingSel);
+
+                break;
             case CursorChainingEvent::TO_PREV_LINK:
-                    // XXX: To be handled
-                    break;
+                // XXX: To be handled
+                break;
+            case CursorChainingEvent::NULL_EVENT:
+                // Do nothing here
+                break;
     }
 
     // Reset event
diff --git a/svx/source/svdraw/textchain.cxx b/svx/source/svdraw/textchain.cxx
index 270712e..a7bd1b6 100644
--- a/svx/source/svdraw/textchain.cxx
+++ b/svx/source/svdraw/textchain.cxx
@@ -27,6 +27,7 @@
 IMPL_CHAIN_PROP_INTERFACE(CursorEvent, CursorChainingEvent)
 IMPL_CHAIN_PROP_INTERFACE(NilChainingEvent, bool)
 IMPL_CHAIN_PROP_INTERFACE(PreChainingSel, ESelection)
+IMPL_CHAIN_PROP_INTERFACE(PostChainingSel, ESelection)
 
 /* End Definition of Properties Interface */
 
diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx
index 1df7fe3..ac1a805 100644
--- a/svx/source/svdraw/textchainflow.cxx
+++ b/svx/source/svdraw/textchainflow.cxx
@@ -45,7 +45,10 @@ TextChainFlow::TextChainFlow(SdrTextObj *pChainTarget)
 
 TextChainFlow::~TextChainFlow()
 {
-
+    if (mpOverflChText)
+        delete mpOverflChText;
+    if (mpUnderflChText)
+        delete mpUnderflChText;
 }
 
 void TextChainFlow::impSetFlowOutlinerParams(SdrOutliner *, SdrOutliner *)
@@ -105,8 +108,10 @@ void TextChainFlow::impUpdateCursorInfo()
     // if this is not an OF triggered during an UF
 
     mbPossiblyCursorOut = bOverflow && !mbOFisUFinduced;
-    if (mbPossiblyCursorOut) {
+    if (mbPossiblyCursorOut) { // if this is false, mpOverflChText might be NULL
         maOverflowPosSel = ESelection(mpOverflChText->GetOverflowPointSel());
+        // After the chaining event the cursor is where the text from the source box merged with the rest
+        maPostChainingSel = ESelection(mpOverflChText->GetInsertionPointSel());
     }
 }
 
@@ -241,23 +246,6 @@ void EditingTextChainFlow::CheckForFlowEvents(SdrOutliner *pFlowOutl)
     impBroadcastCursorInfo();
 }
 
-/*
-void EditingTextChainFlow::ExecuteOverflow(SdrOutliner *pOutl1, SdrOutliner *pOutl2)
-{
-
-
-    impSetTextForEditingOutliner
-
-    // Set cursor
-    pEditView->pImpEditView->SetEditSelection( aCurSel );
-    pEditView->pImpEditView->DrawSelection();
-    pEditView->ShowCursor( true, false );
-
-
-}
-*
-* */
-
 void EditingTextChainFlow::impLeaveOnlyNonOverflowingText(SdrOutliner *pNonOverflOutl)
 {
     OutlinerParaObject *pNewText = impGetNonOverflowingParaObject(pNonOverflOutl);
@@ -279,27 +267,26 @@ void EditingTextChainFlow::impSetFlowOutlinerParams(SdrOutliner *pFlowOutl, SdrO
     pFlowOutl->SetMaxAutoPaperSize(pParamOutl->GetMaxAutoPaperSize());
     pFlowOutl->SetMinAutoPaperSize(pParamOutl->GetMinAutoPaperSize());
     pFlowOutl->SetPaperSize(pParamOutl->GetPaperSize());
-
-    // Set right text attributes // XXX: Not enough: it does not handle complex attributes
-    //pFlowOutl->SetEditTextObjectPool(pParamOutl->GetEditTextObjectPool());
 }
 
 void EditingTextChainFlow::impBroadcastCursorInfo() const
 {
     bool bCursorOut = false;
 
+    // NOTE: I handled already the stuff for the comments below. They will be kept temporarily till stuff settles down.
     // Possibility: 1) why don't we stop passing the actual event to the TextChain and instead we pass
     //              the overflow pos and mbPossiblyCursorOut
     //              2) We pass the current selection before anything happens and we make impBroadcastCursorInfo compute it.
 
     if (mbPossiblyCursorOut) {
         ESelection aPreChainingSel = GetTextChain()->GetPreChainingSel(GetLinkTarget()) ;
+        // Test whether the cursor is out of the box.
         bCursorOut = maOverflowPosSel.IsLess(aPreChainingSel);
     }
 
     if (bCursorOut) {
             //maCursorEvent = CursorChainingEvent::TO_NEXT_LINK;
-            // XXX: GetTextChain()->SetPostChainingPos()sdasd)
+            GetTextChain()->SetPostChainingSel(GetLinkTarget(), maPostChainingSel);
             GetTextChain()->SetCursorEvent(GetLinkTarget(), CursorChainingEvent::TO_NEXT_LINK);
     } else {
         //maCursorEvent = CursorChainingEvent::UNCHANGED;


More information about the Libreoffice-commits mailing list