[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-chained-text-boxes' - 1565 commits - accessibility/inc accessibility/source android/Bootstrap animations/source avmedia/Library_avmediavlc.mk avmedia/source basctl/inc basctl/Library_basctl.mk basctl/source basebmp/source basebmp/test basegfx/inc basegfx/qa basegfx/source basic/inc basic/qa basic/source bean/com binaryurp/source bin/find-unused-defines.awk bin/find-unused-defines.sh bin/gbuild-to-ide bin/includebloat.awk bin/lo-commit-stat bridges/inc bridges/Library_cpp_uno.mk bridges/source bridges/test canvas/README canvas/source canvas/workben chart2/inc chart2/Library_chartcontroller.mk chart2/source chart2/uiconfig chart2/UIConfig_chart2.mk chart2/workbench cli_ure/source codemaker/source comphelper/inc comphelper/qa comphelper/source compilerplugins/clang config_host/config_dconf.h.in config_host/config_version.h.in config_host.mk.in configmgr/CppunitTest_configmgr_unit.mk configmgr/inc configmgr/Library_configmgr.mk configmgr/qa configmgr/source configure.ac connectivity/source connectivity/workben cppcanvas/inc cppcanvas/source cppuhelper/source cppuhelper/test cppu/qa cppu/source cpputools/source cui/source cui/uiconfig dbaccess/CppunitTest_dbaccess_RowSetClones.mk dbaccess/source desktop/inc desktop/source desktop/test desktop/win32 dictionaries distro-configs/LibreOfficeLinux.conf distro-configs/LibreOfficeWin32.conf distro-configs/LibreOfficeWin64.conf download.lst drawinglayer/source dtrans/source dtrans/test editeng/Library_editeng.mk editeng/source embeddedobj/source embeddedobj/test embedserv/Library_emser.mk extensions/Library_oleautobridge.mk extensions/Library_so_activex.mk extensions/Library_so_activex_x64.mk extensions/source external/boost external/bzip2 external/clucene external/firebird external/glew external/icu external/jfreereport external/lcms2 external/libcmis external/liblangtag external/libvisio external/libxml2 external/libxslt external/neon extras/source filter/CppunitTest_filter_u tils.mk filter/Module_filter.mk filter/qa filter/source forms/qa forms/source formula/Library_for.mk formula/source fpicker/Library_fps_office.mk fpicker/source fpicker/uiconfig fpicker/UIConfig_fps.mk framework/inc framework/Library_fwk.mk framework/source framework/util .gitignore helpcompiler/inc helpcontent2 hwpfilter/source i18nlangtag/qa i18nlangtag/source i18npool/inc i18npool/source icon-themes/breeze icon-themes/galaxy icon-themes/hicontrast icon-themes/human icon-themes/sifr icon-themes/tango idlc/inc idlc/source idl/inc idl/source include/animations include/avmedia include/basebmp include/basegfx include/basic include/canvas include/com include/comphelper include/connectivity include/dbaccess include/drawinglayer include/editeng include/filter include/formula include/framework include/i18nlangtag include/i18nutil include/LibreOfficeKit include/linguistic include/o3tl include/oox include/osl include/package include/registry include/rtl include/sal include/salhelper include /sax include/sfx2 include/sot include/svl include/svtools include/svx include/toolkit include/tools include/tubes include/ucbhelper include/unotest include/unotools include/vbahelper include/vcl include/xmloff include/xmlscript instsetoo_native/CustomTarget_setup.mk instsetoo_native/inc_common io/source io/test jurt/com jvmfwk/inc jvmfwk/plugins jvmfwk/source l10ntools/inc l10ntools/source libreofficekit/qa libreofficekit/source lingucomponent/source linguistic/source lotuswordpro/source mysqlc/source o3tl/CppunitTest_o3tl_tests.mk o3tl/qa odk/examples offapi/com offapi/UnoApi_offapi.mk officecfg/registry onlineupdate/Executable_mar.mk onlineupdate/Executable_updater.mk onlineupdate/source oox/inc oox/source package/inc package/source postprocess/qa postprocess/Rdb_services.mk pyuno/Library_pyuno.mk pyuno/source qadevOOo/runner qadevOOo/tests readlicense_oo/docs readlicense_oo/license registry/inc registry/source reportbuilder/java reportdesign/inc reportdesign/source RepositoryExte rnal.mk rsc/inc rsc/source sal/android sal/inc sal/Library_sal.mk sal/osl sal/qa sal/rtl sax/inc sax/source sax/test scaddins/Library_analysis.mk scaddins/source sc/inc sc/Library_sc.mk scp2/inc scp2/source sc/qa scripting/source sc/sdi sc/source sc/uiconfig sd/CppunitTest_sd_export_tests.mk sdext/README sdext/source sd/inc sd/Library_sd.mk sd/qa sd/sdi sd/source sd/uiconfig setup_native/source sfx2/inc sfx2/Library_sfx.mk sfx2/qa sfx2/sdi sfx2/source sfx2/uiconfig shell/inc shell/source slideshow/qa slideshow/source solenv/bin solenv/gbuild solenv/gdb soltools/cpp sot/qa sot/source starmath/inc starmath/sdi starmath/source starmath/uiconfig stoc/source stoc/test store/source svgio/inc svgio/qa svgio/source svl/qa svl/source svtools/inc svtools/Library_svt.mk svtools/source svtools/uiconfig svx/inc svx/Library_svxcore.mk svx/Library_svx.mk svx/sdi svx/source svx/uiconfig svx/UIConfig_svx.mk svx/workben sw/CppunitTest_sw_odfexport.mk sw/CppunitTest_sw_uiwriter.mk sw/inc sw/Library_sw .mk sw/qa sw/sdi sw/source sw/uiconfig test/source testtools/com testtools/source toolkit/inc toolkit/source tools/CppunitTest_tools_test.mk tools/qa tools/source translations ucbhelper/source ucb/qa ucb/source udkapi/com UnoControls/source unotest/source unotools/source unoxml/source uui/source vbahelper/source vcl/CppunitTest_vcl_lifecycle.mk vcl/generic vcl/headless vcl/inc vcl/opengl vcl/osx vcl/qa vcl/quartz vcl/source vcl/unx vcl/win vcl/workben winaccessibility/Library_uacccom.mk winaccessibility/source wizards/com wizards/source writerfilter/inc writerfilter/source writerperfect/source xmlhelp/Library_ucpchelp1.mk xmlhelp/source xmloff/inc xmloff/source xmlsecurity/inc xmlsecurity/source

matteocam matteo.campanelli at gmail.com
Sun Aug 2 06:58:10 PDT 2015


Rebased ref, commits from common ancestor:
commit 116aff4b41e0ef501f1998a14789626fe09820bb
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Sat Aug 1 00:50:13 2015 +0200

    Minor fix
    
    Change-Id: If5bc6647ce07cbe7e6f324c2081168238f9c258d

diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
index 7442f6d..390683f 100644
--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -313,9 +313,8 @@ namespace drawinglayer
                                     aAnchorTransform,
                                     bWordWrap);
                 }
-                else if( rText.isChainable() !rText.isInEditMode() )
+                else if( rText.isChainable() && !rText.isInEditMode() )
                 {
-                    fprintf(stderr, "[CHAINABLE?] Making a Chained Primitive for %p\n", pReferredTextObj);
                     pNew = new SdrChainedTextPrimitive2D(
                                     &rText.getSdrText(),
                                     rText.getOutlinerParaObject(),
commit 45c630b5b2b66b80e44ee5a29a600b36b4b076da
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 31 23:51:44 2015 +0200

    Cleaned comments; Set IsChainable instead of true
    
    Change-Id: Ie3974389ba6c1fe8c43a5f2fafd5baedd2a01502

diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 0580417..ad458b6 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -479,10 +479,6 @@ void ImpEditEngine::FormatDoc()
 
     CallStatusHdl();    // If Modified...
 
-    //FIXME(matteocam)
-
-    //CallChainingEventHdl(); // For chaining
-
     LeaveBlockNotifications();
 }
 
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index dda8537..194d657 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -98,7 +98,7 @@ private:
 
     SVX_DLLPRIVATE void ImpClearVars();
 
-    // FIXME(matteocam)
+    // FIXME(matteocam):Should we have these fields?
     CursorChainingEvent *maCursorEvent;
     ESelection *maPreChainingSel;
 
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index e4de334..575f138 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -227,7 +227,6 @@ protected:
     OverflowingText *mpOverflowingText = NULL;
     bool mbIsUnchainableClone = false;
 
-    //FIXME(matteocam)
     // the successor in a chain
     SdrTextObj *mpNextInChain = NULL;
     SdrTextObj *mpPrevInChain = NULL;
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
index ed1eb37..7442f6d 100644
--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -295,10 +295,6 @@ namespace drawinglayer
                 aAnchorTransform = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
                     * aAnchorTransform;
 
-                // FIXME(matteocam)
-                SdrTextObj *pReferredTextObj = &rText.getSdrText().GetObject();
-                fprintf(stderr, "[MkTextPrimitive] Referring to text object: %p\n", pReferredTextObj);
-
                 if(rText.isFitToSize())
                 {
                     // stretched text in range
@@ -317,7 +313,7 @@ namespace drawinglayer
                                     aAnchorTransform,
                                     bWordWrap);
                 }
-                else if( rText.isChainable() /*&& !rText.isInEditMode()*/ ) // FIXME(matteocam)
+                else if( rText.isChainable() !rText.isInEditMode() )
                 {
                     fprintf(stderr, "[CHAINABLE?] Making a Chained Primitive for %p\n", pReferredTextObj);
                     pNew = new SdrChainedTextPrimitive2D(
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 18fb749..53a0af2 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1309,14 +1309,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 */
 
-        // FIXME(matteocam): Old code from here
         if (pTextEditOutlinerView->PostKeyEvent(rKEvt, pWin))
         {
             if( pMod )
@@ -1325,11 +1326,10 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
                     pMod->SetChanged( true );
             }
 
-            // FIXME(matteocam)
-            // Start chaining processing
+            /* Start chaining processing */
             ImpChainingEventHdl(NULL);
             ImpMoveCursorAfterChainingEvent(pCursorManager);
-            // End chaining processing
+            /* End chaining processing */
 
             if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
 #ifdef DBG_UTIL
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index cd9b764..24f8952 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -218,16 +218,13 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe
     pHitTestOutliner = SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, *this);
     ImpSetOutlinerDefaults(pHitTestOutliner, true);
 
-    // FIXME(matteocam)
     /* Start Text Chaining related code */
-
     // Initialize Chaining Outliner
     pChainingOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, *this );
     ImpSetOutlinerDefaults(pChainingOutliner, true);
 
-    // Make a TextChain //XXX: There should not be only one - XXX: Prototype code
+    // Make a TextChain
     pTextChain = new TextChain;
-
     /* End Text Chaining related code */
 
     ImpCreateTables();
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 46b1bbc..1b47e56 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -752,8 +752,7 @@ void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, boo
                 if (eAniDirection==SDRTEXTANI_UP || eAniDirection==SDRTEXTANI_DOWN) nHgt=1000000;
             }
 
-            // FIXME(matteocam)
-            bool bChainedFrame = true; // XXX: should be returned from a method
+            bool bChainedFrame = IsChainable();
 
             if (!bChainedFrame) {
 
diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx
index 72dc010..72c6ca4 100644
--- a/svx/source/svdraw/svdotxed.cxx
+++ b/svx/source/svdraw/svdotxed.cxx
@@ -63,9 +63,7 @@ bool SdrTextObj::BegTextEdit(SdrOutliner& rOutl)
         rOutl.SetControlWord(nStat);
     }
 
-    // FIXME(matteocam)
-
-    // disable AUTOPAGESIZE
+    // disable AUTOPAGESIZE if IsChainable
     if ( IsChainable() ) {
         EEControlBits nStat1=rOutl.GetControlWord();
         nStat1 &=~EEControlBits::AUTOPAGESIZE;
@@ -191,9 +189,9 @@ void SdrTextObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* p
                 if (eAniDirection==SDRTEXTANI_UP || eAniDirection==SDRTEXTANI_DOWN) nMaxHgt=1000000;
             }
 
-            // FIXME(matteocam)
-            bool bChainedFrame = true; // XXX: should be returned from a method
+            bool bChainedFrame = IsChainable();
 
