View | Details | Raw Unified | Return to issue 19214
Collapse All | Expand All

(-)inc/psprint/printerinfomanager.hxx (+29 lines)
Lines 81-86 Link Here
81
#include <psprint/helper.hxx>
81
#include <psprint/helper.hxx>
82
#endif
82
#endif
83
83
84
#ifdef MACOSX
85
/* MacOS X print system discovery constants:
86
 *
87
 * These values enumerate Apple OS printing systems we could use.
88
 * They are used as indications _as well as_ indexes into the
89
 * aParms structure used below for print commands.
90
 */
91
#define		kApplePrintingFailure		0		/* For whatever reason, we can't print at all */
92
#define		kApplePrintingLPR			1		/* Darwin 5.x style LPR printing */
93
#define		kApplePrintingCUPS			2		/* MacOS X 10.2/Darwin 6 style CUPS (also CUPS installed by users on 10.1) */
94
#define		kApplePrintingPrintCenter	3		/* MacOS X 10.1 /usr/sbin/Print printing */
95
96
/* Constants for PostScript vs PDF printing */
97
#define		kApplePrintingUsePDF		1		/* Default; Run PS through ps2pdf first (requires GhostScript) */
98
#define		kApplePrintingUsePS			2		/* Optional, print PS directly to printer (less compatible, requires PS printer) */
99
100
/* Define various printing commands */
101
#define		kApplePCPrintCommand	"/usr/sbin/Print"		/* Mac OS X 10.1 Print Center Printing command */
102
#define		kApplePS2PDFLocation	"/usr/local/bin/ps2pdf"	/* PS -> PDF conversion command */
103
#define		kApplePCQueueName		"Apple Print Center Default Printer"	/* Name that appears in Print... dialog as the default */
104
																/* printer for 10.1 Print Center printing */
105
106
/* Prototype for print method discovery function.  Returns
107
 * a constant defined in printerinfomanager.hxx
108
 */
109
sal_Int32	macxp_GetSystemPrintMethod( void );
110
#endif
111
112
84
namespace psp
113
namespace psp
85
{
114
{
86
115
(-)inc/psprint/printerjob.hxx (-3 / +4 lines)
Lines 87-93 Link Here
87
87
88
    rtl::OUString           maSpoolDirName;
88
    rtl::OUString           maSpoolDirName;
89
    rtl::OUString           maFileName; // empty: spool to command, else spool to named file
89
    rtl::OUString           maFileName; // empty: spool to command, else spool to named file
90
    int						mnFileMode;
90
    int                     mnFileMode;
91
    rtl::OUString           maJobName;
91
92
92
    osl::File*              mpJobHeader;
93
    osl::File*              mpJobHeader;
93
    osl::File*              mpJobTrailer;
94
    osl::File*              mpJobTrailer;
Lines 95-103 Link Here
95
    std::list< osl::File* > maPageList;
96
    std::list< osl::File* > maPageList;
96
    std::list< osl::File* > maHeaderList;
97
    std::list< osl::File* > maHeaderList;
97
98
98
    JobData					m_aDocumentJobData;
99
    JobData                 m_aDocumentJobData;
99
    JobData                 m_aLastJobData;
100
    JobData                 m_aLastJobData;
100
    PrinterGfx*				m_pGraphics;
101
    PrinterGfx*             m_pGraphics;
101
102
102
    sal_uInt32      mnResolution;
103
    sal_uInt32      mnResolution;
103
104
(-)source/fontmanager/fontmanager.cxx (-4 / +150 lines)
Lines 159-164 Link Here
159
    return nRet;
159
    return nRet;
160
}
160
}
161
161
162
inline sal_uInt32 getUInt32BE( const sal_uInt8*& pBuffer )
163
{
164
    sal_uInt32 nRet = (((sal_uInt32)pBuffer[0]) << 24) |
165
                      (((sal_uInt32)pBuffer[1]) << 16) |
166
                      (((sal_uInt32)pBuffer[2]) << 8)  |
167
                      (((sal_uInt32)pBuffer[3]) );
168
    pBuffer += 4;
169
    return nRet;
170
}
171
162
static italic::type parseItalic( const ByteString& rItalic )
172
static italic::type parseItalic( const ByteString& rItalic )
163
{
173
{
164
    italic::type eItalic = italic::Unknown;
174
    italic::type eItalic = italic::Unknown;
Lines 376-381 Link Here
376
            // so currently we get kernpairs by accessing the raw data
386
            // so currently we get kernpairs by accessing the raw data
377
            struct _TrueTypeFont* pImplTTFont = (struct _TrueTypeFont*)pTTFont;
387
            struct _TrueTypeFont* pImplTTFont = (struct _TrueTypeFont*)pTTFont;
378
388
389
            //-----------------------------------------------------------------
390
            // Kerning:  KT_MICROSOFT
391
            //-----------------------------------------------------------------
379
            if( pImplTTFont->nkern && pImplTTFont->kerntype == KT_MICROSOFT )
392
            if( pImplTTFont->nkern && pImplTTFont->kerntype == KT_MICROSOFT )
380
            {
393
            {
381
                // create a glyph -> character mapping
394
                // create a glyph -> character mapping
Lines 433-440 Link Here
433
                            }
446
                            }
434
                        }
447
                        }
435
                        break;
448
                        break;
436
                        case 2:
437
449
450
                        case 2:
438
                        {
451
                        {
439
                            const sal_uInt8* pSubTable = pTable;
452
                            const sal_uInt8* pSubTable = pTable;
440
                            sal_uInt16 nRowWidth    = getUInt16BE( pTable );
453
                            sal_uInt16 nRowWidth    = getUInt16BE( pTable );
Lines 472-477 Link Here
472
                    }
485
                    }
473
                }
486
                }
474
            }
487
            }
488
489
            //-----------------------------------------------------------------
490
            // Kerning:  KT_APPLE_NEW
491
            //-----------------------------------------------------------------
492
            if( pImplTTFont->nkern && pImplTTFont->kerntype == KT_APPLE_NEW )
493
            {
494
                // create a glyph -> character mapping
495
                ::std::hash_map< sal_uInt16, sal_Unicode > aGlyphMap;
496
                ::std::hash_map< sal_uInt16, sal_Unicode >::iterator left, right;
497
                for( i = 21; i < 0xfffd; i++ )
498
                {
499
                    sal_uInt16 nGlyph = MapChar( pTTFont, (sal_Unicode)i, 0 ); // kerning for horz only
500
                    if( nGlyph != 0 )
501
                        aGlyphMap[ nGlyph ] = (sal_Unicode)i;
502
                }
503
                
504
                // Loop through each of the 'kern' subtables
505
                KernPair aPair;
506
                for( i = 0; i < pImplTTFont->nkern; i++ )
507
                {
508
                    const sal_uInt8* pTable = pImplTTFont->kerntables[i];
509
                    
510
                    sal_uInt32 nLength      = getUInt32BE( pTable );
511
                    sal_uInt16 nCoverage    = getUInt16BE( pTable );
512
                    sal_uInt16 nTupleIndex  = getUInt16BE( pTable );
513
514
                    // Get kerning type
515
                    sal_Bool bKernVertical     = nCoverage & 0x8000;
516
                    sal_Bool bKernCrossStream  = nCoverage & 0x4000;
517
                    sal_Bool bKernVariation    = nCoverage & 0x2000;
518
519
                    // Kerning sub-table format, 0 through 3
520
                    sal_uInt8 nSubTableFormat  = nCoverage & 0x00FF;
521
 
522
                    aPair.kern_x    = 0;
523
                    aPair.kern_y    = 0;
524
                    switch( nSubTableFormat )
525
                    {
526
                        case 0:
527
                        {
528
                            // Grab the # of kern pairs but skip over the:
529
                            //   searchRange
530
                            //   entrySelector
531
                            //   rangeShift
532
                            sal_uInt16 nPairs = getUInt16BE( pTable );
533
                            pTable += 6;
534
535
                            for( int n = 0; n < nPairs; n++ )
536
                            {
537
                                sal_uInt16 nLeftGlyph   = getUInt16BE( pTable );
538
                                sal_uInt16 nRightGlyph  = getUInt16BE( pTable );
539
                                sal_Int16  nKern         = (sal_Int16)getUInt16BE( pTable );
540
541
                                left = aGlyphMap.find( nLeftGlyph );
542
                                right = aGlyphMap.find( nRightGlyph );
543
                                if( left != aGlyphMap.end() && right != aGlyphMap.end() )
544
                                {
545
                                    aPair.first     = left->second;
546
                                    aPair.second    = right->second;
547
548
                                    // Only support horizontal kerning for now
549
                                    aPair.kern_x = (int)nKern * 1000 / pImplTTFont->unitsPerEm;
550
                                    aPair.kern_y = 0;
551
                                    m_pMetrics->m_aXKernPairs.push_back( aPair );
552
553
/*                                  switch( nCoverage & 1 )
554
                                    {
555
                                        case 1:
556
                                            aPair.kern_x = (int)nKern * 1000 / pImplTTFont->unitsPerEm;
557
                                            m_pMetrics->m_aXKernPairs.push_back( aPair );
558
                                            break;
559
                                        case 0:
560
                                            aPair.kern_y = (int)nKern * 1000 / pImplTTFont->unitsPerEm;
561
                                            m_pMetrics->m_aYKernPairs.push_back( aPair );
562
                                            break;                                          
563
                                    }
564
*/
565
                                }
566
                            }
567
                        }
568
                        break;
569
570
                        case 2:
571
                        {
572
                            const sal_uInt8* pSubTable = pTable;
573
                            sal_uInt16 nRowWidth    = getUInt16BE( pTable );
574
                            sal_uInt16 nOfLeft      = getUInt16BE( pTable );
575
                            sal_uInt16 nOfRight     = getUInt16BE( pTable );
576
                            sal_uInt16 nOfArray     = getUInt16BE( pTable );
577
                            const sal_uInt8* pTmp = pSubTable + nOfLeft;
578
                            sal_uInt16 nFirstLeft   = getUInt16BE( pTmp );
579
                            sal_uInt16 nLastLeft    = getUInt16BE( pTmp ) + nFirstLeft - 1;
580
                            pTmp = pSubTable + nOfRight;
581
                            sal_uInt16 nFirstRight  = getUInt16BE( pTmp );
582
                            sal_uInt16 nLastRight   = getUInt16BE( pTmp ) + nFirstRight -1;
583
584
                            int nPairs = (int)(nLastLeft-nFirstLeft+1)*(int)(nLastRight-nFirstRight+1);
585
                            for( aPair.first = nFirstLeft; aPair.first < nLastLeft; aPair.first++ )
586
                            {
587
                                for( aPair.second = 0; aPair.second < nLastRight; aPair.second++ )
588
                                {
589
                                    sal_Int16 nKern = (sal_Int16)getUInt16BE( pTmp );
590
                                    switch( nCoverage & 1 )
591
                                    {
592
                                        case 1:
593
                                            aPair.kern_x = (int)nKern * 1000 / pImplTTFont->unitsPerEm;
594
                                            m_pMetrics->m_aXKernPairs.push_back( aPair );
595
                                            break;
596
                                        case 0:
597
                                            aPair.kern_y = (int)nKern * 1000 / pImplTTFont->unitsPerEm;
598
                                            m_pMetrics->m_aYKernPairs.push_back( aPair );
599
                                            break;                                          
600
                                    }
601
                                }
602
                            }
603
                        }
604
                        break;
605
606
                        default:
607
                            fprintf( stderr, "Found unsupported Apple-style kern subtable type %d.\n", nSubTableFormat );
608
                            break;
609
                    }
610
                }
611
            }
612
475
#if OSL_DEBUG_LEVEL > 1
613
#if OSL_DEBUG_LEVEL > 1
476
            fprintf( stderr, "found %d/%d kern pairs for %s\n",
614
            fprintf( stderr, "found %d/%d kern pairs for %s\n",
477
                     m_pMetrics->m_aXKernPairs.size(),
615
                     m_pMetrics->m_aXKernPairs.size(),
Lines 1438-1446 Link Here
1438
                aNames.pop_front();
1576
                aNames.pop_front();
1439
            }
1577
            }
1440
            else
1578
            else
1441
                // poor font does not have a family name
1579
            {
1442
                // name it to file name minus ".tt{f|c}"
1580
                 sal_Int32   dotIndex;
1443
                pFont->m_nFamilyName = m_pAtoms->getAtom( ATOM_FAMILYNAME, OStringToOUString( pTTFontFile->m_aFontFile.copy( 0, pTTFontFile->m_aFontFile.getLength()-4 ), aEncoding ), sal_True );
1581
1582
                 // poor font does not have a family name
1583
                 // name it to file name minus the extension
1584
                 dotIndex = pTTFontFile->m_aFontFile.lastIndexOf( '.' );
1585
                 if ( dotIndex == -1 )
1586
                     dotIndex = pTTFontFile->m_aFontFile.getLength();
1587
1588
                 pFont->m_nFamilyName = m_pAtoms->getAtom( ATOM_FAMILYNAME, OStringToOUString( pTTFontFile->m_aFontFile.copy( 0, dotIndex ), aEncoding ), sal_True );
1589
            }
1444
        }
1590
        }
1445
        pFont->m_aAliases.clear();
1591
        pFont->m_aAliases.clear();
1446
        for( ::std::list< OUString >::iterator it = aNames.begin(); it != aNames.end(); ++it )
1592
        for( ::std::list< OUString >::iterator it = aNames.begin(); it != aNames.end(); ++it )
(-)source/fontsubset/sft.c (+5 lines)
Lines 1344-1349 Link Here
1344
        eID = GetUInt16(table, 6 + i * 8, 1);
1344
        eID = GetUInt16(table, 6 + i * 8, 1);
1345
        offset = GetUInt32(table, 8 + i * 8, 1);
1345
        offset = GetUInt32(table, 8 + i * 8, 1);
1346
1346
1347
        /* Unicode tables in Apple fonts */
1348
        if (pID == 0) {
1349
            ThreeOne   = offset; break;
1350
        }
1351
1347
        if (pID == 3) {
1352
        if (pID == 3) {
1348
            switch (eID) {
1353
            switch (eID) {
1349
                case 0: ThreeZero  = offset; break;
1354
                case 0: ThreeZero  = offset; break;
(-)source/helper/helper.cxx (+13 lines)
Lines 74-79 Link Here
74
#include <sal/config.h>
74
#include <sal/config.h>
75
#include "jvmaccess/javainfo.hxx"
75
#include "jvmaccess/javainfo.hxx"
76
76
77
#define OSL_DEBUG_LEVEL 2
78
77
using namespace rtl;
79
using namespace rtl;
78
80
79
namespace psp {
81
namespace psp {
Lines 143-150 Link Here
143
    {
145
    {
144
        OUString aNetPath = getOfficePath( psp::NetPath );
146
        OUString aNetPath = getOfficePath( psp::NetPath );
145
        OUString aUserPath = getOfficePath( psp::UserPath );
147
        OUString aUserPath = getOfficePath( psp::UserPath );
148
149
#ifdef MACOSX
150
        // For CUPS printing, add /etc/cups/ppd to pull in autogenerated printer PPDs
151
        aPath += OUString( RTL_CONSTASCII_USTRINGPARAM("/etc/cups/ppd") );
152
#endif
146
        if( aNetPath.getLength() )
153
        if( aNetPath.getLength() )
147
        {
154
        {
155
            if( aPath.getLength() )
156
                aPath += OUString( RTL_CONSTASCII_USTRINGPARAM( ":" ) );
148
            aPath += aNetPath;
157
            aPath += aNetPath;
149
            aPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/share/psprint" ) );
158
            aPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/share/psprint" ) );
150
        }
159
        }
Lines 177-183 Link Here
177
        if( ! aDir.getLength() )
186
        if( ! aDir.getLength() )
178
            continue;
187
            continue;
179
188
189
#ifdef MACOSX
190
        if( pSubDir && !aDir.equals(OString("/etc/cups/ppd")) )
191
#else
180
        if( pSubDir )
192
        if( pSubDir )
193
#endif
181
        {
194
        {
182
            aDir += "/";
195
            aDir += "/";
183
            aDir += pSubDir;
196
            aDir += pSubDir;
(-)source/helper/makefile.mk (+10 lines)
Lines 72-81 Link Here
72
72
73
# --- Files --------------------------------------------------------
73
# --- Files --------------------------------------------------------
74
74
75
.IF "$(GUIBASE)"=="aqua"
76
77
dummy:
78
	@echo "Nothing to build for GUIBASE $(GUIBASE)"
79
80
.ELSE		# "$(GUIBASE)"=="aqua"
81
75
SLOFILES=\
82
SLOFILES=\
76
	$(SLO)$/ppdparser.obj	\
83
	$(SLO)$/ppdparser.obj	\
77
	$(SLO)$/strhelper.obj	\
84
	$(SLO)$/strhelper.obj	\
78
	$(SLO)$/helper.obj
85
	$(SLO)$/helper.obj
86
87
88
.ENDIF # GUIBASE = aqua
79
89
80
# --- Targets ------------------------------------------------------
90
# --- Targets ------------------------------------------------------
81
91
(-)source/helper/ppdparser.cxx (+26 lines)
Lines 267-273 Link Here
267
267
268
    aFile = getPPDFile( aFile );
268
    aFile = getPPDFile( aFile );
269
    if( ! aFile.Len() )
269
    if( ! aFile.Len() )
270
{
271
fprintf( stderr, "Could not get printer PPD file!\n" );
270
        return NULL;
272
        return NULL;
273
}
271
274
272
    for( ::std::list< PPDParser* >::const_iterator it = aAllParsers.begin(); it != aAllParsers.end(); ++it )
275
    for( ::std::list< PPDParser* >::const_iterator it = aAllParsers.begin(); it != aAllParsers.end(); ++it )
273
        if( (*it)->m_aFile == aFile )
276
        if( (*it)->m_aFile == aFile )
Lines 442-447 Link Here
442
        m_nLanguageLevel = pKey->getValue( 0 )->m_aValue.ToInt32();
445
        m_nLanguageLevel = pKey->getValue( 0 )->m_aValue.ToInt32();
443
    if( pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "TTRasterizer" ) ) ) )
446
    if( pKey = getKey( String( RTL_CONSTASCII_USTRINGPARAM( "TTRasterizer" ) ) ) )
444
        m_bType42Capable = pKey->getValue( 0 )->m_aValue.EqualsIgnoreCaseAscii( "Type42" ) ? true : false;
447
        m_bType42Capable = pKey->getValue( 0 )->m_aValue.EqualsIgnoreCaseAscii( "Type42" ) ? true : false;
448
449
#ifdef MACOSX
450
    // Many Mac OS X PPDs for inkjet printers simply use CUPS to convert the output to a PDF,
451
    // and to take advantage of that we wish to embed fonts for these printers even if its
452
    // minimal CUPS PPD doesn't have TTRasterizer.
453
    // To determine if this printer is supposed to take PDF input, look for the "cupsFilter" key,
454
    // and if it exists, for the string "application/pdf" which specifies the CUPS filter to use for it
455
    // If present, we assume that we can embed TrueType fonts and that the CUPS filter will take care
456
    // of rasterizing them appropriately.
457
    if ( m_bType42Capable == false )
458
    {
459
        if ( pKey = getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) ) )
460
        {
461
            ByteString    aCupsFilterString( pKey->getValue( 0 )->m_aValue, RTL_TEXTENCODING_ISO_8859_1 );
462
            if ( strstr(aCupsFilterString.GetBuffer(), "application/pdf") > 0 )
463
                m_bType42Capable = true;
464
        }
465
    }
466
#endif
445
}
467
}
446
468
447
PPDParser::~PPDParser()
469
PPDParser::~PPDParser()
Lines 566-571 Link Here
566
        // found a colon, there may be an option
588
        // found a colon, there may be an option
567
        String aLine = aCurrentLine.Copy( 1, nPos-1 );
589
        String aLine = aCurrentLine.Copy( 1, nPos-1 );
568
        aLine = WhitespaceToSpace( aLine );
590
        aLine = WhitespaceToSpace( aLine );
591
    #ifdef MACOSX
592
        // Some Epson PPDs use <20> to encodes spaces in UI strings
593
        aLine.SearchAndReplaceAllAscii( "<20>", String(RTL_CONSTASCII_USTRINGPARAM(" ")) );
594
    #endif
569
        int nTransPos = aLine.Search( '/' );
595
        int nTransPos = aLine.Search( '/' );
570
        if( nTransPos != STRING_NOTFOUND )
596
        if( nTransPos != STRING_NOTFOUND )
571
            pValue->m_aOptionTranslation = aLine.Copy( nTransPos+1 );
597
            pValue->m_aOptionTranslation = aLine.Copy( nTransPos+1 );
(-)source/printer/makefile.mk (+8 lines)
Lines 72-81 Link Here
72
72
73
# --- Files --------------------------------------------------------
73
# --- Files --------------------------------------------------------
74
74
75
.IF "$(GUIBASE)"=="aqua"
76
77
dummy:
78
	@echo "Nothing to build for GUIBASE $(GUIBASE)"
79
80
.ELSE		# "$(GUIBASE)"=="aqua"
81
75
SLOFILES=\
82
SLOFILES=\
76
	$(SLO)$/printerinfomanager.obj	\
83
	$(SLO)$/printerinfomanager.obj	\
77
	$(SLO)$/jobdata.obj
84
	$(SLO)$/jobdata.obj
78
85
86
.ENDIF # GUIBASE = aqua
79
87
80
# --- Targets ------------------------------------------------------
88
# --- Targets ------------------------------------------------------
81
89
(-)source/printer/printerinfomanager.cxx (-37 / +412 lines)
Lines 73-83 Link Here
73
#include <osl/thread.hxx>
73
#include <osl/thread.hxx>
74
#include <osl/mutex.hxx>
74
#include <osl/mutex.hxx>
75
75
76
#ifdef MACOSX
77
#include <sys/stat.h>
78
#endif
79
76
// filename of configuration files
80
// filename of configuration files
77
#define PRINT_FILENAME  "psprint.conf"
81
#define PRINT_FILENAME  "psprint.conf"
78
// the group of the global defaults
82
// the group of the global defaults
79
#define GLOBAL_DEFAULTS_GROUP "__Global_Printer_Defaults__"
83
#define GLOBAL_DEFAULTS_GROUP "__Global_Printer_Defaults__"
80
84
85
#ifdef MACOSX
86
// filename of CUPS config file
87
#define MACXP_CUPS_CONF_FILENAME   "printers.conf"
88
#define MACXP_CUPS_CONF_DIR        "/etc/cups/"
89
#endif
90
81
using namespace psp;
91
using namespace psp;
82
using namespace rtl;
92
using namespace rtl;
83
using namespace osl;
93
using namespace osl;
Lines 165-171 Link Here
165
    if( ! bChanged )
175
    if( ! bChanged )
166
        bChanged = m_pQueueInfo->hasChanged();
176
        bChanged = m_pQueueInfo->hasChanged();
167
    if( bChanged )
177
    if( bChanged )
178
    {
179
#ifdef MACOSX
180
        // For Mac OS X 10.2, the user may change print queues via the Print Center
181
        // at any point.  Therefore, we need to completely requery the system
182
        // for print queues when our watch file changes.
183
        sal_Int32    applePrintSystem;
184
185
        applePrintSystem = macxp_GetSystemPrintMethod();
186
        if ( applePrintSystem == kApplePrintingCUPS )
187
            m_aSystemPrintQueues.clear();
188
#endif
168
        initialize();
189
        initialize();
190
    }
169
191
170
    return bChanged;
192
    return bChanged;
171
}
193
}
Lines 174-184 Link Here
174
196
175
void PrinterInfoManager::initialize()
197
void PrinterInfoManager::initialize()
176
{
198
{
199
#ifdef MACOSX
200
    sal_Int32    applePrintSystem;
201
#endif
177
    rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding();
202
    rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding();
178
    m_aPrinters.clear();
203
    m_aPrinters.clear();
179
    m_aWatchFiles.clear();
204
    m_aWatchFiles.clear();
180
    OUString aDefaultPrinter;
205
    OUString aDefaultPrinter;
181
206
207
#ifdef MACOSX
208
    // Discover the print system to use on Mac OS X/Darwin
209
    applePrintSystem = macxp_GetSystemPrintMethod();
210
#endif
211
182
    // first initialize the global defaults
212
    // first initialize the global defaults
183
    // have to iterate over all possible files
213
    // have to iterate over all possible files
184
    // there should be only one global setup section in all
214
    // there should be only one global setup section in all
Lines 220-226 Link Here
220
            m_aGlobalDefaults.m_eOrientation = aValue.EqualsIgnoreCaseAscii( "Landscape" ) ? orientation::Landscape : orientation::Portrait;
250
            m_aGlobalDefaults.m_eOrientation = aValue.EqualsIgnoreCaseAscii( "Landscape" ) ? orientation::Landscape : orientation::Portrait;
221
251
222
            aValue = aConfig.ReadKey( "Scale" );
252
            aValue = aConfig.ReadKey( "Scale" );
223
            m_aGlobalDefaults.m_nScale = aValue.ToInt32();
253
		  if ( aValue.Len() )
254
                m_aGlobalDefaults.m_nScale = aValue.ToInt32();
224
255
225
            aValue = aConfig.ReadKey( "MarginAdjust" );
256
            aValue = aConfig.ReadKey( "MarginAdjust" );
226
            m_aGlobalDefaults.m_nLeftMarginAdjust   = aValue.GetToken( 0, ',' ).ToInt32();
257
            m_aGlobalDefaults.m_nLeftMarginAdjust   = aValue.GetToken( 0, ',' ).ToInt32();
Lines 273-278 Link Here
273
    }
304
    }
274
    fillFontSubstitutions( m_aGlobalDefaults );
305
    fillFontSubstitutions( m_aGlobalDefaults );
275
306
307
#ifdef MACOSX
308
    // For Mac OS X 10.2 with CUPS printing, we also wish to be
309
    // notified of queue/printer updates, but these don't necessarily
310
    // happen when psprint.conf changes.  The user can change settings in
311
    // the Print Center which should also make OOo update its queue list.
312
    if ( applePrintSystem == kApplePrintingCUPS )
313
    {
314
        // /etc/cups/printers.conf gets modified every time the Print Center printer
315
        // list is modified, so we want to watch this file too.
316
        INetURLObject aCUPSDir( String(RTL_CONSTASCII_USTRINGPARAM(MACXP_CUPS_CONF_DIR)), INET_PROT_FILE, INetURLObject::ENCODE_ALL );
317
        INetURLObject aCUPSConfFile( aCUPSDir );
318
        aCUPSConfFile.Append( String(RTL_CONSTASCII_USTRINGPARAM(MACXP_CUPS_CONF_FILENAME)) );
319
320
        // check directory validity
321
        OUString aCUPSUniPath;
322
        FileBase::getFileURLFromSystemPath( aCUPSDir.PathToFileName(), aCUPSUniPath );
323
        Directory aTestDirectory( aCUPSUniPath );
324
325
        // If aTestDirectory.open() returns E_None (0), then we are OK.
326
        // If not, don't add the watch file because we can't get to it.
327
        if( aTestDirectory.open() == FileBase::E_None )
328
        {
329
            aTestDirectory.close();
330
331
            FileBase::getFileURLFromSystemPath( aCUPSConfFile.PathToFileName(), aCUPSUniPath );
332
            FileStatus aTestStatus( FileStatusMask_All );
333
            DirectoryItem aTestItem;
334
335
            // setup WatchFile list
336
            WatchFile aCUPSWatchFile;
337
            aCUPSWatchFile.m_aFilePath = aCUPSUniPath;
338
            if( ! DirectoryItem::get( aCUPSUniPath, aTestItem ) &&
339
                ! aTestItem.getFileStatus( aTestStatus ) )
340
            {
341
                aCUPSWatchFile.m_aModified = aTestStatus.getModifyTime();
342
            }
343
            else
344
            {
345
                aCUPSWatchFile.m_aModified.Seconds = 0;
346
                aCUPSWatchFile.m_aModified.Nanosec = 0;
347
            }
348
            m_aWatchFiles.push_back( aCUPSWatchFile );
349
        }
350
    }
351
#endif
352
276
    // now collect all available printers
353
    // now collect all available printers
277
    for( print_dir_it = aDirList.begin(); print_dir_it != aDirList.end(); ++print_dir_it )
354
    for( print_dir_it = aDirList.begin(); print_dir_it != aDirList.end(); ++print_dir_it )
278
    {
355
    {
Lines 377-382 Link Here
377
                     */
454
                     */
378
#if defined SOLARIS || defined(IRIX)
455
#if defined SOLARIS || defined(IRIX)
379
                    aValue = "lp";
456
                    aValue = "lp";
457
#elif defined(MACOSX)
458
                    if ( applePrintSystem == kApplePrintingCUPS )
459
                        aValue = "lp";
460
                    else if ( applePrintSystem == kApplePrintingPrintCenter )
461
                        aValue = kApplePCPrintCommand;
462
                    else
463
                    {
464
                        // Fallback case is kApplePrintingLPR
465
                        aValue = "lpr";
466
                    }
380
#else
467
#else
381
                    aValue = "lpr";
468
                    aValue = "lpr";
382
#endif
469
#endif
Lines 405-415 Link Here
405
                if( aValue.Len() )
492
                if( aValue.Len() )
406
                    aPrinter.m_aInfo.m_eOrientation = aValue.EqualsIgnoreCaseAscii( "Landscape" ) ? orientation::Landscape : orientation::Portrait;
493
                    aPrinter.m_aInfo.m_eOrientation = aValue.EqualsIgnoreCaseAscii( "Landscape" ) ? orientation::Landscape : orientation::Portrait;
407
494
495
                aValue = aConfig.ReadKey( "Scale" );
408
                if( aValue.Len() )
496
                if( aValue.Len() )
409
                {
410
                    aValue = aConfig.ReadKey( "Scale" );
411
                    aPrinter.m_aInfo.m_nScale = aValue.ToInt32();
497
                    aPrinter.m_aInfo.m_nScale = aValue.ToInt32();
412
                }
413
498
414
                aValue = aConfig.ReadKey( "MarginAdjust" );
499
                aValue = aConfig.ReadKey( "MarginAdjust" );
415
                if( aValue.Len() )
500
                if( aValue.Len() )
Lines 536-541 Link Here
536
        aPrinter.m_bModified                = false;
621
        aPrinter.m_bModified                = false;
537
        aPrinter.m_aGroup                   = ByteString( aPrinterName, aEncoding ); //provide group name in case user makes this one permanent in padmin
622
        aPrinter.m_aGroup                   = ByteString( aPrinterName, aEncoding ); //provide group name in case user makes this one permanent in padmin
538
623
624
#ifdef MACOSX
625
        // If we are using OS X 10.2 CUPS printing, we want to grab the PPD that this printer
626
        // is associated with from /etc/cups/ppd (it's autocreated by the OS X printing system) and
627
        // use those values instead of the ones generated in the merged defaults.  We want to make
628
        // this system printer just like we assigned it a PPD in padmin.
629
        if ( applePrintSystem == kApplePrintingCUPS )
630
        {
631
            aPrinter.m_aInfo.m_aFontSubstitutes.clear();
632
            aPrinter.m_aInfo.m_aFontSubstitutions.clear();
633
634
            // Printer's autogenerated PPD will be /etc/cups/ppd/<printername-from-lpstat>.ppd
635
            aPrinter.m_aInfo.m_aDriverName      = String( *it );
636
            aPrinter.m_aInfo.m_pParser          = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
637
            aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
638
639
            if( aPrinter.m_aInfo.m_pParser )
640
            {
641
                // merge the ppd context keys if the printer has the same keys and values
642
                // it is mainly to select default paper sizes for new printers
643
                for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ )
644
                {
645
                    const PPDKey* pDefKey = m_aGlobalDefaults.m_aContext.getModifiedKey( nPPDValueModified );
646
                    const PPDValue* pDefValue = m_aGlobalDefaults.m_aContext.getValue( pDefKey );
647
				// If the default PPD has a certain key, attempt to get that same key in the Printer's PPD
648
                    const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : NULL;
649
650
                    // The key usually merged is PageSize
651
                    if( pDefKey && pPrinterKey )
652
                    {
653
                        // Key exists in both the Default PPD and the printer's specific PPD.
654
                        if( pDefValue )
655
                        {
656
                            const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption );
657
                            // If the printer has a corresponding option for the key, use printer PPD's option
658
                            if( pPrinterValue )
659
                                aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, pPrinterValue );
660
                        }
661
                        else
662
                            aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, NULL );
663
                    }
664
                }
665
666
                // Some CUPS PPDs on Mac OS X (Epson, HP) don't include the requisite
667
                // PageSize information for the value.  We have to fudge it from the
668
                // margin information.  Others (Canon BJC 8200) have the coordinates
669
			 // but not the "setpagedevice" stuff
670
                const PPDKey* pPSizeKey = aPrinter.m_aInfo.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("PageSize")) );
671
                if ( pPSizeKey )
672
                {
673
                    int           psIndex = 0;
674
                    int           nNumValues = pPSizeKey->countValues();
675
676
                    for ( psIndex = 0; psIndex < nNumValues; psIndex++ )
677
                    {
678
                        const PPDValue*   pPSizeValue = pPSizeKey->getValue( psIndex );
679
680
                        // Only take care of PPD values that are not formatted correctly.
681
                        if (  pPSizeValue &&
682
                              ( !(pPSizeValue->m_aValue.Len()) ||
683
                              (pPSizeValue->m_aValue.Len() && (pPSizeValue->m_aValue.SearchAscii("setpagedevice")==STRING_NOTFOUND)) )
684
                           )
685
                        {
686
                            // Deal with the two cases:  1) where there is a blank PageSize value and
687
                            // 2) where there are simply the dimensions as the PageSize value
688
                            if ( !pPSizeValue->m_aValue.Len() )
689
                            {
690
                                int     paperWidth;
691
                                int     paperHeight;
692
                                char    aWidth[ 32 ];
693
                                char    aHeight[ 32 ];
694
695
                                // Grab dimensions for this paper size from the "PaperDimension" key of the PPD
696
                                aPrinter.m_aInfo.m_pParser->getPaperDimension( pPSizeValue->m_aOption, paperWidth, paperHeight );
697
                                snprintf( aWidth, 32, "%d", paperWidth );
698
                                snprintf( aHeight, 32, "%d", paperHeight );
699
700
                                // Construct a suitable PageSize key value from the PaperDimension values for this paper size
701
                           	  pPSizeValue->m_aValue.AppendAscii( "<</PageSize [" );
702
                                pPSizeValue->m_aValue.AppendAscii( aWidth );
703
                           	  pPSizeValue->m_aValue.AppendAscii( " " );
704
                                pPSizeValue->m_aValue.AppendAscii( aHeight );
705
                           	  pPSizeValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" );
706
                            }
707
                            else
708
            			   {
709
                                String  aBox( pPSizeValue->m_aValue );
710
				   
711
                                // The PageSize value was just the bounding box, add in the correct postscript
712
                                pPSizeValue->m_aValue.AssignAscii( "" );
713
                           	  pPSizeValue->m_aValue.AppendAscii( "<</PageSize [" );
714
                                pPSizeValue->m_aValue.Append( aBox );
715
                           	  pPSizeValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" );
716
            			   }
717
                        }
718
                    }
719
                }
720
            }
721
		  else
722
            {
723
                ByteString  aBytePrinterName = ByteString( UniString(aPrinter.m_aInfo.m_aDriverName), RTL_TEXTENCODING_UTF8 );
724
                fprintf( stderr, "Could not get Printer PPD from /etc/cups/ppd for printer '%s'!  Using simple shared printer PPD...\n", aBytePrinterName.GetBuffer() );
725
726
                // Some printers don't have the PPDs in /etc/cups/ppd (like Rendezvous-shared ones)
727
                // so we have to simply use a stripped down shared printer PPD for them
728
                aPrinter.m_aInfo.m_aDriverName    = String( RTL_CONSTASCII_USTRINGPARAM("MacShared") );
729
                aPrinter.m_aInfo.m_pParser        = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
730
                aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
731
                if( !(aPrinter.m_aInfo.m_pParser) )
732
                {
733
                    fprintf( stderr, "Warning:  still couldn't load the PPD, MacShared.ppd may be missing.  Will use generic printer PPD.\n" );
734
                    aPrinter.m_aInfo.m_aDriverName    = String( RTL_CONSTASCII_USTRINGPARAM("SGENPRT") );
735
                    aPrinter.m_aInfo.m_pParser        = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
736
                    aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
737
                }
738
            }
739
        }
740
#endif
741
539
        m_aPrinters[ aPrinterName ] = aPrinter;
742
        m_aPrinters[ aPrinterName ] = aPrinter;
540
    }
743
    }
541
}
744
}
Lines 1017-1022 Link Here
1017
    { "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 },
1220
    { "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 },
1018
    { "lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 },
1221
    { "lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 },
1019
    { "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 }
1222
    { "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 }
1223
#elif defined(MACOSX)
1224
    /* These elements correspond to the constants defined for Apple printing in
1225
     * printerinfomanager.hxx and are indexed by those constants.  ORDER IS IMPORTANT!!!
1226
	*/
1227
    /* Apple LPR printing (kApplePrintingLPR) */
1228
    { "/usr/bin/lpc status", "lpr -P (PRINTER)", "", ":", 0 },
1229
    /* Apple CUPS printing (kApplePrintingCUPS) */
1230
    { "LANG=C;LC_ALL=C;export LANG LC_ALL;/usr/bin/lpstat -s", "lp -d (PRINTER)", "device for ", ": ", 1 },
1231
    /* Apple Print Center printing (kApplePrintingPrintCenter) */
1232
    { kApplePCQueueName, kApplePCPrintCommand, "", ":", 0 }
1020
#else
1233
#else
1021
    { "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 },
1234
    { "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 },
1022
    { "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 },
1235
    { "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 },
Lines 1033-1041 Link Here
1033
    bool bSuccess = false;
1246
    bool bSuccess = false;
1034
    std::list< ByteString > aLines;
1247
    std::list< ByteString > aLines;
1035
    rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding();
1248
    rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding();
1036
1037
    OUString aPrintCommand;
1249
    OUString aPrintCommand;
1038
    
1250
    
1251
#ifdef MACOSX
1252
    sal_Int32	applePrintSysType;
1253
	   
1254
    /* Get our OS specific printing scheme for MacOS X */
1255
    applePrintSysType = macxp_GetSystemPrintMethod();
1256
#endif
1257
1258
    /* Discover which command we can use to get a list of all printer queues */
1039
    for( i = 0; i < sizeof(aParms)/sizeof(aParms[0]) && ! bSuccess; i++ )
1259
    for( i = 0; i < sizeof(aParms)/sizeof(aParms[0]) && ! bSuccess; i++ )
1040
    {
1260
    {
1041
        aLines.clear();
1261
        aLines.clear();
Lines 1047-1100 Link Here
1047
#if OSL_DEBUG_LEVEL > 1
1267
#if OSL_DEBUG_LEVEL > 1
1048
        fprintf( stderr, "trying print queue command \"%s\" ... ", aParms[i].pQueueCommand );
1268
        fprintf( stderr, "trying print queue command \"%s\" ... ", aParms[i].pQueueCommand );
1049
#endif
1269
#endif
1050
        if( pPipe = popen( aPrtQueueCmd.GetBuffer(), "r" ) )
1270
      #ifdef MACOSX
1271
        /* For Mac OS X 10.1 Print Center printing, we only use the default queue.  We do not
1272
         * need to discover it.  So when it comes up in the list of possible queues,
1273
         * recognize it and declare success.
1274
         */
1275
        if ( applePrintSysType == kApplePrintingPrintCenter )
1051
        {
1276
        {
1052
            while( fgets( pBuffer, 1024, pPipe ) )
1277
             if ( strstr(aPrtQueueCmd.GetBuffer(), kApplePCQueueName) != NULL )
1053
                aLines.push_back( ByteString( pBuffer ) );
1278
                 bSuccess = TRUE;
1054
            if( ! pclose( pPipe ) )
1279
           #ifdef DEBUG
1055
                bSuccess = true;
1280
             else
1281
                 fprintf( stderr, "Ignoring print queue command \"%s\" because using 10.1 Print Center printing.\n", aParms[i].pQueueCommand );
1282
           #endif
1283
        }
1284
        else
1285
      #endif
1286
        {
1287
            if( pPipe = popen( aPrtQueueCmd.GetBuffer(), "r" ) )
1288
            {
1289
                while( fgets( pBuffer, 1024, pPipe ) )
1290
                    aLines.push_back( ByteString( pBuffer ) );
1291
                if( ! pclose( pPipe ) )
1292
                    bSuccess = true;
1293
            }
1056
        }
1294
        }
1057
#if OSL_DEBUG_LEVEL > 1
1295
#if OSL_DEBUG_LEVEL > 1
1058
        fprintf( stderr, "%s\n", bSuccess ? "success" : "failed" );
1296
        fprintf( stderr, "%s\n", bSuccess ? "success" : "failed" );
1059
#endif
1297
#endif
1060
    }
1298
    }
1061
1299
1062
    if( bSuccess )
1300
#ifdef MACOSX
1301
    /* Since we only print to the default printer for MacOS X 10.1,
1302
     * queue discovery serves no purpose.
1303
     */
1304
    if ( applePrintSysType == kApplePrintingPrintCenter )
1063
    {
1305
    {
1064
        std::list< OUString > aSysPrintQueues;
1306
        std::list< OUString > aSysPrintQueues;
1065
1307
1066
        while( aLines.begin() != aLines.end() )
1308
        aSysPrintQueues.push_back( OUString::createFromAscii(kApplePCQueueName) );
1309
      #ifdef DEBUG
1310
        fprintf( stderr, "printerinfomanager.cxx: using Print Center default print queue.\n" );
1311
      #endif
1312
1313
        MutexGuard aGuard( m_aMutex );
1314
        m_bChanged	= true;
1315
        m_aQueues	= aSysPrintQueues;
1316
        m_aCommand	= aPrintCommand;
1317
    }
1318
    else
1319
#endif	/* MACOSX */
1320
    {
1321
        /* Normal Unix print queue discovery, also used for Darwin 5 LPR printing
1322
         * and MacOS X 10.2/Darwin 6 CUPS printing.
1323
         */
1324
        if( bSuccess )
1067
        {
1325
        {
1068
            int nPos = 0, nAftPos;
1326
            std::list< OUString > aSysPrintQueues;
1327
1328
            while( aLines.begin() != aLines.end() )
1329
            {
1330
                int nPos = 0, nAftPos;
1069
            
1331
            
1070
            ByteString aOutLine( aLines.front() );
1332
                ByteString aOutLine( aLines.front() );
1071
            aLines.pop_front();
1333
                aLines.pop_front();
1072
            
1334
            
1073
            for( int i = 0; i < nForeTokenCount && nPos != STRING_NOTFOUND; i++ )
1335
                for( int i = 0; i < nForeTokenCount && nPos != STRING_NOTFOUND; i++ )
1074
            {
1075
                nPos = aOutLine.Search( aForeToken, nPos );
1076
                if( nPos != STRING_NOTFOUND && aOutLine.Len() >= nPos+aForeToken.Len() )
1077
                    nPos += aForeToken.Len();
1078
            }
1079
            if( nPos != STRING_NOTFOUND )
1080
            {
1081
                nAftPos = aOutLine.Search( aAftToken, nPos );
1082
                if( nAftPos != STRING_NOTFOUND )
1083
                {
1336
                {
1084
                    OUString aSysQueue( String( aOutLine.Copy( nPos, nAftPos - nPos ), aEncoding ) );
1337
                    nPos = aOutLine.Search( aForeToken, nPos );
1085
                    // do not insert duplicates (e.g. lpstat tends to produce such lines)
1338
                    if( nPos != STRING_NOTFOUND && aOutLine.Len() >= nPos+aForeToken.Len() )
1086
                    std::list< OUString >::const_iterator it;
1339
                        nPos += aForeToken.Len();
1087
                    for( it = aSysPrintQueues.begin(); it != aSysPrintQueues.end() && *it != aSysQueue; ++it )
1340
                }
1088
                        ;
1341
                if( nPos != STRING_NOTFOUND )
1089
                    if( it == aSysPrintQueues.end() )
1342
                {
1090
                        aSysPrintQueues.push_back( aSysQueue );
1343
                    nAftPos = aOutLine.Search( aAftToken, nPos );
1344
                    if( nAftPos != STRING_NOTFOUND )
1345
                    {
1346
                        OUString aSysQueue( String( aOutLine.Copy( nPos, nAftPos - nPos ), aEncoding ) );
1347
                        // do not insert duplicates (e.g. lpstat tends to produce such lines)
1348
                        std::list< OUString >::const_iterator it;
1349
                        for( it = aSysPrintQueues.begin(); it != aSysPrintQueues.end() && *it != aSysQueue; ++it )
1350
                            ;
1351
                        if( it == aSysPrintQueues.end() )
1352
                            aSysPrintQueues.push_back( aSysQueue );
1353
                    }
1091
                }
1354
                }
1092
            }
1355
            }
1093
        }
1094
        
1356
        
1095
        MutexGuard aGuard( m_aMutex );
1357
            MutexGuard aGuard( m_aMutex );
1096
        m_bChanged	= true;
1358
            m_bChanged	= true;
1097
        m_aQueues	= aSysPrintQueues;
1359
            m_aQueues	= aSysPrintQueues;
1098
        m_aCommand	= aPrintCommand;
1360
            m_aCommand	= aPrintCommand;
1361
        }
1099
    }
1362
    }
1100
}
1363
}
1364
1365
#ifdef MACOSX
1366
1367
/* On Apple systems printing gets more complicated...
1368
 * 1)  Darwin 5:     use straight lpr system, user has to configure lpr correctly
1369
 * 2)  MacOS X 10.1: use /usr/sbin/Print which prints to default Print Center printer
1370
 * 3)  MacOS X 10.2: use CUPS duo of lpstat/lp
1371
 * 4)  Darwin 6:     Like MacOS X 10.2, use CUPS
1372
 *
1373
 * --- FIXME ---   We don't support printer choosing on MacOS X 10.1 at this time,
1374
 *                 only printing to default Print Center printer.  The user can
1375
 *                 change the default Print Center printer at any point however.
1376
 */
1377
1378
/*
1379
 * macxp_GetSystemPrintMethod()
1380
 *
1381
 * Find out which printing system/OS we are using.
1382
 *
1383
 * Darwin 5 is the fallback case.  To check for 10.1 printing we try to see if
1384
 * /usr/sbin/Print exists.  For 10.2/Darwin 6, we attempt to find lpstat.  Users
1385
 * might also have installed CUPS on Darwin 5 or MacOS X 10.1, but we default to
1386
 * Print Center (/usr/sbin/Print) printing on 10.1.
1387
 *
1388
 */
1389
sal_Int32 macxp_GetSystemPrintMethod( void )
1390
{
1391
     int			applePrintSysType;
1392
     int			err;
1393
     struct stat	status;
1394
	
1395
     /* Attempt to find out which OS we are on... */
1396
     applePrintSysType = kApplePrintingLPR;
1397
	
1398
     /* Check for MacOS X 10.1 first. */
1399
     err = stat( "/usr/sbin/Print", &status );
1400
     if ( err == 0 )
1401
     {
1402
          applePrintSysType = kApplePrintingPrintCenter;
1403
          #ifdef DEBUG
1404
               fprintf( stderr, "printerinfomanager.cxx:  found MacOS X 10.1-type printing system.\n" );
1405
          #endif
1406
     }
1407
     else
1408
     {
1409
          /* Test for MacOS X 10.2/Darwin6 CUPS printing */
1410
          err = stat( "/usr/bin/lpstat", &status );
1411
          if ( err == 0 )
1412
          {
1413
               applePrintSysType = kApplePrintingCUPS;
1414
               #ifdef DEBUG
1415
                    fprintf( stderr, "printerinfomanager.cxx:  found MacOS X 10.2-type CUPS-based printing system.\n" );
1416
               #endif
1417
          }
1418
     }
1419
	
1420
     #ifdef DEBUG
1421
          if ( applePrintSysType == kApplePrintingLPR )
1422
               fprintf( stderr, "printerinfomanager.cxx:  falling back to Darwin5-type LPR printing system.\n" );
1423
     #endif
1424
	
1425
     return( applePrintSysType );
1426
}
1427
1428
/*
1429
 * macxp_GetSystemPrintFormat()
1430
 *
1431
 * There are two ways to print:  using PostScript (PS) and using PDF.
1432
 * Because MacOS X 10.2 CUPS printing has PDF converts built in for
1433
 * almost every printer, it is very easy to print using PDF.  For 10.1,
1434
 * extra steps must be taken to print with PDF, but it is still more
1435
 * compatible.  For Darwin 5 and 6, we default to PS printing.
1436
 *
1437
 * The user may still wish to print PS to PS compatible printers and
1438
 * therefore the environment variable OOO_PRINT_PS_DIRECTLY, if set,
1439
 * forces OOo to NOT undergo the PS -> PDF translation by default.
1440
 */
1441
/*sal_Int32 macxp_GetSystemPrintFormat( void )
1442
{
1443
     int			printFormat;
1444
     int			err;
1445
     struct stat	status;
1446
     sal_Char		*pPDFOverride = NULL;
1447
1448
     printFormat = kApplePrintingUsePS;
1449
	
1450
     /* Check for presence of OSAScript executable, which is
1451
      * believed to be MacOS X only (ie not present on Darwin).
1452
      *
1453
     err = stat( "/usr/bin/osascript", &status );
1454
     if ( err == 0 )
1455
     {
1456
          /* Check to see if the user wants to print PS anyway *
1457
          pPDFOverride = getenv( "OOO_PRINT_PS_DIRECTLY" );
1458
          if ( pPDFOverride == NULL )
1459
          {
1460
               /* Now we have to check for ps2pdf to make sure we can do the conversion *
1461
               err = stat( kApplePS2PDFLocation, &status );
1462
               if ( err == 0 )
1463
               {
1464
                    printFormat = kApplePrintingUsePDF;
1465
                    #ifdef DEBUG
1466
                         fprintf( stderr, "printerinfomanager.cxx:  Will print in PDF format using PS->PDF coversion filters.\n" );
1467
                    #endif
1468
               }
1469
          }
1470
     }
1471
	
1472
     return( printFormat );
1473
}*/
1474
#endif
1475
(-)source/printergfx/makefile.mk (+9 lines)
Lines 73-78 Link Here
73
73
74
# --- Files --------------------------------------------------------
74
# --- Files --------------------------------------------------------
75
75
76
.IF "$(GUIBASE)"=="aqua"
77
78
dummy:
79
	@echo "Nothing to build for GUIBASE $(GUIBASE)"
80
81
.ELSE		# "$(GUIBASE)"=="aqua"
82
76
SLOFILES=\
83
SLOFILES=\
77
	$(SLO)$/printerjob.obj		\
84
	$(SLO)$/printerjob.obj		\
78
	$(SLO)$/text_gfx.obj		\
85
	$(SLO)$/text_gfx.obj		\
Lines 80-85 Link Here
80
	$(SLO)$/common_gfx.obj		\
87
	$(SLO)$/common_gfx.obj		\
81
	$(SLO)$/glyphset.obj		\
88
	$(SLO)$/glyphset.obj		\
82
	$(SLO)$/bitmap_gfx.obj
89
	$(SLO)$/bitmap_gfx.obj
90
91
.ENDIF
83
92
84
# --- Targets ------------------------------------------------------
93
# --- Targets ------------------------------------------------------
85
94
(-)source/printergfx/printerjob.cxx (-5 / +381 lines)
Lines 107-112 Link Here
107
107
108
using namespace psp ;
108
using namespace psp ;
109
109
110
#ifdef MACOSX
111
// Prototype our MacOS X printing help function
112
void macxp_ProcessAndPrintDocument( sal_Int32 applePrintSysType, 
113
                                    char *spoolFileName, 
114
                                    FILE *pDestFile, 
115
                                    const rtl::OString psprintPrintCmd, 
116
                                    const rtl::OString psprintDriverName,
117
                                    const JobData pJobData, 
118
                                    const rtl::OUString *aJobName, 
119
                                    sal_uInt32 jobDPI );
120
int macxp_ConvertPSFileToPDF( char *psFileName, char *pdfFileName, int pdfFileNameBufferLen, sal_uInt32 jobDPI );
121
#endif
122
110
// forward declaration
123
// forward declaration
111
124
112
#define nBLOCKSIZE 0x2000
125
#define nBLOCKSIZE 0x2000
Lines 431-436 Link Here
431
    maFileName = rFileName;
444
    maFileName = rFileName;
432
    mnFileMode = nMode;
445
    mnFileMode = nMode;
433
    maSpoolDirName = createSpoolDir ();
446
    maSpoolDirName = createSpoolDir ();
447
    maJobName = rJobName;
434
448
435
    rtl::OUString aExt = rtl::OUString::createFromAscii (".ps");
449
    rtl::OUString aExt = rtl::OUString::createFromAscii (".ps");
436
    mpJobHeader  = CreateSpoolFile (rtl::OUString::createFromAscii("psp_head"), aExt);
450
    mpJobHeader  = CreateSpoolFile (rtl::OUString::createFromAscii("psp_head"), aExt);
Lines 496-501 Link Here
496
sal_Bool
510
sal_Bool
497
PrinterJob::EndJob ()
511
PrinterJob::EndJob ()
498
{
512
{
513
#ifdef MACOSX
514
    sal_Int32		applePrintSysType;
515
    char			*spoolFileName = NULL;
516
#endif
517
499
    // write document setup (done here because it
518
    // write document setup (done here because it
500
    // includes the accumulated fonts
519
    // includes the accumulated fonts
501
    writeSetup( mpJobHeader, m_aDocumentJobData );
520
    writeSetup( mpJobHeader, m_aDocumentJobData );
Lines 519-526 Link Here
519
538
520
    FILE* pDestFILE = NULL;
539
    FILE* pDestFILE = NULL;
521
540
522
    /* create a destination either as file or as a pipe */
541
#ifdef MACOSX
542
    /* Ascertain the printing system */
543
    applePrintSysType = macxp_GetSystemPrintMethod();
544
#endif
523
545
546
    /* create a destination either as file or as a pipe */
524
    sal_Bool bSpoolToFile = maFileName.getLength() > 0 ? sal_True : sal_False;
547
    sal_Bool bSpoolToFile = maFileName.getLength() > 0 ? sal_True : sal_False;
525
    if (bSpoolToFile)
548
    if (bSpoolToFile)
526
    {
549
    {
Lines 558-566 Link Here
558
        const rtl::OString aShellCommand = rtl::OUStringToOString (rCommand, 
581
        const rtl::OString aShellCommand = rtl::OUStringToOString (rCommand, 
559
                                                                   RTL_TEXTENCODING_ISO_8859_1);
582
                                                                   RTL_TEXTENCODING_ISO_8859_1);
560
													  
583
													  
561
        pDestFILE = popen (aShellCommand.getStr(), "w");
584
        /* Mac OS X: open a pipe only if we are using (1) Darwin5 LPR printing.
562
        if (pDestFILE == NULL)
585
         *           All other OS X/Darwin cases use spool to file.
563
            return sal_False;
586
	    * Other UNIX:  always open a pipe.
587
         */
588
        if (
589
           #ifdef MACOSX
590
               applePrintSysType == kApplePrintingLPR
591
           #else
592
               sal_True
593
           #endif
594
           )
595
        {
596
            pDestFILE = popen (aShellCommand.getStr(), "w");
597
            if (pDestFILE == NULL)
598
                return sal_False;
599
        }
600
     #ifdef MACOSX
601
        else
602
        {
603
            /* Spool to file instead so we can convert it.  Cases used here:
604
             * 1) kApplePrintingPrintCenter && kApplePrintingUsePDF
605
             * 2) kApplePrintingPrintCenter && kApplePrintingUsePS
606
             * 3) kApplePrintingCUPS && kApplePrintingUsePDF
607
             * 4) kApplePrintingCUPS && kApplePrintingUsePS
608
             */
609
610
            /* Get a temporary file name for the spool file.
611
             * This name must be free()ed later.
612
             */
613
            spoolFileName = macxp_tempnam( NULL, "ooopj" );
614
            if ( spoolFileName == NULL )
615
                return sal_False;
616
617
            /* Create temporary spool file */
618
            pDestFILE = fopen( spoolFileName, "w" );
619
            if ( pDestFILE == NULL )
620
		  {
621
                free( spoolFileName );
622
                return sal_False;
623
            }
624
        }
625
     #endif
564
    }
626
    }
565
627
566
    /* spool the document parts to the destination */
628
    /* spool the document parts to the destination */
Lines 598-607 Link Here
598
    if (bSpoolToFile)
660
    if (bSpoolToFile)
599
        fclose (pDestFILE);
661
        fclose (pDestFILE);
600
    else
662
    else
601
        pclose (pDestFILE);
663
    {
664
        #ifdef MACOSX
665
            sal_uInt32	nXdpi;
666
            sal_uInt32	nYdpi;
667
668
            /* For Mac OS X/Darwin, process and spool the file to the printing subsystem
669
             * if required.
670
             */ 
671
            const rtl::OUString& rPrinter     = m_aLastJobData.m_aPrinterName;
672
            const PrinterInfoManager& rPrinterInfoManager = PrinterInfoManager::get();
673
            const PrinterInfo&   rPrinterInfo = rPrinterInfoManager.getPrinterInfo( rPrinter );
674
675
            // Grab printer's spool command
676
            const rtl::OUString& rCommand     = rPrinterInfo.m_aCommand;
677
            const rtl::OString aShellCommand = rtl::OUStringToOString( rCommand, RTL_TEXTENCODING_ISO_8859_1 );
678
679
            // Grab the printer's PPD file name
680
            const rtl::OUString& rDriverName     = rPrinterInfo.m_aDriverName;
681
            const rtl::OString aDriverName = rtl::OUStringToOString( rDriverName, RTL_TEXTENCODING_ISO_8859_1 );
682
            
683
            /* Grab the resolution for the job, for use in PS->PDF conversion */
684
/*            GetResolution( nXdpi, nYdpi );*/
685
686
            macxp_ProcessAndPrintDocument( applePrintSysType,
687
                                           spoolFileName,
688
                                           pDestFILE,
689
                                           aShellCommand,
690
                                           aDriverName,
691
                                           m_aLastJobData,
692
                                           &maJobName,
693
                                           mnResolution );
694
        #else
695
            pclose (pDestFILE);
696
        #endif
697
    }
698
699
#ifdef MACOSX
700
    /* If we created a spool file for our Mac OS X/Darwin job,
701
     * delete it.  Also free the variable, since it is malloc()ed in macxp_tempnam()
702
     * and otherwise we'd leak memory.
703
     */
704
    if ( spoolFileName )
705
    {
706
        unlink( spoolFileName );
707
        free( spoolFileName );
708
    }
709
#endif
602
710
603
    return sal_True;
711
    return sal_True;
604
}
712
}
713
714
#ifdef MACOSX
715
// Because the printing on MacOS X and Darwin is a bit more complicated,
716
// its got its own routine.
717
718
#define kSysCommandBufferLen    1024
719
#define kPDFFileNameBufferLen   1024
720
721
void macxp_ProcessAndPrintDocument( sal_Int32 applePrintSysType,
722
                                    char *spoolFileName,
723
                                    FILE *pDestFile,
724
                                    const rtl::OString psprintPrintCmd,
725
                                    const rtl::OString psprintDriverName,
726
                                    const JobData pJobData,
727
                                    const rtl::OUString *aJobName,
728
                                    sal_uInt32 jobDPI )
729
{
730
    char      sysCommandBuffer[ kSysCommandBufferLen ];
731
    int       printCmdErr;
732
    sal_Int32 printFormat;
733
734
    if ( applePrintSysType == kApplePrintingLPR )
735
    {
736
        /* Job is to be printed with Darwin5 lpr. It has already 
737
         * been piped to lp/lpr above in EndJob(), so simply
738
	    * close the pipe.
739
	    */
740
        pclose( pDestFile );
741
    }
742
    else
743
    {
744
        /* Handle cases for MacOS X printing that don't pipe directly to lp/lpr */
745
746
        /* Close the intermediate file */
747
        fclose( pDestFile );
748
749
        /* Determine if we are going to print with PostScript, or with PS->PDF conversion.
750
         * We assume we are to use PS->PDF conversion unless proven otherwise.  Most printers
751
         * will have a PPD, except Rendezvous-shared ones.  If the PPD _doesn't_ have the
752
         * "cupsFilter" key, or if the "cupsFilter" key _doesn't_ contain "application/pdf",
753
         * then we print directly with PostScript.
754
         */
755
        printFormat = kApplePrintingUsePDF;
756
        if ( (sal_False == psprintDriverName.equals("SGENPRT")) && (sal_False == psprintDriverName.equals("MacShared")) )
757
        {
758
            /* The should exist a valid PPD for this printer */
759
            if ( pJobData.m_pParser )
760
            {
761
                const PPDKey    *pCupsFilterKey;
762
                const PPDValue  *pCupsFilterValue;
763
764
                pCupsFilterKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) );
765
                pCupsFilterValue = pCupsFilterKey != NULL ? pJobData.m_aContext.getValue( pCupsFilterKey ) : NULL;
766
                if ( pCupsFilterValue )
767
                {
768
                    ByteString    aCupsFilterString( pCupsFilterValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
769
                    if ( aCupsFilterString.Search("application/pdf") == 0 )
770
                    {
771
                        /* cupsFilter didn't have application/pdf */
772
                        printFormat = kApplePrintingUsePS;
773
                    }
774
                }
775
                else
776
                {
777
                    /* No "cupsFilter" key */
778
                    printFormat = kApplePrintingUsePS;
779
                }
780
            }
781
        }
782
783
        if ( (applePrintSysType==kApplePrintingPrintCenter) && (printFormat==kApplePrintingUsePS) )
784
        {		  
785
            /* Now pass the PS file to /usr/sbin/Print for printing. */
786
            snprintf( sysCommandBuffer, kSysCommandBufferLen-1, "%s -M ps \"%s\"", kApplePCPrintCommand, spoolFileName );
787
            #ifdef DEBUG
788
                fprintf( stderr, "printerjob.cxx: printing doc with command '%s'\n", sysCommandBuffer );
789
            #endif
790
791
            printCmdErr = system( sysCommandBuffer );
792
        }
793
        else if ( (applePrintSysType==kApplePrintingPrintCenter) && (printFormat==kApplePrintingUsePDF) )
794
        {
795
            char	pdfFileName[ kPDFFileNameBufferLen ];
796
            char	pdfFileNameMacFormat[ kPDFFileNameBufferLen ];
797
            char	*c;
798
            
799
            /* Convert file to PDF using GhostScript */
800
            printCmdErr =  macxp_ConvertPSFileToPDF( spoolFileName, pdfFileName, kPDFFileNameBufferLen, jobDPI );
801
            if ( printCmdErr == 0 )
802
		  {
803
                /* AppleScript expects MacOS-style paths, so convert Unix path to Mac OS Style.
804
                 * If the Unix path is absolute, get rid of the starting slash
805
                 */
806
                strncpy( pdfFileNameMacFormat, pdfFileName, kPDFFileNameBufferLen-1 );
807
                if ( *pdfFileNameMacFormat == '/' )
808
                    sprintf( pdfFileNameMacFormat, "%s", (pdfFileNameMacFormat+1) );
809
                while ( (c=strchr(pdfFileNameMacFormat,'/')) != NULL )
810
                    *c = ':';
811
            
812
                /* Construct and execute the actual printing command using AppleScript */
813
                snprintf( sysCommandBuffer, kSysCommandBufferLen-1, "/usr/bin/osascript -e 'tell application \"Finder\"' -e 'print {file \"%s\"}' -e 'end tell'", pdfFileNameMacFormat );
814
                #ifdef DEBUG
815
                    fprintf( stderr, "printerjob.cxx: printing PDF with command '%s'\n", sysCommandBuffer );
816
                #endif
817
                printCmdErr = system( sysCommandBuffer );
818
            }
819
		  unlink( pdfFileName );
820
        }
821
        else if ( (applePrintSysType==kApplePrintingCUPS) && ((printFormat==kApplePrintingUsePDF) || (printFormat==kApplePrintingUsePS)) )
822
        {
823
            char	     pdfFileName[ kPDFFileNameBufferLen ];
824
            char         numCopiesSwitch[ 5 ];
825
            sal_uInt32   index;
826
            
827
            /* Convert file to PDF using GhostScript if using PS->PDF conversion */
828
		  if ( printFormat == kApplePrintingUsePDF )
829
                printCmdErr =  macxp_ConvertPSFileToPDF( spoolFileName, pdfFileName, kPDFFileNameBufferLen, jobDPI );
830
            else
831
            {
832
                strncpy( pdfFileName, spoolFileName, kPDFFileNameBufferLen );
833
                printCmdErr = 0;
834
            }
835
836
            if ( printCmdErr == 0 )
837
		  {
838
                #define kJobOptionsStringSize    500
839
		      char    jobOptions[ kJobOptionsStringSize ];
840
841
                jobOptions[ 0 ] = NULL;
842
                /* Based on job options, find out what parameters to pass to the printer. */
843
                if ( pJobData.m_pParser )
844
                {
845
                    const PPDKey    *pSizeKey;
846
                    const PPDValue  *pSizeValue;
847
                    const PPDKey    *pSlotKey;
848
                    const PPDValue  *pSlotValue;
849
                    BOOL            needComma = FALSE;
850
851
                    // Only CUPS PS->PDF printers require the page size options
852
                    if ( printFormat == kApplePrintingUsePDF )
853
                    {
854
                        // Add page size option if necessary
855
                        pSizeKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("PageSize")) );
856
                        pSizeValue = pSizeKey != NULL ? pJobData.m_aContext.getValue( pSizeKey ) : NULL;
857
                        if ( pSizeValue )
858
                        {
859
                            ByteString aSizeString( pSizeValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
860
                            snprintf( jobOptions, kJobOptionsStringSize, "-o \"media=" );
861
                            strncat( jobOptions, aSizeString.GetBuffer(), kJobOptionsStringSize-strlen(jobOptions) );
862
                            needComma = TRUE;
863
                        }
864
                    }
865
866
                    // Add paper tray option if necessary
867
                    pSlotKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("InputSlot")) );
868
                    pSlotValue = pSlotKey != NULL ? pJobData.m_aContext.getValue( pSlotKey ) : NULL;
869
                    if ( pSlotValue )
870
                    {
871
                        ByteString      aSlotString( pSlotValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
872
                        // If the string wasn't created from PageSize, create it now
873
                        if ( strlen(jobOptions) == 0 )
874
                            snprintf( jobOptions, kJobOptionsStringSize, "-o \"media=" );
875
                        if ( TRUE == needComma )
876
                            strncat( jobOptions, ",", kJobOptionsStringSize - strlen(jobOptions) );
877
878
                        strncat( jobOptions, aSlotString.GetBuffer(), kJobOptionsStringSize - strlen(jobOptions) );
879
                    }
880
881
                    // Add on the ending " to the media= part
882
                    if ( strlen(jobOptions) > 0 )
883
                        strncat( jobOptions, "\"", kJobOptionsStringSize - strlen(jobOptions) );
884
				
885
				/* Deal with landscape orientation */
886
                // Disable for the moment since testers say it has undesired effects
887
                //    if ( pJobData.m_eOrientation == orientation::Landscape )
888
                //        strncat( jobOptions, " -o landscape ", kJobOptionsStringSize - strlen(jobOptions) );
889
890
				/* Attach a job title */
891
                    ByteString    jobTitle( aJobName->getStr(), RTL_TEXTENCODING_UTF8 );
892
                    snprintf( jobOptions, kJobOptionsStringSize, "%s -t \"%s\"", jobOptions, jobTitle.GetBuffer() );
893
                }
894
895
                /* Construct and execute the printing command */
896
                snprintf( sysCommandBuffer, kSysCommandBufferLen-1, "cat \"%s\" | %s %s", pdfFileName, psprintPrintCmd.getStr(), jobOptions );
897
                #ifdef DEBUG
898
                    fprintf( stderr, "printerjob.cxx: printing PDF with command '%s'\n", sysCommandBuffer );
899
                #endif
900
901
                /* Stupid lp and lpr on 10.2 don't actually honor their respective # copies arguments.
902
                 * So we have to just keep printing the job over and over for multiple copies for PS->PDF
903
                 * printers.  Direct-to-PostScript printers can handle the # copies _inside_ the PostScript
904
                 * document we are sending to them.
905
                 */
906
                int numCopies = (printFormat == kApplePrintingUsePDF ) ? pJobData.m_nCopies : 1;
907
                for( index = 1; index <= numCopies; index++ )
908
                    printCmdErr = system( sysCommandBuffer );
909
            }
910
            unlink( pdfFileName );
911
        }
912
913
        #ifdef DEBUG
914
	       /* A printCmdErr of -1 will usually be an error in PS->PDF conversion,
915
		   * otherwise its an error returned by system().
916
		   */
917
            if ( printCmdErr != 0 )
918
                fprintf( stderr, "printerjob.cxx: printing error, got %d.\n", printCmdErr );
919
            else
920
                fprintf( stderr, "printerjob.cxx: printing successful, system() returned 0.\n" );
921
        #endif
922
    }
923
}
924
925
#define kSysPrintSetupString  "sh -c 'PATH=$PATH:/usr/local/bin"
926
#define kPDFFileExtension ".pdf"
927
928
// Convert PostScript files to PDF for easy printing, using GhostScript.
929
// Returns:   0 if no error
930
//           -1 if error
931
int macxp_ConvertPSFileToPDF( char *psFileName, char *pdfFileName, int pdfFileNameBufferLen, sal_uInt32 jobDPI )
932
{
933
    int returnVal = 0;
934
    int printCmdErr = 0;
935
936
    /* Make sure we've got the space to play with file names/paths */
937
    if ( (strlen(psFileName) + strlen(kPDFFileExtension)) >= pdfFileNameBufferLen-1 )
938
    {
939
        fprintf( stderr, "printerjob.cxx:  Cannot convert print job to PDF because the file's path is too long.\n" );
940
        returnVal = -1;
941
    }
942
    else
943
    {
944
        char *sysCommandBuffer;
945
946
        /* Create the file name for the converted PDF and assemble the conversion command */
947
        snprintf( pdfFileName, pdfFileNameBufferLen-1, "%s%s", psFileName, kPDFFileExtension );
948
	   
949
	   sysCommandBuffer = (char *)malloc( sizeof(char) * ( strlen(kSysPrintSetupString) +
950
	                                               strlen(kApplePS2PDFLocation) +
951
                                                    10 +	/* For " -r<DPI>" */
952
                                                    strlen(psFileName) +
953
                                                    strlen(pdfFileName) +
954
                                                    10) );  /*  10 bytes fudge factor */
955
        if ( sysCommandBuffer == NULL )
956
            returnVal = -1;
957
        else
958
	   {
959
            sprintf( sysCommandBuffer, "%s;%s -r%d \"%s\" \"%s\"'", kSysPrintSetupString, kApplePS2PDFLocation, jobDPI, psFileName, pdfFileName );
960
          #ifdef DEBUG
961
                fprintf( stderr, "printerjob.cxx: converting document to PDF with command '%s'\n", sysCommandBuffer );
962
          #endif
963
964
            /* Convert the PS spool file to a PDF */
965
            printCmdErr = system( sysCommandBuffer );
966
            free( sysCommandBuffer );
967
968
          #ifdef DEBUG
969
            if ( printCmdErr != 0 )
970
                fprintf( stderr, "printerjob.cxx: pdf conversion error, system() returned %d.\n", printCmdErr );
971
            else
972
                fprintf( stderr, "printerjob.cxx: pdf conversion successful, system() returned 0.\n" );
973
          #endif
974
            returnVal = (printCmdErr != 0) ? -1 : 0;
975
        }
976
    }
977
978
    return( returnVal );
979
}
980
#endif	/* MACOSX */
605
981
606
sal_Bool
982
sal_Bool
607
PrinterJob::AbortJob ()
983
PrinterJob::AbortJob ()
(-)util/makefile.mk (+9 lines)
Lines 71-76 Link Here
71
71
72
# --- Allgemein ----------------------------------------------------------
72
# --- Allgemein ----------------------------------------------------------
73
73
74
.IF "$(GUIBASE)"=="aqua"
75
76
dummy:
77
	@echo "Nothing to build for GUIBASE $(GUIBASE)"
78
79
.ELSE		# "$(GUIBASE)"=="aqua"
80
74
.IF "$(OS)"=="WNT"
81
.IF "$(OS)"=="WNT"
75
LIB1TARGET= $(SLB)$/a$(TARGET).lib
82
LIB1TARGET= $(SLB)$/a$(TARGET).lib
76
LIB1FILES=	$(SLB)$/fontsubset.lib
83
LIB1FILES=	$(SLB)$/fontsubset.lib
Lines 102-107 Link Here
102
SHL1DEF=	$(MISC)$/$(SHL1TARGET).def
109
SHL1DEF=	$(MISC)$/$(SHL1TARGET).def
103
110
104
.ENDIF      # "$(OS)"=="WNT"
111
.ENDIF      # "$(OS)"=="WNT"
112
113
.ENDIF # GUIBASE = aqua
105
114
106
# --- Targets ------------------------------------------------------------
115
# --- Targets ------------------------------------------------------------
107
116

Return to issue 19214