[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-chained-text-boxes' - include/svx svx/source
matteocam
matteo.campanelli at gmail.com
Wed Jul 8 07:31:24 PDT 2015
include/svx/textchain.hxx | 88 ++++++++++++++++++++++++++++++++----
svx/source/svdraw/svdedxv.cxx | 14 -----
svx/source/svdraw/textchain.cxx | 39 ++++-----------
svx/source/svdraw/textchainflow.cxx | 2
4 files changed, 89 insertions(+), 54 deletions(-)
New commits:
commit 4c9e5c5862d1aed26f96228c2fe01ebf0de8fd01
Author: matteocam <matteo.campanelli at gmail.com>
Date: Wed Jul 8 10:29:51 2015 -0400
Define macro system for text chain properties
Change-Id: Id50a9996e0b60e0650dbd67fdb4ebbc8ef2f1d4a
diff --git a/include/svx/textchain.hxx b/include/svx/textchain.hxx
index 730489b..efd52ef 100644
--- a/include/svx/textchain.hxx
+++ b/include/svx/textchain.hxx
@@ -20,6 +20,52 @@
#ifndef INCLUDED_SVX_TEXTCHAIN_HXX
#define INCLUDED_SVX_TEXTCHAIN_HXX
+/*
+ * Properties can be accessed and set from a TextChain with:
+ * - T TextChain::GetPROPNAME(SdrTextObj *)
+ * - void TextChain::SetPROPNAME(SdrTextObj *, T)
+ * where T and PROPNAME are respectively type and name of a property.
+ *
+ * To add a property PROPNAME of type T (and its interface) in TextChain:
+ * 1) Add
+ * "DECL_CHAIN_PROP(PROPNAME, T)"
+ * in class ImpChainLinkProperties;
+ * 2) Add
+ * "INIT_CHAIN_PROP(PROPNAME, V)"
+ * in constructor of ImpChainLinkProperties below
+ * (V is the initialization value for PROPNAME)
+ *
+ * 2) Add
+ * "DECL_CHAIN_PROP_INTERFACE(PROPNAME, T)"
+ * in class TextChain (under "public:");
+ * 3) Add
+ * "IMPL_CHAIN_PROP_INTERFACE(PROPNAME, T)"
+ * in file "svx/source/svdraw/textchain.cxx"
+*/
+
+#define DECL_CHAIN_PROP(PropName, PropType) \
+ PropType a##PropName;
+
+#define INIT_CHAIN_PROP(PropName, PropDefault) \
+ a##PropName = (PropDefault);
+
+#define DECL_CHAIN_PROP_INTERFACE(PropName, PropType) \
+ PropType Get##PropName (SdrTextObj *); \
+ void Set##PropName (SdrTextObj *, PropType);
+
+#define IMPL_CHAIN_PROP_INTERFACE(PropName, PropType) \
+ PropType TextChain::Get##PropName (SdrTextObj *pTarget) { \
+ ImpChainLinkProperties *pLinkProperties = GetLinkProperties(pTarget); \
+ return pLinkProperties->a##PropName; \
+ } \
+ void TextChain::Set##PropName (SdrTextObj *pTarget, PropType aPropParam) \
+ { \
+ ImpChainLinkProperties *pLinkProperties = GetLinkProperties(pTarget); \
+ pLinkProperties->a##PropName = aPropParam; \
+ }
+
+/* End Special Properties Macro */
+
#include <map>
class ImpChainLinkProperties;
@@ -39,16 +85,40 @@ enum class CursorChainingEvent
UNCHANGED
};
+/*
+ * // Note Sure I need the code here
+struct CursorChainingInfo
+{
+ public:
+ CursorChainingEvent GetEvent() const;
+ ESelection GetPreChainingSel() const;
+ ESelection GetPostChainingSel() const;
+
+ void SetEvent(CursorChainingEvent aEvent) { maEvent = aEvent; }
+ void SetPreChainingSel(ESelection aSel) { maPreChainingSel = aSel; }
+ void SetPostChainingSel(ESelection aSel) { maPostChaingingSel = aSel; }
+ private:
+ CursorChainingEvent maEvent;
+ ESelection maPreChainingSel;
+ ESelection maPostChainingSel;
+};
+* */
+
class ImpChainLinkProperties
{
protected:
friend class TextChain;
- ImpChainLinkProperties();
+ ImpChainLinkProperties() {
+ INIT_CHAIN_PROP(NilChainingEvent, false)
+ INIT_CHAIN_PROP(CursorEvent, CursorChainingEvent::UNCHANGED)
+ }
+ private:
// NOTE: Remember to set default value in contructor when adding field
- bool bNilChainingEvent;
- CursorChainingEvent aCursorEvent; // XXX: replace with enum instead of bool?
+ DECL_CHAIN_PROP(NilChainingEvent, bool)
+ DECL_CHAIN_PROP(CursorEvent, CursorChainingEvent)
+
};
@@ -62,18 +132,18 @@ class TextChain {
bool IsLinkInChain(SdrTextObj *) const;
SdrTextObj *GetNextLink(SdrTextObj *) const;
- CursorChainingEvent GetCursorEvent(SdrTextObj *);
- void SetCursorEvent(SdrTextObj *, CursorChainingEvent);
-
ChainLinkId GetId(SdrTextObj *) const;
ImpChainLinkProperties *GetLinkProperties(SdrTextObj *);
+ // Specific Link Properties
+ DECL_CHAIN_PROP_INTERFACE(CursorEvent, CursorChainingEvent)
+ DECL_CHAIN_PROP_INTERFACE(NilChainingEvent, bool)
+
+
+
// return whether a paragraph is split between the two links in the argument
bool GetLinksHaveMergeableFirstPara(SdrTextObj *, SdrTextObj *);
- bool GetNilChainingEvent(SdrTextObj *pTarget);
- void SetNilChainingEvent(SdrTextObj *, bool);
-
protected:
LinkPropertiesMap maLinkPropertiesMap;
};
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index c09dfb1..04bf0df 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -505,23 +505,9 @@ IMPL_LINK_NOARG(SdrObjEditView,ImpChainingEventHdl)
// trigger actual chaining
pTextObj->onChainingEvent();
- // XXX: this logic could be put in a separate approppriate class
- /* Cursor motion stuff */
-
maCursorEvent = new CursorChainingEvent(pTextChain->GetCursorEvent(pTextObj));
//SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain();
-
- // Find last Para
- /*
- const sal_Int32 nParaCount = pTextEditOutliner->GetParagraphCount();
- const sal_Int32 nLastParaIndex = nParaCount > 1 ? nParaCount - 1 : 0;
- Paragraph* pLastPara = pTextEditOutliner->GetParagraph( nLastParaIndex);
- const sal_Int32 nLenLastPara = pTextEditOutliner->GetText(pLastPara).getLength();
- // Selection at end of editing area
- ESelection aEndSel(nLastParaIndex,nLenLastPara,nLastParaIndex,nLenLastPara);
- */
-
// NOTE: Must be called. Don't let the function return if you set it to true and not reset it
pTextChain->SetNilChainingEvent(pTextObj, false);
} else {
diff --git a/svx/source/svdraw/textchain.cxx b/svx/source/svdraw/textchain.cxx
index 37bca69..a9b59a9 100644
--- a/svx/source/svdraw/textchain.cxx
+++ b/svx/source/svdraw/textchain.cxx
@@ -20,15 +20,18 @@
#include <svx/textchain.hxx>
#include <svx/svdotext.hxx>
+/*
+ * Definition of Properties Interface
+*/
-ImpChainLinkProperties::ImpChainLinkProperties()
-{
- // give defaults
- bNilChainingEvent = false;
- aCursorEvent = CursorChainingEvent::UNCHANGED;
-}
+IMPL_CHAIN_PROP_INTERFACE(CursorEvent, CursorChainingEvent)
+IMPL_CHAIN_PROP_INTERFACE(NilChainingEvent, bool)
+
+/* End Definition of Properties Interface */
-// XXX: All getters in the class assume that the guy is in the chain
+/* TextChain */
+
+// NOTE: All getters in the class assume that the guy is in the chain
TextChain::TextChain()
{
@@ -54,17 +57,6 @@ SdrTextObj *TextChain::GetNextLink(SdrTextObj *) const
return NULL; // XXX: To be changed. It'd be a mess to implement now
}
-CursorChainingEvent TextChain::GetCursorEvent(SdrTextObj *pTarget)
-{
- ImpChainLinkProperties *pLinkProperties = GetLinkProperties(pTarget);
- return pLinkProperties->aCursorEvent;
-}
-
-void TextChain::SetCursorEvent(SdrTextObj *pTarget, CursorChainingEvent aCursorEvent)
-{
- ImpChainLinkProperties *pLinkProperties = GetLinkProperties(pTarget);
- pLinkProperties->aCursorEvent = aCursorEvent;
-}
bool TextChain::GetLinksHaveMergeableFirstPara(SdrTextObj* /* pPrevLink */, SdrTextObj* /* pNextLink */)
{
@@ -72,17 +64,6 @@ bool TextChain::GetLinksHaveMergeableFirstPara(SdrTextObj* /* pPrevLink */, SdrT
return false;
}
-bool TextChain::GetNilChainingEvent(SdrTextObj *pTarget)
-{
- ImpChainLinkProperties *pLinkProperties = GetLinkProperties(pTarget);
- return pLinkProperties->bNilChainingEvent;
-}
-
-void TextChain::SetNilChainingEvent(SdrTextObj *pTarget, bool bNilChainingEvent)
-{
- ImpChainLinkProperties *pLinkProperties = GetLinkProperties(pTarget);
- pLinkProperties->bNilChainingEvent = bNilChainingEvent;
-}
ImpChainLinkProperties *TextChain::GetLinkProperties(SdrTextObj *pLink)
{
diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx
index 9e794bc..4b80ea4 100644
--- a/svx/source/svdraw/textchainflow.cxx
+++ b/svx/source/svdraw/textchainflow.cxx
@@ -38,8 +38,6 @@ TextChainFlow::TextChainFlow(SdrTextObj *pChainTarget)
mpOverflChText = NULL;
mpUnderflChText = NULL;
-
-
}
More information about the Libreoffice-commits
mailing list