[ooo-build-commit] .: patches/dev300

Muthu Subramanian sumuthu at kemper.freedesktop.org
Tue Jun 8 06:55:05 PDT 2010


 patches/dev300/desktop-cmd-bulk-conversion.diff |  485 ++++++++++++++++--------
 1 file changed, 339 insertions(+), 146 deletions(-)

New commits:
commit 7e55f86ff774f472bf7da5a175228a5ab0cebcb4
Author: Muthu Subramanian K <sumuthu at novell.com>
Date:   Tue Jun 8 19:22:02 2010 +0530

    Updated batch conversion patch.
    
    * patches/dev300/desktop-cmd-bulk-conversion.diff:

diff --git a/patches/dev300/desktop-cmd-bulk-conversion.diff b/patches/dev300/desktop-cmd-bulk-conversion.diff
index e6bea00..b61f49a 100644
--- a/patches/dev300/desktop-cmd-bulk-conversion.diff
+++ b/patches/dev300/desktop-cmd-bulk-conversion.diff
@@ -1,63 +1,68 @@
-diff --git desktop/source/app/app.cxx desktop/source/app/app.cxx
-index dc7d7ef..1648da1 100644
---- desktop/source/app/app.cxx
-+++ desktop/source/app/app.cxx
-@@ -2468,6 +2468,8 @@ void Desktop::OpenClients()
+diff -upr desktop/source/app/app.cxx desktop/source/app/app.cxx
+--- desktop/source/app/app.cxx	2010-05-11 19:13:49.000000000 +0530
++++ desktop/source/app/app.cxx	2010-05-11 12:08:29.000000000 +0530
+@@ -2546,6 +2546,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 ||
-@@ -2475,7 +2477,8 @@ void Desktop::OpenClients()
+@@ -2553,7 +2556,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 && aRequest.aConversionParams.getLength() > 0 ))
++             ( aRequest.aConversionList.getLength() > 0 && aRequest.aConversionParams.getLength() > 0 ))
          {
              bLoaded = sal_True;
  
-@@ -2825,7 +2828,8 @@ void Desktop::OpenSplashScreen()
+@@ -2903,7 +2907,8 @@ void Desktop::OpenSplashScreen()
           !pCmdLine->IsNoLogo() &&
           !pCmdLine->IsTerminateAfterInit() &&
           !pCmdLine->GetPrintList( aTmpString ) &&
 -         !pCmdLine->GetPrintToList( aTmpString ) )
 +         !pCmdLine->GetPrintToList( aTmpString ) &&
-+     !pCmdLine->GetConversionList( aTmpString ))
++         !pCmdLine->GetConversionList( aTmpString ))
      {
          // Determine application name from command line parameters
          OUString aAppName;
-diff --git desktop/source/app/cmdlineargs.cxx desktop/source/app/cmdlineargs.cxx
-index 88cb6bf..0d1f027 100644
---- desktop/source/app/cmdlineargs.cxx
-+++ desktop/source/app/cmdlineargs.cxx
-@@ -154,6 +154,8 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
+diff -upr desktop/source/app/cmdlineargs.cxx desktop/source/app/cmdlineargs.cxx
+--- desktop/source/app/cmdlineargs.cxx	2010-05-11 19:14:16.000000000 +0530
++++ desktop/source/app/cmdlineargs.cxx	2010-05-11 19:21:17.000000000 +0530
+@@ -151,6 +151,9 @@ void CommandLineArgs::ParseCommandLine_I
      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    bConversionParamsEvent= sal_False;
++    sal_Bool    bConversionOutEvent   = sal_False;
  
      m_eArgumentCount = NONE;
  
-@@ -286,6 +288,12 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
-                             bDisplaySpec	= sal_False;
+@@ -295,6 +298,17 @@ void CommandLineArgs::ParseCommandLine_I
+                         bDisplaySpec	= sal_False;
                      }
                      #endif
