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

(-)source/helper/helper.cxx (-2 / +2 lines)
Lines 233-239 Link Here
233
                    if( rOutFile.write( pWriteBuffer, nBytesToWrite, nRead ) || nRead != nBytesToWrite )
233
                    if( rOutFile.write( pWriteBuffer, nBytesToWrite, nRead ) || nRead != nBytesToWrite )
234
                        bSuccess = false;
234
                        bSuccess = false;
235
235
236
                    delete pWriteBuffer;
236
                    delete [] pWriteBuffer;
237
                }
237
                }
238
                else
238
                else
239
                {
239
                {
Lines 262-268 Link Here
262
            else
262
            else
263
                bSuccess = false;
263
                bSuccess = false;
264
264
265
            delete pBuffer;
265
            delete [] pBuffer;
266
        }
266
        }
267
        else if( nType == 3 )
267
        else if( nType == 3 )
268
            bEof = true;
268
            bEof = true;
(-)source/helper/ppdparser.cxx (-8 / +6 lines)
Lines 385-392 Link Here
385
            ByteString    aCupsFilterString( pKey->getValue( 0 )->m_aValue, RTL_TEXTENCODING_ISO_8859_1 );
385
            ByteString    aCupsFilterString( pKey->getValue( 0 )->m_aValue, RTL_TEXTENCODING_ISO_8859_1 );
386
            if ( strstr(aCupsFilterString.GetBuffer(), "application/pdf") > 0 )
386
            if ( strstr(aCupsFilterString.GetBuffer(), "application/pdf") > 0 )
387
                m_bType42Capable = true;
387
                m_bType42Capable = true;
388
389
fprintf( stderr, "##### PPDParser::PPDParser() got 'cupsFilter' key, app/pdf %s found.  %d  Value: %s\n", m_bType42Capable ? "WAS" : "NOT", aCupsFilterString.Search("application/pdf"), aCupsFilterString.GetBuffer() );
390
        }
388
        }
391
    }
389
    }
392
#endif
390
#endif
Lines 730-736 Link Here
730
    if( ! aConstraint.m_pKey1 || ! aConstraint.m_pKey2 || bFailed )
728
    if( ! aConstraint.m_pKey1 || ! aConstraint.m_pKey2 || bFailed )
731
    {
729
    {
732
#ifdef __DEBUG
730
#ifdef __DEBUG
733
        fprintf( stderr, "Warning: constraint \"%s\" is invalid\n", rLine.GetStr() );
731
        fprintf( stderr, "Warning: constraint \"%s\" is invalid\n", rLine.GetBuffer() );
734
#endif
732
#endif
735
    }
733
    }
736
    else
734
    else
