void CDocTemplate::Dump(CDumpContext& dc) const { CCmdTarget::Dump(dc); dc << "m_nIDResource = " << m_nIDResource; dc << "\nm_strDocStrings: " << m_strDocStrings; if (m_pDocClass) dc << "\nm_pDocClass = " << m_pDocClass->m_lpszClassName; else dc << "\nm_pDocClass = NULL"; if (dc.GetDepth() > 0) { dc << "\ndocument list = {"; POSITION pos = GetFirstDocPosition(); while (pos != NULL) { CDocument* pDoc = GetNextDoc(pos); dc << "\ndocument " << pDoc; } dc << "\n}"; } dc << "\n"; }
bool CGenEdDocTemplate::SaveAll (bool bAskBeforeSave) { POSITION pPosition; pPosition = GetFirstDocPosition (); while (pPosition != NULL) { CGenEdDoc *pDoc; pDoc = dynamic_cast<CGenEdDoc *> (GetNextDoc (pPosition)); assert (pDoc != NULL); if (pDoc == NULL) { continue; } pDoc->EnableParsing(FALSE); if (!pDoc->SaveIfModified (bAskBeforeSave)) { pDoc->EnableParsing(TRUE); return (false); } pDoc->EnableParsing(TRUE); } return (true); }
CDocTemplate::Confidence CDocTemplate::MatchDocType(LPCTSTR lpszPathName, CDocument*& rpDocMatch) { ASSERT(lpszPathName != NULL); rpDocMatch = NULL; // go through all documents POSITION pos = GetFirstDocPosition(); while (pos != NULL) { CDocument* pDoc = GetNextDoc(pos); if (AfxComparePath(pDoc->GetPathName(), lpszPathName)) { // already open rpDocMatch = pDoc; return yesAlreadyOpen; } } // see if it matches our default suffix CString strFilterExt; if (GetDocString(strFilterExt, CDocTemplate::filterExt) && !strFilterExt.IsEmpty()) { // see if extension matches ASSERT(strFilterExt[0] == '.'); LPCTSTR lpszDot = _tcsrchr(lpszPathName, '.'); if (lpszDot != NULL && lstrcmpi(lpszDot, strFilterExt) == 0) return yesAttemptNative; // extension matches, looks like ours } // otherwise we will guess it may work return yesAttemptForeign; }
void CDocTemplate::CloseAllDocuments(BOOL) { POSITION pos = GetFirstDocPosition(); while (pos != NULL) { CDocument* pDoc = GetNextDoc(pos); pDoc->OnCloseDocument(); } }
void CDocTemplate::AssertValid() const { CCmdTarget::AssertValid(); POSITION pos = GetFirstDocPosition(); while (pos != NULL) { CDocument* pDoc = GetNextDoc(pos); ASSERT_VALID(pDoc); } }
void CDocTemplate::OnIdle() { POSITION pos = GetFirstDocPosition(); while (pos != NULL) { CDocument* pDoc = GetNextDoc(pos); ASSERT_VALID(pDoc); ASSERT_KINDOF(CDocument, pDoc); pDoc->OnIdle(); } }
BOOL CDocTemplate::SaveAllModified() { POSITION pos = GetFirstDocPosition(); while (pos != NULL) { CDocument* pDoc = GetNextDoc(pos); if (!pDoc->SaveModified()) return FALSE; } return TRUE; }
// ******************************** // CDocTemplate // ******************************** CDocument* CHidemdiDoctmplDocstrAlone::OpenDocumentFile( LPCTSTR lpszPathName , BOOL bMakeVisible ) //【オーバライド】 // lpszPathName と同じDocStr()を持つドキュメントが存在していたら、 // 新たなドキュメントを開かずに、既存のドキュメントをアクティブに、 // して、そのオブジェクトポインタを返します { CDocument* pRv = NULL ; POSITION LPosition = GetFirstDocPosition() ; while( LPosition != NULL && pRv == NULL ){ CDocument* pLDocument = GetNextDoc( LPosition ) ; ASSERT( pLDocument->IsKindOf( RUNTIME_CLASS( CHidemdiSubDoc ) ) ) ; //[Attention] // このクラスが扱うドキュメントは、CHidemdiSubDocを継承して // いなくてはなりません CHidemdiSubDoc* pLSubDoc = (CHidemdiSubDoc*)pLDocument ; if ( lpszPathName == NULL ){ lpszPathName = _T("" ) ; } if ( pLSubDoc->DocStr() == lpszPathName ){ // 同じDocStr()の子フレームが見つかりました POSITION LViewPosition = pLSubDoc->GetFirstViewPosition() ; while ( LViewPosition != NULL ){ CView* pLView = pLSubDoc->GetNextView( LViewPosition ) ; ( (CMDIFrameWnd*)AfxGetMainWnd() )->MDIActivate( pLView->GetParent() ) ; break ; } //[Attention] // 同名のビュー(のMDI子フレーム)をアクティブにしています pRv = pLSubDoc ; } } //pRv = 同名のビューがすでにあれば、そのビュー、なければNULLです if ( pRv == NULL ){ pRv = super::OpenDocumentFile( lpszPathName , bMakeVisible ) ; } return ( pRv ) ; };
CDocument* CSaxBasicDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName, BOOL bMakeVisible) { POSITION pos = GetFirstDocPosition(); CDocument* pDoc; if (pos == NULL) { pDoc = CMultiDocTemplate::OpenDocumentFile(NULL); if (lpszPathName == NULL) return pDoc; } else pDoc = GetNextDoc(pos); if (lpszPathName == NULL) pDoc->OnNewDocument(); else pDoc->OnOpenDocument(lpszPathName); return pDoc; }