mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 456646 - Replace Carbon printing dialog with Cocoa one. r=josh, r=bsmedberg, sr=jst
--HG-- rename : toolkit/locales/en-US/chrome/global/gnomeprintdialog.properties => toolkit/locales/en-US/chrome/global/printdialog.properties extra : rebase_source : 80b46470b496313b6994366cb953abed5bb0849e
This commit is contained in:
parent
79a79a0e55
commit
5506bd72d5
@ -343,8 +343,10 @@ else
|
|||||||
rm -f $(DIST)/$(APP_NAME).app/Contents/MacOS/$(PROGRAM)
|
rm -f $(DIST)/$(APP_NAME).app/Contents/MacOS/$(PROGRAM)
|
||||||
rsync -aL $(PROGRAM) $(DIST)/$(APP_NAME).app/Contents/MacOS
|
rsync -aL $(PROGRAM) $(DIST)/$(APP_NAME).app/Contents/MacOS
|
||||||
endif
|
endif
|
||||||
|
ifndef MOZ_COCOA_PRINTING
|
||||||
mkdir -p $(DIST)/$(APP_NAME).app/Contents/Plug-Ins
|
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
|
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 -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/firefox.icns $(DIST)/$(APP_NAME).app/Contents/Resources/firefox.icns
|
||||||
cp -RL $(DIST)/branding/document.icns $(DIST)/$(APP_NAME).app/Contents/Resources/document.icns
|
cp -RL $(DIST)/branding/document.icns $(DIST)/$(APP_NAME).app/Contents/Resources/document.icns
|
||||||
|
@ -89,6 +89,7 @@ MOZ_X11 = @MOZ_X11@
|
|||||||
MOZ_PANGO = @MOZ_PANGO@
|
MOZ_PANGO = @MOZ_PANGO@
|
||||||
|
|
||||||
MOZ_CORETEXT = @MOZ_CORETEXT@
|
MOZ_CORETEXT = @MOZ_CORETEXT@
|
||||||
|
MOZ_COCOA_PRINTING = @MOZ_COCOA_PRINTING@
|
||||||
|
|
||||||
MOZ_JS_LIBS = @MOZ_JS_LIBS@
|
MOZ_JS_LIBS = @MOZ_JS_LIBS@
|
||||||
|
|
||||||
|
28
configure.in
28
configure.in
@ -3139,7 +3139,8 @@ case $target in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
dnl Check whether we can compile code for Core Text
|
dnl Check whether we can compile code for Core Text and
|
||||||
|
dnl Cocoa printing
|
||||||
dnl (Mac OS X 10.5 or later)
|
dnl (Mac OS X 10.5 or later)
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
case "$target" in
|
case "$target" in
|
||||||
@ -3147,9 +3148,9 @@ case "$target" in
|
|||||||
AC_MSG_CHECKING([for Core Text])
|
AC_MSG_CHECKING([for Core Text])
|
||||||
AC_TRY_COMPILE([#include <ApplicationServices/ApplicationServices.h>],
|
AC_TRY_COMPILE([#include <ApplicationServices/ApplicationServices.h>],
|
||||||
[CTLineRef lineRef;],
|
[CTLineRef lineRef;],
|
||||||
ac_cv_have_core_text="yes",
|
ac_cv_have_leopard="yes",
|
||||||
ac_cv_have_core_text="no")
|
ac_cv_have_leopard="no")
|
||||||
AC_MSG_RESULT([$ac_cv_have_core_text])
|
AC_MSG_RESULT([$ac_cv_have_leopard])
|
||||||
|
|
||||||
MOZ_CORETEXT=1
|
MOZ_CORETEXT=1
|
||||||
|
|
||||||
@ -3159,15 +3160,30 @@ case "$target" in
|
|||||||
MOZ_CORETEXT=1)
|
MOZ_CORETEXT=1)
|
||||||
|
|
||||||
if test -n "$MOZ_CORETEXT"; then
|
if test -n "$MOZ_CORETEXT"; then
|
||||||
if test "$ac_cv_have_core_text" = "no"; then
|
if test "$ac_cv_have_leopard" = "no"; then
|
||||||
AC_MSG_ERROR([--enable-coretext requires MacOS SDK 10.5 or newer])
|
AC_MSG_ERROR([--enable-coretext requires MacOS SDK 10.5 or newer])
|
||||||
fi
|
fi
|
||||||
AC_DEFINE(MOZ_CORETEXT)
|
AC_DEFINE(MOZ_CORETEXT)
|
||||||
fi
|
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
|
esac
|
||||||
|
|
||||||
AC_SUBST(MOZ_CORETEXT)
|
AC_SUBST(MOZ_COCOA_PRINTING)
|
||||||
|
|
||||||
XLDFLAGS="$X_LIBS"
|
XLDFLAGS="$X_LIBS"
|
||||||
XLIBS="$X_EXTRA_LIBS"
|
XLIBS="$X_EXTRA_LIBS"
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
# ***** 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,7 +14,6 @@
|
|||||||
locale/@AB_CD@/global/global-strres.properties (%chrome/global-strres.properties)
|
locale/@AB_CD@/global/global-strres.properties (%chrome/global-strres.properties)
|
||||||
locale/@AB_CD@/global/plugins.properties (%chrome/plugins.properties)
|
locale/@AB_CD@/global/plugins.properties (%chrome/plugins.properties)
|
||||||
locale/@AB_CD@/global/nsWebBrowserPersist.properties (%chrome/nsWebBrowserPersist.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/xslt/xslt.properties (%chrome/xslt/xslt.properties)
|
||||||
locale/@AB_CD@/global/dom/dom.properties (%chrome/dom/dom.properties)
|
locale/@AB_CD@/global/dom/dom.properties (%chrome/dom/dom.properties)
|
||||||
#ifdef MOZ_SVG
|
#ifdef MOZ_SVG
|
||||||
|
@ -47,7 +47,9 @@ LIBRARY_NAME = printingui_s
|
|||||||
LIBXUL_LIBRARY = 1
|
LIBXUL_LIBRARY = 1
|
||||||
|
|
||||||
|
|
||||||
|
ifndef MOZ_COCOA_PRINTING
|
||||||
DIRS = printpde
|
DIRS = printpde
|
||||||
|
endif
|
||||||
|
|
||||||
CMMSRCS = nsPrintingPromptServiceX.mm
|
CMMSRCS = nsPrintingPromptServiceX.mm
|
||||||
|
|
||||||
@ -56,9 +58,9 @@ CPPSRCS = \
|
|||||||
nsPrintProgress.cpp \
|
nsPrintProgress.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
LOCAL_INCLUDES = \
|
ifndef MOZ_COCOA_PRINTING
|
||||||
-I$(srcdir)/printpde/public \
|
LOCAL_INCLUDES = -I$(srcdir)/printpde/public
|
||||||
$(NULL)
|
endif
|
||||||
|
|
||||||
# we don't want the shared lib, but we want to force the creation of a
|
# we don't want the shared lib, but we want to force the creation of a
|
||||||
# static lib.
|
# static lib.
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
|
|
||||||
// Printing Progress Includes
|
// Printing Progress Includes
|
||||||
#include "nsPrintProgress.h"
|
#include "nsPrintProgress.h"
|
||||||
#include "nsPrintProgressParams.h"
|
|
||||||
#include "nsIWebProgressListener.h"
|
#include "nsIWebProgressListener.h"
|
||||||
|
|
||||||
|
|
||||||
@ -72,9 +71,7 @@ public:
|
|||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsIWindowWatcher> mWatcher;
|
|
||||||
nsCOMPtr<nsIPrintProgress> mPrintProgress;
|
nsCOMPtr<nsIPrintProgress> mPrintProgress;
|
||||||
nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,6 +44,14 @@
|
|||||||
|
|
||||||
#include "nsIPrintingPromptService.h"
|
#include "nsIPrintingPromptService.h"
|
||||||
#include "nsIFactory.h"
|
#include "nsIFactory.h"
|
||||||
|
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
|
||||||
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsIPrintDialogService.h"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#include "nsIDOMWindow.h"
|
#include "nsIDOMWindow.h"
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
#include "nsIEmbeddingSiteWindow.h"
|
#include "nsIEmbeddingSiteWindow.h"
|
||||||
@ -192,6 +200,7 @@ SetDictionaryBooleanvalue(CFMutableDictionaryRef aDictionary, CFStringRef aKey,
|
|||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// nsPrintingPromptService
|
// nsPrintingPromptService
|
||||||
@ -199,8 +208,7 @@ SetDictionaryBooleanvalue(CFMutableDictionaryRef aDictionary, CFStringRef aKey,
|
|||||||
|
|
||||||
NS_IMPL_ISUPPORTS2(nsPrintingPromptService, nsIPrintingPromptService, nsIWebProgressListener)
|
NS_IMPL_ISUPPORTS2(nsPrintingPromptService, nsIPrintingPromptService, nsIWebProgressListener)
|
||||||
|
|
||||||
nsPrintingPromptService::nsPrintingPromptService() :
|
nsPrintingPromptService::nsPrintingPromptService()
|
||||||
mWatcher(do_GetService(NS_WINDOWWATCHER_CONTRACTID))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,6 +225,39 @@ nsresult nsPrintingPromptService::Init()
|
|||||||
// nsPrintingPromptService::nsIPrintingPromptService
|
// 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
|
NS_IMETHODIMP
|
||||||
nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
|
nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
|
||||||
{
|
{
|
||||||
@ -443,19 +484,6 @@ nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrin
|
|||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
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
|
NS_IMETHODIMP
|
||||||
nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
|
nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
|
||||||
{
|
{
|
||||||
@ -502,6 +530,21 @@ nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *p
|
|||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
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
|
NS_IMETHODIMP
|
||||||
nsPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const PRUnichar *printerName, nsIPrintSettings *printSettings)
|
nsPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const PRUnichar *printerName, nsIPrintSettings *printSettings)
|
||||||
{
|
{
|
||||||
@ -516,13 +559,6 @@ nsPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const PRUni
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus)
|
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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,9 +566,6 @@ nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
|
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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,9 +573,6 @@ nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
|
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
|
||||||
{
|
{
|
||||||
if (mWebProgressListener) {
|
|
||||||
return mWebProgressListener->OnLocationChange(aWebProgress, aRequest, location);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,9 +580,6 @@ nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIReque
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
|
nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
|
||||||
{
|
{
|
||||||
if (mWebProgressListener) {
|
|
||||||
return mWebProgressListener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,8 +587,5 @@ nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPrintingPromptService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state)
|
nsPrintingPromptService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state)
|
||||||
{
|
{
|
||||||
if (mWebProgressListener) {
|
|
||||||
return mWebProgressListener->OnSecurityChange(aWebProgress, aRequest, state);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -463,10 +463,10 @@ typedef struct {
|
|||||||
// These are the control ids used in the dialog and
|
// These are the control ids used in the dialog and
|
||||||
// defined by MS-Windows in commdlg.h
|
// defined by MS-Windows in commdlg.h
|
||||||
static PropKeyInfo gAllPropKeys[] = {
|
static PropKeyInfo gAllPropKeys[] = {
|
||||||
{"PrintFrames", grp3},
|
{"printFramesTitleWindows", grp3},
|
||||||
{"Aslaid", rad4},
|
{"asLaidOutWindows", rad4},
|
||||||
{"selectedframe", rad5},
|
{"selectedFrameWindows", rad5},
|
||||||
{"Eachframe", rad6},
|
{"separateFramesWindows", rad6},
|
||||||
{NULL, NULL}};
|
{NULL, NULL}};
|
||||||
|
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
@ -1280,7 +1280,7 @@ ShowNativePrintDialogEx(HWND aHWnd,
|
|||||||
// lLcalize the Property Sheet (Tab) title
|
// lLcalize the Property Sheet (Tab) title
|
||||||
nsCAutoString title;
|
nsCAutoString title;
|
||||||
nsString optionsStr;
|
nsString optionsStr;
|
||||||
if (NS_SUCCEEDED(GetLocalizedString(strBundle, "options", optionsStr))) {
|
if (NS_SUCCEEDED(GetLocalizedString(strBundle, "optionsTitleWindows", optionsStr))) {
|
||||||
// Failure here just means a blank string
|
// Failure here just means a blank string
|
||||||
NS_CopyUnicodeToNative(optionsStr, title);
|
NS_CopyUnicodeToNative(optionsStr, title);
|
||||||
}
|
}
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
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
|
|
59
toolkit/locales/en-US/chrome/global/printdialog.properties
Normal file
59
toolkit/locales/en-US/chrome/global/printdialog.properties
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# 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/mozilla.dtd (%chrome/global/mozilla.dtd)
|
||||||
locale/@AB_CD@/global/notification.dtd (%chrome/global/notification.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/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/printjoboptions.dtd (%chrome/global/printjoboptions.dtd)
|
||||||
+ locale/@AB_CD@/global/printPageSetup.dtd (%chrome/global/printPageSetup.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/printPreview.dtd (%chrome/global/printPreview.dtd)
|
||||||
+ locale/@AB_CD@/global/printPreviewProgress.dtd (%chrome/global/printPreviewProgress.dtd)
|
+ locale/@AB_CD@/global/printPreviewProgress.dtd (%chrome/global/printPreviewProgress.dtd)
|
||||||
locale/@AB_CD@/global/gnomeprintdialog.properties (%chrome/global/gnomeprintdialog.properties)
|
+ locale/@AB_CD@/global/printdialog.properties (%chrome/global/printdialog.properties)
|
||||||
+ locale/@AB_CD@/global/printProgress.dtd (%chrome/global/printProgress.dtd)
|
+ locale/@AB_CD@/global/printProgress.dtd (%chrome/global/printProgress.dtd)
|
||||||
+ locale/@AB_CD@/global/regionNames.properties (%chrome/global/regionNames.properties)
|
+ locale/@AB_CD@/global/regionNames.properties (%chrome/global/regionNames.properties)
|
||||||
+ locale/@AB_CD@/global/dialog.properties (%chrome/global/dialog.properties)
|
+ locale/@AB_CD@/global/dialog.properties (%chrome/global/dialog.properties)
|
||||||
|
@ -64,6 +64,12 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
|||||||
EXPORTS += nsINativeMenuService.h
|
EXPORTS += nsINativeMenuService.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef MOZ_COCOA_PRINTING
|
||||||
|
EXPORTS += \
|
||||||
|
nsIPrintDialogService.h \
|
||||||
|
$(NULL)
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||||
EXPORTS += nsIDragSessionOS2.h
|
EXPORTS += nsIDragSessionOS2.h
|
||||||
endif
|
endif
|
||||||
@ -111,9 +117,11 @@ XPIDLSRCS += nsIPrintSettingsWin.idl
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||||
|
ifndef MOZ_COCOA_PRINTING
|
||||||
XPIDLSRCS += nsIPrintSettingsX.idl \
|
XPIDLSRCS += nsIPrintSettingsX.idl \
|
||||||
nsIPrintSessionX.idl
|
nsIPrintSessionX.idl
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||||
XPIDLSRCS += nsIRwsService.idl
|
XPIDLSRCS += nsIRwsService.idl
|
||||||
|
@ -85,11 +85,16 @@ CMMSRCS = \
|
|||||||
nsDeviceContextSpecX.mm \
|
nsDeviceContextSpecX.mm \
|
||||||
nsPrintOptionsX.mm \
|
nsPrintOptionsX.mm \
|
||||||
nsPrintSettingsX.mm \
|
nsPrintSettingsX.mm \
|
||||||
nsPrintSessionX.mm \
|
|
||||||
nsIdleServiceX.mm \
|
nsIdleServiceX.mm \
|
||||||
nsAccelerometerX.mm \
|
nsAccelerometerX.mm \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
ifdef MOZ_COCOA_PRINTING
|
||||||
|
CMMSRCS += nsPrintDialogX.mm
|
||||||
|
else
|
||||||
|
CMMSRCS += nsPrintSessionX.mm
|
||||||
|
endif
|
||||||
|
|
||||||
XPIDLSRCS += \
|
XPIDLSRCS += \
|
||||||
nsPIWidgetCocoa.idl \
|
nsPIWidgetCocoa.idl \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
@ -41,14 +41,19 @@
|
|||||||
|
|
||||||
#include "nsIDeviceContextSpec.h"
|
#include "nsIDeviceContextSpec.h"
|
||||||
|
|
||||||
#include <Carbon/Carbon.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
#include <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
class nsDeviceContextSpecX : public nsIDeviceContextSpec
|
class nsDeviceContextSpecX : public nsIDeviceContextSpec
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
nsDeviceContextSpecX();
|
nsDeviceContextSpecX();
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||||
NS_IMETHOD GetSurfaceForPrinter(gfxASurface **surface);
|
NS_IMETHOD GetSurfaceForPrinter(gfxASurface **surface);
|
||||||
NS_IMETHOD BeginDocument(PRUnichar* aTitle,
|
NS_IMETHOD BeginDocument(PRUnichar* aTitle,
|
||||||
PRUnichar* aPrintToFileName,
|
PRUnichar* aPrintToFileName,
|
||||||
@ -58,24 +63,18 @@ public:
|
|||||||
NS_IMETHOD BeginPage();
|
NS_IMETHOD BeginPage();
|
||||||
NS_IMETHOD EndPage();
|
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);
|
void GetPaperRect(double* aTop, double* aLeft, double* aBottom, double* aRight);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~nsDeviceContextSpecX();
|
virtual ~nsDeviceContextSpecX();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PMPrintSession mPrintSession; // printing context.
|
PMPrintSession mPrintSession; // printing context.
|
||||||
PMPageFormat mPageFormat; // page format.
|
PMPageFormat mPageFormat; // page format.
|
||||||
PMPrintSettings mPrintSettings; // print settings.
|
PMPrintSettings mPrintSettings; // print settings.
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
NSPrintInfo* mPrintInfo; // Cocoa print info.
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //nsDeviceContextSpecX_h_
|
#endif //nsDeviceContextSpecX_h_
|
||||||
|
@ -48,15 +48,23 @@
|
|||||||
|
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIPrintOptions.h"
|
#include "nsIPrintOptions.h"
|
||||||
#include "nsIPrintSettingsX.h"
|
|
||||||
|
|
||||||
#include "gfxQuartzSurface.h"
|
#include "gfxQuartzSurface.h"
|
||||||
#include "gfxImageSurface.h"
|
#include "gfxImageSurface.h"
|
||||||
|
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
#include "nsPrintSettingsX.h"
|
||||||
|
#else
|
||||||
|
#include "nsIPrintSettingsX.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
nsDeviceContextSpecX::nsDeviceContextSpecX()
|
nsDeviceContextSpecX::nsDeviceContextSpecX()
|
||||||
: mPrintSession(NULL)
|
: mPrintSession(NULL)
|
||||||
, mPageFormat(kPMNoPageFormat)
|
, mPageFormat(kPMNoPageFormat)
|
||||||
, mPrintSettings(kPMNoPrintSettings)
|
, mPrintSettings(kPMNoPrintSettings)
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
, mPrintInfo(nil)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +86,17 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIWidget *aWidget,
|
|||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
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;
|
nsresult rv;
|
||||||
|
|
||||||
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
|
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
|
||||||
@ -86,7 +105,7 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIWidget *aWidget,
|
|||||||
|
|
||||||
rv = printSettingsX->GetNativePrintSession(&mPrintSession);
|
rv = printSettingsX->GetNativePrintSession(&mPrintSession);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
::PMRetain(mPrintSession);
|
::PMRetain(mPrintSession);
|
||||||
|
|
||||||
rv = printSettingsX->GetPMPageFormat(&mPageFormat);
|
rv = printSettingsX->GetPMPageFormat(&mPageFormat);
|
||||||
@ -96,6 +115,7 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIWidget *aWidget,
|
|||||||
rv = printSettingsX->GetPMPrintSettings(&mPrintSettings);
|
rv = printSettingsX->GetPMPrintSettings(&mPrintSettings);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
#endif
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
@ -142,13 +162,6 @@ NS_IMETHODIMP nsDeviceContextSpecX::EndDocument()
|
|||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
NS_IMETHODIMP nsDeviceContextSpecX::AbortDocument()
|
|
||||||
{
|
|
||||||
return EndDocument();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDeviceContextSpecX::BeginPage()
|
NS_IMETHODIMP nsDeviceContextSpecX::BeginPage()
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
97
widget/src/cocoa/nsPrintDialogX.h
Normal file
97
widget/src/cocoa/nsPrintDialogX.h
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/* -*- 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
|
615
widget/src/cocoa/nsPrintDialogX.mm
Normal file
615
widget/src/cocoa/nsPrintDialogX.mm
Normal file
@ -0,0 +1,615 @@
|
|||||||
|
/* -*- 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,8 +46,11 @@ class nsPrintOptionsX : public nsPrintOptions
|
|||||||
public:
|
public:
|
||||||
nsPrintOptionsX();
|
nsPrintOptionsX();
|
||||||
virtual ~nsPrintOptionsX();
|
virtual ~nsPrintOptionsX();
|
||||||
|
|
||||||
|
#ifndef MOZ_COCOA_PRINTING
|
||||||
NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
|
NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
|
||||||
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
|
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsresult _CreatePrintSettings(nsIPrintSettings **_retval);
|
nsresult _CreatePrintSettings(nsIPrintSettings **_retval);
|
||||||
|
@ -41,9 +41,11 @@
|
|||||||
#include "nsPrintOptionsX.h"
|
#include "nsPrintOptionsX.h"
|
||||||
#include "nsPrintSettingsX.h"
|
#include "nsPrintSettingsX.h"
|
||||||
|
|
||||||
|
#ifndef MOZ_COCOA_PRINTING
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "plbase64.h"
|
#include "plbase64.h"
|
||||||
#include "prmem.h"
|
#include "prmem.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
nsPrintOptionsX::nsPrintOptionsX()
|
nsPrintOptionsX::nsPrintOptionsX()
|
||||||
{
|
{
|
||||||
@ -53,6 +55,7 @@ nsPrintOptionsX::~nsPrintOptionsX()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MOZ_COCOA_PRINTING
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
|
nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
|
||||||
{
|
{
|
||||||
@ -67,6 +70,7 @@ nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void **_retval)
|
|||||||
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
|
nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
|
||||||
@ -75,14 +79,19 @@ nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
|
|||||||
|
|
||||||
rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags);
|
rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags);
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
|
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));
|
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!printSettingsX)
|
if (!printSettingsX)
|
||||||
return NS_ERROR_NO_INTERFACE;
|
return NS_ERROR_NO_INTERFACE;
|
||||||
rv = printSettingsX->ReadPageFormatFromPrefs();
|
rv = printSettingsX->ReadPageFormatFromPrefs();
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::ReadPageFormatFromPrefs() failed");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintSettingsX::ReadPageFormatFromPrefs() failed");
|
||||||
|
|
||||||
return NS_OK;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
|
nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
|
||||||
@ -112,11 +121,15 @@ nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName
|
|||||||
rv = nsPrintOptions::WritePrefs(aPS, aPrinterName, aFlags);
|
rv = nsPrintOptions::WritePrefs(aPS, aPrinterName, aFlags);
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
|
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));
|
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
|
||||||
|
#endif
|
||||||
if (!printSettingsX)
|
if (!printSettingsX)
|
||||||
return NS_ERROR_NO_INTERFACE;
|
return NS_ERROR_NO_INTERFACE;
|
||||||
rv = printSettingsX->WritePageFormatToPrefs();
|
rv = printSettingsX->WritePageFormatToPrefs();
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::WritePageFormatToPrefs() failed");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintSettingsX::WritePageFormatToPrefs() failed");
|
||||||
|
|
||||||
return NS_OK;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -39,20 +39,34 @@
|
|||||||
#define nsPrintSettingsX_h_
|
#define nsPrintSettingsX_h_
|
||||||
|
|
||||||
#include "nsPrintSettingsImpl.h"
|
#include "nsPrintSettingsImpl.h"
|
||||||
#include "nsIPrintSettingsX.h"
|
|
||||||
|
|
||||||
class nsPrintSettingsX : public nsPrintSettings,
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
public nsIPrintSettingsX
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#else
|
||||||
|
#include "nsIPrintSettingsX.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class nsPrintSettingsX : public nsPrintSettings
|
||||||
|
#ifndef MOZ_COCOA_PRINTING
|
||||||
|
, public nsIPrintSettingsX
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
#ifndef MOZ_COCOA_PRINTING
|
||||||
NS_DECL_NSIPRINTSETTINGSX
|
NS_DECL_NSIPRINTSETTINGSX
|
||||||
|
#endif
|
||||||
|
|
||||||
nsPrintSettingsX();
|
nsPrintSettingsX();
|
||||||
virtual ~nsPrintSettingsX();
|
virtual ~nsPrintSettingsX();
|
||||||
|
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
|
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
NSPrintInfo* GetCocoaPrintInfo() { return mPrintInfo; }
|
||||||
|
virtual nsresult ReadPageFormatFromPrefs();
|
||||||
|
virtual nsresult WritePageFormatToPrefs();
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsPrintSettingsX(const nsPrintSettingsX& src);
|
nsPrintSettingsX(const nsPrintSettingsX& src);
|
||||||
nsPrintSettingsX& operator=(const nsPrintSettingsX& rhs);
|
nsPrintSettingsX& operator=(const nsPrintSettingsX& rhs);
|
||||||
@ -70,6 +84,9 @@ protected:
|
|||||||
|
|
||||||
PMPageFormat mPageFormat;
|
PMPageFormat mPageFormat;
|
||||||
PMPrintSettings mPrintSettings;
|
PMPrintSettings mPrintSettings;
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
NSPrintInfo* mPrintInfo;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsPrintSettingsX_h_
|
#endif // nsPrintSettingsX_h_
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Conrad Carlen <ccarlen@netscape.com>
|
* Conrad Carlen <ccarlen@netscape.com>
|
||||||
|
* Markus Stange <mstange@themasta.com>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* 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"),
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||||
@ -38,7 +39,6 @@
|
|||||||
|
|
||||||
#include "nsPrintSettingsX.h"
|
#include "nsPrintSettingsX.h"
|
||||||
#include "nsObjCExceptions.h"
|
#include "nsObjCExceptions.h"
|
||||||
#include "nsIPrintSessionX.h"
|
|
||||||
|
|
||||||
#include "nsIPrefService.h"
|
#include "nsIPrefService.h"
|
||||||
#include "nsIPrefBranch.h"
|
#include "nsIPrefBranch.h"
|
||||||
@ -52,6 +52,28 @@
|
|||||||
#include "nsMenuBarX.h"
|
#include "nsMenuBarX.h"
|
||||||
#include "nsMenuUtilsX.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
|
// This struct should be represented identically on all architectures, and
|
||||||
// there shouldn't be any padding before the data field.
|
// there shouldn't be any padding before the data field.
|
||||||
struct FrozenHandle {
|
struct FrozenHandle {
|
||||||
@ -59,9 +81,6 @@ struct FrozenHandle {
|
|||||||
char data[0];
|
char data[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PRINTING_PREF_BRANCH "print."
|
|
||||||
#define MAC_OS_X_PAGE_SETUP_PREFNAME "macosx.pagesetup-2"
|
|
||||||
|
|
||||||
// Utility class stack-based handle ownership
|
// Utility class stack-based handle ownership
|
||||||
class StHandleOwner
|
class StHandleOwner
|
||||||
{
|
{
|
||||||
@ -140,6 +159,8 @@ nsPrintSettingsX::nsPrintSettingsX() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
nsPrintSettingsX::nsPrintSettingsX(const nsPrintSettingsX& src) :
|
nsPrintSettingsX::nsPrintSettingsX(const nsPrintSettingsX& src) :
|
||||||
mPageFormat(kPMNoPageFormat),
|
mPageFormat(kPMNoPageFormat),
|
||||||
mPrintSettings(kPMNoPrintSettings)
|
mPrintSettings(kPMNoPrintSettings)
|
||||||
@ -173,6 +194,10 @@ nsPrintSettingsX& nsPrintSettingsX::operator=(const nsPrintSettingsX& rhs)
|
|||||||
|
|
||||||
nsPrintSettings::operator=(rhs);
|
nsPrintSettings::operator=(rhs);
|
||||||
|
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
[mPrintInfo release];
|
||||||
|
mPrintInfo = [rhs.mPrintInfo copy];
|
||||||
|
#else
|
||||||
OSStatus status;
|
OSStatus status;
|
||||||
|
|
||||||
if (mPageFormat != kPMNoPageFormat) {
|
if (mPageFormat != kPMNoPageFormat) {
|
||||||
@ -210,6 +235,7 @@ nsPrintSettingsX& nsPrintSettingsX::operator=(const nsPrintSettingsX& rhs)
|
|||||||
::PMRelease(printSettings);
|
::PMRelease(printSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
@ -220,6 +246,9 @@ nsresult nsPrintSettingsX::Init()
|
|||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
return InitUnwriteableMargin();
|
||||||
|
#else
|
||||||
OSStatus status;
|
OSStatus status;
|
||||||
|
|
||||||
PMPrintSession printSession = NULL;
|
PMPrintSession printSession = NULL;
|
||||||
@ -239,6 +268,7 @@ nsresult nsPrintSettingsX::Init()
|
|||||||
status = tempStatus;
|
status = tempStatus;
|
||||||
}
|
}
|
||||||
return (status == noErr) ? NS_OK : NS_ERROR_FAILURE;
|
return (status == noErr) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
}
|
}
|
||||||
@ -265,6 +295,75 @@ NS_IMETHODIMP nsPrintSettingsX::InitUnwriteableMargin()
|
|||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
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_IMETHODIMP nsPrintSettingsX::GetNativePrintSession(PMPrintSession *aNativePrintSession)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aNativePrintSession);
|
NS_ENSURE_ARG_POINTER(aNativePrintSession);
|
||||||
@ -451,6 +550,7 @@ NS_IMETHODIMP nsPrintSettingsX::WritePageFormatToPrefs()
|
|||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
nsresult nsPrintSettingsX::_Clone(nsIPrintSettings **_retval)
|
nsresult nsPrintSettingsX::_Clone(nsIPrintSettings **_retval)
|
||||||
{
|
{
|
||||||
@ -474,6 +574,7 @@ NS_IMETHODIMP nsPrintSettingsX::_Assign(nsIPrintSettings *aPS)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MOZ_COCOA_PRINTING
|
||||||
OSStatus nsPrintSettingsX::CreateDefaultPageFormat(PMPrintSession aSession, PMPageFormat& outFormat)
|
OSStatus nsPrintSettingsX::CreateDefaultPageFormat(PMPrintSession aSession, PMPageFormat& outFormat)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||||
@ -531,3 +632,4 @@ NS_IMETHODIMP nsPrintSettingsX::CleanUpAfterCarbonDialog()
|
|||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -64,7 +64,13 @@
|
|||||||
#include "nsScreenManagerCocoa.h"
|
#include "nsScreenManagerCocoa.h"
|
||||||
#include "nsDeviceContextSpecX.h"
|
#include "nsDeviceContextSpecX.h"
|
||||||
#include "nsPrintOptionsX.h"
|
#include "nsPrintOptionsX.h"
|
||||||
|
|
||||||
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
|
#include "nsPrintDialogX.h"
|
||||||
|
#include "nsPrintSession.h"
|
||||||
|
#else
|
||||||
#include "nsPrintSessionX.h"
|
#include "nsPrintSessionX.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
|
||||||
@ -81,7 +87,12 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
|||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerCocoa)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerCocoa)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init)
|
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)
|
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init)
|
||||||
|
#endif
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceX)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceX)
|
||||||
|
|
||||||
#include "nsMenuBarX.h"
|
#include "nsMenuBarX.h"
|
||||||
@ -167,14 +178,25 @@ static const nsModuleComponentInfo gComponents[] =
|
|||||||
NS_DEVICE_CONTEXT_SPEC_CID,
|
NS_DEVICE_CONTEXT_SPEC_CID,
|
||||||
"@mozilla.org/gfx/devicecontextspec;1",
|
"@mozilla.org/gfx/devicecontextspec;1",
|
||||||
nsDeviceContextSpecXConstructor },
|
nsDeviceContextSpecXConstructor },
|
||||||
{ "PrintSettings Service",
|
#ifdef MOZ_COCOA_PRINTING
|
||||||
NS_PRINTSETTINGSSERVICE_CID,
|
{ "Native Print Dialog",
|
||||||
"@mozilla.org/gfx/printsettings-service;1",
|
NS_PRINTDIALOGSERVICE_CID,
|
||||||
nsPrintOptionsXConstructor },
|
NS_PRINTDIALOGSERVICE_CONTRACTID,
|
||||||
|
nsPrintDialogServiceXConstructor },
|
||||||
|
{ "Print Session",
|
||||||
|
NS_PRINTSESSION_CID,
|
||||||
|
"@mozilla.org/gfx/printsession;1",
|
||||||
|
nsPrintSessionConstructor },
|
||||||
|
#else
|
||||||
{ "Print Session",
|
{ "Print Session",
|
||||||
NS_PRINTSESSION_CID,
|
NS_PRINTSESSION_CID,
|
||||||
"@mozilla.org/gfx/printsession;1",
|
"@mozilla.org/gfx/printsession;1",
|
||||||
nsPrintSessionXConstructor },
|
nsPrintSessionXConstructor },
|
||||||
|
#endif
|
||||||
|
{ "PrintSettings Service",
|
||||||
|
NS_PRINTSETTINGSSERVICE_CID,
|
||||||
|
"@mozilla.org/gfx/printsettings-service;1",
|
||||||
|
nsPrintOptionsXConstructor },
|
||||||
{ "User Idle Service",
|
{ "User Idle Service",
|
||||||
NS_IDLE_SERVICE_CID,
|
NS_IDLE_SERVICE_CID,
|
||||||
"@mozilla.org/widget/idleservice;1",
|
"@mozilla.org/widget/idleservice;1",
|
||||||
|
@ -135,7 +135,7 @@ ShowCustomDialog(GtkComboBox *changed_box, gpointer user_data)
|
|||||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||||
|
|
||||||
nsCOMPtr<nsIStringBundle> printBundle;
|
nsCOMPtr<nsIStringBundle> printBundle;
|
||||||
bundleSvc->CreateBundle("chrome://global/locale/gnomeprintdialog.properties", getter_AddRefs(printBundle));
|
bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", getter_AddRefs(printBundle));
|
||||||
nsXPIDLString intlString;
|
nsXPIDLString intlString;
|
||||||
|
|
||||||
printBundle->GetStringFromName(NS_LITERAL_STRING("headerFooterCustom").get(), getter_Copies(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.");
|
NS_ASSERTION(gtkParent, "Need a GTK window for dialog to be modal.");
|
||||||
|
|
||||||
nsCOMPtr<nsIStringBundleService> bundleSvc = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
nsCOMPtr<nsIStringBundleService> bundleSvc = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||||
bundleSvc->CreateBundle("chrome://global/locale/gnomeprintdialog.properties", getter_AddRefs(printBundle));
|
bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", getter_AddRefs(printBundle));
|
||||||
|
|
||||||
dialog = gtk_print_unix_dialog_new(GetUTF8FromBundle("printTitle").get(), gtkParent);
|
dialog = gtk_print_unix_dialog_new(GetUTF8FromBundle("printTitleGTK").get(), gtkParent);
|
||||||
|
|
||||||
gtk_print_unix_dialog_set_manual_capabilities(GTK_PRINT_UNIX_DIALOG(dialog),
|
gtk_print_unix_dialog_set_manual_capabilities(GTK_PRINT_UNIX_DIALOG(dialog),
|
||||||
GtkPrintCapabilities(
|
GtkPrintCapabilities(
|
||||||
@ -248,7 +248,7 @@ nsPrintDialogWidgetGTK::nsPrintDialogWidgetGTK(nsIDOMWindow *aParent, nsIPrintSe
|
|||||||
// the set_border_width below, 12px matches that of just about every other window.
|
// the set_border_width below, 12px matches that of just about every other window.
|
||||||
GtkWidget* custom_options_tab = gtk_vbox_new(FALSE, 0);
|
GtkWidget* custom_options_tab = gtk_vbox_new(FALSE, 0);
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(custom_options_tab), 12);
|
gtk_container_set_border_width(GTK_CONTAINER(custom_options_tab), 12);
|
||||||
GtkWidget* tab_label = gtk_label_new(GetUTF8FromBundle("optionsTabLabel").get());
|
GtkWidget* tab_label = gtk_label_new(GetUTF8FromBundle("optionsTabLabelGTK").get());
|
||||||
|
|
||||||
PRInt16 frameUIFlag;
|
PRInt16 frameUIFlag;
|
||||||
aSettings->GetHowToEnableFrameUI(&frameUIFlag);
|
aSettings->GetHowToEnableFrameUI(&frameUIFlag);
|
||||||
@ -269,7 +269,7 @@ nsPrintDialogWidgetGTK::nsPrintDialogWidgetGTK(nsIDOMWindow *aParent, nsIPrintSe
|
|||||||
|
|
||||||
// "Print Frames" options label, bold and center-aligned
|
// "Print Frames" options label, bold and center-aligned
|
||||||
GtkWidget* print_frames_label = gtk_label_new(NULL);
|
GtkWidget* print_frames_label = gtk_label_new(NULL);
|
||||||
char* pangoMarkup = g_markup_printf_escaped("<b>%s</b>", GetUTF8FromBundle("printFramesTitle").get());
|
char* pangoMarkup = g_markup_printf_escaped("<b>%s</b>", GetUTF8FromBundle("printFramesTitleGTK").get());
|
||||||
gtk_label_set_markup(GTK_LABEL(print_frames_label), pangoMarkup);
|
gtk_label_set_markup(GTK_LABEL(print_frames_label), pangoMarkup);
|
||||||
g_free(pangoMarkup);
|
g_free(pangoMarkup);
|
||||||
gtk_misc_set_alignment(GTK_MISC(print_frames_label), 0, 0);
|
gtk_misc_set_alignment(GTK_MISC(print_frames_label), 0, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user