summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatteocam <matteo.campanelli@gmail.com>2015-09-06 11:26:43 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2015-09-20 13:05:14 +0200
commit089cae1ce1e69d5a01756109d95817f6a87a2bea (patch)
tree1d1d93a9445e21a0fa6a8178df2d9e36881c882f
parent0c0dedb9e4a24f09a46e077ddd0bc36de7b5c575 (diff)
chained editeng: Add TextChain related files
Change-Id: I3fbf9d60cf1d1e022b33bb5b416c88847a1efc64
-rw-r--r--include/svx/textchain.hxx157
-rw-r--r--svx/Library_svxcore.mk1
-rw-r--r--svx/source/svdraw/textchain.cxx68
3 files changed, 226 insertions, 0 deletions
diff --git a/include/svx/textchain.hxx b/include/svx/textchain.hxx
new file mode 100644
index 000000000000..bcdb47d5a0fd
--- /dev/null
+++ b/include/svx/textchain.hxx
@@ -0,0 +1,157 @@
+/* -*- 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_TEXTCHAIN_HXX
+#define INCLUDED_SVX_TEXTCHAIN_HXX
+
+#include <editeng/editdata.hxx>
+#include <map>
+
+/*
+ * 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)
+ *
+ * 3) Add
+ * "DECL_CHAIN_PROP_INTERFACE(PROPNAME, T)"
+ * in class TextChain (under "public:");
+ * 4) 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 (const SdrTextObj *); \
+ void Set##PropName (const SdrTextObj *, PropType);
+
+#define IMPL_CHAIN_PROP_INTERFACE(PropName, PropType) \
+ PropType TextChain::Get##PropName (const SdrTextObj *pTarget) { \
+ ImpChainLinkProperties *pLinkProperties = GetLinkProperties(pTarget); \
+ return pLinkProperties->a##PropName; \
+ } \
+ void TextChain::Set##PropName (const SdrTextObj *pTarget, PropType aPropParam) \
+ { \
+ ImpChainLinkProperties *pLinkProperties = GetLinkProperties(pTarget); \
+ pLinkProperties->a##PropName = aPropParam; \
+ }
+
+/* End Special Properties Macro */
+
+
+class ImpChainLinkProperties;
+class SdrTextObj;
+class SdrModel;
+
+namespace rtl {
+ class OUString;
+}
+
+typedef rtl::OUString ChainLinkId;
+typedef std::map< ChainLinkId, ImpChainLinkProperties *> LinkPropertiesMap;
+
+enum class CursorChainingEvent
+{
+ TO_NEXT_LINK,
+ TO_PREV_LINK,
+ UNCHANGED,
+ NULL_EVENT
+};
+
+class ImpChainLinkProperties
+{
+protected:
+ friend class TextChain;
+
+ ImpChainLinkProperties() {
+ INIT_CHAIN_PROP(NilChainingEvent, false)
+ INIT_CHAIN_PROP(CursorEvent, CursorChainingEvent::NULL_EVENT)
+ INIT_CHAIN_PROP(PreChainingSel, ESelection(0,0,0,0));
+ INIT_CHAIN_PROP(PostChainingSel, ESelection(0,0,0,0));
+ INIT_CHAIN_PROP(IsPartOfLastParaInNextLink, false) // XXX: Should come from file
+ INIT_CHAIN_PROP(PendingOverflowCheck, false)
+ INIT_CHAIN_PROP(SwitchingToNextBox, false)
+ }
+
+private:
+ // NOTE: Remember to set default value in constructor when adding field
+ DECL_CHAIN_PROP(NilChainingEvent, bool)
+ DECL_CHAIN_PROP(CursorEvent, CursorChainingEvent)
+ DECL_CHAIN_PROP(PreChainingSel, ESelection)
+ DECL_CHAIN_PROP(PostChainingSel, ESelection)
+ DECL_CHAIN_PROP(IsPartOfLastParaInNextLink, bool)
+ DECL_CHAIN_PROP(PendingOverflowCheck, bool)
+ DECL_CHAIN_PROP(SwitchingToNextBox, bool)
+};
+
+
+class TextChain
+{
+public:
+ ~TextChain();
+
+ //void AppendLink(SdrTextObj *);
+ //bool IsLinkInChain(SdrTextObj *) const;
+
+ //SdrTextObj *GetNextLink(const SdrTextObj *) const;
+ //SdrTextObj *GetPrevLink(const SdrTextObj *) const;
+
+ ChainLinkId GetId(const SdrTextObj *) const;
+ ImpChainLinkProperties *GetLinkProperties(const SdrTextObj *);
+
+ // Specific Link Properties
+ DECL_CHAIN_PROP_INTERFACE(CursorEvent, CursorChainingEvent)
+ DECL_CHAIN_PROP_INTERFACE(NilChainingEvent, bool)
+ DECL_CHAIN_PROP_INTERFACE(PreChainingSel, ESelection)
+ DECL_CHAIN_PROP_INTERFACE(PostChainingSel, ESelection)
+ // return whether a paragraph is split between this box and the next
+ DECL_CHAIN_PROP_INTERFACE(IsPartOfLastParaInNextLink, bool)
+ // return whether there is a pending overflow check (usually when we move cursor after an overflow in the prev link)
+ DECL_CHAIN_PROP_INTERFACE(PendingOverflowCheck, bool)
+ // return whether we are currently moving the cursor to the next box (useful to know whether we should prevent SetOutlinerParaObject invocations in SdrTextObj::EndTextEdit)
+ DECL_CHAIN_PROP_INTERFACE(SwitchingToNextBox, bool)
+
+protected:
+ TextChain();
+ LinkPropertiesMap maLinkPropertiesMap;
+
+private:
+ friend class SdrModel;
+ //SdrTextObj *impGetNextLink(const SdrTextObj *) const;
+ //SdrTextObj *impGetPrevLink(const SdrTextObj *) const;
+};
+
+#endif // INCLUDED_SVX_TEXTCHAIN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 89b1eb0b89f2..9c22634dd9d2 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -339,6 +339,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/svdraw/svdview \
svx/source/svdraw/svdviter \
svx/source/svdraw/svdxcgv \
+ svx/source/svdraw/textchain \
svx/source/styles/CommonStylePreviewRenderer \
svx/source/styles/CommonStyleManager \
svx/source/styles/ColorSets \
diff --git a/svx/source/svdraw/textchain.cxx b/svx/source/svdraw/textchain.cxx
new file mode 100644
index 000000000000..b7146c12f7bb
--- /dev/null
+++ b/svx/source/svdraw/textchain.cxx
@@ -0,0 +1,68 @@
+/* -*- 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/textchain.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdpage.hxx>
+
+/*
+ * Definition of Properties Interface
+*/
+
+IMPL_CHAIN_PROP_INTERFACE(CursorEvent, CursorChainingEvent)
+IMPL_CHAIN_PROP_INTERFACE(NilChainingEvent, bool)
+IMPL_CHAIN_PROP_INTERFACE(PreChainingSel, ESelection)
+IMPL_CHAIN_PROP_INTERFACE(PostChainingSel, ESelection)
+IMPL_CHAIN_PROP_INTERFACE(IsPartOfLastParaInNextLink, bool)
+IMPL_CHAIN_PROP_INTERFACE(PendingOverflowCheck, bool)
+IMPL_CHAIN_PROP_INTERFACE(SwitchingToNextBox, bool)
+
+
+/* End Definition of Properties Interface */
+
+/* TextChain */
+
+// NOTE: All getters in the class assume that the guy is in the chain
+
+TextChain::TextChain()
+{
+}
+
+TextChain::~TextChain()
+{
+ // XXX: Should free all LinkProperties
+}
+
+ImpChainLinkProperties *TextChain::GetLinkProperties(const SdrTextObj *pLink)
+{
+ // if the guy does not already have properties in the map make them
+ ChainLinkId aLinkId = GetId(pLink);
+ if (maLinkPropertiesMap.find(aLinkId) == maLinkPropertiesMap.end()) {
+ maLinkPropertiesMap[aLinkId] = new ImpChainLinkProperties;
+ }
+
+ return maLinkPropertiesMap[aLinkId];
+}
+
+ChainLinkId TextChain::GetId(const SdrTextObj *pLink) const
+{
+ return pLink->GetName();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */