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

matteocam matteo.campanelli at gmail.com
Wed Jul 29 09:57:31 PDT 2015


 svx/source/svdraw/svdotext.cxx              |   52 ++++++++++++++++++++++++++--
 svx/source/svdraw/svdotextdecomposition.cxx |    3 +
 2 files changed, 53 insertions(+), 2 deletions(-)

New commits:
commit 8e7192c5e053684aaaa930e82a5c6bd53905ac2a
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 b627b77..25feda4 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -1425,6 +1425,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 452ac5b3b37dc3c06ff0dbe958cc65417f2ed064
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


More information about the Libreoffice-commits mailing list