NS_IMETHODIMP 
nsPrintingPromptService::ShowPageSetup(mozIDOMWindowProxy *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
{
  nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
                                           NS_PRINTDIALOGSERVICE_CONTRACTID));
  if (dlgPrint) {
    return dlgPrint->ShowPageSetup(nsPIDOMWindowOuter::From(parent), printSettings);
  }

  return NS_ERROR_FAILURE;
}
/* void showPageSetup (in nsIDOMWindow parent, in nsIPrintSettings printSettings); */
NS_IMETHODIMP 
nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
{
    NS_ENSURE_ARG(printSettings);

    // Try to access a component dialog
    nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
                                             NS_PRINTDIALOGSERVICE_CONTRACTID));
    if (dlgPrint)
      return dlgPrint->ShowPageSetup(parent, printSettings);

    ParamBlock block;
    nsresult rv = block.Init();
    if (NS_FAILED(rv))
      return rv;

    block->SetInt(0, 0);
    return DoDialog(parent, block, nullptr, printSettings, kPageSetupDialogURL);
}
/* void showPrintDialog (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings); */
NS_IMETHODIMP 
nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
{
    NS_ENSURE_ARG(webBrowserPrint);
    NS_ENSURE_ARG(printSettings);

    // Try to access a component dialog
    nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
                                             NS_PRINTDIALOGSERVICE_CONTRACTID));
    if (dlgPrint)
      return dlgPrint->Show(parent, printSettings, webBrowserPrint);

    // Show the built-in dialog instead
    ParamBlock block;
    nsresult rv = block.Init();
    if (NS_FAILED(rv))
      return rv;

    block->SetInt(0, 0);
    return DoDialog(parent, block, webBrowserPrint, printSettings, kPrintDialogURL);
}
Beispiel #4
0
void CPadView::OnChoosePrintFont()
{
	CWaitCursor wait;
	CFont* pFont = GetPrinterFont();
	LOGFONT lf;
	LPLOGFONT plf = NULL;
	if (pFont != NULL)
	{
		pFont->GetObject(sizeof(LOGFONT), &lf);
		plf = &lf;
	}

	// magic to get printer dialog that would be used if we were printing!
	CPrintDialog dlgPrint(FALSE);
	if (!AfxGetApp()->GetPrinterDeviceDefaults(&dlgPrint.m_pd))
	{
		AfxMessageBox(IDP_ERR_GET_DEVICE_DEFAULTS);
		return;
	}
	wait.Restore();
	HDC hdcPrint = dlgPrint.CreatePrinterDC();
	if (hdcPrint == NULL)
	{
		AfxMessageBox(IDP_ERR_GET_PRINTER_DC);
		return;
	}

	CDC dcScreen;
	dcScreen.Attach(::GetDC(NULL));
	CDC dcPrint;
	dcPrint.Attach(hdcPrint);

	if (plf != NULL)
	{
		// need to map initial logfont to screen metrics.
		::ScaleLogFont(plf, dcPrint, dcScreen);
	}

	// now bring up the dialog since we know the printer DC
	CFontDialog dlg(plf, CF_PRINTERFONTS, &dcPrint);
	if (dlg.DoModal() == IDOK)
	{
		// map the resulting logfont back to printer metrics.
		lf = dlg.m_lf;
		::ScaleLogFont(&lf, dcScreen, dcPrint);

		SetPrinterFont(NULL);
		m_fontPrint.DeleteObject();
		if (m_fontPrint.CreateFontIndirect(&lf))
		{
			SetPrinterFont(&m_fontPrint);
			m_lfDefPrintFont = lf;

			// notify container that content has changed
			GetDocument()->UpdateAllItems(NULL);
		}
	}
	//NOTE: destructor will call dcPrint.DeleteDC

	::ReleaseDC(NULL, dcScreen.Detach());
}
Beispiel #5
0
bool PrintManager::ShowPrintRevisionReportDialog(SAFEARRAY** ReportSelection, std::vector<CStdString>& VecElements, LONG_PTR& lPrinterHandle)
{
	lPrinterHandle = 0;
	BOOL bShowDialog = TRUE; 
	_bstr_t bstrOutputFilePathName = _T("");
	LONG lCopies = 1; 
	BOOL bCollate= FALSE;

	StrTerField tFields;
	GetTerFields(this->m_hWnd, &tFields);
	int iTotalPages = tFields.TotalPagesW;

	// show print dialog
	CWSPrintRevisionReportDlg dlgPrint(VecElements, FALSE);

	if(!bShowDialog)
	{
		dlgPrint.GetDefaults();
	}

	dlgPrint.BlackAndWhite(Workshare::OptionApi::GetBool(L"PrintBWOnly"));
	dlgPrint.m_pd.nCopies = (WORD)lCopies;

	if(bCollate)
	{
		dlgPrint.m_pd.Flags |= PD_COLLATE;
	}

	INT_PTR iDlgResponse = IDOK;

	if(bShowDialog)
	{
		iDlgResponse = dlgPrint.DoModal();
	}

	if(iDlgResponse == IDOK)
	{	
		if(CreateSelectedResponsesSafeArray(dlgPrint.GetSelectedElements(), ReportSelection) == false)
		{
			throw std::exception( " CreateSelectedResponsesSafeArray failed");
		}
		m_NoOfCopies = dlgPrint.GetCopies();
		// inform TER of the current printer selection
		PRINTDLG pdlg=dlgPrint.m_pd;
		if(pdlg.hDevNames) 
		{
			InformTerOfCurrentPrinterSelection(dlgPrint);
		}

		Workshare::OptionApi::SetBool(L"PrintBWOnly", (bool)(dlgPrint.BlackAndWhite()));
	
		SetBlackAndWhitePrinting( Workshare::OptionApi::GetBool(L"PrintBWOnly") );

		HDC hdcPrinterHandle = TerStartPrintJob(m_hWnd, _bstr_t(bstrOutputFilePathName), CStdStringA(dlgPrint.GetDocumentNameToPrint()));
		lPrinterHandle = (long)hdcPrinterHandle;

		// Get the current orientation
		m_SaveOrient = GetOrientation();

		if(pdlg.hDevNames && m_SaveOrient!=m_NewOrient && m_iCurSectOrient!=m_NewOrient)
		{
			TerSetSectOrient(this->m_hWnd, m_iCurSectOrient, TRUE);
		}

		//down to here
	}
	else
	{
		return false;
	}

	return true;
}