+ wxView *view = (wxView *)node->GetData();
+ view->OnClosingDocument();
+ node = node->GetNext();
+ }
+}
+
+void wxDocument::SetFilename(const wxString& filename, bool notifyViews)
+{
+ m_documentFile = filename;
+ if ( notifyViews )
+ {
+ // Notify the views that the filename has changed
+ wxList::compatibility_iterator node = m_documentViews.GetFirst();
+ while (node)
+ {
+ wxView *view = (wxView *)node->GetData();
+ view->OnChangeFilename();
+ node = node->GetNext();
+ }
+ }
+}
+
+bool wxDocument::DoSaveDocument(const wxString& file)
+{
+ wxString msgTitle;
+ if (!wxTheApp->GetAppDisplayName().empty())
+ msgTitle = wxTheApp->GetAppDisplayName();
+ else
+ msgTitle = wxString(_("File error"));
+
+#if wxUSE_STD_IOSTREAM
+ wxSTD ofstream store(file.mb_str(), wxSTD ios::binary);
+ if (store.fail() || store.bad())
+#else
+ wxFileOutputStream store(file);
+ if (store.GetLastError() != wxSTREAM_NO_ERROR)
+#endif
+ {
+ (void)wxMessageBox(_("Sorry, could not open this file for saving."), msgTitle, wxOK | wxICON_EXCLAMATION,
+ GetDocumentWindow());
+ // Saving error
+ return false;
+ }
+ if (!SaveObject(store))
+ {
+ (void)wxMessageBox(_("Sorry, could not save this file."), msgTitle, wxOK | wxICON_EXCLAMATION,
+ GetDocumentWindow());
+ // Saving error
+ return false;
+ }
+
+ return true;
+}
+
+bool wxDocument::DoOpenDocument(const wxString& file)
+{
+#if wxUSE_STD_IOSTREAM
+ wxSTD ifstream store(file.mb_str(), wxSTD ios::binary);
+ if (!store.fail() && !store.bad())
+#else
+ wxFileInputStream store(file);
+ if (store.GetLastError() == wxSTREAM_NO_ERROR)
+#endif
+ {
+#if wxUSE_STD_IOSTREAM
+ LoadObject(store);
+ if ( !!store || store.eof() )
+#else
+ int res = LoadObject(store).GetLastError();
+ if ( res == wxSTREAM_NO_ERROR || res == wxSTREAM_EOF )
+#endif
+ return true;