+            // overflow handling may require not modifying width and height this way
             if ( !bChainedFrame ) {
                 // #i119885# Do not limit/force height to geometrical frame (vice versa for vertical writing)
                 if(IsVerticalWriting())
commit cc3b978c4dcac8ba62199eb21be5ab364e767045
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 31 15:40:15 2015 +0200

    Make declaration of ImpOutlinerCalcFieldValueHdl typed
    
    Change-Id: I13925f9dec535f7d3d2a722eccfa9d36bbff2839

diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index 993f210..dda8537 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -129,7 +129,8 @@ protected:
     DECL_LINK(ImpOutlinerStatusEventHdl,EditStatus*);
     DECL_LINK(ImpChainingEventHdl,void*);
     DECL_LINK(ImpAfterCutOrPasteChainingEventHdl,void*);
-    DECL_LINK(ImpOutlinerCalcFieldValueHdl,EditFieldInfo*);
+
+    DECL_LINK_TYPED(ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,void);
 
     // link for EndTextEditHdl
     DECL_LINK(EndTextEditHdl, SdrUndoManager*);
commit 87a96cadf9772c845a43a058d90b8248f1e3f734
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 31 14:52:58 2015 +0200

    Use EditLine instead of EditLine*
    
    Change-Id: I68c6f6e03c8ec79e0b0e313ea56f2048497487f5

diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 19454d2..0580417 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -4655,8 +4655,8 @@ void ImpEditEngine::ImplUpdateOverflowingLineNum(sal_uInt32 nPaperHeight,
     // Like UpdateOverflowingParaNum but for each line in the first
     //  overflowing paragraph.
     for ( sal_Int32 nLine = 0; nLine < pPara->GetLines().Count(); nLine++ ) {
-        EditLine *pLine = pPara->GetLines()[nLine];
-        nLH = pLine->GetHeight();
+        EditLine aLine = pPara->GetLines()[nLine];
+        nLH = aLine.GetHeight();
         nY += nLH;
         if ( nY > nPaperHeight ) // found first line overflowing
         {
commit bd1b4e0978ce8df4ef62ba77b13b6cffceeedb86
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 30 13:48:52 2015 +0200

    Change name to post-paste&cutting method
    
    Change-Id: Ie49890788ea0b7f3b58b3d4a854bbc0f09526bf9

diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index bff66ad..16c416c 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -679,8 +679,8 @@ void OutlinerView::Cut()
         pEditView->Cut();
 
         // Chaining handling
-        if (aEndPasteLink.IsSet())
-            aEndPasteLink.Call(NULL);
+        if (aEndCutPasteLink.IsSet())
+            aEndCutPasteLink.Call(NULL);
     }
 }
 
@@ -712,8 +712,8 @@ void OutlinerView::PasteSpecial()
         pEditView->ShowCursor( true, true );
 
         // XXX: Not sure if this should be called right before ShowCursor
-        if (aEndPasteLink.IsSet())
-            aEndPasteLink.Call(NULL);
+        if (aEndCutPasteLink.IsSet())
+            aEndCutPasteLink.Call(NULL);
     }
 
 }
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 8077b43..7374b4f 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -214,7 +214,7 @@ private:
     EDITENG_DLLPRIVATE void         ImpPasted( sal_Int32 nStart, sal_Int32 nPrevParaCount, sal_Int32 nSize);
     EDITENG_DLLPRIVATE sal_Int32    ImpCalcSelectedPages( bool bIncludeFirstSelected );
 
-    Link<> aEndPasteLink;
+    Link<> aEndCutPasteLink;
 
 public:
                 OutlinerView( Outliner* pOut, vcl::Window* pWindow );
@@ -375,7 +375,7 @@ public:
     OUString    GetSurroundingText() const;
     Selection   GetSurroundingTextSelection() const;
 
-    void        SetEndPasteLinkHdl(const Link<> &rLink) { aEndPasteLink = rLink; }
+    void        SetEndCutPasteLinkHdl(const Link<> &rLink) { aEndCutPasteLink = rLink; }
 };
 
 
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index c8b8492..993f210 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -128,7 +128,7 @@ protected:
     // handler for AutoGrowing text with active Outliner
     DECL_LINK(ImpOutlinerStatusEventHdl,EditStatus*);
     DECL_LINK(ImpChainingEventHdl,void*);
-    DECL_LINK(ImpAfterPasteChainingEventHdl,void*);
+    DECL_LINK(ImpAfterCutOrPasteChainingEventHdl,void*);
     DECL_LINK(ImpOutlinerCalcFieldValueHdl,EditFieldInfo*);
 
     // link for EndTextEditHdl
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index ed296de..18fb749 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -533,7 +533,7 @@ IMPL_LINK_NOARG(SdrObjEditView,ImpChainingEventHdl)
     return 0;
 }
 
-IMPL_LINK_NOARG(SdrObjEditView,ImpAfterPasteChainingEventHdl)
+IMPL_LINK_NOARG(SdrObjEditView,ImpAfterCutOrPasteChainingEventHdl)
 {
     SdrTextObj* pTextObj = dynamic_cast< SdrTextObj * >( GetTextEditObject());
     if (!pTextObj)
@@ -807,7 +807,7 @@ bool SdrObjEditView::SdrBeginTextEdit(
             pTextEditOutlinerView->ShowCursor();
             pTextEditOutliner->SetStatusEventHdl(LINK(this,SdrObjEditView,ImpOutlinerStatusEventHdl));
             if (pTextObj->IsChainable()) {
-                pTextEditOutlinerView->SetEndPasteLinkHdl(LINK(this,SdrObjEditView,ImpAfterPasteChainingEventHdl) );
+                pTextEditOutlinerView->SetEndCutPasteLinkHdl(LINK(this,SdrObjEditView,ImpAfterCutOrPasteChainingEventHdl) );
                 /* We should call:
                  *
                     ImpChainingEventHdl(NULL);
commit 887d6daafee7e8ddf95c09f1ee2bb3a22cbb6f4a
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 30 13:29:45 2015 +0200

    Handle underflow after cutting text
    
    Change-Id: I33d83d7423a18f71ea7c1c4d1a03580354e48092

diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 987bd0a..bff66ad 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -675,8 +675,13 @@ 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 (aEndPasteLink.IsSet())
+            aEndPasteLink.Call(NULL);
+    }
 }
 
 void OutlinerView::Paste()
commit f0e840a3b29e71130add380b0eeda6233da0ea3d
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 30 11:29:40 2015 +0200

    Remove wordwrap method from SdrChainedTextPrimitive
    
    Change-Id: I2800aede1597eb0d94e9bdcb1634f2509503d1fb

diff --git a/svx/inc/sdr/primitive2d/sdrtextprimitive2d.hxx b/svx/inc/sdr/primitive2d/sdrtextprimitive2d.hxx
index a6b1f8f..dee63f7 100644
--- a/svx/inc/sdr/primitive2d/sdrtextprimitive2d.hxx
+++ b/svx/inc/sdr/primitive2d/sdrtextprimitive2d.hxx
@@ -353,7 +353,7 @@ namespace drawinglayer
 
             // get data
             const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
-            bool getWordWrap() const { return true; } // XXX: Hack! Should have a proper implementation
+            //bool getWordWrap() const { return true; } // XXX: Hack! Should have a proper implementation//
 
             // compare operator
             virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index bf603eb..8bb6603 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -1486,7 +1486,7 @@ void SdrTextObj::impDecomposeChainedTextPrimitive(
     const bool bVerticalWritintg(pOutlinerParaObject->IsVertical());
     const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
 
-    if((rSdrChainedTextPrimitive.getWordWrap() || IsTextFrame()))
+    if(IsTextFrame())
     {
         rOutliner.SetMaxAutoPaperSize(aAnchorTextSize);
     }
commit c74676d7585f62f2d457e2854930819363dcaa6b
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Wed Jul 29 19:12:07 2015 +0200

    Check for links instead of chainabity when handling key input
    
    Change-Id: Id8a7892ab5465b85a79a4347a6653de8c975416c

diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index d86a899..ed296de 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -551,6 +551,7 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCu
 
     SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
 
+    // Check if it has links to move it to
     if (!pTextObj->IsChainable())
         return;
 
@@ -1291,7 +1292,7 @@ TextChainCursorManager *SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(
     else
         return NULL;
 
-    if (!pTextObj->IsChainable())
+    if (!pTextObj->GetNextLinkInChain() && !pTextObj->GetPrevLinkInChain())
         return NULL;
 
     TextChainCursorManager *pCursorManager = new TextChainCursorManager(this, pTextObj);
commit 7d66d6a6d1dc8a2c174fee824bdb77dafdb827a1
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Wed Jul 29 18:56:51 2015 +0200

    Check GetNicChainingEvent before chaining in static mode
    
    Change-Id: Ie3e4aeea896ae3269ee196d17d80505e2491eb71

diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index 118c668..bf603eb 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -1413,6 +1413,9 @@ void SdrTextObj::impGetScrollTextTiming(drawinglayer::animation::AnimationEntryL
 
 void SdrTextObj::impHandleChainingEventsDuringDecomposition(SdrOutliner &rOutliner) const
 {
+    if (GetTextChain()->GetNilChainingEvent(this))
+        return;
+
     GetTextChain()->SetNilChainingEvent(this, true);
 
     TextChainFlow aTxtChainFlow(const_cast<SdrTextObj*>(this));
commit b5c6badc97642d539f60c4c6c3f1bfcd81b28b9d
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Wed Jul 29 18:54:55 2015 +0200

    Set link at calls of IsChainable. (not working)
    
    Change-Id: Ia6b57c560f20abac8cac98c29880d7aa5b962d7c

diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index ca28046..46b1bbc 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1984,12 +1984,60 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
     }
 }
 
+// XXX: Make it a method somewhere?
+SdrObject *ImpGetObjByName(SdrObjList *pObjList, OUString aObjName)
+{
+    // scan the whole list
+    size_t nObjCount = pObjList->GetObjCount();
+    for (unsigned i = 0; i < nObjCount; i++) {
+        SdrObject *pCurObj = pObjList->GetObj(i);
+
+        if (pCurObj->GetName() == aObjName) {
+            return pCurObj;
+        }
+    }
+    // not found
+    return NULL;
+}
+
+// XXX: Make it a (private) method of SdrTextObj
+void ImpUpdateChainLinks(SdrTextObj *pTextObj, OUString aNextLinkName)
+{
+    // XXX: Current implementation constraints text boxes to be on the same page
+
+    // No next link
+    if (aNextLinkName == "") {
+        pTextObj->SetNextLinkInChain(NULL);
+        return;
+    }
+
+    SdrPage *pPage = pTextObj->GetPage();
+    assert(pPage);
+    SdrTextObj *pNextTextObj = dynamic_cast< SdrTextObj * >
+                                (ImpGetObjByName(pPage, aNextLinkName));
+    if (!pNextTextObj) {
+        fprintf(stderr, "[CHAINING] Can't find object as next link.\n");
+        return;
+    }
+
+    pTextObj->SetNextLinkInChain(pNextTextObj);
+}
+
 bool SdrTextObj::IsChainable() const
 {
     // Read it as item
     const SfxItemSet& rSet = GetObjectItemSet();
-    OUString aNextName = static_cast<const SfxStringItem&>(rSet.Get(SDRATTR_TEXT_CHAINNEXTNAME)).GetValue();
-    return aNextName != ""; // XXX: Should we also check for GetNilChainingEvent? (see old code below)
+    OUString aNextLinkName = static_cast<const SfxStringItem&>(rSet.Get(SDRATTR_TEXT_CHAINNEXTNAME)).GetValue();
+
+    // Update links if any inconsistency is found
+    bool bNextLinkUnsetYet = (aNextLinkName != "") && !mpNextInChain;
+    bool bInconsistentNextLink = mpNextInChain && mpNextInChain->GetName() != aNextLinkName;
+    // if the link is not set despite there should be one OR if it has changed
+    if (bNextLinkUnsetYet || bInconsistentNextLink) {
+        ImpUpdateChainLinks(const_cast<SdrTextObj *>(this), aNextLinkName);
+    }
+
+    return aNextLinkName != ""; // XXX: Should we also check for GetNilChainingEvent? (see old code below)
 
 /*
     // Check that no overflow is going on
commit d45639a66528a769295d3712326c11b1d74e9424
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Wed Jul 29 17:38:09 2015 +0200

    Remove old code
    
    Change-Id: Ie226e450d3013c92e9a0236a1c3cfd214b6edab5

diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 66b8a7a..ca28046 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1989,35 +1989,13 @@ bool SdrTextObj::IsChainable() const
     // Read it as item
     const SfxItemSet& rSet = GetObjectItemSet();
     OUString aNextName = static_cast<const SfxStringItem&>(rSet.Get(SDRATTR_TEXT_CHAINNEXTNAME)).GetValue();
-    return aNextName != "";
-
-    // XXX
-    if (!GetName().startsWith("Chainable")) {
-        //fprintf(stderr, "[CHAINABLE?] %p is _not_ chainable\n", this);
-        return false;
-    }
+    return aNextName != ""; // XXX: Should we also check for GetNilChainingEvent? (see old code below)
 
+/*
     // Check that no overflow is going on
     if (!GetTextChain() || GetTextChain()->GetNilChainingEvent(this))
         return false;
-
-     // XXX: Hack to have links together
-    static bool bHasDoneTheLinking = false;
-
-    SdrTextObj *pTxtObj0 =  dynamic_cast< SdrTextObj * >( pPage->GetObj( 0 ) );
-
-    if (!bHasDoneTheLinking && pPage && pPage->GetObjCount() > 1 && this == pTxtObj0)
-    {
-        SdrTextObj *pTxtObj1 =  dynamic_cast< SdrTextObj * >( pPage->GetObj( 1 ) );
-        const_cast<SdrTextObj *>(this)->SetNextLinkInChain(pTxtObj1);
-
-        bHasDoneTheLinking = true;
-    }
-    // end hack
-
-
-    return true;
-
+*/
 }
 
 void SdrTextObj::onChainingEvent()
commit 0189497c8f068fe2a679e9c41edfa07dbfde59a3
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Wed Jul 29 17:06:22 2015 +0200

    Set Uno property for chain-next-name from SdXMLTextBoxShapeContext
    
    Change-Id: Ie9dab5768ff555ab2b4c90fffb0311865154f29c

diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index e5eb4a6..f65fcf5 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -1600,7 +1600,8 @@ SdXMLTextBoxShapeContext::SdXMLTextBoxShapeContext(
     uno::Reference< drawing::XShapes >& rShapes,
     bool bTemporaryShape)
 :   SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
-    mnRadius(0)
+    mnRadius(0),
+    maChainNextName("")
 {
 }
 
@@ -1619,6 +1620,12 @@ void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix, const OUStr
                     mnRadius, rValue);
             return;
         }
