mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge backout of bug 456646.
This commit is contained in:
commit
49505be9f8
@ -343,10 +343,8 @@ else
|
||||
rm -f $(DIST)/$(APP_NAME).app/Contents/MacOS/$(PROGRAM)
|
||||
rsync -aL $(PROGRAM) $(DIST)/$(APP_NAME).app/Contents/MacOS
|
||||
endif
|
||||
ifndef MOZ_COCOA_PRINTING
|
||||
mkdir -p $(DIST)/$(APP_NAME).app/Contents/Plug-Ins
|
||||
rsync -a --copy-unsafe-links $(LIBXUL_DIST)/package/PrintPDE.plugin $(DIST)/$(APP_NAME).app/Contents/Plug-Ins
|
||||
endif
|
||||
-cp -L $(DIST)/bin/mangle $(DIST)/bin/shlibsign $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)
|
||||
cp -RL $(DIST)/branding/firefox.icns $(DIST)/$(APP_NAME).app/Contents/Resources/firefox.icns
|
||||
cp -RL $(DIST)/branding/document.icns $(DIST)/$(APP_NAME).app/Contents/Resources/document.icns
|
||||
|
@ -89,7 +89,6 @@ MOZ_X11 = @MOZ_X11@
|
||||
MOZ_PANGO = @MOZ_PANGO@
|
||||
|
||||
MOZ_CORETEXT = @MOZ_CORETEXT@
|
||||
MOZ_COCOA_PRINTING = @MOZ_COCOA_PRINTING@
|
||||
|
||||
MOZ_JS_LIBS = @MOZ_JS_LIBS@
|
||||
|
||||
|
28
configure.in
28
configure.in
@ -3193,8 +3193,7 @@ case $target in
|
||||
esac
|
||||
|
||||
dnl ========================================================
|
||||
dnl Check whether we can compile code for Core Text and
|
||||
dnl Cocoa printing
|
||||
dnl Check whether we can compile code for Core Text
|
||||
dnl (Mac OS X 10.5 or later)
|
||||
dnl ========================================================
|
||||
case "$target" in
|
||||
@ -3202,9 +3201,9 @@ case "$target" in
|
||||
AC_MSG_CHECKING([for Core Text])
|
||||
AC_TRY_COMPILE([#include <ApplicationServices/ApplicationServices.h>],
|
||||
[CTLineRef lineRef;],
|
||||
ac_cv_have_leopard="yes",
|
||||
ac_cv_have_leopard="no")
|
||||
AC_MSG_RESULT([$ac_cv_have_leopard])
|
||||
ac_cv_have_core_text="yes",
|
||||
ac_cv_have_core_text="no")
|
||||
AC_MSG_RESULT([$ac_cv_have_core_text])
|
||||
|
||||
MOZ_CORETEXT=1
|
||||
|
||||
@ -3214,30 +3213,15 @@ case "$target" in
|
||||
MOZ_CORETEXT=1)
|
||||
|
||||
if test -n "$MOZ_CORETEXT"; then
|
||||
if test "$ac_cv_have_leopard" = "no"; then
|
||||
if test "$ac_cv_have_core_text" = "no"; then
|
||||
AC_MSG_ERROR([--enable-coretext requires MacOS SDK 10.5 or newer])
|
||||
fi
|
||||
AC_DEFINE(MOZ_CORETEXT)
|
||||
fi
|
||||
|
||||
MOZ_COCOA_PRINTING=1
|
||||
|
||||
MOZ_ARG_DISABLE_BOOL(cocoa-printing,
|
||||
[ --disable-cocoa-printing
|
||||
Use a Carbon print dialog instead of a Cocoa one],
|
||||
MOZ_COCOA_PRINTING=,
|
||||
MOZ_COCOA_PRINTING=1)
|
||||
|
||||
if test -n "$MOZ_COCOA_PRINTING"; then
|
||||
if test "$ac_cv_have_leopard" = "no"; then
|
||||
AC_MSG_ERROR([--enable-cocoa-printing requires MacOS SDK 10.5 or newer])
|
||||
fi
|
||||
AC_DEFINE(MOZ_COCOA_PRINTING)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(MOZ_COCOA_PRINTING)
|
||||
AC_SUBST(MOZ_CORETEXT)
|
||||
|
||||
XLDFLAGS="$X_LIBS"
|
||||
XLIBS="$X_EXTRA_LIBS"
|
||||
|
41
dom/locales/en-US/chrome/printdialog.properties
Normal file
41
dom/locales/en-US/chrome/printdialog.properties
Normal file
@ -0,0 +1,41 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
PrintFrames=Print Frames
|
||||
Aslaid=As &laid out on the screen
|
||||
selectedframe=The selected &frame
|
||||
Eachframe=&Each frame separately
|
||||
options=Options
|
@ -14,6 +14,7 @@
|
||||
locale/@AB_CD@/global/global-strres.properties (%chrome/global-strres.properties)
|
||||
locale/@AB_CD@/global/plugins.properties (%chrome/plugins.properties)
|
||||
locale/@AB_CD@/global/nsWebBrowserPersist.properties (%chrome/nsWebBrowserPersist.properties)
|
||||
locale/@AB_CD@/global/printdialog.properties (%chrome/printdialog.properties)
|
||||
locale/@AB_CD@/global/xslt/xslt.properties (%chrome/xslt/xslt.properties)
|
||||
locale/@AB_CD@/global/dom/dom.properties (%chrome/dom/dom.properties)
|
||||
#ifdef MOZ_SVG
|
||||
|
@ -47,9 +47,7 @@ LIBRARY_NAME = printingui_s
|
||||
LIBXUL_LIBRARY = 1
|
||||
|
||||
|
||||
ifndef MOZ_COCOA_PRINTING
|
||||
DIRS = printpde
|
||||
endif
|
||||
|
||||
CMMSRCS = nsPrintingPromptServiceX.mm
|
||||
|
||||
@ -58,9 +56,9 @@ CPPSRCS = \
|
||||
nsPrintProgress.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_COCOA_PRINTING
|
||||
LOCAL_INCLUDES = -I$(srcdir)/printpde/public
|
||||
endif
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/printpde/public \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
|
@ -51,6 +51,7 @@
|
||||
|
||||
// Printing Progress Includes
|
||||
#include "nsPrintProgress.h"
|
||||
#include "nsPrintProgressParams.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
|
||||
|
||||
@ -71,7 +72,9 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIWindowWatcher> mWatcher;
|
||||
nsCOMPtr<nsIPrintProgress> mPrintProgress;
|
||||
nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -44,14 +44,6 @@
|
||||
|
||||
#include "nsIPrintingPromptService.h"
|
||||
#include "nsIFactory.h"
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIPrintDialogService.h"
|
||||
|
||||
#else
|
||||
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIEmbeddingSiteWindow.h"
|
||||
@ -200,7 +192,6 @@ SetDictionaryBooleanvalue(CFMutableDictionaryRef aDictionary, CFStringRef aKey,
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
// nsPrintingPromptService
|
||||
@ -208,7 +199,8 @@ SetDictionaryBooleanvalue(CFMutableDictionaryRef aDictionary, CFStringRef aKey,
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPrintingPromptService, nsIPrintingPromptService, nsIWebProgressListener)
|
||||
|
||||
nsPrintingPromptService::nsPrintingPromptService()
|
||||
nsPrintingPromptService::nsPrintingPromptService() :
|
||||
mWatcher(do_GetService(NS_WINDOWWATCHER_CONTRACTID))
|
||||
{
|
||||
}
|
||||
|
||||
@ -225,39 +217,6 @@ nsresult nsPrintingPromptService::Init()
|
||||
// nsPrintingPromptService::nsIPrintingPromptService
|
||||
//*****************************************************************************
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
|
||||
NS_PRINTDIALOGSERVICE_CONTRACTID));
|
||||
if (dlgPrint)
|
||||
return dlgPrint->Show(parent, printSettings);
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
|
||||
NS_PRINTDIALOGSERVICE_CONTRACTID));
|
||||
if (dlgPrint)
|
||||
return dlgPrint->ShowPageSetup(parent, printSettings);
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
|
||||
{
|
||||
@ -484,6 +443,19 @@ nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrin
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowProgress(nsIDOMWindow* parent,
|
||||
nsIWebBrowserPrint* webBrowserPrint, // ok to be null
|
||||
nsIPrintSettings* printSettings, // ok to be null
|
||||
nsIObserver* openDialogObserver, // ok to be null
|
||||
PRBool isForPrinting,
|
||||
nsIWebProgressListener** webProgressListener,
|
||||
nsIPrintProgressParams** printProgressParams,
|
||||
PRBool* notifyOnOpen)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
|
||||
{
|
||||
@ -530,21 +502,6 @@ nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *p
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowProgress(nsIDOMWindow* parent,
|
||||
nsIWebBrowserPrint* webBrowserPrint, // ok to be null
|
||||
nsIPrintSettings* printSettings, // ok to be null
|
||||
nsIObserver* openDialogObserver, // ok to be null
|
||||
PRBool isForPrinting,
|
||||
nsIWebProgressListener** webProgressListener,
|
||||
nsIPrintProgressParams** printProgressParams,
|
||||
PRBool* notifyOnOpen)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const PRUnichar *printerName, nsIPrintSettings *printSettings)
|
||||
{
|
||||
@ -559,6 +516,13 @@ nsPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const PRUni
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus)
|
||||
{
|
||||
if ((aStateFlags & STATE_STOP) && mWebProgressListener) {
|
||||
mWebProgressListener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
|
||||
if (mPrintProgress)
|
||||
mPrintProgress->CloseProgressDialog(PR_TRUE);
|
||||
mPrintProgress = nsnull;
|
||||
mWebProgressListener = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -566,6 +530,9 @@ nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
if (mWebProgressListener) {
|
||||
return mWebProgressListener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -573,6 +540,9 @@ nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
|
||||
{
|
||||
if (mWebProgressListener) {
|
||||
return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -580,6 +550,9 @@ nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIReque
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
|
||||
{
|
||||
if (mWebProgressListener) {
|
||||
return mWebProgressListener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -587,5 +560,8 @@ nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state)
|
||||
{
|
||||
if (mWebProgressListener) {
|
||||
return mWebProgressListener->OnSecurityChange(aWebProgress, aRequest, state);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -463,10 +463,10 @@ typedef struct {
|
||||
// These are the control ids used in the dialog and
|
||||
// defined by MS-Windows in commdlg.h
|
||||
static PropKeyInfo gAllPropKeys[] = {
|
||||
{"printFramesTitleWindows", grp3},
|
||||
{"asLaidOutWindows", rad4},
|
||||
{"selectedFrameWindows", rad5},
|
||||
{"separateFramesWindows", rad6},
|
||||
{"PrintFrames", grp3},
|
||||
{"Aslaid", rad4},
|
||||
{"selectedframe", rad5},
|
||||
{"Eachframe", rad6},
|
||||
{NULL, NULL}};
|
||||
|
||||
//--------------------------------------------------------
|
||||
@ -1280,7 +1280,7 @@ ShowNativePrintDialogEx(HWND aHWnd,
|
||||
// lLcalize the Property Sheet (Tab) title
|
||||
nsCAutoString title;
|
||||
nsString optionsStr;
|
||||
if (NS_SUCCEEDED(GetLocalizedString(strBundle, "optionsTitleWindows", optionsStr))) {
|
||||
if (NS_SUCCEEDED(GetLocalizedString(strBundle, "options", optionsStr))) {
|
||||
// Failure here just means a blank string
|
||||
NS_CopyUnicodeToNative(optionsStr, title);
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
printTitle=Print
|
||||
optionsTabLabel=Options
|
||||
printFramesTitle=Print Frames
|
||||
|
||||
# TRANSLATOR NOTE: For radio button labels and check button labels, an underscore _
|
||||
# before a character will turn that character into an accesskey.
|
||||
# e.g. "_As laid out" will make A the accesskey.
|
||||
|
||||
asLaidOut=_As Laid Out on the Screen
|
||||
selectedFrame=The _Selected Frame
|
||||
separateFrames=Each Frame on Separate _Pages
|
||||
shrinkToFit=Ignore Scaling and S_hrink To Fit Page Width
|
||||
selectionOnly=Print Selection _Only
|
||||
printBGOptions=Print Backgrounds
|
||||
printBGColors=Print Background _Colors
|
||||
printBGImages=Print Background I_mages
|
||||
headerFooter=Header and Footer
|
||||
left=Left
|
||||
center=Center
|
||||
right=Right
|
||||
headerFooterBlank=--blank--
|
||||
headerFooterTitle=Title
|
||||
headerFooterURL=URL
|
||||
headerFooterDate=Date/Time
|
||||
headerFooterPage=Page #
|
||||
headerFooterPageTotal=Page # of #
|
||||
headerFooterCustom=Custom...
|
||||
customHeaderFooterPrompt=Please enter your custom header/footer text
|
@ -1,59 +0,0 @@
|
||||
# These strings are used in the native GTK, Mac and Windows print dialogs.
|
||||
|
||||
# GTK titles:
|
||||
printTitleGTK=Print
|
||||
optionsTabLabelGTK=Options
|
||||
printFramesTitleGTK=Print Frames
|
||||
|
||||
# Mac titles:
|
||||
optionsTitleMac=Options:
|
||||
appearanceTitleMac=Appearance:
|
||||
framesTitleMac=Frames:
|
||||
pageHeadersTitleMac=Page Headers:
|
||||
pageFootersTitleMac=Page Footers:
|
||||
|
||||
# Windows titles:
|
||||
optionsTitleWindows=Options
|
||||
printFramesTitleWindows=Print Frames
|
||||
|
||||
# TRANSLATOR NOTE: For radio button labels and check button labels, an underscore _
|
||||
# before a character will turn that character into an accesskey in the GTK dialog.
|
||||
# e.g. "_As laid out" will make A the accesskey.
|
||||
# In the Windows labels, use an ampersand (&).
|
||||
# On Mac, underscores will be stripped.
|
||||
|
||||
asLaidOut=_As Laid Out on the Screen
|
||||
asLaidOutWindows=As &laid out on the screen
|
||||
selectedFrame=The _Selected Frame
|
||||
selectedFrameWindows=The selected &frame
|
||||
separateFrames=Each Frame on Separate _Pages
|
||||
separateFramesWindows=&Each frame separately
|
||||
shrinkToFit=Ignore Scaling and S_hrink To Fit Page Width
|
||||
selectionOnly=Print Selection _Only
|
||||
printBGOptions=Print Backgrounds
|
||||
printBGColors=Print Background _Colors
|
||||
printBGImages=Print Background I_mages
|
||||
headerFooter=Header and Footer
|
||||
left=Left
|
||||
center=Center
|
||||
right=Right
|
||||
headerFooterBlank=--blank--
|
||||
headerFooterTitle=Title
|
||||
headerFooterURL=URL
|
||||
headerFooterDate=Date/Time
|
||||
headerFooterPage=Page #
|
||||
headerFooterPageTotal=Page # of #
|
||||
headerFooterCustom=Custom...
|
||||
customHeaderFooterPrompt=Please enter your custom header/footer text
|
||||
|
||||
# These are for the summary view in the Mac dialog:
|
||||
summaryFramesTitle=Print Frames
|
||||
summarySelectionOnlyTitle=Print Selection
|
||||
summaryShrinkToFitTitle=Shrink To Fit
|
||||
summaryPrintBGColorsTitle=Print BG Colors
|
||||
summaryPrintBGImagesTitle=Print BG Images
|
||||
summaryHeaderTitle=Page Headers
|
||||
summaryFooterTitle=Page Footers
|
||||
summaryNAValue=N/A
|
||||
summaryOnValue=On
|
||||
summaryOffValue=Off
|
@ -40,12 +40,12 @@
|
||||
locale/@AB_CD@/global/mozilla.dtd (%chrome/global/mozilla.dtd)
|
||||
locale/@AB_CD@/global/notification.dtd (%chrome/global/notification.dtd)
|
||||
locale/@AB_CD@/global/preferences.dtd (%chrome/global/preferences.dtd)
|
||||
locale/@AB_CD@/global/printdialog.dtd (%chrome/global/printdialog.dtd)
|
||||
+ locale/@AB_CD@/global/printdialog.dtd (%chrome/global/printdialog.dtd)
|
||||
+ locale/@AB_CD@/global/printjoboptions.dtd (%chrome/global/printjoboptions.dtd)
|
||||
+ locale/@AB_CD@/global/printPageSetup.dtd (%chrome/global/printPageSetup.dtd)
|
||||
+ locale/@AB_CD@/global/printPreview.dtd (%chrome/global/printPreview.dtd)
|
||||
+ locale/@AB_CD@/global/printPreviewProgress.dtd (%chrome/global/printPreviewProgress.dtd)
|
||||
+ locale/@AB_CD@/global/printdialog.properties (%chrome/global/printdialog.properties)
|
||||
locale/@AB_CD@/global/gnomeprintdialog.properties (%chrome/global/gnomeprintdialog.properties)
|
||||
+ locale/@AB_CD@/global/printProgress.dtd (%chrome/global/printProgress.dtd)
|
||||
+ locale/@AB_CD@/global/regionNames.properties (%chrome/global/regionNames.properties)
|
||||
+ locale/@AB_CD@/global/dialog.properties (%chrome/global/dialog.properties)
|
||||
|
@ -64,12 +64,6 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
EXPORTS += nsINativeMenuService.h
|
||||
endif
|
||||
|
||||
ifdef MOZ_COCOA_PRINTING
|
||||
EXPORTS += \
|
||||
nsIPrintDialogService.h \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
EXPORTS += nsIDragSessionOS2.h
|
||||
endif
|
||||
@ -128,11 +122,9 @@ XPIDLSRCS += nsIPrintSettingsWin.idl \
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
ifndef MOZ_COCOA_PRINTING
|
||||
XPIDLSRCS += nsIPrintSettingsX.idl \
|
||||
nsIPrintSessionX.idl
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
XPIDLSRCS += nsIRwsService.idl
|
||||
|
@ -85,17 +85,12 @@ CMMSRCS = \
|
||||
nsDeviceContextSpecX.mm \
|
||||
nsPrintOptionsX.mm \
|
||||
nsPrintSettingsX.mm \
|
||||
nsPrintSessionX.mm \
|
||||
nsIdleServiceX.mm \
|
||||
nsAccelerometerX.mm \
|
||||
nsCocoaTextInputHandler.mm \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_COCOA_PRINTING
|
||||
CMMSRCS += nsPrintDialogX.mm
|
||||
else
|
||||
CMMSRCS += nsPrintSessionX.mm
|
||||
endif
|
||||
|
||||
XPIDLSRCS += \
|
||||
nsPIWidgetCocoa.idl \
|
||||
$(NULL)
|
||||
|
@ -41,19 +41,14 @@
|
||||
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
class nsDeviceContextSpecX : public nsIDeviceContextSpec
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsDeviceContextSpecX();
|
||||
|
||||
NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMETHOD GetSurfaceForPrinter(gfxASurface **surface);
|
||||
NS_IMETHOD BeginDocument(PRUnichar* aTitle,
|
||||
PRUnichar* aPrintToFileName,
|
||||
@ -63,18 +58,24 @@ public:
|
||||
NS_IMETHOD BeginPage();
|
||||
NS_IMETHOD EndPage();
|
||||
|
||||
/**
|
||||
* Initialize the nsDeviceContextSpecX for use. This will allocate a printrecord for use
|
||||
* @param aWidget Unused
|
||||
* @param aPS Settings for this print job
|
||||
* @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
|
||||
void GetPaperRect(double* aTop, double* aLeft, double* aBottom, double* aRight);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecX();
|
||||
virtual ~nsDeviceContextSpecX();
|
||||
|
||||
protected:
|
||||
PMPrintSession mPrintSession; // printing context.
|
||||
PMPageFormat mPageFormat; // page format.
|
||||
PMPrintSettings mPrintSettings; // print settings.
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
NSPrintInfo* mPrintInfo; // Cocoa print info.
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif //nsDeviceContextSpecX_h_
|
||||
|
@ -48,23 +48,15 @@
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsIPrintSettingsX.h"
|
||||
|
||||
#include "gfxQuartzSurface.h"
|
||||
#include "gfxImageSurface.h"
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
#include "nsPrintSettingsX.h"
|
||||
#else
|
||||
#include "nsIPrintSettingsX.h"
|
||||
#endif
|
||||
|
||||
nsDeviceContextSpecX::nsDeviceContextSpecX()
|
||||
: mPrintSession(NULL)
|
||||
, mPageFormat(kPMNoPageFormat)
|
||||
, mPrintSettings(kPMNoPrintSettings)
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
, mPrintInfo(nil)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@ -86,17 +78,6 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIWidget *aWidget,
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
nsCOMPtr<nsPrintSettingsX> settings(do_QueryInterface(aPS));
|
||||
if (!settings)
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
|
||||
mPrintInfo = settings->GetCocoaPrintInfo();
|
||||
mPrintSession = static_cast<PMPrintSession>([mPrintInfo PMPrintSession]);
|
||||
::PMRetain(mPrintSession);
|
||||
mPageFormat = static_cast<PMPageFormat>([mPrintInfo PMPageFormat]);
|
||||
mPrintSettings = static_cast<PMPrintSettings>([mPrintInfo PMPrintSettings]);
|
||||
#else
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
|
||||
@ -105,7 +86,7 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIWidget *aWidget,
|
||||
|
||||
rv = printSettingsX->GetNativePrintSession(&mPrintSession);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return rv;
|
||||
::PMRetain(mPrintSession);
|
||||
|
||||
rv = printSettingsX->GetPMPageFormat(&mPageFormat);
|
||||
@ -115,7 +96,6 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIWidget *aWidget,
|
||||
rv = printSettingsX->GetPMPrintSettings(&mPrintSettings);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@ -162,6 +142,13 @@ NS_IMETHODIMP nsDeviceContextSpecX::EndDocument()
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP nsDeviceContextSpecX::AbortDocument()
|
||||
{
|
||||
return EndDocument();
|
||||
}
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecX::BeginPage()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
@ -1,97 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla OS X print dialog interface.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Markus Stange <mstange@themasta.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsPrintDialogX_h__
|
||||
#define nsPrintDialogX_h__
|
||||
|
||||
#include "nsIPrintDialogService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
class nsIPrintSettings;
|
||||
class nsIStringBundle;
|
||||
|
||||
class nsPrintDialogServiceX : public nsIPrintDialogService
|
||||
{
|
||||
public:
|
||||
nsPrintDialogServiceX();
|
||||
virtual ~nsPrintDialogServiceX();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHODIMP Init();
|
||||
NS_IMETHODIMP Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings);
|
||||
NS_IMETHODIMP ShowPageSetup(nsIDOMWindow *aParent,
|
||||
nsIPrintSettings *aSettings);
|
||||
};
|
||||
|
||||
@interface PrintPanelAccessoryView : NSView
|
||||
{
|
||||
nsIPrintSettings* mSettings;
|
||||
nsIStringBundle* mPrintBundle;
|
||||
NSButton* mPrintSelectionOnlyCheckbox;
|
||||
NSButton* mShrinkToFitCheckbox;
|
||||
NSButton* mPrintBGColorsCheckbox;
|
||||
NSButton* mPrintBGImagesCheckbox;
|
||||
NSButtonCell* mAsLaidOutRadio;
|
||||
NSButtonCell* mSelectedFrameRadio;
|
||||
NSButtonCell* mSeparateFramesRadio;
|
||||
NSPopUpButton* mHeaderLeftList;
|
||||
NSPopUpButton* mHeaderCenterList;
|
||||
NSPopUpButton* mHeaderRightList;
|
||||
NSPopUpButton* mFooterLeftList;
|
||||
NSPopUpButton* mFooterCenterList;
|
||||
NSPopUpButton* mFooterRightList;
|
||||
}
|
||||
|
||||
- (id)initWithSettings:(nsIPrintSettings*)aSettings;
|
||||
|
||||
- (void)exportSettings;
|
||||
|
||||
@end
|
||||
|
||||
@interface PrintPanelAccessoryController : NSViewController <NSPrintPanelAccessorizing>
|
||||
|
||||
- (id)initWithSettings:(nsIPrintSettings*)aSettings;
|
||||
|
||||
- (void)exportSettings;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
@ -1,615 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla OS X print dialog interface.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Markus Stange <mstange@themasta.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsPrintDialogX.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsPrintSettingsX.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsCocoaUtils.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "nsObjCExceptions.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPrintDialogServiceX, nsIPrintDialogService)
|
||||
|
||||
nsPrintDialogServiceX::nsPrintDialogServiceX()
|
||||
{
|
||||
}
|
||||
|
||||
nsPrintDialogServiceX::~nsPrintDialogServiceX()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintDialogServiceX::Init()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintDialogServiceX::Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
NS_PRECONDITION(aSettings, "aSettings must not be null");
|
||||
|
||||
nsCOMPtr<nsPrintSettingsX> settingsX(do_QueryInterface(aSettings));
|
||||
if (!settingsX)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo();
|
||||
|
||||
NSPrintPanel* panel = [NSPrintPanel printPanel];
|
||||
PrintPanelAccessoryController* viewController =
|
||||
[[PrintPanelAccessoryController alloc] initWithSettings:aSettings];
|
||||
[panel addAccessoryController:viewController];
|
||||
[viewController release];
|
||||
|
||||
// Show the dialog.
|
||||
nsCocoaUtils::PrepareForNativeAppModalDialog();
|
||||
int button = [panel runModalWithPrintInfo:printInfo];
|
||||
nsCocoaUtils::CleanUpAfterNativeAppModalDialog();
|
||||
|
||||
if (button != NSOKButton)
|
||||
return NS_ERROR_ABORT;
|
||||
|
||||
// Export settings.
|
||||
[viewController exportSettings];
|
||||
|
||||
PRInt16 pageRange;
|
||||
aSettings->GetPrintRange(&pageRange);
|
||||
if (pageRange != nsIPrintSettings::kRangeSelection) {
|
||||
PMPrintSettings nativePrintSettings = (PMPrintSettings)[printInfo PMPrintSettings];
|
||||
UInt32 firstPage, lastPage;
|
||||
OSStatus status = ::PMGetFirstPage(nativePrintSettings, &firstPage);
|
||||
if (status == noErr) {
|
||||
status = ::PMGetLastPage(nativePrintSettings, &lastPage);
|
||||
if (status == noErr && lastPage != LONG_MAX) {
|
||||
aSettings->SetPrintRange(nsIPrintSettings::kRangeSpecifiedPageRange);
|
||||
aSettings->SetStartPageRange(firstPage);
|
||||
aSettings->SetEndPageRange(lastPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintDialogServiceX::ShowPageSetup(nsIDOMWindow *aParent,
|
||||
nsIPrintSettings *aNSSettings)
|
||||
{
|
||||
NS_PRECONDITION(aParent, "aParent must not be null");
|
||||
NS_PRECONDITION(aNSSettings, "aSettings must not be null");
|
||||
NS_ENSURE_TRUE(aNSSettings, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsPrintSettingsX> settingsX(do_QueryInterface(aNSSettings));
|
||||
if (!settingsX)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo();
|
||||
NSPageLayout *pageLayout = [NSPageLayout pageLayout];
|
||||
nsCocoaUtils::PrepareForNativeAppModalDialog();
|
||||
int button = [pageLayout runModalWithPrintInfo:printInfo];
|
||||
nsCocoaUtils::CleanUpAfterNativeAppModalDialog();
|
||||
|
||||
return button == NSOKButton ? NS_OK : NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
// Accessory view
|
||||
|
||||
@interface PrintPanelAccessoryView (Private)
|
||||
|
||||
- (NSString*)localizedString:(const char*)aKey;
|
||||
|
||||
- (PRInt16)chosenFrameSetting;
|
||||
|
||||
- (const char*)headerFooterStringForList:(NSPopUpButton*)aList;
|
||||
|
||||
- (void)exportHeaderFooterSettings;
|
||||
|
||||
- (void)initBundle;
|
||||
|
||||
- (NSTextField*)label:(const char*)aLabel
|
||||
withFrame:(NSRect)aRect
|
||||
alignment:(NSTextAlignment)aAlignment;
|
||||
|
||||
- (void)addLabel:(const char*)aLabel
|
||||
withFrame:(NSRect)aRect
|
||||
alignment:(NSTextAlignment)aAlignment;
|
||||
|
||||
- (void)addLabel:(const char*)aLabel withFrame:(NSRect)aRect;
|
||||
|
||||
- (void)addCenteredLabel:(const char*)aLabel withFrame:(NSRect)aRect;
|
||||
|
||||
- (NSButton*)checkboxWithLabel:(const char*)aLabel andFrame:(NSRect)aRect;
|
||||
|
||||
- (NSPopUpButton*)headerFooterItemListWithFrame:(NSRect)aRect
|
||||
selectedItem:(const PRUnichar*)aCurrentString;
|
||||
|
||||
- (void)addOptionsSection;
|
||||
|
||||
- (void)addAppearanceSection;
|
||||
|
||||
- (void)addFramesSection;
|
||||
|
||||
- (void)addHeaderFooterSection;
|
||||
|
||||
- (NSString*)summaryValueForCheckbox:(NSButton*)aCheckbox;
|
||||
|
||||
- (NSString*)framesSummaryValue;
|
||||
|
||||
- (NSString*)headerSummaryValue;
|
||||
|
||||
- (NSString*)footerSummaryValue;
|
||||
|
||||
@end
|
||||
|
||||
static const char sHeaderFooterTags[][4] = {"", "&T", "&U", "&D", "&P", "&PT"};
|
||||
|
||||
@implementation PrintPanelAccessoryView
|
||||
|
||||
// Public methods
|
||||
|
||||
- (id)initWithSettings:(nsIPrintSettings*)aSettings
|
||||
{
|
||||
[super initWithFrame:NSMakeRect(0, 0, 540, 270)];
|
||||
|
||||
mSettings = aSettings;
|
||||
[self initBundle];
|
||||
[self addOptionsSection];
|
||||
[self addAppearanceSection];
|
||||
[self addFramesSection];
|
||||
[self addHeaderFooterSection];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)exportSettings
|
||||
{
|
||||
mSettings->SetPrintRange([mPrintSelectionOnlyCheckbox state] == NSOnState ?
|
||||
(PRInt16)nsIPrintSettings::kRangeSelection :
|
||||
(PRInt16)nsIPrintSettings::kRangeAllPages);
|
||||
mSettings->SetShrinkToFit([mShrinkToFitCheckbox state] == NSOnState);
|
||||
mSettings->SetPrintBGColors([mPrintBGColorsCheckbox state] == NSOnState);
|
||||
mSettings->SetPrintBGImages([mPrintBGImagesCheckbox state] == NSOnState);
|
||||
mSettings->SetPrintFrameType([self chosenFrameSetting]);
|
||||
|
||||
[self exportHeaderFooterSettings];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
NS_IF_RELEASE(mPrintBundle);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
// Localization
|
||||
|
||||
- (void)initBundle
|
||||
{
|
||||
nsCOMPtr<nsIStringBundleService> bundleSvc = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", &mPrintBundle);
|
||||
}
|
||||
|
||||
- (NSString*)localizedString:(const char*)aKey
|
||||
{
|
||||
if (!mPrintBundle)
|
||||
return @"";
|
||||
|
||||
nsXPIDLString intlString;
|
||||
mPrintBundle->GetStringFromName(NS_ConvertUTF8toUTF16(aKey).get(), getter_Copies(intlString));
|
||||
NSString* s = [NSString stringWithUTF8String:NS_ConvertUTF16toUTF8(intlString).get()];
|
||||
|
||||
// Remove all underscores (they're used in the GTK dialog for accesskeys).
|
||||
return [s stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
||||
}
|
||||
|
||||
// Widget helpers
|
||||
|
||||
- (NSTextField*)label:(const char*)aLabel
|
||||
withFrame:(NSRect)aRect
|
||||
alignment:(NSTextAlignment)aAlignment
|
||||
{
|
||||
NSTextField* label = [[[NSTextField alloc] initWithFrame:aRect] autorelease];
|
||||
[label setStringValue:[self localizedString:aLabel]];
|
||||
[label setEditable:NO];
|
||||
[label setSelectable:NO];
|
||||
[label setBezeled:NO];
|
||||
[label setBordered:NO];
|
||||
[label setDrawsBackground:NO];
|
||||
[label setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
|
||||
[label setAlignment:aAlignment];
|
||||
return label;
|
||||
}
|
||||
|
||||
- (void)addLabel:(const char*)aLabel
|
||||
withFrame:(NSRect)aRect
|
||||
alignment:(NSTextAlignment)aAlignment
|
||||
{
|
||||
NSTextField* label = [self label:aLabel withFrame:aRect alignment:aAlignment];
|
||||
[self addSubview:label];
|
||||
}
|
||||
|
||||
- (void)addLabel:(const char*)aLabel withFrame:(NSRect)aRect
|
||||
{
|
||||
[self addLabel:aLabel withFrame:aRect alignment:NSRightTextAlignment];
|
||||
}
|
||||
|
||||
- (void)addCenteredLabel:(const char*)aLabel withFrame:(NSRect)aRect
|
||||
{
|
||||
[self addLabel:aLabel withFrame:aRect alignment:NSCenterTextAlignment];
|
||||
}
|
||||
|
||||
- (NSButton*)checkboxWithLabel:(const char*)aLabel andFrame:(NSRect)aRect
|
||||
{
|
||||
aRect.origin.y += 4.0f;
|
||||
NSButton* checkbox = [[[NSButton alloc] initWithFrame:aRect] autorelease];
|
||||
[checkbox setButtonType:NSSwitchButton];
|
||||
[checkbox setTitle:[self localizedString:aLabel]];
|
||||
[checkbox setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
|
||||
[checkbox sizeToFit];
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
- (NSPopUpButton*)headerFooterItemListWithFrame:(NSRect)aRect
|
||||
selectedItem:(const PRUnichar*)aCurrentString
|
||||
{
|
||||
NSPopUpButton* list = [[[NSPopUpButton alloc] initWithFrame:aRect pullsDown:NO] autorelease];
|
||||
[list setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
|
||||
[[list cell] setControlSize:NSSmallControlSize];
|
||||
NSArray* items =
|
||||
[NSArray arrayWithObjects:[self localizedString:"headerFooterBlank"],
|
||||
[self localizedString:"headerFooterTitle"],
|
||||
[self localizedString:"headerFooterURL"],
|
||||
[self localizedString:"headerFooterDate"],
|
||||
[self localizedString:"headerFooterPage"],
|
||||
[self localizedString:"headerFooterPageTotal"],
|
||||
nil];
|
||||
[list addItemsWithTitles:items];
|
||||
|
||||
NS_ConvertUTF16toUTF8 currentStringUTF8(aCurrentString);
|
||||
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(sHeaderFooterTags); i++) {
|
||||
if (!strcmp(currentStringUTF8.get(), sHeaderFooterTags[i])) {
|
||||
[list selectItemAtIndex:i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
// Build sections
|
||||
|
||||
- (void)addOptionsSection
|
||||
{
|
||||
// Title
|
||||
[self addLabel:"optionsTitleMac" withFrame:NSMakeRect(0, 240, 151, 22)];
|
||||
|
||||
// "Print Selection Only"
|
||||
mPrintSelectionOnlyCheckbox = [self checkboxWithLabel:"selectionOnly"
|
||||
andFrame:NSMakeRect(156, 240, 0, 0)];
|
||||
|
||||
PRBool canPrintSelection;
|
||||
mSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB,
|
||||
&canPrintSelection);
|
||||
[mPrintSelectionOnlyCheckbox setEnabled:canPrintSelection];
|
||||
|
||||
PRInt16 printRange;
|
||||
mSettings->GetPrintRange(&printRange);
|
||||
if (printRange == nsIPrintSettings::kRangeSelection) {
|
||||
[mPrintSelectionOnlyCheckbox setState:NSOnState];
|
||||
}
|
||||
|
||||
[self addSubview:mPrintSelectionOnlyCheckbox];
|
||||
|
||||
// "Shrink To Fit"
|
||||
mShrinkToFitCheckbox = [self checkboxWithLabel:"shrinkToFit"
|
||||
andFrame:NSMakeRect(156, 218, 0, 0)];
|
||||
|
||||
PRBool shrinkToFit;
|
||||
mSettings->GetShrinkToFit(&shrinkToFit);
|
||||
[mShrinkToFitCheckbox setState:(shrinkToFit ? NSOnState : NSOffState)];
|
||||
|
||||
[self addSubview:mShrinkToFitCheckbox];
|
||||
}
|
||||
|
||||
- (void)addAppearanceSection
|
||||
{
|
||||
// Title
|
||||
[self addLabel:"appearanceTitleMac" withFrame:NSMakeRect(0, 188, 151, 22)];
|
||||
|
||||
// "Print Background Colors"
|
||||
mPrintBGColorsCheckbox = [self checkboxWithLabel:"printBGColors"
|
||||
andFrame:NSMakeRect(156, 188, 0, 0)];
|
||||
|
||||
PRBool geckoBool;
|
||||
mSettings->GetPrintBGColors(&geckoBool);
|
||||
[mPrintBGColorsCheckbox setState:(geckoBool ? NSOnState : NSOffState)];
|
||||
|
||||
[self addSubview:mPrintBGColorsCheckbox];
|
||||
|
||||
// "Print Background Images"
|
||||
mPrintBGImagesCheckbox = [self checkboxWithLabel:"printBGImages"
|
||||
andFrame:NSMakeRect(156, 166, 0, 0)];
|
||||
|
||||
mSettings->GetPrintBGImages(&geckoBool);
|
||||
[mPrintBGImagesCheckbox setState:(geckoBool ? NSOnState : NSOffState)];
|
||||
|
||||
[self addSubview:mPrintBGImagesCheckbox];
|
||||
}
|
||||
|
||||
- (void)addFramesSection
|
||||
{
|
||||
// Title
|
||||
[self addLabel:"framesTitleMac" withFrame:NSMakeRect(0, 124, 151, 22)];
|
||||
|
||||
// Radio matrix
|
||||
NSButtonCell *radio = [[NSButtonCell alloc] init];
|
||||
[radio setButtonType:NSRadioButton];
|
||||
[radio setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
|
||||
NSMatrix *matrix = [[NSMatrix alloc] initWithFrame:NSMakeRect(156, 81, 400, 66)
|
||||
mode:NSRadioModeMatrix
|
||||
prototype:(NSCell*)radio
|
||||
numberOfRows:3
|
||||
numberOfColumns:1];
|
||||
[radio release];
|
||||
[matrix setCellSize:NSMakeSize(400, 21)];
|
||||
[self addSubview:matrix];
|
||||
[matrix release];
|
||||
NSArray *cellArray = [matrix cells];
|
||||
mAsLaidOutRadio = [cellArray objectAtIndex:0];
|
||||
mSelectedFrameRadio = [cellArray objectAtIndex:1];
|
||||
mSeparateFramesRadio = [cellArray objectAtIndex:2];
|
||||
[mAsLaidOutRadio setTitle:[self localizedString:"asLaidOut"]];
|
||||
[mSelectedFrameRadio setTitle:[self localizedString:"selectedFrame"]];
|
||||
[mSeparateFramesRadio setTitle:[self localizedString:"separateFrames"]];
|
||||
|
||||
// Radio enabled state
|
||||
PRInt16 frameUIFlag;
|
||||
mSettings->GetHowToEnableFrameUI(&frameUIFlag);
|
||||
if (frameUIFlag == nsIPrintSettings::kFrameEnableNone) {
|
||||
[mAsLaidOutRadio setEnabled:NO];
|
||||
[mSelectedFrameRadio setEnabled:NO];
|
||||
[mSeparateFramesRadio setEnabled:NO];
|
||||
} else if (frameUIFlag == nsIPrintSettings::kFrameEnableAsIsAndEach) {
|
||||
[mSelectedFrameRadio setEnabled:NO];
|
||||
}
|
||||
|
||||
// Radio values
|
||||
PRInt16 printFrameType;
|
||||
mSettings->GetPrintFrameType(&printFrameType);
|
||||
switch (printFrameType) {
|
||||
case nsIPrintSettings::kFramesAsIs:
|
||||
[mAsLaidOutRadio setState:NSOnState];
|
||||
break;
|
||||
case nsIPrintSettings::kSelectedFrame:
|
||||
[mSelectedFrameRadio setState:NSOnState];
|
||||
break;
|
||||
case nsIPrintSettings::kEachFrameSep:
|
||||
[mSeparateFramesRadio setState:NSOnState];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addHeaderFooterSection
|
||||
{
|
||||
// Labels
|
||||
[self addLabel:"pageHeadersTitleMac" withFrame:NSMakeRect(0, 44, 151, 22)];
|
||||
[self addLabel:"pageFootersTitleMac" withFrame:NSMakeRect(0, 0, 151, 22)];
|
||||
[self addCenteredLabel:"left" withFrame:NSMakeRect(156, 22, 100, 22)];
|
||||
[self addCenteredLabel:"center" withFrame:NSMakeRect(256, 22, 100, 22)];
|
||||
[self addCenteredLabel:"right" withFrame:NSMakeRect(356, 22, 100, 22)];
|
||||
|
||||
// Lists
|
||||
nsXPIDLString sel;
|
||||
|
||||
mSettings->GetHeaderStrLeft(getter_Copies(sel));
|
||||
mHeaderLeftList = [self headerFooterItemListWithFrame:NSMakeRect(156, 44, 100, 22)
|
||||
selectedItem:sel];
|
||||
[self addSubview:mHeaderLeftList];
|
||||
|
||||
mSettings->GetHeaderStrCenter(getter_Copies(sel));
|
||||
mHeaderCenterList = [self headerFooterItemListWithFrame:NSMakeRect(256, 44, 100, 22)
|
||||
selectedItem:sel];
|
||||
[self addSubview:mHeaderCenterList];
|
||||
|
||||
mSettings->GetHeaderStrRight(getter_Copies(sel));
|
||||
mHeaderRightList = [self headerFooterItemListWithFrame:NSMakeRect(356, 44, 100, 22)
|
||||
selectedItem:sel];
|
||||
[self addSubview:mHeaderRightList];
|
||||
|
||||
mSettings->GetFooterStrLeft(getter_Copies(sel));
|
||||
mFooterLeftList = [self headerFooterItemListWithFrame:NSMakeRect(156, 0, 100, 22)
|
||||
selectedItem:sel];
|
||||
[self addSubview:mFooterLeftList];
|
||||
|
||||
mSettings->GetFooterStrCenter(getter_Copies(sel));
|
||||
mFooterCenterList = [self headerFooterItemListWithFrame:NSMakeRect(256, 0, 100, 22)
|
||||
selectedItem:sel];
|
||||
[self addSubview:mFooterCenterList];
|
||||
|
||||
mSettings->GetFooterStrRight(getter_Copies(sel));
|
||||
mFooterRightList = [self headerFooterItemListWithFrame:NSMakeRect(356, 0, 100, 22)
|
||||
selectedItem:sel];
|
||||
[self addSubview:mFooterRightList];
|
||||
}
|
||||
|
||||
// Export settings
|
||||
|
||||
- (PRInt16)chosenFrameSetting
|
||||
{
|
||||
if ([mAsLaidOutRadio state] == NSOnState)
|
||||
return nsIPrintSettings::kFramesAsIs;
|
||||
if ([mSelectedFrameRadio state] == NSOnState)
|
||||
return nsIPrintSettings::kSelectedFrame;
|
||||
if ([mSeparateFramesRadio state] == NSOnState)
|
||||
return nsIPrintSettings::kEachFrameSep;
|
||||
return nsIPrintSettings::kNoFrames;
|
||||
}
|
||||
|
||||
- (const char*)headerFooterStringForList:(NSPopUpButton*)aList
|
||||
{
|
||||
NSInteger index = [aList indexOfSelectedItem];
|
||||
NS_ASSERTION(index < NSInteger(NS_ARRAY_LENGTH(sHeaderFooterTags)), "Index of dropdown is higher than expected!");
|
||||
return sHeaderFooterTags[index];
|
||||
}
|
||||
|
||||
- (void)exportHeaderFooterSettings
|
||||
{
|
||||
const char* headerFooterStr;
|
||||
headerFooterStr = [self headerFooterStringForList:mHeaderLeftList];
|
||||
mSettings->SetHeaderStrLeft(NS_ConvertUTF8toUTF16(headerFooterStr).get());
|
||||
|
||||
headerFooterStr = [self headerFooterStringForList:mHeaderCenterList];
|
||||
mSettings->SetHeaderStrCenter(NS_ConvertUTF8toUTF16(headerFooterStr).get());
|
||||
|
||||
headerFooterStr = [self headerFooterStringForList:mHeaderRightList];
|
||||
mSettings->SetHeaderStrRight(NS_ConvertUTF8toUTF16(headerFooterStr).get());
|
||||
|
||||
headerFooterStr = [self headerFooterStringForList:mFooterLeftList];
|
||||
mSettings->SetFooterStrLeft(NS_ConvertUTF8toUTF16(headerFooterStr).get());
|
||||
|
||||
headerFooterStr = [self headerFooterStringForList:mFooterCenterList];
|
||||
mSettings->SetFooterStrCenter(NS_ConvertUTF8toUTF16(headerFooterStr).get());
|
||||
|
||||
headerFooterStr = [self headerFooterStringForList:mFooterRightList];
|
||||
mSettings->SetFooterStrRight(NS_ConvertUTF8toUTF16(headerFooterStr).get());
|
||||
}
|
||||
|
||||
// Summary
|
||||
|
||||
- (NSString*)summaryValueForCheckbox:(NSButton*)aCheckbox
|
||||
{
|
||||
if (![aCheckbox isEnabled])
|
||||
return [self localizedString:"summaryNAValue"];
|
||||
|
||||
return [aCheckbox state] == NSOnState ?
|
||||
[self localizedString:"summaryOnValue"] :
|
||||
[self localizedString:"summaryOffValue"];
|
||||
}
|
||||
|
||||
- (NSString*)framesSummaryValue
|
||||
{
|
||||
switch([self chosenFrameSetting]) {
|
||||
case nsIPrintSettings::kFramesAsIs:
|
||||
return [self localizedString:"asLaidOut"];
|
||||
case nsIPrintSettings::kSelectedFrame:
|
||||
return [self localizedString:"selectedFrame"];
|
||||
case nsIPrintSettings::kEachFrameSep:
|
||||
return [self localizedString:"separateFrames"];
|
||||
}
|
||||
return [self localizedString:"summaryNAValue"];
|
||||
}
|
||||
|
||||
- (NSString*)headerSummaryValue
|
||||
{
|
||||
return [[mHeaderLeftList titleOfSelectedItem] stringByAppendingString:
|
||||
[@", " stringByAppendingString:
|
||||
[[mHeaderCenterList titleOfSelectedItem] stringByAppendingString:
|
||||
[@", " stringByAppendingString:
|
||||
[mHeaderRightList titleOfSelectedItem]]]]];
|
||||
}
|
||||
|
||||
- (NSString*)footerSummaryValue
|
||||
{
|
||||
return [[mFooterLeftList titleOfSelectedItem] stringByAppendingString:
|
||||
[@", " stringByAppendingString:
|
||||
[[mFooterCenterList titleOfSelectedItem] stringByAppendingString:
|
||||
[@", " stringByAppendingString:
|
||||
[mFooterRightList titleOfSelectedItem]]]]];
|
||||
}
|
||||
|
||||
- (NSArray*)localizedSummaryItems
|
||||
{
|
||||
return [NSArray arrayWithObjects:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[self localizedString:"summaryFramesTitle"], NSPrintPanelAccessorySummaryItemNameKey,
|
||||
[self framesSummaryValue], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[self localizedString:"summarySelectionOnlyTitle"], NSPrintPanelAccessorySummaryItemNameKey,
|
||||
[self summaryValueForCheckbox:mPrintSelectionOnlyCheckbox], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[self localizedString:"summaryShrinkToFitTitle"], NSPrintPanelAccessorySummaryItemNameKey,
|
||||
[self summaryValueForCheckbox:mShrinkToFitCheckbox], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[self localizedString:"summaryPrintBGColorsTitle"], NSPrintPanelAccessorySummaryItemNameKey,
|
||||
[self summaryValueForCheckbox:mPrintBGColorsCheckbox], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[self localizedString:"summaryPrintBGImagesTitle"], NSPrintPanelAccessorySummaryItemNameKey,
|
||||
[self summaryValueForCheckbox:mPrintBGImagesCheckbox], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[self localizedString:"summaryHeaderTitle"], NSPrintPanelAccessorySummaryItemNameKey,
|
||||
[self headerSummaryValue], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[self localizedString:"summaryFooterTitle"], NSPrintPanelAccessorySummaryItemNameKey,
|
||||
[self footerSummaryValue], NSPrintPanelAccessorySummaryItemDescriptionKey, nil],
|
||||
nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// Accessory controller
|
||||
|
||||
@implementation PrintPanelAccessoryController
|
||||
|
||||
- (id)initWithSettings:(nsIPrintSettings*)aSettings
|
||||
{
|
||||
[super initWithNibName:nil bundle:nil];
|
||||
NSView* accView = [[PrintPanelAccessoryView alloc] initWithSettings:aSettings];
|
||||
[self setView:accView];
|
||||
[accView release];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)exportSettings
|
||||
{
|
||||
return [(PrintPanelAccessoryView*)[self view] exportSettings];
|
||||
}
|
||||
|
||||
- (NSArray *)localizedSummaryItems
|
||||
{
|
||||
return [(PrintPanelAccessoryView*)[self view] localizedSummaryItems];
|
||||
}
|
||||
|
||||
@end
|
@ -46,11 +46,8 @@ class nsPrintOptionsX : public nsPrintOptions
|
||||
public:
|
||||
nsPrintOptionsX();
|
||||
virtual ~nsPrintOptionsX();
|
||||
|
||||
#ifndef MOZ_COCOA_PRINTING
|
||||
NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
|
||||
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
nsresult _CreatePrintSettings(nsIPrintSettings **_retval);
|
||||
|
@ -41,11 +41,9 @@
|
||||
#include "nsPrintOptionsX.h"
|
||||
#include "nsPrintSettingsX.h"
|
||||
|
||||
#ifndef MOZ_COCOA_PRINTING
|
||||
#include "nsCRT.h"
|
||||
#include "plbase64.h"
|
||||
#include "prmem.h"
|
||||
#endif
|
||||
|
||||
nsPrintOptionsX::nsPrintOptionsX()
|
||||
{
|
||||
@ -55,7 +53,6 @@ nsPrintOptionsX::~nsPrintOptionsX()
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef MOZ_COCOA_PRINTING
|
||||
NS_IMETHODIMP
|
||||
nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
|
||||
{
|
||||
@ -70,7 +67,6 @@ nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void **_retval)
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
|
||||
@ -79,19 +75,14 @@ nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
|
||||
|
||||
rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
nsCOMPtr<nsPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
|
||||
#else
|
||||
|
||||
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
|
||||
#endif
|
||||
|
||||
if (!printSettingsX)
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
rv = printSettingsX->ReadPageFormatFromPrefs();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintSettingsX::ReadPageFormatFromPrefs() failed");
|
||||
|
||||
return rv;
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::ReadPageFormatFromPrefs() failed");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
|
||||
@ -121,15 +112,11 @@ nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName
|
||||
rv = nsPrintOptions::WritePrefs(aPS, aPrinterName, aFlags);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
nsCOMPtr<nsPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
|
||||
#else
|
||||
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
|
||||
#endif
|
||||
if (!printSettingsX)
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
rv = printSettingsX->WritePageFormatToPrefs();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintSettingsX::WritePageFormatToPrefs() failed");
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::WritePageFormatToPrefs() failed");
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -39,33 +39,19 @@
|
||||
#define nsPrintSettingsX_h_
|
||||
|
||||
#include "nsPrintSettingsImpl.h"
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#else
|
||||
#include "nsIPrintSettingsX.h"
|
||||
#endif
|
||||
|
||||
class nsPrintSettingsX : public nsPrintSettings
|
||||
#ifndef MOZ_COCOA_PRINTING
|
||||
, public nsIPrintSettingsX
|
||||
#endif
|
||||
class nsPrintSettingsX : public nsPrintSettings,
|
||||
public nsIPrintSettingsX
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
#ifndef MOZ_COCOA_PRINTING
|
||||
NS_DECL_NSIPRINTSETTINGSX
|
||||
#endif
|
||||
|
||||
nsPrintSettingsX();
|
||||
virtual ~nsPrintSettingsX();
|
||||
nsresult Init();
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
NSPrintInfo* GetCocoaPrintInfo() { return mPrintInfo; }
|
||||
virtual nsresult ReadPageFormatFromPrefs();
|
||||
virtual nsresult WritePageFormatToPrefs();
|
||||
#endif
|
||||
nsresult Init();
|
||||
|
||||
protected:
|
||||
nsPrintSettingsX(const nsPrintSettingsX& src);
|
||||
@ -84,9 +70,6 @@ protected:
|
||||
|
||||
PMPageFormat mPageFormat;
|
||||
PMPrintSettings mPrintSettings;
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
NSPrintInfo* mPrintInfo;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // nsPrintSettingsX_h_
|
||||
|
@ -21,7 +21,6 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Conrad Carlen <ccarlen@netscape.com>
|
||||
* Markus Stange <mstange@themasta.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -39,6 +38,7 @@
|
||||
|
||||
#include "nsPrintSettingsX.h"
|
||||
#include "nsObjCExceptions.h"
|
||||
#include "nsIPrintSessionX.h"
|
||||
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
@ -52,28 +52,6 @@
|
||||
#include "nsMenuBarX.h"
|
||||
#include "nsMenuUtilsX.h"
|
||||
|
||||
#define PRINTING_PREF_BRANCH "print."
|
||||
#define MAC_OS_X_PAGE_SETUP_PREFNAME "macosx.pagesetup-2"
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsX, nsPrintSettings, nsPrintSettingsX)
|
||||
|
||||
nsPrintSettingsX::nsPrintSettingsX()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
mPrintInfo = [[NSPrintInfo sharedPrintInfo] copy];
|
||||
mPageFormat = (PMPageFormat)[mPrintInfo PMPageFormat];
|
||||
mPrintSettings = (PMPrintSettings)[mPrintInfo PMPrintSettings];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "nsIPrintSessionX.h"
|
||||
|
||||
// This struct should be represented identically on all architectures, and
|
||||
// there shouldn't be any padding before the data field.
|
||||
struct FrozenHandle {
|
||||
@ -81,6 +59,9 @@ struct FrozenHandle {
|
||||
char data[0];
|
||||
};
|
||||
|
||||
#define PRINTING_PREF_BRANCH "print."
|
||||
#define MAC_OS_X_PAGE_SETUP_PREFNAME "macosx.pagesetup-2"
|
||||
|
||||
// Utility class stack-based handle ownership
|
||||
class StHandleOwner
|
||||
{
|
||||
@ -159,8 +140,6 @@ nsPrintSettingsX::nsPrintSettingsX() :
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsPrintSettingsX::nsPrintSettingsX(const nsPrintSettingsX& src) :
|
||||
mPageFormat(kPMNoPageFormat),
|
||||
mPrintSettings(kPMNoPrintSettings)
|
||||
@ -194,10 +173,6 @@ nsPrintSettingsX& nsPrintSettingsX::operator=(const nsPrintSettingsX& rhs)
|
||||
|
||||
nsPrintSettings::operator=(rhs);
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
[mPrintInfo release];
|
||||
mPrintInfo = [rhs.mPrintInfo copy];
|
||||
#else
|
||||
OSStatus status;
|
||||
|
||||
if (mPageFormat != kPMNoPageFormat) {
|
||||
@ -235,7 +210,6 @@ nsPrintSettingsX& nsPrintSettingsX::operator=(const nsPrintSettingsX& rhs)
|
||||
::PMRelease(printSettings);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
|
||||
@ -246,9 +220,6 @@ nsresult nsPrintSettingsX::Init()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
return InitUnwriteableMargin();
|
||||
#else
|
||||
OSStatus status;
|
||||
|
||||
PMPrintSession printSession = NULL;
|
||||
@ -268,7 +239,6 @@ nsresult nsPrintSettingsX::Init()
|
||||
status = tempStatus;
|
||||
}
|
||||
return (status == noErr) ? NS_OK : NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
@ -295,75 +265,6 @@ NS_IMETHODIMP nsPrintSettingsX::InitUnwriteableMargin()
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
NS_IMETHODIMP nsPrintSettingsX::ReadPageFormatFromPrefs()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefService->GetBranch(PRINTING_PREF_BRANCH, getter_AddRefs(prefBranch));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsXPIDLCString encodedData;
|
||||
rv = prefBranch->GetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, getter_Copies(encodedData));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// decode the base64
|
||||
char* decodedData = PL_Base64Decode(encodedData.get(), encodedData.Length(), nsnull);
|
||||
NSData* data = [NSData dataWithBytes:decodedData length:PL_strlen(decodedData)];
|
||||
if (!data)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PMPageFormat newPageFormat;
|
||||
OSStatus status = ::PMPageFormatCreateWithDataRepresentation((CFDataRef)data, &newPageFormat);
|
||||
if (status == noErr) {
|
||||
::PMCopyPageFormat(newPageFormat, mPageFormat);
|
||||
[mPrintInfo updateFromPMPageFormat];
|
||||
}
|
||||
InitUnwriteableMargin();
|
||||
|
||||
return NS_OK;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::WritePageFormatToPrefs()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
if (mPageFormat == kPMNoPageFormat)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
rv = prefService->GetBranch(PRINTING_PREF_BRANCH, getter_AddRefs(prefBranch));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NSData* data = nil;
|
||||
OSStatus err = ::PMPageFormatCreateDataRepresentation(mPageFormat, (CFDataRef*)&data, kPMDataFormatXMLDefault);
|
||||
if (err != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLCString encodedData;
|
||||
encodedData.Adopt(PL_Base64Encode((char*)[data bytes], [data length], nsnull));
|
||||
if (!encodedData.get())
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return prefBranch->SetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, encodedData);
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
#else
|
||||
NS_IMETHODIMP nsPrintSettingsX::GetNativePrintSession(PMPrintSession *aNativePrintSession)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNativePrintSession);
|
||||
@ -550,7 +451,6 @@ NS_IMETHODIMP nsPrintSettingsX::WritePageFormatToPrefs()
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult nsPrintSettingsX::_Clone(nsIPrintSettings **_retval)
|
||||
{
|
||||
@ -574,7 +474,6 @@ NS_IMETHODIMP nsPrintSettingsX::_Assign(nsIPrintSettings *aPS)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef MOZ_COCOA_PRINTING
|
||||
OSStatus nsPrintSettingsX::CreateDefaultPageFormat(PMPrintSession aSession, PMPageFormat& outFormat)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
@ -632,4 +531,3 @@ NS_IMETHODIMP nsPrintSettingsX::CleanUpAfterCarbonDialog()
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
#endif
|
||||
|
@ -64,13 +64,7 @@
|
||||
#include "nsScreenManagerCocoa.h"
|
||||
#include "nsDeviceContextSpecX.h"
|
||||
#include "nsPrintOptionsX.h"
|
||||
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
#include "nsPrintDialogX.h"
|
||||
#include "nsPrintSession.h"
|
||||
#else
|
||||
#include "nsPrintSessionX.h"
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
|
||||
@ -87,12 +81,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerCocoa)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init)
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceX, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
|
||||
#else
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init)
|
||||
#endif
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceX)
|
||||
|
||||
#include "nsMenuBarX.h"
|
||||
@ -178,25 +167,14 @@ static const nsModuleComponentInfo gComponents[] =
|
||||
NS_DEVICE_CONTEXT_SPEC_CID,
|
||||
"@mozilla.org/gfx/devicecontextspec;1",
|
||||
nsDeviceContextSpecXConstructor },
|
||||
#ifdef MOZ_COCOA_PRINTING
|
||||
{ "Native Print Dialog",
|
||||
NS_PRINTDIALOGSERVICE_CID,
|
||||
NS_PRINTDIALOGSERVICE_CONTRACTID,
|
||||
nsPrintDialogServiceXConstructor },
|
||||
{ "Print Session",
|
||||
NS_PRINTSESSION_CID,
|
||||
"@mozilla.org/gfx/printsession;1",
|
||||
nsPrintSessionConstructor },
|
||||
#else
|
||||
{ "Print Session",
|
||||
NS_PRINTSESSION_CID,
|
||||
"@mozilla.org/gfx/printsession;1",
|
||||
nsPrintSessionXConstructor },
|
||||
#endif
|
||||
{ "PrintSettings Service",
|
||||
NS_PRINTSETTINGSSERVICE_CID,
|
||||
"@mozilla.org/gfx/printsettings-service;1",
|
||||
nsPrintOptionsXConstructor },
|
||||
{ "Print Session",
|
||||
NS_PRINTSESSION_CID,
|
||||
"@mozilla.org/gfx/printsession;1",
|
||||
nsPrintSessionXConstructor },
|
||||
{ "User Idle Service",
|
||||
NS_IDLE_SERVICE_CID,
|
||||
"@mozilla.org/widget/idleservice;1",
|
||||
|
@ -135,7 +135,7 @@ ShowCustomDialog(GtkComboBox *changed_box, gpointer user_data)
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> printBundle;
|
||||
bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", getter_AddRefs(printBundle));
|
||||
bundleSvc->CreateBundle("chrome://global/locale/gnomeprintdialog.properties", getter_AddRefs(printBundle));
|
||||
nsXPIDLString intlString;
|
||||
|
||||
printBundle->GetStringFromName(NS_LITERAL_STRING("headerFooterCustom").get(), getter_Copies(intlString));
|
||||
@ -230,9 +230,9 @@ nsPrintDialogWidgetGTK::nsPrintDialogWidgetGTK(nsIDOMWindow *aParent, nsIPrintSe
|
||||
NS_ASSERTION(gtkParent, "Need a GTK window for dialog to be modal.");
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleSvc = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", getter_AddRefs(printBundle));
|
||||
bundleSvc->CreateBundle("chrome://global/locale/gnomeprintdialog.properties", getter_AddRefs(printBundle));
|
||||
|
||||
dialog = gtk_print_unix_dialog_new(GetUTF8FromBundle("printTitleGTK").get(), gtkParent);
|
||||
dialog = gtk_print_unix_dialog_new(GetUTF8FromBundle("printTitle").get(), gtkParent);
|
||||
|
||||
gtk_print_unix_dialog_set_manual_capabilities(GTK_PRINT_UNIX_DIALOG(dialog),
|
||||
GtkPrintCapabilities(
|
||||
@ -248,7 +248,7 @@ nsPrintDialogWidgetGTK::nsPrintDialogWidgetGTK(nsIDOMWindow *aParent, nsIPrintSe
|
||||
// the set_border_width below, 12px matches that of just about every other window.
|
||||
GtkWidget* custom_options_tab = gtk_vbox_new(FALSE, 0);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(custom_options_tab), 12);
|
||||
GtkWidget* tab_label = gtk_label_new(GetUTF8FromBundle("optionsTabLabelGTK").get());
|
||||
GtkWidget* tab_label = gtk_label_new(GetUTF8FromBundle("optionsTabLabel").get());
|
||||
|
||||
PRInt16 frameUIFlag;
|
||||
aSettings->GetHowToEnableFrameUI(&frameUIFlag);
|
||||
@ -269,7 +269,7 @@ nsPrintDialogWidgetGTK::nsPrintDialogWidgetGTK(nsIDOMWindow *aParent, nsIPrintSe
|
||||
|
||||
// "Print Frames" options label, bold and center-aligned
|
||||
GtkWidget* print_frames_label = gtk_label_new(NULL);
|
||||
char* pangoMarkup = g_markup_printf_escaped("<b>%s</b>", GetUTF8FromBundle("printFramesTitleGTK").get());
|
||||
char* pangoMarkup = g_markup_printf_escaped("<b>%s</b>", GetUTF8FromBundle("printFramesTitle").get());
|
||||
gtk_label_set_markup(GTK_LABEL(print_frames_label), pangoMarkup);
|
||||
g_free(pangoMarkup);
|
||||
gtk_misc_set_alignment(GTK_MISC(print_frames_label), 0, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user