diff options
author | Muthu Subramanian K <sumuthu@novell.com> | 2010-08-25 23:37:30 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2010-08-26 13:08:40 +0200 |
commit | 5d7c99f0c7f5fcc147fe45f01efbc7b7607784e8 (patch) | |
tree | 5c3eb3c6a3eaa2edf580285c438938a8c3975b8c /desktop/source/app | |
parent | 495e53b5cf4eca01ac3137aca702bf69d7f8eaff (diff) |
desktop-cmd-bulk-conversion.diff: Batch conversion.
Based on work by Florian Reuter <freuter@novell.com>.
Diffstat (limited to 'desktop/source/app')
-rw-r--r-- | desktop/source/app/app.cxx | 9 | ||||
-rw-r--r-- | desktop/source/app/cmdlineargs.cxx | 67 | ||||
-rw-r--r-- | desktop/source/app/cmdlineargs.hxx | 6 | ||||
-rw-r--r-- | desktop/source/app/cmdlinehelp.cxx | 12 | ||||
-rw-r--r-- | desktop/source/app/dispatchwatcher.cxx | 203 | ||||
-rw-r--r-- | desktop/source/app/dispatchwatcher.hxx | 6 | ||||
-rw-r--r-- | desktop/source/app/officeipcthread.cxx | 59 | ||||
-rw-r--r-- | desktop/source/app/officeipcthread.hxx | 3 |
8 files changed, 339 insertions, 26 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index b5406fc127..6e8d53e1d0 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -2564,6 +2564,9 @@ void Desktop::OpenClients() pArgs->GetPrinterName( aRequest.aPrinterName ); pArgs->GetForceOpenList( aRequest.aForceOpenList ); pArgs->GetForceNewList( aRequest.aForceNewList ); + pArgs->GetConversionList( aRequest.aConversionList ); + pArgs->GetConversionParams( aRequest.aConversionParams ); + pArgs->GetConversionOut( aRequest.aConversionOut ); if ( aRequest.aOpenList.getLength() > 0 || aRequest.aViewList.getLength() > 0 || @@ -2571,7 +2574,8 @@ void Desktop::OpenClients() aRequest.aPrintList.getLength() > 0 || aRequest.aForceOpenList.getLength() > 0 || aRequest.aForceNewList.getLength() > 0 || - ( aRequest.aPrintToList.getLength() > 0 && aRequest.aPrinterName.getLength() > 0 )) + ( aRequest.aPrintToList.getLength() > 0 && aRequest.aPrinterName.getLength() > 0 ) || + aRequest.aConversionList.getLength() > 0 ) { bLoaded = sal_True; @@ -2921,7 +2925,8 @@ void Desktop::OpenSplashScreen() !pCmdLine->IsNoLogo() && !pCmdLine->IsTerminateAfterInit() && !pCmdLine->GetPrintList( aTmpString ) && - !pCmdLine->GetPrintToList( aTmpString ) ) + !pCmdLine->GetPrintToList( aTmpString ) && + !pCmdLine->GetConversionList( aTmpString )) { // Determine application name from command line parameters OUString aAppName; diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 06f6e33555..89348723a6 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -151,6 +151,11 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) sal_Bool bForceOpenEvent = sal_False; sal_Bool bForceNewEvent = sal_False; sal_Bool bDisplaySpec = sal_False; + sal_Bool bConversionEvent= sal_False; + sal_Bool bConversionParamsEvent= sal_False; + sal_Bool bBatchPrintEvent= sal_False; + sal_Bool bBatchPrinterNameEvent= sal_False; + sal_Bool bConversionOutEvent = sal_False; m_eArgumentCount = NONE; @@ -295,6 +300,27 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) bDisplaySpec = sal_False; } #endif + else if ( aArgStr.EqualsIgnoreCaseAscii( "-convert-to" ) ) + { + bOpenEvent = sal_False; + bConversionEvent = sal_True; + bConversionParamsEvent = sal_True; + } + else if ( aArgStr.EqualsIgnoreCaseAscii( "-print-to-file" ) ) + { + bOpenEvent = sal_False; + bBatchPrintEvent = sal_True; + } + else if ( aArgStr.EqualsIgnoreCaseAscii( "-printer-name" ) && + bBatchPrintEvent ) + { + bBatchPrinterNameEvent = sal_True; + } + else if ( aArgStr.EqualsIgnoreCaseAscii( "-outdir" ) && + (bConversionEvent || bBatchPrintEvent) ) + { + bConversionOutEvent = sal_True; + } } else { @@ -304,6 +330,23 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) AddStringListParam_Impl( CMD_STRINGPARAM_PRINTERNAME, aArgStr ); bPrinterName = sal_False; } + else if ( bConversionParamsEvent && bConversionEvent ) + { + // first argument must be the the params + AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONPARAMS, aArgStr ); + bConversionParamsEvent = sal_False; + } + else if ( bBatchPrinterNameEvent && bBatchPrintEvent ) + { + // first argument is the printer name + AddStringListParam_Impl( CMD_STRINGPARAM_PRINTERNAME, aArgStr ); + bBatchPrinterNameEvent = sal_False; + } + else if ( (bConversionEvent || bBatchPrintEvent) && bConversionOutEvent ) + { + AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONOUT, aArgStr ); + bConversionOutEvent = sal_False; + } else { if( bOpenEvent || bViewEvent || bForceNewEvent || bForceOpenEvent ) @@ -335,6 +378,8 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) bDisplaySpec = sal_False; // only one display, not a lsit bOpenEvent = sal_True; // set back to standard } + else if ( bConversionEvent || bBatchPrintEvent ) + AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONLIST, aArgStr ); } } } @@ -891,6 +936,28 @@ sal_Bool CommandLineArgs::GetLanguage( ::rtl::OUString& rPara ) const return m_aStrSetParams[ CMD_STRINGPARAM_LANGUAGE ]; } +sal_Bool CommandLineArgs::GetConversionList( ::rtl::OUString& rPara ) const +{ + osl::MutexGuard aMutexGuard( m_aMutex ); + rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONLIST ]; + return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONLIST ]; +} + +sal_Bool CommandLineArgs::GetConversionParams( ::rtl::OUString& rPara ) const +{ + osl::MutexGuard aMutexGuard( m_aMutex ); + rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONPARAMS ]; + return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONPARAMS ]; +} +sal_Bool CommandLineArgs::GetConversionOut( ::rtl::OUString& rPara ) const +{ + osl::MutexGuard aMutexGuard( m_aMutex ); + rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONOUT ]; + return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONOUT ]; +} + + + sal_Bool CommandLineArgs::IsEmpty() const { osl::MutexGuard aMutexGuard( m_aMutex ); diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx index 569dd5ccbc..f6c2845d57 100644 --- a/desktop/source/app/cmdlineargs.hxx +++ b/desktop/source/app/cmdlineargs.hxx @@ -90,6 +90,9 @@ class CommandLineArgs CMD_STRINGPARAM_VERSION, CMD_STRINGPARAM_PRINTTOLIST, CMD_STRINGPARAM_PRINTERNAME, + CMD_STRINGPARAM_CONVERSIONLIST, + CMD_STRINGPARAM_CONVERSIONPARAMS, + CMD_STRINGPARAM_CONVERSIONOUT, CMD_STRINGPARAM_DISPLAY, CMD_STRINGPARAM_LANGUAGE, CMD_STRINGPARAM_COUNT // must be last element! @@ -169,6 +172,9 @@ class CommandLineArgs sal_Bool GetPrintToList( ::rtl::OUString& rPara ) const; sal_Bool GetPrinterName( ::rtl::OUString& rPara ) const; sal_Bool GetLanguage( ::rtl::OUString& rPara ) const; + sal_Bool GetConversionList( ::rtl::OUString& rPara ) const; + sal_Bool GetConversionParams( ::rtl::OUString& rPara ) const; + sal_Bool GetConversionOut( ::rtl::OUString& rPara ) const; // Special analyzed states (does not match directly to a command line parameter!) sal_Bool IsPrinting() const; diff --git a/desktop/source/app/cmdlinehelp.cxx b/desktop/source/app/cmdlinehelp.cxx index 8af72e63ec..cb96e6f3f0 100644 --- a/desktop/source/app/cmdlinehelp.cxx +++ b/desktop/source/app/cmdlinehelp.cxx @@ -116,7 +116,17 @@ namespace desktop "-unaccept=<accept-string>\n"\ " Close an acceptor that was created with -accept=<accept-string>\n"\ " Use -unnaccept=all to close all open acceptors\n"\ - "Remaining arguments will be treated as filenames or URLs of documents to open.\n"; + "-convert-to output_file_extension[:output_filter_name] [-outdir ouput_dir] files\n"\ + " Batch convert files.\n"\ + " If -outdir is not specified then current working dir is used as output_dir.\n"\ + " Eg. -convert-to pdf *.doc\n"\ + " -convert-to pdf:writer_pdf_Export -outdir /home/user *.doc\n"\ + "-print-to-file [-printer-name printer_name] [-outdir ouput_dir] files\n"\ + " Batch print files to file.\n"\ + " If -outdir is not specified then current working dir is used as output_dir.\n"\ + " Eg. -print-to-file *.doc\n"\ + " -print-to-file -printer-name nasty_lowres_printer -outdir /home/user *.doc\n"\ + "\nRemaining arguments will be treated as filenames or URLs of documents to open.\n"; void ReplaceStringHookProc( UniString& rStr ); diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index e6383e32bd..9bcba45eed 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -28,6 +28,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_desktop.hxx" +#include <sfx2/docfile.hxx> +#include <sfx2/docfilt.hxx> +#include <sfx2/fcontnr.hxx> +#include "osl/file.hxx" +#include <svl/fstathelper.hxx> + #include "dispatchwatcher.hxx" #include <rtl/ustring.hxx> #include <tools/string.hxx> @@ -48,13 +54,15 @@ #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/document/MacroExecMode.hpp> #include <com/sun/star/document/UpdateDocMode.hpp> +#include <com/sun/star/frame/XStorable.hpp> #include <tools/urlobj.hxx> #include <comphelper/mediadescriptor.hxx> #include <vector> +#include <osl/thread.hxx> -using namespace ::rtl; +using ::rtl::OUString; using namespace ::osl; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; @@ -80,6 +88,42 @@ struct DispatchHolder Reference< XDispatch > xDispatch; }; +// Temporary code +static void impl_sleep( sal_uInt32 nSec ) +{ + TimeValue aTime; + aTime.Seconds = nSec; + aTime.Nanosec = 0; + + osl::Thread::wait( aTime ); +} + +static String impl_GetFilterFromExt( OUString aUrl, SfxFilterFlags nFlags, + String aAppl ) +{ + String aFilter; + SfxMedium* pMedium = new SfxMedium( aUrl, + STREAM_STD_READ, FALSE ); + const SfxFilter *pSfxFilter = NULL; + SfxFilterMatcher aMatcher; + if( nFlags == SFX_FILTER_EXPORT ) + aMatcher = SfxFilterMatcher( aAppl ); + aMatcher.GuessFilterIgnoringContent( *pMedium, &pSfxFilter, nFlags, 0 ); + if( pSfxFilter ) + aFilter = ( nFlags == SFX_FILTER_EXPORT ) ? pSfxFilter->GetFilterName() : + pSfxFilter->GetServiceName(); + + delete pMedium; + return aFilter; +} +static OUString impl_GuessFilter( OUString aUrlIn, OUString aUrlOut ) +{ + /* aAppl can also be set to Factory like scalc, swriter... */ + String aAppl; + aAppl = impl_GetFilterFromExt( aUrlIn, SFX_FILTER_IMPORT, aAppl ); + return impl_GetFilterFromExt( aUrlOut, SFX_FILTER_EXPORT, aAppl ); +} + Mutex* DispatchWatcher::pWatcherMutex = NULL; Mutex& DispatchWatcher::GetMutex() @@ -141,7 +185,6 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch for ( p = aDispatchRequestsList.begin(); p != aDispatchRequestsList.end(); p++ ) { - String aPrinterName; const DispatchRequest& aDispatchRequest = *p; // create parameter array @@ -151,7 +194,9 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch // we need more properties for a print/print to request if ( aDispatchRequest.aRequestType == REQUEST_PRINT || - aDispatchRequest.aRequestType == REQUEST_PRINTTO ) + aDispatchRequest.aRequestType == REQUEST_PRINTTO || + aDispatchRequest.aRequestType == REQUEST_BATCHPRINT || + aDispatchRequest.aRequestType == REQUEST_CONVERSION) nCount++; Sequence < PropertyValue > aArgs( nCount ); @@ -161,7 +206,9 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch aArgs[0].Value <<= ::rtl::OUString::createFromAscii("private:OpenEvent"); if ( aDispatchRequest.aRequestType == REQUEST_PRINT || - aDispatchRequest.aRequestType == REQUEST_PRINTTO ) + aDispatchRequest.aRequestType == REQUEST_PRINTTO || + aDispatchRequest.aRequestType == REQUEST_BATCHPRINT || + aDispatchRequest.aRequestType == REQUEST_CONVERSION) { aArgs[1].Name = ::rtl::OUString::createFromAscii("ReadOnly"); aArgs[2].Name = ::rtl::OUString::createFromAscii("OpenNewView"); @@ -196,7 +243,9 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch ::rtl::OUString aTarget( RTL_CONSTASCII_USTRINGPARAM("_default") ); if ( aDispatchRequest.aRequestType == REQUEST_PRINT || - aDispatchRequest.aRequestType == REQUEST_PRINTTO ) + aDispatchRequest.aRequestType == REQUEST_PRINTTO || + aDispatchRequest.aRequestType == REQUEST_BATCHPRINT || + aDispatchRequest.aRequestType == REQUEST_CONVERSION) { // documents opened for printing are opened readonly because they must be opened as a new document and this // document could be open already @@ -214,7 +263,6 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch // hidden documents should never be put into open tasks aTarget = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ); } - // load the document ... if they are loadable! // Otherwise try to dispatch it ... Reference < XPrintable > xDoc; @@ -361,24 +409,133 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch OfficeIPCThread::RequestsCompleted( 1 ); } else if ( aDispatchRequest.aRequestType == REQUEST_PRINT || - aDispatchRequest.aRequestType == REQUEST_PRINTTO ) + aDispatchRequest.aRequestType == REQUEST_PRINTTO || + aDispatchRequest.aRequestType == REQUEST_BATCHPRINT || + aDispatchRequest.aRequestType == REQUEST_CONVERSION ) { if ( xDoc.is() ) { - if ( aDispatchRequest.aRequestType == REQUEST_PRINTTO ) - { - // create the printer + if ( aDispatchRequest.aRequestType == REQUEST_CONVERSION ) { + Reference< XStorable > xStorable( xDoc, UNO_QUERY ); + if ( xStorable.is() ) { + rtl::OUString aParam = aDispatchRequest.aPrinterName; + sal_Int32 nPathIndex = aParam.lastIndexOfAsciiL( ";", 1 ); + sal_Int32 nFilterIndex = aParam.indexOfAsciiL( ":", 1 ); + if( nPathIndex < nFilterIndex ) + nFilterIndex = -1; + rtl::OUString aFilterOut=aParam.copy( nPathIndex+1 ); + rtl::OUString aFilter; + rtl::OUString aFilterExt; + sal_Bool bGuess = sal_False; + + if( nFilterIndex >= 0 ) + { + aFilter = aParam.copy( nFilterIndex+1, nPathIndex-nFilterIndex-1 ); + aFilterExt = aParam.copy( 0, nFilterIndex ); + } + else + { + // Guess + bGuess = sal_True; + aFilterExt = aParam.copy( 0, nPathIndex ); + } + INetURLObject aOutFilename( aObj ); + aOutFilename.SetExtension( aFilterExt ); + FileBase::getFileURLFromSystemPath( aFilterOut, aFilterOut ); + rtl::OUString aOutFile = aFilterOut+ + ::rtl::OUString::createFromAscii( "/" )+ + aOutFilename.getName(); + //FileBase::getFileURLFromSystemPath( aOutFile, aOutFile ); + + if ( bGuess ) + { + aFilter = impl_GuessFilter( aName, aOutFile ); + } + + Sequence<PropertyValue> conversionProperties( 2 ); + conversionProperties[0].Name = ::rtl::OUString::createFromAscii( "Overwrite" ); + conversionProperties[0].Value <<= sal_True; + + conversionProperties[1].Name = ::rtl::OUString::createFromAscii( "FilterName" ); + conversionProperties[1].Value <<= aFilter; + + rtl::OUString aTempName; + FileBase::getSystemPathFromFileURL( aName, aTempName ); + rtl::OString aSource8 = ::rtl::OUStringToOString ( aTempName, RTL_TEXTENCODING_UTF8 ); + FileBase::getSystemPathFromFileURL( aOutFile, aTempName ); + rtl::OString aTargetURL8 = ::rtl::OUStringToOString(aTempName, RTL_TEXTENCODING_UTF8 ); + printf("convert %s -> %s using %s\n", aSource8.getStr(), aTargetURL8.getStr(), + ::rtl::OUStringToOString( aFilter, RTL_TEXTENCODING_UTF8 ).getStr()); + if( FStatHelper::IsDocument(aOutFile) ) + printf("Overwriting: %s\n",::rtl::OUStringToOString( aTempName, RTL_TEXTENCODING_UTF8 ).getStr() ); + try + { + xStorable->storeToURL( aOutFile, conversionProperties ); + } + catch ( Exception& ) + { + fprintf( stderr, "Error: Please reverify input parameters...\n" ); + } + } + } else if ( aDispatchRequest.aRequestType == REQUEST_BATCHPRINT ) { + rtl::OUString aParam = aDispatchRequest.aPrinterName; + sal_Int32 nPathIndex = aParam.lastIndexOfAsciiL( ";", 1 ); + + rtl::OUString aFilterOut; + rtl::OUString aPrinterName; + if( nPathIndex != -1 ) + aFilterOut=aParam.copy( nPathIndex+1 ); + if( nPathIndex != 0 ) + aPrinterName=aParam.copy( 0, nPathIndex ); + + INetURLObject aOutFilename( aObj ); + aOutFilename.SetExtension( ::rtl::OUString::createFromAscii("ps") ); + FileBase::getFileURLFromSystemPath( aFilterOut, aFilterOut ); + rtl::OUString aOutFile = aFilterOut+ + ::rtl::OUString::createFromAscii( "/" )+ + aOutFilename.getName(); + + rtl::OUString aTempName; + FileBase::getSystemPathFromFileURL( aName, aTempName ); + rtl::OString aSource8 = ::rtl::OUStringToOString ( aTempName, RTL_TEXTENCODING_UTF8 ); + FileBase::getSystemPathFromFileURL( aOutFile, aTempName ); + rtl::OString aTargetURL8 = ::rtl::OUStringToOString(aTempName, RTL_TEXTENCODING_UTF8 ); + printf("print %s -> %s using %s\n", aSource8.getStr(), aTargetURL8.getStr(), + aPrinterName.getLength() ? + ::rtl::OUStringToOString( aPrinterName, RTL_TEXTENCODING_UTF8 ).getStr() : "<default_printer>"); + + // create the custom printer, if given Sequence < PropertyValue > aPrinterArgs( 1 ); - aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Name"); - aPrinterArgs[0].Value <<= ::rtl::OUString( aDispatchRequest.aPrinterName ); - xDoc->setPrinter( aPrinterArgs ); + if( aPrinterName.getLength() ) + { + aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Name"); + aPrinterArgs[0].Value <<= aPrinterName; + xDoc->setPrinter( aPrinterArgs ); + } + + // print ( also without user interaction ) + aPrinterArgs.realloc(2); + aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("FileName"); + aPrinterArgs[0].Value <<= aOutFile; + aPrinterArgs[1].Name = ::rtl::OUString::createFromAscii("Wait"); + aPrinterArgs[1].Value <<= ( sal_Bool ) sal_True; + xDoc->print( aPrinterArgs ); + } else { + if ( aDispatchRequest.aRequestType == REQUEST_PRINTTO ) + { + // create the printer + Sequence < PropertyValue > aPrinterArgs( 1 ); + aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Name"); + aPrinterArgs[0].Value <<= ::rtl::OUString( aDispatchRequest.aPrinterName ); + xDoc->setPrinter( aPrinterArgs ); + } + + // print ( also without user interaction ) + Sequence < PropertyValue > aPrinterArgs( 1 ); + aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Wait"); + aPrinterArgs[0].Value <<= ( sal_Bool ) sal_True; + xDoc->print( aPrinterArgs ); } - - // print ( also without user interaction ) - Sequence < PropertyValue > aPrinterArgs( 1 ); - aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Wait"); - aPrinterArgs[0].Value <<= ( sal_Bool ) sal_True; - xDoc->print( aPrinterArgs ); } else { @@ -442,10 +599,16 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch // implementation via statusChanged!! if ( bEmpty && !bNoTerminate /*m_aRequestContainer.empty()*/ ) { + // Delay give a chance for threads to complete work + impl_sleep(2); + // We have to check if we have an open task otherwise we have to shutdown the office. Reference< XFramesSupplier > xTasksSupplier( xDesktop, UNO_QUERY ); aGuard.clear(); + // Delay give a chance for threads to complete work + impl_sleep(1); + Reference< XElementAccess > xList( xTasksSupplier->getFrames(), UNO_QUERY ); if ( !xList->hasElements() ) @@ -470,7 +633,7 @@ throw(::com::sun::star::uno::RuntimeException) void SAL_CALL DispatchWatcher::dispatchFinished( const DispatchResultEvent& ) throw( RuntimeException ) { osl::ClearableMutexGuard aGuard( GetMutex() ); - sal_Int16 nCount = --m_nRequestCount; + sal_Int16 nCount = m_nRequestCount; aGuard.clear(); OfficeIPCThread::RequestsCompleted( 1 ); /* diff --git a/desktop/source/app/dispatchwatcher.hxx b/desktop/source/app/dispatchwatcher.hxx index f7de7ae0df..62828a5a0f 100644 --- a/desktop/source/app/dispatchwatcher.hxx +++ b/desktop/source/app/dispatchwatcher.hxx @@ -75,7 +75,9 @@ class DispatchWatcher : public ::cppu::WeakImplHelper1< ::com::sun::star::frame: REQUEST_PRINT, REQUEST_PRINTTO, REQUEST_FORCEOPEN, - REQUEST_FORCENEW + REQUEST_FORCENEW, + REQUEST_CONVERSION, + REQUEST_BATCHPRINT }; struct DispatchRequest @@ -86,7 +88,7 @@ class DispatchWatcher : public ::cppu::WeakImplHelper1< ::com::sun::star::frame: RequestType aRequestType; rtl::OUString aURL; boost::optional< rtl::OUString > aCwdUrl; - rtl::OUString aPrinterName; + rtl::OUString aPrinterName; // also conversion params rtl::OUString aPreselectedFactory; }; diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index 0bd9db40de..56d02e4c28 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -51,6 +51,7 @@ #include "osl/file.hxx" #include "rtl/process.h" #include "tools/getprocessworkingdir.hxx" +#include "osl/file.hxx" using namespace vos; using namespace rtl; @@ -945,6 +946,62 @@ static void AddToDispatchList( } } +static void AddConversionsToDispatchList( + DispatchWatcher::DispatchList& rDispatchList, + boost::optional< rtl::OUString > const & cwdUrl, + const OUString& rRequestList, + const OUString& rParam, + const OUString& rPrinterName, + const OUString& rFactory, + const OUString& rParamOut ) +{ + DispatchWatcher::RequestType nType; + OUString aParam( rParam ); + + if( rParam.getLength() ) + { + nType = DispatchWatcher::REQUEST_CONVERSION; + aParam = rParam; + } + else + { + nType = DispatchWatcher::REQUEST_BATCHPRINT; + aParam = rPrinterName; + } + + OUString aOutDir( rParamOut.trim() ); + ::rtl::OUString aPWD; + ::tools::getProcessWorkingDir( &aPWD ); + + if( !::osl::FileBase::getAbsoluteFileURL( aPWD, rParamOut, aOutDir ) ) + ::osl::FileBase::getSystemPathFromFileURL( aOutDir, aOutDir ); + + if( rParamOut.trim().getLength() ) + { + aParam += ::rtl::OUString::createFromAscii(";"); + aParam += aOutDir; + } + else + { + ::osl::FileBase::getSystemPathFromFileURL( aPWD, aPWD ); + aParam += ::rtl::OUString::createFromAscii( ";" ) + aPWD; + } + + if ( rRequestList.getLength() > 0 ) + { + sal_Int32 nIndex = 0; + do + { + OUString aToken = rRequestList.getToken( 0, APPEVENT_PARAM_DELIMITER, nIndex ); + if ( aToken.getLength() > 0 ) + rDispatchList.push_back( + DispatchWatcher::DispatchRequest( nType, aToken, cwdUrl, aParam, rFactory )); + } + while ( nIndex >= 0 ); + } +} + + sal_Bool OfficeIPCThread::ExecuteCmdLineRequests( ProcessDocumentsRequest& aRequest ) { // protect the dispatch list @@ -961,7 +1018,7 @@ sal_Bool OfficeIPCThread::ExecuteCmdLineRequests( ProcessDocumentsRequest& aRequ AddToDispatchList( aDispatchList, aRequest.aCwdUrl, aRequest.aPrintToList, DispatchWatcher::REQUEST_PRINTTO, aRequest.aPrinterName, aRequest.aModule ); AddToDispatchList( aDispatchList, aRequest.aCwdUrl, aRequest.aForceOpenList, DispatchWatcher::REQUEST_FORCEOPEN, aEmpty, aRequest.aModule ); AddToDispatchList( aDispatchList, aRequest.aCwdUrl, aRequest.aForceNewList, DispatchWatcher::REQUEST_FORCENEW, aEmpty, aRequest.aModule ); - + AddConversionsToDispatchList( aDispatchList, aRequest.aCwdUrl, aRequest.aConversionList, aRequest.aConversionParams, aRequest.aPrinterName, aRequest.aModule, aRequest.aConversionOut ); sal_Bool bShutdown( sal_False ); if ( pGlobalOfficeIPCThread ) diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx index 92a35a5ff7..4f442a988a 100644 --- a/desktop/source/app/officeipcthread.hxx +++ b/desktop/source/app/officeipcthread.hxx @@ -66,6 +66,9 @@ struct ProcessDocumentsRequest ::rtl::OUString aForceNewList; // Documents that should be forced to create a new document ::rtl::OUString aPrinterName; // The printer name that should be used for printing ::rtl::OUString aPrintToList; // Documents that should be printed on the given printer + ::rtl::OUString aConversionList; + ::rtl::OUString aConversionParams; + ::rtl::OUString aConversionOut; ::osl::Condition *pcProcessed; // pointer condition to be set when the request has been processed }; |