+void wxDocManager::OnMRUFile(wxCommandEvent& event)
+{
+ // Check if the id is in the range assigned to MRU list entries.
+ const int id = event.GetId();
+ if ( id >= wxID_FILE1 &&
+ id < wxID_FILE1 + static_cast<int>(m_fileHistory->GetCount()) )
+ {
+ DoOpenMRUFile(id - wxID_FILE1);
+ }
+ else
+ {
+ event.Skip();
+ }
+}
+
+void wxDocManager::DoOpenMRUFile(unsigned n)
+{
+ wxString filename(GetHistoryFile(n));
+ if ( filename.empty() )
+ return;
+
+ wxString errMsg; // must contain exactly one "%s" if non-empty
+ if ( wxFile::Exists(filename) )
+ {
+ // Try to open it but don't give an error if it failed: this could be
+ // normal, e.g. because the user cancelled opening it, and we don't
+ // have any useful information to put in the error message anyhow, so
+ // we assume that in case of an error the appropriate message had been
+ // already logged.
+ (void)CreateDocument(filename, wxDOC_SILENT);
+ }
+ else // file doesn't exist
+ {
+ OnMRUFileNotExist(n, filename);
+ }
+}
+
+void wxDocManager::OnMRUFileNotExist(unsigned n, const wxString& filename)
+{
+ // remove the file which we can't open from the MRU list
+ RemoveFileFromHistory(n);
+
+ // and tell the user about it
+ wxLogError(_("The file '%s' doesn't exist and couldn't be opened.\n"
+ "It has been removed from the most recently used files list."),
+ filename);
+}
+
+#if wxUSE_PRINTING_ARCHITECTURE
+