void CWordPadApp::OnFileNew() { int nDocType = -1; if (!m_bPromptForType) { if (cmdInfo.m_bForceTextMode) nDocType = RD_TEXT; else if (!cmdInfo.m_strFileName.IsEmpty()) { CFileException fe; nDocType = GetDocTypeFromName(cmdInfo.m_strFileName, fe); } if (nDocType == -1) nDocType = RD_DEFAULT; } else { CFileNewDialog dlg; if (dlg.DoModal() == IDCANCEL) return; nDocType = (dlg.m_nSel == 0) ? RD_DEFAULT: //Word 6 (dlg.m_nSel == 1) ? RD_RICHTEXT : //RTF RD_TEXT ; //text if (nDocType != RD_TEXT) cmdInfo.m_bForceTextMode = FALSE; } m_nNewDocType = nDocType; DocTemplate.OpenDocumentFile(NULL); // if returns NULL, the user has already been alerted }
BOOL CWordPadDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (m_lpRootStg != NULL) // we are embedded { // we really want to use the converter on this storage m_nNewDocType = RD_EMBEDDED; } else { if (theApp.cmdInfo.m_bForceTextMode) m_nNewDocType = RD_TEXT; else { CFileException fe; m_nNewDocType = GetDocTypeFromName(lpszPathName, fe); if (m_nNewDocType == -1) { ReportSaveLoadException(lpszPathName, &fe, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC); return FALSE; } if (m_nNewDocType == RD_TEXT && theApp.m_bForceOEM) m_nNewDocType = RD_OEMTEXT; } ScanForConverters(); if (!doctypes[m_nNewDocType].bRead) { CString str; CString strName = doctypes[m_nNewDocType].GetString(DOCTYPE_DOCTYPE); AfxFormatString1(str, IDS_CANT_LOAD, strName); AfxMessageBox(str, MB_OK|MB_ICONINFORMATION); return FALSE; } } // SetDocType(nNewDocType); if (!CRichEditDoc::OnOpenDocument(lpszPathName)) return FALSE; return TRUE; }