-+                    else if ( aArgStr.EqualsIgnoreCaseAscii( "-bulk" ))
++                    else if ( aArgStr.EqualsIgnoreCaseAscii( "-convert-to" ) )
 +                    {
-+              bOpenEvent = sal_False;
-+              bConversionEvent = sal_True;
-+              bConversionParamsEvent = sal_True;
-+            }
++                        bOpenEvent = sal_False;
++                        bConversionEvent = sal_True;
++                        bConversionParamsEvent = sal_True;
++                    }
++                    else if ( aArgStr.EqualsIgnoreCaseAscii( "-outdir" ) && 
++                              bConversionEvent )
++                    {
++                        bConversionOutEvent = sal_True;
++                    }
                  }
                  else
                  {
-@@ -295,6 +303,12 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
+@@ -304,6 +318,17 @@ void CommandLineArgs::ParseCommandLine_I
                          AddStringListParam_Impl( CMD_STRINGPARAM_PRINTERNAME, aArgStr );
                          bPrinterName = sal_False;
                      }
@@ -67,22 +72,29 @@ index 88cb6bf..0d1f027 100644
 +                        AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONPARAMS, aArgStr );
 +                        bConversionParamsEvent = sal_False;
 +                    }
++                    else if ( bConversionEvent && bConversionOutEvent )
++                    {
++                        AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONOUT, aArgStr );
++                        bConversionOutEvent = sal_False;
++                    }
                      else
                      {
  						if( bOpenEvent || bViewEvent || bForceNewEvent || bForceOpenEvent )
-@@ -326,6 +340,10 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
+@@ -335,6 +360,12 @@ void CommandLineArgs::ParseCommandLine_I
                              bDisplaySpec = sal_False; // only one display, not a lsit
                              bOpenEvent = sal_True;    // set back to standard
                          }
 +                        else if ( bConversionEvent )
 +                            AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONLIST, aArgStr );
 +                        else if ( bConversionParamsEvent )
++                        {
 +                            AddStringListParam_Impl( CMD_STRINGPARAM_CONVERSIONPARAMS, aArgStr );
++                        }
                      }
                  }
              }
-@@ -870,6 +888,22 @@ sal_Bool CommandLineArgs::GetPrinterName( ::rtl::OUString& rPara ) const
-     return m_aStrSetParams[ CMD_STRINGPARAM_PRINTERNAME ];
+@@ -891,6 +922,28 @@ sal_Bool CommandLineArgs::GetLanguage( :
+     return m_aStrSetParams[ CMD_STRINGPARAM_LANGUAGE ];
  }
  
 +sal_Bool CommandLineArgs::GetConversionList( ::rtl::OUString& rPara ) const
@@ -98,39 +110,130 @@ index 88cb6bf..0d1f027 100644
 +    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 desktop/source/app/cmdlineargs.hxx desktop/source/app/cmdlineargs.hxx
-index 9b5d046..f98becf 100644
---- desktop/source/app/cmdlineargs.hxx
-+++ desktop/source/app/cmdlineargs.hxx
-@@ -93,6 +93,8 @@ class CommandLineArgs
+diff -upr desktop/source/app/cmdlineargs.hxx desktop/source/app/cmdlineargs.hxx
+--- desktop/source/app/cmdlineargs.hxx	2010-05-11 19:13:37.000000000 +0530
++++ desktop/source/app/cmdlineargs.hxx	2010-05-11 12:20:13.000000000 +0530
+@@ -90,6 +90,9 @@ class CommandLineArgs
              CMD_STRINGPARAM_VERSION,
              CMD_STRINGPARAM_PRINTTOLIST,
              CMD_STRINGPARAM_PRINTERNAME,
-+        CMD_STRINGPARAM_CONVERSIONLIST,
-+        CMD_STRINGPARAM_CONVERSIONPARAMS,	    
++            CMD_STRINGPARAM_CONVERSIONLIST,
++            CMD_STRINGPARAM_CONVERSIONPARAMS,
++            CMD_STRINGPARAM_CONVERSIONOUT,
              CMD_STRINGPARAM_DISPLAY,
+             CMD_STRINGPARAM_LANGUAGE,
              CMD_STRINGPARAM_COUNT			// must be last element!
