#include #include #include #include "frmMain.h" #include "odt.h" #include "version.h" class ODTHelpBrowser: public wxApp { virtual bool OnInit(); }; IMPLEMENT_APP(ODTHelpBrowser); ODT::ODT odtDocument; bool ODTHelpBrowser::OnInit() { // Process the first argument as the filename to read. static const wxCmdLineEntryDesc cmdLineDescription [] = { { wxCMD_LINE_SWITCH, "h", "help", "Displays help on command line parameters", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_OPTION, "d", "document", "Flat ODT document to open to display help contacts", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, "v", "version", "Displays version number", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE } }; wxCmdLineParser ODTHelpBrowserArgs (cmdLineDescription, argc, argv); ODTHelpBrowserArgs.Parse(); if (ODTHelpBrowserArgs.Found(wxT("h"))) return false; if (ODTHelpBrowserArgs.Found(wxT("v"))) { std::cout << ODTHELPBROWSER_VERSION << std::endl; return false; } wxString documentFilename; if (!ODTHelpBrowserArgs.Found(wxT("d"), &documentFilename)) { std::cout << "No file for the -d switch was given." << std::endl; return false; } // Load and process the ODT document. std::string fileToLoad = std::string(documentFilename.mb_str()); if (!odtDocument.LoadDocument(fileToLoad)) { std::cout << "Unable to open file " << documentFilename.mb_str() << std::endl; return false; } // Setup the form and load in the document data. wxFileSystem::AddHandler(new wxMemoryFSHandler); frmMain *frame = new frmMain( NULL, &odtDocument ); frame->Show(true); SetTopWindow(frame); return true; }