Printing of selected frameset frames and Iframes

Bug 66783 r=dcone sr=buster,attinasi
This commit is contained in:
rods%netscape.com 2006-02-07 01:12:27 +00:00
parent 5a699cf2bf
commit 509a230fa9
4 changed files with 45 additions and 26 deletions

View File

@ -78,6 +78,10 @@ interface nsIPrintOptions : nsISupports
const short kSelectedFrame = 1;
const short kEachFrameSep = 2;
const short kFrameEnableNone = 0;
const short kFrameEnableAll = 1;
const short kFrameEnableAsIsAndEach = 2;
/**
* Show Native Print Options dialog, this may not be supported on all platforms
*/
@ -125,7 +129,7 @@ interface nsIPrintOptions : nsISupports
attribute wstring title;
attribute wstring docURL;
attribute boolean isPrintFrame;
attribute short howToEnableFrameUI;
attribute short printFrameType;
/* Additional XP Related */

View File

@ -53,6 +53,10 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: Init(void)
return NS_OK;
}
//--------------------------------------------------------
//--------------------------------------------------------
static UINT gFrameSelectedRadioBtn = NULL;
//--------------------------------------------------------
static void SetRadio(HWND aParent,
UINT aId,
@ -71,33 +75,45 @@ static void SetRadio(HWND aParent,
::SendMessage(wnd, BM_SETCHECK, (WPARAM)aIsSet, (LPARAM)0);
}
//--------------------------------------------------------
static UINT gFrameSelectedRadioBtn = NULL;
//--------------------------------------------------------
UINT CALLBACK PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
if (uiMsg == WM_COMMAND) {
gFrameSelectedRadioBtn = LOWORD(wParam);
UINT id = LOWORD(wParam);
if (id == rad4 || id == rad5 || id == rad6) {
gFrameSelectedRadioBtn = id;
}
} else if (uiMsg == WM_INITDIALOG) {
PRINTDLG * printDlg = (PRINTDLG *)lParam;
PRBool doingFrames = (PRBool)printDlg->lCustData;
HWND collateChk = GetDlgItem (hdlg, chx2);
PRINTDLG * printDlg = (PRINTDLG *)lParam;
PRInt16 howToEnableFrameUI = (PRBool)printDlg->lCustData;
HWND collateChk = GetDlgItem (hdlg, chx2);
if (collateChk) {
::ShowWindow(collateChk, SW_SHOW);
}
if (!doingFrames) {
if (howToEnableFrameUI == nsIPrintOptions::kFrameEnableAll) {
SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE); // XXX this is just temporary (should be enabled)
SetRadio(hdlg, rad5, PR_TRUE);
SetRadio(hdlg, rad6, PR_FALSE);
// set default so user doesn't have to actually press on it
gFrameSelectedRadioBtn = rad5;
} else if (howToEnableFrameUI == nsIPrintOptions::kFrameEnableAsIsAndEach) {
SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE); // XXX this is just temporary (should be enabled)
SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE);
SetRadio(hdlg, rad6, PR_TRUE);
// set default so user doesn't have to actually press on it
gFrameSelectedRadioBtn = rad6;
} else { // nsIPrintOptions::kFrameEnableNone
// we are using this function to disabe the group box
SetRadio(hdlg, grp3, PR_FALSE, PR_FALSE);
// now disable radiobuttons
SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE);
SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE);
SetRadio(hdlg, rad6, PR_FALSE, PR_FALSE);
} else {
SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE); // XXX this is just temporary
SetRadio(hdlg, rad5, PR_TRUE);
SetRadio(hdlg, rad6, PR_FALSE);
}
}
return 0L;
@ -115,6 +131,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget
NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);
PRINTDLG prntdlg;
memset(&prntdlg, 0, sizeof(PRINTDLG));
HWND hWnd = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW);
HINSTANCE hInstance = (HINSTANCE)::GetWindowLong(hWnd, GWL_HINSTANCE);
@ -128,14 +145,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget
PD_ENABLEPRINTTEMPLATE | PD_ENABLEPRINTHOOK | PD_USEDEVMODECOPIESANDCOLLATE;
// if there is a current selection then enable the "Selection" radio button
PRBool isPrintFrames = PR_FALSE;
PRInt16 howToEnableFrameUI = nsIPrintOptions::kFrameEnableNone;
if (printService) {
PRBool isOn;
printService->GetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectionRB, &isOn);
if (!isOn) {
prntdlg.Flags |= PD_NOSELECTION;
}
printService->GetIsPrintFrame(&isPrintFrames);
printService->GetHowToEnableFrameUI(&howToEnableFrameUI);
}
prntdlg.nFromPage = 1;
@ -144,7 +161,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget
prntdlg.nMaxPage = 1000;
prntdlg.nCopies = 1;
prntdlg.hInstance = hInstance;
prntdlg.lCustData = (DWORD)isPrintFrames;
prntdlg.lCustData = (DWORD)howToEnableFrameUI;
prntdlg.lpfnPrintHook = PrintHookProc;
prntdlg.lpfnSetupHook = NULL;
prntdlg.lpPrintTemplateName = (LPCTSTR)"PRINTDLGNEW";
@ -175,7 +192,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget
#endif
// fill the print options with the info from the dialog
if(printService) {
if (printService) {
if (prntdlg.Flags & PD_SELECTION) {
printService->SetPrintRange(nsIPrintOptions::kRangeSelection);
@ -200,8 +217,6 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget
case rad6:
printService->SetPrintFrameType(nsIPrintOptions::kEachFrameSep);
break;
default:
printService->SetIsPrintFrame(PR_FALSE);
} // switch
}

View File

@ -103,7 +103,7 @@ nsPrintOptions::nsPrintOptions() :
mPaperSize(kLetterPaperSize),
mPrintToFile(PR_FALSE),
mPrintFrameType(kSelectedFrame),
mIsPrintFrame(PR_FALSE),
mHowToEnableFrameUI(kFrameEnableNone),
mPageNumJust(kJustLeft)
{
NS_INIT_ISUPPORTS();
@ -535,15 +535,15 @@ NS_IMETHODIMP nsPrintOptions::SetDocURL(const PRUnichar * aDocURL)
}
/* attribute boolean isPrintFrame; */
NS_IMETHODIMP nsPrintOptions::GetIsPrintFrame(PRBool *aIsPrintFrame)
NS_IMETHODIMP nsPrintOptions::GetHowToEnableFrameUI(PRInt16 *aHowToEnableFrameUI)
{
NS_ENSURE_ARG_POINTER(aIsPrintFrame);
*aIsPrintFrame = (PRInt32)mIsPrintFrame;
NS_ENSURE_ARG_POINTER(aHowToEnableFrameUI);
*aHowToEnableFrameUI = (PRInt32)mHowToEnableFrameUI;
return NS_OK;
}
NS_IMETHODIMP nsPrintOptions::SetIsPrintFrame(PRBool aIsPrintFrame)
NS_IMETHODIMP nsPrintOptions::SetHowToEnableFrameUI(PRInt16 aHowToEnableFrameUI)
{
mIsPrintFrame = aIsPrintFrame;
mHowToEnableFrameUI = aHowToEnableFrameUI;
return NS_OK;
}

View File

@ -61,7 +61,7 @@ protected:
PRInt16 mPageNumJust;
PRInt16 mPrintFrameType;
PRBool mIsPrintFrame;
PRBool mHowToEnableFrameUI;
nsFont* mDefaultFont;
nsString mTitle;