Index: kgv_miniwidget.cpp =================================================================== RCS file: /home/kde/kdegraphics/kghostview/kgv_miniwidget.cpp,v retrieving revision 1.146.2.2 diff -u -r1.146.2.2 kgv_miniwidget.cpp --- kgv_miniwidget.cpp 1 Oct 2002 20:22:52 -0000 1.146.2.2 +++ kgv_miniwidget.cpp 6 Apr 2003 14:45:52 -0000 @@ -289,23 +289,22 @@ } _tmpDSC->close(); - _pdfFileName = _fileName; - _fileName = _tmpDSC->name(); _format = PDF; - openPSFile(); + openPSFile(_tmpDSC->name()); } -void KGVMiniWidget::openPSFile() +void KGVMiniWidget::openPSFile(const QString &file) { + QString fileName = file.isEmpty() ? _fileName : file; kdDebug(4500) << "KGVMiniWidget::openPSFile" << endl; - FILE* fp = fopen( QFile::encodeName( _fileName ), "r"); + FILE* fp = fopen( QFile::encodeName( fileName ), "r"); if( fp == 0 ) { KMessageBox::error( _part->widget(), i18n( "Error opening file %1: %2" ) - .arg( _fileName ) + .arg( fileName ) .arg( strerror( errno ) ) ); emit canceled( "" ); return; @@ -316,9 +315,7 @@ _isFileOpen = true; scanDSC(); buildTOC(); - _psWidget->setFileName( dsc()->isStructured() - ? QString::null - : _fileName ); + _psWidget->setFileName( _fileName, dsc()->isStructured() ); emit completed(); } } @@ -843,6 +840,7 @@ << "-dNOPAUSE" << "-dBATCH" << "-dSAFER" + << "-dPARANOIDSAFER" << "-sDEVICE=pswrite" << ( QCString("-sOutputFile=")+QFile::encodeName(saveFileName) ) << ( QString("-dFirstPage=")+QString::number( firstPage ) ) @@ -851,7 +849,7 @@ << "save" << "pop" << "-f" - << QFile::encodeName(_pdfFileName); + << QFile::encodeName(_fileName); /*QValueList args = process.args(); QValueList::Iterator it = args.begin(); @@ -1058,7 +1056,7 @@ QString::null, _part->widget(), QString::null ); - if( !KIO::NetAccess::upload( _format == PDF ? _pdfFileName : _fileName, + if( !KIO::NetAccess::upload( _fileName, saveURL ) ) ; // TODO: Proper error dialog } @@ -1279,10 +1277,16 @@ _process = new KProcess; *_process << _ghostscriptPath + << "-dSAFER" + << "-dPARANOIDSAFER" + << "-dDELAYSAFER" << "-dNODISPLAY" << "-dQUIET" << QString( "-sPDFname=%1" ).arg( pdfName ) << QString( "-sDSCname=%1" ).arg( dscName ) + << "-c" + << "<< /PermitFileReading [ PDFname ] /PermitFileWriting [ DSCname ] /PermitFileControl [] >> setuserparams .locksafe" + << "-f" << "pdf2dsc.ps" << "-c" << "quit"; Index: kgv_miniwidget.h =================================================================== RCS file: /home/kde/kdegraphics/kghostview/kgv_miniwidget.h,v retrieving revision 1.78 diff -u -r1.78 kgv_miniwidget.h --- kgv_miniwidget.h 17 Mar 2002 23:01:47 -0000 1.78 +++ kgv_miniwidget.h 6 Apr 2003 14:45:53 -0000 @@ -85,7 +85,7 @@ void clearTemporaryFiles(); void uncompressFile(); - void openPSFile(); + void openPSFile(const QString &file=QString::null); protected slots: void doOpenFile(); @@ -116,7 +116,7 @@ /*- PRINTING and SAVING ---------------------------------------------------*/ // private data used: -// Document specific: _dsc, _fileName, _pdfFileName, _format, _origurl +// Document specific: _dsc, _fileName, _format, _origurl // View specific: _currentPage, _marklist // This section only: _printer, _tmpFromPDF @@ -258,7 +258,6 @@ int _visiblePage; QString _fileName; - QString _pdfFileName; QString _mimetype; MarkList* _marklist; Index: kpswidget.cpp =================================================================== RCS file: /home/kde/kdegraphics/kghostview/kpswidget.cpp,v retrieving revision 1.91 diff -u -r1.91 kpswidget.cpp --- kpswidget.cpp 7 Mar 2002 12:28:33 -0000 1.91 +++ kpswidget.cpp 6 Apr 2003 14:45:53 -0000 @@ -311,10 +311,11 @@ } } -void KPSWidget::setFileName( const QString& fileName ) +void KPSWidget::setFileName( const QString& fileName, bool usePipe ) { - if( _fileName != fileName ) + if(( _fileName != fileName ) || (_usePipe != usePipe)) { + _usePipe = usePipe; _fileName = fileName; stopInterpreter(); _ghostscriptDirty = true; @@ -510,8 +511,11 @@ for( ; it != _ghostscriptArguments.end(); ++it ) *_process << (*it); - if( _fileName.isEmpty() ) - *_process << "-"; + if( _usePipe ) + *_process << + // The following two lines are their to ensure that we are allowed to read _fileName + "-dDELAYSAFER" << "-sInputFile="+_fileName << "-c" << + "<< /PermitFileReading [ InputFile ] /PermitFileWriting [] /PermitFileControl [] >> setuserparams .locksafe"; else *_process << _fileName << "-c" << "quit"; @@ -529,7 +533,7 @@ // Finally fire up the interpreter. kdDebug(4500) << "KPSWidget: starting interpreter" << endl; if( _process->start( KProcess::NotifyOnExit, - _fileName.isEmpty() ? KProcess::All : KProcess::AllOutput ) ) + _usePipe ? KProcess::All : KProcess::AllOutput ) ) { _interpreterBusy = true; setCursor( waitCursor ); @@ -650,7 +654,7 @@ if( !intConfig->platformFonts() ) arguments << "-dNOPLATFONTS"; - arguments << "-dNOPAUSE" << "-dQUIET" << "-dSAFER"; + arguments << "-dNOPAUSE" << "-dQUIET" << "-dSAFER" << "-dPARANOIDSAFER"; setGhostscriptArguments( arguments ); Index: kpswidget.h =================================================================== RCS file: /home/kde/kdegraphics/kghostview/kpswidget.h,v retrieving revision 1.52 diff -u -r1.52 kpswidget.h --- kpswidget.h 8 Feb 2002 12:11:06 -0000 1.52 +++ kpswidget.h 6 Apr 2003 14:45:53 -0000 @@ -134,10 +134,11 @@ bool sendPS( FILE*, unsigned int begin, unsigned int end ); /** - * Sets the filename of the ghostscript input. Usually we use a pipe for - * communication and no filename will be needed. + * Sets the filename of the ghostscript input. + * @p usePipe indicates whether we use a pipe for + * communication or let ghoscript read the file itself. */ - void setFileName( const QString& ); + void setFileName( const QString&, bool usePipe ); /** * Set the bounding box of the drawable. See my comment in the source @@ -249,6 +250,7 @@ QString _ghostscriptPath; QStringList _ghostscriptArguments; QString _fileName; + bool _usePipe; /** * Flag set when one of the properties _ghostscriptPath,