From 8ffdb92d82c41a8545bcb7230fd11fc6a556806e Mon Sep 17 00:00:00 2001 From: "amardare%qnx.com" Date: Fri, 30 Apr 2004 20:01:40 +0000 Subject: [PATCH] Changes for qnx/photon platform. They should not affect building/runtime other platforms. When printing from the embedded application, allow it to set the print frame, BG colors, BG images in the print settings, according to the preferences. git-svn-id: svn://10.0.0.236/trunk@155769 18797224-902f-48f8-a5cc-f745e15eee43 --- .../gfx/src/photon/nsDeviceContextSpecPh.cpp | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp b/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp index 20f6838f3e9..b3d6f9f5a53 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp @@ -54,6 +54,9 @@ #include "nsString.h" #include "nsIServiceManager.h" #include "nsReadableUtils.h" +#include "nsIPref.h" + +static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); nsDeviceContextSpecPh :: nsDeviceContextSpecPh() { @@ -168,6 +171,48 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(nsIWidget* aWidget, aPS->GetEndPageRange( &p ); PpPrintReleasePC(mPC); mPC = ( PpPrintContext_t *) p; + + /* set the print frame / BG colors and images settings, according to the Pt_ARG_WEB_OPTION setting */ + nsresult res; + nsCOMPtr prefs(do_GetService(kPrefCID, &res)); + + PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone; + aPS->GetHowToEnableFrameUI(&howToEnableFrameUI); + + if( howToEnableFrameUI == nsIPrintSettings::kFrameEnableAll || + howToEnableFrameUI == nsIPrintSettings::kFrameEnableAsIsAndEach ) + { + /* we have frames and we have a selected frame already only if kFrameEnableAll */ + /* look at the Pt_ARG_WEB_OPTION related to this */ + + char *printFrame = NULL; + if( prefs ) prefs->CopyCharPref( "user.print.print_frame", &printFrame ); + + if( printFrame ) { + if( !stricmp( printFrame, "print_frame_as_is" ) ) + aPS->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); + else if( !stricmp( printFrame, "print_frame_all" ) ) + aPS->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); + else if( !stricmp( printFrame, "print_frame_selected" ) ) { + if( howToEnableFrameUI == nsIPrintSettings::kFrameEnableAll ) + aPS->SetPrintFrameType(nsIPrintSettings::kSelectedFrame); + else /* if no frame is selected, use the kFramesAsIs */ + aPS->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); + } + } + } + + char *SetPrintBGColors = NULL, *SetPrintBGImages = NULL; + if( prefs ) prefs->CopyCharPref( "user.print.SetPrintBGColors", &SetPrintBGColors ); + if( prefs ) prefs->CopyCharPref( "user.print.SetPrintBGImages", &SetPrintBGImages ); + + if( SetPrintBGColors && !stricmp( SetPrintBGColors, "true" ) ) + aPS->SetPrintBGColors( PR_TRUE ); + else aPS->SetPrintBGColors( PR_FALSE ); + + if( SetPrintBGImages && !stricmp( SetPrintBGImages, "true" ) ) + aPS->SetPrintBGImages( PR_TRUE ); + else aPS->SetPrintBGImages( PR_FALSE ); } return rv;