-         };
-@@ -171,6 +173,8 @@ class CommandLineArgs
-         sal_Bool				GetPrintList( ::rtl::OUString& rPara) const;
+@@ -170,6 +173,9 @@ class CommandLineArgs
          sal_Bool				GetPrintToList( ::rtl::OUString& rPara ) const;
          sal_Bool				GetPrinterName( ::rtl::OUString& rPara ) const;
-+        sal_Bool				GetConversionList( ::rtl::OUString& rPara ) const;
-+        sal_Bool				GetConversionParams( ::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 desktop/source/app/dispatchwatcher.cxx desktop/source/app/dispatchwatcher.cxx
-index 891e756..cc87832 100644
---- desktop/source/app/dispatchwatcher.cxx
-+++ desktop/source/app/dispatchwatcher.cxx
-@@ -51,6 +51,7 @@
+diff -upr desktop/source/app/dispatchwatcher.hxx desktop/source/app/dispatchwatcher.hxx
+--- desktop/source/app/dispatchwatcher.hxx	2010-05-11 19:11:24.000000000 +0530
++++ desktop/source/app/dispatchwatcher.hxx	2010-05-10 13:51:16.000000000 +0530
+@@ -75,7 +75,8 @@ class DispatchWatcher : public ::cppu::W
+             REQUEST_PRINT,
+             REQUEST_PRINTTO,
+             REQUEST_FORCEOPEN,
+-            REQUEST_FORCENEW
++            REQUEST_FORCENEW,
++            REQUEST_CONVERSION
+         };
+ 
+         struct DispatchRequest
+@@ -86,7 +87,7 @@ class DispatchWatcher : public ::cppu::W
+             RequestType		aRequestType;
+             rtl::OUString	aURL;
+             boost::optional< rtl::OUString > aCwdUrl;
+-            rtl::OUString	aPrinterName;
++            rtl::OUString   aPrinterName;  // also conversion params
+             rtl::OUString   aPreselectedFactory;
+         };
+ 
+--- sfx2/source/bastyp/fltfnc.cxx	2010-05-11 19:11:26.000000000 +0530
++++ sfx2/source/bastyp/fltfnc.cxx	2010-05-14 12:15:37.000000000 +0530
+@@ -374,8 +374,8 @@ const SfxFilter* SfxFilterMatcher::GetAn
+ sal_uInt32  SfxFilterMatcher::GuessFilterIgnoringContent(
+     SfxMedium& rMedium,
+     const SfxFilter**ppFilter,
+-    SfxFilterFlags /*nMust*/,
+-    SfxFilterFlags /*nDont*/ ) const
++    SfxFilterFlags nMust,
++    SfxFilterFlags nDont ) const
+ {
+     Reference< XTypeDetection > xDetection( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.document.TypeDetection")), UNO_QUERY );
+     ::rtl::OUString sTypeName;
+@@ -390,7 +390,7 @@ sal_uInt32  SfxFilterMatcher::GuessFilte
+ 
+     *ppFilter = NULL;
+     if ( sTypeName.getLength() )
+-        *ppFilter = GetFilter4EA( sTypeName );
++        *ppFilter = GetFilter4EA( sTypeName, nMust, nDont );
+ 
+     return *ppFilter ? ERRCODE_NONE : ERRCODE_ABORT;
+ }
+--- desktop/source/app/cmdlinehelp.cxx	2010-05-11 19:13:48.000000000 +0530
++++ desktop/source/app/cmdlinehelp.cxx	2010-05-17 16:44:48.000000000 +0530
+@@ -116,7 +116,12 @@ 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"\
++        "\nRemaining arguments will be treated as filenames or URLs of documents to open.\n";
+ 
+     void ReplaceStringHookProc( UniString& rStr );
+ 
+diff -upr desktop/source/app/officeipcthread.hxx desktop/source/app/officeipcthread.hxx
+--- desktop/source/app/officeipcthread.hxx    2010-05-11 19:11:24.000000000 +0530
++++ desktop/source/app/officeipcthread.hxx    2010-05-11 12:11:09.000000000 +0530
+@@ -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
+ };
+
+--- desktop/source/app/dispatchwatcher.cxx	2010-05-11 19:11:24.000000000 +0530
++++ desktop/source/app/dispatchwatcher.cxx	2010-05-25 16:40:20.000000000 +0530
+@@ -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 <svtools/fstathelper.hxx>
++
+ #include "dispatchwatcher.hxx"
+ #include <rtl/ustring.hxx>
+ #include <tools/string.hxx>
+@@ -48,13 +54,14 @@
  #include <com/sun/star/util/XURLTransformer.hpp>
  #include <com/sun/star/document/MacroExecMode.hpp>
  #include <com/sun/star/document/UpdateDocMode.hpp>
