Ejemplo n.º 1
0
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;
}
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);
}
Ejemplo n.º 3
0
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";
}
Ejemplo n.º 4
0
//----------------------------------------------------------------------------
// OnViewYaxis performs Menu-View-YAxis command
//----------------------------------------------------------------------------
void CippsDemoApp::OnViewYaxis() 
{
   m_YAxis = !m_YAxis;
   MY_POSITION pos = GetFirstDocPosition();
   while (pos)
      GetNextIppsDoc(pos)->UpdateYAxis();
}
Ejemplo n.º 5
0
void CDocTemplate::CloseAllDocuments(BOOL)
{
	POSITION pos = GetFirstDocPosition();
	while (pos != NULL)
	{
		CDocument* pDoc = GetNextDoc(pos);
		pDoc->OnCloseDocument();
	}
}
Ejemplo n.º 6
0
void CDocTemplate::AssertValid() const
{
	CCmdTarget::AssertValid();

	POSITION pos = GetFirstDocPosition();
	while (pos != NULL)
	{
		CDocument* pDoc = GetNextDoc(pos);
		ASSERT_VALID(pDoc);
	}
}
Ejemplo n.º 7
0
void CDocTemplate::OnIdle()
{
	POSITION pos = GetFirstDocPosition();
	while (pos != NULL)
	{
		CDocument* pDoc = GetNextDoc(pos);
		ASSERT_VALID(pDoc);
		ASSERT_KINDOF(CDocument, pDoc);
		pDoc->OnIdle();
	}
}
Ejemplo n.º 8
0
BOOL CDocTemplate::SaveAllModified()
{
	POSITION pos = GetFirstDocPosition();
	while (pos != NULL)
	{
		CDocument* pDoc = GetNextDoc(pos);
		if (!pDoc->SaveModified())
			return FALSE;
	}
	return TRUE;
}
Ejemplo n.º 9
0
//----------------------------------------------------------------------------
// OnZoomAll performs Menu-Zoom-ZoomAllAsActive command
//----------------------------------------------------------------------------
void CippsDemoApp::OnZoomAll() 
{
   CippsDemoDoc* pActiveDoc = ACTIVE_DOC;
   double scaleW = pActiveDoc->FactorW();
   double scaleH = pActiveDoc->FactorH();
   MY_POSITION pos = GetFirstDocPosition();
   while (pos) {
      CippsDemoDoc* pDoc = GetNextIppsDoc(pos);
      if (pDoc == pActiveDoc) continue;
      pDoc->ZoomByFactors(scaleW,scaleH);
   }
}
Ejemplo n.º 10
0
// ********************************
//	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 ) ;	
};
Ejemplo n.º 11
0
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;
}