Index: kgv_miniwidget.cpp =================================================================== RCS file: /home/kde/kdegraphics/kghostview/kgv_miniwidget.cpp,v retrieving revision 1.155.2.2 diff -u -r1.155.2.2 kgv_miniwidget.cpp --- kgv_miniwidget.cpp 4 Apr 2003 17:23:43 -0000 1.155.2.2 +++ kgv_miniwidget.cpp 5 Apr 2003 23:44:42 -0000 @@ -293,23 +293,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; @@ -320,9 +319,7 @@ _isFileOpen = true; scanDSC(); buildTOC(); - _psWidget->setFileName( dsc()->isStructured() - ? QString::null - : _fileName ); + _psWidget->setFileName( _fileName, dsc()->isStructured() ); emit completed(); } } @@ -854,6 +851,7 @@ << "-dNOPAUSE" << "-dBATCH" << "-dSAFER" + << "-dPARANOIDSAFER" << "-sDEVICE=pswrite" << ( QCString("-sOutputFile=")+QFile::encodeName(saveFileName) ) << ( QString("-dFirstPage=")+QString::number( firstPage ) ) @@ -862,7 +860,7 @@ << "save" << "pop" << "-f" - << QFile::encodeName(_pdfFileName); + << QFile::encodeName(_fileName); /*QValueList args = process.args(); QValueList::Iterator it = args.begin(); @@ -1069,7 +1067,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 } @@ -1306,10 +1304,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.79 diff -u -r1.79 kgv_miniwidget.h --- kgv_miniwidget.h 29 Jul 2002 09:34:26 -0000 1.79 +++ kgv_miniwidget.h 5 Apr 2003 23:44:42 -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 @@ -267,7 +267,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.92.2.1 diff -u -r1.92.2.1 kpswidget.cpp --- kpswidget.cpp 16 Mar 2003 19:52:47 -0000 1.92.2.1 +++ kpswidget.cpp 5 Apr 2003 23:44:42 -0000 @@ -309,10 +309,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; @@ -508,8 +509,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"; @@ -527,7 +531,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.53 diff -u -r1.53 kpswidget.h --- kpswidget.h 21 Aug 2002 11:40:22 -0000 1.53 +++ kpswidget.h 5 Apr 2003 23:44:42 -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 @@ -243,6 +244,7 @@ QString _ghostscriptPath; QStringList _ghostscriptArguments; QString _fileName; + bool _usePipe; /** * Flag set when one of the properties _ghostscriptPath,