1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XML resource compiler
4 // Author: Vaclav Slavik, Eduardo Marques <edrdo@netcabo.pt>
7 // Copyright: (c) 2000 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx/wx.h".
12 #include "wx/wxprec.h"
18 // for all others, include the necessary headers
22 #include "wx/wxcrtvararg.h"
25 #include "wx/cmdline.h"
26 #include "wx/xml/xml.h"
28 #include "wx/filename.h"
29 #include "wx/wfstream.h"
31 #include "wx/hashset.h"
32 #include "wx/mimetype.h"
33 #include "wx/vector.h"
35 WX_DECLARE_HASH_SET(wxString
, wxStringHash
, wxStringEqual
, StringSet
);
40 XRCWidgetData(const wxString
& vname
,const wxString
& vclass
)
41 : m_class(vclass
), m_name(vname
) {}
42 const wxString
& GetName() const { return m_name
; }
43 const wxString
& GetClass() const { return m_class
; }
49 #include "wx/arrimpl.cpp"
50 WX_DECLARE_OBJARRAY(XRCWidgetData
,ArrayOfXRCWidgetData
);
51 WX_DEFINE_OBJARRAY(ArrayOfXRCWidgetData
)
57 wxString m_parentClassName
;
58 StringSet m_ancestorClassNames
;
59 ArrayOfXRCWidgetData m_wdata
;
61 void BrowseXmlNode(wxXmlNode
* node
)
68 if (node
->GetName() == _T("object")
69 && node
->GetAttribute(_T("class"),&classValue
)
70 && node
->GetAttribute(_T("name"),&nameValue
))
72 m_wdata
.Add(XRCWidgetData(nameValue
,classValue
));
74 children
= node
->GetChildren();
76 BrowseXmlNode(children
);
77 node
= node
->GetNext();
82 XRCWndClassData(const wxString
& className
,
83 const wxString
& parentClassName
,
84 const wxXmlNode
* node
) :
85 m_className(className
) , m_parentClassName(parentClassName
)
87 if ( className
== _T("wxMenu") )
89 m_ancestorClassNames
.insert(_T("wxMenu"));
90 m_ancestorClassNames
.insert(_T("wxMenuBar"));
92 else if ( className
== _T("wxMDIChildFrame") )
94 m_ancestorClassNames
.insert(_T("wxMDIParentFrame"));
96 else if( className
== _T("wxMenuBar") ||
97 className
== _T("wxStatusBar") ||
98 className
== _T("wxToolBar") )
100 m_ancestorClassNames
.insert(_T("wxFrame"));
104 m_ancestorClassNames
.insert(_T("wxWindow"));
107 BrowseXmlNode(node
->GetChildren());
110 const ArrayOfXRCWidgetData
& GetWidgetData()
115 bool CanBeUsedWithXRCCTRL(const wxString
& name
)
117 if (name
== _T("tool") ||
118 name
== _T("data") ||
119 name
== _T("unknown") ||
120 name
== _T("notebookpage") ||
121 name
== _T("separator") ||
122 name
== _T("sizeritem") ||
123 name
== _T("wxMenuBar") ||
124 name
== _T("wxMenuItem") ||
125 name
== _T("wxStaticBoxSizer") )
132 void GenerateHeaderCode(wxFFile
& file
)
135 file
.Write(_T("class ") + m_className
+ _T(" : public ") + m_parentClassName
136 + _T(" {\nprotected:\n"));
138 for(i
=0;i
<m_wdata
.GetCount();++i
)
140 const XRCWidgetData
& w
= m_wdata
.Item(i
);
141 if( !CanBeUsedWithXRCCTRL(w
.GetClass()) ) continue;
142 if( w
.GetName().Length() == 0 ) continue;
144 _T(" ") + w
.GetClass() + _T("* ") + w
.GetName()
147 file
.Write(_T("\nprivate:\n void InitWidgetsFromXRC(wxWindow *parent){\n")
148 _T(" wxXmlResource::Get()->LoadObject(this,parent,_T(\"")
153 for(i
=0;i
<m_wdata
.GetCount();++i
)
155 const XRCWidgetData
& w
= m_wdata
.Item(i
);
156 if( !CanBeUsedWithXRCCTRL(w
.GetClass()) ) continue;
157 if( w
.GetName().Length() == 0 ) continue;
160 + _T(" = XRCCTRL(*this,\"")
166 file
.Write(_T(" }\n"));
168 file
.Write( _T("public:\n"));
170 if ( m_ancestorClassNames
.size() == 1 )
176 *m_ancestorClassNames
.begin() +
177 _T(" *parent=NULL){\n") +
178 _T(" InitWidgetsFromXRC((wxWindow *)parent);\n")
185 file
.Write(m_className
+ _T("(){\n") +
186 _T(" InitWidgetsFromXRC(NULL);\n")
190 for ( StringSet::const_iterator it
= m_ancestorClassNames
.begin();
191 it
!= m_ancestorClassNames
.end();
194 file
.Write(m_className
+ _T("(") + *it
+ _T(" *parent){\n") +
195 _T(" InitWidgetsFromXRC((wxWindow *)parent);\n")
202 WX_DECLARE_OBJARRAY(XRCWndClassData
,ArrayOfXRCWndClassData
);
203 WX_DEFINE_OBJARRAY(ArrayOfXRCWndClassData
)
205 struct ExtractedString
207 ExtractedString() : lineNo(-1) {}
208 ExtractedString(const wxString
& str_
,
209 const wxString
& filename_
, int lineNo_
)
210 : str(str_
), filename(filename_
), lineNo(lineNo_
)
219 typedef wxVector
<ExtractedString
> ExtractedStrings
;
222 class XmlResApp
: public wxAppConsole
225 // don't use builtin cmd line parsing:
226 virtual bool OnInit() { return true; }
230 void ParseParams(const wxCmdLineParser
& cmdline
);
232 wxArrayString
PrepareTempFiles();
233 void FindFilesInXML(wxXmlNode
*node
, wxArrayString
& flist
, const wxString
& inputPath
);
235 wxString
GetInternalFileName(const wxString
& name
, const wxArrayString
& flist
);
236 void DeleteTempFiles(const wxArrayString
& flist
);
237 void MakePackageZIP(const wxArrayString
& flist
);
238 void MakePackageCPP(const wxArrayString
& flist
);
239 void MakePackagePython(const wxArrayString
& flist
);
241 void OutputGettext();
242 ExtractedStrings
FindStrings();
243 ExtractedStrings
FindStrings(const wxString
& filename
, wxXmlNode
*node
);
245 bool flagVerbose
, flagCPP
, flagPython
, flagGettext
;
246 wxString parOutput
, parFuncname
, parOutputPath
;
247 wxArrayString parFiles
;
250 ArrayOfXRCWndClassData aXRCWndClassData
;
255 IMPLEMENT_APP_CONSOLE(XmlResApp
)
257 int XmlResApp::OnRun()
259 static const wxCmdLineEntryDesc cmdLineDesc
[] =
261 { wxCMD_LINE_SWITCH
, "h", "help", "show help message", wxCMD_LINE_VAL_NONE
, wxCMD_LINE_OPTION_HELP
},
262 { wxCMD_LINE_SWITCH
, "v", "verbose", "be verbose" },
263 { wxCMD_LINE_SWITCH
, "e", "extra-cpp-code", "output C++ header file with XRC derived classes" },
264 { wxCMD_LINE_SWITCH
, "c", "cpp-code", "output C++ source rather than .rsc file" },
265 { wxCMD_LINE_SWITCH
, "p", "python-code", "output wxPython source rather than .rsc file" },
266 { wxCMD_LINE_SWITCH
, "g", "gettext", "output list of translatable strings (to stdout or file if -o used)" },
267 { wxCMD_LINE_OPTION
, "n", "function", "C++/Python function name (with -c or -p) [InitXmlResource]" },
268 { wxCMD_LINE_OPTION
, "o", "output", "output file [resource.xrs/cpp]" },
269 #if 0 // not yet implemented
270 { wxCMD_LINE_OPTION
, "l", "list-of-handlers", "output list of necessary handlers to this file" },
272 { wxCMD_LINE_PARAM
, NULL
, NULL
, "input file(s)",
273 wxCMD_LINE_VAL_STRING
,
274 wxCMD_LINE_PARAM_MULTIPLE
| wxCMD_LINE_OPTION_MANDATORY
},
279 wxCmdLineParser
parser(cmdLineDesc
, argc
, argv
);
281 switch (parser
.Parse())
301 void XmlResApp::ParseParams(const wxCmdLineParser
& cmdline
)
303 flagGettext
= cmdline
.Found("g");
304 flagVerbose
= cmdline
.Found("v");
305 flagCPP
= cmdline
.Found("c");
306 flagPython
= cmdline
.Found("p");
307 flagH
= flagCPP
&& cmdline
.Found("e");
310 if (!cmdline
.Found("o", &parOutput
))
313 parOutput
= wxEmptyString
;
317 parOutput
= _T("resource.cpp");
319 parOutput
= _T("resource.py");
321 parOutput
= _T("resource.xrs");
324 if (!parOutput
.empty())
326 wxFileName
fn(parOutput
);
328 parOutput
= fn
.GetFullPath();
329 parOutputPath
= wxPathOnly(parOutput
);
331 if (!parOutputPath
) parOutputPath
= _T(".");
333 if (!cmdline
.Found("n", &parFuncname
))
334 parFuncname
= _T("InitXmlResource");
336 for (size_t i
= 0; i
< cmdline
.GetParamCount(); i
++)
339 wxString fn
=wxFindFirstFile(cmdline
.GetParam(i
), wxFILE
);
346 parFiles
.Add(cmdline
.GetParam(i
));
354 void XmlResApp::CompileRes()
356 wxArrayString files
= PrepareTempFiles();
358 wxRemoveFile(parOutput
);
363 MakePackageCPP(files
);
368 MakePackagePython(files
);
370 MakePackageZIP(files
);
373 DeleteTempFiles(files
);
377 wxString
XmlResApp::GetInternalFileName(const wxString
& name
, const wxArrayString
& flist
)
379 wxString name2
= name
;
380 name2
.Replace(_T(":"), _T("_"));
381 name2
.Replace(_T("/"), _T("_"));
382 name2
.Replace(_T("\\"), _T("_"));
383 name2
.Replace(_T("*"), _T("_"));
384 name2
.Replace(_T("?"), _T("_"));
386 wxString s
= wxFileNameFromPath(parOutput
) + _T("$") + name2
;
388 if (wxFileExists(s
) && flist
.Index(s
) == wxNOT_FOUND
)
390 for (int i
= 0;; i
++)
392 s
.Printf(wxFileNameFromPath(parOutput
) + _T("$%03i-") + name2
, i
);
393 if (!wxFileExists(s
) || flist
.Index(s
) != wxNOT_FOUND
)
400 wxArrayString
XmlResApp::PrepareTempFiles()
404 for (size_t i
= 0; i
< parFiles
.GetCount(); i
++)
407 wxPrintf(_T("processing ") + parFiles
[i
] + _T("...\n"));
411 if (!doc
.Load(parFiles
[i
]))
413 wxLogError(_T("Error parsing file ") + parFiles
[i
]);
418 wxString name
, ext
, path
;
419 wxSplitPath(parFiles
[i
], &path
, &name
, &ext
);
421 FindFilesInXML(doc
.GetRoot(), flist
, path
);
424 wxXmlNode
* node
= (doc
.GetRoot())->GetChildren();
425 wxString classValue
,nameValue
;
427 if(node
->GetName() == _T("object")
428 && node
->GetAttribute(_T("class"),&classValue
)
429 && node
->GetAttribute(_T("name"),&nameValue
)){
431 aXRCWndClassData
.Add(
432 XRCWndClassData(nameValue
,classValue
,node
)
435 node
= node
-> GetNext();
438 wxString internalName
= GetInternalFileName(parFiles
[i
], flist
);
440 doc
.Save(parOutputPath
+ wxFILE_SEP_PATH
+ internalName
);
441 flist
.Add(internalName
);
448 // Does 'node' contain filename information at all?
449 static bool NodeContainsFilename(wxXmlNode
*node
)
451 const wxString name
= node
->GetName();
453 // Any bitmaps (bitmap2 is used for disabled toolbar buttons):
454 if ( name
== _T("bitmap") || name
== _T("bitmap2") )
457 if ( name
== _T("icon") )
461 wxXmlNode
*parent
= node
->GetParent();
462 if (parent
!= NULL
&&
463 parent
->GetAttribute(_T("class"), _T("")) == _T("wxBitmapButton") &&
464 (name
== _T("focus") ||
465 name
== _T("disabled") ||
466 name
== _T("hover") ||
467 name
== _T("selected")))
470 // wxBitmap or wxIcon toplevel resources:
471 if ( name
== _T("object") )
473 wxString klass
= node
->GetAttribute(_T("class"), wxEmptyString
);
474 if (klass
== _T("wxBitmap") ||
475 klass
== _T("wxIcon") ||
476 klass
== _T("data") )
480 // URLs in wxHtmlWindow:
481 if ( name
== _T("url") &&
483 parent
->GetAttribute(_T("class"), _T("")) == _T("wxHtmlWindow") )
485 // FIXME: this is wrong for e.g. http:// URLs
492 // find all files mentioned in structure, e.g. <bitmap>filename</bitmap>
493 void XmlResApp::FindFilesInXML(wxXmlNode
*node
, wxArrayString
& flist
, const wxString
& inputPath
)
495 // Is 'node' XML node element?
496 if (node
== NULL
) return;
497 if (node
->GetType() != wxXML_ELEMENT_NODE
) return;
499 bool containsFilename
= NodeContainsFilename(node
);
501 wxXmlNode
*n
= node
->GetChildren();
504 if (containsFilename
&&
505 (n
->GetType() == wxXML_TEXT_NODE
||
506 n
->GetType() == wxXML_CDATA_SECTION_NODE
))
509 if (wxIsAbsolutePath(n
->GetContent()) || inputPath
.empty())
510 fullname
= n
->GetContent();
512 fullname
= inputPath
+ wxFILE_SEP_PATH
+ n
->GetContent();
515 wxPrintf(_T("adding ") + fullname
+ _T("...\n"));
517 wxString filename
= GetInternalFileName(n
->GetContent(), flist
);
518 n
->SetContent(filename
);
520 if (flist
.Index(filename
) == wxNOT_FOUND
)
523 wxFileInputStream
sin(fullname
);
524 wxFileOutputStream
sout(parOutputPath
+ wxFILE_SEP_PATH
+ filename
);
525 sin
.Read(sout
); // copy the stream
529 if (n
->GetType() == wxXML_ELEMENT_NODE
)
530 FindFilesInXML(n
, flist
, inputPath
);
538 void XmlResApp::DeleteTempFiles(const wxArrayString
& flist
)
540 for (size_t i
= 0; i
< flist
.GetCount(); i
++)
541 wxRemoveFile(parOutputPath
+ wxFILE_SEP_PATH
+ flist
[i
]);
546 void XmlResApp::MakePackageZIP(const wxArrayString
& flist
)
550 for (size_t i
= 0; i
< flist
.GetCount(); i
++)
551 files
+= flist
[i
] + _T(" ");
555 wxPrintf(_T("compressing ") + parOutput
+ _T("...\n"));
557 wxString cwd
= wxGetCwd();
558 wxSetWorkingDirectory(parOutputPath
);
559 int execres
= wxExecute(_T("zip -9 -j ") +
560 wxString(flagVerbose
? _T("\"") : _T("-q \"")) +
561 parOutput
+ _T("\" ") + files
, true);
562 wxSetWorkingDirectory(cwd
);
565 wxLogError(_T("Unable to execute zip program. Make sure it is in the path."));
566 wxLogError(_T("You can download it at http://www.cdrom.com/pub/infozip/"));
574 static wxString
FileToCppArray(wxString filename
, int num
)
579 wxFFile
file(filename
, wxT("rb"));
580 wxFileOffset offset
= file
.Length();
581 wxASSERT_MSG( offset
>= 0 , wxT("Invalid file length") );
583 const size_t lng
= wx_truncate_cast(size_t, offset
);
584 wxASSERT_MSG( wx_static_cast(wxFileOffset
, lng
) == offset
,
585 wxT("Huge file not supported") );
587 snum
.Printf(_T("%i"), num
);
588 output
.Printf(_T("static size_t xml_res_size_") + snum
+ _T(" = %i;\n"), lng
);
589 output
+= _T("static unsigned char xml_res_file_") + snum
+ _T("[] = {\n");
590 // we cannot use string literals because MSVC is dumb wannabe compiler
591 // with arbitrary limitation to 2048 strings :(
593 unsigned char *buffer
= new unsigned char[lng
];
594 file
.Read(buffer
, lng
);
596 for (size_t i
= 0, linelng
= 0; i
< lng
; i
++)
598 tmp
.Printf(_T("%i"), buffer
[i
]);
599 if (i
!= 0) output
<< _T(',');
606 linelng
+= tmp
.Length()+1;
611 output
+= _T("};\n\n");
617 void XmlResApp::MakePackageCPP(const wxArrayString
& flist
)
619 wxFFile
file(parOutput
, wxT("wt"));
623 wxPrintf(_T("creating C++ source file ") + parOutput
+ _T("...\n"));
627 "// This file was automatically generated by wxrc, do not edit by hand.\n"
629 "#include <wx/wxprec.h>\n"
631 "#ifdef __BORLANDC__\n"
636 "#include <wx/filesys.h>\n"
637 "#include <wx/fs_mem.h>\n"
638 "#include <wx/xrc/xmlres.h>\n"
639 "#include <wx/xrc/xh_all.h>\n"
641 "#if wxCHECK_VERSION(2,8,5) && wxABI_VERSION >= 20805\n"
642 " #define XRC_ADD_FILE(name, data, size, mime) \\\n"
643 " wxMemoryFSHandler::AddFileWithMimeType(name, data, size, mime)\n"
645 " #define XRC_ADD_FILE(name, data, size, mime) \\\n"
646 " wxMemoryFSHandler::AddFile(name, data, size)\n"
650 for (i
= 0; i
< flist
.GetCount(); i
++)
652 FileToCppArray(parOutputPath
+ wxFILE_SEP_PATH
+ flist
[i
], i
));
655 "void " + parFuncname
+ "()\n"
658 " // Check for memory FS. If not present, load the handler:\n"
660 " wxMemoryFSHandler::AddFile(wxT(\"XRC_resource/dummy_file\"), wxT(\"dummy one\"));\n"
661 " wxFileSystem fsys;\n"
662 " wxFSFile *f = fsys.OpenFile(wxT(\"memory:XRC_resource/dummy_file\"));\n"
663 " wxMemoryFSHandler::RemoveFile(wxT(\"XRC_resource/dummy_file\"));\n"
664 " if (f) delete f;\n"
665 " else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n"
669 for (i
= 0; i
< flist
.GetCount(); i
++)
674 wxString ext
= wxFileName(flist
[i
]).GetExt();
675 if ( ext
.Lower() == _T("xrc") )
676 mime
= _T("text/xml");
680 wxFileType
*ft
= wxTheMimeTypesManager
->GetFileTypeFromExtension(ext
);
683 ft
->GetMimeType(&mime
);
687 #endif // wxUSE_MIMETYPE
689 s
.Printf(" XRC_ADD_FILE(wxT(\"XRC_resource/" + flist
[i
] +
690 "\"), xml_res_file_%i, xml_res_size_%i, _T(\"%s\"));\n",
695 for (i
= 0; i
< parFiles
.GetCount(); i
++)
697 file
.Write(" wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/" +
698 GetInternalFileName(parFiles
[i
], flist
) + "\"));\n");
706 void XmlResApp::GenCPPHeader()
708 wxString fileSpec
= ((parOutput
.BeforeLast('.')).AfterLast('/')).AfterLast('\\');
709 wxString heaFileName
= fileSpec
+ _T(".h");
711 wxFFile
file(heaFileName
, wxT("wt"));
714 "// This file was automatically generated by wxrc, do not edit by hand.\n"
716 "#ifndef __" + fileSpec
+ "_h__\n"
717 "#define __" + fileSpec
+ "_h__\n"
719 for(size_t i
=0;i
<aXRCWndClassData
.GetCount();++i
){
720 aXRCWndClassData
.Item(i
).GenerateHeaderCode(file
);
728 static wxString
FileToPythonArray(wxString filename
, int num
)
733 wxFFile
file(filename
, wxT("rb"));
734 wxFileOffset offset
= file
.Length();
735 wxASSERT_MSG( offset
>= 0 , wxT("Invalid file length") );
737 const size_t lng
= wx_truncate_cast(size_t, offset
);
738 wxASSERT_MSG( wx_static_cast(wxFileOffset
, lng
) == offset
,
739 wxT("Huge file not supported") );
741 snum
.Printf(_T("%i"), num
);
742 output
= " xml_res_file_" + snum
+ " = '''\\\n";
744 unsigned char *buffer
= new unsigned char[lng
];
745 file
.Read(buffer
, lng
);
747 for (size_t i
= 0, linelng
= 0; i
< lng
; i
++)
749 unsigned char c
= buffer
[i
];
755 else if (c
< 32 || c
> 127 || c
== '\'')
756 tmp
.Printf(_T("\\x%02x"), c
);
764 output
<< _T("\\\n");
767 linelng
+= tmp
.Length();
772 output
+= _T("'''\n\n");
778 void XmlResApp::MakePackagePython(const wxArrayString
& flist
)
780 wxFFile
file(parOutput
, wxT("wt"));
784 wxPrintf(_T("creating Python source file ") + parOutput
+ _T("...\n"));
788 "# This file was automatically generated by wxrc, do not edit by hand.\n"
795 file
.Write("def " + parFuncname
+ "():\n");
797 for (i
= 0; i
< flist
.GetCount(); i
++)
799 FileToPythonArray(parOutputPath
+ wxFILE_SEP_PATH
+ flist
[i
], i
));
802 " # check if the memory filesystem handler has been loaded yet, and load it if not\n"
803 " wx.MemoryFSHandler.AddFile('XRC_resource/dummy_file', 'dummy value')\n"
804 " fsys = wx.FileSystem()\n"
805 " f = fsys.OpenFile('memory:XRC_resource/dummy_file')\n"
806 " wx.MemoryFSHandler.RemoveFile('XRC_resource/dummy_file')\n"
807 " if f is not None:\n"
810 " wx.FileSystem.AddHandler(wx.MemoryFSHandler())\n"
812 " # load all the strings as memory files and load into XmlRes\n"
816 for (i
= 0; i
< flist
.GetCount(); i
++)
819 s
.Printf(" wx.MemoryFSHandler.AddFile('XRC_resource/" + flist
[i
] +
820 "', xml_res_file_%i)\n", i
);
823 for (i
= 0; i
< parFiles
.GetCount(); i
++)
825 file
.Write(" wx.xrc.XmlResource.Get().Load('memory:XRC_resource/" +
826 GetInternalFileName(parFiles
[i
], flist
) + "')\n");
834 void XmlResApp::OutputGettext()
836 ExtractedStrings str
= FindStrings();
839 if (parOutput
.empty())
842 fout
.Open(parOutput
, wxT("wt"));
844 for (ExtractedStrings::const_iterator i
= str
.begin(); i
!= str
.end(); ++i
)
848 s
.Printf("#line %d \"%s\"\n", i
->lineNo
, i
->filename
);
850 fout
.Write("_(\"" + i
->str
+ "\");\n");
853 if (!parOutput
) fout
.Detach();
858 ExtractedStrings
XmlResApp::FindStrings()
860 ExtractedStrings arr
, a2
;
862 for (size_t i
= 0; i
< parFiles
.GetCount(); i
++)
865 wxPrintf(_T("processing ") + parFiles
[i
] + _T("...\n"));
868 if (!doc
.Load(parFiles
[i
]))
870 wxLogError(_T("Error parsing file ") + parFiles
[i
]);
874 a2
= FindStrings(parFiles
[i
], doc
.GetRoot());
876 WX_APPEND_ARRAY(arr
, a2
);
884 static wxString
ConvertText(const wxString
& str
)
889 for (dt
= str
.c_str(); *dt
; dt
++)
893 if ( *(++dt
) == wxT('_') )
896 str2
<< wxT('&') << *dt
;
902 case wxT('\n') : str2
<< wxT("\\n"); break;
903 case wxT('\t') : str2
<< wxT("\\t"); break;
904 case wxT('\r') : str2
<< wxT("\\r"); break;
905 case wxT('\\') : if ((*(dt
+1) != 'n') &&
912 case wxT('"') : str2
<< wxT("\\\""); break;
913 default : str2
<< *dt
; break;
923 XmlResApp::FindStrings(const wxString
& filename
, wxXmlNode
*node
)
925 ExtractedStrings arr
;
928 if (n
== NULL
) return arr
;
929 n
= n
->GetChildren();
933 if ((node
->GetType() == wxXML_ELEMENT_NODE
) &&
934 // parent is an element, i.e. has subnodes...
935 (n
->GetType() == wxXML_TEXT_NODE
||
936 n
->GetType() == wxXML_CDATA_SECTION_NODE
) &&
937 // ...it is textnode...
939 node
/*not n!*/->GetName() == _T("label") ||
940 (node
/*not n!*/->GetName() == _T("value") &&
941 !n
->GetContent().IsNumber()) ||
942 node
/*not n!*/->GetName() == _T("help") ||
943 node
/*not n!*/->GetName() == _T("longhelp") ||
944 node
/*not n!*/->GetName() == _T("tooltip") ||
945 node
/*not n!*/->GetName() == _T("htmlcode") ||
946 node
/*not n!*/->GetName() == _T("title") ||
947 node
/*not n!*/->GetName() == _T("item")
949 // ...and known to contain translatable string
952 node
->GetAttribute(_T("translate"), _T("1")) != _T("0"))
958 ConvertText(n
->GetContent()),
967 if (n
->GetType() == wxXML_ELEMENT_NODE
)
969 ExtractedStrings a2
= FindStrings(filename
, n
);
970 WX_APPEND_ARRAY(arr
, a2
);