+
+        if( IsXMLToken( rLocalName, XML_CHAIN_NEXT_NAME ) )
+        {
+            maChainNextName = rValue;
+            return;
+        }
     }
 
     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
@@ -1752,6 +1759,23 @@ void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAtt
             }
         }
 
+        if(maChainNextName != "")
+        {
+            uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
+            if(xPropSet.is())
+            {
+                try
+                {
+                    xPropSet->setPropertyValue("TextChainNextName",
+                                               uno::makeAny( maChainNextName ) );
+                }
+                catch(const uno::Exception&)
+                {
+                    OSL_FAIL( "exception during setting of name of next chain link!");
+                }
+            }
+        }
+
         SdXMLShapeContext::StartElement(mxAttrList);
     }
 }
diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx
index 73c9d8c..fdf1e70 100644
--- a/xmloff/source/draw/ximpshap.hxx
+++ b/xmloff/source/draw/ximpshap.hxx
@@ -247,6 +247,7 @@ public:
 class SdXMLTextBoxShapeContext : public SdXMLShapeContext
 {
     sal_Int32                   mnRadius;
+    OUString                    maChainNextName;
 
 public:
     TYPEINFO_OVERRIDE();
commit c411f534cdb4b3bab2d3b3b2cc962840e2680d38
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Wed Jul 29 09:06:41 2015 +0200

    Add chaining constant in unoshap
    
    Change-Id: I4a7d69636df9d5b80420da8fa5bd9bea8cf1d3f0

diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 30ff3f4..7235afe 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -670,6 +670,7 @@ SvxShapeControlPropertyMapping[] =
     { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_COLOR),   RTL_CONSTASCII_STRINGPARAM("TextColor") },
     { RTL_CONSTASCII_STRINGPARAM("CharBackColor"), RTL_CONSTASCII_STRINGPARAM("CharBackColor") },
     { RTL_CONSTASCII_STRINGPARAM("CharBackTransparent"), RTL_CONSTASCII_STRINGPARAM("CharBackTransparent") },
+    { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_TEXT_CHAINNEXTNAME), RTL_CONSTASCII_STRINGPARAM(UNO_NAME_TEXT_CHAINNEXTNAME) },
     { RTL_CONSTASCII_STRINGPARAM("CharRelief"),   RTL_CONSTASCII_STRINGPARAM("FontRelief") },
     { RTL_CONSTASCII_STRINGPARAM("CharUnderlineColor"),   RTL_CONSTASCII_STRINGPARAM("TextLineColor") },
     { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_PARA_ADJUST), RTL_CONSTASCII_STRINGPARAM("Align") },
commit 7e4096b1a2380ec15f777eba8ef3e47440960adb
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Wed Jul 29 08:48:54 2015 +0200

    Fixed operator
    
    Change-Id: Ib82ad17855654dafc92bdf423691f3e76b54b387

diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index de5859e..66b8a7a 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1989,7 +1989,7 @@ bool SdrTextObj::IsChainable() const
     // Read it as item
     const SfxItemSet& rSet = GetObjectItemSet();
     OUString aNextName = static_cast<const SfxStringItem&>(rSet.Get(SDRATTR_TEXT_CHAINNEXTNAME)).GetValue();
