include/svx/svdmodel.hxx | 1 + include/svx/svdotext.hxx | 2 ++ include/svx/textchain.hxx | 12 ++++++------ svx/source/svdraw/svdmodel.cxx | 6 ++++++ svx/source/svdraw/svdotext.cxx | 32 ++++++++++++++++++++++++++++++++ svx/source/svdraw/textchain.cxx | 2 ++ 6 files changed, 49 insertions(+), 6 deletions(-)
New commits: commit c6987ebc1dc98d0d9807ff3c9b683ade341eb8fe Author: matteocam <matteo.campane...@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 815ab1c..4b5c462 100644 --- a/include/svx/svdmodel.hxx +++ b/include/svx/svdmodel.hxx @@ -338,6 +338,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 6dc4ed4..17a542c 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits