// ZoomViewDoc.cpp : implementation of the CZoomViewDoc class // #include "stdafx.h" #include "ZoomView.h" #include "ZoomViewDoc.h" #include "ZoomViewView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // 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() { // TODO: add one-time construction code here } CZoomViewDoc::~CZoomViewDoc() { } BOOL CZoomViewDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; POSITION pos = GetFirstViewPosition(); CZoomViewView* pView = (CZoomViewView * ) GetNextView(pos); if(pView) { pView->m_LBitmapWnd.CopyFromClipboard(pView->m_hWnd); pView->m_LBitmapWnd.GetContainerObject().SetUserMode(ANNUSER_RUN); } SetTitle(TEXT("Paste")); 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 #define ISTIF(nFormat) \ ((nFormat) == FILE_JTIF || \ (nFormat) == FILE_LEAD2JTIF || \ (nFormat) == FILE_LEAD1JTIF || \ (nFormat) == FILE_TIFLZW || \ (nFormat) == FILE_TIFLZW_CMYK || \ (nFormat) == FILE_TIFLZW_YCC || \ (nFormat) == FILE_TIF || \ (nFormat) == FILE_TIF_CMYK || \ (nFormat) == FILE_TIF_YCC || \ (nFormat) == FILE_TIF_PACKBITS || \ (nFormat) == FILE_TIF_PACKBITS_CMYK ||\ (nFormat) == FILE_TIF_PACKBITS_YCC || \ (nFormat) == FILE_CCITT || \ (nFormat) == FILE_CCITT_GROUP3_1DIM ||\ (nFormat) == FILE_CCITT_GROUP3_2DIM ||\ (nFormat) == FILE_CCITT_GROUP4) void CZoomViewDoc::GetAnnFile(LAnnotationWindow *pAnnWindow, LPTSTR pDest, LPTSTR pSource, L_UINT nPage, L_INT nFormat) { LPTSTR p; L_UINT16 uType; L_UINT32 uCount; LOADFILEOPTION LoadFileOption; LFile CSrc(pAnnWindow, pSource); LBaseFile::GetDefaultLoadFileOption(&LoadFileOption, sizeof(LoadFileOption)); LoadFileOption.PageNumber = nPage; if( nFormat < 0 && CSrc.ReadTag(ANNTAG_TIFF, &uType, &uCount, NULL, &LoadFileOption) > 0 || ISTIF(nFormat) ) // the file has annotation data! lstrcpy(pDest, pSource); else { // else look for a .ANN file lstrcpy(pDest, pSource); p = _tcsrchr(pDest, '.'); if(!p) p = _tcsrchr(pDest, '\0'); lstrcpy(p, _T(".ann")); } } ///////////////////////////////////////////////////////////////////////////// // CZoomViewDoc commands BOOL CZoomViewDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; CZoomViewApp* pApp=(CZoomViewApp*)AfxGetApp(); // TODO: Add your specialized creation code here POSITION pos = GetFirstViewPosition(); if((pos)&&(pApp)) { FILEINFO fInfo; CZoomViewView * pView = (CZoomViewView *) GetNextView(pos); if(pView==NULL) return FALSE; pView->m_LBitmapWnd.SetFileName((LPTSTR)lpszPathName); LOADFILEOPTION LoadFileOption; LBaseFile::GetDefaultLoadFileOption(&LoadFileOption,sizeof(LoadFileOption)); LoadFileOption.PageNumber = pApp->m_nPageNumber; pView->m_LBitmapWnd.File()->GetInfo(&fInfo,sizeof(fInfo), 0, &LoadFileOption); if(pView->m_LBitmapWnd.Load( fInfo.BitsPerPixel, ORDER_BGRORGRAY, &LoadFileOption)!=SUCCESS) return FALSE; { TCHAR szAnnFile[_MAX_PATH]; GetAnnFile(&pView->m_LBitmapWnd, szAnnFile, (LPTSTR)lpszPathName, 1, -1); pView->m_LBitmapWnd.AnnLoad(szAnnFile, &LoadFileOption); pView->m_LBitmapWnd.GetContainerObject().SetUserMode(ANNUSER_RUN); } } return TRUE; }