// STATIC // called by CProjectDoc when it is opening // This reads parameters out of the project document. These // params give us the path of the base file (ana document) // the size and placement of the window, the processing goal, etc. CAnaInputDoc * CAnaInputDoc ::loadDocument( LPCTSTR lpszField, SFMFile & f) { CDocTemplate* pT = theApp.getDocTemplate(getRegFileTypeID()); ASSERTX(pT); CParseStream stream(lpszField); CString sPath; stream.getQuotedString(sPath); //if(!theApp.askUserToFindFileIfNotFound(sPath, getRegFileTypeID())) // return NULL; CPathDescriptor path(sPath); if(!path.fileExists()) // don't bother the user (mar 99) { // need to skip the rest of the fields related to this document in the project file CString sMarker, sField; do { f.getField(sMarker, sField); } while (sMarker != END_MARKER()); return NULL; } // jdh I'm not certain what this does, but it appears that it will just set // the member variable m_strPathName, so that whent the panels are displayed, // we then go and load up that file into the first panel. CAnaInputDoc * pDoc = (CAnaInputDoc *)pT->OpenDocumentFile(sPath); ASSERTX(pDoc->IsKindOf(RUNTIME_CLASS(CAnaInputDoc ))); pDoc->readParams(f); pDoc->SetTitle(getFullFileName(pDoc->GetPathName())); return pDoc; }
void g_OpenPic(const ResourceBlob *pData) { // Get the document template, so we can create a new CPicDoc. CDocTemplate *pDocTemplate = theApp.GetPicTemplate(); if (pDocTemplate) { // and create the PicResource for it. CPicDoc *pDocument = (CPicDoc*)pDocTemplate->OpenDocumentFile(NULL, TRUE); if (pDocument) { PicResource *pepic = new PicResource(); if (pepic) { HRESULT hr = pepic->InitFromResource(pData); if (FAILED(hr)) { delete pepic; } else { pDocument->SetEditPic(pepic, pData->GetId()); } } } } }
bool CMainFrame::MakeWave(const WAVEGEN_PARMS& Parms) { POSITION pos = theApp.GetFirstDocTemplatePosition(); CDocTemplate *pTpl = theApp.GetNextDocTemplate(pos); CWaveShopDoc *pDoc = DYNAMIC_DOWNCAST(CWaveShopDoc, pTpl->CreateNewDocument()); if (pDoc == NULL) return(FALSE); bool retc, canceled; { CProgressDlg ProgDlg; if (!ProgDlg.Create()) // create progress dialog AfxThrowResourceException(); ProgDlg.SetWindowText(LDS(IDS_MAIN_GENERATING_AUDIO)); retc = CWaveGenDlg::MakeWave(Parms, pDoc->m_Wave, &ProgDlg); canceled = ProgDlg.Canceled(); } // destroy progress dialog if (!retc) { // if generation failed if (!canceled) // if user canceled AfxMessageBox(IDS_MAIN_CANT_MAKE_WAVE); return(FALSE); } CDocument *pEmptyDoc = pTpl->OpenDocumentFile(NULL); // create new view if (pEmptyDoc == NULL || m_View == NULL) return(FALSE); CString title = pEmptyDoc->GetTitle(); pEmptyDoc->RemoveView(m_View); // remove empty document from view pDoc->SetTitle(title); // copy empty document's title to generated document pDoc->AddView(m_View); // add generated document to view m_View->OnInitialUpdate(); OnActivateView(m_View); // view is still linked to empty document's undo manager; must relink m_View->SetUndoManager(&pDoc->m_UndoMgr); // link view to undo manager pDoc->m_UndoMgr.SetRoot(m_View); // link undo manager to view return(TRUE); }
CDocument *CDocManager::OpenDocumentFile( LPCTSTR lpszFileName ) /**************************************************************/ { POSITION position = m_templateList.GetHeadPosition(); CDocTemplate *pSelected = NULL; CDocTemplate::Confidence nSelConfidence = CDocTemplate::noAttempt; while( position != NULL ) { CDocTemplate *pTemplate = (CDocTemplate *)m_templateList.GetNext( position ); ASSERT( pTemplate != NULL ); CDocument *pMatch = NULL; CDocTemplate::Confidence nConfidence = pTemplate->MatchDocType( lpszFileName, pMatch ); if( nConfidence > nSelConfidence ) { nSelConfidence = nConfidence; pSelected = pTemplate; if( nConfidence == CDocTemplate::yesAlreadyOpen ) { ASSERT( pMatch != NULL ); POSITION viewPos = pMatch->GetFirstViewPosition(); if( viewPos != NULL ) { CView *pView = pMatch->GetNextView( viewPos ); CFrameWnd *pFrame = pView->GetParentFrame(); ASSERT( pFrame != NULL ); pFrame->ActivateFrame(); } return( pMatch ); } } } if( pSelected == NULL ) { return( NULL ); } return( pSelected->OpenDocumentFile( lpszFileName ) ); }
//---------------------------------------------------------------------------- // OpenNewDoc opens new user customized document. // If newView == VIEW_DEMO then document will be created with signal default // parameters and will be shown in graphic view; // if newView == NEW_TEXT then document will be created with digital default // parameters and will be shown in digital view // if newView == VIEW_CHAR then document will be created with character default // parameters and will be shown in character view //---------------------------------------------------------------------------- void CippsDemoApp::OpenNewDoc(int newView) { POSITION tPos = GetFirstDocTemplatePosition( ); CDocTemplate* pTpl; for (int i=0; i<=newView; i++) pTpl = GetNextDocTemplate(tPos); ASSERT(pTpl); CippsDemoDoc* pDoc = (CippsDemoDoc*)pTpl->OpenDocumentFile(NULL); if (pDoc) pDoc->InitHisto(); }
CUSBLogDoc *CSnoopyProApp::CreateNewDocument(void) { ASSERT(NULL != m_pDocManager); POSITION pos = m_pDocManager->GetFirstDocTemplatePosition(); CDocTemplate* pTemplate = (CDocTemplate*)m_pDocManager->GetNextDocTemplate(pos); ASSERT(pTemplate != NULL); ASSERT_KINDOF(CDocTemplate, pTemplate); CUSBLogDoc *pDocument = (CUSBLogDoc *) pTemplate->OpenDocumentFile(NULL); ASSERT(NULL != pDocument); ASSERT_KINDOF(CUSBLogDoc, pDocument); return pDocument; }
CSampleDoc* CIppsSampleApp::CreateNewDoc(int len, ppType type, BOOL bMakeVisible) { int lenSave = m_NewLen; ppType typeSave = m_NewType; m_NewLen = len; m_NewType = type; POSITION pos = GetFirstDocTemplatePosition(); CDocTemplate* pTpl = GetNextDocTemplate(pos); CSampleDoc* pDoc = (CSampleDoc*)pTpl->OpenDocumentFile(NULL,bMakeVisible); m_NewLen = lenSave; m_NewType = typeSave; return pDoc; }
// NOTE: This is *NOT* called when the user opens a document explicity; only when starting up and reopening docs // which the user left open last time. CSourceTextInputDoc* CSourceTextInputDoc::loadDocument( LPCTSTR lpszField, SFMFile & f) { CDocTemplate* pT = theApp.getDocTemplate(getRegFileTypeID()); ASSERTX(pT); CParseStream stream(lpszField); CString sPath; stream.getQuotedString(sPath); CPathDescriptor path(sPath); if(!path.fileExists()) // don't bother the user (mar 99) //if(!theApp.askUserToFindFileIfNotFound(sPath, getRegFileTypeID())) { // need to skip the rest of the fields related to this document in the project file CString sMarker, sField; do { f.getField(sMarker, sField); } while (sMarker != END_MARKER()); return NULL; } // jdh I'm not certain what this does, but it appears that it will just set // the member variable m_strPathName, so that whent the panels are displayed, // we then go and load up that file into the first panel. CSourceTextInputDoc* pDoc = (CSourceTextInputDoc*)pT->OpenDocumentFile(sPath); if(pDoc) //jdh 2/9/00 Added check for NULL doc, which will crop up when there was something like a sharing violation. { ASSERTX(pDoc->IsKindOf(RUNTIME_CLASS(CSourceTextInputDoc))); pDoc->readParams(f); // jdh 12April2001 check the readonly flag of the file pDoc->SetBaseReadOnly(FILE_ATTRIBUTE_READONLY & ::GetFileAttributes(pDoc->GetPathName())); /*the above sets the title, too*/ } else //jdh 2/9/00 Added handler for when we get a NULL doc { // need to skip the rest of the fields related to this document in the project file CString sMarker, sField; do { f.getField(sMarker, sField); } while (sMarker != END_MARKER()); } return pDoc; }
void CDocManager::OnFileNew() /***************************/ { POSITION position = GetFirstDocTemplatePosition(); if( position != NULL ) { CDocTemplate *pTemplate = GetNextDocTemplate( position ); ASSERT( pTemplate != NULL ); if( position == NULL ) { pTemplate->OpenDocumentFile( NULL ); } else { CFileNewDialog dlg( this ); if( dlg.DoModal() == IDOK ) { ASSERT( dlg.m_pDocTemplate != NULL ); dlg.m_pDocTemplate->OpenDocumentFile( NULL ); } } } }
void CBMPFrame::Duplicate(OUT CBMPFrame** frame, OUT CBMPView** view, OUT CBMPDoc** document) { // 기존 CBMPDoc을 가져옴 CBMPDoc *pSrcDoc = GetActiveDocument(); ASSERT_VALID(pSrcDoc); if (!pSrcDoc) return; // 신규 BMP 문서 (CBMPDoc) 생성 CDocTemplate *pTml = pSrcDoc->GetDocTemplate(); pTml->OpenDocumentFile(NULL); // 기존 CBMPDoc으로부터 복제 *frame = (CBMPFrame*)((CMainFrame*)AfxGetMainWnd())->GetActiveFrame(); *view = (CBMPView*)(*frame)->GetActiveView(); *document = (*view)->GetDocument(); (*document)->copyFrom(pSrcDoc); }
CDocument *CPythonWinApp::OpenDocumentFile(LPCTSTR lpszFileName) { #if 0 // win32s no longer supported ver.dwOSVersionInfoSize = sizeof(ver); GetVersionEx(&ver); ver.dwOSVersionInfoSize = sizeof(ver); GetVersionEx(&ver); if (ver.dwPlatformId == VER_PLATFORM_WIN32s) { OutputDebugString("Win32s - Searching templates!\n"); POSITION posTempl = m_pDocManager->GetFirstDocTemplatePosition(); CDocTemplate* pTemplate = m_pDocManager->GetNextDocTemplate(posTempl); if (pTemplate) return pTemplate->OpenDocumentFile(lpszFileName); else { AfxMessageBox("win32s error - There is no template to use"); return NULL; } } else #endif return CWinApp::OpenDocumentFile(lpszFileName); }
CDocument* CMyDocManager::OpenDocumentFile(LPCTSTR lpszFileName) { // From MFC: CDocManager::OpenDocumentFile CString strFileName = lpszFileName; strFileName.TrimLeft(); strFileName.TrimRight(); if (strFileName[0] == '\"') strFileName.Delete(0); int nPos = strFileName.ReverseFind('\"'); if (nPos != -1) strFileName.Delete(nPos); CString strQuery, strPage; nPos = strFileName.Find('?'); if (nPos != -1) { strQuery = strFileName.Mid(nPos + 1); strFileName = strFileName.Left(nPos); } bool bPathTooLong = false; TCHAR szPath[_MAX_PATH]; if (!AfxFullPath(szPath, strFileName)) bPathTooLong = true; if (bPathTooLong || !PathFileExists(szPath)) { // Try extracting page number nPos = strFileName.ReverseFind('#'); if (nPos != -1) { strPage = strFileName.Mid(nPos + 1); strFileName = strFileName.Left(nPos); if (!AfxFullPath(szPath, strFileName)) bPathTooLong = true; } } if (bPathTooLong) { AfxMessageBox(FormatString(IDS_PATH_TOO_LONG, szPath), MB_ICONEXCLAMATION | MB_OK); return NULL; } TCHAR szLinkName[_MAX_PATH]; if (AfxResolveShortcut(GetMainWnd(), szPath, szLinkName, _MAX_PATH)) lstrcpy(szPath, szLinkName); // find the highest confidence CDocTemplate::Confidence bestMatch = CDocTemplate::noAttempt; CDocTemplate* pBestTemplate = NULL; CDocument* pOpenDocument = NULL; CMainFrame* pOldMainFrm = (CMainFrame*) theApp.m_pMainWnd; POSITION pos = m_templateList.GetHeadPosition(); while (pos != NULL) { CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos); ASSERT_KINDOF(CDocTemplate, pTemplate); CDocTemplate::Confidence match; ASSERT(pOpenDocument == NULL); match = pTemplate->MatchDocType(szPath, pOpenDocument); if (match > bestMatch) { bestMatch = match; pBestTemplate = pTemplate; } if (match == CDocTemplate::yesAlreadyOpen) break; } if (pOpenDocument != NULL) { POSITION pos = pOpenDocument->GetFirstViewPosition(); if (pos != NULL) { CView* pView = pOpenDocument->GetNextView(pos); ASSERT_VALID(pView); CMainFrame* pMainFrm = (CMainFrame*) pView->GetTopLevelFrame(); pMainFrm->ActivateDocument(pOpenDocument); } else TRACE(_T("Error: Can not find a view for document to activate.\n")); } if (pOpenDocument == NULL) { if (pBestTemplate == NULL) { AfxMessageBox(AFX_IDP_FAILED_TO_OPEN_DOC); return NULL; } pOpenDocument = pBestTemplate->OpenDocumentFile(szPath); } if (pOpenDocument != NULL) { CDjVuDoc* pDoc = (CDjVuDoc*) pOpenDocument; CDjVuView* pView = pDoc->GetDjVuView(); CMainFrame* pMainFrm = pView->GetMainFrame(); // CDocManager::OnDDECommand shows the previous main window. // If it was in the fullscreen mode, hide it back. if (pOldMainFrm != NULL && pOldMainFrm != pMainFrm && pOldMainFrm->IsFullscreenMode()) pOldMainFrm->ShowWindow(SW_HIDE); if (!strPage.IsEmpty()) pView->GoToURL(MakeUTF8String(_T("#") + strPage)); } return pOpenDocument; }