This commit is contained in:
pavlov%pavlov.net 2006-11-30 02:12:03 +00:00
Родитель c3a0763e5f
Коммит 105a014990
7 изменённых файлов: 240 добавлений и 2 удалений

Просмотреть файл

@ -68,7 +68,10 @@ DIRS += freetype
endif
ifdef MOZ_ENABLE_POSTSCRIPT
DIRS += psshared ps
DIRS += psshared
ifndef MOZ_ENABLE_CAIRO_GFX
DIRS += ps
endif
endif
# Build xlibrgb only for X toolkits and/or Xprint

Просмотреть файл

@ -113,6 +113,7 @@ CPPSRCS = \
nsAccessibilityHelper.cpp \
nsPrintJobFactoryGTK.cpp \
nsPrintJobGTK.cpp \
nsTempfilePS.cpp \
$(NULL)
# build our subdirs, too

Просмотреть файл

@ -391,6 +391,10 @@ nsDeviceContextSpecGTK::~nsDeviceContextSpecGTK()
}
/* Use both PostScript and Xprint module */
#ifdef MOZ_CAIRO_GFX
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK,
nsIDeviceContextSpec)
#else
#if defined(USE_XPRINT) && defined(USE_POSTSCRIPT)
NS_IMPL_ISUPPORTS3(nsDeviceContextSpecGTK,
nsIDeviceContextSpec,
@ -413,6 +417,7 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK,
#else
#error "This should not happen"
#endif
#endif
#ifdef MOZ_CAIRO_GFX
//#define USE_PDF 1

Просмотреть файл

@ -44,12 +44,16 @@
#include "nsIPrintOptions.h"
#include "nsVoidArray.h"
#include "nsCOMPtr.h"
#ifndef MOZ_CAIRO_GFX
#ifdef USE_POSTSCRIPT
#include "nsIDeviceContextSpecPS.h"
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
#include "nsIDeviceContextSpecXPrint.h"
#endif /* USE_XPRINT */
#endif
#include "nsCRT.h" /* should be <limits.h>? */
#include "nsIPrintJobGTK.h"
@ -65,12 +69,14 @@ typedef enum
} PrintMethod;
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec
#ifndef MOZ_CAIRO_GFX
#ifdef USE_POSTSCRIPT
, public nsIDeviceContextSpecPS
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
, public nsIDeviceContextSpecXp
#endif /* USE_XPRINT */
#endif
{
public:
nsDeviceContextSpecGTK();

Просмотреть файл

@ -39,7 +39,6 @@
#include "nscore.h"
#include "nsIDeviceContext.h" // NS_ERROR_GFX_*
#include "nsIDeviceContextPS.h" // NS_POSTSCRIPT_DRIVER_NAME_LEN
#include "nsIDeviceContextSpec.h"
#include "nsDeviceContextSpecG.h"

Просмотреть файл

@ -0,0 +1,133 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */
/* ***** 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
* Kenneth Herron <kherron@newsguy.com>.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kenneth Herron <kherron@newsguy.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"),
* 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 "nsTempfilePS.h"
#include "nsCOMPtr.h"
#include "nsDirectoryServiceDefs.h"
#include "nsILocalFile.h"
#include "nsPrintfCString.h"
#include "prtime.h"
nsTempfilePS::nsTempfilePS()
{
nsresult rv;
// Get the standard temporary directory.
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mTempDir));
if (NS_FAILED(rv))
return;
// Grab some low-order bits from the current time for use in temporary
// filenames.
LL_L2UI(mCount, PR_Now());
// Append an arbitrary subdirectory name to the temp dir...
rv = mTempDir->Append(
NS_ConvertASCIItoUTF16(nsPrintfCString("%lx.tmp", mCount++)));
if (NS_FAILED(rv)) {
mTempDir = nsnull;
return;
}
// and try to create it as a private directory for our temp files. Note
// CreateUnique() may adjust the subdirectory name we just appended.
rv = mTempDir->CreateUnique(nsIFile::DIRECTORY_TYPE, 0700);
if (NS_FAILED(rv))
mTempDir = nsnull;
}
nsTempfilePS::~nsTempfilePS()
{
if (nsnull != mTempDir)
mTempDir->Remove(PR_TRUE);
}
nsresult
nsTempfilePS::CreateTempFile(nsILocalFile** aFile)
{
NS_PRECONDITION(nsnull != aFile, "aFile argument is NULL");
NS_ENSURE_TRUE(nsnull != mTempDir, NS_ERROR_NOT_INITIALIZED);
// Get the temporary directory path
nsresult rv;
nsAutoString tmpdir;
rv = mTempDir->GetPath(tmpdir);
NS_ENSURE_SUCCESS(rv, rv);
// Create a new object for the temporary file
nsCOMPtr<nsILocalFile> tmpfile;
rv = NS_NewLocalFile(tmpdir, PR_FALSE, getter_AddRefs(tmpfile));
NS_ENSURE_SUCCESS(rv, rv);
NS_POSTCONDITION(nsnull != tmpfile,
"NS_NewLocalFile succeeded but tmpfile is invalid");
rv = tmpfile->Append(
NS_ConvertASCIItoUTF16(nsPrintfCString("%lx.tmp", mCount++)));
NS_ENSURE_SUCCESS(rv, rv);
// Create the temporary file. This may adjust the file's basename.
rv = tmpfile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
NS_ENSURE_SUCCESS(rv, rv);
*aFile = tmpfile.get();
NS_ADDREF(*aFile);
return NS_OK;
}
nsresult
nsTempfilePS::CreateTempFile(nsILocalFile** aFile,
FILE **aHandle, const char *aMode)
{
NS_PRECONDITION(nsnull != aHandle, "aHandle is invalid");
NS_PRECONDITION(nsnull != aMode, "aMode is invalid");
nsresult rv = CreateTempFile(aFile);
NS_ENSURE_SUCCESS(rv, rv);
NS_POSTCONDITION(nsnull != *aFile,
"CreateTempFile() succeeded but *aFile is invalid");
rv = (*aFile)->OpenANSIFileDesc(aMode, aHandle);
if (NS_FAILED(rv)) {
(*aFile)->Remove(PR_FALSE);
NS_RELEASE(*aFile);
}
return rv;
}

Просмотреть файл

@ -0,0 +1,91 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */
/* ***** 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
* Kenneth Herron <kherron@newsguy.com>.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kenneth Herron <kherron@newsguy.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"),
* 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 nsTempfilePS_h__
#define nsTempfilePS_h__
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsIFile.h"
#include "nsString.h"
class nsILocalFile;
class nsTempfilePS
{
public:
nsTempfilePS();
~nsTempfilePS();
/**
* Create a temporary file and return an nsILocalFile object for
* accessing it.
*
* @param aFileName After a successful return, this will be filled in
* with an nsILocalFile object for a newly-created
* temporary file. There are no open file descriptors
* to the file.
* @return NS_OK on success, or a suitable error value.
*/
nsresult CreateTempFile(nsILocalFile** aFile);
/**
* Like |CreateTempFile(nsILocalFile**)|, but also initialize a stdio
* file handle for the file.
*
* @param aFileName After a successful return, this will be filled in
* with an nsILocalFile object for a newly-created
* temporary file.
* @param aHandle After a successful return, this will be filled in
* with a file handle that may be used to access the
* file, opened according to the specified mode.
* @param aMode Stdio mode string for opening the temporary file.
* See fopen(3).
* @return NS_OK on success, or a suitable error value.
*/
nsresult CreateTempFile(nsILocalFile** aFile,
FILE **aHandle, const char *aMode);
private:
nsCOMPtr<nsIFile> mTempDir;
PRUint32 mCount;
};
#endif /* nsTempfilePS_h__ */