浏览代码

Merge origin/maint

Jambunathan K 12 年之前
父节点
当前提交
f4148cf525
共有 2 个文件被更改,包括 34 次插入25 次删除
  1. 6 3
      lisp/org-compat.el
  2. 28 22
      lisp/org-odt.el

+ 6 - 3
lisp/org-compat.el

@@ -438,10 +438,13 @@ With two arguments, return floor and remainder of their quotient."
     (funcall 'switch-to-buffer buffer-or-name norecord)))
     (funcall 'switch-to-buffer buffer-or-name norecord)))
 
 
 ;; `condition-case-unless-debug' has been introduced in Emacs 24.1
 ;; `condition-case-unless-debug' has been introduced in Emacs 24.1
+;; `condition-case-no-debug' has been introduced in Emacs 23.1
 (defalias 'org-condition-case-unless-debug
 (defalias 'org-condition-case-unless-debug
-  (if (fboundp 'condition-case-unless-debug)
-      'condition-case-unless-debug
-    'condition-case-no-debug))
+  (or (and (fboundp 'condition-case-unless-debug)
+	   'condition-case-unless-debug)
+      (and (fboundp 'condition-case-no-debug)
+	   'condition-case-no-debug)
+      'condition-case))
 
 
 (defmacro org-check-version ()
 (defmacro org-check-version ()
   "Try very hard to provide sensible version strings."
   "Try very hard to provide sensible version strings."

+ 28 - 22
lisp/org-odt.el

@@ -2031,31 +2031,37 @@ ATTR is a string of other attributes of the a element."
   "Limiting dimensions for an embedded image.")
   "Limiting dimensions for an embedded image.")
 
 
 (defun org-odt-do-image-size (probe-method file &optional dpi anchor-type)
 (defun org-odt-do-image-size (probe-method file &optional dpi anchor-type)
-  (setq dpi (or dpi org-export-odt-pixels-per-inch))
-  (setq anchor-type (or anchor-type "paragraph"))
-  (flet ((size-in-cms (size-in-pixels)
-		      (flet ((pixels-to-cms (pixels)
-					    (let* ((cms-per-inch 2.54)
-						   (inches (/ pixels dpi)))
-					      (* cms-per-inch inches))))
-			(and size-in-pixels
-			     (cons (pixels-to-cms (car size-in-pixels))
-				   (pixels-to-cms (cdr size-in-pixels)))))))
+  (let* ((dpi (or dpi org-export-odt-pixels-per-inch))
+	 (anchor-type (or anchor-type "paragraph"))
+	 (--pixels-to-cms
+	  (function
+	   (lambda (pixels dpi)
+	     (let* ((cms-per-inch 2.54)
+		    (inches (/ pixels dpi)))
+	       (* cms-per-inch inches)))))
+	 (--size-in-cms
+	  (function
+	   (lambda (size-in-pixels dpi)
+	     (and size-in-pixels
+		  (cons (funcall --pixels-to-cms (car size-in-pixels) dpi)
+			(funcall --pixels-to-cms (cdr size-in-pixels) dpi)))))))
     (case probe-method
     (case probe-method
       (emacs
       (emacs
-       (size-in-cms (ignore-errors	; Emacs could be in batch mode
-		      (clear-image-cache)
-		      (image-size (create-image file) 'pixels))))
+       (let ((size-in-pixels
+	      (ignore-errors		; Emacs could be in batch mode
+		(clear-image-cache)
+		(image-size (create-image file) 'pixels))))
+	 (funcall --size-in-cms size-in-pixels dpi)))
       (imagemagick
       (imagemagick
-       (size-in-cms
-	(let ((dim (shell-command-to-string
-		    (format "identify -format \"%%w:%%h\" \"%s\"" file))))
-	  (when (string-match "\\([0-9]+\\):\\([0-9]+\\)" dim)
-	    (cons (string-to-number (match-string 1 dim))
-		  (string-to-number (match-string 2 dim)))))))
-      (t
-       (cdr (assoc-string anchor-type
-			  org-export-odt-default-image-sizes-alist))))))
+       (let ((size-in-pixels
+	      (let ((dim (shell-command-to-string
+			  (format "identify -format \"%%w:%%h\" \"%s\"" file))))
+		(when (string-match "\\([0-9]+\\):\\([0-9]+\\)" dim)
+		  (cons (string-to-number (match-string 1 dim))
+			(string-to-number (match-string 2 dim)))))))
+	 (funcall --size-in-cms size-in-pixels dpi)))
+      (t (cdr (assoc-string anchor-type
+			    org-export-odt-default-image-sizes-alist))))))
 
 
 (defun org-odt-image-size-from-file (file &optional user-width
 (defun org-odt-image-size-from-file (file &optional user-width
 					  user-height scale dpi embed-as)
 					  user-height scale dpi embed-as)