Rebased ref, commits from common ancestor:
commit e3387e02b340d8fe99f00a77364c9261b67c7713
Author: Thorsten Behrens <thorsten.behr...@cib.de>
Date:   Sun Sep 20 01:42:12 2015 +0200

    chained editeng: Convert fprintf to SAL_INFO
    
    Change-Id: I8e0cfedd34d7e0d70a30147a3bbf0f1cd8e6d3cc

diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 2298ecc..aef05f5 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -564,18 +564,13 @@ void ImpEditEngine::CheckAutoPageSize()
 
 void ImpEditEngine::CheckPageOverflow()
 {
-    // FIXME(matteocam)
-    /* fprintf( stderr, IsPageOverflow(aPaperSize, aPrevPaperSize)
-                        ? "YES Overflow!\n"  : "NO Overflow!\n" ); */
-    // setting overflow status
-
-    fprintf(stderr, "[CONTROL_STATUS] AutoPageSize is %s",  ( 
aStatus.GetControlWord() & EEControlBits::AUTOPAGESIZE ) ? "ON\n" : "OFF\n" );
+    SAL_INFO("editeng.chaining", "[CONTROL_STATUS] AutoPageSize is " << (( 
aStatus.GetControlWord() & EEControlBits::AUTOPAGESIZE ) ? "ON" : "OFF") );
 
     sal_uInt32 nBoxHeight = GetMaxAutoPaperSize().Height();
-    fprintf(stderr, "[OVERFLOW-CHECK] Current MaxAutoPaperHeight is %d\n", 
nBoxHeight);
+    SAL_INFO("editeng.chaining", "[OVERFLOW-CHECK] Current MaxAutoPaperHeight 
is " << nBoxHeight);
 
     sal_uInt32 nTxtHeight = CalcTextHeight(NULL);
-    fprintf(stderr, "[OVERFLOW-CHECK] Current Text Height is %d\n", 
nTxtHeight);
+    SAL_INFO("editeng.chaining", "[OVERFLOW-CHECK] Current Text Height is " << 
nTxtHeight);
 
     sal_uInt32 nParaCount = GetParaPortions().Count();
     sal_uInt32 nFirstLineCount = GetLineCount(0);
@@ -4638,7 +4633,7 @@ void 
ImpEditEngine::ImplUpdateOverflowingParaNum(sal_uInt32 nPaperHeight)
         if ( nY > nPaperHeight /*nCurTextHeight*/ ) // found first paragraph 
overflowing
         {
             mnOverflowingPara = nPara;
-            fprintf(stderr, "[CHAINING] Setting first overflowing #Para#: 
%d\n", nPara);
+            SAL_INFO("editeng.chaining", "[CHAINING] Setting first overflowing 
#Para#: " << nPara);
             ImplUpdateOverflowingLineNum( nPaperHeight, nPara, nY-nPH);
             return;
         }
@@ -4664,13 +4659,13 @@ void 
ImpEditEngine::ImplUpdateOverflowingLineNum(sal_uInt32 nPaperHeight,
 
         // Debugging output
         if (nLine == 0) {
-            fprintf(stderr, "[CHAINING] First line has height %d\n", nLH);
+            SAL_INFO("editeng.chaining", "[CHAINING] First line has height " 
<< nLH);
         }
 
         if ( nY > nPaperHeight ) // found first line overflowing
         {
             mnOverflowingLine = nLine;
-            fprintf(stderr, "[CHAINING] Setting first overflowing -Line- to: 
%d\n", nLine);
+            SAL_INFO("editeng.chaining", "[CHAINING] Setting first overflowing 
-Line- to: " << nLine);
             return;
         }
     }
diff --git a/editeng/source/outliner/outliner.cxx 
b/editeng/source/outliner/outliner.cxx
index f0c982f..1f077c2 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -2081,17 +2081,16 @@ NonOverflowingText *Outliner::GetNonOverflowingText() 
const
 
     // Defensive check: oveflowing para index beyond actual # of paragraphs?
     if ( nCount > GetParagraphCount()-1) {
-        fprintf(stderr,
-                "[Overflowing] Ops, trying to retrieve para %d when max index 
is %d\n",
-                nCount,
-                GetParagraphCount()-1);
+        SAL_INFO("editeng.chaining",
+                 "[Overflowing] Ops, trying to retrieve para "
+                 << nCount << " when max index is " << GetParagraphCount()-1 );
         return NULL;
     }
 
      if (nCount < 0)
      {
-        fprintf(stderr,
-                "[Overflowing] No Overflowing text but GetNonOverflowinText 
called?!\n");
+        SAL_INFO("editeng.chaining",
+                 "[Overflowing] No Overflowing text but GetNonOverflowinText 
called?!");
         return NULL;
      }
 
@@ -2189,10 +2188,10 @@ OverflowingText *Outliner::GetOverflowingText() const
 
     // Defensive check: oveflowing para index beyond actual # of paragraphs?
     if ( pEditEngine->GetOverflowingParaNum() > GetParagraphCount()-1) {
-        fprintf(stderr,
-                "[Overflowing] Ops, trying to retrieve para %d when max index 
is %d\n",
-                pEditEngine->GetOverflowingParaNum(),
-                GetParagraphCount()-1);
+        SAL_INFO("editeng.chaining",
+                 "[Overflowing] Ops, trying to retrieve para "
+                 << pEditEngine->GetOverflowingParaNum() << " when max index 
is "
+                 << GetParagraphCount()-1 );
         return NULL;
     }
 
diff --git a/editeng/source/outliner/overflowingtxt.cxx 
b/editeng/source/outliner/overflowingtxt.cxx
index 60120e5..0993e37 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -19,7 +19,6 @@
 
 #include "rtl/ustring.hxx"
 #include "tools/debug.hxx"
-#include "sal/info.hxx"
 
 #include "editeng/overflowingtxt.hxx"
 #include "editeng/outliner.hxx"
@@ -158,11 +157,9 @@ bool NonOverflowingText::IsLastParaInterrupted() const
 OutlinerParaObject *NonOverflowingText::RemoveOverflowingText(Outliner 
*pOutliner) const
 {
     pOutliner->QuickDelete(maContentSel);
-    fprintf(stderr, "Deleting selection from (Para: %d, Pos: %d) to (Para: %d, 
Pos: %d)\n",
-            maContentSel.nStartPara,
-            maContentSel.nStartPos,
-            maContentSel.nEndPara,
-            maContentSel.nEndPos);
+    SAL_INFO("editeng.chaining", "Deleting selection from (Para: " << 
maContentSel.nStartPara
+             << ", Pos: " << maContentSel.nStartPos << ") to (Para: " << 
maContentSel.nEndPara
+             << ", Pos: " << maContentSel.nEndPos << ")");
     return pOutliner->CreateParaObject();
 }
 
@@ -213,10 +210,10 @@ OutlinerParaObject 
*OFlowChainedText::InsertOverflowingText(Outliner *pOutliner,
         return NULL;
 
     if (mbIsDeepMerge) {
-        fprintf(stderr, "[TEXTCHAINFLOW - OF] Deep merging paras\n" );
+        SAL_INFO("editeng.chaining", "[TEXTCHAINFLOW - OF] Deep merging paras" 
);
         return mpOverflowingTxt->DeeplyMergeParaObject(pOutliner, 
pTextToBeMerged );
     } else {
-        fprintf(stderr, "[TEXTCHAINFLOW - OF] Juxtaposing paras\n" );
+        SAL_INFO("editeng.chaining", "[TEXTCHAINFLOW - OF] Juxtaposing paras" 
);
         return mpOverflowingTxt->JuxtaposeParaObject(pOutliner, 
pTextToBeMerged );
     }
 }
@@ -249,11 +246,11 @@ OutlinerParaObject 
*UFlowChainedText::CreateMergedUnderflowParaObject(Outliner *
     OutlinerParaObject *pNewText = NULL;
 
     if (mbIsDeepMerge) {
-        fprintf(stderr, "[TEXTCHAINFLOW - UF] Deep merging paras\n" );
+        SAL_INFO("editeng.chaining", "[TEXTCHAINFLOW - UF] Deep merging paras" 
);
         pNewText = TextChainingUtils::DeeplyMergeParaObject(mxUnderflowingTxt, 
pOutl, pNextLinkWholeText);
     } else {
         // NewTextForCurBox = Txt(CurBox) ++ Txt(NextBox)
-        fprintf(stderr, "[TEXTCHAINFLOW - UF] Juxtaposing paras\n" );
+        SAL_INFO("editeng.chaining", "[TEXTCHAINFLOW - UF] Juxtaposing paras" 
);
         pNewText = TextChainingUtils::JuxtaposeParaObject(mxUnderflowingTxt, 
pOutl, pNextLinkWholeText);
     }
 
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 0b477ca..0d7d013 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -543,7 +543,7 @@ void SdrObjEditView::ImpChainingEventHdl()
             pTextChain->SetNilChainingEvent(pTextObj, false);
         } else {
             // XXX
-            fprintf(stderr, "[OnChaining] No Edit Outliner View\n");
+            SAL_INFO("svx.chaining", "[OnChaining] No Edit Outliner View");
         }
     }
 
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 55948aa..cc3f479 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -2020,7 +2020,7 @@ void ImpUpdateChainLinks(SdrTextObj *pTextObj, OUString 
aNextLinkName)
     SdrTextObj *pNextTextObj = dynamic_cast< SdrTextObj * >
                                 (ImpGetObjByName(pPage, aNextLinkName));
     if (!pNextTextObj) {
-        fprintf(stderr, "[CHAINING] Can't find object as next link.\n");
+        SAL_INFO("svx.chaining", "[CHAINING] Can't find object as next link.");
         return;
     }
 
@@ -2061,25 +2061,21 @@ void SdrTextObj::onChainingEvent()
     EditingTextChainFlow aTxtChainFlow(this);
     aTxtChainFlow.CheckForFlowEvents(pEdtOutl);
 
-
     if (aTxtChainFlow.IsOverflow()) {
-        fprintf(stderr, "[CHAINING] Overflow going on\n");
+        SAL_INFO("svx.chaining", "[CHAINING] Overflow going on");
         // One outliner is for non-overflowing text, the other for overflowing 
text
         // We remove text directly from the editing outliner
         aTxtChainFlow.ExecuteOverflow(pEdtOutl, &aDrawOutliner);
     } else if (aTxtChainFlow.IsUnderflow()) {
-        fprintf(stderr, "[CHAINING] Underflow going on\n");
+        SAL_INFO("svx.chaining", "[CHAINING] Underflow going on");
         // underflow-induced overflow
         aTxtChainFlow.ExecuteUnderflow(&aDrawOutliner);
         bool bIsOverflowFromUnderflow = aTxtChainFlow.IsOverflow();
         // handle overflow
         if (bIsOverflowFromUnderflow) {
-            fprintf(stderr, "[CHAINING] Overflow going on (underflow 
induced)\n");
+            SAL_INFO("svx.chaining", "[CHAINING] Overflow going on (underflow 
induced)");
             // prevents infinite loops when setting text for editing outliner
-
-
             aTxtChainFlow.ExecuteOverflow(&aDrawOutliner, &aDrawOutliner);
-
         }
     }
 }
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx 
b/svx/source/svdraw/svdotextdecomposition.cxx
index be19e39..3ad8f71 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -1425,7 +1425,7 @@ void 
SdrTextObj::impHandleChainingEventsDuringDecomposition(SdrOutliner &rOutlin
         SdrTextObj *pCurObj = (SdrTextObj *) pPage->GetObj(i);
 
         if (pCurObj == this) {
-            fprintf(stderr, "Working on TextBox %d\n", i);
+            SAL_INFO("svx.chaining", "Working on TextBox " << i);
             break;
         }
     }
diff --git a/svx/source/svdraw/textchainflow.cxx 
b/svx/source/svdraw/textchainflow.cxx
index 3286b86..71d4649 100644
--- a/svx/source/svdraw/textchainflow.cxx
+++ b/svx/source/svdraw/textchainflow.cxx
@@ -28,7 +28,7 @@
 TextChainFlow::TextChainFlow(SdrTextObj *pChainTarget)
     : mpTargetLink(pChainTarget)
 {
-    fprintf(stderr, "\n[TEXTCHAINFLOW] Creating a new TextChainFlow\n");
+    SAL_INFO("svx.chaining", "[TEXTCHAINFLOW] Creating a new TextChainFlow");
 
     mpTextChain = mpTargetLink->GetTextChain();
     mpNextLink = mpTargetLink->GetNextLinkInChain();
@@ -205,7 +205,8 @@ void 
TextChainFlow::impLeaveOnlyNonOverflowingText(SdrOutliner *pNonOverflOutl)
 {
     OutlinerParaObject *pNewText = 
mpOverflChText->RemoveOverflowingText(pNonOverflOutl);
 
-    fprintf(stderr, "[TEXTCHAINFLOW - OF] SOURCE box set to %d paras \n", 
pNewText->GetTextObject().GetParagraphCount());
+    SAL_INFO("svx.chaining", "[TEXTCHAINFLOW - OF] SOURCE box set to "
+             << pNewText->GetTextObject().GetParagraphCount() << " paras");
 
     // adds it to current outliner anyway (useful in static decomposition)
     pNonOverflOutl->SetText(*pNewText);
@@ -221,20 +222,22 @@ void 
TextChainFlow::impMoveChainedTextToNextLink(SdrOutliner *pOverflOutl)
 {
     // prevent copying text in same box
     if ( mpNextLink ==  mpTargetLink ) {
-        fprintf(stderr, "[CHAINING] Trying to copy text for next link in same 
object\n");
+        SAL_INFO("svx.chaining", "[CHAINING] Trying to copy text for next link 
in same object");
         return;
     }
 
     OutlinerParaObject *pNewText =
         mpOverflChText->InsertOverflowingText(pOverflOutl,
                                               
mpNextLink->GetOutlinerParaObject());
-    fprintf(stderr, "[TEXTCHAINFLOW - OF] DEST box set to %d paras \n", 
pNewText->GetTextObject().GetParagraphCount());
+    SAL_INFO("svx.chaining", "[TEXTCHAINFLOW - OF] DEST box set to "
+             << pNewText->GetTextObject().GetParagraphCount() << " paras");
 
     if (pNewText)
         mpNextLink->NbcSetOutlinerParaObject(pNewText);
 
     // Set Deep Merge status
-    fprintf(stderr, "[DEEPMERGE] Setting deepMerge to %d\n", 
mpOverflChText->IsLastParaInterrupted());
+    SAL_INFO("svx.chaining", "[DEEPMERGE] Setting deepMerge to "
+             << mpOverflChText->IsLastParaInterrupted());
     GetTextChain()->SetIsPartOfLastParaInNextLink(
                           mpTargetLink,
                           mpOverflChText->IsLastParaInterrupted());
@@ -284,7 +287,7 @@ UFlowChainedText *TextChainFlow::GetUnderflowChainedText() 
const
 EditingTextChainFlow::EditingTextChainFlow(SdrTextObj *pLinkTarget) :
     TextChainFlow(pLinkTarget)
 {
-    fprintf(stderr, "[TEXTCHAINFLOW] Creating a new EditingTextChainFlow\n");
+    SAL_INFO("svx.chaining", "[TEXTCHAINFLOW] Creating a new 
EditingTextChainFlow");
 }
 
 void EditingTextChainFlow::CheckForFlowEvents(SdrOutliner *pFlowOutl)
commit 1a31df9b93edbd0ccdb8d2b3c19facf15867df72
Author: matteocam <matteo.campane...@gmail.com>
Date:   Mon Sep 7 20:01:35 2015 +0200

    chained editeng: Handle chaining for cutting and pasting
    
    Change-Id: Iec08e339a7f06c5fa56e67b42206b31c766f845b

diff --git a/editeng/source/outliner/outlvw.cxx 
b/editeng/source/outliner/outlvw.cxx
index 4a0d96e..edf617f 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -675,8 +675,12 @@ void OutlinerView::InsertText( const OutlinerParaObject& 
rParaObj )
 
 void OutlinerView::Cut()
 {
-    if ( !ImpCalcSelectedPages( false ) || pOwner->ImpCanDeleteSelectedPages( 
this ) )
+    if ( !ImpCalcSelectedPages( false ) || pOwner->ImpCanDeleteSelectedPages( 
this ) ) {
         pEditView->Cut();
+        // Chaining handling
+        if (aEndCutPasteLink.IsSet())
+            aEndCutPasteLink.Call(NULL);
+    }
 }
 
 void OutlinerView::Paste()
@@ -705,6 +709,11 @@ void OutlinerView::PasteSpecial()
         pEditView->SetEditEngineUpdateMode( true );
         pOwner->UndoActionEnd( OLUNDO_INSERT );
         pEditView->ShowCursor( true );
+
+        // Chaining handling
+        // NOTE: We need to do this last because it pEditView may be deleted 
if a switch of box occurs
+        if (aEndCutPasteLink.IsSet())
+            aEndCutPasteLink.Call(NULL);
     }
 }
 
commit d675b2e387dfc655bc6aa3eb6312e4a23bf6f233
Author: matteocam <matteo.campane...@gmail.com>
Date:   Mon Sep 7 19:58:16 2015 +0200

    chained editeng: Handle DEL key for chaining
    
    Change-Id: I124b1adf6df3c42a58d45eaeb0e1e053c0eea4c9

diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index da65984..d9e0a99 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -950,7 +950,10 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
                 {
                     vcl::KeyCode aKCode(KEY_DELETE);
                     KeyEvent aKEvt( 0, aKCode);
-                    pOLV->PostKeyEvent(aKEvt);
+                    //pOLV->PostKeyEvent(aKEvt);
+                    // We use SdrObjEditView to handle DEL for underflow 
handling
+                    mpDrawView->KeyInput(aKEvt, NULL);
+
                 }
             }
             else
commit 2c7f7b171af00668cb60d5792116b0873cd6b648
Author: matteocam <matteo.campane...@gmail.com>
Date:   Mon Sep 7 16:37:56 2015 +0200

    chained editeng: Enable chaining after a key is pressed
    
    Change-Id: I64351619dd0886f3bb0c080557864c46a17d737d

diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 9dbf0ab..0b477ca 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1312,6 +1312,15 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, 
vcl::Window* pWin)
 {
     if(pTextEditOutlinerView)
     {
+        /* Start special handling of keys within a chain */
+        // We possibly move to another box before any handling
+        bool bHandled = false;
+        TextChainCursorManager *pCursorManager =
+            ImpHandleMotionThroughBoxesKeyInput(rKEvt, pWin, &bHandled);
+        if (bHandled)
+            return true;
+        /* End special handling of keys within a chain */
+
         if (pTextEditOutlinerView->PostKeyEvent(rKEvt, pWin))
         {
             if( mpModel )
@@ -1320,6 +1329,11 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, 
vcl::Window* pWin)
                     mpModel->SetChanged();
             }
 
+            /* Start chaining processing */
+            ImpChainingEventHdl();
+            ImpMoveCursorAfterChainingEvent(pCursorManager);
+            /* End chaining processing */
+
             if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
 #ifdef DBG_UTIL
             if (mpItemBrowser!=nullptr) mpItemBrowser->SetDirty();
commit ad0046f9f420643a686044a8bcee00649311ec50
Author: matteocam <matteo.campane...@gmail.com>
Date:   Mon Sep 7 16:33:39 2015 +0200

    chained editeng: Add methods and basic setup for editing-mode chaining
    
    Change-Id: I8065bebaf2a54170bc7b3ddbd35740bcca42298d

diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index 5dc3514..bec7338 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -34,6 +34,7 @@ class EditFieldInfo;
 class ImpSdrEditPara;
 struct PasteOrDropInfos;
 class SdrUndoManager;
+class TextChainCursorManager;
 
 namespace com { namespace sun { namespace star { namespace uno {
     class Any;
@@ -101,6 +102,10 @@ protected:
     // provide their document UndoManager and derive it from SdrUndoManager.
     virtual SdrUndoManager* getSdrUndoManagerForEnhancedTextEdit() const;
 
+    void ImpMoveCursorAfterChainingEvent(TextChainCursorManager 
*pCursorManager);
+    TextChainCursorManager *ImpHandleMotionThroughBoxesKeyInput(const 
KeyEvent& rKEvt, vcl::Window* pWin, bool *bOutHandled);
+
+
     OutlinerView* ImpFindOutlinerView(vcl::Window* pWin) const;
 
     // Create a new OutlinerView at the heap and initialize all required 
parameters.
@@ -109,6 +114,11 @@ protected:
     void ImpPaintOutlinerView(OutlinerView& rOutlView, const Rectangle& rRect, 
OutputDevice& rTargetDevice) const;
     void ImpInvalidateOutlinerView(OutlinerView& rOutlView) const;
 
+    // Chaining
+    void ImpChainingEventHdl();
+    DECL_LINK(ImpAfterCutOrPasteChainingEventHdl,void*);
+
+
     // Check if the whole text is selected.
     // Still returns sal_True if there is no text present.
     bool ImpIsTextEditAllSelected() const;
diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx
index 6bb82ad7..d1117bd 100644
--- a/sd/source/ui/view/outlview.cxx
+++ b/sd/source/ui/view/outlview.cxx
@@ -1370,6 +1370,7 @@ void OutlineView::ResetLinks() const
     mrOutliner.SetDrawPortionHdl(Link<DrawPortionInfo*,void>());
     mrOutliner.SetBeginPasteOrDropHdl(Link<PasteOrDropInfos*,void>());
     mrOutliner.SetEndPasteOrDropHdl(Link<PasteOrDropInfos*,void>());
+    mrOutliner.SetChainingEventHdl(Link<>());
 }
 
 sal_Int8 OutlineView::AcceptDrop( const AcceptDropEvent&, DropTargetHelper&, 
::sd::Window*, sal_uInt16, sal_uInt16)
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
index 18fbf2e..524faba 100644
--- a/sd/source/ui/view/sdview.cxx
+++ b/sd/source/ui/view/sdview.cxx
@@ -1204,6 +1204,7 @@ void View::OnBeginPasteOrDrop( PasteOrDropInfos* 
/*pInfos*/ )
     get the correct style sheet. */
 void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
 {
+    /* Style Sheet handling */
     SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetTextEditObject() );
     SdrOutliner* pOutliner = GetTextEditOutliner();
     if( pOutliner && pTextObj && pTextObj->GetPage() )
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index ea6ae00..9dbf0ab 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -51,6 +51,8 @@
 #include "svx/svdstr.hrc"
 #include "svdglob.hxx"
 #include "svx/globl3d.hxx"
+#include <svx/textchain.hxx>
+#include <svx/textchaincursor.hxx>
 #include <editeng/outliner.hxx>
 #include <editeng/adjustitem.hxx>
 #include <svtools/colorcfg.hxx>
@@ -486,6 +488,102 @@ IMPL_LINK_TYPED(SdrObjEditView,ImpOutlinerStatusEventHdl, 
EditStatus&, rEditStat
     }
 }
 
+void SdrObjEditView::ImpChainingEventHdl()
+{
+    if(pTextEditOutliner )
+    {
+        SdrTextObj* pTextObj = dynamic_cast< SdrTextObj * >( 
mxTextEditObj.get() );
+        OutlinerView* pOLV = GetTextEditOutlinerView();
+        if( pTextObj && pOLV)
+        {
+            TextChain *pTextChain = pTextObj->GetTextChain();
+
+             // XXX: IsChainable and GetNilChainingEvent are a bit mixed up atm
+            if (!pTextObj->IsChainable()) {
+                return;
+            }
+            // This is true during an underflow-caused overflow (with 
pEdtOutl->SetText())
+            if (pTextChain->GetNilChainingEvent(pTextObj)) {
+                return;
+            }
+
+            // We prevent to trigger further handling of overflow/underflow 
for pTextObj
+            pTextChain->SetNilChainingEvent(pTextObj, true); // XXX
+
+            // Save previous selection pos // NOTE: It must be done to have 
the right CursorEvent in KeyInput
+            pTextChain->SetPreChainingSel(pTextObj, pOLV->GetSelection());
+            //maPreChainingSel = new ESelection(pOLV->GetSelection());
+
+            // Handling Undo
+            const int nText = 0; // XXX: hardcoded index (SdrTextObj::getText 
handles only 0)
+
+            SdrUndoObjSetText *pTxtUndo  = dynamic_cast< SdrUndoObjSetText* >
+                ( 
GetModel()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nText ) );
+
+            // trigger actual chaining
+            pTextObj->onChainingEvent();
+
+           if (pTxtUndo!=NULL)
+            {
+                pTxtUndo->AfterSetText();
+                if (!pTxtUndo->IsDifferent())
+                {
+                    delete pTxtUndo;
+                    pTxtUndo=NULL;
+                }
+            }
+
+            if (pTxtUndo)
+                AddUndo(pTxtUndo);
+
+            //maCursorEvent = new 
CursorChainingEvent(pTextChain->GetCursorEvent(pTextObj));
+            //SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain();
+
+            // NOTE: Must be called. Don't let the function return if you set 
it to true and not reset it
+            pTextChain->SetNilChainingEvent(pTextObj, false);
+        } else {
+            // XXX
+            fprintf(stderr, "[OnChaining] No Edit Outliner View\n");
+        }
+    }
+
+}
+
+IMPL_LINK_NOARG(SdrObjEditView,ImpAfterCutOrPasteChainingEventHdl)
+{
+    SdrTextObj* pTextObj = dynamic_cast< SdrTextObj * >( GetTextEditObject());
+    if (!pTextObj)
+        return 0;
+    ImpChainingEventHdl();
+    TextChainCursorManager *pCursorManager = new TextChainCursorManager(this, 
pTextObj);
+    ImpMoveCursorAfterChainingEvent(pCursorManager);
+    return 0;
+}
+
+void SdrObjEditView::ImpMoveCursorAfterChainingEvent(TextChainCursorManager 
*pCursorManager)
+{
+    if (!mxTextEditObj.is() || !pCursorManager)
+        return;
+
+    SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
+
+    // Check if it has links to move it to
+    if (!pTextObj->IsChainable())
+        return;
+
+    TextChain *pTextChain = pTextObj->GetTextChain();
+    ESelection aNewSel = pTextChain->GetPostChainingSel(pTextObj);
+
+
+    pCursorManager->HandleCursorEventAfterChaining(
+        pTextChain->GetCursorEvent(pTextObj),
+        aNewSel);
+
+    // Reset event
+    pTextChain->SetCursorEvent(pTextObj, CursorChainingEvent::NULL_EVENT);
+}
+
+
 
IMPL_LINK_TYPED(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI,void)
 {
     bool bOk=false;
@@ -724,6 +822,10 @@ bool SdrObjEditView::SdrBeginTextEdit(
 
             pTextEditOutlinerView->ShowCursor();
             
pTextEditOutliner->SetStatusEventHdl(LINK(this,SdrObjEditView,ImpOutlinerStatusEventHdl));
+            if (pTextObj->IsChainable()) {
+                
pTextEditOutlinerView->SetEndCutPasteLinkHdl(LINK(this,SdrObjEditView,ImpAfterCutOrPasteChainingEventHdl)
 );
+            }
+
 #ifdef DBG_UTIL
             if (mpItemBrowser!=nullptr) mpItemBrowser->SetDirty();
 #endif
@@ -913,6 +1015,8 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool 
bDontDeleteReally)
             
pTEOutliner->SetBeginPasteOrDropHdl(Link<PasteOrDropInfos*,void>());
             pTEOutliner->SetEndPasteOrDropHdl(Link<PasteOrDropInfos*,void>());
 
+            pTEOutliner->SetChainingEventHdl(Link<>());
+
             const bool bUndo = IsUndoEnabled();
             if( bUndo )
             {
@@ -1176,6 +1280,32 @@ bool SdrObjEditView::IsTextEditFrameHit(const Point& 
rHit) const
     return bOk;
 }
 
+TextChainCursorManager *SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(
+                                            const KeyEvent& rKEvt,
+                                            vcl::Window*,
+                                            bool *bOutHandled)
+{
+    *bOutHandled = false;
+
+    SdrTextObj* pTextObj = NULL;
+    if (mxTextEditObj.is())
+        pTextObj= dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
+    else
+        return NULL;
+
+    if (!pTextObj->GetNextLinkInChain() && !pTextObj->GetPrevLinkInChain())
+        return NULL;
+
+    TextChainCursorManager *pCursorManager = new TextChainCursorManager(this, 
pTextObj);
+    if( pCursorManager->HandleKeyEvent(rKEvt) ) {
+        // Possibly do other stuff here if necessary...
+        // XXX: Careful with the checks below (in KeyInput) for pWin and co. 
You should do them here I guess.
+        *bOutHandled = true;
+    }
+
+    return pCursorManager;
+}
+
 
 
 bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to