-    return aNextName == "";
+    return aNextName != "";
 
     // XXX
     if (!GetName().startsWith("Chainable")) {
commit d88fe000fdc853ff0fbfc477abbf11013b5502c2
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Tue Jul 28 09:20:13 2015 +0200

    Read IsChainable as Item
    
    Change-Id: Iee7b19bc711a8ce4934f2c5722191ae9ca87d358

diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 1aa6e73..de5859e 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1986,6 +1986,11 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
 
 bool SdrTextObj::IsChainable() const
 {
+    // Read it as item
+    const SfxItemSet& rSet = GetObjectItemSet();
+    OUString aNextName = static_cast<const SfxStringItem&>(rSet.Get(SDRATTR_TEXT_CHAINNEXTNAME)).GetValue();
+    return aNextName == "";
+
     // XXX
     if (!GetName().startsWith("Chainable")) {
         //fprintf(stderr, "[CHAINABLE?] %p is _not_ chainable\n", this);
commit a6d73d3349a2d8eaac4c971c71eba5b9b1a4b8f6
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jul 27 17:54:08 2015 +0200

    Fix last value in defs
    
    Change-Id: I49cf99ac116f10f14ab21d2a3e738bdece659cb8

diff --git a/include/svx/svddef.hxx b/include/svx/svddef.hxx
index 1cdacb7..5b3e5e9 100644
--- a/include/svx/svddef.hxx
+++ b/include/svx/svddef.hxx
@@ -113,7 +113,7 @@
 #define SDRATTR_TEXT_WORDWRAP           (SDRATTR_MISC_FIRST +25)   /*   1122 */ /*   1122 */ /*   1105 */             /* Pool V2 */
 #define SDRATTR_TEXT_AUTOGROWSIZE       (SDRATTR_MISC_FIRST +26)   /*   1123 */ /*   1123 */ /*   1106 */             /* Pool V2 */
 #define SDRATTR_TEXT_CHAINNEXTNAME      (SDRATTR_MISC_FIRST + 27)   /*  1124 */ /*   11124 */
-#define SDRATTR_MISC_LAST               (SDRATTR_TEXT_AUTOGROWSIZE)        /* 1125   */ /* 1125   */ /* 1108   */ /* Pool V1: 1056 */
+#define SDRATTR_MISC_LAST               (SDRATTR_TEXT_CHAINNEXTNAME)        /* 1125   */ /* 1125   */ /* 1108   */ /* Pool V1: 1056 */
 
 #define SDRATTR_EDGE_FIRST              (SDRATTR_MISC_LAST + 1)      /* 1127   */ /* Pool V4 */
 #define SDRATTR_EDGEKIND                (SDRATTR_EDGE_FIRST + 0)   /*   1127 */ /* Pool V4 */
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index c824318..f3bfaca 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -502,7 +502,6 @@ void SdrItemPool::TakeItemName(sal_uInt16 nWhich, OUString& rItemName)
         case SDRATTR_TEXT_WORDWRAP          : nResId = SIP_SA_WORDWRAP;break;
         case SDRATTR_TEXT_CHAINNEXTNAME     : nResId = SIP_SA_CHAINNEXTNAME;break;
         case SDRATTR_TEXT_AUTOGROWSIZE      : nResId = SIP_SA_AUTOGROWSIZE;break;
-
         case SDRATTR_EDGEKIND           : nResId = SIP_SA_EDGEKIND;break;
         case SDRATTR_EDGENODE1HORZDIST  : nResId = SIP_SA_EDGENODE1HORZDIST;break;
         case SDRATTR_EDGENODE1VERTDIST  : nResId = SIP_SA_EDGENODE1VERTDIST;break;
commit 5d3959726bebda5d1a39f295e482d4e0118d5ca8
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jul 27 17:49:43 2015 +0200

    Added attributes for chaining around
    
    Change-Id: I41f498ae1778a487fefd7c48f00dc514180c0683

diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx
index 0566288..498d417 100644
--- a/include/editeng/unoprnms.hxx
+++ b/include/editeng/unoprnms.hxx
@@ -113,6 +113,7 @@
 #define UNO_NAME_TEXT_WRITINGMODE               "TextWritingMode"
 #define UNO_NAME_TEXT_FONTINDEPENDENTLINESPACING "FontIndependentLineSpacing"
 #define UNO_NAME_TEXT_WORDWRAP                  "TextWordWrap"
+#define UNO_NAME_TEXT_CHAINNEXTNAME              "TextChainNextName"
 
 #define UNO_NAME_MEASUREKIND                    "MeasureKind"
 #define UNO_NAME_MEASURETEXTHPOS                "MeasureTextHorizontalPosition"
diff --git a/include/svx/svdstr.hrc b/include/svx/svdstr.hrc
index 36e8719..8a94938 100644
--- a/include/svx/svdstr.hrc
+++ b/include/svx/svdstr.hrc
@@ -714,4 +714,6 @@
 #define STR_TABLE_STYLE_SETTINGS            (SIP_Begin + 275)
 #define SIP_SA_CROP_MARKERS                 (SIP_Begin + 276)
 
+#define SIP_SA_CHAINNEXTNAME                (SIP_Begin + 277)
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx
index b7a95be..2f8e35e 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -291,6 +291,7 @@
     { OUString(UNO_NAME_TEXT_FONTINDEPENDENTLINESPACING),SDRATTR_TEXT_USEFIXEDCELLHEIGHT,cppu::UnoType<bool>::get(),                   0,      0},               \
     { OUString(UNO_NAME_TEXT_VERTADJUST),       SDRATTR_TEXT_VERTADJUST,        cppu::UnoType<css::drawing::TextVerticalAdjust>::get(),    0,      0},\
     { OUString(UNO_NAME_TEXT_WORDWRAP),         SDRATTR_TEXT_WORDWRAP,          cppu::UnoType<bool>::get(),        0,      0}, \
+    { OUString(UNO_NAME_TEXT_CHAINNEXTNAME),    SDRATTR_TEXT_CHAINNEXTNAME,     ::cppu::UnoType<OUString>::get(),        0,      0}, \
     SVX_UNOEDIT_CHAR_PROPERTIES, \
     SVX_UNOEDIT_PARA_PROPERTIES,
 
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 2b22692..c824318 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -164,6 +164,7 @@ SdrItemPool::SdrItemPool(
     mppLocalPoolDefaults[SDRATTR_XMLATTRIBUTES -SDRATTR_START]=new SvXMLAttrContainerItem( SDRATTR_XMLATTRIBUTES );
     mppLocalPoolDefaults[SDRATTR_TEXT_USEFIXEDCELLHEIGHT -SDRATTR_START]=new SdrTextFixedCellHeightItem;
     mppLocalPoolDefaults[SDRATTR_TEXT_WORDWRAP         -SDRATTR_START]=new SdrOnOffItem(SDRATTR_TEXT_WORDWRAP, true);
+    mppLocalPoolDefaults[SDRATTR_TEXT_CHAINNEXTNAME    -SDRATTR_START]=new SfxStringItem(SDRATTR_TEXT_CHAINNEXTNAME, "");
     mppLocalPoolDefaults[SDRATTR_TEXT_AUTOGROWSIZE     -SDRATTR_START]=new SdrOnOffItem(SDRATTR_TEXT_AUTOGROWSIZE, false);
     mppLocalPoolDefaults[SDRATTR_EDGEKIND         -SDRATTR_START]=new SdrEdgeKindItem;
     mppLocalPoolDefaults[SDRATTR_EDGENODE1HORZDIST-SDRATTR_START]=new SdrEdgeNode1HorzDistItem(nDefEdgeDist);
@@ -499,6 +500,7 @@ void SdrItemPool::TakeItemName(sal_uInt16 nWhich, OUString& rItemName)
         case SDRATTR_XMLATTRIBUTES          : nResId = SIP_SA_XMLATTRIBUTES;break;
         case SDRATTR_TEXT_USEFIXEDCELLHEIGHT: nResId = SIP_SA_TEXT_USEFIXEDCELLHEIGHT;break;
         case SDRATTR_TEXT_WORDWRAP          : nResId = SIP_SA_WORDWRAP;break;
+        case SDRATTR_TEXT_CHAINNEXTNAME     : nResId = SIP_SA_CHAINNEXTNAME;break;
         case SDRATTR_TEXT_AUTOGROWSIZE      : nResId = SIP_SA_AUTOGROWSIZE;break;
 
         case SDRATTR_EDGEKIND           : nResId = SIP_SA_EDGEKIND;break;
diff --git a/svx/source/svdraw/svdstr.src b/svx/source/svdraw/svdstr.src
index 6dc4420..bfe195b 100644
--- a/svx/source/svdraw/svdstr.src
+++ b/svx/source/svdraw/svdstr.src
@@ -2114,6 +2114,11 @@ String SIP_SA_WORDWRAP
     Text[ en-US ] = "Word wrap text in shape";
 };
 
+String SIP_SA_CHAINNEXTNAME
+{
+    Text[ en-US ] = "Next link in text chain";
+};
+
 String SIP_SA_AUTOGROWSIZE
 {
     Text[ en-US ] = "Auto grow shape to fit text";
commit c7ff7fe73e2c1ffd3f24ed672164c3dc7f31354c
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jul 27 17:27:32 2015 +0200

    Add TextChainNextName svddef.h
    
    Change-Id: I1589b610f6cf794befe7b95a775192f0d80fd154

diff --git a/include/svx/svddef.hxx b/include/svx/svddef.hxx
index 0e92e7f..1cdacb7 100644
--- a/include/svx/svddef.hxx
+++ b/include/svx/svddef.hxx
@@ -112,6 +112,7 @@
 #define SDRATTR_TEXT_USEFIXEDCELLHEIGHT (SDRATTR_MISC_FIRST +24)   /*   1121 */ /*   1121 */ /*   1104 */             /* Pool V2 */
 #define SDRATTR_TEXT_WORDWRAP           (SDRATTR_MISC_FIRST +25)   /*   1122 */ /*   1122 */ /*   1105 */             /* Pool V2 */
 #define SDRATTR_TEXT_AUTOGROWSIZE       (SDRATTR_MISC_FIRST +26)   /*   1123 */ /*   1123 */ /*   1106 */             /* Pool V2 */
+#define SDRATTR_TEXT_CHAINNEXTNAME      (SDRATTR_MISC_FIRST + 27)   /*  1124 */ /*   11124 */
 #define SDRATTR_MISC_LAST               (SDRATTR_TEXT_AUTOGROWSIZE)        /* 1125   */ /* 1125   */ /* 1108   */ /* Pool V1: 1056 */
 
 #define SDRATTR_EDGE_FIRST              (SDRATTR_MISC_LAST + 1)      /* 1127   */ /* Pool V4 */
commit 089667672e3a0f5f7f1ff4aa8cb340f263614f42
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jul 27 17:09:40 2015 +0200

    Add TextChainNextName to the set of mapped properties
    
    Change-Id: Ie7b11d56bc2ace27110abd0a2d0e034e54c1c2f7

diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx
index 45920d9..e6764ec 100644
--- a/xmloff/source/draw/sdpropls.cxx
+++ b/xmloff/source/draw/sdpropls.cxx
@@ -146,6 +146,7 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
     GMAP( "NumberingRules",                 XML_NAMESPACE_TEXT, XML_LIST_STYLE,             XML_SD_TYPE_NUMBULLET|MID_FLAG_ELEMENT_ITEM, CTF_NUMBERINGRULES ),
     GMAP( "NumberingRules",                 XML_NAMESPACE_TEXT, XML_LIST_STYLE_NAME,        XML_TYPE_STRING, CTF_SD_NUMBERINGRULES_NAME ),
     GMAP( "TextWordWrap",                   XML_NAMESPACE_FO,   XML_WRAP_OPTION,            XML_TYPE_WRAP_OPTION, 0 ),
+    GMAP( "TextChainNextName",              XML_NAMESPACE_DRAW,   XML_CHAIN_NEXT_NAME,      XML_TYPE_STRING, 0 ),
 
     // shadow attributes
     GMAP( "Shadow",                         XML_NAMESPACE_DRAW, XML_SHADOW,                 XML_SD_TYPE_SHADOW, 0 ),
commit a428705c9fa17b772466a33183113fcbcb7d1206
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jul 27 14:07:58 2015 +0200

    Make linking only for chainable boxes
    
    Change-Id: Ia8ed6ae90abba5a0c3092c5a1d781443ea611fc9

diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index d9b16b8..1aa6e73 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1986,7 +1986,17 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
 
 bool SdrTextObj::IsChainable() const
 {
-    // XXX: Hack to have links together
+    // XXX
+    if (!GetName().startsWith("Chainable")) {
+        //fprintf(stderr, "[CHAINABLE?] %p is _not_ chainable\n", this);
+        return false;
+    }
+
+    // Check that no overflow is going on
+    if (!GetTextChain() || GetTextChain()->GetNilChainingEvent(this))
+        return false;
+
+     // XXX: Hack to have links together
     static bool bHasDoneTheLinking = false;
 
     SdrTextObj *pTxtObj0 =  dynamic_cast< SdrTextObj * >( pPage->GetObj( 0 ) );
@@ -1998,19 +2008,9 @@ bool SdrTextObj::IsChainable() const
 
         bHasDoneTheLinking = true;
     }
+    // end hack
 
 
-
-    // XXX
-    if (!GetName().startsWith("Chainable")) {
-        //fprintf(stderr, "[CHAINABLE?] %p is _not_ chainable\n", this);
-        return false;
-    }
-
-    // Check that no overflow is going on
-    if (!GetTextChain() || GetTextChain()->GetNilChainingEvent(this))
-        return false;
-
     return true;
 
 }
commit 14726320a770747231fd86d0e6112aaabdf4b78e
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jul 27 13:49:38 2015 +0200

    Add hack to link first two boxes in IsChainable
    
    Change-Id: I2903096b48f06e086e5589d88d9147664a868660

diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 5f4f2f5..d9b16b8 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1986,6 +1986,22 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
 
 bool SdrTextObj::IsChainable() const
 {
+    // XXX: Hack to have links together
+    static bool bHasDoneTheLinking = false;
+
+    SdrTextObj *pTxtObj0 =  dynamic_cast< SdrTextObj * >( pPage->GetObj( 0 ) );
+
+    if (!bHasDoneTheLinking && pPage && pPage->GetObjCount() > 1 && this == pTxtObj0)
+    {
+        SdrTextObj *pTxtObj1 =  dynamic_cast< SdrTextObj * >( pPage->GetObj( 1 ) );
+        const_cast<SdrTextObj *>(this)->SetNextLinkInChain(pTxtObj1);
+
+        bHasDoneTheLinking = true;
+    }
+
+
+
+    // XXX
     if (!GetName().startsWith("Chainable")) {
         //fprintf(stderr, "[CHAINABLE?] %p is _not_ chainable\n", this);
         return false;
commit a0f58d255e660c0c18e7e7f2d2947ffaa3253d80
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jul 27 12:46:41 2015 +0200

    Make TextChain creatable only by SdrModel
    
    Change-Id: I5385885a9b2c72c6ce359745d74e396083de8489

diff --git a/include/svx/textchain.hxx b/include/svx/textchain.hxx
index b39cc04..631f646 100644
--- a/include/svx/textchain.hxx
+++ b/include/svx/textchain.hxx
@@ -72,6 +72,7 @@
 
 class ImpChainLinkProperties;
 class SdrTextObj;
+class SdrModel;
 
 namespace rtl {
     class OUString;
@@ -134,7 +135,7 @@ class ImpChainLinkProperties
 class TextChain {
 
     public:
-    TextChain();
+
     ~TextChain();
 
     //void AppendLink(SdrTextObj *);
@@ -157,9 +158,11 @@ class TextChain {
 
 
     protected:
+    TextChain();
     LinkPropertiesMap maLinkPropertiesMap;
 
     private:
+    friend class SdrModel;
     //SdrTextObj *impGetNextLink(const SdrTextObj *) const;
     //SdrTextObj *impGetPrevLink(const SdrTextObj *) const;
 
commit 3995f47972286dc097a9afe2646b8d4711bfa277
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jul 27 12:00:21 2015 +0200

    Implement text chain as doubly linked list in SdrTextObj
    
    Change-Id: Id755e129b9f0dc820eae0c47b21d247ce7c4504c

diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 9191841..bdab026 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -329,6 +329,7 @@ public:
 
     SdrOutliner&         GetChainingOutliner(const SdrTextObj* pObj=NULL) const;
     TextChain *GetTextChain() const;
+    void SetNextLinkInTextChain(SdrTextObj *pPrev, SdrTextObj *pNext);
 
     SdrOutliner&         GetHitTestOutliner() const { return *pHitTestOutliner; }
     const SdrTextObj*    GetFormattingTextObj() const;
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 59e0463..e4de334 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -230,6 +230,7 @@ protected:
     //FIXME(matteocam)
     // the successor in a chain
     SdrTextObj *mpNextInChain = NULL;
+    SdrTextObj *mpPrevInChain = NULL;
 
     // indicating the for its text to be chained to another text box
     bool mbToBeChained : 1;
@@ -367,6 +368,7 @@ public:
     // Chaining // XXX: how are we using IsToBeChained at the moment?
     bool IsToBeChained() const;
     SdrTextObj *GetNextLinkInChain() const;
+    void SetNextLinkInChain(SdrTextObj *);
     SdrTextObj *GetPrevLinkInChain() const;
     bool IsChainable() const;
     void SetPreventChainable();
diff --git a/include/svx/textchain.hxx b/include/svx/textchain.hxx
index 41f0fc8..b39cc04 100644
--- a/include/svx/textchain.hxx
+++ b/include/svx/textchain.hxx
@@ -137,11 +137,11 @@ class TextChain {
     TextChain();
     ~TextChain();
 
-    void AppendLink(SdrTextObj *);
-    bool IsLinkInChain(SdrTextObj *) const;
+    //void AppendLink(SdrTextObj *);
+    //bool IsLinkInChain(SdrTextObj *) const;
 
-    SdrTextObj *GetNextLink(const SdrTextObj *) const;
-    SdrTextObj *GetPrevLink(const SdrTextObj *) const;
+    //SdrTextObj *GetNextLink(const SdrTextObj *) const;
+    //SdrTextObj *GetPrevLink(const SdrTextObj *) const;
 
     ChainLinkId GetId(const SdrTextObj *) const;
     ImpChainLinkProperties *GetLinkProperties(const SdrTextObj *);
@@ -160,8 +160,8 @@ class TextChain {
     LinkPropertiesMap maLinkPropertiesMap;
 
     private:
-    SdrTextObj *impGetNextLink(const SdrTextObj *) const;
-    SdrTextObj *impGetPrevLink(const SdrTextObj *) const;
+    //SdrTextObj *impGetNextLink(const SdrTextObj *) const;
+    //SdrTextObj *impGetPrevLink(const SdrTextObj *) const;
 
 
 };
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 2260188..cd9b764 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -2013,6 +2013,12 @@ TextChain *SdrModel::GetTextChain() const
     return pTextChain;
 }
 
+void SdrModel::SetNextLinkInTextChain(SdrTextObj *pPrev, SdrTextObj *pNext)
+{
+    // Delegate to SdrTextObj
+    pPrev->SetNextLinkInChain(pNext);
+}
+
 const SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum) const
 {
     DBG_ASSERT(nPgNum < maMaPag.size(), "SdrModel::GetMasterPage: Access out of range (!)");
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 83bd15d..5f4f2f5 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -2082,18 +2082,50 @@ void SdrTextObj::SetObjectItemNoBroadcast(const SfxPoolItem& rItem)
 
 SdrTextObj* SdrTextObj::GetNextLinkInChain() const
 {
+    /*
     if (GetTextChain())
         return GetTextChain()->GetNextLink(this);
 
     return NULL;
+    */
+
+    return mpNextInChain;
+}
+
+void SdrTextObj::SetNextLinkInChain(SdrTextObj *pNextObj)
+{
+    // Basically a doubly linked list implementation
+
+    SdrTextObj *pOldNextObj = mpNextInChain;
+
+    // Replace next link
+    mpNextInChain = pNextObj;
+    // Deal with old next link's prev link
+    if (pOldNextObj) {
+        pOldNextObj->mpPrevInChain = NULL;
+    }
+
+    // Deal with new next link's prev link
+    if (mpNextInChain) {
+        if (mpNextInChain->mpPrevInChain)
+            mpNextInChain->mpPrevInChain->mpNextInChain = NULL;
+        mpNextInChain->mpPrevInChain = this;
+    }
+
+    // TODO: Introduce check for circular chains
+
 }
 
 SdrTextObj* SdrTextObj::GetPrevLinkInChain() const
 {
+    /*
     if (GetTextChain())
         return GetTextChain()->GetPrevLink(this);
 
     return NULL;
+    */
+
+    return mpPrevInChain;
 }
 
 void SdrTextObj::SetPreventChainable()
diff --git a/svx/source/svdraw/textchain.cxx b/svx/source/svdraw/textchain.cxx
index 7cfa0a4..c19b924 100644
--- a/svx/source/svdraw/textchain.cxx
+++ b/svx/source/svdraw/textchain.cxx
@@ -46,6 +46,7 @@ TextChain::~TextChain()
     // XXX: Should free all LinkProperties
 }
 
+/*
 bool TextChain::IsLinkInChain(SdrTextObj *) const
 {
     return true;    // XXX: Should make an actual check
@@ -105,6 +106,7 @@ SdrTextObj *TextChain::impGetPrevLink(const SdrTextObj *pTextObj) const
         return NULL;
     }
 }
+*/
 
 
 ImpChainLinkProperties *TextChain::GetLinkProperties(const SdrTextObj *pLink)
commit 91a53679d4b4716186db10266d5b490fd73708d6
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Mon Jul 27 10:35:30 2015 +0200

    Minor changes
    
    Change-Id: Ibdf1c035a110eb2f95e430fe02d5e01f4ab90247

diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index 9f4e000..6daf59b 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -77,6 +77,8 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
     ESelection aCurSel = pOLV->GetSelection();
 
+    ESelection aEndSelPrevBox(100000, 100000);
+
     sal_Int32 nLastPara = pOutl->GetParagraphCount()-1;
     OUString aLastParaText = pOutl->GetText(pOutl->GetParagraph(nLastPara));
     sal_Int32 nLastParaLen = aLastParaText.getLength();
@@ -110,7 +112,7 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     if (nCode == KEY_LEFT && bAtStartOfTextContent && pPrevLink)
     {
         *pOutCursorEvt = CursorChainingEvent::TO_PREV_LINK;
-        *pOutSel = ESelection(100000, 100000); // Set at end of selection
+        *pOutSel = aEndSelPrevBox; // Set at end of selection
         *bOutHandled = true; // Nothing more to do than move cursor
         return;
     }
@@ -119,7 +121,7 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     if (nCode == KEY_BACKSPACE && bAtStartOfTextContent && pPrevLink)
     {
         *pOutCursorEvt = CursorChainingEvent::TO_PREV_LINK;
-        *pOutSel = ESelection(100000, 100000); // Set at end of selection
+        *pOutSel = aEndSelPrevBox; // Set at end of selection
         *bOutHandled = false; // We need to delete characters after moving cursor
         return;
     }
commit 394fc85fa492159a731f9d5b6dcf2c80c5fd194c
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 18:15:29 2015 +0200

    Add Cursor handling after post-paste chaining
    
    Change-Id: Id3bd5a86e09d0171f6d0afdbd228fa6e45042a6d

diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index 8d267da..c8b8492 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -128,6 +128,7 @@ protected:
     // handler for AutoGrowing text with active Outliner
     DECL_LINK(ImpOutlinerStatusEventHdl,EditStatus*);
     DECL_LINK(ImpChainingEventHdl,void*);
+    DECL_LINK(ImpAfterPasteChainingEventHdl,void*);
     DECL_LINK(ImpOutlinerCalcFieldValueHdl,EditFieldInfo*);
 
     // link for EndTextEditHdl
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index a3b4c17..d86a899 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -533,6 +533,16 @@ IMPL_LINK_NOARG(SdrObjEditView,ImpChainingEventHdl)
     return 0;
 }
 
+IMPL_LINK_NOARG(SdrObjEditView,ImpAfterPasteChainingEventHdl)
+{
+    SdrTextObj* pTextObj = dynamic_cast< SdrTextObj * >( GetTextEditObject());
+    if (!pTextObj)
+        return 0;
+    ImpChainingEventHdl(NULL);
+    TextChainCursorManager *pCursorManager = new TextChainCursorManager(this, pTextObj);
+    ImpMoveCursorAfterChainingEvent(pCursorManager);
+    return 0;
+}
 
 void SdrObjEditView::ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager)
 {
@@ -796,7 +806,7 @@ bool SdrObjEditView::SdrBeginTextEdit(
             pTextEditOutlinerView->ShowCursor();
             pTextEditOutliner->SetStatusEventHdl(LINK(this,SdrObjEditView,ImpOutlinerStatusEventHdl));
             if (pTextObj->IsChainable()) {
-                pTextEditOutlinerView->SetEndPasteLinkHdl(LINK(this,SdrObjEditView,ImpChainingEventHdl) );
+                pTextEditOutlinerView->SetEndPasteLinkHdl(LINK(this,SdrObjEditView,ImpAfterPasteChainingEventHdl) );
                 /* We should call:
                  *
                     ImpChainingEventHdl(NULL);
commit c139549951a5dc61fd62ea9536f746ea9a5b25f7
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 18:04:27 2015 +0200

    Move Chaining post-paste to OutlinerView
    
    Change-Id: If869ba6fc27d4c293a003a88c97cd52b71b9d895

diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 88c6d10..987bd0a 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -705,6 +705,10 @@ void OutlinerView::PasteSpecial()
         pEditView->SetEditEngineUpdateMode( true );
         pOwner->UndoActionEnd( OLUNDO_INSERT );
         pEditView->ShowCursor( true, true );
+
+        // XXX: Not sure if this should be called right before ShowCursor
+        if (aEndPasteLink.IsSet())
+            aEndPasteLink.Call(NULL);
     }
 
 }
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
index 8a93ab8..2bbee1e 100644
--- a/sd/source/ui/view/sdview.cxx
+++ b/sd/source/ui/view/sdview.cxx
@@ -1258,10 +1258,6 @@ void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
         }
     }
 
-    /* Chaining handling */
-    ImpChainingEventHdl(NULL);
-    TextChainCursorManager *pCursorManager = new TextChainCursorManager(this, pTextObj);
-    ImpMoveCursorAfterChainingEvent(pCursorManager);
 }
 
 bool View::ShouldToggleOn(
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 63cc779..a3b4c17 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -795,8 +795,15 @@ bool SdrObjEditView::SdrBeginTextEdit(
 
             pTextEditOutlinerView->ShowCursor();
             pTextEditOutliner->SetStatusEventHdl(LINK(this,SdrObjEditView,ImpOutlinerStatusEventHdl));
-            if (pTextObj->IsChainable())
-                pTextEditOutliner->SetChainingEventHdl(LINK(this,SdrObjEditView,ImpChainingEventHdl) );
+            if (pTextObj->IsChainable()) {
+                pTextEditOutlinerView->SetEndPasteLinkHdl(LINK(this,SdrObjEditView,ImpChainingEventHdl) );
+                /* We should call:
+                 *
+                    ImpChainingEventHdl(NULL);
+                    TextChainCursorManager *pCursorManager = new TextChainCursorManager(this, pTextObj);
+                    ImpMoveCursorAfterChainingEvent(pCursorManager);
+                */
+            }
 
 #ifdef DBG_UTIL
             if (pItemBrowser!=nullptr) pItemBrowser->SetDirty();
commit 801a56252b96ea6c65e34da5a9e2363d09d70dd9
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 17:38:14 2015 +0200

    Handle Chaining after Paste in sd
    
    Change-Id: I0891842228251a52a252a29adbaabbed3f8965ba

diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
index 7668773..61e6939 100644
--- a/include/svx/textchaincursor.hxx
+++ b/include/svx/textchaincursor.hxx
@@ -20,13 +20,15 @@
 #ifndef INCLUDED_SVX_TEXTCHAINCURSOR_HXX
 #define INCLUDED_SVX_TEXTCHAINCURSOR_HXX
 
+#include <svx/svxdllapi.h>
+
 class SdrObjEditView;
 class SdrTextObj;
 class KeyEvent;
 class SdrOutliner;
 
 
-class TextChainCursorManager
+class SVX_DLLPUBLIC TextChainCursorManager
 {
 public:
     TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj);
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
index 18fbf2e..8a93ab8 100644
--- a/sd/source/ui/view/sdview.cxx
+++ b/sd/source/ui/view/sdview.cxx
@@ -41,6 +41,8 @@
 #include <svx/svdoutl.hxx>
 #include <svx/sdr/contact/displayinfo.hxx>
 
+#include <svx/textchaincursor.hxx>
+
 #include <svx/svdetc.hxx>
 #include <editeng/editstat.hxx>
 
@@ -1204,6 +1206,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() )
@@ -1254,6 +1257,11 @@ void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
             }
         }
     }
+
+    /* Chaining handling */
+    ImpChainingEventHdl(NULL);
+    TextChainCursorManager *pCursorManager = new TextChainCursorManager(this, pTextObj);
+    ImpMoveCursorAfterChainingEvent(pCursorManager);
 }
 
 bool View::ShouldToggleOn(
commit f85111d1ff33f0fd4ad244096ac289f785c64b6b
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 17:16:08 2015 +0200

    Detect DEL by KeyFuncType::DELETE
    
    Change-Id: I062360a104e9ed07ac4b693536df0c45f18078b3

diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index 35a339e..9f4e000 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -68,7 +68,7 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
 
     // We need to have this KeyFuncType
-    if (eFunc !=  KeyFuncType::DONTKNOW)
+    if (eFunc !=  KeyFuncType::DONTKNOW && eFunc != KeyFuncType::DELETE)
     {
         *pOutCursorEvt = CursorChainingEvent::NULL_EVENT;
         return;
@@ -94,7 +94,7 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     }
 
     // Possibility: Are we "pushing" at the end of the object?
-    if (nCode == KEY_DELETE && bAtEndOfTextContent && pNextLink)
+    if (eFunc == KeyFuncType::DELETE && bAtEndOfTextContent && pNextLink)
     {
         *pOutCursorEvt = CursorChainingEvent::TO_NEXT_LINK;
         // Selection unchanged: we are at the beginning of the box
commit 221e1f9d8a33a6cf0a99ab3d863525581e75f954
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 16:29:47 2015 +0200

    Handle DEL calling Sdr*View::KeyInput instead of OutlinerView::PostKeyEvent
    
    Change-Id: I7f4483e5165d30786288462fe5397ee93e477673

diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 0eb9f29..2ed7864 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -908,7 +908,8 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
                 {
                     vcl::KeyCode aKCode(KEY_DELETE);
                     KeyEvent aKEvt( 0, aKCode);
-                    pOLV->PostKeyEvent(aKEvt);
+                    //pOLV->PostKeyEvent(aKEvt);
+                    mpDrawView->KeyInput(aKEvt, NULL);
                 }
             }
             else
commit 1863697842932e3655f1b72647712c8ddc7d8ed1
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 12:04:31 2015 +0200

    Handle Delete
    
    Change-Id: I17a1886689785420fb881bea8f1d609ab3f35c4e

diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index cf39d33..8d267da 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;
 
 enum class CursorChainingEvent;
 class ESelection;
@@ -110,8 +111,8 @@ protected:
 
     OutlinerView* ImpFindOutlinerView(vcl::Window* pWin) const;
 
-    void ImpMoveCursorAfterChainingEvent();
-    bool ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin);
+    void ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager);
+    TextChainCursorManager *ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin, bool *bOutHandled);
 
     // Create a new OutlinerView at the heap and initialize all required parameters.
     // pTextEditObj, pTextEditPV and pTextEditOutliner have to be initialized
diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
index 1d9c4de..7668773 100644
--- a/include/svx/textchaincursor.hxx
+++ b/include/svx/textchaincursor.hxx
@@ -31,19 +31,28 @@ class TextChainCursorManager
 public:
     TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj);
 
-    bool HandleKeyEvent( const KeyEvent& rKEvt ) const;
+    bool HandleKeyEvent( const KeyEvent& rKEvt );
+
+    // Used by HandledKeyEvent and basic building block for handling cursor event
     void HandleCursorEvent(const CursorChainingEvent aCurEvt,
-                           const ESelection  aNewSel) const;
+                           const ESelection  aNewSel);
+
+    // To be used after chaining event to deal with some nuisances
+    void  HandleCursorEventAfterChaining(const CursorChainingEvent aCurEvt,
+                                         const ESelection  aNewSel);
 
 private:
     SdrObjEditView *mpEditView;
     const SdrTextObj *mpTextObj;
 
