GNU bug report logs - #13622
24.3.50; doc-view: Use (and prefer) soffice as default ODF->PDF converter

Previous Next

Package: emacs;

Reported by: Jambunathan K <kjambunathan <at> gmail.com>

Date: Sun, 3 Feb 2013 19:04:02 UTC

Severity: wishlist

Found in version 24.3.50

Done: Tassilo Horn <tsdh <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13622 in the body.
You can then email your comments to 13622 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#13622; Package emacs. (Sun, 03 Feb 2013 19:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jambunathan K <kjambunathan <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 03 Feb 2013 19:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jambunathan K <kjambunathan <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50;
	doc-view: Use (and prefer) soffice as default ODF->PDF converter
Date: Mon, 04 Feb 2013 00:31:47 +0530
[Message part 1 (text/plain, inline)]
I am attaching a patch.  Please apply to trunk.

[Message part 2 (text/plain, inline)]
=== modified file 'lisp/doc-view.el'
--- lisp/doc-view.el	2013-01-24 03:34:20 +0000
+++ lisp/doc-view.el	2013-02-03 18:47:45 +0000
@@ -231,14 +231,36 @@ If this and `doc-view-dvipdfm-program' a
   :type 'file
   :group 'doc-view)
 
-(defcustom doc-view-unoconv-program "unoconv"
+(define-obsolete-variable-alias 'doc-view-unoconv-program
+                                'doc-view-odf->pdf-converter-program
+                                "24.4")
+
+(defcustom doc-view-odf->pdf-converter-program
+  (cond
+   ((executable-find "soffice") "soffice")
+   ((executable-find "unoconv") "unoconv"))
   "Program to convert any file type readable by OpenOffice.org to PDF.
 
 Needed for viewing OpenOffice.org (and MS Office) files."
-  :version "24.1"
+  :version "24.4"
   :type 'file
   :group 'doc-view)
 
+(defcustom doc-view-odf->pdf-converter-function
+  (cond
+   ((string-match "unoconv\\'" doc-view-odf->pdf-converter-program)
+    #'doc-view-odf->pdf-converter-unoconv)
+   ((string-match "soffice\\'" doc-view-odf->pdf-converter-program)
+    #'doc-view-odf->pdf-converter-soffice))
+  "Function to call to convert a ODF file into a PDF file."
+  :type '(radio
+          (function-item doc-view-odf->pdf-converter-unoconv
+                         :doc "Use unoconv")
+          (function-item doc-view-odf->pdf-converter-soffice
+                         :doc "Use LibreOffice")
+          function)
+  :version "24.4")
+
 (defcustom doc-view-ps2pdf-program "ps2pdf"
   "Program to convert PS files to PDF.
 
@@ -700,8 +722,8 @@ OpenDocument format)."
 	 (and doc-view-ghostscript-program
 	      (executable-find doc-view-ghostscript-program)))
 	((eq type 'odf)
-	 (and doc-view-unoconv-program
-	      (executable-find doc-view-unoconv-program)
+	 (and doc-view-odf->pdf-converter-program
+	      (executable-find doc-view-odf->pdf-converter-program)
 	      (doc-view-mode-p 'pdf)))
 	((eq type 'djvu)
 	 (executable-find "ddjvu"))
@@ -903,14 +925,23 @@ If PAGE is nil, convert the whole docume
      ,@(if page `(,(format "%d" page))))
    callback))
 
-(defun doc-view-odf->pdf (odf callback)
+(defun doc-view-odf->pdf-converter-unoconv (odf callback)
   "Convert ODF to PDF asynchronously and call CALLBACK when finished.
 The converted PDF is put into the current cache directory, and it
 is named like ODF with the extension turned to pdf."
-  (doc-view-start-process "odf->pdf" doc-view-unoconv-program
+  (doc-view-start-process "odf->pdf" doc-view-odf->pdf-converter-program
 			  (list "-f" "pdf" "-o" (doc-view-current-cache-dir) odf)
 			  callback))
 
+(defun doc-view-odf->pdf-converter-soffice (odf callback)
+  "Convert ODF to PDF asynchronously and call CALLBACK when finished.
+The converted PDF is put into the current cache directory, and it
+is named like ODF with the extension turned to pdf."
+  (doc-view-start-process "odf->pdf" doc-view-odf->pdf-converter-program
+			  (list "--headless" "--convert-to" "pdf"
+				"--outdir" (doc-view-current-cache-dir) odf)
+			  callback))
+
 (defun doc-view-pdf/ps->png (pdf-ps png)
   ;; FIXME: Fix name and docstring to account for djvu&tiff.
   "Convert PDF-PS to PNG asynchronously."
@@ -1058,7 +1089,7 @@ Those files are saved in the directory g
 	 ;; The unoconv tool only supports an output directory, but no
 	 ;; file name.  It's named like the input file with the
 	 ;; extension replaced by pdf.
-         (doc-view-odf->pdf doc-view-buffer-file-name
+         (funcall doc-view-odf->pdf-converter-function doc-view-buffer-file-name
                             (lambda ()
 			      ;; Rename to doc.pdf
 			      (rename-file opdf pdf)

[Message part 3 (text/plain, inline)]
In GNU Emacs 24.3.50.8 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2013-02-02 on debian-6.05
Bzr revision: 111663 eliz <at> gnu.org-20130202171424-zeijhu9wq1tstzt0
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
System Description:	Debian GNU/Linux 6.0.5 (squeeze)


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13622; Package emacs. (Tue, 05 Feb 2013 08:06:01 GMT) Full text and rfc822 format available.

Message #8 received at 13622 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Jambunathan K <kjambunathan <at> gmail.com>
Cc: 13622 <at> debbugs.gnu.org
Subject: Re: bug#13622: 24.3.50;
	doc-view: Use (and prefer) soffice as default ODF->PDF converter
Date: Tue, 05 Feb 2013 03:04:13 -0500
Jambunathan K wrote:

> I am attaching a patch.  Please apply to trunk.

Some explanation as to why would be nice.

> +(defcustom doc-view-odf->pdf-converter-program
> +  (cond
> +   ((executable-find "soffice") "soffice")
> +   ((executable-find "unoconv") "unoconv"))

This could end up being nil, which would give a type mismatch with 'file.

>    :type 'file

>  
> +(defcustom doc-view-odf->pdf-converter-function
> +  (cond
> +   ((string-match "unoconv\\'" doc-view-odf->pdf-converter-program)
> +    #'doc-view-odf->pdf-converter-unoconv)
> +   ((string-match "soffice\\'" doc-view-odf->pdf-converter-program)
> +    #'doc-view-odf->pdf-converter-soffice))
> +  "Function to call to convert a ODF file into a PDF file."
> +  :type '(radio
> +          (function-item doc-view-odf->pdf-converter-unoconv
> +                         :doc "Use unoconv")
> +          (function-item doc-view-odf->pdf-converter-soffice
> +                         :doc "Use LibreOffice")
> +          function)
> +  :version "24.4")

Why do you need this, as opposed to a single function which calls
-program with a customizable -program-options argument?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13622; Package emacs. (Tue, 05 Feb 2013 10:56:01 GMT) Full text and rfc822 format available.

Message #11 received at 13622 <at> debbugs.gnu.org (full text, mbox):

From: Jambunathan K <kjambunathan <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 13622 <at> debbugs.gnu.org
Subject: Re: bug#13622: 24.3.50;
	doc-view: Use (and prefer) soffice as default ODF->PDF converter
Date: Tue, 05 Feb 2013 16:23:56 +0530
Glenn Morris <rgm <at> gnu.org> writes:

> Jambunathan K wrote:
>
>> I am attaching a patch.  Please apply to trunk.
>
> Some explanation as to why would be nice.

One is likely to have LibreOffice installed rather than unoconv.
Getting unoconv on non-Linux platforms could be cumbersome.

>
>> +(defcustom doc-view-odf->pdf-converter-program
>> +  (cond
>> +   ((executable-find "soffice") "soffice")
>> +   ((executable-find "unoconv") "unoconv"))
>
> This could end up being nil, which would give a type mismatch with 'file.
>
>>    :type 'file

What would you suggest?  Use `choice'?

>>  
>> +(defcustom doc-view-odf->pdf-converter-function
>> +  (cond
>> +   ((string-match "unoconv\\'" doc-view-odf->pdf-converter-program)
>> +    #'doc-view-odf->pdf-converter-unoconv)
>> +   ((string-match "soffice\\'" doc-view-odf->pdf-converter-program)
>> +    #'doc-view-odf->pdf-converter-soffice))
>> +  "Function to call to convert a ODF file into a PDF file."
>> +  :type '(radio
>> +          (function-item doc-view-odf->pdf-converter-unoconv
>> +                         :doc "Use unoconv")
>> +          (function-item doc-view-odf->pdf-converter-soffice
>> +                         :doc "Use LibreOffice")
>> +          function)
>> +  :version "24.4")
>
> Why do you need this, as opposed to a single function which calls
> -program with a customizable -program-options argument?

I am mimicing what is done for recent mupdf changes.

    ,----
    | (defcustom doc-view-pdf->png-converter-function
    |   (if (executable-find doc-view-pdfdraw-program)
    |       #'doc-view-pdf->png-converter-mupdf
    |     #'doc-view-pdf->png-converter-ghostscript)
    |   "Function to call to convert a PDF file into a PNG file."
    |   :type '(radio
    |           (function-item doc-view-pdf->png-converter-ghostscript
    |                          :doc "Use ghostscript")
    |           (function-item doc-view-pdf->png-converter-mupdf
    |                          :doc "Use mupdf")
    |           function)
    |   :version "24.4")
    `----




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13622; Package emacs. (Tue, 05 Feb 2013 11:53:01 GMT) Full text and rfc822 format available.

Message #14 received at 13622 <at> debbugs.gnu.org (full text, mbox):

From: Jambunathan K <kjambunathan <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 13622 <at> debbugs.gnu.org
Subject: Re: bug#13622: 24.3.50;
	doc-view: Use (and prefer) soffice as default ODF->PDF converter
Date: Tue, 05 Feb 2013 17:20:57 +0530
Glenn

I am interested in patch sailing through in whatever form that suits
maintainers.  Crux of the patch is in how soffice needs to be used.
Rest all are fillers, that a reviewer can easily workaround.

Feel free to modify the patch in a way that is acceptable to you.

Jambunathan K.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13622; Package emacs. (Sat, 09 Feb 2013 05:30:02 GMT) Full text and rfc822 format available.

Message #17 received at 13622 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: 13622 <at> debbugs.gnu.org, Jambunathan K <kjambunathan <at> gmail.com>
Subject: Re: 24.3.50;
	doc-view: Use (and prefer) soffice as default ODF->PDF converter
Date: Sat, 09 Feb 2013 13:29:31 +0800
Hi Tassilo,

Could you please review the changes suggested by Jambunathan K (and go
ahead and apply them if you agree)?  Thanks.

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13622




Reply sent to Tassilo Horn <tsdh <at> gnu.org>:
You have taken responsibility. (Sat, 09 Feb 2013 10:04:02 GMT) Full text and rfc822 format available.

Notification sent to Jambunathan K <kjambunathan <at> gmail.com>:
bug acknowledged by developer. (Sat, 09 Feb 2013 10:04:03 GMT) Full text and rfc822 format available.

Message #22 received at 13622-done <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Chong Yidong <cyd <at> gnu.org>
Cc: Jambunathan K <kjambunathan <at> gmail.com>, 13622-done <at> debbugs.gnu.org
Subject: Re: 24.3.50;
	doc-view: Use (and prefer) soffice as default ODF->PDF converter
Date: Sat, 09 Feb 2013 11:03:20 +0100
Chong Yidong <cyd <at> gnu.org> writes:

Hi Chong,

> Could you please review the changes suggested by Jambunathan K (and go
> ahead and apply them if you agree)?  Thanks.
>
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13622

Thanks for notifying.

Oh, I didn't know soffice up to now.  That's a great change as it
removes the (optional) dependency to unoconv which probably nobody has
installed anyway.

I've committed the patch with some minor modification.  Thanks,
Jambunathan!

Bye,
Tassilo




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 09 Mar 2013 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 191 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.