@@ -138,103 +241,203 @@ index 891e756..cc87832 100644
  
  #include <tools/urlobj.hxx>
  #include <comphelper/mediadescriptor.hxx>
-@@ -122,7 +123,7 @@ DispatchWatcher* DispatchWatcher::GetDispatchWatcher()
  
+ #include <vector>
  
- DispatchWatcher::DispatchWatcher()
--    : m_nRequestCount(1)
-+    : m_nRequestCount(0)
- {
- }
- 
-@@ -142,11 +143,16 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch
-     std::vector< DispatchHolder >	aDispatches;
-     ::rtl::OUString					aAsTemplateArg( RTL_CONSTASCII_USTRINGPARAM( "AsTemplate"));
+-using namespace ::rtl;
++using ::rtl::OUString;
+ using namespace ::osl;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::util;
+@@ -80,6 +87,32 @@ struct DispatchHolder
+     Reference< XDispatch > xDispatch;
+ };
  
-+    printf("executeDispatchRequests(bNoTerminate=%i)\n", bNoTerminate);
-+    m_nRequestCount++;
++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 );
++}
 +
-     for ( p = aDispatchRequestsList.begin(); p != aDispatchRequestsList.end(); p++ )
-     {
-         String					aPrinterName;
-         const DispatchRequest&	aDispatchRequest = *p;
+ Mutex* DispatchWatcher::pWatcherMutex = NULL;
  
-+    printf("#aDispatchRequest\n");
-+
-         // create parameter array
-         sal_Int32 nCount = 4;
-         if ( aDispatchRequest.aPreselectedFactory.getLength() )
-@@ -154,7 +160,8 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch
+ Mutex& DispatchWatcher::GetMutex()
+@@ -151,7 +188,8 @@ sal_Bool DispatchWatcher::executeDispatc
  
          // 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_CONVERSION)
++             aDispatchRequest.aRequestType == REQUEST_CONVERSION)
              nCount++;
  
          Sequence < PropertyValue > aArgs( nCount );
-@@ -164,7 +171,8 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch
+@@ -161,7 +199,8 @@ sal_Bool DispatchWatcher::executeDispatc
          aArgs[0].Value <<= ::rtl::OUString::createFromAscii("private:OpenEvent");
  
          if ( aDispatchRequest.aRequestType == REQUEST_PRINT ||
 -             aDispatchRequest.aRequestType == REQUEST_PRINTTO )
 +             aDispatchRequest.aRequestType == REQUEST_PRINTTO ||
-+         aDispatchRequest.aRequestType == REQUEST_CONVERSION)
++             aDispatchRequest.aRequestType == REQUEST_CONVERSION)
          {
              aArgs[1].Name = ::rtl::OUString::createFromAscii("ReadOnly");
              aArgs[2].Name = ::rtl::OUString::createFromAscii("OpenNewView");
-@@ -199,7 +207,8 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch
+@@ -196,7 +235,8 @@ sal_Bool DispatchWatcher::executeDispatc
          ::rtl::OUString aTarget( RTL_CONSTASCII_USTRINGPARAM("_default") );
  
          if ( aDispatchRequest.aRequestType == REQUEST_PRINT ||
 -             aDispatchRequest.aRequestType == REQUEST_PRINTTO )
 +             aDispatchRequest.aRequestType == REQUEST_PRINTTO ||
-+         aDispatchRequest.aRequestType == REQUEST_CONVERSION)
++             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
-@@ -364,10 +373,38 @@ sal_Bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatch
+@@ -214,7 +254,6 @@ sal_Bool DispatchWatcher::executeDispatc
+             // 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 +400,87 @@ sal_Bool DispatchWatcher::executeDispatc
                  OfficeIPCThread::RequestsCompleted( 1 );
              }
              else if ( aDispatchRequest.aRequestType == REQUEST_PRINT ||
 -                      aDispatchRequest.aRequestType == REQUEST_PRINTTO )
 +                      aDispatchRequest.aRequestType == REQUEST_PRINTTO ||