-    void impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const;
+    // flag for handling of CANC which is kind of an exceptional case
+    bool mbHandlingDel;
+
+    void impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel);
     void impDetectEvent(const KeyEvent& rKEvt,
                         CursorChainingEvent *pOutCursorEvt,
                         ESelection *pOutSel,
-                        bool *bOutHandled) const;
+                        bool *bOutHandled);
 };
 
 
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 8968828..63cc779 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -533,9 +533,10 @@ IMPL_LINK_NOARG(SdrObjEditView,ImpChainingEventHdl)
     return 0;
 }
 
-void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
+
+void SdrObjEditView::ImpMoveCursorAfterChainingEvent(TextChainCursorManager *pCursorManager)
 {
-    if (!mxTextEditObj.is())
+    if (!mxTextEditObj.is() || !pCursorManager)
         return;
 
     SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
@@ -546,8 +547,8 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
     TextChain *pTextChain = pTextObj->GetTextChain();
     ESelection aNewSel = pTextChain->GetPostChainingSel(pTextObj);
 
-    TextChainCursorManager aCursorManager(this, pTextObj);
-    aCursorManager.HandleCursorEvent(
+
+    pCursorManager->HandleCursorEventAfterChaining(
         pTextChain->GetCursorEvent(pTextObj),
         aNewSel);
 
@@ -1260,25 +1261,30 @@ bool SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const
     return bOk;
 }
 
-bool SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
+TextChainCursorManager *SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(
+                                            const KeyEvent& rKEvt,
+                                            vcl::Window* pWin,
+                                            bool *bOutHandled)
 {
+    *bOutHandled = false;
+
     SdrTextObj* pTextObj = NULL;
     if (mxTextEditObj.is())
         pTextObj= dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
     else
-        return false;
+        return NULL;
 
     if (!pTextObj->IsChainable())
-        return false;
+        return NULL;
 
-    TextChainCursorManager aCursorManager(this, pTextObj);
-    if( aCursorManager.HandleKeyEvent(rKEvt) ) {
+    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.
-        return true;
-    } else {
-        return false;
+        *bOutHandled = true;
     }
+
+    return pCursorManager;
 }
 
 bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
@@ -1286,7 +1292,10 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
     if(pTextEditOutlinerView)
     {
         // We possibly move to another box before any handling
-        if (ImpHandleMotionThroughBoxesKeyInput(rKEvt, pWin))
+        bool bHandled = false;
+        TextChainCursorManager *pCursorManager =
+            ImpHandleMotionThroughBoxesKeyInput(rKEvt, pWin, &bHandled);
+        if (bHandled)
             return true;
 
         // FIXME(matteocam): Old code from here
@@ -1301,7 +1310,7 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
             // FIXME(matteocam)
             // Start chaining processing
             ImpChainingEventHdl(NULL);
-            ImpMoveCursorAfterChainingEvent();
+            ImpMoveCursorAfterChainingEvent(pCursorManager);
             // End chaining processing
 
             if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index af2af7c..35a339e 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -28,14 +28,15 @@
 
 TextChainCursorManager::TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj) :
     mpEditView(pEditView),
-    mpTextObj(pTextObj)
+    mpTextObj(pTextObj),
+    mbHandlingDel(false)
 {
     assert(mpEditView);
     assert(mpTextObj);
 
 }
 
-bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const
+bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt )
 {
     ESelection aNewSel;
     CursorChainingEvent aCursorEvent;
@@ -56,7 +57,7 @@ bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const
 void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
                                             CursorChainingEvent *pOutCursorEvt,
                                             ESelection *pOutSel,
-                                            bool *bOutHandled) const
+                                            bool *bOutHandled)
 {
     SdrOutliner *pOutl = mpEditView->GetTextEditOutliner();
     OutlinerView *pOLV = mpEditView->GetTextEditOutlinerView();
@@ -92,6 +93,16 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
         return;
     }
 
