From 71aa51d5db835b7a294f24b51142116abe11601a Mon Sep 17 00:00:00 2001 From: marian Date: Tue, 2 Mar 2010 09:27:10 +0000 Subject: [PATCH] Don't indent element text when it's the only child. Fixed documentation. git-svn-id: http://yate.null.ro/svn/yate/trunk@3100 acf43c95-373e-0410-b603-e72c3f656dc1 --- libs/yxml/XML.cpp | 11 +++++++++-- libs/yxml/yatexml.h | 6 ++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libs/yxml/XML.cpp b/libs/yxml/XML.cpp index 31ced50d..6379fc85 100644 --- a/libs/yxml/XML.cpp +++ b/libs/yxml/XML.cpp @@ -1788,9 +1788,16 @@ void XmlElement::toString(String& dump, bool esc, const String& indent, auxDump << "/"; auxDump << ">"; if (m) { - m_children.toString(auxDump,esc,indent + origIndent,origIndent,completeOnly,auth,this); + // Avoid adding text on new line when text is the only child + XmlText* text = 0; + if (m == 1) + text = static_cast(getChildren().skipNull()->get())->xmlText(); + if (!text) + m_children.toString(auxDump,esc,indent + origIndent,origIndent,completeOnly,auth,this); + else + text->toString(auxDump,esc,String::empty(),auth,this); if (m_complete) - auxDump << indent << ""; + auxDump << (!text ? indent : String::empty()) << ""; } dump << auxDump; } diff --git a/libs/yxml/yatexml.h b/libs/yxml/yatexml.h index afc51acf..f5c4f26d 100644 --- a/libs/yxml/yatexml.h +++ b/libs/yxml/yatexml.h @@ -998,10 +998,8 @@ public: bool completeOnly = true) const; /** - * Load an file an parse it - - * Reset the document - + * Load a file an parse it + * Reset the document * @param file The file to load * @param error Pointer to data to be filled with file error if IOError is returned * @return Parser error (NoError on success)