diff options
author | Stef Walter <stef@memberwebs.com> | 2004-07-27 21:34:03 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-07-27 21:34:03 +0000 |
commit | 61ff9cee67228fd5b430eb929687ca0cac992a7c (patch) | |
tree | 73e27790adf037ce31280ae92e67d494983d18bd | |
parent | d2105fb3fb2082bb32875eaab6db6a2c04c7eae5 (diff) |
- Element comparison fixes
- Other XML fixup fixes
-rw-r--r-- | src/domhelpers.cpp | 8 | ||||
-rw-r--r-- | src/xmlcomposer.cpp | 9 | ||||
-rw-r--r-- | src/xmlfixups.cpp | 8 | ||||
-rw-r--r-- | test-files/sample.xml | 2 |
4 files changed, 17 insertions, 10 deletions
diff --git a/src/domhelpers.cpp b/src/domhelpers.cpp index 4836d17..9a9cfd2 100644 --- a/src/domhelpers.cpp +++ b/src/domhelpers.cpp @@ -50,7 +50,7 @@ bool DOMHelpers::isElement(const DOM::Node& node, const string& name) bool DOMHelpers::isEqualElement(const DOM::Element& el1, const DOM::Element& el2) { - if(el1.getNodeName() == el2.getNodeName()) + if(el1.getNodeName() != el2.getNodeName()) return false; // Compare attributes @@ -67,14 +67,14 @@ bool DOMHelpers::isEqualElement(const DOM::Element& el1, const DOM::Element& el2 for(int i = 0; i < at1->getLength(); i++) { DOM::Attr attr1 = (const DOM::Attr&)at1->item(0); - if(attr1 != NULL) + if(attr1 == NULL) return false; DOM::Attr attr2 = (const DOM::Attr&)at2->getNamedItem(attr1.getNodeName()); - if(attr2 != NULL) + if(attr2 == NULL) return false; - if(attr1.getNodeValue() == attr2.getNodeValue()) + if(attr1.getNodeValue() != attr2.getNodeValue()) return false; } diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index a90c25a..6f41b29 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -1095,7 +1095,14 @@ ON_CHARDATA(Content) AN_ATTRIBUTE(kAtName, font); if(fontsize != -1) - AN_ATTRIBUTE(kAtSize, fontsize); + { + // Little hack for half point sizes + wstring size = NUM_ATTR(fontsize / 2); + if(fontsize % 2) + size.append(L".5"); + + AN_ATTRIBUTE(kAtSize, size); + } if(format.textColor() != -1) AN_ATTRIBUTE(kAtColor, format.textColor()); diff --git a/src/xmlfixups.cpp b/src/xmlfixups.cpp index 45fa59a..3b56f6b 100644 --- a/src/xmlfixups.cpp +++ b/src/xmlfixups.cpp @@ -75,7 +75,7 @@ XmlFixups::XmlFixups() { loadStringSet(m_duplicates, kNoDuplicates); loadStringSet(m_removes, kRemoveTags); - loadStringSet(m_removes, kRemoveEmpty); + loadStringSet(m_removeEmpty, kRemoveEmpty); loadStringSet(m_requireAttrs, kRequireAttrs); loadStringSet(m_consolidateStart, kConsolidateStart); loadStringSet(m_consolidateEnd, kConsolidateEnd); @@ -511,7 +511,7 @@ void XmlFixups::runPassTwo(const DOM::Document& doc) if(font != NULL) el.setAttribute(kAtName, font.getAttribute(kAtName)); - font.removeAttribute(kAtId); + el.removeAttribute(kAtId); } } @@ -545,7 +545,7 @@ void XmlFixups::runPassTwo(const DOM::Document& doc) // Tags that get removed but contents preserved. Also here are // tags that get removed if they have no attributes if(m_removes.find(name) != m_removes.end() || - (m_requireAttrs.find(name) != m_requireAttrs.end() && el.hasAttributes())) + (m_requireAttrs.find(name) != m_requireAttrs.end() && !el.hasAttributes())) { DOM::Node parent = el->getParentNode(); @@ -569,7 +569,7 @@ void XmlFixups::runPassTwo(const DOM::Document& doc) } // Tags that get removed when no child nodes exist - if(m_removeEmpty.find(name) != m_removeEmpty.end() && el.hasChildNodes()) + if(m_removeEmpty.find(name) != m_removeEmpty.end() && !el.hasChildNodes()) { DOM::Node parent = el->getParentNode(); diff --git a/test-files/sample.xml b/test-files/sample.xml index a20d97b..85b8bfa 100644 --- a/test-files/sample.xml +++ b/test-files/sample.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="UTF-8"?><document><info><title>This is a test RTF</title><author>Nate</author><operator>Nate</operator></info><stylesheet><style name="Normal"/><style name="heading 1"/><style name="footnote text"/></stylesheet><para style="heading 1"><b>This is a test RTF</b></para><para>Hi! I’m a test file. This is some <b>bold</b> text, and some <i>italic</i> text, as well as some <u>underline</u> text. And a bit of <hide>hidden</hide> text. So we’re going to end this paragraph here and go on to a nice little list:</para><para/><list ordered="0" start="1"><para>Item 1</para><para>Item 2</para><para>Item 3</para><para>Item 4</para></list><para/><para>And now comes a fun table:</para><para/><table><row><cell><para>Cell 1</para></cell><cell><para>Cell 2</para><para>More in cell 2</para></cell><cell><para>Cell 3</para></cell></row><row><cell><para>Next row</para></cell><cell><para>Next row </para></cell><cell><para>Next row</para></cell></row></table><para/><para>A page break:</para><page/><para>And here we’re on the next page. </para><para>This para has a <ref type="footnote" to="1"/>footnote.</para><para>And here’s yet another paragraph. </para><para/><footnote id="1"><para> This is the actual content of the footnote.</para></footnote></document>
\ No newline at end of file +<?xml version="1.0" encoding="UTF-8"?><document xmlns="http://memberwebs.com/ns/rtfx/"><info><title>This is a test RTF</title><author>Nate</author><operator>Nate</operator></info><stylesheet><style name="Normal"/><style name="heading 1"/><style name="footnote text"/></stylesheet><options><font size="12" color="0" name="Times New Roman"/></options><para style="heading 1"><font name="1" size="16"><b>This is a test RTF</b></font></para><para>Hi! I’m a test file. This is some <b>bold</b> text, and some <i>italic</i> text, as well as some <u>underline</u> text. And a bit of <hide>hidden</hide> text. So we’re going to end this paragraph here and go on to a nice little list:</para><para/><list type="disc" ordered="0" start="1"><para>Item 1</para><para>Item 2</para><para>Item 3</para><para>Item 4</para></list><para/><para>And now comes a fun table:</para><para/><table><row><cell><para>Cell 1</para></cell><cell><para>Cell 2</para><para>More in cell 2</para></cell><cell><para>Cell 3</para></cell></row><row><cell><para>Next row</para></cell><cell><para>Next row </para></cell><cell><para>Next row</para></cell></row></table><para/><para>A page break:</para><page/><para>And here we’re on the next page. </para><para>This para has a <ref type="footnote" to="1"><super>1</super></ref>footnote.</para><para>And here’s yet another paragraph. </para><para/><footnote id="1"><para><font size="10"><super>1</super> This is the actual content of the footnote.</font></para></footnote></document>
\ No newline at end of file |