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"
34 WX_DECLARE_HASH_SET(wxString
, wxStringHash
, wxStringEqual
, StringSet
);
39 XRCWidgetData(const wxString
& vname
,const wxString
& vclass
)
40 : m_class(vclass
), m_name(vname
) {}
41 const wxString
& GetName() const { return m_name
; }
42 const wxString
& GetClass() const { return m_class
; }
48 #include "wx/arrimpl.cpp"
49 WX_DECLARE_OBJARRAY(XRCWidgetData
,ArrayOfXRCWidgetData
);
50 WX_DEFINE_OBJARRAY(ArrayOfXRCWidgetData
)
56 wxString m_parentClassName
;
57 StringSet m_ancestorClassNames
;
58 ArrayOfXRCWidgetData m_wdata
;
60 void BrowseXmlNode(wxXmlNode
* node
)
67 if (node
->GetName() == _T("object")
68 && node
->GetAttribute(_T("class"),&classValue
)
69 && node
->GetAttribute(_T("name"),&nameValue
))
71 m_wdata
.Add(XRCWidgetData(nameValue
,classValue
));
73 children
= node
->GetChildren();
75 BrowseXmlNode(children
);
76 node
= node
->GetNext();
81 XRCWndClassData(const wxString
& className
,
82 const wxString
& parentClassName
,
83 const wxXmlNode
* node
) :
84 m_className(className
) , m_parentClassName(parentClassName
)
86 if ( className
== _T("wxMenu") )
88 m_ancestorClassNames
.insert(_T("wxMenu"));
89 m_ancestorClassNames
.insert(_T("wxMenuBar"));
91 else if ( className
== _T("wxMDIChildFrame") )
93 m_ancestorClassNames
.insert(_T("wxMDIParentFrame"));
95 else if( className
== _T("wxMenuBar") ||
96 className
== _T("wxStatusBar") ||
97 className
== _T("wxToolBar") )
99 m_ancestorClassNames
.insert(_T("wxFrame"));
103 m_ancestorClassNames
.insert(_T("wxWindow"));
106 BrowseXmlNode(node
->GetChildren());
109 const ArrayOfXRCWidgetData
& GetWidgetData()
114 bool CanBeUsedWithXRCCTRL(const wxString
& name
)
116 if (name
== _T("tool") ||
117 name
== _T("data") ||
118 name
== _T("unknown") ||
119 name
== _T("notebookpage") ||
120 name
== _T("separator") ||
121 name
== _T("sizeritem") ||
122 name
== _T("wxMenuBar") ||
123 name
== _T("wxMenuItem") ||
124 name
== _T("wxStaticBoxSizer") )
131 void GenerateHeaderCode(wxFFile
& file
)
134 file
.Write(_T("class ") + m_className
+ _T(" : public ") + m_parentClassName
135 + _T(" {\nprotected:\n"));
137 for(i
=0;i
<m_wdata
.GetCount();++i
)
139 const XRCWidgetData
& w
= m_wdata
.Item(i
);
140 if( !CanBeUsedWithXRCCTRL(w
.GetClass()) ) continue;
141 if( w
.GetName().Length() == 0 ) continue;
143 _T(" ") + w
.GetClass() + _T("* ") + w
.GetName()
146 file
.Write(_T("\nprivate:\n void InitWidgetsFromXRC(wxWindow *parent){\n")
147 _T(" wxXmlResource::Get()->LoadObject(this,parent,_T(\"")
152 for(i
=0;i
<m_wdata
.GetCount();++i
)
154 const XRCWidgetData
& w
= m_wdata
.Item(i
);
155 if( !CanBeUsedWithXRCCTRL(w
.GetClass()) ) continue;
156 if( w
.GetName().Length() == 0 ) continue;
159 + _T(" = XRCCTRL(*this,\"")
165 file
.Write(_T(" }\n"));
167 file
.Write( _T("public:\n"));
169 if ( m_ancestorClassNames
.size() == 1 )
175 *m_ancestorClassNames
.begin() +
176 _T(" *parent=NULL){\n") +
177 _T(" InitWidgetsFromXRC((wxWindow *)parent);\n")
184 file
.Write(m_className
+ _T("(){\n") +
185 _T(" InitWidgetsFromXRC(NULL);\n")
189 for ( StringSet::const_iterator it
= m_ancestorClassNames
.begin();
190 it
!= m_ancestorClassNames
.end();
193 file
.Write(m_className
+ _T("(") + *it
+ _T(" *parent){\n") +
194 _T(" InitWidgetsFromXRC((wxWindow *)parent);\n")
201 WX_DECLARE_OBJARRAY(XRCWndClassData
,ArrayOfXRCWndClassData
);
202 WX_DEFINE_OBJARRAY(ArrayOfXRCWndClassData
)
205 class XmlResApp
: public wxAppConsole
208 // don't use builtin cmd line parsing:
209 virtual bool OnInit() { return true; }
213 void ParseParams(const wxCmdLineParser
& cmdline
);
215 wxArrayString
PrepareTempFiles();
216 void FindFilesInXML(wxXmlNode
*node
, wxArrayString
& flist
, const wxString
& inputPath
);
218 wxString
GetInternalFileName(const wxString
& name
, const wxArrayString
& flist
);
219 void DeleteTempFiles(const wxArrayString
& flist
);
220 void MakePackageZIP(const wxArrayString
& flist
);
221 void MakePackageCPP(const wxArrayString
& flist
);
222 void MakePackagePython(const wxArrayString
& flist
);
224 void OutputGettext();
225 wxArrayString
FindStrings();
226 wxArrayString
FindStrings(wxXmlNode
*node
);
228 bool flagVerbose
, flagCPP
, flagPython
, flagGettext
;
229 wxString parOutput
, parFuncname
, parOutputPath
;
230 wxArrayString parFiles
;
233 ArrayOfXRCWndClassData aXRCWndClassData
;
238 IMPLEMENT_APP_CONSOLE(XmlResApp
)
240 int XmlResApp::OnRun()
242 static const wxCmdLineEntryDesc cmdLineDesc
[] =
244 { wxCMD_LINE_SWITCH
, _T("h"), _T("help"), _T("show help message"),
245 wxCMD_LINE_VAL_NONE
, wxCMD_LINE_OPTION_HELP
},
246 { wxCMD_LINE_SWITCH
, _T("v"), _T("verbose"), _T("be verbose"), (wxCmdLineParamType
)0, 0 },
247 { wxCMD_LINE_SWITCH
, _T("e"), _T("extra-cpp-code"), _T("output C++ header file with XRC derived classes"), (wxCmdLineParamType
)0, 0 },
248 { wxCMD_LINE_SWITCH
, _T("c"), _T("cpp-code"), _T("output C++ source rather than .rsc file"), (wxCmdLineParamType
)0, 0 },
249 { wxCMD_LINE_SWITCH
, _T("p"), _T("python-code"), _T("output wxPython source rather than .rsc file"), (wxCmdLineParamType
)0, 0 },
250 { wxCMD_LINE_SWITCH
, _T("g"), _T("gettext"), _T("output list of translatable strings (to stdout or file if -o used)"), (wxCmdLineParamType
)0, 0 },
251 { wxCMD_LINE_OPTION
, _T("n"), _T("function"), _T("C++/Python function name (with -c or -p) [InitXmlResource]"), (wxCmdLineParamType
)0, 0 },
252 { wxCMD_LINE_OPTION
, _T("o"), _T("output"), _T("output file [resource.xrs/cpp]"), (wxCmdLineParamType
)0, 0 },
253 #if 0 // not yet implemented
254 { wxCMD_LINE_OPTION
, _T("l"), _T("list-of-handlers"), _T("output list of necessary handlers to this file"), (wxCmdLineParamType
)0, 0 },
256 { wxCMD_LINE_PARAM
, NULL
, NULL
, _T("input file(s)"),
257 wxCMD_LINE_VAL_STRING
,
258 wxCMD_LINE_PARAM_MULTIPLE
| wxCMD_LINE_OPTION_MANDATORY
},
263 wxCmdLineParser
parser(cmdLineDesc
, argc
, argv
);
265 switch (parser
.Parse())
285 void XmlResApp::ParseParams(const wxCmdLineParser
& cmdline
)
287 flagGettext
= cmdline
.Found(_T("g"));
288 flagVerbose
= cmdline
.Found(_T("v"));
289 flagCPP
= cmdline
.Found(_T("c"));
290 flagPython
= cmdline
.Found(_T("p"));
291 flagH
= flagCPP
&& cmdline
.Found(_T("e"));
294 if (!cmdline
.Found(_T("o"), &parOutput
))
297 parOutput
= wxEmptyString
;
301 parOutput
= _T("resource.cpp");
303 parOutput
= _T("resource.py");
305 parOutput
= _T("resource.xrs");
308 if (!parOutput
.empty())
310 wxFileName
fn(parOutput
);
312 parOutput
= fn
.GetFullPath();
313 parOutputPath
= wxPathOnly(parOutput
);
315 if (!parOutputPath
) parOutputPath
= _T(".");
317 if (!cmdline
.Found(_T("n"), &parFuncname
))
318 parFuncname
= _T("InitXmlResource");
320 for (size_t i
= 0; i
< cmdline
.GetParamCount(); i
++)
323 wxString fn
=wxFindFirstFile(cmdline
.GetParam(i
), wxFILE
);
330 parFiles
.Add(cmdline
.GetParam(i
));
338 void XmlResApp::CompileRes()
340 wxArrayString files
= PrepareTempFiles();
342 wxRemoveFile(parOutput
);
347 MakePackageCPP(files
);
352 MakePackagePython(files
);
354 MakePackageZIP(files
);
357 DeleteTempFiles(files
);
361 wxString
XmlResApp::GetInternalFileName(const wxString
& name
, const wxArrayString
& flist
)
363 wxString name2
= name
;
364 name2
.Replace(_T(":"), _T("_"));
365 name2
.Replace(_T("/"), _T("_"));
366 name2
.Replace(_T("\\"), _T("_"));
367 name2
.Replace(_T("*"), _T("_"));
368 name2
.Replace(_T("?"), _T("_"));
370 wxString s
= wxFileNameFromPath(parOutput
) + _T("$") + name2
;
372 if (wxFileExists(s
) && flist
.Index(s
) == wxNOT_FOUND
)
374 for (int i
= 0;; i
++)
376 s
.Printf(wxFileNameFromPath(parOutput
) + _T("$%03i-") + name2
, i
);
377 if (!wxFileExists(s
) || flist
.Index(s
) != wxNOT_FOUND
)
384 wxArrayString
XmlResApp::PrepareTempFiles()
388 for (size_t i
= 0; i
< parFiles
.GetCount(); i
++)
391 wxPrintf(_T("processing ") + parFiles
[i
] + _T("...\n"));
395 if (!doc
.Load(parFiles
[i
]))
397 wxLogError(_T("Error parsing file ") + parFiles
[i
]);
402 wxString name
, ext
, path
;
403 wxSplitPath(parFiles
[i
], &path
, &name
, &ext
);
405 FindFilesInXML(doc
.GetRoot(), flist
, path
);
408 wxXmlNode
* node
= (doc
.GetRoot())->GetChildren();
409 wxString classValue
,nameValue
;
411 if(node
->GetName() == _T("object")
412 && node
->GetAttribute(_T("class"),&classValue
)
413 && node
->GetAttribute(_T("name"),&nameValue
)){
415 aXRCWndClassData
.Add(
416 XRCWndClassData(nameValue
,classValue
,node
)
419 node
= node
-> GetNext();
422 wxString internalName
= GetInternalFileName(parFiles
[i
], flist
);
424 doc
.Save(parOutputPath
+ wxFILE_SEP_PATH
+ internalName
);
425 flist
.Add(internalName
);
432 // Does 'node' contain filename information at all?
433 static bool NodeContainsFilename(wxXmlNode
*node
)
435 const wxString name
= node
->GetName();
437 // Any bitmaps (bitmap2 is used for disabled toolbar buttons):
438 if ( name
== _T("bitmap") || name
== _T("bitmap2") )
441 if ( name
== _T("icon") )
445 wxXmlNode
*parent
= node
->GetParent();
446 if (parent
!= NULL
&&
447 parent
->GetAttribute(_T("class"), _T("")) == _T("wxBitmapButton") &&
448 (name
== _T("focus") ||
449 name
== _T("disabled") ||
450 name
== _T("hover") ||
451 name
== _T("selected")))
454 // wxBitmap or wxIcon toplevel resources:
455 if ( name
== _T("object") )
457 wxString klass
= node
->GetAttribute(_T("class"), wxEmptyString
);
458 if (klass
== _T("wxBitmap") ||
459 klass
== _T("wxIcon") ||
460 klass
== _T("data") )
464 // URLs in wxHtmlWindow:
465 if ( name
== _T("url") &&
467 parent
->GetAttribute(_T("class"), _T("")) == _T("wxHtmlWindow") )
469 // FIXME: this is wrong for e.g. http:// URLs
476 // find all files mentioned in structure, e.g. <bitmap>filename</bitmap>
477 void XmlResApp::FindFilesInXML(wxXmlNode
*node
, wxArrayString
& flist
, const wxString
& inputPath
)
479 // Is 'node' XML node element?
480 if (node
== NULL
) return;
481 if (node
->GetType() != wxXML_ELEMENT_NODE
) return;
483 bool containsFilename
= NodeContainsFilename(node
);
485 wxXmlNode
*n
= node
->GetChildren();
488 if (containsFilename
&&
489 (n
->GetType() == wxXML_TEXT_NODE
||
490 n
->GetType() == wxXML_CDATA_SECTION_NODE
))
493 if (wxIsAbsolutePath(n
->GetContent()) || inputPath
.empty())
494 fullname
= n
->GetContent();
496 fullname
= inputPath
+ wxFILE_SEP_PATH
+ n
->GetContent();
499 wxPrintf(_T("adding ") + fullname
+ _T("...\n"));
501 wxString filename
= GetInternalFileName(n
->GetContent(), flist
);
502 n
->SetContent(filename
);
504 if (flist
.Index(filename
) == wxNOT_FOUND
)
507 wxFileInputStream
sin(fullname
);
508 wxFileOutputStream
sout(parOutputPath
+ wxFILE_SEP_PATH
+ filename
);
509 sin
.Read(sout
); // copy the stream
513 if (n
->GetType() == wxXML_ELEMENT_NODE
)
514 FindFilesInXML(n
, flist
, inputPath
);
522 void XmlResApp::DeleteTempFiles(const wxArrayString
& flist
)
524 for (size_t i
= 0; i
< flist
.GetCount(); i
++)
525 wxRemoveFile(parOutputPath
+ wxFILE_SEP_PATH
+ flist
[i
]);
530 void XmlResApp::MakePackageZIP(const wxArrayString
& flist
)
534 for (size_t i
= 0; i
< flist
.GetCount(); i
++)
535 files
+= flist
[i
] + _T(" ");
539 wxPrintf(_T("compressing ") + parOutput
+ _T("...\n"));
541 wxString cwd
= wxGetCwd();
542 wxSetWorkingDirectory(parOutputPath
);
543 int execres
= wxExecute(_T("zip -9 -j ") +
544 wxString(flagVerbose
? _T("\"") : _T("-q \"")) +
545 parOutput
+ _T("\" ") + files
, true);
546 wxSetWorkingDirectory(cwd
);
549 wxLogError(_T("Unable to execute zip program. Make sure it is in the path."));
550 wxLogError(_T("You can download it at http://www.cdrom.com/pub/infozip/"));
558 static wxString
FileToCppArray(wxString filename
, int num
)
563 wxFFile
file(filename
, wxT("rb"));
564 wxFileOffset offset
= file
.Length();
565 wxASSERT_MSG( offset
>= 0 , wxT("Invalid file length") );
567 const size_t lng
= wx_truncate_cast(size_t, offset
);
568 wxASSERT_MSG( lng
== offset
, wxT("Huge file not supported") );
570 snum
.Printf(_T("%i"), num
);
571 output
.Printf(_T("static size_t xml_res_size_") + snum
+ _T(" = %i;\n"), lng
);
572 output
+= _T("static unsigned char xml_res_file_") + snum
+ _T("[] = {\n");
573 // we cannot use string literals because MSVC is dumb wannabe compiler
574 // with arbitrary limitation to 2048 strings :(
576 unsigned char *buffer
= new unsigned char[lng
];
577 file
.Read(buffer
, lng
);
579 for (size_t i
= 0, linelng
= 0; i
< lng
; i
++)
581 tmp
.Printf(_T("%i"), buffer
[i
]);
582 if (i
!= 0) output
<< _T(',');
589 linelng
+= tmp
.Length()+1;
594 output
+= _T("};\n\n");
600 void XmlResApp::MakePackageCPP(const wxArrayString
& flist
)
602 wxFFile
file(parOutput
, wxT("wt"));
606 wxPrintf(_T("creating C++ source file ") + parOutput
+ _T("...\n"));
610 "// This file was automatically generated by wxrc, do not edit by hand.\n"
612 "#include <wx/wxprec.h>\n"
614 "#ifdef __BORLANDC__\n"
619 "#include <wx/filesys.h>\n"
620 "#include <wx/fs_mem.h>\n"
621 "#include <wx/xrc/xmlres.h>\n"
622 "#include <wx/xrc/xh_all.h>\n"
624 "#if wxCHECK_VERSION(2,8,5) && wxABI_VERSION >= 20805\n"
625 " #define XRC_ADD_FILE(name, data, size, mime) \\\n"
626 " wxMemoryFSHandler::AddFileWithMimeType(name, data, size, mime)\n"
628 " #define XRC_ADD_FILE(name, data, size, mime) \\\n"
629 " wxMemoryFSHandler::AddFile(name, data, size)\n"
633 for (i
= 0; i
< flist
.GetCount(); i
++)
635 FileToCppArray(parOutputPath
+ wxFILE_SEP_PATH
+ flist
[i
], i
));
638 "void " + parFuncname
+ "()\n"
641 " // Check for memory FS. If not present, load the handler:\n"
643 " wxMemoryFSHandler::AddFile(wxT(\"XRC_resource/dummy_file\"), wxT(\"dummy one\"));\n"
644 " wxFileSystem fsys;\n"
645 " wxFSFile *f = fsys.OpenFile(wxT(\"memory:XRC_resource/dummy_file\"));\n"
646 " wxMemoryFSHandler::RemoveFile(wxT(\"XRC_resource/dummy_file\"));\n"
647 " if (f) delete f;\n"
648 " else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n"
652 for (i
= 0; i
< flist
.GetCount(); i
++)
657 wxString ext
= wxFileName(flist
[i
]).GetExt();
658 if ( ext
.Lower() == _T("xrc") )
659 mime
= _T("text/xml");
662 wxFileType
*ft
= wxTheMimeTypesManager
->GetFileTypeFromExtension(ext
);
664 ft
->GetMimeType(&mime
);
667 s
.Printf(" XRC_ADD_FILE(wxT(\"XRC_resource/" + flist
[i
] +
668 "\"), xml_res_file_%i, xml_res_size_%i, _T(\"%s\"));\n",
673 for (i
= 0; i
< parFiles
.GetCount(); i
++)
675 file
.Write(" wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/" +
676 GetInternalFileName(parFiles
[i
], flist
) + "\"));\n");
684 void XmlResApp::GenCPPHeader()
686 wxString fileSpec
= ((parOutput
.BeforeLast('.')).AfterLast('/')).AfterLast('\\');
687 wxString heaFileName
= fileSpec
+ _T(".h");
689 wxFFile
file(heaFileName
, wxT("wt"));
692 "// This file was automatically generated by wxrc, do not edit by hand.\n"
694 "#ifndef __" + fileSpec
+ "_h__\n"
695 "#define __" + fileSpec
+ "_h__\n"
697 for(size_t i
=0;i
<aXRCWndClassData
.GetCount();++i
){
698 aXRCWndClassData
.Item(i
).GenerateHeaderCode(file
);
706 static wxString
FileToPythonArray(wxString filename
, int num
)
711 wxFFile
file(filename
, wxT("rb"));
712 wxFileOffset offset
= file
.Length();
713 wxASSERT_MSG( offset
>= 0 , wxT("Invalid file length") );
715 const size_t lng
= wx_truncate_cast(size_t, offset
);
716 wxASSERT_MSG( offset
== lng
, wxT("Huge file not supported") );
718 snum
.Printf(_T("%i"), num
);
719 output
= " xml_res_file_" + snum
+ " = '''\\\n";
721 unsigned char *buffer
= new unsigned char[lng
];
722 file
.Read(buffer
, lng
);
724 for (size_t i
= 0, linelng
= 0; i
< lng
; i
++)
726 unsigned char c
= buffer
[i
];
732 else if (c
< 32 || c
> 127 || c
== '\'')
733 tmp
.Printf(_T("\\x%02x"), c
);
741 output
<< _T("\\\n");
744 linelng
+= tmp
.Length();
749 output
+= _T("'''\n\n");
755 void XmlResApp::MakePackagePython(const wxArrayString
& flist
)
757 wxFFile
file(parOutput
, wxT("wt"));
761 wxPrintf(_T("creating Python source file ") + parOutput
+ _T("...\n"));
765 "# This file was automatically generated by wxrc, do not edit by hand.\n"
772 file
.Write("def " + parFuncname
+ "():\n");
774 for (i
= 0; i
< flist
.GetCount(); i
++)
776 FileToPythonArray(parOutputPath
+ wxFILE_SEP_PATH
+ flist
[i
], i
));
779 " # check if the memory filesystem handler has been loaded yet, and load it if not\n"
780 " wx.MemoryFSHandler.AddFile('XRC_resource/dummy_file', 'dummy value')\n"
781 " fsys = wx.FileSystem()\n"
782 " f = fsys.OpenFile('memory:XRC_resource/dummy_file')\n"
783 " wx.MemoryFSHandler.RemoveFile('XRC_resource/dummy_file')\n"
784 " if f is not None:\n"
787 " wx.FileSystem.AddHandler(wx.MemoryFSHandler())\n"
789 " # load all the strings as memory files and load into XmlRes\n"
793 for (i
= 0; i
< flist
.GetCount(); i
++)
796 s
.Printf(" wx.MemoryFSHandler.AddFile('XRC_resource/" + flist
[i
] +
797 "', xml_res_file_%i)\n", i
);
800 for (i
= 0; i
< parFiles
.GetCount(); i
++)
802 file
.Write(" wx.xrc.XmlResource.Get().Load('memory:XRC_resource/" +
803 GetInternalFileName(parFiles
[i
], flist
) + "')\n");
811 void XmlResApp::OutputGettext()
813 wxArrayString str
= FindStrings();
816 if (parOutput
.empty())
819 fout
.Open(parOutput
, wxT("wt"));
821 for (size_t i
= 0; i
< str
.GetCount(); i
++)
822 fout
.Write("_(\"" + str
[i
] + "\");\n");
824 if (!parOutput
) fout
.Detach();
829 wxArrayString
XmlResApp::FindStrings()
831 wxArrayString arr
, a2
;
833 for (size_t i
= 0; i
< parFiles
.GetCount(); i
++)
836 wxPrintf(_T("processing ") + parFiles
[i
] + _T("...\n"));
839 if (!doc
.Load(parFiles
[i
]))
841 wxLogError(_T("Error parsing file ") + parFiles
[i
]);
845 a2
= FindStrings(doc
.GetRoot());
846 WX_APPEND_ARRAY(arr
, a2
);
854 static wxString
ConvertText(const wxString
& str
)
859 for (dt
= str
.c_str(); *dt
; dt
++)
863 if ( *(++dt
) == wxT('_') )
866 str2
<< wxT('&') << *dt
;
872 case wxT('\n') : str2
<< wxT("\\n"); break;
873 case wxT('\t') : str2
<< wxT("\\t"); break;
874 case wxT('\r') : str2
<< wxT("\\r"); break;
875 case wxT('\\') : if ((*(dt
+1) != 'n') &&
882 case wxT('"') : str2
<< wxT("\\\""); break;
883 default : str2
<< *dt
; break;
892 wxArrayString
XmlResApp::FindStrings(wxXmlNode
*node
)
897 if (n
== NULL
) return arr
;
898 n
= n
->GetChildren();
902 if ((node
->GetType() == wxXML_ELEMENT_NODE
) &&
903 // parent is an element, i.e. has subnodes...
904 (n
->GetType() == wxXML_TEXT_NODE
||
905 n
->GetType() == wxXML_CDATA_SECTION_NODE
) &&
906 // ...it is textnode...
908 node
/*not n!*/->GetName() == _T("label") ||
909 (node
/*not n!*/->GetName() == _T("value") &&
910 !n
->GetContent().IsNumber()) ||
911 node
/*not n!*/->GetName() == _T("help") ||
912 node
/*not n!*/->GetName() == _T("longhelp") ||
913 node
/*not n!*/->GetName() == _T("tooltip") ||
914 node
/*not n!*/->GetName() == _T("htmlcode") ||
915 node
/*not n!*/->GetName() == _T("title") ||
916 node
/*not n!*/->GetName() == _T("item")
918 // ...and known to contain translatable string
921 node
->GetAttribute(_T("translate"), _T("1")) != _T("0"))
923 arr
.Add(ConvertText(n
->GetContent()));
928 if (n
->GetType() == wxXML_ELEMENT_NODE
)
930 wxArrayString a2
= FindStrings(n
);
931 WX_APPEND_ARRAY(arr
, a2
);