Browse Source

ox-odt: Fix export of footnotes outside subtree during subtree export

* etc/styles/OrgOdtStyles.xml: Define "OrgFootnoteCenter" and
  "OrgFootnoteQuotations" styles.
* lisp/ox-odt.el (org-odt--format-paragraph): New function.
(org-odt-paragraph): Use new function to limit code duplication.
(org-odt-footnote-reference): Change default style for paragraphs when
transcoding a footnote definition.
Nicolas Goaziou 8 years ago
parent
commit
9c854372ff
2 changed files with 38 additions and 14 deletions
  1. 6 0
      etc/styles/OrgOdtStyles.xml
  2. 32 14
      lisp/ox-odt.el

+ 6 - 0
etc/styles/OrgOdtStyles.xml

@@ -256,6 +256,9 @@
   <style:style style:name="Quotations" style:family="paragraph" style:parent-style-name="Standard" style:class="html">
    <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="1cm" fo:margin-top="0cm" fo:margin-bottom="0.499cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
   </style:style>
+  <style:style style:name="OrgFootnoteQuotations" style:family="paragraph" style:parent-style-name="Footnote" style:class="html">
+   <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="1cm" fo:margin-top="0cm" fo:margin-bottom="0.499cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
+  </style:style>
   <style:style style:name="Preformatted_20_Text" style:display-name="Preformatted Text" style:family="paragraph" style:parent-style-name="Standard" style:class="html">
    <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
    <style:text-properties style:font-name="Courier New" fo:font-size="10pt" style:font-name-asian="NSimSun" style:font-size-asian="10pt" style:font-name-complex="Courier New" style:font-size-complex="10pt"/>
@@ -298,6 +301,9 @@
   <style:style style:name="OrgCenter" style:family="paragraph" style:parent-style-name="Text_20_body">
    <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
   </style:style>
+  <style:style style:name="OrgFootnoteCenter" style:family="paragraph" style:parent-style-name="Footnote">
+   <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+  </style:style>
   <style:style style:name="OrgTableContents" style:family="paragraph" style:parent-style-name="Text_20_body"/>
   <style:style style:name="OrgTableHeading" style:family="paragraph" style:parent-style-name="OrgTableContents" style:class="extra">
     <style:paragraph-properties fo:text-align="center" style:justify-single-word="false" text:number-lines="false" text:line-number="0"/>

+ 32 - 14
lisp/ox-odt.el

@@ -1750,9 +1750,17 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 	;; Inline definitions are secondary strings.
 	;; Non-inline footnotes definitions are full Org data.
 	(t
-	 (let* ((raw (org-export-get-footnote-definition footnote-reference
-							 info))
-		(def (let ((def (org-trim (org-export-data raw info))))
+	 (let* ((raw (org-export-get-footnote-definition
+		      footnote-reference info))
+		(translations
+		 (cons (cons 'paragraph
+			     (lambda (p c i)
+			       (org-odt--format-paragraph
+				p c "Footnote" "OrgFootnoteCenter"
+				"OrgFootnoteQuotations")))
+		       (org-export-backend-translate-table 'odt)))
+		(def (let ((def (org-trim (org-export-data-with-translations
+					   raw translations info))))
 		       (if (eq (org-element-type raw) 'org-data) def
 			 (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
 				 "Footnote" def)))))
@@ -2872,27 +2880,37 @@ INFO is a plist holding contextual information.  See
 
 ;;;; Paragraph
 
-(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."
+(defun org-odt--format-paragraph (paragraph contents 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 "Quotations")
-		  (center-block "OrgCenter")
-		  (footnote-definition "Footnote")
-		  (t (or (org-element-property :style paragraph)
-			 "Text_20_body")))))
+		  (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))))
+	       (eq paragraph (car (org-element-contents parent))))
       (setq contents (concat (org-odt--checkbox parent) contents)))
-    (assert style)
     (format "\n<text:p text:style-name=\"%s\">%s</text:p>" style 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
+   (or (org-element-property :style paragraph) "Text_20_body")
+   "OrgCenter"
+   "Quotations"))
+
 
 ;;;; Plain List