Lines 1249-1258 Link Here
1249
                {
1247
                {
1250
#ifdef __DEBUG  
1248
#ifdef __DEBUG  
1251
                    fprintf( stderr, "PPDContext::setValue: option %s (%s) is constrained after setting %s to %s\n",
1249
                    fprintf( stderr, "PPDContext::setValue: option %s (%s) is constrained after setting %s to %s\n",
1252
                             it->first->getKey().GetStr(),
1250
                             it->first->getKey().GetBuffer(),
1253
                             it->second->m_aOption.GetStr(),
1251
                             it->second->m_aOption.GetBuffer(),
1254
                             pKey->getKey().GetStr(),
1252
                             pKey->getKey().GetBuffer(),
1255
                             pValue->m_aOption.GetStr() );
1253
                             pValue->m_aOption.GetBuffer() );
1256
#endif
1254
#endif
1257
                    resetValue( it->first, true );
1255
                    resetValue( it->first, true );
1258
                    it = m_aCurrentValues.begin();
1256
                    it = m_aCurrentValues.begin();
Lines 1300-1306 Link Here
1300
        return false;
1298
        return false;
1301
1299
1302
#ifdef __DEBUG
1300
#ifdef __DEBUG
1303
    fprintf( stderr, "resetValue( %s, %s ) ", pKey->getKey().GetStr(),
1301
    fprintf( stderr, "resetValue( %s, %s ) ", pKey->getKey().GetBuffer(),
1304
             bDefaultable ? "true" : "false" );
1302
             bDefaultable ? "true" : "false" );
1305
#endif
1303
#endif
1306
1304
(-)source/helper/strhelper.cxx (-8 / +6 lines)
Lines 61-67 Link Here
61
#include <psprint/strhelper.hxx>
61
#include <psprint/strhelper.hxx>
62
#ifdef SOLARIS
62
#ifdef SOLARIS
63
#include <ieeefp.h> // finite
63
#include <ieeefp.h> // finite
64
#include <alloca.h>
64
#endif
65
#endif
66
#include <stdlib.h>
65
#include <math.h> // for isnan
67
#include <math.h> // for isnan
66
#include <string.h> // strcpy
68
#include <string.h> // strcpy
67
69
Lines 162-168 Link Here
162
        return String();
164
        return String();
163
    
165
    
164
    int nActualToken = 0;
166
    int nActualToken = 0;
165
    sal_Unicode* pBuffer = new sal_Unicode[ nLen + 1 ];
167
    sal_Unicode* pBuffer = (sal_Unicode*)alloca( sizeof(sal_Unicode)*( nLen + 1 ) );
166
    const sal_Unicode* pRun = rLine.GetBuffer();
168
    const sal_Unicode* pRun = rLine.GetBuffer();
167
    sal_Unicode* pLeap;
169
    sal_Unicode* pLeap;
168
    
170
    
Lines 203-209 Link Here
203
    *pLeap = 0;
205
    *pLeap = 0;
204
    
206
    
205
    String aRet( pBuffer );
207
    String aRet( pBuffer );
206
    delete pBuffer;
207
    return aRet;
208
    return aRet;
208
}
209
}
209
210
Lines 214-220 Link Here
214
        return ByteString();
215
        return ByteString();
215
    
216
    
216
    int nActualToken = 0;
217
    int nActualToken = 0;
217
    char* pBuffer = new char[ nLen + 1 ];
218
    char* pBuffer = (char*)alloca( nLen + 1 );
218
    const char* pRun = rLine.GetBuffer();
219
    const char* pRun = rLine.GetBuffer();
219
    char* pLeap;
220
    char* pLeap;
220
    
221
    
Lines 255-261 Link Here
255
    *pLeap = 0;
256
    *pLeap = 0;
256
    
257
    
257
    ByteString aRet( pBuffer );
258
    ByteString aRet( pBuffer );
258
    delete pBuffer;
259
    return aRet;
259
    return aRet;
260
}
260
}
261
261
Lines 367-373 Link Here
367
    if( ! nLen )
367
    if( ! nLen )
368
        return String();
368
        return String();
369
    
369
    
370
    sal_Unicode *pBuffer = new sal_Unicode[ nLen + 1 ];
370
    sal_Unicode *pBuffer = (sal_Unicode*)alloca( sizeof(sal_Unicode)*(nLen + 1) );
371
    const sal_Unicode *pRun = rLine.GetBuffer();
371
    const sal_Unicode *pRun = rLine.GetBuffer();
372
    sal_Unicode *pLeap = pBuffer;
372
    sal_Unicode *pLeap = pBuffer;
373
373
Lines 415-421 Link Here
415
        *pLeap = 0;
415
        *pLeap = 0;
416
416
417
    String aRet( *pBuffer == ' ' ? pBuffer+1 : pBuffer );
417
    String aRet( *pBuffer == ' ' ? pBuffer+1 : pBuffer );
418
    delete pBuffer;
419
    return aRet;    
418
    return aRet;    
420
}
419
}
421
420
Lines 425-431 Link Here
425
    if( ! nLen )
424
    if( ! nLen )
426
        return ByteString();
425
        return ByteString();
427
    
426
    
428
    char *pBuffer = new char[ nLen + 1 ];
427
    char *pBuffer = (char*)alloca( nLen + 1 );
429
    const char *pRun = rLine.GetBuffer();
428
    const char *pRun = rLine.GetBuffer();
430
    char *pLeap = pBuffer;
429
    char *pLeap = pBuffer;
431
430
Lines 473-479 Link Here
473
        *pLeap = 0;
