emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111707: * doc-view.el: Use (and pref


From: Tassilo Horn
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111707: * doc-view.el: Use (and prefer) soffice as default ODF->PDF
Date: Sat, 09 Feb 2013 10:58:48 +0100
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111707
committer: Tassilo Horn <address@hidden>
branch nick: trunk
timestamp: Sat 2013-02-09 10:58:48 +0100
message:
  * doc-view.el: Use (and prefer) soffice as default ODF->PDF
  converter (Bug#13622).  Patch provided by Jambunathan K
  <address@hidden>.
  (doc-view-unoconv-program): Make obsolete variable.
  (doc-view-odf->pdf-converter-program): New variable.
  (doc-view-odf->pdf-converter-function): New variable.
  (doc-view-mode-p): Use it.
  (doc-view-odf->pdf-converter-unoconv): Rename from
  `doc-view-odf->pdf-converter-unoconv'.
  (doc-view-odf->pdf-converter-soffice): New function.
  (doc-view-convert-current-doc): Use
  `doc-view-odf->pdf-converter-function'.
modified:
  lisp/ChangeLog
  lisp/doc-view.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-02-09 05:52:20 +0000
+++ b/lisp/ChangeLog    2013-02-09 09:58:48 +0000
@@ -1,3 +1,18 @@
+2013-02-09  Tassilo Horn  <address@hidden>
+
+       * doc-view.el: Use (and prefer) soffice as default ODF->PDF
+       converter (Bug#13622).  Patch provided by Jambunathan K
+       <address@hidden>.
+       (doc-view-unoconv-program): Make obsolete variable.
+       (doc-view-odf->pdf-converter-program): New variable.
+       (doc-view-odf->pdf-converter-function): New variable.
+       (doc-view-mode-p): Use it.
+       (doc-view-odf->pdf-converter-unoconv): Rename from
+       `doc-view-odf->pdf-converter-unoconv'.
+       (doc-view-odf->pdf-converter-soffice): New function.
+       (doc-view-convert-current-doc): Use
+       `doc-view-odf->pdf-converter-function'.
+
 2013-02-09  Chong Yidong  <address@hidden>
 
        * minibuffer.el (minibuffer-inactive-mode-map): Bind mouse-1 to

=== modified file 'lisp/doc-view.el'
--- a/lisp/doc-view.el  2013-01-24 03:34:20 +0000
+++ b/lisp/doc-view.el  2013-02-09 09:58:48 +0000
@@ -231,14 +231,37 @@
   :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")
+   (t "soffice"))
   "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 +723,8 @@
         (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 +926,23 @@
      ,@(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 +1090,7 @@
         ;; 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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]