// ZoomViewDoc.cpp : implementation of the CZoomViewDoc class // #include "stdafx.h" #include "ZoomView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CZoomViewApp theApp; extern void ExitMFCApp(); ///////////////////////////////////////////////////////////////////////////// // CZoomViewDoc IMPLEMENT_DYNCREATE(CZoomViewDoc, CDocument) BEGIN_MESSAGE_MAP(CZoomViewDoc, CDocument) //{{AFX_MSG_MAP(CZoomViewDoc) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CZoomViewDoc construction/destruction CZoomViewDoc::CZoomViewDoc() { HRESULT hr; //Create the licensed LTRaster COM object m_pRaster = NULL; hr = theApp.CreateRasterObjectLic(&m_pRaster); if (FAILED(hr)){theApp.DisplayLEADError(ERROR_INV_PARAMETER);ExitMFCApp(); return;} } CZoomViewDoc::~CZoomViewDoc() { m_pRaster->Release(); } BOOL CZoomViewDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; switch(theApp.m_nOpenMode) { case OPENMODE_PASTE: { SetTitle(TEXT("Clipboard Data")); return OnOpenPaste(); } } return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CZoomViewDoc serialization void CZoomViewDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CZoomViewDoc diagnostics #ifdef _DEBUG void CZoomViewDoc::AssertValid() const { CDocument::AssertValid(); } void CZoomViewDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG BOOL CZoomViewDoc::OnOpenPaste() { m_pRaster->Paste(PASTE_DOPASTE); return(TRUE); } ///////////////////////////////////////////////////////////////////////////// // CZoomViewDoc commands BOOL CZoomViewDoc::OnOpenDocument(LPCTSTR lpszPathName) { int nRet; if (theApp.m_pRasterIO->ReadTag(lpszPathName, theApp.m_iPage, ANN_TAG_TIFF) == 0) { memcpy(m_strAnnFile , lpszPathName, lstrlen(lpszPathName)); } else { GetAnnName (lpszPathName, m_strAnnFile); } if(lpszPathName) { UNLOCKSUPPORT(*m_pRaster); if(((CMainFrame*)theApp.m_pMainWnd)->m_pRaster->GetBitmap()) { m_pRaster->put_RefBitmap(TRUE); m_pRaster->put_Bitmap(((CMainFrame*)theApp.m_pMainWnd)->m_pRaster->GetBitmap()); m_pRaster->put_RefBitmap(FALSE); nRet = m_pRaster->GetBitmap()?0:ERROR_NO_BITMAP; } else { nRet = theApp.m_pRasterIO->Load(m_pRaster, lpszPathName, 0, theApp.m_iPage, 1); } theApp.m_iPage = 1; if(nRet) { theApp.DisplayLEADError(nRet); return(FALSE); } theApp.m_pRasterIO->GetFileInfo(m_pRaster, lpszPathName, theApp.m_iPage, 0); return(TRUE); } return(FALSE); } void CZoomViewDoc::GetAnnName(LPCTSTR szFilename, LPTSTR szAnnName) { LPTSTR lp; #ifdef _UNICODE if( (lp = wcsrchr(szFilename,'.')) == NULL ) #else if( (lp = strrchr(szFilename,'.')) == NULL ) #endif { lstrcpy(szAnnName,szFilename); lstrcat(szAnnName,TEXT(".ann")); } else { memcpy(szAnnName,szFilename,(lp-szFilename)*sizeof(TCHAR)); lstrcpy(szAnnName+(lp-szFilename),TEXT(".ann")); } }