// PDFCompDemoDoc.cpp : implementation of the CPDFCompDemoDoc class // #include "stdafx.h" #include "PDFCompDemo.h" #include "PDFCompDemoDoc.h" #include "PDFCompDemoView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern L_VOID PDFCompError(HWND hwnd, L_INT nCode, L_TCHAR* pTitle, L_TCHAR* pFilename); ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc IMPLEMENT_DYNCREATE(CPDFCompDemoDoc, CDocument) BEGIN_MESSAGE_MAP(CPDFCompDemoDoc, CDocument) //{{AFX_MSG_MAP(CPDFCompDemoDoc) // 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() ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc construction/destruction CPDFCompDemoDoc::CPDFCompDemoDoc() { // TODO: add one-time construction code here memset(&m_PDFCompSettings, 0, sizeof(m_PDFCompSettings)); m_PDFCompSettings.m_n1Bit = 5; m_PDFCompSettings.m_n2Bit = 0; m_PDFCompSettings.m_nPict = 5; m_PDFCompSettings.m_bCheckBackground= FALSE; m_PDFCompSettings.m_nSeg = 1; m_PDFCompSettings.m_nQFactor = 50; m_PDFCompSettings.nPageNumber = -1; } CPDFCompDemoDoc::~CPDFCompDemoDoc() { } BOOL CPDFCompDemoDoc::OnNewDocument() { static int i=0; if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) if(i>=1) return TRUE; else { i++; return FALSE; } } ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc serialization void CPDFCompDemoDoc::Serialize(CArchive& ar) { CFile* pf; pf = ar.GetFile(); if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc diagnostics #ifdef _DEBUG void CPDFCompDemoDoc::AssertValid() const { CDocument::AssertValid(); } void CPDFCompDemoDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoDoc commands BOOL CPDFCompDemoDoc::OnOpenDocument(LPCTSTR lpszPathName) { L_INT nRet; if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; // TODO: Add your specialized creation code here OPENDLGPARAMS OPENParams; FILEINFO fInfo; POSITION pos; CPDFCompDemoApp* pApp = (CPDFCompDemoApp* )AfxGetApp(); pos = GetFirstViewPosition(); CPDFCompDemoView* pView = (CPDFCompDemoView*)GetNextView(pos); memset(&OPENParams,0,sizeof(OPENParams)); memset(&fInfo,0,sizeof(fInfo)); if((pApp==NULL) /*|| (pView==NULL)*/) return TRUE ; pApp->m_LDlgFile.GetOpenParams(&OPENParams, sizeof(OPENParams)); m_LeadBitmap.SetFileName((L_TCHAR L_FAR * )lpszPathName); m_LeadBitmap.File()->GetInfo(&fInfo, sizeof(FILEINFO)); if(OPENParams.pFileData != NULL) nRet = m_LeadBitmap.Load(fInfo.BitsPerPixel,ORDER_BGRORGRAY, OPENParams.pFileData[0].nPageNumber); else nRet = m_LeadBitmap.Load(fInfo.BitsPerPixel,ORDER_BGRORGRAY,1); if(nRet != SUCCESS) { if(nRet == ERROR_PDF_BAD_INITIALIZATION_FILES) { if( IDYES == MessageBox ( pView->m_hWnd,TEXT("LEADTOOLS PDF plugin is not found, do you want to download the plugin now?"), TEXT("Open File"),MB_ICONEXCLAMATION | MB_YESNO)) { ShellExecute(pView->m_hWnd, TEXT("open"), TEXT("http://www.leadtools.com/ReleaseDownloads/v14/LEADTOOLSPDFRuntime.exe"), NULL, NULL, SW_SHOWNORMAL); } } else PDFCompError(AfxGetApp()->m_pMainWnd->m_hWnd, nRet, TEXT("PDFComp Demo"), TEXT("")); return FALSE; } return TRUE; } void CPDFCompDemoDoc::OnCloseDocument() { // TODO: Add your specialized code here and/or call the base class if( m_LeadBitmap.IsAllocated() ) m_LeadBitmap.Free(); CDocument::OnCloseDocument(); }