summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobody <nobody@gnome.org>2004-09-17 06:21:00 +0000
committernobody <nobody@gnome.org>2004-09-17 06:21:00 +0000
commitf8605f7b38429a5687c1ac80eccb805e52b633ff (patch)
tree42f2eab1c8c490e4b62a3a01b3e9d4cc7e9c47f2
parent2028a92de0b5379db24a786a246e353a6c3ff555 (diff)
This commit was manufactured by cvs2svn to create tagDEBIAN-1_1_2-4
'DEBIAN-1_1_2-4'.
-rw-r--r--patches/OOO_1_1/psprint-cups.diff1425
-rw-r--r--patches/OOO_1_1/sparc-v8-fixes.diff98
-rw-r--r--patches/OOO_1_1/system-curl.diff35
-rw-r--r--patches/OOO_1_1/tmpfile-fix.diff64
-rw-r--r--patches/OOO_1_1_1/apply3
-rw-r--r--patches/OOO_1_1_2/apply6
6 files changed, 1233 insertions, 398 deletions
diff --git a/patches/OOO_1_1/psprint-cups.diff b/patches/OOO_1_1/psprint-cups.diff
index 16e8e4c43..8bd947ba2 100644
--- a/patches/OOO_1_1/psprint-cups.diff
+++ b/patches/OOO_1_1/psprint-cups.diff
@@ -1,15 +1,44 @@
+ padmin/source/adddlg.cxx | 7
+ psprint/inc/cupsmgr.hxx | 136 ++++
+ psprint/inc/psprint/fontcache.hxx | 4
+ psprint/inc/psprint/jobdata.hxx | 5
+ psprint/inc/psprint/ppdparser.hxx | 4
+ psprint/inc/psprint/printergfx.hxx | 26
+ psprint/inc/psprint/printerinfomanager.hxx | 109 ++-
+ psprint/source/fontmanager/fontmanager.cxx | 24
+ psprint/source/fontmanager/makefile.mk | 4
+ psprint/source/fontmanager/parseAFM.cxx | 3
+ psprint/source/fontsubset/gsub.cxx | 6
+ psprint/source/fontsubset/list.c | 5
+ psprint/source/fontsubset/sft.c | 19
+ psprint/source/fontsubset/ttcr.c | 12
+ psprint/source/helper/helper.cxx | 12
+ psprint/source/helper/ppdparser.cxx | 100 +-
+ psprint/source/helper/strhelper.cxx | 6
+ psprint/source/printer/cupsmgr.cxx | 872 ++++++++++++++++++++++++++
+ psprint/source/printer/jobdata.cxx | 24
+ psprint/source/printer/makefile.mk | 15
+ psprint/source/printer/printerinfomanager.cxx | 310 ++++++---
+ psprint/source/printergfx/bitmap_gfx.cxx | 23
+ psprint/source/printergfx/common_gfx.cxx | 119 ++-
+ psprint/source/printergfx/printerjob.cxx | 250 +++++--
+ psprint/source/printergfx/psheader.ps | 62 +
+ psprint/source/printergfx/psputil.cxx | 6
+ psprint/source/printergfx/text_gfx.cxx | 62 +
+ 27 files changed, 1856 insertions(+), 369 deletions(-)
+
Index: psprint/inc/cupsmgr.hxx
===================================================================
---- /dev/null
-+++ psprint/inc/cupsmgr.hxx
-@@ -0,0 +1,128 @@
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ psprint/inc/cupsmgr.hxx 2004-08-31 21:09:34.000000000 +0200
+@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: psprint-cups.diff,v $
+ *
-+ * $Revision: 1.7 $
++ * $Revision: 1.8 $
+ *
-+ * last change: $Author: challs $ $Date: 2004/07/07 23:12:06 $
++ * last change: $Author: challs $ $Date: 2004/07/08 17:31:02 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
@@ -69,6 +98,8 @@ Index: psprint/inc/cupsmgr.hxx
+
+#include <psprint/printerinfomanager.hxx>
+#include <osl/module.h>
++#include <osl/thread.h>
++#include <osl/mutex.hxx>
+
+namespace psp
+{
@@ -88,19 +119,27 @@ Index: psprint/inc/cupsmgr.hxx
+ std::hash_map< FILE*, rtl::OString, FPtrHash > m_aSpoolFiles;
+ int m_nDests;
+ void* m_pDests;
-+ bool m_bFirstDest;
++ bool m_bNewDests;
+ std::hash_map< rtl::OUString, int, rtl::OUStringHash > m_aCUPSDestMap;
+
++ std::hash_map< rtl::OUString, PPDContext, rtl::OUStringHash > m_aDefaultContexts;
++
+ rtl::OString m_aUser;
+ // this is a security risk, but the CUPS API demands
+ // to deliver a pointer to a static buffer containing
+ // the password, so this cannot be helped
+ rtl::OString m_aPassword;
+
-+ CUPSManager( CUPSWrapper*, int nDests = 0, void* pDests = NULL );
++ osl::Mutex m_aCUPSMutex;
++ oslThread m_aDestThread;
++
++ CUPSManager( CUPSWrapper* );
+ virtual ~CUPSManager();
+
+ virtual void initialize();
++
++ void runDests();
++ static void runDestThread(void* pMgr);
+public:
+
+ static CUPSManager* tryLoadCUPS();
@@ -131,25 +170,10 @@ Index: psprint/inc/cupsmgr.hxx
+} // namespace psp
+
+#endif
-Index: psprint/inc/psprint/fontcache.hxx
-===================================================================
---- psprint/inc/psprint/fontcache.hxx.orig
-+++ psprint/inc/psprint/fontcache.hxx
-@@ -70,6 +70,10 @@
- #include <tools/string.hxx>
- #endif
-
-+#ifndef _STRING_HXX
-+#include <tools/string.hxx>
-+#endif
-+
- #include <hash_map>
-
- namespace psp
Index: psprint/inc/psprint/jobdata.hxx
===================================================================
---- psprint/inc/psprint/jobdata.hxx.orig
-+++ psprint/inc/psprint/jobdata.hxx
+--- psprint/inc/psprint/jobdata.hxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/inc/psprint/jobdata.hxx 2004-08-26 10:40:01.000000000 +0200
@@ -105,6 +105,10 @@ struct JobData
m_eOrientation( orientation::Portrait ),
m_pParser( NULL ) {}
@@ -169,8 +193,8 @@ Index: psprint/inc/psprint/jobdata.hxx
#endif // PSPRINT_JOBDATA_HXX
Index: psprint/inc/psprint/ppdparser.hxx
===================================================================
---- psprint/inc/psprint/ppdparser.hxx.orig
-+++ psprint/inc/psprint/ppdparser.hxx
+--- psprint/inc/psprint/ppdparser.hxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/inc/psprint/ppdparser.hxx 2004-08-26 12:29:44.000000000 +0200
@@ -149,11 +149,13 @@ public:
*/
@@ -188,8 +212,8 @@ Index: psprint/inc/psprint/ppdparser.hxx
Index: psprint/inc/psprint/printergfx.hxx
===================================================================
---- psprint/inc/psprint/printergfx.hxx.orig
-+++ psprint/inc/psprint/printergfx.hxx
+--- psprint/inc/psprint/printergfx.hxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/inc/psprint/printergfx.hxx 2004-08-26 10:40:01.000000000 +0200
@@ -113,10 +113,10 @@ public:
meColorspace (eRGB)
{}
@@ -253,8 +277,8 @@ Index: psprint/inc/psprint/printergfx.hxx
const sal_Int32* pDeltaArray = NULL);
Index: psprint/inc/psprint/printerinfomanager.hxx
===================================================================
---- psprint/inc/psprint/printerinfomanager.hxx.orig
-+++ psprint/inc/psprint/printerinfomanager.hxx
+--- psprint/inc/psprint/printerinfomanager.hxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/inc/psprint/printerinfomanager.hxx 2004-08-26 10:40:01.000000000 +0200
@@ -80,6 +80,36 @@
#ifndef _PSPRINT_HELPER_HXX_
#include <psprint/helper.hxx>
@@ -468,8 +492,8 @@ Index: psprint/inc/psprint/printerinfomanager.hxx
} // namespace
Index: psprint/source/fontmanager/fontmanager.cxx
===================================================================
---- psprint/source/fontmanager/fontmanager.cxx.orig
-+++ psprint/source/fontmanager/fontmanager.cxx
+--- psprint/source/fontmanager/fontmanager.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/fontmanager/fontmanager.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -543,12 +543,12 @@ bool PrintFontManager::TrueTypeFontFile:
@@ -559,8 +583,8 @@ Index: psprint/source/fontmanager/fontmanager.cxx
return aRet;
Index: psprint/source/fontmanager/makefile.mk
===================================================================
---- psprint/source/fontmanager/makefile.mk.orig
-+++ psprint/source/fontmanager/makefile.mk
+--- psprint/source/fontmanager/makefile.mk.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/fontmanager/makefile.mk 2004-08-26 10:40:01.000000000 +0200
@@ -66,12 +66,12 @@ ENABLE_EXCEPTIONS=TRUE
PRJNAME=psprint
TARGET=fontman
@@ -578,8 +602,8 @@ Index: psprint/source/fontmanager/makefile.mk
SLOFILES=\
Index: psprint/source/fontmanager/parseAFM.cxx
===================================================================
---- psprint/source/fontmanager/parseAFM.cxx.orig
-+++ psprint/source/fontmanager/parseAFM.cxx
+--- psprint/source/fontmanager/parseAFM.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/fontmanager/parseAFM.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -655,8 +655,7 @@ static int parseCharWidths( FILE* fp, re
*/
@@ -592,8 +616,8 @@ Index: psprint/source/fontmanager/parseAFM.cxx
Index: psprint/source/fontsubset/gsub.cxx
===================================================================
---- psprint/source/fontsubset/gsub.cxx.orig
-+++ psprint/source/fontsubset/gsub.cxx
+--- psprint/source/fontsubset/gsub.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/fontsubset/gsub.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -149,7 +149,7 @@ int ReadGSUB( struct _TrueTypeFont* pTTF
if( (nDefaultLangsysOfs != 0) && (nDefaultLangsysOfs != nLangsysOffset) )
{
@@ -623,8 +647,8 @@ Index: psprint/source/fontsubset/gsub.cxx
// TODO: switch( eLookupType )
Index: psprint/source/fontsubset/list.c
===================================================================
---- psprint/source/fontsubset/list.c.orig
-+++ psprint/source/fontsubset/list.c
+--- psprint/source/fontsubset/list.c.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/fontsubset/list.c 2004-08-26 10:40:01.000000000 +0200
@@ -72,8 +72,11 @@
#include <stdlib.h>
@@ -640,8 +664,8 @@ Index: psprint/source/fontsubset/list.c
#ifdef MALLOC_TRACE
Index: psprint/source/fontsubset/sft.c
===================================================================
---- psprint/source/fontsubset/sft.c.orig
-+++ psprint/source/fontsubset/sft.c
+--- psprint/source/fontsubset/sft.c.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/fontsubset/sft.c 2004-08-26 10:40:01.000000000 +0200
@@ -67,7 +67,9 @@
*/
@@ -709,8 +733,8 @@ Index: psprint/source/fontsubset/sft.c
Index: psprint/source/fontsubset/ttcr.c
===================================================================
---- psprint/source/fontsubset/ttcr.c.orig
-+++ psprint/source/fontsubset/ttcr.c
+--- psprint/source/fontsubset/ttcr.c.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/fontsubset/ttcr.c 2004-08-26 10:40:01.000000000 +0200
@@ -73,7 +73,9 @@
#include <string.h>
@@ -760,8 +784,8 @@ Index: psprint/source/fontsubset/ttcr.c
Index: psprint/source/helper/helper.cxx
===================================================================
---- psprint/source/helper/helper.cxx.orig
-+++ psprint/source/helper/helper.cxx
+--- psprint/source/helper/helper.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/helper/helper.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -359,8 +359,8 @@ bool psp::convertPfbToPfa( ::osl::File&
{
// read leading bytes
@@ -797,8 +821,8 @@ Index: psprint/source/helper/helper.cxx
buffer[ nBuffer++ ] = hexDigits[ pBuffer[ i ] & 15 ];
Index: psprint/source/helper/ppdparser.cxx
===================================================================
---- psprint/source/helper/ppdparser.cxx.orig
-+++ psprint/source/helper/ppdparser.cxx
+--- psprint/source/helper/ppdparser.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/helper/ppdparser.cxx 2004-08-26 12:30:32.000000000 +0200
@@ -67,16 +67,19 @@
// define a hash for PPDKey
namespace psp { class PPDKey; }
@@ -834,7 +858,38 @@ Index: psprint/source/helper/ppdparser.cxx
INetURLObject aPPDDir(rDir);
while( aDir.getNextItem( aItem ) == osl::FileBase::E_None )
-@@ -275,7 +276,8 @@ const PPDParser* PPDParser::getParser( S
+@@ -181,24 +182,21 @@ String PPDParser::getPPDFile( const Stri
+ if( ! aStream.IsOpen() )
+ {
+ initPPDFiles();
+-#ifdef MACOSX
++ // some PPD files contain dots beside the extension, so try name first,
++ // base after that
+ std::hash_map< OUString, OUString, OUStringHash >::const_iterator it =
+ pAllPPDFiles->find( aPPD.getName() );
+-#else
+- std::hash_map< OUString, OUString, OUStringHash >::const_iterator it =
+- pAllPPDFiles->find( aPPD.getBase() );
+-#endif // MACOSX
++ if( it == pAllPPDFiles->end() )
++ it = pAllPPDFiles->find( aPPD.getBase() );
+ if( it == pAllPPDFiles->end() )
+ {
+ // a new file ? rehash
+ delete pAllPPDFiles; pAllPPDFiles = NULL;
+ initPPDFiles();
+ // aPPD is already the file name minus the extension
+-#ifdef MACOSX
+ it = pAllPPDFiles->find( aPPD.getName() );
+-#else
+- it = pAllPPDFiles->find( aPPD.getBase() );
+-#endif // MACOSX
++ if( it == pAllPPDFiles->end() )
++ it = pAllPPDFiles->find( aPPD.getBase() );
+ // note this is optimized for office start where
+ // no new files occur and initPPDFiles is called only once
+ }
+@@ -275,10 +273,13 @@ const PPDParser* PPDParser::getParser( S
static ::osl::Mutex aMutex;
::osl::Guard< ::osl::Mutex > aGuard( aMutex );
@@ -843,8 +898,14 @@ Index: psprint/source/helper/ppdparser.cxx
+ aFile = getPPDFile( aFile );
if( ! aFile.Len() )
{
- fprintf( stderr, "Could not get printer PPD file!\n" );
-@@ -286,8 +288,21 @@ const PPDParser* PPDParser::getParser( S
+- fprintf( stderr, "Could not get printer PPD file!\n" );
++#if OSL_DEBUG_LEVEL > 1
++ fprintf( stderr, "Could not get printer PPD file \"%s\" !\n", OUStringToOString( aFile, osl_getThreadTextEncoding() ).getStr() );
++#endif
+ return NULL;
+ }
+
+@@ -286,8 +287,25 @@ const PPDParser* PPDParser::getParser( S
if( (*it)->m_aFile == aFile )
return *it;
@@ -859,16 +920,20 @@ Index: psprint/source/helper/ppdparser.cxx
+ if( rMgr.getType() == PrinterInfoManager::CUPS )
+ {
+ pNewParser = const_cast<PPDParser*>(static_cast<CUPSManager&>(rMgr).createCUPSParser( aFile ));
-+ if( pNewParser )
-+ pNewParser->m_aFile = aFile;
+ }
+ }
+ if( pNewParser )
-+ aAllParsers.push_back( pNewParser );
++ {
++ // this may actually be the SGENPRT parser,
++ // so ensure uniquness here
++ aAllParsers.remove( pNewParser );
++ // insert new parser to list
++ aAllParsers.push_front( pNewParser );
++ }
return pNewParser;
}
-@@ -304,6 +319,7 @@ void PPDParser::freeAll()
+@@ -304,6 +322,7 @@ void PPDParser::freeAll()
PPDParser::PPDParser( const String& rFile ) :
m_aFile( rFile ),
@@ -876,7 +941,7 @@ Index: psprint/source/helper/ppdparser.cxx
m_pDefaultImageableArea( NULL ),
m_pImageableAreas( NULL ),
m_pDefaultPaperDimension( NULL ),
-@@ -314,8 +330,7 @@ PPDParser::PPDParser( const String& rFil
+@@ -314,8 +333,7 @@ PPDParser::PPDParser( const String& rFil
m_pResolutions( NULL ),
m_pDefaultDuplexType( NULL ),
m_pDuplexTypes( NULL ),
@@ -886,7 +951,71 @@ Index: psprint/source/helper/ppdparser.cxx
{
// read in the file
::std::list< String > aLines;
-@@ -490,7 +505,7 @@ void PPDParser::insertKey( const String&
+@@ -350,8 +368,8 @@ PPDParser::PPDParser( const String& rFil
+
+ // now get the Values
+ parse( aLines );
+-#ifdef __DEBUG
+- fprintf( stderr, "acquired %d Keys from PPD %s:\n", m_aKeys.Count(), BSTRING( m_aFile ).GetBuffer() );
++#if OSL_DEBUG_LEVEL > 2
++ fprintf( stderr, "acquired %d Keys from PPD %s:\n", m_aKeys.size(), BSTRING( m_aFile ).GetBuffer() );
+ for( PPDParser::hash_type::const_iterator it = m_aKeys.begin(); it != m_aKeys.end(); ++it )
+ {
+ const PPDKey* pKey = it->second;
+@@ -375,7 +393,7 @@ PPDParser::PPDParser( const String& rFil
+ for( int j = 0; j < pKey->countValues(); j++ )
+ {
+ fprintf( stderr, "\t\t" );
+- PPDValue* pValue = pKey->getValue( j );
++ const PPDValue* pValue = pKey->getValue( j );
+ if( pValue == pKey->m_pDefaultValue )
+ fprintf( stderr, "(Default:) " );
+ char* pVType = "<unknown>";
+@@ -396,15 +414,14 @@ PPDParser::PPDParser( const String& rFil
+ BSTRING( pValue->m_aValueTranslation ).GetBuffer() );
+ }
+ }
+- fprintf( stderr, "constraints: (%d found)\n", m_aConstraints.Count() );
+- for( int j = 0; j < m_aConstraints.Count(); j++ )
++ fprintf( stderr, "constraints: (%d found)\n", m_aConstraints.size() );
++ for( std::list< PPDConstraint >::const_iterator cit = m_aConstraints.begin(); cit != m_aConstraints.end(); ++cit )
+ {
+- PPDConstraint* pCon = m_aConstraints.GetObject( j );
+ fprintf( stderr, "*\"%s\" \"%s\" *\"%s\" \"%s\"\n",
+- BSTRING( pCon->m_pKey1->getKey() ).GetBuffer(),
+- pCon->m_pOption1 ? BSTRING( pCon->m_pOption1->m_aOption ).GetBuffer() : "<nil>",
+- BSTRING( pCon->m_pKey2->getKey() ).GetBuffer(),
+- pCon->m_pOption2 ? BSTRING( pCon->m_pOption2->m_aOption ).GetBuffer() : "<nil>"
++ BSTRING( cit->m_pKey1->getKey() ).GetBuffer(),
++ cit->m_pOption1 ? BSTRING( cit->m_pOption1->m_aOption ).GetBuffer() : "<nil>",
++ BSTRING( cit->m_pKey2->getKey() ).GetBuffer(),
++ cit->m_pOption2 ? BSTRING( cit->m_pOption2->m_aOption ).GetBuffer() : "<nil>"
+ );
+ }
+ #endif
+@@ -444,16 +461,16 @@ PPDParser::PPDParser( const String& rFil
+ DBG_ASSERT( m_pFontList, "Warning: no Font in PPD\n" );
+
+ // fill in direct values
+- if( pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "ModelName" ) ) ) )
++ if( (pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "ModelName" ) ) )) )
+ m_aPrinterName = pKey->getValue( 0 )->m_aValue;
+- if( pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "NickName" ) ) ) )
++ if( (pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "NickName" ) ) )) )
+ m_aNickName = pKey->getValue( 0 )->m_aValue;
+- if( pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "ColorDevice" ) ) ) )
++ if( (pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "ColorDevice" ) ) )) )
+ m_bColorDevice = pKey->getValue( 0 )->m_aValue.CompareIgnoreCaseToAscii( "true", 4 ) == COMPARE_EQUAL ? true : false;
+
+- if( pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "LanguageLevel" ) ) ) )
++ if( (pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "LanguageLevel" ) ) )) )
+ m_nLanguageLevel = pKey->getValue( 0 )->m_aValue.ToInt32();
+- if( pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "TTRasterizer" ) ) ) )
++ if( (pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "TTRasterizer" ) ) )) )
+ m_bType42Capable = pKey->getValue( 0 )->m_aValue.EqualsIgnoreCaseAscii( "Type42" ) ? true : false;
+
+ #ifdef MACOSX
+@@ -490,7 +507,7 @@ void PPDParser::insertKey( const String&
const PPDKey* PPDParser::getKey( int n ) const
{
@@ -895,7 +1024,7 @@ Index: psprint/source/helper/ppdparser.cxx
}
const PPDKey* PPDParser::getKey( const String& rKey ) const
-@@ -1194,10 +1209,10 @@ const String& PPDParser::getFont( int nF
+@@ -1194,10 +1211,10 @@ const String& PPDParser::getFont( int nF
PPDKey::PPDKey( const String& rKey ) :
m_aKey( rKey ),
@@ -908,7 +1037,7 @@ Index: psprint/source/helper/ppdparser.cxx
m_nOrderDependency( 100 ),
m_eSetupType( AnySetup )
{
-@@ -1213,14 +1228,13 @@ PPDKey::~PPDKey()
+@@ -1213,14 +1230,13 @@ PPDKey::~PPDKey()
const PPDValue* PPDKey::getValue( int n ) const
{
@@ -924,7 +1053,7 @@ Index: psprint/source/helper/ppdparser.cxx
PPDKey::hash_type::const_iterator it = m_aValues.find( rOption );
return it != m_aValues.end() ? &it->second : NULL;
}
-@@ -1299,8 +1313,11 @@ const PPDKey* PPDContext::getModifiedKey
+@@ -1299,8 +1315,11 @@ const PPDKey* PPDContext::getModifiedKey
void PPDContext::setParser( const PPDParser* pParser )
{
@@ -938,7 +1067,7 @@ Index: psprint/source/helper/ppdparser.cxx
}
// -------------------------------------------------------------------
-@@ -1539,7 +1556,6 @@ void PPDContext::getUnconstrainedValues(
+@@ -1539,7 +1558,6 @@ void PPDContext::getUnconstrainedValues(
void* PPDContext::getStreamableBuffer( ULONG& rBytes ) const
{
rBytes = 0;
@@ -948,8 +1077,8 @@ Index: psprint/source/helper/ppdparser.cxx
::std::hash_map< const PPDKey*, const PPDValue* >::const_iterator it;
Index: psprint/source/helper/strhelper.cxx
===================================================================
---- psprint/source/helper/strhelper.cxx.orig
-+++ psprint/source/helper/strhelper.cxx
+--- psprint/source/helper/strhelper.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/helper/strhelper.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -664,12 +664,12 @@ int getValueOfDouble( char* pBuffer, dou
*pBuffer++ = '-';
f = -f;
@@ -976,16 +1105,16 @@ Index: psprint/source/helper/strhelper.cxx
// hardware implementations seem to round at this point
Index: psprint/source/printer/cupsmgr.cxx
===================================================================
---- /dev/null
-+++ psprint/source/printer/cupsmgr.cxx
-@@ -0,0 +1,755 @@
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ psprint/source/printer/cupsmgr.cxx 2004-08-31 21:14:04.000000000 +0200
+@@ -0,0 +1,894 @@
+/*************************************************************************
+ *
+ * $RCSfile: psprint-cups.diff,v $
+ *
-+ * $Revision: 1.7 $
++ * $Revision: 1.8 $
+ *
-+ * last change: $Author: challs $ $Date: 2004/07/07 23:12:06 $
++ * last change: $Author: challs $ $Date: 2004/07/08 17:31:02 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
@@ -1051,6 +1180,7 @@ Index: psprint/source/printer/cupsmgr.cxx
+
+#include <osl/thread.h>
+#include <osl/diagnose.h>
++#include <osl/conditn.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <cupsmgr.hxx>
+
@@ -1059,6 +1189,7 @@ Index: psprint/source/printer/cupsmgr.cxx
+class CUPSWrapper
+{
+ oslModule m_pLib;
++ osl::Mutex m_aGetPPDMutex;
+
+ int (*m_pcupsPrintFile)(const char*, const char*, const char*, int, cups_option_t*);
+ int (*m_pcupsGetDests)(cups_dest_t**);
@@ -1098,8 +1229,7 @@ Index: psprint/source/printer/cupsmgr.cxx
+ cups_option_t* pOptions )
+ { return m_pcupsPrintFile( pPrinter, pFileName, pTitle, nOptions, pOptions ); }
+
-+ const char* cupsGetPPD( const char* pPrinter )
-+ { return m_pcupsGetPPD( pPrinter ); }
++ const char* cupsGetPPD( const char* pPrinter );
+
+ int cupsMarkOptions(ppd_file_t* pPPD, int nOptions, cups_option_t* pOptions )
+ { return m_pcupsMarkOptions(pPPD, nOptions, pOptions); }
@@ -1232,6 +1362,70 @@ Index: psprint/source/printer/cupsmgr.cxx
+ return m_pLib != NULL;
+}
+
++static struct GetPPDAttribs
++{
++ const char* (*pFunction)(const char*);
++ osl::Condition m_aCondition;
++ const char* m_pParameter;
++ const char* m_pResult;
++ oslThread m_aThread;
++} *pAttribs = NULL;
++
++extern "C" {
++ static void getPPDWorker(void*)
++ {
++ pAttribs->m_pResult = pAttribs->pFunction( pAttribs->m_pParameter );
++ if( pAttribs->m_aCondition.check() )
++ {
++ // timed out, unlink file
++ if( pAttribs->m_pResult )
++ unlink( pAttribs->m_pResult );
++ delete pAttribs;
++ pAttribs = NULL;
++ }
++ else
++ pAttribs->m_aCondition.set();
++ }
++}
++
++const char* CUPSWrapper::cupsGetPPD( const char* pPrinter )
++{
++ const char* pResult = NULL;
++
++ // if one thread hangs in cupsGetPPD already, don't start another
++ if( ! pAttribs )
++ {
++ pAttribs = new GetPPDAttribs();
++ pAttribs->pFunction = m_pcupsGetPPD;
++ pAttribs->m_aCondition.reset();
++ pAttribs->m_pParameter = pPrinter;
++ pAttribs->m_pResult = NULL;
++ pAttribs->m_aThread = osl_createThread( getPPDWorker, NULL );
++
++ TimeValue aValue;
++ aValue.Seconds = 5;
++ aValue.Nanosec = 0;
++ if( pAttribs->m_aCondition.wait( &aValue ) == Condition::result_ok )
++ {
++ osl_destroyThread( pAttribs->m_aThread );
++ pResult = pAttribs->m_pResult;
++ delete pAttribs;
++ pAttribs = NULL;
++ }
++ else
++ {
++#if OSL_DEBUG_LEVEL > 1
++ fprintf( stderr, "cupsGetPPD %s timed out\n", pPrinter );
++#endif
++ // should the thread awake again notify it to clean up itself
++ pAttribs->m_aCondition.set();
++ osl_destroyThread( pAttribs->m_aThread );
++ }
++ }
++
++ return pResult;
++}
++
+static const char* setPasswordCallback( const char* pIn )
+{
+ const char* pRet = NULL;
@@ -1257,66 +1451,91 @@ Index: psprint/source/printer/cupsmgr.cxx
+ // try to load CUPS
+ CUPSWrapper* pWrapper = new CUPSWrapper();
+ if( pWrapper->isValid() )
-+ {
-+ // check if there are any dests; if not
-+ // CUPS is unconfigured (at least) and
-+ // should not be used
-+ cups_dest_t* pDests = NULL;
-+ int nDests = pWrapper->cupsGetDests( &pDests );
-+ if( nDests && pDests )
-+ pManager = new CUPSManager( pWrapper, nDests, pDests );
-+#if OSL_DEBUG_LEVEL > 1
-+ else
-+ fprintf( stderr, "CUPS loaded but no dests -> CUPS disabled\n" );
-+#endif
-+ }
-+ // something failed, don't use CUPS
-+ if( ! pManager )
++ pManager = new CUPSManager( pWrapper );
++ else
+ delete pWrapper;
+ }
+#endif
+ return pManager;
+}
+
-+CUPSManager::CUPSManager( CUPSWrapper* pWrapper, int nDests, void* pDests ) :
++CUPSManager::CUPSManager( CUPSWrapper* pWrapper ) :
+ PrinterInfoManager( CUPS ),
+ m_pCUPSWrapper( pWrapper ),
-+ m_nDests( nDests ),
-+ m_pDests( pDests )
++ m_nDests( 0 ),
++ m_pDests( NULL ),
++ m_bNewDests( false )
+{
-+ m_bFirstDest = (nDests && pDests);
++ m_aDestThread = osl_createThread( runDestThread, this );
+}
+
+CUPSManager::~CUPSManager()
+{
++ if( m_aDestThread )
++ {
++ // if the thread is still running here, then
++ // cupsGetDests is hung; terminate the thread instead of joining
++ osl_terminateThread( m_aDestThread );
++ osl_destroyThread( m_aDestThread );
++ }
++
+ if( m_nDests && m_pDests )
+ m_pCUPSWrapper->cupsFreeDests( m_nDests, (cups_dest_t*)m_pDests );
+ delete m_pCUPSWrapper;
+}
+
++void CUPSManager::runDestThread( void* pThis )
++{
++ ((CUPSManager*)pThis)->runDests();
++}
++
++void CUPSManager::runDests()
++{
++#if OSL_DEBUG_LEVEL > 1
++ fprintf( stderr, "starting cupsGetDests\n" );
++#endif
++ osl::MutexGuard aGuard( m_aCUPSMutex );
++
++ m_nDests = m_pCUPSWrapper->cupsGetDests( (cups_dest_t**)&m_pDests );
++ m_bNewDests = true;
++#if OSL_DEBUG_LEVEL > 1
++ fprintf( stderr, "finished cupsGetDests\n" );
++#endif
++}
++
+void CUPSManager::initialize()
+{
++ // get normal printers, clear printer list
++ PrinterInfoManager::initialize();
++
+#ifdef ENABLE_CUPS
-+ // there may have been a previous run
-+ if( m_nDests && m_pDests && !m_bFirstDest )
-+ m_pCUPSWrapper->cupsFreeDests( m_nDests, (cups_dest_t*)m_pDests );
-+ m_aPrinters.clear();
++ // check whether thread has completed
++ // if not behave like old printing system
++ osl::MutexGuard aGuard( m_aCUPSMutex );
++
++ if( ! (m_nDests && m_pDests ) )
++ return;
++
++ // dest thread has run, clean up
++ if( m_aDestThread )
++ {
++ osl_joinWithThread( m_aDestThread );
++ osl_destroyThread( m_aDestThread );
++ m_aDestThread = NULL;
++ }
++
++ // clear old stuff
+ m_aCUPSDestMap.clear();
+
-+ // get normal printers
-+ PrinterInfoManager::initialize();
++#if 0
++ // update dests
++ m_pCUPSWrapper->cupsFreeDests( m_nDests, (cups_dest_t*)m_pDests );
++ m_nDests = m_pCUPSWrapper->cupsGetDests( (cups_dest_t**)&m_pDests );
++#endif
++ m_bNewDests = false;
+
+ rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
-+ int nPrinter = 0;
-+
-+ // get CUPS dests if this is not the first run after the constructor
-+ // in which case m_pDests was already intialized
-+ if( m_bFirstDest && m_nDests && m_pDests )
-+ nPrinter = m_nDests;
-+ else
-+ m_nDests = nPrinter = m_pCUPSWrapper->cupsGetDests( (cups_dest_t**)&m_pDests );
-+
-+ m_bFirstDest = false;
++ int nPrinter = m_nDests;
+
+ // add CUPS printers, should there be a printer
+ // with the same name as a CUPS printer, overwrite it
@@ -1352,6 +1571,12 @@ Index: psprint/source/printer/cupsmgr.cxx
+ // behaviour
+ aPrinter.m_aInfo.m_pParser = NULL;
+ aPrinter.m_aInfo.m_aContext.setParser( NULL );
++ std::hash_map< OUString, PPDContext, OUStringHash >::const_iterator c_it = m_aDefaultContexts.find( aPrinterName );
++ if( c_it != m_aDefaultContexts.end() )
++ {
++ aPrinter.m_aInfo.m_pParser = c_it->second.getParser();
++ aPrinter.m_aInfo.m_aContext = c_it->second;
++ }
+ aPrinter.m_aInfo.m_aDriverName = aBuf.makeStringAndClear();
+ aPrinter.m_bModified = false;
+
@@ -1383,7 +1608,7 @@ Index: psprint/source/printer/cupsmgr.cxx
+}
+
+#ifdef ENABLE_CUPS
-+static void updatePrinterContextInfo( ppd_group_t* pPPDGroup, PrinterInfo& rInfo )
++static void updatePrinterContextInfo( ppd_group_t* pPPDGroup, PPDContext& rContext )
+{
+ rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
+ for( int i = 0; i < pPPDGroup->num_options; i++ )
@@ -1394,7 +1619,7 @@ Index: psprint/source/printer/cupsmgr.cxx
+ ppd_choice_t* pChoice = pOption->choices + n;
+ if( pChoice->marked )
+ {
-+ const PPDKey* pKey = rInfo.m_pParser->getKey( OStringToOUString( pOption->keyword, aEncoding ) );
++ const PPDKey* pKey = rContext.getParser()->getKey( OStringToOUString( pOption->keyword, aEncoding ) );
+ if( pKey )
+ {
+ const PPDValue* pValue = pKey->getValue( OStringToOUString( pChoice->choice, aEncoding ) );
@@ -1402,7 +1627,7 @@ Index: psprint/source/printer/cupsmgr.cxx
+ {
+ if( pValue != pKey->getDefaultValue() )
+ {
-+ rInfo.m_aContext.setValue( pKey, pValue, true );
++ rContext.setValue( pKey, pValue, true );
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "key %s is set to %s\n", pOption->keyword, pChoice->choice );
+#endif
@@ -1429,7 +1654,7 @@ Index: psprint/source/printer/cupsmgr.cxx
+ // recurse through subgroups
+ for( int g = 0; g < pPPDGroup->num_subgroups; g++ )
+ {
-+ updatePrinterContextInfo( pPPDGroup->subgroups + g, rInfo );
++ updatePrinterContextInfo( pPPDGroup->subgroups + g, rContext );
+ }
+}
+#endif // ENABLE_CUPS
@@ -1437,8 +1662,6 @@ Index: psprint/source/printer/cupsmgr.cxx
+const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter )
+{
+ const PPDParser* pNewParser = NULL;
-+ rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
-+
+ OUString aPrinter;
+
+ if( rPrinter.compareToAscii( "CUPS:", 5 ) == 0 )
@@ -1447,53 +1670,66 @@ Index: psprint/source/printer/cupsmgr.cxx
+ aPrinter = rPrinter;
+
+#ifdef ENABLE_CUPS
-+ std::hash_map< OUString, int, OUStringHash >::iterator dest_it =
-+ m_aCUPSDestMap.find( aPrinter );
-+ if( dest_it != m_aCUPSDestMap.end() )
++ if( m_aCUPSMutex.tryToAcquire() && m_nDests && m_pDests )
+ {
-+ cups_dest_t* pDest = ((cups_dest_t*)m_pDests) + dest_it->second;
-+ const char* pPPDFile = m_pCUPSWrapper->cupsGetPPD( pDest->name );
++ std::hash_map< OUString, int, OUStringHash >::iterator dest_it =
++ m_aCUPSDestMap.find( aPrinter );
++ if( dest_it != m_aCUPSDestMap.end() )
++ {
++ cups_dest_t* pDest = ((cups_dest_t*)m_pDests) + dest_it->second;
++ const char* pPPDFile = m_pCUPSWrapper->cupsGetPPD( pDest->name );
+#if OSL_DEBUG_LEVEL > 1
-+ fprintf( stderr, "PPD for %s is %s\n", OUStringToOString( aPrinter, osl_getThreadTextEncoding() ).getStr(), pPPDFile );
++ fprintf( stderr, "PPD for %s is %s\n", OUStringToOString( aPrinter, osl_getThreadTextEncoding() ).getStr(), pPPDFile );
+#endif
-+ if( pPPDFile )
-+ {
-+ rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
-+ OUString aFileName( OStringToOUString( pPPDFile, aEncoding ) );
-+ // create the new parser
-+ pNewParser = new PPDParser( aFileName );
-+
-+ // update the printer info with context information
-+ ppd_file_t* pPPD = m_pCUPSWrapper->ppdOpenFile( pPPDFile );
-+ /*int nConflicts =*/ m_pCUPSWrapper->cupsMarkOptions( pPPD, pDest->num_options, pDest->options );
++ if( pPPDFile )
++ {
++ rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
++ OUString aFileName( OStringToOUString( pPPDFile, aEncoding ) );
++ // create the new parser
++ PPDParser* pCUPSParser = new PPDParser( aFileName );
++ pCUPSParser->m_aFile = rPrinter;
++ pNewParser = pCUPSParser;
++
++ // update the printer info with context information
++ ppd_file_t* pPPD = m_pCUPSWrapper->ppdOpenFile( pPPDFile );
++ /*int nConflicts =*/ m_pCUPSWrapper->cupsMarkOptions( pPPD, pDest->num_options, pDest->options );
+#if OSL_DEBUG_LEVEL > 1
-+ fprintf( stderr, "processing the following options for printer %s (instance %s):\n",
-+ pDest->name, pDest->instance );
-+ for( int k = 0; k < pDest->num_options; k++ )
-+ fprintf( stderr, " \"%s\" = \"%s\"\n",
-+ pDest->options[k].name,
-+ pDest->options[k].value );
++ fprintf( stderr, "processing the following options for printer %s (instance %s):\n",
++ pDest->name, pDest->instance );
++ for( int k = 0; k < pDest->num_options; k++ )
++ fprintf( stderr, " \"%s\" = \"%s\"\n",
++ pDest->options[k].name,
++ pDest->options[k].value );
+#endif
-+ PrinterInfo& rInfo = m_aPrinters[ aPrinter ].m_aInfo;
++ PrinterInfo& rInfo = m_aPrinters[ aPrinter ].m_aInfo;
+
-+ rInfo.m_pParser = pNewParser;
-+ rInfo.m_aContext.setParser( pNewParser );
-+ for( int i = 0; i < pPPD->num_groups; i++ )
-+ updatePrinterContextInfo( pPPD->groups + i, rInfo );
++ // remember the default context for later use
++ PPDContext& rContext = m_aDefaultContexts[ aPrinter ];
++ rContext.setParser( pNewParser );
++ for( int i = 0; i < pPPD->num_groups; i++ )
++ updatePrinterContextInfo( pPPD->groups + i, rContext );
+
-+ // clean up the mess
-+ m_pCUPSWrapper->ppdClose( pPPD );
++ rInfo.m_pParser = pNewParser;
++ rInfo.m_aContext = rContext;
+
-+ // remove temporary PPD file
-+ unlink( pPPDFile );
-+ }
++ // clean up the mess
++ m_pCUPSWrapper->ppdClose( pPPD );
++
++
++
++ // remove temporary PPD file
++ unlink( pPPDFile );
++ }
+#if OSL_DEBUG_LEVEL > 1
-+ else
-+ fprintf( stderr, "no dest found for printer %s\n", OUStringToOString( aPrinter, osl_getThreadTextEncoding() ).getStr() );
++ else
++ fprintf( stderr, "no dest found for printer %s\n", OUStringToOString( aPrinter, osl_getThreadTextEncoding() ).getStr() );
+#endif
++ }
++ m_aCUPSMutex.release();
+ }
-+ if( ! pNewParser )
+#endif // ENABLE_CUPS
++
++ if( ! pNewParser )
+ {
+ // get the default PPD
+ pNewParser = PPDParser::getParser( String( RTL_CONSTASCII_USTRINGPARAM( "SGENPRT" ) ) );
@@ -1532,6 +1768,16 @@ Index: psprint/source/printer/cupsmgr.cxx
+ // which updates the printer info
+ p_it->second.m_aInfo.m_pParser = PPDParser::getParser( p_it->second.m_aInfo.m_aDriverName );
+ }
++ if( p_it->second.m_aInfo.m_aContext.getParser() == NULL )
++ {
++ OUString aPrinter;
++ if( p_it->second.m_aInfo.m_aDriverName.compareToAscii( "CUPS:", 5 ) == 0 )
++ aPrinter = p_it->second.m_aInfo.m_aDriverName.copy( 5 );
++ else
++ aPrinter = p_it->second.m_aInfo.m_aDriverName;
++
++ p_it->second.m_aInfo.m_aContext = m_aDefaultContexts[ aPrinter ];
++ }
+
+ rData.m_pParser = p_it->second.m_aInfo.m_pParser;
+ rData.m_aContext = p_it->second.m_aInfo.m_aContext;
@@ -1566,6 +1812,8 @@ Index: psprint/source/printer/cupsmgr.cxx
+ fclose( pFile );
+ rtl_TextEncoding aEnc = osl_getThreadTextEncoding();
+
++ osl::MutexGuard aGuard( m_aCUPSMutex );
++
+ std::hash_map< OUString, int, OUStringHash >::iterator dest_it =
+ m_aCUPSDestMap.find( rPrintername );
+ if( dest_it != m_aCUPSDestMap.end() )
@@ -1608,7 +1856,18 @@ Index: psprint/source/printer/cupsmgr.cxx
+
+bool CUPSManager::checkPrintersChanged()
+{
-+ return PrinterInfoManager::checkPrintersChanged();
++ bool bChanged = false;
++ if( m_aCUPSMutex.tryToAcquire() )
++ {
++ bChanged = m_bNewDests;
++ m_aCUPSMutex.release();
++ initialize();
++ }
++
++ if( ! bChanged )
++ bChanged = PrinterInfoManager::checkPrintersChanged();
++
++ return bChanged;
+}
+
+bool CUPSManager::addPrinter( const OUString& rName, const OUString& rDriver )
@@ -1631,23 +1890,23 @@ Index: psprint/source/printer/cupsmgr.cxx
+
+bool CUPSManager::setDefaultPrinter( const OUString& rName )
+{
++ bool bSuccess = false;
+#ifdef ENABLE_CUPS
+ std::hash_map< OUString, int, OUStringHash >::iterator nit =
+ m_aCUPSDestMap.find( rName );
-+ if( nit == m_aCUPSDestMap.end() )
-+ return false;
-+
-+ cups_dest_t* pDests = (cups_dest_t*)m_pDests;
-+ for( int i = 0; i < m_nDests; i++ )
-+ pDests[i].is_default = 0;
-+ pDests[ nit->second ].is_default = 1;
-+ m_pCUPSWrapper->cupsSetDests( m_nDests, (cups_dest_t*)m_pDests );
-+ m_aDefaultPrinter = rName;
-+
-+ return true;
-+#else
-+ return false;
++ if( nit != m_aCUPSDestMap.end() && m_aCUPSMutex.tryToAcquire() )
++ {
++ cups_dest_t* pDests = (cups_dest_t*)m_pDests;
++ for( int i = 0; i < m_nDests; i++ )
++ pDests[i].is_default = 0;
++ pDests[ nit->second ].is_default = 1;
++ m_pCUPSWrapper->cupsSetDests( m_nDests, (cups_dest_t*)m_pDests );
++ m_aDefaultPrinter = rName;
++ m_aCUPSMutex.release();
++ bSuccess = true;
++ }
+#endif
++ return bSuccess;
+}
+
+bool CUPSManager::writePrinterConfig()
@@ -1667,32 +1926,39 @@ Index: psprint/source/printer/cupsmgr.cxx
+ if( ! prt->second.m_bModified )
+ continue;
+
-+ bDestModified = true;
-+ cups_dest_t* pDest = ((cups_dest_t*)m_pDests) + nit->second;
-+ PrinterInfo& rInfo = prt->second.m_aInfo;
-+
-+ // create new option list
-+ int nNewOptions = 0;
-+ cups_option_t* pNewOptions = NULL;
-+ int nValues = rInfo.m_aContext.countValuesModified();
-+ for( int i = 0; i < nValues; i++ )
++ if( m_aCUPSMutex.tryToAcquire() )
+ {
-+ const PPDKey* pKey = rInfo.m_aContext.getModifiedKey( i );
-+ const PPDValue* pValue = rInfo.m_aContext.getValue( pKey );
-+ if( pKey && pValue ) // sanity check
++ bDestModified = true;
++ cups_dest_t* pDest = ((cups_dest_t*)m_pDests) + nit->second;
++ PrinterInfo& rInfo = prt->second.m_aInfo;
++
++ // create new option list
++ int nNewOptions = 0;
++ cups_option_t* pNewOptions = NULL;
++ int nValues = rInfo.m_aContext.countValuesModified();
++ for( int i = 0; i < nValues; i++ )
+ {
-+ OString aName = OUStringToOString( pKey->getKey(), aEncoding );
-+ OString aValue = OUStringToOString( pValue->m_aOption, aEncoding );
-+ nNewOptions = m_pCUPSWrapper->cupsAddOption( aName.getStr(), aValue.getStr(), nNewOptions, &pNewOptions );
++ const PPDKey* pKey = rInfo.m_aContext.getModifiedKey( i );
++ const PPDValue* pValue = rInfo.m_aContext.getValue( pKey );
++ if( pKey && pValue ) // sanity check
++ {
++ OString aName = OUStringToOString( pKey->getKey(), aEncoding );
++ OString aValue = OUStringToOString( pValue->m_aOption, aEncoding );
++ nNewOptions = m_pCUPSWrapper->cupsAddOption( aName.getStr(), aValue.getStr(), nNewOptions, &pNewOptions );
++ }
+ }
++ // set PPD options on CUPS dest
++ m_pCUPSWrapper->cupsFreeOptions( pDest->num_options, pDest->options );
++ pDest->num_options = nNewOptions;
++ pDest->options = pNewOptions;
++ m_aCUPSMutex.release();
+ }
-+ // set PPD options on CUPS dest
-+ m_pCUPSWrapper->cupsFreeOptions( pDest->num_options, pDest->options );
-+ pDest->num_options = nNewOptions;
-+ pDest->options = pNewOptions;
+ }
-+ if( bDestModified )
++ if( bDestModified && m_aCUPSMutex.tryToAcquire() )
++ {
+ m_pCUPSWrapper->cupsSetDests( m_nDests, (cups_dest_t*)m_pDests );
++ m_aCUPSMutex.release();
++ }
+#endif // ENABLE_CUPS
+
+ return PrinterInfoManager::writePrinterConfig();
@@ -1714,6 +1980,8 @@ Index: psprint/source/printer/cupsmgr.cxx
+ (bool(*)(const OString&,OString&,OString&))osl_getSymbol( pLib, aSym.pData );
+ if( getpw )
+ {
++ osl::MutexGuard aGuard( m_aCUPSMutex );
++
+ OString aUser = m_pCUPSWrapper->cupsUser();
+ OString aServer = m_pCUPSWrapper->cupsServer();
+ OString aPassword;
@@ -1736,8 +2004,8 @@ Index: psprint/source/printer/cupsmgr.cxx
+}
Index: psprint/source/printer/jobdata.cxx
===================================================================
---- psprint/source/printer/jobdata.cxx.orig
-+++ psprint/source/printer/jobdata.cxx
+--- psprint/source/printer/jobdata.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/printer/jobdata.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -72,6 +72,30 @@
using namespace psp;
using namespace rtl;
@@ -1771,8 +2039,8 @@ Index: psprint/source/printer/jobdata.cxx
// consistency checks
Index: psprint/source/printer/makefile.mk
===================================================================
---- psprint/source/printer/makefile.mk.orig
-+++ psprint/source/printer/makefile.mk
+--- psprint/source/printer/makefile.mk.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/printer/makefile.mk 2004-08-26 10:40:01.000000000 +0200
@@ -70,6 +70,10 @@ TARGET=printer
.INCLUDE : settings.mk
@@ -1807,8 +2075,8 @@ Index: psprint/source/printer/makefile.mk
+
Index: psprint/source/printer/printerinfomanager.cxx
===================================================================
---- psprint/source/printer/printerinfomanager.cxx.orig
-+++ psprint/source/printer/printerinfomanager.cxx
+--- psprint/source/printer/printerinfomanager.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/printer/printerinfomanager.cxx 2004-08-31 21:14:25.000000000 +0200
@@ -67,7 +67,7 @@
#include <tools/stream.hxx>
#include <tools/debug.hxx>
@@ -1818,7 +2086,7 @@ Index: psprint/source/printer/printerinfomanager.cxx
#include <psprint/fontmanager.hxx>
#include <osl/thread.hxx>
-@@ -123,17 +123,29 @@ class SystemQueueInfo : public Thread
+@@ -123,17 +123,32 @@ class SystemQueueInfo : public Thread
PrinterInfoManager& PrinterInfoManager::get()
{
@@ -1834,6 +2102,9 @@ Index: psprint/source/printer/printerinfomanager.cxx
+
+ if( pManager )
+ pManager->initialize();
++#if OSL_DEBUG_LEVEL > 1
++ fprintf( stderr, "PrinterInfoManager::get create Manager of type %d\n", pManager->getType() );
++#endif
+ }
+
+ return *pManager;
@@ -1853,7 +2124,7 @@ Index: psprint/source/printer/printerinfomanager.cxx
}
// -----------------------------------------------------------------
-@@ -172,7 +184,7 @@ bool PrinterInfoManager::checkPrintersCh
+@@ -172,7 +187,7 @@ bool PrinterInfoManager::checkPrintersCh
}
}
}
@@ -1862,7 +2133,16 @@ Index: psprint/source/printer/printerinfomanager.cxx
bChanged = m_pQueueInfo->hasChanged();
if( bChanged )
{
-@@ -254,8 +266,12 @@ void PrinterInfoManager::initialize()
+@@ -183,7 +198,7 @@ bool PrinterInfoManager::checkPrintersCh
+ sal_Int32 applePrintSystem;
+
+ applePrintSystem = macxp_GetSystemPrintMethod();
+- if ( (applePrintSystem == kApplePrintingCUPS) || (applePrintSystem == kApplePrintingNewCUPS) )
++ if ( applePrintSystem == kApplePrintingCUPS )
+ {
+ m_aSystemPrintQueues.clear();
+ delete m_pQueueInfo;
+@@ -254,8 +269,12 @@ void PrinterInfoManager::initialize()
m_aGlobalDefaults.m_eOrientation = aValue.EqualsIgnoreCaseAscii( "Landscape" ) ? orientation::Landscape : orientation::Portrait;
aValue = aConfig.ReadKey( "Scale" );
@@ -1876,7 +2156,16 @@ Index: psprint/source/printer/printerinfomanager.cxx
aValue = aConfig.ReadKey( "MarginAdjust" );
m_aGlobalDefaults.m_nLeftMarginAdjust = aValue.GetToken( 0, ',' ).ToInt32();
-@@ -415,60 +431,67 @@ void PrinterInfoManager::initialize()
+@@ -313,7 +332,7 @@ void PrinterInfoManager::initialize()
+ // notified of queue/printer updates, but these don't necessarily
+ // happen when psprint.conf changes. The user can change settings in
+ // the Print Center which should also make OOo update its queue list.
+- if ( (applePrintSystem == kApplePrintingCUPS) || (applePrintSystem == kApplePrintingNewCUPS) )
++ if ( applePrintSystem == kApplePrintingCUPS )
+ {
+ // /etc/cups/printers.conf gets modified every time the Print Center printer
+ // list is modified, so we want to watch this file too.
+@@ -415,62 +434,71 @@ void PrinterInfoManager::initialize()
aPrinterName = String( aValue.Copy( nNamePos+1 ), RTL_TEXTENCODING_UTF8 );
aPrinter.m_aInfo.m_aPrinterName = aPrinterName;
aPrinter.m_aInfo.m_aDriverName = String( aValue.Copy( 0, nNamePos ), RTL_TEXTENCODING_UTF8 );
@@ -1887,57 +2176,60 @@ Index: psprint/source/printer/printerinfomanager.cxx
- // ignore this printer if its driver is not found
- if( ! aPrinter.m_aInfo.m_pParser )
- continue;
--
+
- // merge the ppd context keys if the printer has the same keys and values
- // this is a bit tricky, since it involves mixing two PPDs
- // without constraints which might end up badly
- // this feature should be use with caution
- // it is mainly to select default paper sizes for new printers
- for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ )
-+ // set parser, merge settings
-+ // don't do this for CUPS printers as this is done
-+ // by the CUPS system itself
++ // set parser, merge settings
++ // don't do this for CUPS printers as this is done
++ // by the CUPS system itself
++ if( aPrinter.m_aInfo.m_aDriverName.compareToAscii( "CUPS:", 5 ) != 0 )
{
- const PPDKey* pDefKey = m_aGlobalDefaults.m_aContext.getModifiedKey( nPPDValueModified );
- const PPDValue* pDefValue = m_aGlobalDefaults.m_aContext.getValue( pDefKey );
- const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : NULL;
- if( pDefKey && pPrinterKey )
- // at least the options exist in both PPDs
-+ aPrinter.m_aInfo.m_pParser = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
-+ aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
-+ // note: setParser also purges the context
-+ // ignore this printer if its driver is not found
-+ if ( ! aPrinter.m_aInfo.m_pParser )
-+ continue;
-+
-+ // merge the ppd context keys if the printer has the same keys and values
-+ // this is a bit tricky, since it involves mixing two PPDs
-+ // without constraints which might end up badly
-+ // this feature should be use with caution
-+ // it is mainly to select default paper sizes for new printers
-+ for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ )
++ aPrinter.m_aInfo.m_pParser = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
++ aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
++ // note: setParser also purges the context
++
++ // ignore this printer if its driver is not found
++ if( ! aPrinter.m_aInfo.m_pParser )
++ continue;
++
++ // merge the ppd context keys if the printer has the same keys and values
++ // this is a bit tricky, since it involves mixing two PPDs
++ // without constraints which might end up badly
++ // this feature should be use with caution
++ // it is mainly to select default paper sizes for new printers
++ for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ )
{
- if( pDefValue )
-+ const PPDKey* pDefKey = m_aGlobalDefaults.m_aContext.getModifiedKey( nPPDValueModified );
-+ const PPDValue* pDefValue = m_aGlobalDefaults.m_aContext.getValue( pDefKey );
-+ const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : NULL;
-+ if( pDefKey && pPrinterKey )
-+ // at least the options exist in both PPDs
++ const PPDKey* pDefKey = m_aGlobalDefaults.m_aContext.getModifiedKey( nPPDValueModified );
++ const PPDValue* pDefValue = m_aGlobalDefaults.m_aContext.getValue( pDefKey );
++ const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : NULL;
++ if( pDefKey && pPrinterKey )
++ // at least the options exist in both PPDs
{
- const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption );
- if( pPrinterValue )
- // the printer has a corresponding option for the key
- aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, pPrinterValue );
-+ if( pDefValue )
-+ {
-+ const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption );
-+ if( pPrinterValue )
-+ // the printer has a corresponding option for the key
-+ aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, pPrinterValue );
-+ }
- }
+- }
++ if( pDefValue )
++ {
++ const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption );
++ if( pPrinterValue )
++ // the printer has a corresponding option for the key
++ aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, pPrinterValue );
++ }
else
aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, NULL );
++ }
}
- }
@@ -1968,25 +2260,27 @@ Index: psprint/source/printer/printerinfomanager.cxx
- aValue = "lpr";
- }
+#elif defined(MACOSX)
-+ if ( applePrintSystem == kApplePrintingCUPS )
-+ aValue = "lp";
-+ else if ( applePrintSystem == kApplePrintingPrintCenter )
-+ aValue = kApplePCPrintCommand;
-+ else
-+ {
-+ // Fallback case is kApplePrintingLPR
-+ aValue = "lpr";
-+ }
++ if ( applePrintSystem == kApplePrintingCUPS )
++ aValue = "lp";
++ else if ( applePrintSystem == kApplePrintingPrintCenter )
++ aValue = kApplePCPrintCommand;
++ else
++ {
++ // Fallback case is kApplePrintingLPR
++ aValue = "lpr";
++ }
#else
- aValue = "lpr";
+ aValue = "lpr";
#endif
-+ }
-+ aPrinter.m_aInfo.m_aCommand = String( aValue, RTL_TEXTENCODING_UTF8 );
++ }
++ aPrinter.m_aInfo.m_aCommand = String( aValue, RTL_TEXTENCODING_UTF8 );
}
- aPrinter.m_aInfo.m_aCommand = String( aValue, RTL_TEXTENCODING_UTF8 );
+- aPrinter.m_aInfo.m_aCommand = String( aValue, RTL_TEXTENCODING_UTF8 );
-@@ -496,7 +519,11 @@ void PrinterInfoManager::initialize()
+ aValue = aConfig.ReadKey( "Features" );
+ aPrinter.m_aInfo.m_aFeatures = String( aValue, RTL_TEXTENCODING_UTF8 );
+@@ -496,7 +524,11 @@ void PrinterInfoManager::initialize()
aValue = aConfig.ReadKey( "Scale" );
if( aValue.Len() )
@@ -1998,7 +2292,7 @@ Index: psprint/source/printer/printerinfomanager.cxx
aValue = aConfig.ReadKey( "MarginAdjust" );
if( aValue.Len() )
-@@ -531,7 +558,7 @@ void PrinterInfoManager::initialize()
+@@ -531,7 +563,7 @@ void PrinterInfoManager::initialize()
for( int nKey = 0; nKey < aConfig.GetKeyCount(); nKey++ )
{
ByteString aKey( aConfig.GetKeyName( nKey ) );
@@ -2007,7 +2301,7 @@ Index: psprint/source/printer/printerinfomanager.cxx
{
aValue = aConfig.ReadKey( aKey );
const PPDKey* pKey = aPrinter.m_aInfo.m_pParser->getKey( String( aKey.Copy( 4 ), RTL_TEXTENCODING_ISO_8859_1 ) );
-@@ -568,6 +595,9 @@ void PrinterInfoManager::initialize()
+@@ -568,6 +600,9 @@ void PrinterInfoManager::initialize()
}
}
@@ -2017,132 +2311,16 @@ Index: psprint/source/printer/printerinfomanager.cxx
// set default printer
if( m_aPrinters.size() )
{
-@@ -741,6 +771,124 @@ void PrinterInfoManager::initialize()
- }
- #endif
-
-+#ifdef MACOSX
-+ // If we are using OS X 10.2 CUPS printing, we want to grab the PPD that this printer
-+ // is associated with from /etc/cups/ppd (it's autocreated by the OS X printing system) and
-+ // use those values instead of the ones generated in the merged defaults. We want to make
-+ // this system printer just like we assigned it a PPD in padmin.
+@@ -628,7 +663,7 @@ void PrinterInfoManager::initialize()
+ // is associated with from /etc/cups/ppd (it's autocreated by the OS X printing system) and
+ // use those values instead of the ones generated in the merged defaults. We want to make
+ // this system printer just like we assigned it a PPD in padmin.
+- if ( (applePrintSystem == kApplePrintingCUPS) || (applePrintSystem == kApplePrintingNewCUPS) )
+ if ( applePrintSystem == kApplePrintingCUPS )
-+ {
-+ aPrinter.m_aInfo.m_aFontSubstitutes.clear();
-+ aPrinter.m_aInfo.m_aFontSubstitutions.clear();
-+
-+ // Printer's autogenerated PPD will be /etc/cups/ppd/<printername-from-lpstat>.ppd
-+ aPrinter.m_aInfo.m_aDriverName = String( *it );
-+ aPrinter.m_aInfo.m_pParser = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
-+ aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
-+
-+ if( aPrinter.m_aInfo.m_pParser )
-+ {
-+ // merge the ppd context keys if the printer has the same keys and values
-+ // it is mainly to select default paper sizes for new printers
-+ for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ )
-+ {
-+ const PPDKey* pDefKey = m_aGlobalDefaults.m_aContext.getModifiedKey( nPPDValueModified );
-+ const PPDValue* pDefValue = m_aGlobalDefaults.m_aContext.getValue( pDefKey );
-+ // If the default PPD has a certain key, attempt to get that same key in the Printer's PPD
-+ const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : NULL;
-+
-+ // The key usually merged is PageSize
-+ if( pDefKey && pPrinterKey )
-+ {
-+ // Key exists in both the Default PPD and the printer's specific PPD.
-+ if( pDefValue )
-+ {
-+ const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption );
-+ // If the printer has a corresponding option for the key, use printer PPD's option
-+ if( pPrinterValue )
-+ aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, pPrinterValue );
-+ }
-+ else
-+ aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, NULL );
-+ }
-+ }
-+
-+ // Some CUPS PPDs on Mac OS X (Epson, HP) don't include the requisite
-+ // PageSize information for the value. We have to fudge it from the
-+ // margin information. Others (Canon BJC 8200) have the coordinates
-+ // but not the "setpagedevice" stuff
-+ const PPDKey* pPSizeKey = aPrinter.m_aInfo.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("PageSize")) );
-+ if ( pPSizeKey )
-+ {
-+ int psIndex = 0;
-+ int nNumValues = pPSizeKey->countValues();
-+
-+ for ( psIndex = 0; psIndex < nNumValues; psIndex++ )
-+ {
-+ const PPDValue* pPSizeValue = pPSizeKey->getValue( psIndex );
-+
-+ // Only take care of PPD values that are not formatted correctly.
-+ if ( pPSizeValue &&
-+ ( !(pPSizeValue->m_aValue.Len()) ||
-+ (pPSizeValue->m_aValue.Len() && (pPSizeValue->m_aValue.SearchAscii("setpagedevice")==STRING_NOTFOUND)) )
-+ )
-+ {
-+ // Deal with the two cases: 1) where there is a blank PageSize value and
-+ // 2) where there are simply the dimensions as the PageSize value
-+ if ( !pPSizeValue->m_aValue.Len() )
-+ {
-+ int paperWidth;
-+ int paperHeight;
-+ char aWidth[ 32 ];
-+ char aHeight[ 32 ];
-+
-+ // Grab dimensions for this paper size from the "PaperDimension" key of the PPD
-+ aPrinter.m_aInfo.m_pParser->getPaperDimension( pPSizeValue->m_aOption, paperWidth, paperHeight );
-+ snprintf( aWidth, 32, "%d", paperWidth );
-+ snprintf( aHeight, 32, "%d", paperHeight );
-+
-+ // Construct a suitable PageSize key value from the PaperDimension values for this paper size
-+ pPSizeValue->m_aValue.AppendAscii( "<</PageSize [" );
-+ pPSizeValue->m_aValue.AppendAscii( aWidth );
-+ pPSizeValue->m_aValue.AppendAscii( " " );
-+ pPSizeValue->m_aValue.AppendAscii( aHeight );
-+ pPSizeValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" );
-+ }
-+ else
-+ {
-+ String aBox( pPSizeValue->m_aValue );
-+
-+ // The PageSize value was just the bounding box, add in the correct postscript
-+ pPSizeValue->m_aValue.AssignAscii( "" );
-+ pPSizeValue->m_aValue.AppendAscii( "<</PageSize [" );
-+ pPSizeValue->m_aValue.Append( aBox );
-+ pPSizeValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" );
-+ }
-+ }
-+ }
-+ }
-+ }
-+ else
-+ {
-+ ByteString aBytePrinterName = ByteString( UniString(aPrinter.m_aInfo.m_aDriverName), RTL_TEXTENCODING_UTF8 );
-+ fprintf( stderr, "Could not get Printer PPD from /etc/cups/ppd for printer '%s'! Using simple shared printer PPD...\n", aBytePrinterName.GetBuffer() );
-+
-+ // Some printers don't have the PPDs in /etc/cups/ppd (like Rendezvous-shared ones)
-+ // so we have to simply use a stripped down shared printer PPD for them
-+ aPrinter.m_aInfo.m_aDriverName = String( RTL_CONSTASCII_USTRINGPARAM("MacShared") );
-+ aPrinter.m_aInfo.m_pParser = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
-+ aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
-+ if( !(aPrinter.m_aInfo.m_pParser) )
-+ {
-+ fprintf( stderr, "Warning: still couldn't load the PPD, MacShared.ppd may be missing. Will use generic printer PPD.\n" );
-+ aPrinter.m_aInfo.m_aDriverName = String( RTL_CONSTASCII_USTRINGPARAM("SGENPRT") );
-+ aPrinter.m_aInfo.m_pParser = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
-+ aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
-+ }
-+ }
-+ }
-+#endif
-+
- m_aPrinters[ aPrinterName ] = aPrinter;
- }
- }
-@@ -896,16 +1044,19 @@ bool PrinterInfoManager::writePrinterCon
+ {
+ aPrinter.m_aInfo.m_aFontSubstitutes.clear();
+ aPrinter.m_aInfo.m_aFontSubstitutions.clear();
+@@ -896,16 +931,19 @@ bool PrinterInfoManager::writePrinterCon
aValue += ByteString::CreateFromInt32( it->second.m_aInfo.m_nBottomMarginAdjust );
pConfig->WriteKey( "MarginAdjust", aValue );
@@ -2171,7 +2349,7 @@ Index: psprint/source/printer/printerinfomanager.cxx
}
// write font substitution table
-@@ -968,6 +1119,14 @@ bool PrinterInfoManager::addPrinter( con
+@@ -968,6 +1006,14 @@ bool PrinterInfoManager::addPrinter( con
m_aPrinters[ rPrinterName ] = aPrinter;
bSuccess = true;
@@ -2186,7 +2364,16 @@ Index: psprint/source/printer/printerinfomanager.cxx
}
return bSuccess;
}
-@@ -1145,7 +1304,7 @@ void PrinterInfoManager::fillFontSubstit
+@@ -1118,7 +1164,7 @@ void PrinterInfoManager::fillFontSubstit
+ if( nSubstitute != -1 )
+ {
+ rInfo.m_aFontSubstitutions[ it->m_nID ] = nSubstitute;
+-#if OSL_DEBUG_LEVEL > 1
++#if OSL_DEBUG_LEVEL > 2
+ FastPrintFontInfo aInfo;
+ rFontManager.getFontFastInfo( nSubstitute, aInfo );
+ fprintf( stderr,
+@@ -1145,7 +1191,7 @@ void PrinterInfoManager::fillFontSubstit
void PrinterInfoManager::getSystemPrintCommands( std::list< OUString >& rCommands )
{
@@ -2195,7 +2382,7 @@ Index: psprint/source/printer/printerinfomanager.cxx
{
m_aSystemPrintCommand = m_pQueueInfo->getCommand();
m_pQueueInfo->getSystemQueues( m_aSystemPrintQueues );
-@@ -1164,7 +1323,7 @@ void PrinterInfoManager::getSystemPrintC
+@@ -1164,7 +1210,7 @@ void PrinterInfoManager::getSystemPrintC
const std::list< OUString >& PrinterInfoManager::getSystemPrintQueues()
{
@@ -2204,7 +2391,7 @@ Index: psprint/source/printer/printerinfomanager.cxx
{
m_aSystemPrintCommand = m_pQueueInfo->getCommand();
m_pQueueInfo->getSystemQueues( m_aSystemPrintQueues );
-@@ -1173,6 +1332,32 @@ const std::list< OUString >& PrinterInfo
+@@ -1173,6 +1219,33 @@ const std::list< OUString >& PrinterInfo
return m_aSystemPrintQueues;
}
@@ -2212,8 +2399,9 @@ Index: psprint/source/printer/printerinfomanager.cxx
+{
+ const PrinterInfo& rPrinterInfo = getPrinterInfo (rPrintername);
+ const rtl::OUString& rCommand = rPrinterInfo.m_aCommand;
-+ const rtl::OString aShellCommand = OUStringToOString (rCommand, RTL_TEXTENCODING_ISO_8859_1);
-+
++ rtl::OString aShellCommand = OUStringToOString (rCommand, RTL_TEXTENCODING_ISO_8859_1);
++ aShellCommand += rtl::OString( " 2>/dev/null" );
++
+ return popen (aShellCommand.getStr(), "w");
+}
+
@@ -2237,19 +2425,227 @@ Index: psprint/source/printer/printerinfomanager.cxx
// -----------------------------------------------------------------
SystemQueueInfo::SystemQueueInfo() :
-@@ -1253,7 +1438,7 @@ void SystemQueueInfo::run()
+@@ -1213,7 +1286,7 @@ struct SystemCommandParameters
+ const char* pPrintCommand;
+ const char* pForeToken;
+ const char* pAftToken;
+- int nForeTokenCount;
++ unsigned int nForeTokenCount;
+ };
+
+ static const struct SystemCommandParameters aParms[] =
+@@ -1227,11 +1300,11 @@ static const struct SystemCommandParamet
+ * printerinfomanager.hxx and are indexed by those constants. ORDER IS IMPORTANT!!!
+ */
+ /* Apple LPR printing (kApplePrintingLPR) */
+- { "/usr/sbin/lpc status", "lpr -P (PRINTER)", "", ":", 0 },
++ { "/usr/bin/lpc status", "lpr -P (PRINTER)", "", ":", 0 },
+ /* Apple CUPS printing (kApplePrintingCUPS) */
+ { "LANG=C;LC_ALL=C;export LANG LC_ALL;/usr/bin/lpstat -s", "lp -d (PRINTER)", "device for ", ": ", 1 },
+- /* Apple New CUPS printing (kApplePrintingCUPS) */
+- { "LANG=C;LC_ALL=C;export LANG LC_ALL;/usr/bin/lpstat -s", "lp -d (PRINTER)", "device for ", ": ", 1 },
++ /* Apple Print Center printing (kApplePrintingPrintCenter) */
++ { kApplePCQueueName, kApplePCPrintCommand, "", ":", 0 }
+ #else
+ { "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 },
+ { "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 },
+@@ -1241,19 +1314,9 @@ static const struct SystemCommandParamet
+ void SystemQueueInfo::run()
+ {
+-
+-#ifdef MACOSX
+- // FIXME: revisit this to see why MacOSX needs to grab the mutex earlier
+- // Workaround to allow MacOSX print queue detection to work
+- // Must grab the mutex as early as possible to make
+- // sure that run() actually runs before hasChanged() or
+- // getSystemQueues() get called by the PrinterInfoManager
+- MutexGuard aGuard( m_aMutex );
+-#endif
+-
char pBuffer[1024];
ByteString aPrtQueueCmd, aForeToken, aAftToken, aString;
- int nForeTokenCount, i;
-+ int nForeTokenCount = 0, i;
++ unsigned int nForeTokenCount = 0, i;
FILE *pPipe;
bool bSuccess = false;
std::list< ByteString > aLines;
+@@ -1279,8 +1342,25 @@ void SystemQueueInfo::run()
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "trying print queue command \"%s\" ... ", aParms[i].pQueueCommand );
+ #endif
++#ifdef MACOSX
++ /* For Mac OS X 10.1 Print Center printing, we only use the default queue. We do not
++ * need to discover it. So when it comes up in the list of possible queues,
++ * recognize it and declare success.
++ */
++ if ( applePrintSysType == kApplePrintingPrintCenter )
+ {
+- if( pPipe = popen( aPrtQueueCmd.GetBuffer(), "r" ) )
++ if ( strstr(aPrtQueueCmd.GetBuffer(), kApplePCQueueName) != NULL )
++ bSuccess = TRUE;
++#ifdef DEBUG
++ else
++ fprintf( stderr, "Ignoring print queue command \"%s\" because using 10.1 Print Center printing.\n", aParms[i].pQueueCommand );
++#endif
++ }
++ else
++#endif
++ {
++ aPrtQueueCmd += ByteString( " 2>/dev/null" );
++ if( (pPipe = popen( aPrtQueueCmd.GetBuffer(), "r" )) )
+ {
+ while( fgets( pBuffer, 1024, pPipe ) )
+ aLines.push_back( ByteString( pBuffer ) );
+@@ -1293,7 +1373,27 @@ void SystemQueueInfo::run()
+ #endif
+ }
+
+- {
++#ifdef MACOSX
++ /* Since we only print to the default printer for MacOS X 10.1,
++ * queue discovery serves no purpose.
++ */
++ if ( applePrintSysType == kApplePrintingPrintCenter )
++ {
++ std::list< OUString > aSysPrintQueues;
++
++ aSysPrintQueues.push_back( OUString::createFromAscii(kApplePCQueueName) );
++ #ifdef DEBUG
++ fprintf( stderr, "printerinfomanager.cxx: using Print Center default print queue.\n" );
++ #endif
++
++ MutexGuard aGuard( m_aMutex );
++ m_bChanged = true;
++ m_aQueues = aSysPrintQueues;
++ m_aCommand = aPrintCommand;
++ }
++ else
++#endif /* MACOSX */
++ {
+ /* Normal Unix print queue discovery, also used for Darwin 5 LPR printing
+ * and MacOS X 10.2/Darwin 6 CUPS printing.
+ */
+@@ -1308,7 +1408,7 @@ void SystemQueueInfo::run()
+ ByteString aOutLine( aLines.front() );
+ aLines.pop_front();
+
+- for( int i = 0; i < nForeTokenCount && nPos != STRING_NOTFOUND; i++ )
++ for( i = 0; i < nForeTokenCount && nPos != STRING_NOTFOUND; i++ )
+ {
+ nPos = aOutLine.Search( aForeToken, nPos );
+ if( nPos != STRING_NOTFOUND && aOutLine.Len() >= nPos+aForeToken.Len() )
+@@ -1330,11 +1430,7 @@ void SystemQueueInfo::run()
+ }
+ }
+
+-#ifndef MACOSX
+- // FIXME: revisit this to see why MacOSX needs to grab the mutex earlier
+- // A specific MacOSX workaround grabbed this Mutex earlier so do not regrab
+ MutexGuard aGuard( m_aMutex );
+-#endif
+ m_bChanged = true;
+ m_aQueues = aSysPrintQueues;
+ m_aCommand = aPrintCommand;
+@@ -1346,10 +1442,13 @@ void SystemQueueInfo::run()
+
+ /* On Apple systems printing gets more complicated...
+ * 1) Darwin 5: use straight lpr system, user has to configure lpr correctly
+- * 2) MacOS X 10.2: use CUPS duo of lpstat/lp
+- * 3) Darwin 6: Like MacOS X 10.2, use CUPS
+- * 4) MacOS X 10.3:use New CUPS and duo lpstat/lp
+- * 5) Darwin 7: Like MacOS X 10.3
++ * 2) MacOS X 10.1: use /usr/sbin/Print which prints to default Print Center printer
++ * 3) MacOS X 10.2: use CUPS duo of lpstat/lp
++ * 4) Darwin 6: Like MacOS X 10.2, use CUPS
++ *
++ * --- FIXME --- We don't support printer choosing on MacOS X 10.1 at this time,
++ * only printing to default Print Center printer. The user can
++ * change the default Print Center printer at any point however.
+ */
+
+ /*
+@@ -1357,8 +1456,11 @@ void SystemQueueInfo::run()
+ *
+ * Find out which printing system/OS we are using.
+ *
+- * Darwin 5 is the fallback case. For 10.2/Darwin 6, we attempt to find lpstat.
+- * For 10.3/Darwin 7, we attempt to fid pstopdf
++ * Darwin 5 is the fallback case. To check for 10.1 printing we try to see if
++ * /usr/sbin/Print exists. For 10.2/Darwin 6, we attempt to find lpstat. Users
++ * might also have installed CUPS on Darwin 5 or MacOS X 10.1, but we default to
++ * Print Center (/usr/sbin/Print) printing on 10.1.
++ *
+ */
+ sal_Int32 macxp_GetSystemPrintMethod( void )
+ {
+@@ -1369,13 +1471,13 @@ sal_Int32 macxp_GetSystemPrintMethod( vo
+ /* Attempt to find out which OS we are on... */
+ applePrintSysType = kApplePrintingLPR;
+
+- /* Check for MacOS X 10.3 and later CUPS first. */
+- err = stat( "/usr/bin/pstopdf", &status );
++ /* Check for MacOS X 10.1 first. */
++ err = stat( "/usr/sbin/Print", &status );
+ if ( err == 0 )
+ {
+- applePrintSysType = kApplePrintingNewCUPS;
++ applePrintSysType = kApplePrintingPrintCenter;
+ #ifdef DEBUG
+- fprintf( stderr, "printerinfomanager.cxx: found MacOS X 10.3 or later type printing system.\n" );
++ fprintf( stderr, "printerinfomanager.cxx: found MacOS X 10.1-type printing system.\n" );
+ #endif
+ }
+ else
+@@ -1399,6 +1501,7 @@ sal_Int32 macxp_GetSystemPrintMethod( vo
+ return( applePrintSysType );
+ }
+
++#if 0
+ /*
+ * macxp_GetSystemPrintFormat()
+ *
+@@ -1412,7 +1515,7 @@ sal_Int32 macxp_GetSystemPrintMethod( vo
+ * therefore the environment variable OOO_PRINT_PS_DIRECTLY, if set,
+ * forces OOo to NOT undergo the PS -> PDF translation by default.
+ */
+-/*sal_Int32 macxp_GetSystemPrintFormat( void )
++sal_Int32 macxp_GetSystemPrintFormat( void )
+ {
+ int printFormat;
+ int err;
+@@ -1423,15 +1526,15 @@ sal_Int32 macxp_GetSystemPrintMethod( vo
+
+ /* Check for presence of OSAScript executable, which is
+ * believed to be MacOS X only (ie not present on Darwin).
+- *
++ */
+ err = stat( "/usr/bin/osascript", &status );
+ if ( err == 0 )
+ {
+- /* Check to see if the user wants to print PS anyway *
++ /* Check to see if the user wants to print PS anyway */
+ pPDFOverride = getenv( "OOO_PRINT_PS_DIRECTLY" );
+ if ( pPDFOverride == NULL )
+ {
+- /* Now we have to check for ps2pdf to make sure we can do the conversion *
++ /* Now we have to check for ps2pdf to make sure we can do the conversion */
+ err = stat( kApplePS2PDFLocation, &status );
+ if ( err == 0 )
+ {
+@@ -1444,6 +1547,7 @@ sal_Int32 macxp_GetSystemPrintMethod( vo
+ }
+
+ return( printFormat );
+-}*/
++}
++#endif
+ #endif
+
Index: psprint/source/printergfx/bitmap_gfx.cxx
===================================================================
---- psprint/source/printergfx/bitmap_gfx.cxx.orig
-+++ psprint/source/printergfx/bitmap_gfx.cxx
+--- psprint/source/printergfx/bitmap_gfx.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/printergfx/bitmap_gfx.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -71,8 +71,8 @@
namespace psp {
@@ -2330,8 +2726,8 @@ Index: psprint/source/printergfx/bitmap_gfx.cxx
Index: psprint/source/printergfx/common_gfx.cxx
===================================================================
---- psprint/source/printergfx/common_gfx.cxx.orig
-+++ psprint/source/printergfx/common_gfx.cxx
+--- psprint/source/printergfx/common_gfx.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/printergfx/common_gfx.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -94,7 +94,9 @@ static const sal_Int32 nMaxTextColumn =
GraphicsStatus::GraphicsStatus() :
mnTextHeight( 0 ),
@@ -2619,9 +3015,19 @@ Index: psprint/source/printergfx/common_gfx.cxx
"/b4_Inc_state save def\n"
Index: psprint/source/printergfx/printerjob.cxx
===================================================================
---- psprint/source/printergfx/printerjob.cxx.orig
-+++ psprint/source/printergfx/printerjob.cxx
-@@ -143,8 +143,8 @@ AppendPS (FILE* pDst, osl::File* pSrc, s
+--- psprint/source/printergfx/printerjob.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/printergfx/printerjob.cxx 2004-08-26 11:04:48.000000000 +0200
+@@ -107,7 +107,8 @@
+
+ #include "glyphset.hxx"
+
+-using namespace psp ;
++using namespace psp;
++using namespace rtl;
+
+ #ifdef MACOSX
+ // Prototype our MacOS X printing help function
+@@ -143,8 +144,8 @@ AppendPS (FILE* pDst, osl::File* pSrc, s
pSrc->setPos (osl_Pos_Absolut, 0);
@@ -2632,7 +3038,7 @@ Index: psprint/source/printergfx/printerjob.cxx
do
{
pSrc->read (pBuffer, nBlockSize, nIn);
-@@ -267,8 +267,8 @@ PrinterJob::GetCurrentPageBody ()
+@@ -267,8 +268,8 @@ PrinterJob::GetCurrentPageBody ()
*/
PrinterJob::PrinterJob () :
@@ -2643,7 +3049,7 @@ Index: psprint/source/printergfx/printerjob.cxx
{
}
-@@ -451,6 +451,8 @@ PrinterJob::StartJob (
+@@ -451,6 +452,8 @@ PrinterJob::StartJob (
rtl::OUString aExt = rtl::OUString::createFromAscii (".ps");
mpJobHeader = CreateSpoolFile (rtl::OUString::createFromAscii("psp_head"), aExt);
mpJobTrailer = CreateSpoolFile (rtl::OUString::createFromAscii("psp_tail"), aExt);
@@ -2652,7 +3058,7 @@ Index: psprint/source/printergfx/printerjob.cxx
// write document header according to Document Structuring Conventions (DSC)
WritePS (mpJobHeader,
-@@ -481,6 +483,7 @@ PrinterJob::StartJob (
+@@ -481,6 +484,7 @@ PrinterJob::StartJob (
// Document Title
aFilterWS = WhitespaceToSpace( rJobName, FALSE );
@@ -2660,7 +3066,16 @@ Index: psprint/source/printergfx/printerjob.cxx
WritePS (mpJobHeader, "%%Title: ");
WritePS (mpJobHeader, aFilterWS);
WritePS (mpJobHeader, "\n");
-@@ -519,8 +522,11 @@ PrinterJob::EndJob ()
+@@ -500,7 +504,7 @@ PrinterJob::StartJob (
+ WritePS (mpJobHeader, "%%EndComments\n");
+
+ // write Prolog
+- writeProlog (mpJobHeader);
++ writeProlog (mpJobHeader, rSetupData);
+
+ // mark last job setup as not set
+ m_aLastJobData.m_pParser = NULL;
+@@ -519,8 +523,11 @@ PrinterJob::EndJob ()
// write document setup (done here because it
// includes the accumulated fonts
@@ -2673,7 +3088,7 @@ Index: psprint/source/printergfx/printerjob.cxx
// write document trailer according to Document Structuring Conventions (DSC)
rtl::OStringBuffer aTrailer(512);
-@@ -575,6 +581,12 @@ PrinterJob::EndJob ()
+@@ -575,6 +582,12 @@ PrinterJob::EndJob ()
}
else
{
@@ -2686,7 +3101,7 @@ Index: psprint/source/printergfx/printerjob.cxx
const PrinterInfoManager& rPrinterInfoManager = PrinterInfoManager::get ();
const rtl::OUString& rPrinter = m_aLastJobData.m_aPrinterName;
const PrinterInfo& rPrinterInfo = rPrinterInfoManager.getPrinterInfo (rPrinter);
-@@ -587,19 +599,12 @@ PrinterJob::EndJob ()
+@@ -587,26 +600,19 @@ PrinterJob::EndJob ()
* All other OS X/Darwin cases use spool to file.
* Other UNIX: always open a pipe.
*/
@@ -2707,7 +3122,18 @@ Index: psprint/source/printergfx/printerjob.cxx
else
{
/* Spool to file instead so we can convert it. Cases used here:
-@@ -624,7 +629,7 @@ PrinterJob::EndJob ()
+- * 1) kApplePrintingCUPS && kApplePrintingUsePDF
+- * 2) kApplePrintingCUPS && kApplePrintingUsePS
+- * 3) kApplePrintingNewCUPS && kApplePrintingUseNewPDF
+- * 2) kApplePrintingNewCUPS && kApplePrintingUsePS
++ * 1) kApplePrintingPrintCenter && kApplePrintingUsePDF
++ * 2) kApplePrintingPrintCenter && kApplePrintingUsePS
++ * 3) kApplePrintingCUPS && kApplePrintingUsePDF
++ * 4) kApplePrintingCUPS && kApplePrintingUsePS
+ */
+
+ /* Get a temporary file name for the spool file.
+@@ -624,7 +630,7 @@ PrinterJob::EndJob ()
return sal_False;
}
}
@@ -2716,7 +3142,7 @@ Index: psprint/source/printergfx/printerjob.cxx
}
/* spool the document parts to the destination */
-@@ -633,25 +638,36 @@ PrinterJob::EndJob ()
+@@ -633,25 +639,36 @@ PrinterJob::EndJob ()
AppendPS (pDestFILE, mpJobHeader, pBuffer);
mpJobHeader->close();
@@ -2762,7 +3188,7 @@ Index: psprint/source/printergfx/printerjob.cxx
}
AppendPS (pDestFILE, mpJobTrailer, pBuffer);
-@@ -662,8 +678,13 @@ PrinterJob::EndJob ()
+@@ -662,8 +679,13 @@ PrinterJob::EndJob ()
if (bSpoolToFile)
fclose (pDestFILE);
else
@@ -2777,7 +3203,7 @@ Index: psprint/source/printergfx/printerjob.cxx
sal_uInt32 nXdpi;
sal_uInt32 nYdpi;
-@@ -691,14 +712,9 @@ PrinterJob::EndJob ()
+@@ -691,14 +713,9 @@ PrinterJob::EndJob ()
aShellCommand,
aDriverName,
m_aLastJobData,
@@ -2793,7 +3219,7 @@ Index: psprint/source/printergfx/printerjob.cxx
/* If we created a spool file for our Mac OS X/Darwin job,
* delete it. Also free the variable, since it is malloc()ed in macxp_tempnam()
* and otherwise we'd leak memory.
-@@ -710,7 +726,7 @@ PrinterJob::EndJob ()
+@@ -710,7 +727,7 @@ PrinterJob::EndJob ()
}
#endif
@@ -2802,7 +3228,135 @@ Index: psprint/source/printergfx/printerjob.cxx
}
#ifdef MACOSX
-@@ -1014,6 +1030,9 @@ PrinterJob::StartPage (const JobData& rJ
+@@ -754,46 +771,73 @@ void macxp_ProcessAndPrintDocument( sal_
+ * "cupsFilter" key, or if the "cupsFilter" key _doesn't_ contain "application/pdf",
+ * then we print directly with PostScript.
+ */
+-
+- /* For Jaguar default to using PDF unless no PDF filter in ppd */
+- if (applePrintSysType==kApplePrintingCUPS) {
+- printFormat = kApplePrintingUsePDF;
+- if ( (sal_False == psprintDriverName.equals("SGENPRT")) && (sal_False == psprintDriverName.equals("MacShared")) )
++ printFormat = kApplePrintingUsePDF;
++ if ( (sal_False == psprintDriverName.equals("SGENPRT")) && (sal_False == psprintDriverName.equals("MacShared")) )
++ {
++ /* The should exist a valid PPD for this printer */
++ if ( pJobData.m_pParser )
+ {
+- /* The should exist a valid PPD for this printer */
+- if ( pJobData.m_pParser )
+- {
+- const PPDKey *pCupsFilterKey;
+- const PPDValue *pCupsFilterValue;
++ const PPDKey *pCupsFilterKey;
++ const PPDValue *pCupsFilterValue;
+
+- pCupsFilterKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) );
+- pCupsFilterValue = pCupsFilterKey != NULL ? pJobData.m_aContext.getValue( pCupsFilterKey ) : NULL;
+- if ( pCupsFilterValue )
+- {
+- ByteString aCupsFilterString( pCupsFilterValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
+- if ( aCupsFilterString.Search("application/pdf") == 0 )
+- {
+- /* cupsFilter didn't have application/pdf */
+- printFormat = kApplePrintingUsePS;
+- }
+- }
+- else
++ pCupsFilterKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) );
++ pCupsFilterValue = pCupsFilterKey != NULL ? pJobData.m_aContext.getValue( pCupsFilterKey ) : NULL;
++ if ( pCupsFilterValue )
++ {
++ ByteString aCupsFilterString( pCupsFilterValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
++ if ( aCupsFilterString.Search("application/pdf") == 0 )
+ {
+- /* No "cupsFilter" key */
++ /* cupsFilter didn't have application/pdf */
+ printFormat = kApplePrintingUsePS;
+ }
+ }
++ else
++ {
++ /* No "cupsFilter" key */
++ printFormat = kApplePrintingUsePS;
++ }
+ }
+- }
+-
+- /* For Panther and later simply use PS and let the new CUPS handle any conversions via filters */
+- if (applePrintSysType==kApplePrintingNewCUPS) {
+- printFormat = kApplePrintingUsePS;
+ }
+
++ if ( (applePrintSysType==kApplePrintingPrintCenter) && (printFormat==kApplePrintingUsePS) )
++ {
++ /* Now pass the PS file to /usr/sbin/Print for printing. */
++ snprintf( sysCommandBuffer, kSysCommandBufferLen-1, "%s -M ps \"%s\"", kApplePCPrintCommand, spoolFileName );
++ #ifdef DEBUG
++ fprintf( stderr, "printerjob.cxx: printing doc with command '%s'\n", sysCommandBuffer );
++ #endif
+
+- if ( ((applePrintSysType==kApplePrintingCUPS) || (applePrintSysType==kApplePrintingNewCUPS))
+- && ((printFormat==kApplePrintingUsePDF) || (printFormat==kApplePrintingUsePS)) )
++ printCmdErr = system( sysCommandBuffer );
++ }
++ else if ( (applePrintSysType==kApplePrintingPrintCenter) && (printFormat==kApplePrintingUsePDF) )
++ {
++ char pdfFileName[ kPDFFileNameBufferLen ];
++ char pdfFileNameMacFormat[ kPDFFileNameBufferLen ];
++ char *c;
++
++ /* Convert file to PDF using GhostScript */
++ printCmdErr = macxp_ConvertPSFileToPDF( spoolFileName, pdfFileName, kPDFFileNameBufferLen, jobDPI );
++ if ( printCmdErr == 0 )
++ {
++ /* AppleScript expects MacOS-style paths, so convert Unix path to Mac OS Style.
++ * If the Unix path is absolute, get rid of the starting slash
++ */
++ strncpy( pdfFileNameMacFormat, pdfFileName, kPDFFileNameBufferLen-1 );
++ if ( *pdfFileNameMacFormat == '/' )
++ strncpy( pdfFileNameMacFormat, pdfFileName+1, kPDFFileNameBufferLen-2 );
++ while ( (c=strchr(pdfFileNameMacFormat,'/')) != NULL )
++ *c = ':';
++
++ /* Construct and execute the actual printing command using AppleScript */
++ snprintf( sysCommandBuffer, kSysCommandBufferLen-1, "/usr/bin/osascript -e 'tell application \"Finder\"' -e 'print {file \"%s\"}' -e 'end tell'", pdfFileNameMacFormat );
++ #ifdef DEBUG
++ fprintf( stderr, "printerjob.cxx: printing PDF with command '%s'\n", sysCommandBuffer );
++ #endif
++ printCmdErr = system( sysCommandBuffer );
++ }
++ unlink( pdfFileName );
++ }
++ else if ( (applePrintSysType==kApplePrintingCUPS) && ((printFormat==kApplePrintingUsePDF) || (printFormat==kApplePrintingUsePS)) )
+ {
+ char pdfFileName[ kPDFFileNameBufferLen ];
+ char numCopiesSwitch[ 5 ];
+@@ -923,18 +967,19 @@ int macxp_ConvertPSFileToPDF( char *psFi
+
+ /* Create the file name for the converted PDF and assemble the conversion command */
+ snprintf( pdfFileName, pdfFileNameBufferLen-1, "%s%s", psFileName, kPDFFileExtension );
+-
+- sysCommandBuffer = (char *)malloc( sizeof(char) * ( strlen(kSysPrintSetupString) +
++ int nBufferSize = sizeof(char) * ( strlen(kSysPrintSetupString) +
+ strlen(kApplePS2PDFLocation) +
+ 10 + /* For " -r<DPI>" */
+ strlen(psFileName) +
+ strlen(pdfFileName) +
+- 10) ); /* 10 bytes fudge factor */
++ 10); /* 10 bytes fudge factor */
++
++ sysCommandBuffer = (char *)malloc( nBufferSize );
+ if ( sysCommandBuffer == NULL )
+ returnVal = -1;
+ else
+ {
+- sprintf( sysCommandBuffer, "%s;%s -r%d \"%s\" \"%s\"'", kSysPrintSetupString, kApplePS2PDFLocation, jobDPI, psFileName, pdfFileName );
++ snprintf( sysCommandBuffer, nBufferSize, "%s;%s -r%d \"%s\" \"%s\"'", kSysPrintSetupString, kApplePS2PDFLocation, jobDPI, psFileName, pdfFileName );
+ #ifdef DEBUG
+ fprintf( stderr, "printerjob.cxx: converting document to PDF with command '%s'\n", sysCommandBuffer );
+ #endif
+@@ -1014,6 +1059,9 @@ PrinterJob::StartPage (const JobData& rJ
maHeaderList.push_back (pPageHeader);
maPageList.push_back (pPageBody);
@@ -2812,7 +3366,7 @@ Index: psprint/source/printergfx/printerjob.cxx
/* #i7262# write setup only before first page
* don't do this in StartJob since the jobsetup there may be
* different.
-@@ -1061,6 +1080,9 @@ PrinterJob::EndPage ()
+@@ -1061,6 +1109,9 @@ PrinterJob::EndPage ()
osl::File* pPageHeader = maHeaderList.back();
osl::File* pPageBody = maPageList.back();
@@ -2822,7 +3376,7 @@ Index: psprint/source/printergfx/printerjob.cxx
// copy page to paper and write page trailer according to DSC
sal_Char pTrailer[256];
-@@ -1116,7 +1138,7 @@ bool PrinterJob::writeFeatureList( osl::
+@@ -1116,7 +1167,7 @@ bool PrinterJob::writeFeatureList( osl::
// emit features ordered to OrderDependency
// ignore features that are set to default
@@ -2831,7 +3385,65 @@ Index: psprint/source/printergfx/printerjob.cxx
// sanity check
if( rJob.m_pParser == rJob.m_aContext.getParser() &&
rJob.m_pParser &&
-@@ -1287,6 +1309,12 @@ bool PrinterJob::writeProlog (osl::File*
+@@ -1223,10 +1274,55 @@ bool PrinterJob::writePageSetup( osl::Fi
+ return bSuccess;
+ }
+
+-bool PrinterJob::writeProlog (osl::File* pFile)
++void PrinterJob::writeJobPatch( osl::File* pFile, const JobData& rJobData )
++{
++ const PPDKey* pKey = NULL;
++
++ if( rJobData.m_pParser )
++ pKey = rJobData.m_pParser->getKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPatchFile" ) ) );
++ if( ! pKey )
++ return;
++
++ // order the patch files
++ // according to PPD spec the JobPatchFile options must be int
++ // and should be emitted in order
++ std::list< sal_Int32 > patch_order;
++ int nValueCount = pKey->countValues();
++ for( int i = 0; i < nValueCount; i++ )
++ {
++ const PPDValue* pVal = pKey->getValue( i );
++ patch_order.push_back( pVal->m_aOption.ToInt32() );
++ if( patch_order.back() == 0 && ! pVal->m_aOption.EqualsAscii( "0" ) )
++ {
++ WritePS( pFile, "% Warning: left out JobPatchFile option \"" );
++ OString aOption = OUStringToOString( pVal->m_aOption, RTL_TEXTENCODING_ASCII_US );
++ WritePS( pFile, aOption.getStr() );
++ WritePS( pFile,
++ "\"\n% as it violates the PPD spec;\n"
++ "% JobPatchFile options need to be numbered for ordering.\n" );
++ }
++ }
++
++ patch_order.sort();
++ patch_order.unique();
++
++ while( patch_order.begin() != patch_order.end() )
++ {
++ // note: this discards patch files not adhering to the "int" scheme
++ // as there won't be a value for them
++ writeFeature( pFile, pKey, pKey->getValue( OUString::valueOf( patch_order.front() ) ) );
++ patch_order.pop_front();
++ }
++}
++
++bool PrinterJob::writeProlog (osl::File* pFile, const JobData& rJobData )
+ {
++ WritePS( pFile, "%%BeginProlog\n" );
++
++ // JobPatchFile feature needs to be emitted at begin of prolog
++ writeJobPatch( pFile, rJobData );
++
+ const sal_Char pProlog[] = {
+- "%%BeginProlog\n"
+ "%%BeginResource: procset PSPrint-Prolog 1.0 0\n"
+ "/ISO1252Encoding [\n"
+ "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
+@@ -1287,6 +1383,12 @@ bool PrinterJob::writeProlog (osl::File*
"rlineto closepath } def\n"
"/rectfill { rectangle fill } def\n"
"/rectstroke { rectangle stroke } def } if\n"
@@ -2846,8 +3458,8 @@ Index: psprint/source/printergfx/printerjob.cxx
"/psp_ascii85filter { currentfile /ASCII85Decode filter } def\n"
Index: psprint/source/printergfx/psheader.ps
===================================================================
---- psprint/source/printergfx/psheader.ps.orig
-+++ psprint/source/printergfx/psheader.ps
+--- psprint/source/printergfx/psheader.ps.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/printergfx/psheader.ps 2004-08-26 10:40:01.000000000 +0200
@@ -339,3 +339,65 @@ if
/psp_reencodedfont exch definefont
} def
@@ -2916,8 +3528,8 @@ Index: psprint/source/printergfx/psheader.ps
+} def
Index: psprint/source/printergfx/psputil.cxx
===================================================================
---- psprint/source/printergfx/psputil.cxx.orig
-+++ psprint/source/printergfx/psputil.cxx
+--- psprint/source/printergfx/psputil.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/printergfx/psputil.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -193,7 +193,7 @@ WritePS (osl::File* pFile, const sal_Cha
sal_uInt64 nInLength = rtl_str_getLength (pString);
sal_uInt64 nOutLength = 0;
@@ -2947,8 +3559,8 @@ Index: psprint/source/printergfx/psputil.cxx
return nInLength == nOutLength;
Index: psprint/source/printergfx/text_gfx.cxx
===================================================================
---- psprint/source/printergfx/text_gfx.cxx.orig
-+++ psprint/source/printergfx/text_gfx.cxx
+--- psprint/source/printergfx/text_gfx.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ psprint/source/printergfx/text_gfx.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -176,7 +176,9 @@ PrinterGfx::SetFont(
sal_Int32 nHeight,
sal_Int32 nWidth,
@@ -3098,8 +3710,8 @@ Index: psprint/source/printergfx/text_gfx.cxx
PSUploadPS1Font (mnFontID);
Index: padmin/source/adddlg.cxx
===================================================================
---- padmin/source/adddlg.cxx.orig
-+++ padmin/source/adddlg.cxx
+--- padmin/source/adddlg.cxx.orig 2004-08-26 10:39:57.000000000 +0200
++++ padmin/source/adddlg.cxx 2004-08-26 10:40:01.000000000 +0200
@@ -112,6 +112,13 @@ APChooseDevicePage::APChooseDevicePage(
m_aOldBtn.Check( FALSE );
if( ! AddPrinterDialog::getOldPrinterLocation().Len() )
@@ -3114,3 +3726,20 @@ Index: padmin/source/adddlg.cxx
}
APChooseDevicePage::~APChooseDevicePage()
+Index: printerjob.hxx
+===================================================================
+RCS file: /cvs/gsl/psprint/inc/psprint/printerjob.hxx,v
+retrieving revision 1.4.44.1
+diff -u -r1.4.44.1 printerjob.hxx
+--- psprint/inc/psprint/printerjob.hxx 28 Jan 2004 11:22:11 -0000 1.4.44.1
++++ psprint/inc/psprint/printerjob.hxx 16 Sep 2004 20:26:28 -0000
+@@ -126,7 +126,8 @@
+ bool writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup );
+ bool writeSetup( osl::File* pFile, const JobData& );
+ bool writePageSetup( osl::File* pFile, const JobData& );
+- bool writeProlog (osl::File* pFile);
++ bool writeProlog (osl::File* pFile, const JobData& rJobData);
++ void writeJobPatch (osl::File* pFile, const JobData& rJobData);
+
+ public: // for usage in PrinterGfx
+
diff --git a/patches/OOO_1_1/sparc-v8-fixes.diff b/patches/OOO_1_1/sparc-v8-fixes.diff
new file mode 100644
index 000000000..6a3e7d095
--- /dev/null
+++ b/patches/OOO_1_1/sparc-v8-fixes.diff
@@ -0,0 +1,98 @@
+Index: sal/osl/unx/util.c
+===================================================================
+RCS file: /cvs/porting/sal/osl/unx/util.c,v
+retrieving revision 1.5
+diff -u -u -r1.5 util.c
+--- sal/osl/unx/util.c 2 Jul 2003 13:35:19 -0000 1.5
++++ sal/osl/unx/util.c 12 Jul 2004 08:02:39 -0000
+@@ -398,3 +398,23 @@
+
+ #endif
+
++#if defined ( LINUX ) && defined ( SPARC )
++#include <sys/utsname.h>
++void osl_InitSparcV9(void) __attribute__((constructor));
++void osl_InterlockedCountSetV9(sal_Bool bV9);
++/* Determine which machine we are running on (sparc or sparc64)
++ * The approach is very similar to Solaris.
++ */
++void osl_InitSparcV9(void)
++{
++ struct utsname name;
++ int rc;
++ rc = uname(&name);
++ if ( rc != -1 ) {
++ if ( !strcmp( "sparc", name.machine ))
++ return;
++ osl_InterlockedCountSetV9(sal_True);
++ }
++}
++
++#endif
+Index: sal/osl/unx/asm/interlck_sparc.s
+===================================================================
+RCS file: /cvs/porting/sal/osl/unx/asm/interlck_sparc.s,v
+retrieving revision 1.3
+diff -u -u -r1.3 interlck_sparc.s
+--- sal/osl/unx/asm/interlck_sparc.s 28 Apr 2003 17:13:44 -0000 1.3
++++ sal/osl/unx/asm/interlck_sparc.s 12 Jul 2004 08:02:39 -0000
+@@ -248,7 +248,9 @@
+
+ 1: ld [%o0], %o1
+ add %o1, 1, %o2
+- cas [%o0], %o1, %o2
++! allow linux to build for v8
++ .word 0xD5E21009
++! cas [%o0], %o1, %o2
+ cmp %o1, %o2
+ bne 1b
+ nop ! delay slot
+@@ -267,7 +269,9 @@
+
+ 1: ld [%o0], %o1
+ sub %o1, 1, %o2
+- cas [%o0], %o1, %o2
++! allow linux to build for v8
++ .word 0xD5E21009
++! cas [%o0], %o1, %o2
+ cmp %o1, %o2
+ bne 1b
+ nop ! delay slot
+@@ -276,4 +280,3 @@
+
+ .type osl_decrementInterlockedCountV9,#function
+ .size osl_decrementInterlockedCountV9,.-osl_decrementInterlockedCountV9
+-
+Index: sc/source/core/data/makefile.mk
+===================================================================
+RCS file: /cvs/sc/sc/source/core/data/makefile.mk,v
+retrieving revision 1.6.260.3
+diff -u -u -r1.6.260.3 makefile.mk
+--- sc/source/core/data/makefile.mk 28 Jan 2004 10:02:07 -0000 1.6.260.3
++++ sc/source/core/data/makefile.mk 12 Jul 2004 08:02:42 -0000
+@@ -205,7 +205,8 @@
+ $(SLO)$/table3.obj \
+ $(SLO)$/table4.obj \
+ $(SLO)$/documen4.obj \
+- $(SLO)$/conditio.obj
++ $(SLO)$/conditio.obj \
++ $(SLO)$/validat.obj
+ .ENDIF
+
+ EXCEPTIONSFILES= \
+Index: solenv/inc/unxlngs.mk
+===================================================================
+RCS file: /cvs/tools/solenv/inc/unxlngs.mk,v
+retrieving revision 1.2.50.2
+diff -u -u -r1.2.50.2 unxlngs.mk
+--- solenv/inc/unxlngs.mk 30 Mar 2004 13:17:38 -0000 1.2.50.2
++++ solenv/inc/unxlngs.mk 12 Jul 2004 08:02:55 -0000
+@@ -62,7 +62,7 @@
+
+ # mk file for unxlngs
+ ASM=$(CC)
+-AFLAGS=-Wa,-Av8plus,-K,PIC -c $(CDEFS)
++AFLAGS=-Wa,-K,PIC -c $(CDEFS)
+
+ SOLAR_JAVA*=TRUE
+ JAVAFLAGSDEBUG=-g
diff --git a/patches/OOO_1_1/system-curl.diff b/patches/OOO_1_1/system-curl.diff
index feccd995d..64b97027b 100644
--- a/patches/OOO_1_1/system-curl.diff
+++ b/patches/OOO_1_1/system-curl.diff
@@ -67,3 +67,38 @@ diff -u -r1.11 ftpurl.hxx
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
SHL1LIBS= \
$(LIB1TARGET)
+Index: ftphandleprovider.hxx
+===================================================================
+RCS file: /cvs/ucb/ucb/source/ucp/ftp/ftphandleprovider.hxx,v
+retrieving revision 1.2
+diff -u -r1.2 ftphandleprovider.hxx
+--- ucb/source/ucp/ftp/ftphandleprovider.hxx 15 Oct 2002 09:21:17 -0000 1.2
++++ ucb/source/ucp/ftp/ftphandleprovider.hxx 20 Jul 2004 22:02:48 -0000
+@@ -1,5 +1,5 @@
+ #include <rtl/ustring.hxx>
+-#include <curl/types.h>
++#include <curl/curl.h>
+
+ namespace ftp {
+
+Index: ftploaderthread.hxx
+===================================================================
+RCS file: /cvs/ucb/ucb/source/ucp/ftp/ftploaderthread.hxx,v
+retrieving revision 1.5
+diff -u -r1.5 ftploaderthread.hxx
+--- ucb/source/ucp/ftp/ftploaderthread.hxx 28 Aug 2002 07:23:14 -0000 1.5
++++ ucb/source/ucp/ftp/ftploaderthread.hxx 20 Jul 2004 22:02:48 -0000
+@@ -71,11 +71,10 @@
+ #ifndef _OSL_THREAD_H_
+ #include <osl/thread.h>
+ #endif
+-#ifndef __CURL_TYPES_H
+-#include <curl/types.h>
++#ifndef __CURL_CURL_H
++#include <curl/curl.h>
+ #endif
+
+-
+ namespace ftp {
+
+ /** A loaderthread acts as factory for CURL-handles,
diff --git a/patches/OOO_1_1/tmpfile-fix.diff b/patches/OOO_1_1/tmpfile-fix.diff
new file mode 100644
index 000000000..73093df8d
--- /dev/null
+++ b/patches/OOO_1_1/tmpfile-fix.diff
@@ -0,0 +1,64 @@
+Index: tempfile.cxx
+===================================================================
+RCS file: /cvs/util/unotools/source/ucbhelper/tempfile.cxx,v
+retrieving revision 1.14
+retrieving revision 1.14.72.1
+diff -u -r1.14 -r1.14.72.1
+--- unotools/source/ucbhelper/tempfile.cxx 9 Sep 2002 10:25:47 -0000 1.14
++++ unotolls/source/ucbhelper/tempfile.cxx 1 Sep 2004 09:28:55 -0000 1.14.72.1
+@@ -70,6 +70,7 @@
+ #include <tools/time.hxx>
+ #include <tools/debug.hxx>
+ #include <stdio.h>
++#include <sys/stat.h>
+
+ using namespace osl;
+
+@@ -119,7 +120,15 @@
+ // HACK: create directory on a mount point with nobrowse option
+ // returns ENOSYS in any case !!
+ osl::Directory aDirectory( aPath );
++#ifdef UNX
++#include <sys/stat.h>
++/* RW permission for the user only! */
++ mode_t old_mode = umask(077);
++#endif
+ osl::FileBase::RC nError = aDirectory.open();
++#ifdef UNX
++umask(old_mode);
++#endif
+ aDirectory.close();
+ if( nError == osl::File::E_None )
+ return sal_True;
+@@ -240,7 +249,15 @@
+ {
+ DBG_ASSERT( bKeep, "Too expensive, use directory for creating name!" );
+ File aFile( aTmp );
++#ifdef UNX
++#include <sys/stat.h>
++/* RW permission for the user only! */
++ mode_t old_mode = umask(077);
++#endif
+ FileBase::RC err = aFile.open(osl_File_OpenFlag_Create);
++#ifdef UNX
++umask(old_mode);
++#endif
+ if ( err == FileBase::E_None )
+ {
+ rName = aTmp;
+@@ -318,7 +335,15 @@
+ else
+ {
+ File aFile( aTmp );
++#ifdef UNX
++#include <sys/stat.h>
++/* RW permission for the user only! */
++ mode_t old_mode = umask(077);
++#endif
+ FileBase::RC err = aFile.open(osl_File_OpenFlag_Create);
++#ifdef UNX
++umask(old_mode);
++#endif
+ if ( err == FileBase::E_None )
+ {
+ pImp->aName = aTmp;
diff --git a/patches/OOO_1_1_1/apply b/patches/OOO_1_1_1/apply
index b0095d698..596e0ac5a 100644
--- a/patches/OOO_1_1_1/apply
+++ b/patches/OOO_1_1_1/apply
@@ -68,6 +68,9 @@ build-sparc-assembler.diff
# Fix alignment of long/doubles on Sparc #24059
bridges-sparc-alignment.diff
+# make libsal v8 on sparc, #30774
+sparc-v8-fixes.diff
+
# Don't -DBUILD, -DBUILD_ID for our build system #12782: rc3
stlport-defeat-include.diff
diff --git a/patches/OOO_1_1_2/apply b/patches/OOO_1_1_2/apply
index 6528cb9c0..f11b39856 100644
--- a/patches/OOO_1_1_2/apply
+++ b/patches/OOO_1_1_2/apply
@@ -132,6 +132,12 @@ security-sonames.diff
# do not pack any potential .orig files with ppds
psprint_config-no-orig.diff
+# make libsal v8 on sparc, #30774
+sparc-v8-fixes.diff
+
+# fix tmpfile permissions, #33357
+tmpfile-fix.diff
+
[ ODKFixes ]
# Fix ODK Java bits