[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/lib/store
From: David Faure <faure () kde ! org>
Date: 2004-07-16 18:56:01
Message-ID: 20040716185601.1A366126E4 () office ! kde ! org
[Download RAW message or body]
CVS commit by faure:
Fixed wrong newlines in tags whose last (or only) child is a text node.
M +3 -1 koxmlwriter.cc 1.16
M +2 -1 koxmlwriter.h 1.17
M +5 -2 tests/xmlwritertest.cpp 1.12
--- koffice/lib/store/koxmlwriter.cc #1.15:1.16
@@ -112,4 +112,5 @@ bool KoXmlWriter::prepareForChild()
closeStartElement( parent );
parent.hasChildren = true;
+ parent.lastChildIsText = false;
}
if ( parent.indentInside ) {
@@ -167,5 +168,5 @@ void KoXmlWriter::endElement()
}
else {
- if ( tag.indentInside ) {
+ if ( tag.indentInside && !tag.lastChildIsText ) {
writeIndent();
}
@@ -183,4 +184,5 @@ void KoXmlWriter::addTextNode( const cha
closeStartElement( parent );
parent.hasChildren = true;
+ parent.lastChildIsText = true;
}
--- koffice/lib/store/koxmlwriter.h #1.16:1.17
@@ -196,8 +196,9 @@ private:
struct Tag {
Tag( const char* t = 0, bool ind = true )
- : tagName( t ), hasChildren( false ),
+ : tagName( t ), hasChildren( false ), lastChildIsText( false ),
openingTagClosed( false ), indentInside( ind ) {}
const char* tagName;
bool hasChildren; ///< element or text children
+ bool lastChildIsText; ///< last child is a text node
bool openingTagClosed; ///< true once the '\>' in \<tag a="b"\> is written \
out
bool indentInside; ///< whether to indent the contents of this tag
--- koffice/lib/store/tests/xmlwritertest.cpp #1.11:1.12
@@ -107,6 +107,9 @@ int main( int argc, char** argv ) {
writer.addConfigItem( "TestConfigInt", num );
writer.addConfigItem( "TestConfigDouble", numdouble );
- TEST_END( "test config", "<r>\n <config:config-item \
config:name=\"TestConfigDouble\" \
config:type=\"double\"/>5.0</config:config-item><r>\n" );
-
+ TEST_END( "test config", "<r>\n"
+ " <config:config-item config:name=\"TestConfigBool\" \
config:type=\"boolean\">true</config:config-item>\n" + " \
<config:config-item config:name=\"TestConfigInt\" \
config:type=\"int\">1</config:config-item>\n" + " \
<config:config-item config:name=\"TestConfigDouble\" \
config:type=\"double\">5</config:config-item>\n" + \
"</r>\n" );
speedTest();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic