diff options
author | Stef Walter <stef@memberwebs.com> | 2004-07-24 22:32:14 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-07-24 22:32:14 +0000 |
commit | a70bc0519f2705257efca1c8a714a44c941534fb (patch) | |
tree | f43dd57982917760b8d12534e5a3c9520da8f024 /src/xmlfixups.cpp | |
parent | 07e7c437647e45b6f06b30a8dc02b663fd6a782c (diff) |
- Bug fixes to new fixup scheme
Diffstat (limited to 'src/xmlfixups.cpp')
-rw-r--r-- | src/xmlfixups.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/src/xmlfixups.cpp b/src/xmlfixups.cpp index b8c84f4..10b35f1 100644 --- a/src/xmlfixups.cpp +++ b/src/xmlfixups.cpp @@ -42,7 +42,7 @@ #include "tags.h" static const char* kNoDuplicates[] = - { kElB, kElU, kElI, kElColor, kElHide, kElColor, kElSuper, kElSub, NULL }; + { kElB, kElU, kElI, kElColor, kElHide, kElSuper, kElSub, NULL }; static const char* kRemoveTags[] = { kElDest, kElListdef, kElListtable, kElFontTable, NULL }; @@ -62,7 +62,7 @@ static const char* kConsolidateStart[] = void loadStringSet(StringSet& set, const char** strings) { while(*strings) - set.insert(string(*strings)); + set.insert(string(*(strings++))); } XmlFixups::XmlFixups() @@ -412,54 +412,14 @@ void XmlFixups::runPassTwo(const DOM::Document& doc) DOM::Element top = doc.getDocumentElement(); - // Get stylesheet block - DOM::Element el = DOMHelpers::getChildElement(top, kElStylesheet); - if(el != NULL) - { - // Load the styles into a id mapped table - styles.load(el, kElStyle); - - if(!styles.empty()) - { - styles.removeIds(); - haveStyles = true; - } - } - - // Get the font block - el = DOMHelpers::getChildElement(top, kElFontTable); - if(el != NULL) - { - // Load the fonts into an id mapped table - fonts.load(el, kElFont); - - if(!fonts.empty()) - { - fonts.removeIds(); - haveFonts = true; - } - } - - // Get the list definition block - el = DOMHelpers::getChildElement(top, kElListtable); - if(el != NULL) - { - // Load the lists into an id mapped table - lists.load(el, kElListdef); - - if(!lists.empty()) - { - lists.removeIds(); - haveLists = true; - } - } - NodeStack toStart; // Nodes that get moved to beginning of document NodeStack toEnd; // Nodes that get moved to the end of the document ElementIterator it(top); ElementIterator end; + DOM::Element el; + for( ; it != end; ++it) { el = *it; @@ -472,7 +432,46 @@ void XmlFixups::runPassTwo(const DOM::Document& doc) el.setUserData((void*)PASS_TWO); string name = el.getNodeName(); - if(name == kElBlock) + // Get stylesheet block + if(name == kElStylesheet) + { + // Load the styles into a id mapped table + styles.load(el, kElStyle); + + if(!styles.empty()) + { + styles.removeIds(); + haveStyles = true; + } + } + + // The Font Table + else if(name == kElFontTable) + { + // Load the fonts into an id mapped table + fonts.load(el, kElFontDef); + + if(!fonts.empty()) + { + fonts.removeIds(); + haveFonts = true; + } + } + + // Get the list definition block + else if(name == kElListtable) + { + // Load the lists into an id mapped table + lists.load(el, kElListdef); + + if(!lists.empty()) + { + lists.removeIds(); + haveLists = true; + } + } + + else if(name == kElBlock) { // Change style attribute on blocks to name if(haveStyles && el.hasAttribute(kElStyle)) @@ -487,6 +486,7 @@ void XmlFixups::runPassTwo(const DOM::Document& doc) * new element. The new element still needs to be processed, so we * just backup one, and then short circuit the loop below. */ + --it; // Now fix the block itself fixBlock(doc, el); @@ -602,10 +602,10 @@ void XmlFixups::runPassTwo(const DOM::Document& doc) if(parent != NULL && DOMHelpers::hasAncestor(top, node)) { // Remove it from it's child - parent.removeChild(el); + parent.removeChild(node); // And put at start of the document of the document - top.insertBefore(el, top.getFirstChild()); + top.insertBefore(node, top.getFirstChild()); } toStart.pop(); @@ -619,10 +619,10 @@ void XmlFixups::runPassTwo(const DOM::Document& doc) if(parent != NULL && DOMHelpers::hasAncestor(top, node)) { // Remove it from it's child - parent.removeChild(el); + parent.removeChild(node); // And put at end of the document of the document - top.appendChild(el); + top.appendChild(node); } toEnd.pop(); @@ -733,7 +733,7 @@ void XmlFixups::fixBlock(const DOM::Document& doc, DOM::Element& block) block.removeAttribute(kAtFix); // BUG: Sablotron bug work around - if(val.length() > 0) + if(val.length() == 0) { val = block.getAttributeNS("", kAtFix); if(val.length() > 0) |