summaryrefslogtreecommitdiff
path: root/sw/source/core/layout/atrfrm.cxx
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-05-09 00:06:40 +0200
committerMichael Stahl <mstahl@redhat.com>2015-05-09 11:02:28 +0200
commitd60db2401198421d8b69707e49113c89a0ea1616 (patch)
treed49556b7ae25308a181c94ee90fd4d3bb0e57867 /sw/source/core/layout/atrfrm.cxx
parent94be2168635e5305f3dfa3b1baf7f97d85ab026c (diff)
sw: add assertions to check invariants of frame anchoring
Change-Id: Iddb5936c088dfba0245a0d921c7122a0587bdc9b
Diffstat (limited to 'sw/source/core/layout/atrfrm.cxx')
-rw-r--r--sw/source/core/layout/atrfrm.cxx61
1 files changed, 61 insertions, 0 deletions
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 335c85e96092..e78ae9b5a00f 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -3487,4 +3487,65 @@ bool IsFlyFrmFmtInHeader(const SwFrmFmt& rFmt)
return false;
}
+namespace sw {
+
+void CheckAnchoredFlyConsistency(SwDoc const& rDoc)
+{
+#if OSL_DEBUG_LEVEL > 0
+ SwNodes const& rNodes(rDoc.GetNodes());
+ sal_uLong const count(rNodes.Count());
+ for (sal_uLong i = 0; i != count; ++i)
+ {
+ SwNode const*const pNode(rNodes[i]);
+ std::vector<SwFrmFmt*> const*const pFlys(pNode->GetAnchoredFlys());
+ if (pFlys)
+ {
+ for (auto it = pFlys->begin(); it != pFlys->end(); ++it)
+ {
+ SwFmtAnchor const& rAnchor((**it).GetAnchor(false));
+ assert(&rAnchor.GetCntntAnchor()->nNode.GetNode() == pNode);
+ }
+ }
+ }
+ SwFrmFmts const*const pSpzFrmFmts(rDoc.GetSpzFrmFmts());
+ if (pSpzFrmFmts)
+ {
+ for (auto it = pSpzFrmFmts->begin(); it != pSpzFrmFmts->end(); ++it)
+ {
+ SwFmtAnchor const& rAnchor((**it).GetAnchor(false));
+ if (FLY_AT_PAGE == rAnchor.GetAnchorId())
+ {
+ assert(!rAnchor.GetCntntAnchor());
+ }
+ else
+ {
+ SwNode & rNode(rAnchor.GetCntntAnchor()->nNode.GetNode());
+ std::vector<SwFrmFmt*> const*const pFlys(rNode.GetAnchoredFlys());
+ assert(std::find(pFlys->begin(), pFlys->end(), *it) != pFlys->end());
+ switch (rAnchor.GetAnchorId())
+ {
+ case FLY_AT_FLY:
+ assert(rNode.IsStartNode());
+ break;
+ case FLY_AT_PARA:
+ assert(rNode.IsTxtNode() || rNode.IsTableNode());
+ break;
+ case FLY_AS_CHAR:
+ case FLY_AT_CHAR:
+ assert(rNode.IsTxtNode());
+ break;
+ default:
+ assert(false);
+ break;
+ }
+ }
+ }
+ }
+#else
+ (void) rDoc;
+#endif
+}
+
+} // namespace sw
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */