Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


Hi all,

I wrote a patch to allow passing FilterOptions via cli,
which fixes <https://bugs.freedesktop.org/show_bug.cgi?id=36313>.
The patch is attached.

The patch takes the FilterOptions from --infilter and --convert-to args
using : as a delimiter.  This should hopefully not be a problem,
it is current separator used in --convert-to and I am not aware of a filter
name containing that character.  If that is a problem, the separator could
be easily changed to a different character.

The patch was written on top of libreoffice-4-3-branch-point tag
(which compiled for me without serious problems).
Would it be possible to cherry-pick the bug fix also to a fresh 4.2.X
release?

I have tested the change manually and as discussed on the mailing
list last week, there is no easy way to write a test case for
this kind of stuff currently.

Thank you,

Tomas
From 843fefde549b2e3254d95325cc173622e4544eef Mon Sep 17 00:00:00 2001
From: Tomas Hlavaty <tomas.hlavaty@knowledgetools.de>
Date: Tue, 3 Jun 2014 12:42:47 +0200
Subject: [PATCH] allow passing FilterOptions via cli

fixes https://bugs.freedesktop.org/show_bug.cgi?id=36313

Examples:
  --infilter="Text (encoded):UTF8,LF,,,"
  --convert-to "html:XHTML Writer File:UTF8"
  --convert-to "txt:Text (encoded):UTF8"

Change-Id: I69a0524ef63f6d486637d68280331528d1001b56
---
 desktop/source/app/cmdlinehelp.cxx     |    7 +++++--
 desktop/source/app/dispatchwatcher.cxx |   31 ++++++++++++++++++++++++++++---
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/desktop/source/app/cmdlinehelp.cxx b/desktop/source/app/cmdlinehelp.cxx
index 756dcab..a956038 100644
--- a/desktop/source/app/cmdlinehelp.cxx
+++ b/desktop/source/app/cmdlinehelp.cxx
@@ -109,14 +109,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"\
-        "--infilter=<filter>\n"\
+        "--infilter=<filter>[:filter_options]\n"\
         "      Force an input filter type if possible\n"\
         "      Eg. --infilter=\"Calc Office Open XML\"\n"\
-        "--convert-to output_file_extension[:output_filter_name] [--outdir output_dir] files\n"\
+        "          --infilter=\"Text (encoded):UTF8,LF,,,\"\n"\
+        "--convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir 
output_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"\
+        "          --convert-to \"html:XHTML Writer File:UTF8\" *.doc\n"\
+        "          --convert-to \"txt:Text (encoded):UTF8\" *.doc\n"\
         "--print-to-file [-printer-name printer_name] [--outdir output_dir] files\n"\
         "      Batch print files to file.\n"\
         "      If --outdir is not specified then current working dir is used as output_dir.\n"\
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index abdbe38..77e5857 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -375,7 +375,21 @@ bool DispatchWatcher::executeDispatchRequests( const DispatchList& 
aDispatchRequ
                 sal_Int32 nIndex = aArgs.getLength();
                 aArgs.realloc(nIndex+1);
                 aArgs[nIndex].Name = "FilterName";
-                aArgs[nIndex].Value <<= aForcedInputFilter;
+
+                sal_Int32 nFilterOptionsIndex = aForcedInputFilter.indexOf( ':' );
+                if( 0 < nFilterOptionsIndex )
+                {
+                    aArgs[nIndex].Value <<= aForcedInputFilter.copy( 0, nFilterOptionsIndex );
+
+                    nIndex = aArgs.getLength();
+                    aArgs.realloc(nIndex+1);
+                    aArgs[nIndex].Name = "FilterOptions";
+                    aArgs[nIndex].Value <<= aForcedInputFilter.copy( nFilterOptionsIndex+1 );
+                }
+                else
+                {
+                    aArgs[nIndex].Value <<= aForcedInputFilter;
+                }
             }
 
             // This is a synchron loading of a component so we don't have to deal with our 
statusChanged listener mechanism.
@@ -449,12 +463,23 @@ bool DispatchWatcher::executeDispatchRequests( const DispatchList& 
aDispatchRequ
                                 aFilter = impl_GuessFilter( aName, aOutFile );
                             }
 
-                            Sequence<PropertyValue> conversionProperties( 2 );
+                            sal_Int32 nFilterOptionsIndex = aFilter.indexOf( ':' );
+                            Sequence<PropertyValue> conversionProperties( 0 < nFilterOptionsIndex 
? 3 : 2 );
                             conversionProperties[0].Name = "Overwrite";
                             conversionProperties[0].Value <<= sal_True;
 
                             conversionProperties[1].Name = "FilterName";
-                            conversionProperties[1].Value <<= aFilter;
+                            if( 0 < nFilterOptionsIndex )
+                            {
+                                conversionProperties[1].Value <<= aFilter.copy( 0, 
nFilterOptionsIndex );
+
+                                conversionProperties[2].Name = "FilterOptions";
+                                conversionProperties[2].Value <<= aFilter.copy( 
nFilterOptionsIndex+1 );
+                            }
+                            else
+                            {
+                                conversionProperties[1].Value <<= aFilter;
+                            }
 
                             OUString aTempName;
                             FileBase::getSystemPathFromFileURL( aName, aTempName );
-- 
1.7.9.5


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.