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
This commit is contained in:
amardare%qnx.com
2004-04-30 20:01:40 +00:00
parent 8d2e763357
commit 8ffdb92d82

View File

@@ -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<nsIPref> 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;