-+              aDispatchRequest.aRequestType == REQUEST_CONVERSION )
++                      aDispatchRequest.aRequestType == REQUEST_CONVERSION )
              {
                  if ( xDoc.is() )
                  {
-+          if (aDispatchRequest.aRequestType == REQUEST_CONVERSION) {
-+            Reference< XStorable > xStorable( xDoc, UNO_QUERY );
-+            if (xStorable.is()) {		  
-+              rtl::OString aSource8 = ::rtl::OUStringToOString (aObj.GetFull(), RTL_TEXTENCODING_UTF8);
-+              INetURLObject aParam( aDispatchRequest.aPrinterName, INetURLObject::FSYS_DETECT);
-+              rtl::OUString aParamName=aParam.GetName(INetURLObject::DECODE_WITH_CHARSET);
+-                    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.lastIndexOfAsciiL( ":", 1 );
++                            rtl::OUString aFilterOut=aParam.copy( nPathIndex+1 );
++                            rtl::OUString aFilter;
++                            rtl::OUString aFilterExt;
++                            sal_Bool bGuess = sal_False;
 +
-+              rtl::OUString aParamExt=aParam.GetExtension(INetURLObject::DECODE_WITH_CHARSET);
-+              rtl::OUString aFilterName(aParamName, aParamName.getLength()-aParamExt.getLength()-1);
-+              rtl::OString aFilterName8 = ::rtl::OUStringToOString (aFilterName, RTL_TEXTENCODING_UTF8);		      
-+              
-+              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 <<= aFilterName;
-+            
-+            INetURLObject aTargetURL(aParam);
-+            aTargetURL.SetName(aObj.GetName());
-+            aTargetURL.SetExtension(aParam.GetExtension());
-+            rtl::OString aTargetURL8 = ::rtl::OUStringToOString (aTargetURL.GetFull(), RTL_TEXTENCODING_UTF8);
-+            
-+            printf("convert %s->%s using %s\n", aSource8.getStr(), aTargetURL8.getStr(), aFilterName8.getStr());
-+            xStorable->storeToURL( aTargetURL.GetMainURL(INetURLObject::NO_DECODE), conversionProperties);
-+            }
-+          } else {
-                     if ( aDispatchRequest.aRequestType == REQUEST_PRINTTO )
-                     {
-                         // create the printer
-@@ -473,7 +510,7 @@ throw(::com::sun::star::uno::RuntimeException)
++                            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(a TempName, 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_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("Name");
+-                        aPrinterArgs[0].Value <<= ::rtl::OUString( aDispatchRequest.aPrinterName );
+-                        xDoc->setPrinter( aPrinterArgs );
++                        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,9 +544,15 @@ sal_Bool DispatchWatcher::executeDispatc
+     // implementation via statusChanged!!
+     if ( bEmpty && !bNoTerminate /*m_aRequestContainer.empty()*/ )
+     {
++        // Delay give a chance for threads to complete work
++        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
++        sleep(1);
+ 
+         Reference< XElementAccess > xList( xTasksSupplier->getFrames(), UNO_QUERY );
+ 
+@@ -470,7 +578,7 @@ throw(::com::sun::star::uno::RuntimeExce
  void SAL_CALL DispatchWatcher::dispatchFinished( const DispatchResultEvent& ) throw( RuntimeException )
  {
      osl::ClearableMutexGuard aGuard( GetMutex() );
@@ -243,34 +446,17 @@ index 891e756..cc87832 100644
      aGuard.clear();
      OfficeIPCThread::RequestsCompleted( 1 );
  /*
-diff --git desktop/source/app/dispatchwatcher.hxx desktop/source/app/dispatchwatcher.hxx
-index ef62dc2..3d3a619 100644
---- desktop/source/app/dispatchwatcher.hxx
-+++ desktop/source/app/dispatchwatcher.hxx
-@@ -78,7 +78,8 @@ class DispatchWatcher : public ::cppu::WeakImplHelper1< ::com::sun::star::frame:
-             REQUEST_PRINT,
-             REQUEST_PRINTTO,
-             REQUEST_FORCEOPEN,
--            REQUEST_FORCENEW
-+            REQUEST_FORCENEW,
-+        REQUEST_CONVERSION
-         };
- 
-         struct DispatchRequest
-@@ -89,7 +90,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;
-         };
+--- desktop/source/app/officeipcthread.cxx	2010-05-11 19:11:24.000000000 +0530
++++ desktop/source/app/officeipcthread.cxx	2010-05-25 16:04:14.000000000 +0530
+@@ -51,6 +51,7 @@
+ #include "osl/file.hxx"
+ #include "rtl/process.h"
+ #include "tools/getprocessworkingdir.hxx"
++#include "osl/file.hxx"
  
-diff --git desktop/source/app/officeipcthread.cxx desktop/source/app/officeipcthread.cxx
-index 9e158b7..73085f5 100644
---- desktop/source/app/officeipcthread.cxx
-+++ desktop/source/app/officeipcthread.cxx
-@@ -948,6 +948,29 @@ static void AddToDispatchList(
+ using namespace vos;
+ using namespace rtl;
+@@ -945,6 +946,49 @@ static void AddToDispatchList(
      }
  }
  
@@ -279,9 +465,29 @@ index 9e158b7..73085f5 100644
 +    boost::optional< rtl::OUString > const & cwdUrl,
 +    const OUString& aRequestList,
 +    DispatchWatcher::RequestType nType,
-+    const OUString& aParam,
-+    const OUString& aFactory )
++    const OUString& aPara,
++    const OUString& aFactory,
++    const OUString& aParamOut )
 +{
++    OUString aOutDir( aParamOut.trim() );
++    OUString aParam( aPara );
++    ::rtl::OUString aPWD;
++    ::tools::getProcessWorkingDir( &aPWD );
++
++    if( !::osl::FileBase::getAbsoluteFileURL( aPWD, aParamOut, aOutDir ) )
++        ::osl::FileBase::getSystemPathFromFileURL( aOutDir, aOutDir );
++ 
++    if( aParamOut.trim().getLength() )
++    {
++        aParam += ::rtl::OUString::createFromAscii(";");
++        aParam += aOutDir;
++    }
++    else
++    {
++        ::osl::FileBase::getSystemPathFromFileURL( aPWD, aPWD );
++        aParam += ::rtl::OUString::createFromAscii( ";" ) + aPWD;
++    }
++
 +    if ( aRequestList.getLength() > 0 )
 +    {
 +        sal_Int32 nIndex = 0;
@@ -300,25 +506,12 @@ index 9e158b7..73085f5 100644
  sal_Bool OfficeIPCThread::ExecuteCmdLineRequests( ProcessDocumentsRequest& aRequest )
  {
      // protect the dispatch list
-@@ -964,7 +987,7 @@ sal_Bool OfficeIPCThread::ExecuteCmdLineRequests( ProcessDocumentsRequest& aRequ
+@@ -961,7 +1005,7 @@ sal_Bool OfficeIPCThread::ExecuteCmdLine
      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, DispatchWatcher::REQUEST_CONVERSION, aRequest.aConversionParams, aRequest.aModule );
++    AddConversionsToDispatchList( aDispatchList, aRequest.aCwdUrl, aRequest.aConversionList, DispatchWatcher::REQUEST_CONVERSION, aRequest.aConversionParams, aRequest.aModule, aRequest.aConversionOut );
      sal_Bool bShutdown( sal_False );
  
      if ( pGlobalOfficeIPCThread )
-diff --git desktop/source/app/officeipcthread.hxx desktop/source/app/officeipcthread.hxx
-index a2949b9..75d5485 100644
---- desktop/source/app/officeipcthread.hxx
-+++ desktop/source/app/officeipcthread.hxx
-@@ -69,6 +69,8 @@ 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;
-     ::osl::Condition *pcProcessed;  // pointer condition to be set when the request has been processed
- };
- 


More information about the ooo-build-commit mailing list