diff options
Diffstat (limited to 'src/xmlcomposer.cpp')
-rw-r--r-- | src/xmlcomposer.cpp | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index 9795fe2..36a705a 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -726,10 +726,10 @@ ON_CONTROLWORD(ListOverrideTable) // the list node for overriding, using the 'listid' and 'ls' we gathered if(curList != NULL && lsId != -1) { - DOM::Element parent = (DOM::Element&)curList.getParentNode(); + DOM::Element parent = (const DOM::Element&)curList.getParentNode(); if(parent != NULL) { - curList = (DOM::Element&)curList.cloneNode(true); + curList = (const DOM::Element&)curList.cloneNode(true); if(curList != NULL) { parent.appendChild(curList); @@ -990,11 +990,11 @@ bool RtfParser::isEqualElement(const DOM::Element& el1, const DOM::Element& el2) for(int i = 0; i < at1->getLength(); i++) { - DOM::Attr attr1 = (DOM::Attr&)at1->item(0); + DOM::Attr attr1 = (const DOM::Attr&)at1->item(0); if(attr1 != NULL) return false; - DOM::Attr attr2 = (DOM::Attr&)at2->getNamedItem(attr1.getNodeName()); + DOM::Attr attr2 = (const DOM::Attr&)at2->getNamedItem(attr1.getNodeName()); if(attr2 != NULL) return false; @@ -1008,7 +1008,13 @@ bool RtfParser::isEqualElement(const DOM::Element& el1, const DOM::Element& el2) wstring RtfParser::formatInt(int num) { wchar_t buff[12]; + + // The Win32 version isn't secure +#ifdef _WIN32 swprintf(buff, L"%d", num); +#else + swprintf(buff, 12, L"%d", num); +#endif wstring n(buff); return n; @@ -1110,7 +1116,7 @@ void RtfParser::breakBreak(DOM::Document& doc, const string& contain, { for(int i = 0; i < els->getLength(); i++) { - DOM::Element el = (DOM::Element&)els->item(i); + DOM::Element el = (const DOM::Element&)els->item(i); #if 0 // See if parent node only has this break tag // in it. If so then replace parent with this @@ -1154,11 +1160,11 @@ void RtfParser::breakBreak(DOM::Document& doc, const string& contain, * <b>test of </b> your concentration. * </dest> */ -bool RtfParser::breakElement(DOM::Element& el, const string& contain) +bool RtfParser::breakElement(const DOM::Element& el, const string& contain) { ASSERT(el != NULL); - DOM::Element parent = (DOM::Element&)el.getParentNode(); + DOM::Element parent = (const DOM::Element&)el.getParentNode(); DOM::Element grandparent; string s = el.getNodeName(); @@ -1166,7 +1172,7 @@ bool RtfParser::breakElement(DOM::Element& el, const string& contain) // Get the parent node if(parent != NULL) - grandparent = (DOM::Element&)parent.getParentNode(); + grandparent = (const DOM::Element&)parent.getParentNode(); // Make sure we have something to work with before continuing if(grandparent == NULL || parent == NULL || @@ -1200,7 +1206,7 @@ bool RtfParser::breakElement(DOM::Element& el, const string& contain) else { // Clone it but not deep - DOM::Element parent2 = (DOM::Element&)parent.cloneNode(false); + DOM::Element parent2 = (const DOM::Element&)parent.cloneNode(false); if(parent2 == NULL) return false; @@ -1254,7 +1260,7 @@ void RtfParser::breakBlocks(DOM::Document& document) { for(int i = 0; i < blocks->getLength(); i++) { - DOM::Element block = (DOM::Element&)blocks->item(i); + DOM::Element block = (const DOM::Element&)blocks->item(i); // If it's the single closed style para then break it if(block != NULL && !block.hasChildNodes()) @@ -1269,7 +1275,7 @@ void RtfParser::breakBlocks(DOM::Document& document) { for(int i = 0; i < destinations->getLength(); i++) { - DOM::Element dest = (DOM::Element&)destinations->item(i); + DOM::Element dest = (const DOM::Element&)destinations->item(i); // Sanity Check if(dest == NULL || !dest.hasChildNodes()) @@ -1321,7 +1327,7 @@ void RtfParser::wrapTags(DOM::Document& doc, const string& tagName, { for(int i = 0; i < tags->getLength(); i++) { - DOM::Element tag = (DOM::Element&)tags->item(i); + DOM::Element tag = (const DOM::Element&)tags->item(i); DOM::Element wrap = doc.createElement(wrapName); while(tag.hasChildNodes()) @@ -1340,7 +1346,7 @@ void RtfParser::breakTags(DOM::Document& doc, const string& parentName, { for(int i = 0; i < parents->getLength(); i++) { - DOM::Element parent = (DOM::Element&)parents->item(i); + DOM::Element parent = (const DOM::Element&)parents->item(i); if(!parent.hasChildNodes()) continue; @@ -1349,7 +1355,7 @@ void RtfParser::breakTags(DOM::Document& doc, const string& parentName, if(tags != NULL) { for(int i = 0; i < tags->getLength(); i++) - breakElement((DOM::Element&)tags->item(i), parentName); + breakElement((const DOM::Element&)tags->item(i), parentName); } DOM::Node tag = doc.createElement(tagName); @@ -1406,7 +1412,7 @@ void RtfParser::breakTags(DOM::Document& doc, const string& parentName, { for(int i = 0; i < tags->getLength(); i++) { - DOM::Element tag = (DOM::Element&)tags->item(i); + DOM::Element tag = (const DOM::Element&)tags->item(i); DOM::Node parent = tag.getParentNode(); if(parent != NULL && !isElement(parent, parentName)) @@ -1438,7 +1444,7 @@ void RtfParser::breakLists(DOM::Document& doc) { for(int i = 0; i < destinations->getLength(); i++) { - DOM::Element dest = (DOM::Element&)destinations->item(i); + DOM::Element dest = (const DOM::Element&)destinations->item(i); // Sanity Check if(dest == NULL) @@ -1503,14 +1509,14 @@ void RtfParser::fixStyles(const DOM::Document doc) { for(int i = 0; i < blocks->getLength(); i++) { - DOM::Element block = (DOM::Element&)blocks->item(i); + DOM::Element block = (const DOM::Element&)blocks->item(i); if(block == NULL || !block.hasAttribute(kElStyle)) continue; for(int j = 0; j < styles->getLength(); j++) { - DOM::Element style = (DOM::Element&)styles->item(j); + DOM::Element style = (const DOM::Element&)styles->item(j); if(style != NULL) { if(style.getAttribute(kAtId) == block.getAttribute(kElStyle)) @@ -1526,7 +1532,7 @@ void RtfParser::fixStyles(const DOM::Document doc) for(int i = 0; i < styles->getLength(); i++) { - DOM::Element style = (DOM::Element&)styles->item(i); + DOM::Element style = (const DOM::Element&)styles->item(i); if(style != NULL) style.removeAttribute(kAtId); } @@ -1543,7 +1549,7 @@ void RtfParser::breakTables(DOM::Document& doc) { for(int i = 0; i < rows->getLength(); i++) { - DOM::Element row = (DOM::Element&)rows->item(i); + DOM::Element row = (const DOM::Element&)rows->item(i); DOM::Node parent = row.getParentNode(); if(parent == NULL) @@ -1574,7 +1580,7 @@ void RtfParser::breakTables(DOM::Document& doc) { for(int i = 0; i < destinations->getLength(); i++) { - DOM::Element dest = (DOM::Element&)destinations->item(i); + DOM::Element dest = (const DOM::Element&)destinations->item(i); // Sanity Check if(dest == NULL) @@ -1643,7 +1649,7 @@ void RtfParser::removeTags(const DOM::Document& doc) { for(int j = 0; j < elements->getLength(); j++) { - DOM::Element el = (DOM::Element&)elements->item(j); + DOM::Element el = (const DOM::Element&)elements->item(j); DOM::Node parent = el->getParentNode(); if(parent == NULL) @@ -1668,14 +1674,14 @@ void RtfParser::fixLists(const DOM::Document doc) { for(int i = 0; i < listdefs->getLength(); i++) { - DOM::Element listdef = (DOM::Element&)listdefs->item(i); + DOM::Element listdef = (const DOM::Element&)listdefs->item(i); if(listdef == NULL || !listdef.hasAttribute(kAtList)) continue; for(int j = 0; j < lists->getLength(); j++) { - DOM::Element list = (DOM::Element&)lists->item(j); + DOM::Element list = (const DOM::Element&)lists->item(j); if(list != NULL) { if(list.getAttribute(kAtList) == listdef.getAttribute(kAtList)) @@ -1701,7 +1707,7 @@ void RtfParser::fixBlocks(const DOM::Document doc) for(int i = 0; i < blocks->getLength(); i++) { - DOM::Element block = (DOM::Element&)blocks->item(i); + DOM::Element block = (const DOM::Element&)blocks->item(i); DOM::Node parent = block.getParentNode(); if(parent == NULL) @@ -1756,7 +1762,7 @@ void RtfParser::removeDuplicates(const DOM::Document& doc) { // Make sure it's a valid element - DOM::Element element = (DOM::Element&)elements->item(j); + DOM::Element element = (const DOM::Element&)elements->item(j); if(element == NULL) continue; |