+    // Possibility: Are we "pushing" at the end of the object?
+    if (nCode == KEY_DELETE && bAtEndOfTextContent && pNextLink)
+    {
+        *pOutCursorEvt = CursorChainingEvent::TO_NEXT_LINK;
+        // Selection unchanged: we are at the beginning of the box
+        *bOutHandled = false; // We still need to delete the characters
+        mbHandlingDel = true;
+        return;
+    }
+
     ESelection aStartSel = ESelection(0, 0);
     bool bAtStartOfTextContent = aCurSel.IsEqual(aStartSel);
 
@@ -118,16 +129,40 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
 
 }
 
+void TextChainCursorManager::HandleCursorEventAfterChaining(
+                            const CursorChainingEvent aCurEvt,
+                            const ESelection  aNewSel)
+
+{
+     // Special case for DELETE handling: we need to get back at the end of the prev box
+    if (mbHandlingDel) {
+        // reset flag
+        mbHandlingDel = false;
+
+        // Move to end of prev box
+        SdrTextObj *pPrevLink = mpTextObj->GetPrevLinkInChain();
+        ESelection aEndSel(100000, 100000);
+        impChangeEditingTextObj(pPrevLink, aEndSel);
+        return;
+    }
+
+    // Standard handling
+    HandleCursorEvent(aCurEvt, aNewSel);
+}
+
+
 void TextChainCursorManager::HandleCursorEvent(
                             const CursorChainingEvent aCurEvt,
                             const ESelection  aNewSel)
-                            const
+
 {
 
     OutlinerView* pOLV = mpEditView->GetTextEditOutlinerView();
     SdrTextObj *pNextLink = mpTextObj->GetNextLinkInChain();
     SdrTextObj *pPrevLink = mpTextObj->GetPrevLinkInChain();
 
+
+
     switch ( aCurEvt ) {
             case CursorChainingEvent::UNCHANGED:
                 // Set same selection as before the chaining (which is saved as PostChainingSel)
@@ -148,7 +183,7 @@ void TextChainCursorManager::HandleCursorEvent(
 
 }
 
-void TextChainCursorManager::impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const
+void TextChainCursorManager::impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel)
 {
     assert(pTargetTextObj);
 
@@ -156,7 +191,10 @@ void TextChainCursorManager::impChangeEditingTextObj(SdrTextObj *pTargetTextObj,
     mpEditView->SdrBeginTextEdit(pTargetTextObj);
     // OutlinerView has changed, so we update the pointer
     OutlinerView *pOLV = mpEditView->GetTextEditOutlinerView();
-    pOLV->SetSelection(aNewSel); // XXX
+    pOLV->SetSelection(aNewSel);
+
+    // Update reference text obj
+    mpTextObj = pTargetTextObj;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit a1b0674bbb734d8acb0e1358cab1dcae47ee7e9b
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 11:15:21 2015 +0200

    Remove test for next link in chain before moving cursor
    
    Change-Id: I37a22ab3ca02d6105d632a6cd08521f7bc5ee431

diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index b89fe66..8968828 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -540,7 +540,7 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
 
     SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
 
-    if (!pTextObj->IsChainable() || !pTextObj->GetNextLinkInChain())
+    if (!pTextObj->IsChainable())
         return;
 
     TextChain *pTextChain = pTextObj->GetTextChain();
commit d8b954355943e61b6269957e88c19717c3217c53
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 11:00:27 2015 +0200

    Handle Backspace
    
    Change-Id: Ied9802481595f1f823ccd1abe6b6ccc97897a856

diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
index b56dd72..1d9c4de 100644
--- a/include/svx/textchaincursor.hxx
+++ b/include/svx/textchaincursor.hxx
@@ -42,7 +42,8 @@ private:
     void impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const;
     void impDetectEvent(const KeyEvent& rKEvt,
                         CursorChainingEvent *pOutCursorEvt,
-                        ESelection *pOutSel) const;
+                        ESelection *pOutSel,
+                        bool *bOutHandled) const;
 };
 
 
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index 3952d8b..af2af7c 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -41,19 +41,22 @@ bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const
     CursorChainingEvent aCursorEvent;
 
     // check what the cursor/event situation looks like
-    impDetectEvent(rKEvt, &aCursorEvent, &aNewSel);
+    bool bCompletelyHandled = false;
+    impDetectEvent(rKEvt, &aCursorEvent, &aNewSel, &bCompletelyHandled);
 
     if (aCursorEvent == CursorChainingEvent::NULL_EVENT)
         return false;
     else {
         HandleCursorEvent(aCursorEvent, aNewSel);
-        return true;
+        // return value depends on the situation we are in
+        return bCompletelyHandled;
     }
 }
 
 void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
                                             CursorChainingEvent *pOutCursorEvt,
