2 #include <wx/cmdline.h>
9 class ODTHelpBrowser: public wxApp
11 virtual bool OnInit();
14 IMPLEMENT_APP(ODTHelpBrowser);
18 bool ODTHelpBrowser::OnInit()
20 // Process the first argument as the filename to read.
22 static const wxCmdLineEntryDesc cmdLineDescription [] =
24 { wxCMD_LINE_SWITCH, "h", "help", "Displays help on command line parameters",
25 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
26 { wxCMD_LINE_OPTION, "d", "document", "Flat ODT document to open to display help contacts",
27 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
28 { wxCMD_LINE_SWITCH, "v", "version", "Displays version number",
29 wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
33 wxCmdLineParser ODTHelpBrowserArgs (cmdLineDescription, argc, argv);
34 ODTHelpBrowserArgs.Parse();
36 if (ODTHelpBrowserArgs.Found(wxT("h")))
39 if (ODTHelpBrowserArgs.Found(wxT("v")))
41 std::cout << ODTHELPBROWSER_VERSION << std::endl;
45 wxString documentFilename;
47 if (!ODTHelpBrowserArgs.Found(wxT("d"), &documentFilename))
49 std::cout << "No file for the -d switch was given." << std::endl;
53 // Load and process the ODT document.
55 std::string fileToLoad = std::string(documentFilename.mb_str());
57 if (!odtDocument.LoadDocument(fileToLoad))
59 std::cout << "Unable to open file " << documentFilename.mb_str() << std::endl;
63 // Setup the form and load in the document data.
65 wxFileSystem::AddHandler(new wxMemoryFSHandler);
67 frmMain *frame = new frmMain( NULL, &odtDocument );