fix for filenames extraction for wxBitmapButton

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2002-09-19 22:39:25 +00:00
parent 2304dc6eaa
commit c0d4a6b3c1
2 changed files with 86 additions and 62 deletions

View File

@@ -251,43 +251,55 @@ wxArrayString XmlResApp::PrepareTempFiles()
// find all files mentioned in structure, e.g. <bitmap>filename</bitmap> // find all files mentioned in structure, e.g. <bitmap>filename</bitmap>
void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxString& inputPath) void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxString& inputPath)
{ {
wxXmlNode *n = node; // Is 'node' XML node element?
if (n == NULL) return; if (node == NULL) return;
n = n->GetChildren(); if (node->GetType() != wxXML_ELEMENT_NODE) return;
while (n) // Does 'node' contain filename information at all?
if (
// Any bitmaps:
(node->GetName() == _T("bitmap")) ||
// URLs in wxHtmlWindow:
(node->GetName() == _T("url")) ||
// wxBitmapButton:
(node->GetParent() != NULL &&
node->GetParent()->GetPropVal(_T("class"), _T("")) == _T("wxBitmapButton") &&
(node->GetName() == _T("focus") ||
node->GetName() == _T("disabled") ||
node->GetName() == _T("selected")))
)
{ {
if ((node->GetType() == wxXML_ELEMENT_NODE) && wxXmlNode *n = node->GetChildren();
// parent is an element, i.e. has subnodes... while (n)
(n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE) &&
// ...it is textnode...
((node/*not n!*/->GetName() == "bitmap") ||
(node/*not n!*/->GetName() == "url")))
// ...and known to contain filename
{ {
wxString fullname; if (n->GetType() == wxXML_TEXT_NODE ||
if (wxIsAbsolutePath(n->GetContent()) || inputPath == "") fullname = n->GetContent(); n->GetType() == wxXML_CDATA_SECTION_NODE)
else fullname = inputPath + "/" + n->GetContent(); {
wxString fullname;
if (wxIsAbsolutePath(n->GetContent()) || inputPath == "")
fullname = n->GetContent();
else
fullname = inputPath + "/" + n->GetContent();
if (flagVerbose) if (flagVerbose)
wxPrintf("adding " + fullname + "...\n"); wxPrintf("adding " + fullname + "...\n");
wxString filename = GetInternalFileName(n->GetContent(), flist);
n->SetContent(filename);
flist.Add(filename); wxString filename = GetInternalFileName(n->GetContent(), flist);
n->SetContent(filename);
wxFileInputStream sin(fullname); flist.Add(filename);
wxFileOutputStream sout(parOutputPath + "/" + filename);
sin.Read(sout); // copy the stream wxFileInputStream sin(fullname);
wxFileOutputStream sout(parOutputPath + "/" + filename);
sin.Read(sout); // copy the stream
}
// subnodes:
if (n->GetType() == wxXML_ELEMENT_NODE)
FindFilesInXML(n, flist, inputPath);
n = n->GetNext();
} }
// subnodes:
if (n->GetType() == wxXML_ELEMENT_NODE)
FindFilesInXML(n, flist, inputPath);
n = n->GetNext();
} }
} }

View File

@@ -251,43 +251,55 @@ wxArrayString XmlResApp::PrepareTempFiles()
// find all files mentioned in structure, e.g. <bitmap>filename</bitmap> // find all files mentioned in structure, e.g. <bitmap>filename</bitmap>
void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxString& inputPath) void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxString& inputPath)
{ {
wxXmlNode *n = node; // Is 'node' XML node element?
if (n == NULL) return; if (node == NULL) return;
n = n->GetChildren(); if (node->GetType() != wxXML_ELEMENT_NODE) return;
while (n) // Does 'node' contain filename information at all?
if (
// Any bitmaps:
(node->GetName() == _T("bitmap")) ||
// URLs in wxHtmlWindow:
(node->GetName() == _T("url")) ||
// wxBitmapButton:
(node->GetParent() != NULL &&
node->GetParent()->GetPropVal(_T("class"), _T("")) == _T("wxBitmapButton") &&
(node->GetName() == _T("focus") ||
node->GetName() == _T("disabled") ||
node->GetName() == _T("selected")))
)
{ {
if ((node->GetType() == wxXML_ELEMENT_NODE) && wxXmlNode *n = node->GetChildren();
// parent is an element, i.e. has subnodes... while (n)
(n->GetType() == wxXML_TEXT_NODE ||
n->GetType() == wxXML_CDATA_SECTION_NODE) &&
// ...it is textnode...
((node/*not n!*/->GetName() == "bitmap") ||
(node/*not n!*/->GetName() == "url")))
// ...and known to contain filename
{ {
wxString fullname; if (n->GetType() == wxXML_TEXT_NODE ||
if (wxIsAbsolutePath(n->GetContent()) || inputPath == "") fullname = n->GetContent(); n->GetType() == wxXML_CDATA_SECTION_NODE)
else fullname = inputPath + "/" + n->GetContent(); {
wxString fullname;
if (wxIsAbsolutePath(n->GetContent()) || inputPath == "")
fullname = n->GetContent();
else
fullname = inputPath + "/" + n->GetContent();
if (flagVerbose) if (flagVerbose)
wxPrintf("adding " + fullname + "...\n"); wxPrintf("adding " + fullname + "...\n");
wxString filename = GetInternalFileName(n->GetContent(), flist);
n->SetContent(filename);
flist.Add(filename); wxString filename = GetInternalFileName(n->GetContent(), flist);
n->SetContent(filename);
wxFileInputStream sin(fullname); flist.Add(filename);
wxFileOutputStream sout(parOutputPath + "/" + filename);
sin.Read(sout); // copy the stream wxFileInputStream sin(fullname);
wxFileOutputStream sout(parOutputPath + "/" + filename);
sin.Read(sout); // copy the stream
}
// subnodes:
if (n->GetType() == wxXML_ELEMENT_NODE)
FindFilesInXML(n, flist, inputPath);
n = n->GetNext();
} }
// subnodes:
if (n->GetType() == wxXML_ELEMENT_NODE)
FindFilesInXML(n, flist, inputPath);
n = n->GetNext();
} }
} }