From ad3419180f3a452fe7264b01a130116a60425c66 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Thu, 1 Sep 2011 18:32:13 +0530 Subject: [PATCH] Refactor org-odt-format-table-cell * contrib/lisp/org-odt.el (org-odt-get-paragraph-style-cookie-for-table-cell) (org-odt-get-style-name-cookie-for-table-cell): Factored out from `org-odt-format-table-cell'. (org-odt-format-table-cell): Simplified using above functions. --- contrib/lisp/org-odt.el | 48 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index d7736ff14..f36e684fa 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -708,32 +708,30 @@ PUB-DIR is set, use this as the publishing directory." (defun org-odt-get-paragraph-style-for-table-cell (r c) (capitalize (aref org-lparse-table-colalign-vector c))) +(defun org-odt-get-paragraph-style-cookie-for-table-cell (r c) + (concat + (cond + (org-lparse-table-cur-rowgrp-is-hdr "OrgTableHeading") + ((and (= c 0) (org-lparse-get 'TABLE-FIRST-COLUMN-AS-LABELS)) + "OrgTableHeading") + (t "OrgTableContents")) + (and org-lparse-table-is-styled + (format "@@table-cell:p@@%03d@@%03d@@" r c)))) + +(defun org-odt-get-style-name-cookie-for-table-cell (r c) + (when org-lparse-table-is-styled + (format "@@table-cell:style-name@@%03d@@%03d@@" r c))) + (defun org-odt-format-table-cell (data r c) - (if (not org-lparse-table-is-styled) - (org-odt-format-tags - '("" . "") - (org-odt-format-stylized-paragraph - (cond - (org-lparse-table-cur-rowgrp-is-hdr "OrgTableHeading") - ((and (= c 0) (org-lparse-get 'TABLE-FIRST-COLUMN-AS-LABELS)) - "OrgTableHeading") - (t "OrgTableContents")) - data)) - (let* ((style-name-cookie - (format "@@table-cell:style-name@@%03d@@%03d@@" r c)) - (paragraph-style-cookie - (concat - (cond - (org-lparse-table-cur-rowgrp-is-hdr "OrgTableHeading") - ((and (= c 0) (org-lparse-get 'TABLE-FIRST-COLUMN-AS-LABELS)) - "OrgTableHeading") - (t "OrgTableContents")) - (format "@@table-cell:p@@%03d@@%03d@@" r c)))) - (org-odt-format-tags - '("" . - "") - (org-odt-format-stylized-paragraph paragraph-style-cookie data) - style-name-cookie)))) + (let* ((paragraph-style-cookie + (org-odt-get-paragraph-style-cookie-for-table-cell r c)) + (style-name-cookie + (org-odt-get-style-name-cookie-for-table-cell r c)) + (extra (if style-name-cookie + (format " table:style-name=\"%s\"" style-name-cookie) ""))) + (org-odt-format-tags + '("" . "") + (org-odt-format-stylized-paragraph paragraph-style-cookie data) extra))) (defun org-odt-begin-footnote-definition (n) (org-lparse-begin-paragraph 'footnote))