You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2012/11/14 22:55:11 UTC

svn commit: r1409457 - in /incubator/ooo/branches/gbuild/main/writerfilter: inc/resourcemodel/TagLogger.hxx source/resourcemodel/TagLogger.cxx

Author: arist
Date: Wed Nov 14 21:55:10 2012
New Revision: 1409457

URL: http://svn.apache.org/viewvc?rev=1409457&view=rev
Log:
writerfilter10_21_b4a56c7574da.patch
# HG changeset patch
# User Henning Brinkmann <hb...@openoffice.org>
# Date 1298385007 -3600
# Node ID b4a56c7574da67fb7bdc47401cebb6c7519de97f
# Parent  9467e7f6cd608a5372a56fe57c2e454b8ba62ca4
TagLogger: new method toTree


Modified:
    incubator/ooo/branches/gbuild/main/writerfilter/inc/resourcemodel/TagLogger.hxx
    incubator/ooo/branches/gbuild/main/writerfilter/source/resourcemodel/TagLogger.cxx

Modified: incubator/ooo/branches/gbuild/main/writerfilter/inc/resourcemodel/TagLogger.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/gbuild/main/writerfilter/inc/resourcemodel/TagLogger.hxx?rev=1409457&r1=1409456&r2=1409457&view=diff
==============================================================================
--- incubator/ooo/branches/gbuild/main/writerfilter/inc/resourcemodel/TagLogger.hxx (original)
+++ incubator/ooo/branches/gbuild/main/writerfilter/inc/resourcemodel/TagLogger.hxx Wed Nov 14 21:55:10 2012
@@ -78,7 +78,8 @@ namespace writerfilter
         void chars(const string & rChars);
         void chars(const ::rtl::OUString & rChars);
         const string & getTag() const;
-        string toString() const; 
+        string toString() const;
+        string toTree(const string & sIndent = "") const;
         
         ostream & output(ostream & o, const string & sIndent = "") const;
     };

Modified: incubator/ooo/branches/gbuild/main/writerfilter/source/resourcemodel/TagLogger.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/gbuild/main/writerfilter/source/resourcemodel/TagLogger.cxx?rev=1409457&r1=1409456&r2=1409457&view=diff
==============================================================================
--- incubator/ooo/branches/gbuild/main/writerfilter/source/resourcemodel/TagLogger.cxx (original)
+++ incubator/ooo/branches/gbuild/main/writerfilter/source/resourcemodel/TagLogger.cxx Wed Nov 14 21:55:10 2012
@@ -171,6 +171,75 @@ string XMLTag::toString() const
     return sResult;
 }
 
+string XMLTag::toTree(const string & sIndent) const
+{
+    if (mChars.length() > 0)
+        return sIndent + mChars;
+
+    string sResult;
+    
+    size_t nSize = sIndent.size();
+    if (nSize > 1)
+    {
+        sResult += sIndent.substr(0, nSize - 2) + "+-\\" + mTag;
+    }
+    else
+    {
+        sResult += "\\" + mTag;
+    }
+        
+    XMLAttributes_t::const_iterator aIt = mAttrs.begin();
+    while (aIt != mAttrs.end())
+    {
+        if (aIt == mAttrs.begin())
+        {
+            sResult += "(";
+        }
+        else
+        {
+            sResult += sIndent + ", ";
+        }
+
+        sResult += aIt->mName;
+        sResult += "=";
+        sResult += aIt->mValue;
+
+        aIt++;
+
+        if (aIt == mAttrs.end())
+        {
+            sResult += ")";
+        }
+    }
+
+    sResult += "\n";
+
+    if (mTags.size() > 0)
+    {
+        XMLTags_t::const_iterator aItTags = mTags.begin();
+        size_t nSize = mTags.size();
+        while (aItTags != mTags.end())
+        {
+            if ((*aItTags).get() != NULL)
+            {
+                if (nSize == 1)
+                {
+                    sResult += (*aItTags)->toTree(sIndent + "  ");
+                }
+                else
+                {
+                    sResult += (*aItTags)->toTree(sIndent + "| ");
+                }                    
+            }
+
+            aItTags++;
+            nSize--;
+        }
+    }
+
+    return sResult;
+}
+
 ostream & XMLTag::output(ostream & o, const string & sIndent) const
 {
     bool bHasContent = mChars.size() > 0 || mTags.size() > 0;