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:
@@ -251,43 +251,55 @@ wxArrayString XmlResApp::PrepareTempFiles()
|
||||
// find all files mentioned in structure, e.g. <bitmap>filename</bitmap>
|
||||
void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxString& inputPath)
|
||||
{
|
||||
wxXmlNode *n = node;
|
||||
if (n == NULL) return;
|
||||
n = n->GetChildren();
|
||||
|
||||
while (n)
|
||||
// Is 'node' XML node element?
|
||||
if (node == NULL) return;
|
||||
if (node->GetType() != wxXML_ELEMENT_NODE) return;
|
||||
|
||||
// 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) &&
|
||||
// parent is an element, i.e. has subnodes...
|
||||
(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
|
||||
wxXmlNode *n = node->GetChildren();
|
||||
while (n)
|
||||
{
|
||||
wxString fullname;
|
||||
if (wxIsAbsolutePath(n->GetContent()) || inputPath == "") fullname = n->GetContent();
|
||||
else fullname = inputPath + "/" + n->GetContent();
|
||||
if (n->GetType() == wxXML_TEXT_NODE ||
|
||||
n->GetType() == wxXML_CDATA_SECTION_NODE)
|
||||
{
|
||||
wxString fullname;
|
||||
if (wxIsAbsolutePath(n->GetContent()) || inputPath == "")
|
||||
fullname = n->GetContent();
|
||||
else
|
||||
fullname = inputPath + "/" + n->GetContent();
|
||||
|
||||
if (flagVerbose)
|
||||
wxPrintf("adding " + fullname + "...\n");
|
||||
|
||||
wxString filename = GetInternalFileName(n->GetContent(), flist);
|
||||
n->SetContent(filename);
|
||||
if (flagVerbose)
|
||||
wxPrintf("adding " + fullname + "...\n");
|
||||
|
||||
flist.Add(filename);
|
||||
wxString filename = GetInternalFileName(n->GetContent(), flist);
|
||||
n->SetContent(filename);
|
||||
|
||||
wxFileInputStream sin(fullname);
|
||||
wxFileOutputStream sout(parOutputPath + "/" + filename);
|
||||
sin.Read(sout); // copy the stream
|
||||
flist.Add(filename);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -251,43 +251,55 @@ wxArrayString XmlResApp::PrepareTempFiles()
|
||||
// find all files mentioned in structure, e.g. <bitmap>filename</bitmap>
|
||||
void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxString& inputPath)
|
||||
{
|
||||
wxXmlNode *n = node;
|
||||
if (n == NULL) return;
|
||||
n = n->GetChildren();
|
||||
|
||||
while (n)
|
||||
// Is 'node' XML node element?
|
||||
if (node == NULL) return;
|
||||
if (node->GetType() != wxXML_ELEMENT_NODE) return;
|
||||
|
||||
// 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) &&
|
||||
// parent is an element, i.e. has subnodes...
|
||||
(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
|
||||
wxXmlNode *n = node->GetChildren();
|
||||
while (n)
|
||||
{
|
||||
wxString fullname;
|
||||
if (wxIsAbsolutePath(n->GetContent()) || inputPath == "") fullname = n->GetContent();
|
||||
else fullname = inputPath + "/" + n->GetContent();
|
||||
if (n->GetType() == wxXML_TEXT_NODE ||
|
||||
n->GetType() == wxXML_CDATA_SECTION_NODE)
|
||||
{
|
||||
wxString fullname;
|
||||
if (wxIsAbsolutePath(n->GetContent()) || inputPath == "")
|
||||
fullname = n->GetContent();
|
||||
else
|
||||
fullname = inputPath + "/" + n->GetContent();
|
||||
|
||||
if (flagVerbose)
|
||||
wxPrintf("adding " + fullname + "...\n");
|
||||
|
||||
wxString filename = GetInternalFileName(n->GetContent(), flist);
|
||||
n->SetContent(filename);
|
||||
if (flagVerbose)
|
||||
wxPrintf("adding " + fullname + "...\n");
|
||||
|
||||
flist.Add(filename);
|
||||
wxString filename = GetInternalFileName(n->GetContent(), flist);
|
||||
n->SetContent(filename);
|
||||
|
||||
wxFileInputStream sin(fullname);
|
||||
wxFileOutputStream sout(parOutputPath + "/" + filename);
|
||||
sin.Read(sout); // copy the stream
|
||||
flist.Add(filename);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user