472
        *pLeap = 0;
474
473
475
    ByteString aRet( *pBuffer == ' ' ? pBuffer+1 : pBuffer );
474
    ByteString aRet( *pBuffer == ' ' ? pBuffer+1 : pBuffer );
476
    delete pBuffer;
477
    return aRet;    
475
    return aRet;    
478
}
476
}
479
477
(-)source/printer/jobdata.cxx (-3 / +8 lines)
Lines 63-68 Link Here
63
#include <psprint/printerinfomanager.hxx>
63
#include <psprint/printerinfomanager.hxx>
64
#include <tools/stream.hxx>
64
#include <tools/stream.hxx>
65
65
66
#ifdef SOLARIS
67
#include <alloca.h>
68
#else
69
#include <stdlib.h>
70
#endif
71
66
using namespace psp;
72
using namespace psp;
67
using namespace rtl;
73
using namespace rtl;
68
74
Lines 127-133 Link Here
127
        aStream.Write( pContextBuffer, nBytes );
133
        aStream.Write( pContextBuffer, nBytes );
128
134
129
    // success
135
    // success
130
    pData = new char[ bytes = aStream.GetSize() ];
136
    pData = rtl_allocateMemory( bytes = aStream.GetSize() );
131
    memcpy( pData, aStream.GetData(), bytes );
137
    memcpy( pData, aStream.GetData(), bytes );
132
    return true;
138
    return true;
133
}
139
}
Lines 206-215 Link Here
206
                {
212
                {
207
                    rJobData.m_aContext.setParser( rJobData.m_pParser );
213
                    rJobData.m_aContext.setParser( rJobData.m_pParser );
208
                    int nBytes = bytes - aStream.Tell();
214
                    int nBytes = bytes - aStream.Tell();
209
                    void* pRemain = new char[ bytes - aStream.Tell() ];
215
                    void* pRemain = alloca( bytes - aStream.Tell() );
210
                    aStream.Read( pRemain, nBytes );
216
                    aStream.Read( pRemain, nBytes );
211
                    rJobData.m_aContext.rebuildFromStreamBuffer( pRemain, nBytes );
217
                    rJobData.m_aContext.rebuildFromStreamBuffer( pRemain, nBytes );
212
                    delete pRemain;
213
                    bContext = true;
218
                    bContext = true;
214
                }
219
                }
215
            }
220
            }
(-)source/printer/printerinfomanager.cxx (-6 / +66 lines)
Lines 598-615 Link Here
598
            if( aPrinter.m_aInfo.m_pParser )
598
            if( aPrinter.m_aInfo.m_pParser )
599
            {
599
            {
600
                // merge the ppd context keys if the printer has the same keys and values
600
                // merge the ppd context keys if the printer has the same keys and values
601
                // this is a bit tricky, since it involves mixing two PPDs
602
                // without constraints which might end up badly
603
                // this feature should be use with caution
604
                // it is mainly to select default paper sizes for new printers
601
                // it is mainly to select default paper sizes for new printers
605
                for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ )
602
                for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ )
606
                {
603
                {
607
                    const PPDKey* pDefKey = m_aGlobalDefaults.m_aContext.getModifiedKey( nPPDValueModified );
604
                    const PPDKey* pDefKey = m_aGlobalDefaults.m_aContext.getModifiedKey( nPPDValueModified );
608
                    const PPDValue* pDefValue = m_aGlobalDefaults.m_aContext.getValue( pDefKey );
605
                    const PPDValue* pDefValue = m_aGlobalDefaults.m_aContext.getValue( pDefKey );
606
				// If the default PPD has a certain key, attempt to get that same key in the Printer's PPD
609
                    const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : NULL;
607
                    const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : NULL;
608
609
                    // The key usually merged is PageSize
610
                    if( pDefKey && pPrinterKey )
610
                    if( pDefKey && pPrinterKey )
611
                    {
611
                    {
612
                        // at least the options exist in both PPDs
612
                        // Key exists in both the Default PPD and the printer's specific PPD.
613
                        if( pDefValue )
613
                        if( pDefValue )
614
                        {
614
                        {
615
                            const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption );
615
                            const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption );
Lines 621-626 Link Here
621
                            aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, NULL );
621
                            aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, NULL );
622
                    }
622
                    }
