]>
Commit | Line | Data |
---|---|---|
38153d1a | 1 | --- oo_1.1rc3_src/psprint/source/helper/ppdparser.cxx.psprint-cups-PPD 2003-04-15 12:14:50.000000000 -0400 |
2 | +++ oo_1.1rc3_src/psprint/source/helper/ppdparser.cxx 2003-08-25 07:27:23.000000000 -0400 | |
3 | @@ -61,6 +61,9 @@ | |
4 | #include <stdlib.h> | |
5 | #include <stdio.h> | |
6 | ||
7 | +#ifndef __SGI_STL_MAP | |
8 | +#include <map> | |
9 | +#endif | |
10 | #ifndef __SGI_STL_HASH_MAP | |
11 | #include <hash_map> | |
12 | #endif | |
13 | @@ -83,6 +86,9 @@ struct std::hash< const psp::PPDKey* > | |
14 | #include <osl/file.hxx> | |
15 | #include <osl/process.h> | |
16 | #include <osl/thread.h> | |
17 | +#include <tools/fsys.hxx> | |
18 | +#include <rtl/bootstrap.hxx> | |
19 | +#include <cups/cups.h> | |
20 | ||
21 | #define PRINTER_PPDDIR "driver" | |
22 | ||
23 | @@ -173,6 +179,52 @@ void PPDParser::initPPDFiles() | |
24 | } | |
25 | } | |
26 | ||
27 | +static String GetPPDFileFromCUPS ( const String& rPrinter ) | |
28 | +{ | |
29 | + String aPPDFile; | |
30 | + const char *pPPDFile; | |
31 | + | |
32 | + // Try to get the PPD file from a CUPS server | |
33 | + pPPDFile = cupsGetPPD( OString( rPrinter.GetBuffer(), | |
34 | + rPrinter.Len(), | |
35 | + RTL_TEXTENCODING_UTF8 ).getStr() ); | |
36 | + | |
37 | + // If found, cache it immediately to the user psprint/drivers directory | |
38 | + if ( pPPDFile ) | |
39 | + { | |
40 | + // Get user psprint directory name | |
41 | + static OUString aUserPath; | |
42 | + static bOnce = false; | |
43 | + | |
44 | + if ( ! bOnce ) | |
45 | + { | |
46 | + bOnce = true; | |
47 | + OUString aIni; | |
48 | + osl_getExecutableFile( &aIni.pData ); | |
49 | + aIni = aIni.copy( 0, aIni.lastIndexOf( SAL_PATHDELIMITER )+1 ); | |
50 | + aIni += OUString( RTL_CONSTASCII_USTRINGPARAM( SAL_CONFIGFILE( "bootstrap" ) ) ); | |
51 | + Bootstrap aBootstrap( aIni ); | |
52 | + aBootstrap.getFrom( OUString( RTL_CONSTASCII_USTRINGPARAM( "UserInstallation" ) ), aUserPath ); | |
53 | + | |
54 | + if( ! aUserPath.compareToAscii( "file://", 7 ) ) | |
55 | + aUserPath = aUserPath.copy( 7 ); | |
56 | + | |
57 | + // The directory is bound to exist since it is created at installation time | |
58 | + aUserPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/user/psprint/" PRINTER_PPDDIR "/" ) ); | |
59 | + } | |
60 | + | |
61 | + // Copy and remove temporary PPD file | |
62 | + DirEntry aSrcPath( String::CreateFromAscii( pPPDFile ) ); | |
63 | + DirEntry aDstPath( aUserPath + rPrinter + String::CreateFromAscii( ".PPD" ) ); | |
64 | + aSrcPath.CopyTo( aDstPath, FSYS_ACTION_COPYFILE ); | |
65 | + remove( pPPDFile ); | |
66 | + | |
67 | + aPPDFile = aDstPath.GetFull(); | |
68 | + } | |
69 | + | |
70 | + return aPPDFile; | |
71 | +} | |
72 | + | |
73 | String PPDParser::getPPDFile( const String& rFile ) | |
74 | { | |
75 | INetURLObject aPPD( rFile, INET_PROT_FILE, INetURLObject::ENCODE_ALL ); | |
76 | @@ -195,6 +247,17 @@ String PPDParser::getPPDFile( const Stri | |
77 | if( it != pAllPPDFiles->end() ) | |
78 | aStream.Open( it->second, STREAM_READ ); | |
79 | } | |
80 | + if ( ! aStream.IsOpen() ) | |
81 | + { | |
82 | + // Try to get the PPD file from a CUPS server | |
83 | + String aFile( GetPPDFileFromCUPS( rFile ) ); | |
84 | + | |
85 | + if ( aFile.Len() ) | |
86 | + { | |
87 | + aPPD = INetURLObject( aFile, INET_PROT_FILE, INetURLObject::ENCODE_ALL ); | |
88 | + aStream.Open( aPPD.PathToFileName(), STREAM_READ ); | |
89 | + } | |
90 | + } | |
91 | ||
92 | String aRet; | |
93 | if( aStream.IsOpen() ) | |
94 | --- oo_1.1rc3_src/psprint/source/printer/printerinfomanager.cxx.psprint-cups-PPD 2003-08-25 07:29:03.000000000 -0400 | |
95 | +++ oo_1.1rc3_src/psprint/source/printer/printerinfomanager.cxx 2003-08-25 07:24:49.000000000 -0400 | |
96 | @@ -536,6 +536,37 @@ void PrinterInfoManager::initialize() | |
97 | aPrinter.m_bModified = false; | |
98 | aPrinter.m_aGroup = ByteString( aPrinterName, aEncoding ); //provide group name in case user makes this one permanent in padmin | |
99 | ||
100 | + const PPDParser* pParser = PPDParser::getParser( *it ); | |
101 | + if ( pParser ) | |
102 | + { | |
103 | + aPrinter.m_bModified = true; | |
104 | + aPrinter.m_aInfo.m_aDriverName = *it; | |
105 | + aPrinter.m_aInfo.m_pParser = pParser; | |
106 | + aPrinter.m_aInfo.m_aContext.setParser( pParser ); | |
107 | + | |
108 | + fillFontSubstitutions( aPrinter.m_aInfo ); | |
109 | + // merge PPD values with merge defaults | |
110 | + for( int nPPDValueModified = 0; nPPDValueModified < aMergeInfo.m_aContext.countValuesModified(); nPPDValueModified++ ) | |
111 | + { | |
112 | + const PPDKey* pDefKey = aMergeInfo.m_aContext.getModifiedKey( nPPDValueModified ); | |
113 | + const PPDValue* pDefValue = aMergeInfo.m_aContext.getValue( pDefKey ); | |
114 | + const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : NULL; | |
115 | + if( pDefKey && pPrinterKey ) | |
116 | + // at least the options exist in both PPDs | |
117 | + { | |
118 | + if( pDefValue ) | |
119 | + { | |
120 | + const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption ); | |
121 | + if( pPrinterValue ) | |
122 | + // the printer has a corresponding option for the key | |
123 | + aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, pPrinterValue ); | |
124 | + } | |
125 | + else | |
126 | + aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, NULL ); | |
127 | + } | |
128 | + } | |
129 | + } | |
130 | + | |
131 | m_aPrinters[ aPrinterName ] = aPrinter; | |
132 | } | |
133 | } | |
5931e141 AM |
134 | --- oo_1.1rc3_src/psprint/util/makefile.mk.orig 2004-03-30 02:07:00.000000000 +0000 |
135 | +++ oo_1.1rc3_src/psprint/util/makefile.mk 2004-03-30 02:07:14.000000000 +0000 | |
136 | @@ -103,7 +103,7 @@ | |
137 | SHL1STDLIBS=$(UNOTOOLSLIB) \ | |
38153d1a | 138 | $(TOOLSLIB) \ |
38153d1a | 139 | $(SALLIB) \ |
140 | - -lX11 | |
141 | + -lX11 -lcups | |
5931e141 AM |
142 | .IF "$(SOLAR_JAVA)"!="" |
143 | SHL1STDLIBS+=$(JVMACCESSLIB) | |
144 | .ENDIF |