[Libreoffice-commits] core.git: 4 commits - sw/inc sw/README sw/source
Michael Stahl
mstahl at redhat.com
Thu Jul 6 21:30:58 UTC 2017
sw/README | 57 +++++++++++++++++
sw/inc/SwNumberTree.hxx | 19 ++---
sw/inc/doc.hxx | 17 ++---
sw/inc/ndarr.hxx | 1
sw/inc/node.hxx | 1
sw/source/core/SwNumberTree/SwNumberTree.cxx | 88 +++++++++------------------
6 files changed, 103 insertions(+), 80 deletions(-)
New commits:
commit c65cae183dec9b89ac5279da9c5aa099254b7234
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Jul 6 17:45:53 2017 +0200
sw/README: document lists and outline
Change-Id: I1f6a7a29a308e13c20e5987902d148ee8d466e31
diff --git a/sw/README b/sw/README
index 4305613debac..60de27ba4ccd 100644
--- a/sw/README
+++ b/sw/README
@@ -140,3 +140,60 @@ There are multiple model classes involved for fields:
Its life-cycle is determined by UNO clients outside of sw; it will get
disposed when the SwFormatField dies.
+=== Lists ===
+
+- SwNumFormat (subclass of SvxNumFormat) determines the formatting of a single
+ numbering level.
+
+- SwNumRule (NOT a subclass of SvxNumRule) is a *list style*, containing one
+ SwNumFormat per list level.
+ SwNumRule::maTextNodeList is the list of SwTextNode that have this list style
+ applied.
+
+- SwNumberTreeNode is a base class that represents an abstract node in a
+ hierarchical tree of numbered nodes.
+
+- SwNodeNum is the subclass of SwNumberTreeNode that connects it with an
+ actual SwTextNode and also with a SwNumRule;
+ SwTextNode::mpNodeNum points back in the other direction
+
+- SwList represents a list, which is (mostly) a vector of SwNodeNum trees,
+ one per SwNodes top-level section (why that?).
+
+- IDocumentListsAccess, sw::DocumentListsManager owns all SwList instances,
+ and maintains mappings:
+ + from list-id to SwList
+ + from list style name to SwList (the "default" SwList for that list style)
+
+- IDocumentListItems, sw::DocumentListItemsManager contains a set of all
+ SwNodeNum instances, ordered by SwNode index
+
+- the special Outline numbering rule: SwDoc::mpOutlineRule
+
+- IDocumentOutlineNodes, sw::DocumentOutlineNodesManager maintain
+ a list (which is actually stored in SwNodes::m_pOutlineNodes) of SwTextNodes
+ that either have the Outline numrule applied,
+ or have the RES_PARATR_OUTLINELEVEL item set (note that in the latter case,
+ the SwTextNode does not have a SwNodeNum and is not associated with the
+ SwDoc::mpOutlineRule).
+
+- SwTextNodes and paragraph styles have items/properties:
+ + RES_PARATR_OUTLINELEVEL/"OutlineLevel" to specify an outline level without
+ necessarily having the outline SwNumRule assigned
+ + RES_PARATR_NUMRULE/"NumberingStyleName" the list style to apply; may be
+ empty "" which means no list style (to override inherited value)
+ Only SwTextNode has these items:
+ + RES_PARATR_LIST_ID/"ListId"
+ determines the SwList to which the node is added
+ + RES_PARATR_LIST_LEVEL/"NumberingLevel"
+ the level at which the SwTextNode will appear in the list
+ + RES_PARATR_LIST_ISRESTART/"ParaIsNumberingRestart"
+ restart numbering sequence at this SwTextNode
+ + RES_PARATR_LIST_RESTARTVALUE/"NumberingStartValue"
+ restart numbering sequence at this SwTextNode with this value
+ + RES_PARATR_LIST_ISCOUNTED/"NumberingIsNumber"
+ determines if the node is actually counted in the numbering sequence;
+ these are different from "phantoms" because there's still a SwTextNode.
+
+Note that there is no UNO service to represent a list.
+
commit ea3e718855d804943831db81428fec249b9c7575
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Jul 6 14:13:12 2017 +0200
sw: convert SwNumberTree::IsSane to assert() and simplify
Change-Id: Ib2087a53d2a22f5fdafa5c3d0d058dd0ad8ed643
diff --git a/sw/inc/SwNumberTree.hxx b/sw/inc/SwNumberTree.hxx
index 3d19458e5b8c..c908eeca490c 100644
--- a/sw/inc/SwNumberTree.hxx
+++ b/sw/inc/SwNumberTree.hxx
@@ -346,7 +346,7 @@ public:
@retval true the structure of this node is sane
@retval false else
*/
- bool IsSane(bool bRecursive) const;
+ void IsSane(bool bRecursive) const;
#endif // DBG_UTIL
protected:
@@ -391,15 +391,12 @@ protected:
virtual void PostRemove() = 0;
#ifdef DBG_UTIL
- /**
- Sanity check with loop detection.
+ /** Sanity check with loop detection.
@param bRecursive descend to children
@param rParents vector for recording path
-
- @retval true this node is sane
- @retval false else */
- virtual bool IsSane
+ */
+ virtual void IsSane
(bool bRecursive, std::vector<const SwNumberTreeNode *> rParents) const;
#endif // DBG_UTIL
diff --git a/sw/source/core/SwNumberTree/SwNumberTree.cxx b/sw/source/core/SwNumberTree/SwNumberTree.cxx
index f60f0c0a732b..c606f7b34aea 100644
--- a/sw/source/core/SwNumberTree/SwNumberTree.cxx
+++ b/sw/source/core/SwNumberTree/SwNumberTree.cxx
@@ -23,6 +23,8 @@
#include <osl/diagnose.h>
#include <sal/log.hxx>
+#include <cassert>
+
using std::vector;
using std::find;
@@ -385,7 +387,8 @@ void SwNumberTreeNode::MoveGreaterChildren( SwNumberTreeNode& _rCompareNode,
}
#ifdef DBG_UTIL
- SAL_WARN_IF(!IsSane(false) || !_rDestNode.IsSane(true), "sw.core", "insanity");
+ IsSane(false);
+ _rDestNode.IsSane(true);
#endif
}
@@ -433,7 +436,8 @@ void SwNumberTreeNode::MoveChildren(SwNumberTreeNode * pDest)
OSL_ENSURE(mChildren.empty(), "MoveChildren failed!");
#ifdef DBG_UTIL
- OSL_ENSURE(IsSane(false) && pDest->IsSane(false), "insanity!");
+ IsSane(false);
+ pDest->IsSane(false);
#endif
}
@@ -585,7 +589,7 @@ void SwNumberTreeNode::AddChild( SwNumberTreeNode * pChild,
}
#ifdef DBG_UTIL
- SAL_WARN_IF(!IsSane(false), "sw.core", "insanity");
+ IsSane(false);
#endif
}
@@ -678,7 +682,7 @@ void SwNumberTreeNode::RemoveMe()
pSavedParent->ClearObsoletePhantoms();
#ifdef DBG_UTIL
- SAL_WARN_IF(!IsSane(false), "sw.core", "insanity");
+ IsSane(false);
#endif
}
}
@@ -857,34 +861,22 @@ SwNumberTreeNode::GetChildCount() const
}
#ifdef DBG_UTIL
-bool SwNumberTreeNode::IsSane(bool bRecursive) const
+void SwNumberTreeNode::IsSane(bool bRecursive) const
{
vector<const SwNumberTreeNode*> aParents;
return IsSane(bRecursive, aParents);
}
-bool SwNumberTreeNode::IsSane(bool bRecursive,
+void SwNumberTreeNode::IsSane(bool bRecursive,
vector<const SwNumberTreeNode *> rParents)
const
{
- bool bResult = true;
-
tSwNumberTreeChildren::const_iterator aIt;
- if (find(rParents.begin(), rParents.end(), this) != rParents.end())
- {
- OSL_FAIL(" I'm my own ancestor!");
-
- bResult = false;
- }
+ assert(find(rParents.begin(), rParents.end(), this) == rParents.end());
- if (! rParents.empty() && rParents.back() != mpParent)
- {
- OSL_FAIL(" I'm a bastard!");
-
- bResult = false;
- }
+ assert(rParents.empty() || rParents.back() == mpParent);
rParents.push_back(this);
@@ -895,49 +887,33 @@ bool SwNumberTreeNode::IsSane(bool bRecursive,
{
if ((*aIt)->IsPhantom())
{
- if ((*aIt)->HasOnlyPhantoms())
- {
- bResult = false;
- }
+ SAL_WARN_IF((*aIt)->HasOnlyPhantoms(), "sw.core",
+ "HasOnlyPhantoms: is this an error?");
- if (! bFirst)
- {
- OSL_FAIL(" found phantom not at first position.");
-
- bResult = false;
- }
+ assert(bFirst && "found phantom not at first position.");
}
- if ((*aIt)->mpParent != (SwNumberTreeNode *) this)
- {
- OSL_FAIL("found a bastard");
-
- bResult = false;
- }
+ assert((*aIt)->mpParent == this);
if (mpParent)
{
- if (!(*aIt)->IsPhantom() && (*aIt)->LessThan(*this))
- {
- OSL_FAIL(" found child less than me");
-
- bResult = false;
- }
+ assert((*aIt)->IsPhantom() || !(*aIt)->LessThan(*this));
}
}
else
{
- OSL_FAIL("found child that is NULL");
- bResult = false;
+ assert(!"found child that is NULL");
}
- if (bRecursive)
- bResult = (*aIt)->IsSane(bRecursive, rParents) && bResult;
+ if (bRecursive)
+ {
+ (*aIt)->IsSane(bRecursive, rParents);
+ }
+
+ bFirst = false;
}
rParents.pop_back();
-
- return bResult;
}
#endif // DBG_UTIL
commit a0dc0d3cc2cf64567eeebba73d308f6ad827d810
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Jul 6 13:21:59 2017 +0200
sw: enable some SwNumberTree sanity testing code
__SW_NUMBER_TREE_SANITY_CHECK isn't defined anywhere.
Change-Id: Ieb8c47d12c47a8a1ffcad0616382e4d2b55024a0
diff --git a/sw/inc/SwNumberTree.hxx b/sw/inc/SwNumberTree.hxx
index 166ad1fd18ce..3d19458e5b8c 100644
--- a/sw/inc/SwNumberTree.hxx
+++ b/sw/inc/SwNumberTree.hxx
@@ -337,7 +337,7 @@ public:
*/
const SwNumberTreeNode* GetPrecedingNodeOf( const SwNumberTreeNode& rNode ) const;
-#ifdef __SW_NUMBER_TREE_SANITY_CHECK
+#ifdef DBG_UTIL
/**
Sanity check.
@@ -347,7 +347,7 @@ public:
@retval false else
*/
bool IsSane(bool bRecursive) const;
-#endif // __SW_NUMBER_TREE_SANITY_CHECK
+#endif // DBG_UTIL
protected:
/**
@@ -390,7 +390,7 @@ protected:
// method called after this tree node has been removed from the list tree
virtual void PostRemove() = 0;
-#ifdef __SW_NUMBER_TREE_SANITY_CHECK
+#ifdef DBG_UTIL
/**
Sanity check with loop detection.
@@ -401,7 +401,7 @@ protected:
@retval false else */
virtual bool IsSane
(bool bRecursive, std::vector<const SwNumberTreeNode *> rParents) const;
-#endif // __SW_NUMBER_TREE_SANITY_CHECK
+#endif // DBG_UTIL
/**
the parent node
diff --git a/sw/source/core/SwNumberTree/SwNumberTree.cxx b/sw/source/core/SwNumberTree/SwNumberTree.cxx
index 69564bfb5416..f60f0c0a732b 100644
--- a/sw/source/core/SwNumberTree/SwNumberTree.cxx
+++ b/sw/source/core/SwNumberTree/SwNumberTree.cxx
@@ -21,6 +21,7 @@
#include <functional>
#include <SwNumberTree.hxx>
#include <osl/diagnose.h>
+#include <sal/log.hxx>
using std::vector;
using std::find;
@@ -383,9 +384,8 @@ void SwNumberTreeNode::MoveGreaterChildren( SwNumberTreeNode& _rCompareNode,
}
}
-#ifdef __SW_NUMBER_TREE_SANITY_CHECK
- if (! IsSane(false) || ! IsSane(&_rDestNode))
- clog << __FUNCTION__ << "insanity!" << endl;
+#ifdef DBG_UTIL
+ SAL_WARN_IF(!IsSane(false) || !_rDestNode.IsSane(true), "sw.core", "insanity");
#endif
}
@@ -432,7 +432,7 @@ void SwNumberTreeNode::MoveChildren(SwNumberTreeNode * pDest)
OSL_ENSURE(mChildren.empty(), "MoveChildren failed!");
-#ifdef __SW_NUMBER_TREE_SANITY_CHECK
+#ifdef DBG_UTIL
OSL_ENSURE(IsSane(false) && pDest->IsSane(false), "insanity!");
#endif
}
@@ -584,9 +584,8 @@ void SwNumberTreeNode::AddChild( SwNumberTreeNode * pChild,
}
}
-#ifdef __SW_NUMBER_TREE_SANITY_CHECK
- if (! IsSane(false))
- clog << __FUNCTION__ << ": insanity!" << endl;
+#ifdef DBG_UTIL
+ SAL_WARN_IF(!IsSane(false), "sw.core", "insanity");
#endif
}
@@ -678,9 +677,8 @@ void SwNumberTreeNode::RemoveMe()
if (pSavedParent)
pSavedParent->ClearObsoletePhantoms();
-#ifdef __SW_NUMBER_TREE_SANITY_CHECK
- if (! IsSane(false))
- clog << __FUNCTION__ << ": insanity!" << endl;
+#ifdef DBG_UTIL
+ SAL_WARN_IF(!IsSane(false), "sw.core", "insanity");
#endif
}
}
@@ -858,7 +856,7 @@ SwNumberTreeNode::GetChildCount() const
return mChildren.size();
}
-#ifdef __SW_NUMBER_TREE_SANITY_CHECK
+#ifdef DBG_UTIL
bool SwNumberTreeNode::IsSane(bool bRecursive) const
{
vector<const SwNumberTreeNode*> aParents;
@@ -941,7 +939,7 @@ bool SwNumberTreeNode::IsSane(bool bRecursive,
return bResult;
}
-#endif // __SW_NUMBER_TREE_SANITY_CHECK
+#endif // DBG_UTIL
SwNumberTreeNode::tSwNumberTreeChildren::const_iterator
SwNumberTreeNode::GetIterator(const SwNumberTreeNode * pChild) const
commit 4a932d3b672029374a6ada000f115ad86d7bc523
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Jul 5 14:19:05 2017 +0200
sw: comment cosmetics
Change-Id: I572bf8b28738e82e2f207b5201a0c27d9d9b623d
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index c9fb60cb678b..b0042896602f 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1032,23 +1032,21 @@ public:
// Outline - promote / demote.
bool OutlineUpDown( const SwPaM& rPam, short nOffset );
- // Ountline - move up / move down.
+ /// Outline - move up / move down.
bool MoveOutlinePara( const SwPaM& rPam, SwOutlineNodes::difference_type nOffset);
bool GotoOutline( SwPosition& rPos, const OUString& rName ) const;
- /** Accept changes of outline styles for OUtlineRule.
- re-use unused 3rd parameter
- Optional parameter <bResetIndentAttrs> - default value false:
+ /** Accept changes of outline styles for OutlineRule.
+ @param bResetIndentAttrs Optional parameter - default value false:
If <bResetIndentAttrs> equals true, the indent attributes "before text"
and "first line indent" are additionally reset at the provided PaM, if
the list style makes use of the new list level attributes.
- Parameters <bCreateNewList> and <sContinuedListId>:
- <bCreateNewList> indicates, if a new list is created by applying the given list style.
- If <bCreateNewList> equals false, <sContinuedListId> may contain the
- list Id of a list, which has to be continued by applying the given list style
+ @param bCreateNewList indicates if a new list is created by applying the given list style.
+ @param sContinuedListId If bCreateNewList is false, may contain the
+ list Id of a list which has to be continued by applying the given list style
- Returns the set ListId if bSetItem is true */
+ @return the set ListId if bSetItem is true */
OUString SetNumRule( const SwPaM&,
const SwNumRule&,
bool bCreateNewList,
@@ -1604,7 +1602,6 @@ public:
/**
* Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by default)
- * @since 3.5
*/
void dumpAsXml(struct _xmlTextWriter* = nullptr) const;
diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx
index 4e7cca5fa0ee..eebc176e1f54 100644
--- a/sw/inc/ndarr.hxx
+++ b/sw/inc/ndarr.hxx
@@ -323,7 +323,6 @@ public:
/**
* Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by default)
- * @since 3.5
*/
void dumpAsXml( xmlTextWriterPtr pWriter ) const;
};
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 89c6f7f10a94..48411c5facc6 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -283,7 +283,6 @@ public:
/**
* Dumps the node structure to the given destination (file nodes.xml in the current directory by default)
- * @since 3.5
*/
virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
More information about the Libreoffice-commits
mailing list