-                                            ESelection *pOutSel) const
+                                            ESelection *pOutSel,
+                                            bool *bOutHandled) const
 {
     SdrOutliner *pOutl = mpEditView->GetTextEditOutliner();
     OutlinerView *pOLV = mpEditView->GetTextEditOutlinerView();
@@ -80,22 +83,33 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     ESelection aEndSel = ESelection(nLastPara, nLastParaLen);
     bool bAtEndOfTextContent = aCurSel.IsEqual(aEndSel);
 
-    // Are we "pushing" at the end of the object?
+    // Possibility: Are we "pushing" at the end of the object?
     if (nCode == KEY_RIGHT && bAtEndOfTextContent && pNextLink)
     {
         *pOutCursorEvt = CursorChainingEvent::TO_NEXT_LINK;
         // Selection unchanged: we are at the beginning of the box
+        *bOutHandled = true; // Nothing more to do than move cursor
         return;
     }
 
     ESelection aStartSel = ESelection(0, 0);
     bool bAtStartOfTextContent = aCurSel.IsEqual(aStartSel);
 
-    // Are we "pushing" at the start of the object?
+    // Possibility: Are we "pushing" at the start of the object?
     if (nCode == KEY_LEFT && bAtStartOfTextContent && pPrevLink)
     {
         *pOutCursorEvt = CursorChainingEvent::TO_PREV_LINK;
         *pOutSel = ESelection(100000, 100000); // Set at end of selection
+        *bOutHandled = true; // Nothing more to do than move cursor
+        return;
+    }
+
+    // Possibility: Are we "pushing" at the start of the object and deleting left?
+    if (nCode == KEY_BACKSPACE && bAtStartOfTextContent && pPrevLink)
+    {
+        *pOutCursorEvt = CursorChainingEvent::TO_PREV_LINK;
+        *pOutSel = ESelection(100000, 100000); // Set at end of selection
+        *bOutHandled = false; // We need to delete characters after moving cursor
         return;
     }
 
commit 100c78a6ee4e45accfa8f9c59a63a823d4f0eed0
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 02:14:16 2015 +0200

    Handle Left Arrow and Prev Link
    
    Change-Id: I08f56fc5fc747d097d90313f4bfec14091b6f5a7

diff --git a/svx/source/svdraw/textchain.cxx b/svx/source/svdraw/textchain.cxx
index 86357c2..7cfa0a4 100644
--- a/svx/source/svdraw/textchain.cxx
+++ b/svx/source/svdraw/textchain.cxx
@@ -89,17 +89,17 @@ SdrTextObj *TextChain::impGetNextLink(const SdrTextObj *pTextObj) const
 
 SdrTextObj *TextChain::impGetPrevLink(const SdrTextObj *pTextObj) const
 {
-    SdrTextObj *pNextTextObj = NULL;
+    SdrTextObj *pPrevTextObj = NULL;
     SdrPage *pPage = pTextObj->pPage;
 
     if ( pPage && pPage->GetObjCount() > 1) {
 
-        sal_uInt32 nextIndex = (pTextObj->GetOrdNum()-1);
+        sal_Int32 prevIndex = (pTextObj->GetOrdNum()-1);
 
-        if (nextIndex > 0)
-            pNextTextObj =  dynamic_cast< SdrTextObj * >( pPage->GetObj( nextIndex ) );
+        if (prevIndex >= 0)
+            pPrevTextObj =  dynamic_cast< SdrTextObj * >( pPage->GetObj( prevIndex ) );
 
-        return pNextTextObj;
+        return pPrevTextObj;
     } else {
         fprintf(stderr, "Make New Object please\n");
         return NULL;
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index 7ca44f7..3952d8b 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -58,6 +58,9 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     SdrOutliner *pOutl = mpEditView->GetTextEditOutliner();
     OutlinerView *pOLV = mpEditView->GetTextEditOutlinerView();
 
+    SdrTextObj *pNextLink = mpTextObj->GetNextLinkInChain();
+    SdrTextObj *pPrevLink = mpTextObj->GetPrevLinkInChain();
+
     KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
 
     // We need to have this KeyFuncType
@@ -74,17 +77,27 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     OUString aLastParaText = pOutl->GetText(pOutl->GetParagraph(nLastPara));
     sal_Int32 nLastParaLen = aLastParaText.getLength();
 
-    bool bAtEndOfTextContent =
-        (aCurSel.nEndPara == nLastPara) &&
-        (aCurSel.nEndPos == nLastParaLen);
+    ESelection aEndSel = ESelection(nLastPara, nLastParaLen);
+    bool bAtEndOfTextContent = aCurSel.IsEqual(aEndSel);
 
-    if (nCode == KEY_RIGHT && bAtEndOfTextContent)
+    // Are we "pushing" at the end of the object?
+    if (nCode == KEY_RIGHT && bAtEndOfTextContent && pNextLink)
     {
         *pOutCursorEvt = CursorChainingEvent::TO_NEXT_LINK;
         // Selection unchanged: we are at the beginning of the box
+        return;
     }
 
-    // if (nCode == KEY_LEFT && bAtStartOfTextContent) ...
+    ESelection aStartSel = ESelection(0, 0);
+    bool bAtStartOfTextContent = aCurSel.IsEqual(aStartSel);
+
+    // Are we "pushing" at the start of the object?
+    if (nCode == KEY_LEFT && bAtStartOfTextContent && pPrevLink)
+    {
+        *pOutCursorEvt = CursorChainingEvent::TO_PREV_LINK;
+        *pOutSel = ESelection(100000, 100000); // Set at end of selection
+        return;
+    }
 
     // If arrived here there is no event detected
     *pOutCursorEvt = CursorChainingEvent::NULL_EVENT;
commit a55e9a4b93c10bd1f01f75f06d43fec65f1b983e
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 01:38:16 2015 +0200

    Add specific method for detecting event
    
    Change-Id: I3030f4a5c80bcade440fb66d578430abb15dfc44

diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
index ce5200f..b56dd72 100644
--- a/include/svx/textchaincursor.hxx
+++ b/include/svx/textchaincursor.hxx
@@ -23,6 +23,7 @@
 class SdrObjEditView;
 class SdrTextObj;
 class KeyEvent;
+class SdrOutliner;
 
 
 class TextChainCursorManager
@@ -39,6 +40,9 @@ private:
     const SdrTextObj *mpTextObj;
 
     void impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const;
+    void impDetectEvent(const KeyEvent& rKEvt,
+                        CursorChainingEvent *pOutCursorEvt,
+                        ESelection *pOutSel) const;
 };
 
 
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 27db21d..b89fe66 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1268,6 +1268,9 @@ bool SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt,
     else
         return false;
 
+    if (!pTextObj->IsChainable())
+        return false;
+
     TextChainCursorManager aCursorManager(this, pTextObj);
     if( aCursorManager.HandleKeyEvent(rKEvt) ) {
         // Possibly do other stuff here if necessary...
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index a0def07..7ca44f7 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -30,49 +30,73 @@ TextChainCursorManager::TextChainCursorManager(SdrObjEditView *pEditView, const
     mpEditView(pEditView),
     mpTextObj(pTextObj)
 {
+    assert(mpEditView);
+    assert(mpTextObj);
 
 }
 
 bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const
 {
-    bool bHandled = false;
+    ESelection aNewSel;
+    CursorChainingEvent aCursorEvent;
+
+    // check what the cursor/event situation looks like
+    impDetectEvent(rKEvt, &aCursorEvent, &aNewSel);
+
+    if (aCursorEvent == CursorChainingEvent::NULL_EVENT)
+        return false;
+    else {
+        HandleCursorEvent(aCursorEvent, aNewSel);
+        return true;
+    }
+}
+
+void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
+                                            CursorChainingEvent *pOutCursorEvt,
+                                            ESelection *pOutSel) const
+{
+    SdrOutliner *pOutl = mpEditView->GetTextEditOutliner();
+    OutlinerView *pOLV = mpEditView->GetTextEditOutlinerView();
 
-    // XXX: Find a clean way to do this (even cleaner than the code commented below)
-    // if( pTextEditOutlinerView->IsKeyEventPushingOutOfPage(rKevt, pWin)
-    //       pWin = HandleKeyPushingOutOfBox(rKevt);
     KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
-    sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
-    ESelection aCurSel = mpEditView->GetTextEditOutlinerView()->GetSelection();
 
-    if (mpTextObj && mpTextObj->IsChainable() && mpTextObj->GetNextLinkInChain() &&
-        eFunc ==  KeyFuncType::DONTKNOW)
+    // We need to have this KeyFuncType
+    if (eFunc !=  KeyFuncType::DONTKNOW)
     {
-        SdrOutliner *pOutl = mpEditView->GetTextEditOutliner();
-        sal_Int32 nLastPara = pOutl->GetParagraphCount()-1;
-        OUString aLastParaText = pOutl->GetText(pOutl->GetParagraph(nLastPara));
-        sal_Int32 nLastParaLen = aLastParaText.getLength();
-
-        if (nCode == KEY_RIGHT &&
-            aCurSel.nEndPara == nLastPara &&
-            aCurSel.nEndPos == nLastParaLen
-            )
-        {
-            fprintf(stderr, "[CHAIN - CURSOR] Trying to move to next box\n" );
-
-            // Move to next box
-            mpEditView->SdrEndTextEdit();
-            SdrTextObj *pNextLink = mpTextObj->GetNextLinkInChain();
-            mpEditView->SdrBeginTextEdit(pNextLink);
-            bHandled = true;
-        }
+        *pOutCursorEvt = CursorChainingEvent::NULL_EVENT;
+        return;
+    }
 
+    sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+    ESelection aCurSel = pOLV->GetSelection();
+
+    sal_Int32 nLastPara = pOutl->GetParagraphCount()-1;
+    OUString aLastParaText = pOutl->GetText(pOutl->GetParagraph(nLastPara));
+    sal_Int32 nLastParaLen = aLastParaText.getLength();
+
+    bool bAtEndOfTextContent =
+        (aCurSel.nEndPara == nLastPara) &&
+        (aCurSel.nEndPos == nLastParaLen);
+
+    if (nCode == KEY_RIGHT && bAtEndOfTextContent)
+    {
+        *pOutCursorEvt = CursorChainingEvent::TO_NEXT_LINK;
+        // Selection unchanged: we are at the beginning of the box
     }
-    return bHandled;
+
+    // if (nCode == KEY_LEFT && bAtStartOfTextContent) ...
+
+    // If arrived here there is no event detected
+    *pOutCursorEvt = CursorChainingEvent::NULL_EVENT;
+
 }
 
-void TextChainCursorManager::HandleCursorEvent(const CursorChainingEvent aCurEvt,
-                           const ESelection  aNewSel) const
+void TextChainCursorManager::HandleCursorEvent(
+                            const CursorChainingEvent aCurEvt,
+                            const ESelection  aNewSel)
+                            const
 {
+
     OutlinerView* pOLV = mpEditView->GetTextEditOutlinerView();
     SdrTextObj *pNextLink = mpTextObj->GetNextLinkInChain();
     SdrTextObj *pPrevLink = mpTextObj->GetPrevLinkInChain();
@@ -99,8 +123,7 @@ void TextChainCursorManager::HandleCursorEvent(const CursorChainingEvent aCurEvt
 
 void TextChainCursorManager::impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const
 {
-    if (!pTargetTextObj)
-        return;
+    assert(pTargetTextObj);
 
     mpEditView->SdrEndTextEdit();
     mpEditView->SdrBeginTextEdit(pTargetTextObj);
commit 0f29998d8bf8e719fbc534a5e0880acbe3a6be27
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 01:03:58 2015 +0200

    Add specific method for cursor event handling
    
    Change-Id: I664e1ac9ac52d7d54e2f3ca35cbb429dc2e131cb

diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
index 456d3c1..ce5200f 100644
--- a/include/svx/textchaincursor.hxx
+++ b/include/svx/textchaincursor.hxx
@@ -31,10 +31,14 @@ public:
     TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj);
 
     bool HandleKeyEvent( const KeyEvent& rKEvt ) const;
+    void HandleCursorEvent(const CursorChainingEvent aCurEvt,
+                           const ESelection  aNewSel) const;
 
 private:
     SdrObjEditView *mpEditView;
     const SdrTextObj *mpTextObj;
+
+    void impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const;
 };
 
 
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index afbf3cf..27db21d 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -543,39 +543,16 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
     if (!pTextObj->IsChainable() || !pTextObj->GetNextLinkInChain())
         return;
 
-
-    SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain();
-    OutlinerView* pOLV = GetTextEditOutlinerView();
-
     TextChain *pTextChain = pTextObj->GetTextChain();
     ESelection aNewSel = pTextChain->GetPostChainingSel(pTextObj);
 
-    switch ( pTextChain->GetCursorEvent(pTextObj) ) {
-
-            case CursorChainingEvent::UNCHANGED:
-                // Set same selection as before the chaining (which is saved as PostChainingSel)
-                // We need an explicit set because the Outliner is messed up
-                //    after text transfer and otherwise it brings us at arbitrary positions.
-                pOLV->SetSelection(aNewSel);
-                break;
-            case CursorChainingEvent::TO_NEXT_LINK:
-                SdrEndTextEdit();
-                SdrBeginTextEdit(pNextLink);
-                // OutlinerView has changed, so we update the pointer
-                pOLV = GetTextEditOutlinerView();
-                pOLV->SetSelection(aNewSel); // XXX
-                break;
-            case CursorChainingEvent::TO_PREV_LINK:
-                // XXX: To be handled
-                break;
-            case CursorChainingEvent::NULL_EVENT:
-                // Do nothing here
-                break;
-    }
+    TextChainCursorManager aCursorManager(this, pTextObj);
+    aCursorManager.HandleCursorEvent(
+        pTextChain->GetCursorEvent(pTextObj),
+        aNewSel);
 
     // Reset event
     pTextChain->SetCursorEvent(pTextObj, CursorChainingEvent::NULL_EVENT);
-
 }
 
 IMPL_LINK_TYPED(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI,void)
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index 37b5931..a0def07 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -22,6 +22,10 @@
 #include <svx/svdedxv.hxx>
 #include <svx/svdoutl.hxx>
 
+// XXX: Possible duplication of code in behavior with stuff in ImpEditView (or ImpEditEngine) and OutlinerView
+
+// XXX: We violate Demeter's Law several times here, I'm afraid
+
 TextChainCursorManager::TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj) :
     mpEditView(pEditView),
     mpTextObj(pTextObj)
@@ -66,4 +70,43 @@ bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const
     return bHandled;
 }
 
+void TextChainCursorManager::HandleCursorEvent(const CursorChainingEvent aCurEvt,
+                           const ESelection  aNewSel) const
+{
+    OutlinerView* pOLV = mpEditView->GetTextEditOutlinerView();
+    SdrTextObj *pNextLink = mpTextObj->GetNextLinkInChain();
+    SdrTextObj *pPrevLink = mpTextObj->GetPrevLinkInChain();
+
+    switch ( aCurEvt ) {
+            case CursorChainingEvent::UNCHANGED:
+                // Set same selection as before the chaining (which is saved as PostChainingSel)
+                // We need an explicit set because the Outliner is messed up
+                //    after text transfer and otherwise it brings us at arbitrary positions.
+                pOLV->SetSelection(aNewSel);
+                break;
+            case CursorChainingEvent::TO_NEXT_LINK:
+                impChangeEditingTextObj(pNextLink, aNewSel);
+                break;
+            case CursorChainingEvent::TO_PREV_LINK:
+                impChangeEditingTextObj(pPrevLink, aNewSel);
+                break;
+            case CursorChainingEvent::NULL_EVENT:
+                // Do nothing here
+                break;
+    }
+
+}
+
+void TextChainCursorManager::impChangeEditingTextObj(SdrTextObj *pTargetTextObj, ESelection aNewSel) const
+{
+    if (!pTargetTextObj)
+        return;
+
+    mpEditView->SdrEndTextEdit();
+    mpEditView->SdrBeginTextEdit(pTargetTextObj);
+    // OutlinerView has changed, so we update the pointer
+    OutlinerView *pOLV = mpEditView->GetTextEditOutlinerView();
+    pOLV->SetSelection(aNewSel); // XXX
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 1780d2ce92b8b15551e9a199615885bd20bf5fa7
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Jul 24 00:24:28 2015 +0200

    Set PostChainingSel even with event UNCHANGED
    
    Change-Id: I5d5133fa46949eab8937e3e83a4e4f53f754f825

diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index f2b3186..afbf3cf 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -553,10 +553,10 @@ void SdrObjEditView::ImpMoveCursorAfterChainingEvent()
     switch ( pTextChain->GetCursorEvent(pTextObj) ) {
 
             case CursorChainingEvent::UNCHANGED:
-                // Set same selection as before the chaining
+                // Set same selection as before the chaining (which is saved as PostChainingSel)
                 // 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));
+                pOLV->SetSelection(aNewSel);
                 break;
             case CursorChainingEvent::TO_NEXT_LINK:
                 SdrEndTextEdit();
diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx
index 4d6352f..581b5be 100644
--- a/svx/source/svdraw/textchainflow.cxx
+++ b/svx/source/svdraw/textchainflow.cxx
@@ -317,18 +317,16 @@ void EditingTextChainFlow::impSetFlowOutlinerParams(SdrOutliner *pFlowOutl, SdrO
 
 void EditingTextChainFlow::impBroadcastCursorInfo() const
 {
-    bool bCursorOut = false;
+    ESelection aPreChainingSel = GetTextChain()->GetPreChainingSel(GetLinkTarget()) ;
+
+    // Test whether the cursor is out of the box.
+    bool bCursorOut = mbPossiblyCursorOut && maOverflowPosSel.IsLess(aPreChainingSel);
 
     // 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;
@@ -336,6 +334,7 @@ void EditingTextChainFlow::impBroadcastCursorInfo() const
             GetTextChain()->SetCursorEvent(GetLinkTarget(), CursorChainingEvent::TO_NEXT_LINK);
     } else {
         //maCursorEvent = CursorChainingEvent::UNCHANGED;
+        GetTextChain()->SetPostChainingSel(GetLinkTarget(), aPreChainingSel);
         GetTextChain()->SetCursorEvent(GetLinkTarget(), CursorChainingEvent::UNCHANGED);
     }
 
commit 0cec9e8af96ab89cb1105460ecbae46cb8505aad
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 23 23:46:47 2015 +0200

    Move code for right motion into TextChainCursorManager
    
    Change-Id: Ifa6aecbd2c55763583f2d48b0883698f876cbc6c

diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
index 71dbc60..456d3c1 100644
--- a/include/svx/textchaincursor.hxx
+++ b/include/svx/textchaincursor.hxx
@@ -20,10 +20,21 @@
 #ifndef INCLUDED_SVX_TEXTCHAINCURSOR_HXX
 #define INCLUDED_SVX_TEXTCHAINCURSOR_HXX
 
+class SdrObjEditView;
+class SdrTextObj;
+class KeyEvent;
 
-class TextChainCursorHandler
+
+class TextChainCursorManager
 {
-    TextChainCursorHandler();
+public:
+    TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj);
+
+    bool HandleKeyEvent( const KeyEvent& rKEvt ) const;
+
+private:
+    SdrObjEditView *mpEditView;
+    const SdrTextObj *mpTextObj;
 };
 
 
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index d41533b..f2b3186 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -52,6 +52,7 @@
 #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>
@@ -1284,49 +1285,20 @@ bool SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const
 
 bool SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
 {
-    // XXX: Find a clean way to do this (even cleaner than the code commented below)
-    // if( pTextEditOutlinerView->IsKeyEventPushingOutOfPage(rKevt, pWin)
-    //       pWin = HandleKeyPushingOutOfBox(rKevt);
-    KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
-    sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
-    ESelection aCurSel = pTextEditOutlinerView->GetSelection();
-
-
     SdrTextObj* pTextObj = NULL;
     if (mxTextEditObj.is())
         pTextObj= dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
+    else
+        return false;
 
-    bool bHandled = false;
-
-    // XXX: Add check for last position in the para
-    if (pTextObj && pTextObj->IsChainable() && pTextObj->GetNextLinkInChain() &&
-        eFunc ==  KeyFuncType::DONTKNOW)
-    {
-        SdrOutliner *pOutl = GetTextEditOutliner();
-        sal_Int32 nLastPara = pOutl->GetParagraphCount()-1;
-        OUString aLastParaText = pOutl->GetText(pOutl->GetParagraph(nLastPara));
-        sal_Int32 nLastParaLen = aLastParaText.getLength();
-
-        if (nCode == KEY_RIGHT &&
-            aCurSel.nEndPara == nLastPara &&
-            aCurSel.nEndPos == nLastParaLen
-            )
-        {
-            fprintf(stderr, "[CHAIN - CURSOR] Trying to move to next box\n" );
-
-            // Move to next box
-            SdrEndTextEdit();
-            SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain();
-            SdrBeginTextEdit(pNextLink);
-            bHandled = true;
-        }
-
+    TextChainCursorManager aCursorManager(this, pTextObj);
+    if( aCursorManager.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.
-
+        return true;
+    } else {
+        return false;
     }
-
-    return bHandled;
-
 }
 
 bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
@@ -1358,8 +1330,6 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin)
 #endif
             ImpMakeTextCursorAreaVisible();
 
-
-
             return true;
         }
     }
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index 45f8533..37b5931 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -17,11 +17,53 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <svx/textchain.hxx>
 #include <svx/textchaincursor.hxx>
+#include <svx/svdedxv.hxx>
+#include <svx/svdoutl.hxx>
 
-TextChainCursorHandler::TextChainCursorHandler()
+TextChainCursorManager::TextChainCursorManager(SdrObjEditView *pEditView, const SdrTextObj *pTextObj) :
+    mpEditView(pEditView),
+    mpTextObj(pTextObj)
 {
 
 }
 
+bool TextChainCursorManager::HandleKeyEvent( const KeyEvent& rKEvt ) const
+{
+    bool bHandled = false;
+
+    // XXX: Find a clean way to do this (even cleaner than the code commented below)
+    // if( pTextEditOutlinerView->IsKeyEventPushingOutOfPage(rKevt, pWin)
+    //       pWin = HandleKeyPushingOutOfBox(rKevt);
+    KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
+    sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+    ESelection aCurSel = mpEditView->GetTextEditOutlinerView()->GetSelection();
+
+    if (mpTextObj && mpTextObj->IsChainable() && mpTextObj->GetNextLinkInChain() &&
+        eFunc ==  KeyFuncType::DONTKNOW)
+    {
+        SdrOutliner *pOutl = mpEditView->GetTextEditOutliner();
+        sal_Int32 nLastPara = pOutl->GetParagraphCount()-1;
+        OUString aLastParaText = pOutl->GetText(pOutl->GetParagraph(nLastPara));
+        sal_Int32 nLastParaLen = aLastParaText.getLength();
+
+        if (nCode == KEY_RIGHT &&
+            aCurSel.nEndPara == nLastPara &&
+            aCurSel.nEndPos == nLastParaLen
+            )
+        {
+            fprintf(stderr, "[CHAIN - CURSOR] Trying to move to next box\n" );
+
+            // Move to next box
+            mpEditView->SdrEndTextEdit();
+            SdrTextObj *pNextLink = mpTextObj->GetNextLinkInChain();
+            mpEditView->SdrBeginTextEdit(pNextLink);
+            bHandled = true;
+        }
+
+    }
+    return bHandled;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 003db9bdfb562401e5fecdbf65b84b9b32e51c6e
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 23 20:49:31 2015 +0200

    Prototype textchaincursor files
    
    Change-Id: Icf93a63f51cae31c804f4ab247e577f5a5deca77

diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
index 0e6c127..71dbc60 100644
--- a/include/svx/textchaincursor.hxx
+++ b/include/svx/textchaincursor.hxx
@@ -1,6 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SVX_TEXTCHAINCURSOR_HXX
+#define INCLUDED_SVX_TEXTCHAINCURSOR_HXX
 
 
 class TextChainCursorHandler
 {
-
+    TextChainCursorHandler();
 };
+
+
+#endif // INCLUDED_SVX_TEXTCHAINCURSOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index bdaf992..d41533b 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1319,9 +1319,9 @@ bool SdrObjEditView::ImpHandleMotionThroughBoxesKeyInput(const KeyEvent& rKEvt,
             SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain();
             SdrBeginTextEdit(pNextLink);
             bHandled = true;
-        } // else if (...)
+        }
 