623
                }
623
                }
624
625
                // Some CUPS PPDs on Mac OS X (Epson, HP) don't include the requisite
626
                // PageSize information for the value.  We have to fudge it from the
627
                // margin information.  Others (Canon BJC 8200) have the coordinates
628
			 // but not the "setpagedevice" stuff
629
                const PPDKey* pPSizeKey = aPrinter.m_aInfo.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("PageSize")) );
630
                if ( pPSizeKey )
631
                {
632
                    int           psIndex = 0;
633
                    int           nNumValues = pPSizeKey->countValues();
634
635
                    for ( psIndex = 0; psIndex < nNumValues; psIndex++ )
636
                    {
637
                        const PPDValue*   pPSizeValue = pPSizeKey->getValue( psIndex );
638
639
                        // Only take care of PPD values that are not formatted correctly.
640
                        if (  pPSizeValue &&
641
                              ( !(pPSizeValue->m_aValue.Len()) ||
642
                              (pPSizeValue->m_aValue.Len() && (pPSizeValue->m_aValue.SearchAscii("setpagedevice")==STRING_NOTFOUND)) )
643
                           )
644
                        {
645
                            // Deal with the two cases:  1) where there is a blank PageSize value and
646
                            // 2) where there are simply the dimensions as the PageSize value
647
                            if ( !pPSizeValue->m_aValue.Len() )
648
                            {
649
                                int     paperWidth;
650
                                int     paperHeight;
651
                                char    aWidth[ 32 ];
652
                                char    aHeight[ 32 ];
653
654
                                // Grab dimensions for this paper size from the "PaperDimension" key of the PPD
655
                                aPrinter.m_aInfo.m_pParser->getPaperDimension( pPSizeValue->m_aOption, paperWidth, paperHeight );
656
                                snprintf( aWidth, 32, "%d", paperWidth );
657
                                snprintf( aHeight, 32, "%d", paperHeight );
658
659
                                // Construct a suitable PageSize key value from the PaperDimension values for this paper size
660
                           	  pPSizeValue->m_aValue.AppendAscii( "<</PageSize [" );
661
                                pPSizeValue->m_aValue.AppendAscii( aWidth );
662
                           	  pPSizeValue->m_aValue.AppendAscii( " " );
663
                                pPSizeValue->m_aValue.AppendAscii( aHeight );
664
                           	  pPSizeValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" );
665
                            }
666
                            else
667
            			   {
668
                                String  aBox( pPSizeValue->m_aValue );
669
				   
670
                                // The PageSize value was just the bounding box, add in the correct postscript
671
                                pPSizeValue->m_aValue.AssignAscii( "" );
672
                           	  pPSizeValue->m_aValue.AppendAscii( "<</PageSize [" );
673
                                pPSizeValue->m_aValue.Append( aBox );
674
                           	  pPSizeValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" );
675
            			   }
676
                        }
677
                    }
678
                }
624
            }
679
            }
625
		  else
680
		  else
626
            {
681
            {
Lines 629-639 Link Here
629
684
630
                // Some printers don't have the PPDs in /etc/cups/ppd (like Rendezvous-shared ones)
685
                // Some printers don't have the PPDs in /etc/cups/ppd (like Rendezvous-shared ones)
631
                // so we have to simply use a stripped down shared printer PPD for them
686
                // so we have to simply use a stripped down shared printer PPD for them
632
                aPrinter.m_aInfo.m_aDriverName    = String( RTL_CONSTASCII_USTRINGPARAM( "MacShared" ) );
687
                aPrinter.m_aInfo.m_aDriverName    = String( RTL_CONSTASCII_USTRINGPARAM("MacShared") );
633
                aPrinter.m_aInfo.m_pParser        = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
688
                aPrinter.m_aInfo.m_pParser        = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
634
                aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
689
                aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
635
                if( !(aPrinter.m_aInfo.m_pParser) )
690
                if( !(aPrinter.m_aInfo.m_pParser) )
636
                    fprintf( stderr, "Warning:  still couldn't load the PPD, MacShared.ppd may be missing.\n" );
691
                {
692
                    fprintf( stderr, "Warning:  still couldn't load the PPD, MacShared.ppd may be missing.  Will use generic printer PPD.\n" );
693
                    aPrinter.m_aInfo.m_aDriverName    = String( RTL_CONSTASCII_USTRINGPARAM("SGENPRT") );
694
                    aPrinter.m_aInfo.m_pParser        = PPDParser::getParser( aPrinter.m_aInfo.m_aDriverName );
695
                    aPrinter.m_aInfo.m_aContext.setParser( aPrinter.m_aInfo.m_pParser );
696
                }
637
            }
697
            }
