diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp index 1fb3b4e..298192b 100644 --- a/src/xmlcopyeditor.cpp +++ b/src/xmlcopyeditor.cpp @@ -1053,12 +1053,7 @@ MyFrame::MyFrame ( ( wxWindow * ) commandPanel, wxAuiPaneInfo().Bottom().Hide().Caption ( _T ( "Command" ) ).DestroyOnClose ( false ).Layer ( 3 ) ); - if ( !wxDirExists ( applicationDir ) ) -#ifdef __WXMSW__ - GetStatusBar()->SetStatusText ( _ ( "Cannot open application directory: see Tools, Options..., General" ) ); -#else - GetStatusBar()->SetStatusText ( _ ( "Cannot open application directory: see Edit, Preferences..., General" ) ); -#endif + validatePaths(); // handle command line and, on Windows, MS Word integration handleCommandLineFlag = ( wxTheApp->argc > 1 ) ? true : false; @@ -6224,3 +6219,46 @@ void MyFrame::addToFileQueue ( wxString& fileName ) { fileQueue.push_back ( fileName ); } + +void MyFrame::validatePaths() +{ + bool valid = true; + wxString msg; + + // Warning: Don't put a space between 'CHECK' and '(' +#define CHECK( check, path ) \ + if ( !( check ) ( path ) )\ + {\ + valid = false;\ + msg << _ ( "Invalid path: " ) << path << wxTextFile::GetEOL();\ + } + CHECK ( wxDirExists, ruleSetDir ); + //CHECK ( wxDirExists, filterDir ); + CHECK ( wxDirExists, templateDir ); + //CHECK ( wxDirExists, binDir ); + CHECK ( wxDirExists, helpDir ); + CHECK ( wxDirExists, rngDir ); + //CHECK ( wxDirExists, htmlDir ); + CHECK ( wxDirExists, pngDir ); + //CHECK ( wxDirExists, daisyDir ); + CHECK ( wxFileExists, catalogPath ); + CHECK ( wxFileExists, xslDtdPath ); + CHECK ( wxFileExists, rssDtdPath ); + CHECK ( wxFileExists, xtmDtdPath ); + CHECK ( wxFileExists, lzxDtdPath ); + CHECK ( wxFileExists, xliffDtdPath ); + CHECK ( wxDirExists, aspellDataPath ); + CHECK ( wxDirExists, aspellDictPath ); +#undef CHECK + + if ( valid ) + return; + + msg << wxTextFile::GetEOL() +#ifdef __WXMSW__ + << _ ( "To change application directory, see Tools, Options..., General" ); +#else + << _ ( "To change application directory, see Edit, Preferences..., General" ); +#endif + wxMessageBox ( msg, GetTitle(), wxOK | wxICON_ERROR, this ); +} diff --git a/src/xmlcopyeditor.h b/src/xmlcopyeditor.h index 47ec6b4..a6599c2 100644 --- a/src/xmlcopyeditor.h +++ b/src/xmlcopyeditor.h @@ -527,6 +527,7 @@ class MyFrame : public wxFrame wxString getAuxPath ( const wxString& fileName ); wxMenuBar *getMenuBar(); wxToolBar *getToolBar(); + void validatePaths(); DECLARE_EVENT_TABLE() };