void CPmwView::DoFileSaveAsGraphic() { BOOL fRet = FALSE; CPmwDoc *pDoc = GetDocument (); CString Filter; Filter.LoadString (IDS_SAVE_AS_GRAPHIC_FILT); // this array must match the order in the above string! SaveGraphicType graphicTypes[] = { None, Pmo, Bmp8, Bmp24, Jpeg, Png, Gif, Pcx, Tiff, WMeta }; CString InitialDir = pDoc->GetPathManager()->ExpandPath("[[P]]"); CString defExt = "*.pmo"; // This must match the first selection in the filter string CFileSaveAsGraphicDlg fileDlg(pDoc->something_selected(), Filter, defExt, InitialDir, this); PBOX WorldAll, WorldSel; pDoc->get_panel_world (&WorldAll, pDoc->get_current_panel()); if (pDoc->GetSelectBound (&WorldSel) != TRUE) WorldSel = WorldAll; CDC *pDC = GetDC(); if (!pDC) { return; // just bail... } int LogPixX = pDC->GetDeviceCaps (LOGPIXELSX); int LogPixY = pDC->GetDeviceCaps (LOGPIXELSY); fileDlg.SetDimensions(&WorldAll, &WorldSel, LogPixX, LogPixY); ReleaseDC (pDC); if (fileDlg.DoModal () == IDOK) { CString Filename = fileDlg.GetPathName (); CPoint cpDims; cpDims.x = fileDlg.m_Width; cpDims.y = fileDlg.m_Height; enum SaveGraphicType gt; gt = graphicTypes[fileDlg.GetGraphicTypeIndex ()]; ASSERT ((gt > None) && (gt < Invalid)); BOOL fSelected = fileDlg.IsSaveSelected(); ERRORCODE error = ERRORCODE_Memory; if (gt == Pmo) { // save as "PrintMaster Objects" file error = SavePMObjectsToFile(Filename, pDoc, fSelected); } else { CDibToGraphicFile pDibToGraphicFile(Filename); pDibToGraphicFile.CreateGraphicFile (pDoc, gt, cpDims, fSelected, NULL, LogPixX); error = pDibToGraphicFile.GetErrorCode(); } if (error != ERRORCODE_None) AfxMessageBox (IDS_ERROR_SAVING); else { if (fileDlg.AddToGallery() == TRUE) { CPMWCollection* pCollection = GetGlobalCollectionManager()->GetUserCollection(CPMWCollection::typeArt); if (pCollection != NULL) { int nResult = pCollection->ImportItem(Filename, NULL, NULL, fileDlg.m_strCategory, FALSE); if (nResult != ERRORCODE_None) AfxMessageBox (IDS_ERROR_SAVING); } } } } }
int CLabelView::GrindOutPrintJob(PrintContext& pc) { /* // Print our document(s). */ CLabelPrintDialog* pDialog = (CLabelPrintDialog*)pc.m_pPD; CPmwDoc* pDoc = GetDocument(); pDialog->ComputeTotals(); /* Extract the name list. */ CStdMacroServer* pMacroServer = pDoc->GetMacroServer(); NameListRecord* pNameList = pMacroServer->GetNameList(); BOOL fMergePrint = FALSE; int nNames = pNameList->Names(); int nTotalPages = pDialog->m_nTotalPages; int nError = FALSE; BOOL fOldShow = pMacroServer->ShowMacroValues(); StorageFile* pDatabaseFile = NULL; CFlatFileDatabase* pDatabase = NULL; CFlatFileDatabaseCursor* pCursor = NULL; if (GetConfiguration()->SupportsAddressBook(FALSE)) { // get sender values for address book. pMacroServer->BindSender(); } if (!fOldShow) { pMacroServer->ShowMacroValues(TRUE); pDoc->ReflowMacros(); } pc.m_pCursor = NULL; PPNT dims = pDoc->get_dimensions(); pc.m_source.x0 = 0; pc.m_source.y0 = 0; pc.m_source.x1 = dims.x; pc.m_source.y1 = dims.y; /* // Set the printing conditions. */ pc.m_nBoundName = -1; pc.m_nCurrentName = (nNames == 0) ? -1 : 0; pc.m_nCurrentCopy = 0; CString csFullName; TRY { csFullName = pDoc->GetPathManager()->LocatePath(pNameList->AddressBookName()); TRACE("Open database %s for data!\r\n", (LPCSTR)csFullName); if (nNames != 0) { ERRORCODE Error = CAddressBook::OpenAddressBookDatabase(csFullName, pDatabaseFile, pDatabase, FALSE); if (Error != ERRORCODE_None) { ThrowErrorcodeException(Error); } // Create a cursor on the database. pCursor = new CFlatFileDatabaseCursor; pCursor->Attach(pDatabase); pc.m_pCursor = pCursor; } int nFromPage = pc.m_pInfo->GetFromPage(); int nToPage = pc.m_pInfo->GetToPage(); int nError = 0; pc.SaveStartOfBand(); for (;;) { if (pc.m_fDoubleSided && (nFromPage != nToPage)) { // // 1. Put up the dialog telling the user we are about to begin. // CPmwDialog BeginDialog(IDD_DOUBLE_SIDED_BEGIN); if (BeginDialog.DoModal() != IDOK) { nError = -1; break; } // We need to do the double-sided thing. // // 2. Print the first half of the document. // // Print the key sheet now if it goes first. if ((pc.m_wDoubleSidedType & DBLPRN_FRONTKEYMASK) == DBLPRN_FrontKeyFirst) { if ((nError = PrintKeySheetFront(pc)) != 0) { break; } } // Print the document pages. pc.ToStartOfBand(); if ((nError = PrintLabelsFront(pc)) != 0) { break; } // Print the key sheet now if it goes last. if ((pc.m_wDoubleSidedType & DBLPRN_FRONTKEYMASK) == DBLPRN_FrontKeyLast) { if ((nError = PrintKeySheetFront(pc)) != 0) { break; } } // End the first print job. EndPrintDoc(pc, 0); // // 3. Put up the dialog telling the user to re-insert the stack. // CPmwDialog NotifyDialog(IDD_DOUBLE_SIDED_NOTIFY); if (NotifyDialog.DoModal() != IDOK) { nError = -1; break; } // // 4. Print the second half of the document. // // Start up the second print job. if ((nError = StartPrintDoc(pc)) != 0) { break; } // Print the key sheet now if it goes first. if ((pc.m_wDoubleSidedType & DBLPRN_BACKKEYMASK) == DBLPRN_BackKeyFirst) { if ((nError = PrintKeySheetBack(pc)) != 0) { break; } } // Print the document pages. pc.ToStartOfBand(); if ((nError = PrintLabelsBack(pc)) != 0) { break; } // Print the key sheet now if it goes last. if ((pc.m_wDoubleSidedType & DBLPRN_BACKKEYMASK) == DBLPRN_BackKeyLast) { if ((nError = PrintKeySheetBack(pc)) != 0) { break; } } } else { // Not double-sided. See what page(s) to print. // // Here are the cases: // From == 1, To == 1 (Front only) // From == 2, To == 2 (Back only) // From == 1, To == 2 (Both pages) // // So, we print page 1 if "from" is 1, and we print page 2 if "to" is 2. if (nFromPage == 1) { // Print the fronts in forward order. pc.ToStartOfBand(); if ((nError = PrintLabelsForward(pc, 0)) != 0) { break; } } if (nToPage == 2) { // Print the backs in forward order. pc.ToStartOfBand(); if ((nError = PrintLabelsForward(pc, 1)) != 0) { break; } } } // Done. Always leave! break; } } END_TRY BOOL fReflow = !fOldShow; pMacroServer->ShowMacroValues(fOldShow); if (nNames != 0 && pc.m_nCurrentName > 0) { /* Go back to the first name. */ if (pCursor != NULL) { pMacroServer->BindToRecord(pCursor, pNameList->Name(0)); } fReflow = TRUE; } if (fReflow) { pDoc->ReflowMacros(); } delete pCursor; pCursor = NULL; CAddressBook::CloseAddressBookDatabase(pDatabaseFile, pDatabase); return nError; }
void CCardView::OnCardServer() { // Some configurations do not support online greetings ("card server"). if (!GetConfiguration()->SupportsCardServer()) { return; } // Get our document. CPmwDoc* pDoc = GetDocument(); if(GetGlobalContentManager()->CheckAccountStatus()) { CString strID = GetGlobalContentManager()->GetAccountID(); if(strID != "") { // Put up the card server dialog. CCardServerDialog Dialog(this); Dialog.m_ctTime = CTime::GetCurrentTime(); if (Dialog.DoModal() == IDOK) { // Put up the disclaimer dialog. CCardServerDisclaimer Disclaimer(this); if (Disclaimer.DoModal() == IDOK) { // Create the directory we want to use as our FTP source. CString csDir = pDoc->GetPathManager()->ExpandPath("[[U]]\\NETCARD"); if (!Util::MakeDirectory(csDir)) { // Not able to make the directory. // LPCSTR pFormat = "Can't create the directory\n%s"; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateDirectory); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csDir); AfxMessageBox(csMessage); return; } // Construct the text file. CString csTextFile; Util::ConstructPath(csTextFile, csDir, "INFO.INI"); CFile cfText; CString csVersion; CString csPPN; TRY { CFileException e; //if (!cfText.Open(csTextFile, // CFile::modeCreate // | CFile::modeWrite, // &e)) //{ // AfxThrowFileException(e.m_cause, e.m_lOsError); //} //do the time stuff //time zone difference from PST struct _timeb tstruct; _ftime( &tstruct ); int timecorrection = PacificTimeCorrection(tstruct.timezone); //get date of delivery - include current time struct tm when; CString strDate; CTime testtime = CTime::GetCurrentTime(); when = *testtime.GetLocalTm(NULL); SYSTEMTIME sysTime = *Dialog.GetTime(); if((when.tm_mday != sysTime.wDay) || (when.tm_mon != (sysTime.wMonth - 1))) { when.tm_mday = sysTime.wDay; when.tm_mon = sysTime.wMonth - 1; ConvertToPST(&when, timecorrection); CString str_ampm = "AM"; if( when.tm_hour > 12 ) /* Set up extension. */ str_ampm = "PM"; if( when.tm_hour > 12 ) /* Convert from 24-hour */ when.tm_hour -= 12; /* to 12-hour clock. */ if( when.tm_hour == 0 ) /*Set hour to 12 if midnight. */ when.tm_hour = 12; strDate.Format("%d/%d/%d %d:%d:%d%s", (int)((int)when.tm_mon + 1),when.tm_mday,when.tm_year,when.tm_hour,when.tm_min,when.tm_sec,str_ampm); } else { strDate = ""; } CString strPSTCorrection; strPSTCorrection.Format("%d", timecorrection); // Construct the version string. CString csEol = "\r\n"; csVersion = GetConfiguration()->ReplacementText('T'); csVersion += ' '; csVersion += GET_PMWAPP()->GetVersion(); csPPN = GET_PMWAPP()->GetParentPartNumber(); WritePrivateProfileString( "UserData", "UserId", GetGlobalContentManager()->GetAccountID(), csTextFile); WritePrivateProfileString( "UserData", "Description", csVersion, csTextFile); WritePrivateProfileString( "UserData", "SenderEmail", Dialog.m_csFrom, csTextFile); WritePrivateProfileString( "UserData", "RecipientEmail", Dialog.m_csTo, csTextFile); WritePrivateProfileString( "UserData", "sku", csPPN, csTextFile); WritePrivateProfileString( "CardData", "Title", Dialog.m_csTitle, csTextFile); WritePrivateProfileString( "CardData", "Date", strDate, csTextFile); WritePrivateProfileString( "CardData", "Offset", strPSTCorrection, csTextFile); #if 0 // Write version cfText.Write(csVersion, csVersion.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write "from" email address cfText.Write(Dialog.m_csFrom, Dialog.m_csFrom.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write "to" email address cfText.Write(Dialog.m_csTo, Dialog.m_csTo.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write Parent Part Number cfText.Write(csPPN, csPPN.GetLength()); cfText.Write(csEol, csEol.GetLength()); #endif //cfText.Close(); } CATCH_ALL(e) { // Could not write the text file. Complain. // LPCSTR pFormat = "Can't create the file\n%s"; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateFile); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csTextFile); AfxMessageBox(csMessage); return; } END_CATCH_ALL // Figure out how big we want the panels to be. CPoint cpFrontDims; CPoint cpInsideDims; PBOX World; pDoc->get_panel_world(&World, CARD_PANEL_Front); // Fit the front panel into a 425x425 square. PPNT FrontDims; FrontDims.x = World.x1 - World.x0; FrontDims.y = World.y1 - World.y0; double dScale = 425.0/(double)FrontDims.x; double dYScale = 425.0/(double)FrontDims.y; if (dScale > dYScale) dScale = dYScale; cpFrontDims.x = (int)((double)FrontDims.x*dScale); cpFrontDims.y = (int)((double)FrontDims.y*dScale); pDoc->get_panel_world(&World, CARD_PANEL_Inside); cpInsideDims.x = (int)((double)(World.x1-World.x0)*dScale); cpInsideDims.y = (int)((double)(World.y1-World.y0)*dScale); TRACE("Front: %d, %d; Inside: %d, %d\n", cpFrontDims.x, cpFrontDims.y, cpInsideDims.x, cpInsideDims.y); BOOL fSuccess = FALSE; CCardServerProgressDialog ProgressDialog(AfxGetMainWnd()); CString csName; Util::ConstructPath(csName, csDir, "front.gif"); ProgressDialog.SetStatus(IDS_BuildingFront); if (DumpPanel(CARD_PANEL_Front, csName, cpFrontDims)) { ProgressDialog.SetStatus(IDS_BuildingInside); Util::ConstructPath(csName, csDir, "inside.gif"); if(DumpPanel(CARD_PANEL_Inside, csName, cpInsideDims)) fSuccess = TRUE; } if (!fSuccess) { // "Can't create card pictures." AfxMessageBox(GET_PMWAPP()->GetResourceStringPointer(IDS_ErrWriteCardPictures)); return; } // Now, invoke the DLL to write the data. CCardServerDLL DLL; #ifdef WIN32 CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP32.DLL"); #else CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP16.DLL"); #endif // Startup the dialog. if (DLL.Startup(csDLLName)) { if(CheckForValidConnection()){ // Put up our progress dialog. // Send the files. int nResult = DLL.SendFiles(csDir, ProgressDialog); // Take down the progress dialog now. ProgressDialog.DestroyWindow(); // Shut down the DLL. DLL.Shutdown(); CPmwDialog Dialog(nResult == 0 ? IDD_CARD_SERVER_SUCCESS : IDD_CARD_SERVER_FAILURE); Dialog.DoModal(); } } else { // Not able to load the DLL. Complain. // LPCSTR pFormat = "The file\n%s\nis missing or bad."; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrMissingDLL); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csDLLName); AfxMessageBox(csMessage); } }