638
        }
698
        }
639
#endif
699
#endif
(-)source/printergfx/printerjob.cxx (-73 / +36 lines)
Lines 740-746 Link Here
740
                const PPDValue  *pCupsFilterValue;
740
                const PPDValue  *pCupsFilterValue;
741
741
742
                pCupsFilterKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) );
742
                pCupsFilterKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) );
743
                pCupsFilterValue = pJobData.m_aContext.getValue( pCupsFilterKey );
743
                pCupsFilterValue = pCupsFilterKey != NULL ? pJobData.m_aContext.getValue( pCupsFilterKey ) : NULL;
744
                if ( pCupsFilterValue )
744
                if ( pCupsFilterValue )
745
                {
745
                {
746
                    ByteString    aCupsFilterString( pCupsFilterValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
746
                    ByteString    aCupsFilterString( pCupsFilterValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
Lines 815-830 Link Here
815
		  {
815
		  {
816
                #define kJobOptionsStringSize    500
816
                #define kJobOptionsStringSize    500
817
		      char    jobOptions[ kJobOptionsStringSize ];
817
		      char    jobOptions[ kJobOptionsStringSize ];
818
                /* Determine which printing system we are using, either 'lp' or 'lpr'.  They
819
                 * each have a different switch for number of copies.
820
                 * Note that neither of these two actually honors these arguments on 10.2 right now.
821
                 */
822
                /*
823
                if ( (strstr(psprintPrintCmd.getStr(), "lp ") != NULL) || (psprintPrintCmd=="lp") )
824
                     strncpy( numCopiesSwitch, "-n", 4 );
825
                else if ( (strstr(psprintPrintCmd.getStr(), "lpr ") != NULL) || (psprintPrintCmd=="lpr") )
826
                     strncpy( numCopiesSwitch, "-#", 4 );
827
                */
828
818
829
                jobOptions[ 0 ] = NULL;
819
                jobOptions[ 0 ] = NULL;
830
                /* Based on job options, find out what parameters to pass to the printer. */
820
                /* Based on job options, find out what parameters to pass to the printer. */
Lines 834-856 Link Here
834
                    const PPDValue  *pSizeValue;
824
                    const PPDValue  *pSizeValue;
835
                    const PPDKey    *pSlotKey;
825
                    const PPDKey    *pSlotKey;
836
                    const PPDValue  *pSlotValue;
826
                    const PPDValue  *pSlotValue;
827
                    BOOL            needComma = FALSE;
837
828
838
                    pSizeKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("PageSize")) );
829
                    // Only CUPS PS->PDF printers require the page size options
839
                    pSizeValue = pJobData.m_aContext.getValue( pSizeKey );
830
                    if ( printFormat == kApplePrintingUsePDF )
840
                    if ( pSizeValue )
841
                    {
831
                    {
842
                        ByteString      aSizeString( pSizeValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
832
                        // Add page size option if necessary
843
                        snprintf( jobOptions, kJobOptionsStringSize, "-o media=%s", aSizeString.GetBuffer() );
833
                        pSizeKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("PageSize")) );
844
				    
834
                        pSizeValue = pSizeKey != NULL ? pJobData.m_aContext.getValue( pSizeKey ) : NULL;
845
                        pSlotKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("InputSlot")) );
835
                        if ( pSizeValue )
846
                        pSlotValue = pJobData.m_aContext.getValue( pSlotKey );
847
                        if ( pSlotValue )
848
                        {
836
                        {
849
                            ByteString      aSlotString( pSlotValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
837
                            ByteString aSizeString( pSizeValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
850
                            strncat( jobOptions, ",", kJobOptionsStringSize - strlen(jobOptions) );
838
                            snprintf( jobOptions, kJobOptionsStringSize, "-o \"media=" );
851
                            strncat( jobOptions, aSlotString.GetBuffer(), kJobOptionsStringSize - strlen(jobOptions) );
839
                            strncat( jobOptions, aSizeString.GetBuffer(), kJobOptionsStringSize-strlen(jobOptions) );
840
                            needComma = TRUE;
852
                        }
841
                        }
853
                    }
842
                    }
843
844
                    // Add paper tray option if necessary
845
                    pSlotKey = pJobData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("InputSlot")) );
846
                    pSlotValue = pSlotKey != NULL ? pJobData.m_aContext.getValue( pSlotKey ) : NULL;
847
                    if ( pSlotValue )
848
                    {
849
                        ByteString      aSlotString( pSlotValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 );
850
                        // If the string wasn't created from PageSize, create it now
851
                        if ( strlen(jobOptions) == 0 )
852
                            snprintf( jobOptions, kJobOptionsStringSize, "-o \"media=" );
853
                        if ( TRUE == needComma )
854
                            strncat( jobOptions, ",", kJobOptionsStringSize - strlen(jobOptions) );
855
856
                        strncat( jobOptions, aSlotString.GetBuffer(), kJobOptionsStringSize - strlen(jobOptions) );
857
                    }
858
859
                    // Add on the ending " to the media= part
860
                    if ( strlen(jobOptions) > 0 )
861
                        strncat( jobOptions, "\"", kJobOptionsStringSize - strlen(jobOptions) );
854
				
862
				
855
				/* Deal with landscape orientation */
863
				/* Deal with landscape orientation */
856
                // Disable for the moment since testers say it has undesired effects
864
                // Disable for the moment since testers say it has undesired effects
Lines 869-877 Link Here
869
                #endif
877
                #endif
870
878
871
                /* Stupid lp and lpr on 10.2 don't actually honor their respective # copies arguments.
879
                /* Stupid lp and lpr on 10.2 don't actually honor their respective # copies arguments.
872
                 * So we have to just keep printing the job over and over for multiple copies.
880
                 * So we have to just keep printing the job over and over for multiple copies for PS->PDF
881
                 * printers.  Direct-to-PostScript printers can handle the # copies _inside_ the PostScript
882
                 * document we are sending to them.
873
                 */
883
                 */
874
                for( index = 1; index <= pJobData.m_nCopies; index++ )
884
                int numCopies = (printFormat == kApplePrintingUsePDF ) ? pJobData.m_nCopies : 1;
885
                for( index = 1; index <= numCopies; index++ )
875
                    printCmdErr = system( sysCommandBuffer );
886
                    printCmdErr = system( sysCommandBuffer );
876
            }
887
            }
877
            unlink( pdfFileName );
888
            unlink( pdfFileName );
Lines 1252-1259 Link Here
1252
            aKeys[i] = rJob.m_aContext.getModifiedKey( i );
1263
            aKeys[i] = rJob.m_aContext.getModifiedKey( i );
1253
        ::std::sort( aKeys.begin(), aKeys.end(), less_ppd_key() );
1264
        ::std::sort( aKeys.begin(), aKeys.end(), less_ppd_key() );
1254
1265
1255
fprintf( stderr, "----- FEATURE: %d keys in feature section\n", nKeys );
1256
1257
        for( i = 0; i < nKeys && bSuccess; i++ )
1266
        for( i = 0; i < nKeys && bSuccess; i++ )
1258
        {
1267
        {
1259
            const PPDKey* pKey = aKeys[i];
1268
            const PPDKey* pKey = aKeys[i];
Lines 1262-1283 Link Here
1262
                pKey->getSetupType()    == PPDKey::AnySetup )
1271
                pKey->getSetupType()    == PPDKey::AnySetup )
1263
            {
1272
            {
1264
                const PPDValue* pValue = rJob.m_aContext.getValue( pKey );
1273
                const PPDValue* pValue = rJob.m_aContext.getValue( pKey );
1265
{
1266
ByteString	bsOption( pValue->m_aOption, RTL_TEXTENCODING_UTF8 );
1267
ByteString	bsValue( pValue->m_aValue, RTL_TEXTENCODING_UTF8 );
1268
fprintf( stderr,"        Trying Key, Option: %s, Value: %s\n", bsOption.GetBuffer(), bsValue.GetBuffer() );
1269
fflush(stderr);
1270
}
1271
                if(pValue 
1274
                if(pValue 
1272
                   && pValue->m_eType == eInvocation 
1275
                   && pValue->m_eType == eInvocation 
1273
            #ifdef MACOSX
1274
                   // Some CUPS PPDs on OS X do not have values for PageSize.  So we have
1275
                   // to let the key through anyway and fudge the values.
1276
                   && (pValue->m_aValue.Len()
1277
                       || (pKey->getKey().EqualsIgnoreCaseAscii("PageSize")))
1278
            #else
1279
                   && pValue->m_aValue.Len() 
1276
                   && pValue->m_aValue.Len() 
1280
            #endif
1281
                   && ( m_aLastJobData.m_pParser == NULL 
1277
                   && ( m_aLastJobData.m_pParser == NULL 
1282
                        || m_aLastJobData.m_aContext.getValue( pKey ) != pValue )
1278
                        || m_aLastJobData.m_aContext.getValue( pKey ) != pValue )
1283
                   )
1279
                   )
Lines 1291-1333 Link Here
1291
                        if( bHavePS2 )
1287
                        if( bHavePS2 )
1292
                            continue;
1288
                            continue;
1293
                    }
1289
                    }
1294
            #ifdef MACOSX
1295
                   // Some CUPS PPDs on Mac OS X (Epson, HP) don't include the requisite
1296
                   // PageSize information for the value.  We have to fudge it from the
1297
                   // margin information.  Others (Canon BJC 8200) have the coordinates
1298
			    // but not the "setpagedevice" stuff
1299
                   if ( !(pValue->m_aValue.Len()) && pKey->getKey().EqualsIgnoreCaseAscii("PageSize") )
1300
                   {
1301
                       char    aWidth[ 32 ];
1302
                       char    aHeight[ 32 ];
1303
1304
                       snprintf( aWidth, 32, "%d", mnWidthPt );
1305
                       snprintf( aHeight, 32, "%d", mnHeightPt );
1306
1307
                       // bounding box was blank, construct from margin info
1308
               	   pValue->m_aValue.AppendAscii( "<</PageSize [" );
1309
                       pValue->m_aValue.AppendAscii( aWidth );
1310
               	   pValue->m_aValue.AppendAscii( " " );
1311
                       pValue->m_aValue.AppendAscii( aHeight );
1312
               	   pValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" );
1313
                   }
1314
			    else if ( pValue->m_aValue.Len() && (pValue->m_aValue.SearchAscii("setpagedevice")==STRING_NOTFOUND) )
1315
			    {
1316
                       String  aBox( pValue->m_aValue );
1317
				   
1318
                       // The value was just the bounding box, add in the correct postscript
1319
                       pValue->m_aValue.AssignAscii( "" );
1320
               	   pValue->m_aValue.AppendAscii( "<</PageSize [" );
1321
                       pValue->m_aValue.Append( aBox );
1322
               	   pValue->m_aValue.AppendAscii( "] /ImagingBBox null>> setpagedevice" );
1323
			    }
1324
            #endif
1325
                    bSuccess = writeFeature( pFile, pKey, pValue );
1290
                    bSuccess = writeFeature( pFile, pKey, pValue );
1326
fprintf( stderr,"        Attempted to write key, success = %s\n", bSuccess ? "good" : "bad" );
1327
                }
1291
                }
1328
            }
1292
            }
1329
        }
1293
        }
1330
fprintf( stderr, "----- END FEATURE\n" );
1331
    }
1294
    }
1332
    else
1295
    else
1333
        bSuccess = false;
1296
        bSuccess = false;

Return to issue 15529