Explorar el Código

org-e-odt: Handle caption/label for src blocks.

Add Listing-related entries to OrgOdtContentTemplate.xml,
OrgOdtStyles.xml.
Jambunathan K hace 13 años
padre
commit
bb291df296
Se han modificado 3 ficheros con 23 adiciones y 3 borrados
  1. 17 3
      EXPERIMENTAL/org-e-odt.el
  2. 1 0
      etc/styles/OrgOdtContentTemplate.xml
  3. 5 0
      etc/styles/OrgOdtStyles.xml

+ 17 - 3
EXPERIMENTAL/org-e-odt.el

@@ -1149,7 +1149,7 @@ ATTR is a string of other attributes of the a element."
 	 ;; grok language setting
 	 (en-strings (assoc-default "en" org-e-odt-category-strings))
 	 (lang (plist-get info :language)) ; FIXME
-	 (lang-strings (assoc-default lang org-export-odt-category-strings))
+	 (lang-strings (assoc-default lang org-e-odt-category-strings))
 	 ;; retrieve localized category sting
 	 (pos (- (length org-e-odt-category-map-alist)
 		 (length (memq label-props org-e-odt-category-map-alist))))
@@ -1799,6 +1799,7 @@ standard Emacs.")
 		  (src . "OrgSrcBlock")
 		  (illustration . "Illustration")
 		  (table . "Table")
+		  (listing . "Listing")
 		  (definition-term . "Text_20_body_20_bold")
 		  (horizontal-line . "Horizontal_20_Line")))
     (character . ((bold . "Bold")
@@ -1974,7 +1975,7 @@ specifiers - %e and %n.  %e is replaced with the CATEGORY-NAME.
 `org-e-odt-format-label-reference'.")
 
 (defcustom org-e-odt-category-strings
-  '(("en" "Table" "Figure" "Equation" "Equation"))
+  '(("en" "Table" "Figure" "Equation" "Equation" "Listing"))
   "Specify category strings for various captionable entities.
 Captionable entity can be one of a Table, an Embedded Image, a
 LaTeX fragment (generated with dvipng) or a Math Formula.
@@ -2001,6 +2002,9 @@ below.
 			       (const :tag "Use Default" nil)
 			       (string :tag "Category string"))
 		       (choice :tag "Dvipng Image"
+			       (const :tag "Use Default" nil)
+			       (string :tag "Category string"))
+		       (choice :tag "Listing"
 			       (const :tag "Use Default" nil)
 			       (string :tag "Category string")))))
 
@@ -2009,6 +2013,7 @@ below.
     ("__Figure__" "Illustration" "value")
     ("__MathFormula__" "Text" "math-formula")
     ("__DvipngImage__" "Equation" "value")
+    ("__Listing__" "Listing" "value")
     ;; ("__Table__" "Table" "category-and-value")
     ;; ("__Figure__" "Figure" "category-and-value")
     ;; ("__DvipngImage__" "Equation" "category-and-value")
@@ -3866,6 +3871,8 @@ INFO is a plist holding contextual information.  See
 					; FIXME: Check if it is
 					; acutally latex eqn.
 		       "__MathFormula__")
+		      ((eq (org-element-type destination) 'src-block)
+		       "__Listing__")
 		      (t (error "Handle enumeration of %S" destination)))))
 	       (org-e-odt-format-label-reference label default-category number)))))))
      ;; Coderef: replace link with the reference name or the
@@ -4065,13 +4072,20 @@ CONTENTS holds the contents of the item.  INFO is a plist holding
 contextual information."
   (let* ((lang (org-element-property :language src-block))
 	 (caption (org-element-property :caption src-block))
+	 (short-caption (and (cdr caption) (org-export-secondary-string
+					    (cdr caption) 'e-odt info)))
+	 (caption (and (car caption) (org-export-secondary-string
+				      (car caption) 'e-odt info)))
 	 (label (org-element-property :name src-block)))
     ;; FIXME: Handle caption
     ;; caption-str (when caption)
     ;; (main (org-export-secondary-string (car caption) 'e-odt info))
     ;; (secondary (org-export-secondary-string (cdr caption) 'e-odt info))
     ;; (caption-str (org-e-odt--caption/label-string caption label info))
-    (org-e-odt-format-code src-block info)))
+    (concat
+     (org-e-odt-format-stylized-paragraph
+      'listing (org-e-odt-format-entity-caption label caption "__Listing__"))
+     (org-e-odt-format-code src-block info))))
 
 
 ;;;; Statistics Cookie

+ 1 - 0
etc/styles/OrgOdtContentTemplate.xml

@@ -256,6 +256,7 @@
 	<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
 	<text:sequence-decl text:display-outline-level="0" text:name="Equation"/>
 	<text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
+	<text:sequence-decl text:display-outline-level="0" text:name="Listing"/>
       </text:sequence-decls>
     </office:text>
   </office:body>

+ 5 - 0
etc/styles/OrgOdtStyles.xml

@@ -319,6 +319,11 @@
   <style:style style:name="Table" style:family="paragraph" style:parent-style-name="Caption" style:class="extra">
    <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
   </style:style>
+  <style:style style:name="Listing" style:family="paragraph" style:parent-style-name="Caption" style:class="extra">
+   <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" fo:keep-with-next="always">
+    <style:tab-stops/>
+   </style:paragraph-properties>
+  </style:style>
   <style:style style:name="Horizontal_20_Line" style:display-name="Horizontal Line" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="html">
    <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.499cm" style:border-line-width-bottom="0.002cm 0.035cm 0.002cm" fo:padding="0cm" fo:border-left="none" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.039cm double #808080" text:number-lines="false" text:line-number="0" style:join-border="false"/>
    <style:text-properties fo:font-size="6pt" style:font-size-asian="6pt" style:font-size-complex="6pt"/>