]> code.delx.au - gnu-emacs/blobdiff - lisp/org/ox-odt.el
Update copyright year to 2015
[gnu-emacs] / lisp / org / ox-odt.el
index 49be3bcb01529fabeaf3b13ebe5100d310f97a76..29bc87875a1525edce367f32dd7d2bf281995d93 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ox-odt.el --- OpenDocument Text Exporter for Org Mode
 
-;; Copyright (C) 2010-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
 
 ;; Author: Jambunathan K <kjambunathan at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -1741,7 +1741,8 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
                               :transcoders
                               '((paragraph . (lambda (p c i)
                                                (org-odt--format-paragraph
-                                                p c "Footnote"
+                                                p c i
+                                                "Footnote"
                                                 "OrgFootnoteCenter"
                                                 "OrgFootnoteQuotations")))))
                              info))))
@@ -2732,7 +2733,7 @@ INFO is a plist holding contextual information.  See
      ;; link's description.
      ((string= type "radio")
       (let ((destination (org-export-resolve-radio-link link info)))
-       (when destination
+       (if (not destination) desc
          (format
           "<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
           (org-export-solidify-link-text
@@ -2832,33 +2833,44 @@ INFO is a plist holding contextual information.  See
 
 ;;;; Paragraph
 
-(defun org-odt--format-paragraph (paragraph contents default center quote)
+(defun org-odt--paragraph-style (paragraph)
+  "Return style of PARAGRAPH.
+Style is a symbol among `quoted', `centered' and nil."
+  (let ((up paragraph))
+    (while (and (setq up (org-element-property :parent up))
+               (not (memq (org-element-type up)
+                          '(center-block quote-block section)))))
+    (case (org-element-type up)
+      (center-block 'centered)
+      (quote-block 'quoted))))
+
+(defun org-odt--format-paragraph (paragraph contents info default center quote)
   "Format paragraph according to given styles.
 PARAGRAPH is a paragraph type element.  CONTENTS is the
-transcoded contents of that paragraph, as a string.  DEFAULT,
-CENTER and QUOTE are, respectively, style to use when paragraph
-belongs to no special environment, a center block, or a quote
-block."
-  (let* ((parent (org-export-get-parent paragraph))
-        (parent-type (org-element-type parent))
-        (style (case parent-type
-                 (quote-block quote)
-                 (center-block center)
-                 (t default))))
-    ;; If this paragraph is a leading paragraph in an item and the
-    ;; item has a checkbox, splice the checkbox and paragraph contents
-    ;; together.
-    (when (and (eq (org-element-type parent) 'item)
-              (eq paragraph (car (org-element-contents parent))))
-      (setq contents (concat (org-odt--checkbox parent) contents)))
-    (format "\n<text:p text:style-name=\"%s\">%s</text:p>" style contents)))
+transcoded contents of that paragraph, as a string.  INFO is
+a plist used as a communication channel.  DEFAULT, CENTER and
+QUOTE are, respectively, style to use when paragraph belongs to
+no special environment, a center block, or a quote block."
+  (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+         (case (org-odt--paragraph-style paragraph)
+           (quoted quote)
+           (centered center)
+           (otherwise default))
+         ;; If PARAGRAPH is a leading paragraph in an item that has
+         ;; a checkbox, splice checkbox and paragraph contents
+         ;; together.
+         (concat (let ((parent (org-element-property :parent paragraph)))
+                   (and (eq (org-element-type parent) 'item)
+                        (not (org-export-get-previous-element paragraph info))
+                        (org-odt--checkbox parent)))
+                 contents)))
 
 (defun org-odt-paragraph (paragraph contents info)
   "Transcode a PARAGRAPH element from Org to ODT.
 CONTENTS is the contents of the paragraph, as a string.  INFO is
 the plist used as a communication channel."
   (org-odt--format-paragraph
-   paragraph contents
+   paragraph contents info
    (or (org-element-property :style paragraph) "Text_20_body")
    "OrgCenter"
    "Quotations"))