-        // XXX: Careful with the checks below for pWin and co. You should do them here I guess.
+        // XXX: Careful with the checks below (in KeyInput) for pWin and co. You should do them here I guess.
 
     }
 
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index 8b13789..45f8533 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -1 +1,27 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
 
+#include <svx/textchaincursor.hxx>
+
+TextChainCursorHandler::TextChainCursorHandler()
+{
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit b7a0111465156ae7b6f00d9157588ca19519a26f
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 23 20:45:15 2015 +0200

    Add textchaincursor files
    
    Change-Id: I1d6d5004ee1d5979dd4227141cf7544240399a4f

diff --git a/include/svx/textchaincursor.hxx b/include/svx/textchaincursor.hxx
new file mode 100644
index 0000000..0e6c127
--- /dev/null
+++ b/include/svx/textchaincursor.hxx
@@ -0,0 +1,6 @@
+
+
+class TextChainCursorHandler
+{
+
+};
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 22ce1a3..dc90153 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -341,6 +341,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
     svx/source/svdraw/svdxcgv \
     svx/source/svdraw/textchain \
     svx/source/svdraw/textchainflow \
+    svx/source/svdraw/textchaincursor \
     svx/source/styles/CommonStylePreviewRenderer \
     svx/source/styles/CommonStyleManager \
     svx/source/table/cell \
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -0,0 +1 @@
+
commit e8d89995fb825922584fe45e7fcb103e11bdc175
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 23 20:23:44 2015 +0200

    Write implementation of prev link accessor
    
    Change-Id: I5b66071e00a4edbeb67447938c98d9fcd92158b6

diff --git a/svx/source/svdraw/textchain.cxx b/svx/source/svdraw/textchain.cxx
index ddddb70..86357c2 100644
--- a/svx/source/svdraw/textchain.cxx
+++ b/svx/source/svdraw/textchain.cxx
@@ -89,7 +89,21 @@ SdrTextObj *TextChain::impGetNextLink(const SdrTextObj *pTextObj) const
 
 SdrTextObj *TextChain::impGetPrevLink(const SdrTextObj *pTextObj) const
 {
-    return NULL;
+    SdrTextObj *pNextTextObj = NULL;
+    SdrPage *pPage = pTextObj->pPage;
+
+    if ( pPage && pPage->GetObjCount() > 1) {
+
+        sal_uInt32 nextIndex = (pTextObj->GetOrdNum()-1);
+
+        if (nextIndex > 0)
+            pNextTextObj =  dynamic_cast< SdrTextObj * >( pPage->GetObj( nextIndex ) );
+
+        return pNextTextObj;
+    } else {
+        fprintf(stderr, "Make New Object please\n");
+        return NULL;
+    }
 }
 
 
commit 49fce4abee6d4f3d9635e9b46d6fb0faf0cc7d30
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Jul 23 19:29:07 2015 +0200

    Move (prototype) implementation of prev link in TextChain
    
    Change-Id: I1fab18b994f807d9d1e025f7be274df8dcec8eaf

diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 35b481b..83bd15d 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -2090,7 +2090,9 @@ SdrTextObj* SdrTextObj::GetNextLinkInChain() const
 
 SdrTextObj* SdrTextObj::GetPrevLinkInChain() const
 {
-    // FIXME: To be implemented
+    if (GetTextChain())
+        return GetTextChain()->GetPrevLink(this);
+
     return NULL;
 }
 
diff --git a/svx/source/svdraw/textchain.cxx b/svx/source/svdraw/textchain.cxx
index 31ea1fd..ddddb70 100644
--- a/svx/source/svdraw/textchain.cxx
+++ b/svx/source/svdraw/textchain.cxx
@@ -68,6 +68,8 @@ SdrTextObj *TextChain::GetPrevLink(const SdrTextObj *pTextObj) const
 
 SdrTextObj *TextChain::impGetNextLink(const SdrTextObj *pTextObj) const
 {
+    // XXX: Temporary implementation based on index number
+
     SdrTextObj *pNextTextObj = NULL;
     SdrPage *pPage = pTextObj->pPage;
 
@@ -87,7 +89,6 @@ SdrTextObj *TextChain::impGetNextLink(const SdrTextObj *pTextObj) const
 
 SdrTextObj *TextChain::impGetPrevLink(const SdrTextObj *pTextObj) const
 {
-    // XXX: To be implemented

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list