diff options
| author | Tassilo Horn | 2013-02-09 10:58:48 +0100 |
|---|---|---|
| committer | Tassilo Horn | 2013-02-09 10:58:48 +0100 |
| commit | f63f9398b397afa6ded4d2375bf5508c9c5ba0b4 (patch) | |
| tree | d42a76138eb0516e461a374f6bc20d3c95ba12d4 | |
| parent | 6b48c831056a733d5243826547f5ec18219c49ea (diff) | |
| download | emacs-f63f9398b397afa6ded4d2375bf5508c9c5ba0b4.tar.gz emacs-f63f9398b397afa6ded4d2375bf5508c9c5ba0b4.zip | |
* doc-view.el: Use (and prefer) soffice as default ODF->PDF
converter (Bug#13622). Patch provided by Jambunathan K
<kjambunathan@gmail.com>.
(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'.
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/doc-view.el | 46 |
2 files changed, 54 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d0eba1bcb4c..f5b6daf16d8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2013-02-09 Tassilo Horn <tsdh@gnu.org> | ||
| 2 | |||
| 3 | * doc-view.el: Use (and prefer) soffice as default ODF->PDF | ||
| 4 | converter (Bug#13622). Patch provided by Jambunathan K | ||
| 5 | <kjambunathan@gmail.com>. | ||
| 6 | (doc-view-unoconv-program): Make obsolete variable. | ||
| 7 | (doc-view-odf->pdf-converter-program): New variable. | ||
| 8 | (doc-view-odf->pdf-converter-function): New variable. | ||
| 9 | (doc-view-mode-p): Use it. | ||
| 10 | (doc-view-odf->pdf-converter-unoconv): Rename from | ||
| 11 | `doc-view-odf->pdf-converter-unoconv'. | ||
| 12 | (doc-view-odf->pdf-converter-soffice): New function. | ||
| 13 | (doc-view-convert-current-doc): Use | ||
| 14 | `doc-view-odf->pdf-converter-function'. | ||
| 15 | |||
| 1 | 2013-02-09 Chong Yidong <cyd@gnu.org> | 16 | 2013-02-09 Chong Yidong <cyd@gnu.org> |
| 2 | 17 | ||
| 3 | * minibuffer.el (minibuffer-inactive-mode-map): Bind mouse-1 to | 18 | * minibuffer.el (minibuffer-inactive-mode-map): Bind mouse-1 to |
diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 30aa3a09bf2..e7d1ebc35ff 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el | |||
| @@ -231,14 +231,37 @@ If this and `doc-view-dvipdfm-program' are set, | |||
| 231 | :type 'file | 231 | :type 'file |
| 232 | :group 'doc-view) | 232 | :group 'doc-view) |
| 233 | 233 | ||
| 234 | (defcustom doc-view-unoconv-program "unoconv" | 234 | (define-obsolete-variable-alias 'doc-view-unoconv-program |
| 235 | 'doc-view-odf->pdf-converter-program | ||
| 236 | "24.4") | ||
| 237 | |||
| 238 | (defcustom doc-view-odf->pdf-converter-program | ||
| 239 | (cond | ||
| 240 | ((executable-find "soffice") "soffice") | ||
| 241 | ((executable-find "unoconv") "unoconv") | ||
| 242 | (t "soffice")) | ||
| 235 | "Program to convert any file type readable by OpenOffice.org to PDF. | 243 | "Program to convert any file type readable by OpenOffice.org to PDF. |
| 236 | 244 | ||
| 237 | Needed for viewing OpenOffice.org (and MS Office) files." | 245 | Needed for viewing OpenOffice.org (and MS Office) files." |
| 238 | :version "24.1" | 246 | :version "24.4" |
| 239 | :type 'file | 247 | :type 'file |
| 240 | :group 'doc-view) | 248 | :group 'doc-view) |
| 241 | 249 | ||
| 250 | (defcustom doc-view-odf->pdf-converter-function | ||
| 251 | (cond | ||
| 252 | ((string-match "unoconv\\'" doc-view-odf->pdf-converter-program) | ||
| 253 | #'doc-view-odf->pdf-converter-unoconv) | ||
| 254 | ((string-match "soffice\\'" doc-view-odf->pdf-converter-program) | ||
| 255 | #'doc-view-odf->pdf-converter-soffice)) | ||
| 256 | "Function to call to convert a ODF file into a PDF file." | ||
| 257 | :type '(radio | ||
| 258 | (function-item doc-view-odf->pdf-converter-unoconv | ||
| 259 | :doc "Use unoconv") | ||
| 260 | (function-item doc-view-odf->pdf-converter-soffice | ||
| 261 | :doc "Use LibreOffice") | ||
| 262 | function) | ||
| 263 | :version "24.4") | ||
| 264 | |||
| 242 | (defcustom doc-view-ps2pdf-program "ps2pdf" | 265 | (defcustom doc-view-ps2pdf-program "ps2pdf" |
| 243 | "Program to convert PS files to PDF. | 266 | "Program to convert PS files to PDF. |
| 244 | 267 | ||
| @@ -700,8 +723,8 @@ OpenDocument format)." | |||
| 700 | (and doc-view-ghostscript-program | 723 | (and doc-view-ghostscript-program |
| 701 | (executable-find doc-view-ghostscript-program))) | 724 | (executable-find doc-view-ghostscript-program))) |
| 702 | ((eq type 'odf) | 725 | ((eq type 'odf) |
| 703 | (and doc-view-unoconv-program | 726 | (and doc-view-odf->pdf-converter-program |
| 704 | (executable-find doc-view-unoconv-program) | 727 | (executable-find doc-view-odf->pdf-converter-program) |
| 705 | (doc-view-mode-p 'pdf))) | 728 | (doc-view-mode-p 'pdf))) |
| 706 | ((eq type 'djvu) | 729 | ((eq type 'djvu) |
| 707 | (executable-find "ddjvu")) | 730 | (executable-find "ddjvu")) |
| @@ -903,14 +926,23 @@ If PAGE is nil, convert the whole document." | |||
| 903 | ,@(if page `(,(format "%d" page)))) | 926 | ,@(if page `(,(format "%d" page)))) |
| 904 | callback)) | 927 | callback)) |
| 905 | 928 | ||
| 906 | (defun doc-view-odf->pdf (odf callback) | 929 | (defun doc-view-odf->pdf-converter-unoconv (odf callback) |
| 907 | "Convert ODF to PDF asynchronously and call CALLBACK when finished. | 930 | "Convert ODF to PDF asynchronously and call CALLBACK when finished. |
| 908 | The converted PDF is put into the current cache directory, and it | 931 | The converted PDF is put into the current cache directory, and it |
| 909 | is named like ODF with the extension turned to pdf." | 932 | is named like ODF with the extension turned to pdf." |
| 910 | (doc-view-start-process "odf->pdf" doc-view-unoconv-program | 933 | (doc-view-start-process "odf->pdf" doc-view-odf->pdf-converter-program |
| 911 | (list "-f" "pdf" "-o" (doc-view-current-cache-dir) odf) | 934 | (list "-f" "pdf" "-o" (doc-view-current-cache-dir) odf) |
| 912 | callback)) | 935 | callback)) |
| 913 | 936 | ||
| 937 | (defun doc-view-odf->pdf-converter-soffice (odf callback) | ||
| 938 | "Convert ODF to PDF asynchronously and call CALLBACK when finished. | ||
| 939 | The converted PDF is put into the current cache directory, and it | ||
| 940 | is named like ODF with the extension turned to pdf." | ||
| 941 | (doc-view-start-process "odf->pdf" doc-view-odf->pdf-converter-program | ||
| 942 | (list "--headless" "--convert-to" "pdf" | ||
| 943 | "--outdir" (doc-view-current-cache-dir) odf) | ||
| 944 | callback)) | ||
| 945 | |||
| 914 | (defun doc-view-pdf/ps->png (pdf-ps png) | 946 | (defun doc-view-pdf/ps->png (pdf-ps png) |
| 915 | ;; FIXME: Fix name and docstring to account for djvu&tiff. | 947 | ;; FIXME: Fix name and docstring to account for djvu&tiff. |
| 916 | "Convert PDF-PS to PNG asynchronously." | 948 | "Convert PDF-PS to PNG asynchronously." |
| @@ -1058,7 +1090,7 @@ Those files are saved in the directory given by the function | |||
| 1058 | ;; The unoconv tool only supports an output directory, but no | 1090 | ;; The unoconv tool only supports an output directory, but no |
| 1059 | ;; file name. It's named like the input file with the | 1091 | ;; file name. It's named like the input file with the |
| 1060 | ;; extension replaced by pdf. | 1092 | ;; extension replaced by pdf. |
| 1061 | (doc-view-odf->pdf doc-view-buffer-file-name | 1093 | (funcall doc-view-odf->pdf-converter-function doc-view-buffer-file-name |
| 1062 | (lambda () | 1094 | (lambda () |
| 1063 | ;; Rename to doc.pdf | 1095 | ;; Rename to doc.pdf |
| 1064 | (rename-file opdf pdf) | 1096 | (rename-file opdf pdf) |