Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
3da4d517d4063fc9102e4ba721ab8ff1ea6b2a76
[xestiaab/.git] / source / tools / odthelpbrowser / main.cpp
1 #include <wx/wx.h>
2 #include <wx/cmdline.h>
3 #include <wx/fs_mem.h>
5 #include "frmMain.h"
6 #include "odt.h"
7 #include "version.h"
9 class ODTHelpBrowser: public wxApp
10 {
11     virtual bool OnInit();
12 };
14 IMPLEMENT_APP(ODTHelpBrowser);
16 ODT::ODT odtDocument;
18 bool ODTHelpBrowser::OnInit()
19 {
20         // Process the first argument as the filename to read.
21         
22         static const wxCmdLineEntryDesc cmdLineDescription [] =
23         {
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 },
30                 { wxCMD_LINE_NONE }
31         };
32         
33         wxCmdLineParser ODTHelpBrowserArgs (cmdLineDescription, argc, argv);
34         ODTHelpBrowserArgs.Parse();
35         
36         if (ODTHelpBrowserArgs.Found(wxT("h")))
37                 return false;
39         if (ODTHelpBrowserArgs.Found(wxT("v")))
40         {
41                 std::cout << ODTHELPBROWSER_VERSION << std::endl;
42                 return false;
43         }
45         wxString documentFilename;
47         if (!ODTHelpBrowserArgs.Found(wxT("d"), &documentFilename))
48         {
49                 std::cout << "No file for the -d switch was given." << std::endl;
50                 return false;
51         }
53         // Load and process the ODT document.
54         
55         std::string fileToLoad = std::string(documentFilename.mb_str());
56         
57         if (!odtDocument.LoadDocument(fileToLoad))
58         {
59                 std::cout << "Unable to open file " << documentFilename.mb_str() << std::endl;
60                 return false;
61         }
63         // Setup the form and load in the document data.
64         
65         wxFileSystem::AddHandler(new wxMemoryFSHandler);
67         frmMain *frame = new frmMain( NULL, &odtDocument );
68         
69         frame->Show(true);
70         
71         SetTopWindow(frame);
72         
73         return true;
74 }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy