# HG changeset patch
# User Henning Brinkmann <hbrinkm@openoffice.org>
# Date 1249914475 -7200
# Node ID a7182165b6db3c4822d860d1ac45b18cff6b600f
# Parent  65dafca71021c79bbc508ef91e112cc60c73a230
#i102420# rewritten debug output for SwNodes.

diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx
--- a/sw/source/core/doc/dbgoutsw.cxx
+++ b/sw/source/core/doc/dbgoutsw.cxx
@@ -542,7 +542,7 @@
     String aTmpStr;
 
     aTmpStr += String("<node ", RTL_TEXTENCODING_ASCII_US);
-    aTmpStr += String("index =\"", RTL_TEXTENCODING_ASCII_US);
+    aTmpStr += String("index=\"", RTL_TEXTENCODING_ASCII_US);
     aTmpStr += String::CreateFromInt32(rNode.GetIndex());
     aTmpStr += String("\"", RTL_TEXTENCODING_ASCII_US);
 
@@ -668,7 +668,15 @@
         }
     }
     else if (rNode.IsStartNode())
-        aTmpStr += String("<start/>", RTL_TEXTENCODING_ASCII_US);
+    {
+        aTmpStr += String("<start end=\"", RTL_TEXTENCODING_ASCII_US);
+        
+        const SwStartNode * pStartNode = dynamic_cast<const SwStartNode *> (&rNode);
+        if (pStartNode != NULL)            
+            aTmpStr += String::CreateFromInt32(pStartNode->EndOfSectionNode()->GetIndex());
+            
+        aTmpStr += String("\"/>", RTL_TEXTENCODING_ASCII_US);
+    }
     else if (rNode.IsEndNode())
         aTmpStr += String("<end/>", RTL_TEXTENCODING_ASCII_US);
 
@@ -718,26 +726,67 @@
     return TRUE;
 }
 
+void lcl_dbg_nodes_inner(String & aStr, SwNodes & rNodes, ULONG & nIndex)
+{
+    SwNode * pNode = rNodes[nIndex];
+    SwStartNode * pStartNode = dynamic_cast<SwStartNode *> (pNode);
+
+    SwNode * pEndNode = NULL;
+    if (pStartNode != NULL)
+        pEndNode = pStartNode->EndOfSectionNode();
+        
+    ULONG nCount = rNodes.Count();
+    ULONG nStartIndex = nIndex;
+
+    bool bDone = false;
+    
+    String aTag;
+    if (pNode->IsTableNode())
+        aTag += String("table", RTL_TEXTENCODING_ASCII_US);
+    else if (pNode->IsSectionNode())
+        aTag += String("section", RTL_TEXTENCODING_ASCII_US);
+    else
+        aTag += String("nodes", RTL_TEXTENCODING_ASCII_US);
+        
+    aStr += String("<", RTL_TEXTENCODING_ASCII_US);
+    aStr += aTag;
+    aStr += String(">", RTL_TEXTENCODING_ASCII_US);
+
+    while (! bDone)
+    {        
+        if (pNode->IsStartNode() && nIndex != nStartIndex)
+            lcl_dbg_nodes_inner(aStr, rNodes, nIndex);
+        else
+        {
+            aStr += lcl_dbg_out(*pNode);
+            aStr += String("\n", RTL_TEXTENCODING_ASCII_US);
+
+            nIndex++;
+        }
+        
+        if (pNode == pEndNode || nIndex >= nCount)
+            bDone = true;
+        else
+            pNode = rNodes[nIndex];            
+    }
+    
+    aStr += String("</", RTL_TEXTENCODING_ASCII_US);
+    aStr += aTag;
+    aStr += String(">\n", RTL_TEXTENCODING_ASCII_US);
+}
+
 String lcl_dbg_out(SwNodes & rNodes)
 {
-    String aStr("<nodes>", RTL_TEXTENCODING_ASCII_US);
-
-    for (ULONG i = 0; i < rNodes.Count(); i++)
+    String aStr;
+    
+    ULONG nIndex = 0;
+    ULONG nCount = rNodes.Count();
+    
+    while (nIndex < nCount)
     {
-        SwNode * pNode = rNodes[i];
-        
-        if (pNode->IsEndNode())
-            aStr += String("</nodes>\n", RTL_TEXTENCODING_ASCII_US);
-            
-        aStr += lcl_dbg_out(*pNode);
-        aStr += String("\n", RTL_TEXTENCODING_ASCII_US);
-        
-        if (pNode->IsStartNode())
-            aStr += String("<nodes>", RTL_TEXTENCODING_ASCII_US);
+        lcl_dbg_nodes_inner(aStr, rNodes, nIndex);
     }
 
-    aStr += String("</nodes>\n", RTL_TEXTENCODING_ASCII_US);
-
     return aStr;
 }
 
