+void wxXmlRcEditDocument::UpgradeNodeValue(wxXmlNode *node)
+{
+ wxXmlNode *n = node;
+ if (n == NULL) return;
+ n = n->GetChildren();
+
+ while (n)
+ {
+ if (n->GetType() == wxXML_TEXT_NODE ||
+ n->GetType() == wxXML_CDATA_SECTION_NODE)
+ {
+ wxString str1 = n->GetContent();
+ const wxChar *dt;
+
+ for (dt = str1.c_str(); *dt; dt++)
+ {
+ // Remap amp_char to &, map double amp_char to amp_char (for things
+ // like "&File..." -- this is illegal in XML, so we use "_File..."):
+ if (*dt == '$')
+ {
+ if ( *(++dt) != '$' )
+ str1[size_t(dt-str1.c_str()-1)] = '_';
+ }
+ }
+ n->SetContent(str1);
+ }
+ n = n->GetNext();
+ }
+}
+
+void wxXmlRcEditDocument::UpgradeNode(wxXmlNode *node)
+{
+ if (node)
+ {
+ UpgradeNodeValue(node);
+ UpgradeNode(node->GetNext());
+ UpgradeNode(node->GetChildren());
+ }
+}
+
+void wxXmlRcEditDocument::Upgrade()
+{
+ int v1,v2,v3,v4;
+ long version;
+ wxXmlNode *node = GetRoot();
+ wxString verstr = wxT("0.0.0.0");
+ node->GetPropVal(wxT("version"),verstr);
+ if (wxSscanf(verstr.c_str(), wxT("%i.%i.%i.%i"),
+ &v1, &v2, &v3, &v4) == 4)
+ version = v1*256*256*256+v2*256*256+v3*256+v4;
+ else
+ version = 0;
+ if (!version)
+ {
+ UpgradeNode(node);
+ }
+ node->DeleteProperty(wxT("version"));
+ node->AddProperty(wxT("version"), wxT(WX_XMLRES_CURRENT_VERSION_STRING));
+}
+