diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2011-10-16 10:55:28 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2011-10-16 10:55:28 +0200 |
commit | 872aec78d608b2398ca7e717582d8447e9f79d18 (patch) | |
tree | 9da03e517eef69b34d8642ea7515f035b1cd7709 | |
parent | 2e93c951e5fc948b06e4c59f469e657a132a7883 (diff) | |
download | org-mode-872aec78d608b2398ca7e717582d8447e9f79d18.tar.gz |
Put table style and col sizes under direct user control
* contrib/lisp/org-lparse.el
(org-lparse-table-get-colalign-info): Renamed
`org-forced-aligns' to `org-col-cookies'. Renamed local
variable `forced-aligns' to `col-cookies'.
(org-lparse-format-table-row): With the introduction of
`org-col-cookies' property the internal structure of
`org-lparse-table-colalign-info' has changed. Do the right
thing while setting up col alignment. Pass on the colwidth
property as horiz-span arg of `TABLE-CELL' callback.
* contrib/lisp/org-odt.el (org-odt-begin-table): Let the table
style be settable throught #+ATTR_ODT line. By default tables
are configured to occupy 90% of paper width. This is too big
for smaller tables. For aesthetic reasons, a user might
prefer that such tables of shorter width and thus specify a
different style.
(org-odt-end-table, org-odt-format-table-cell): Honor colwidth
specification.
* contrib/lisp/org-xhtml.el (org-xhtml-format-table-cell): Fix
signature as mandated by changes in TABLE-CELL callback.
See comments in the earlier patch. See also
http://lists.gnu.org/archive/html/emacs-orgmode/2011-08/msg01053.html
-rwxr-xr-x | contrib/lisp/org-lparse.el | 36 | ||||
-rw-r--r-- | contrib/lisp/org-odt.el | 47 | ||||
-rw-r--r-- | contrib/lisp/org-xhtml.el | 2 |
3 files changed, 52 insertions, 33 deletions
diff --git a/contrib/lisp/org-lparse.el b/contrib/lisp/org-lparse.el index fbc9024..ac98ff5 100755 --- a/contrib/lisp/org-lparse.el +++ b/contrib/lisp/org-lparse.el @@ -1316,13 +1316,12 @@ version." (org-lparse-format-table-table lines)))) (defun org-lparse-table-get-colalign-info (lines) - (let ((forced-aligns (org-find-text-property-in-string - 'org-forced-aligns (car lines)))) - (when (and forced-aligns org-table-clean-did-remove-column) - (setq forced-aligns - (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) forced-aligns))) - - forced-aligns)) + (let ((col-cookies (org-find-text-property-in-string + 'org-col-cookies (car lines)))) + (when (and col-cookies org-table-clean-did-remove-column) + (setq col-cookies + (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) col-cookies))) + col-cookies)) (defvar org-lparse-table-style) (defvar org-lparse-table-ncols) @@ -2059,12 +2058,13 @@ See `org-xhtml-entity-format-callbacks-alist' for more information." (make-vector org-lparse-table-ncols nil)) (let ((c -1)) (while (< (incf c) org-lparse-table-ncols) - (let ((cookie (cdr (assoc (1+ c) org-lparse-table-colalign-info)))) + (let* ((col-cookie (cdr (assoc (1+ c) org-lparse-table-colalign-info))) + (align (nth 0 col-cookie))) (setf (aref org-lparse-table-colalign-vector c) (cond - ((string= cookie "l") "left") - ((string= cookie "r") "right") - ((string= cookie "c") "center") + ((string= align "l") "left") + ((string= align "r") "right") + ((string= align "c") "center") (t nil)))))))) (incf org-lparse-table-rownum) (let ((i -1)) @@ -2075,11 +2075,15 @@ See `org-xhtml-entity-format-callbacks-alist' for more information." (when (and (string= x "") text-for-empty-fields) (setq x text-for-empty-fields)) (incf i) - (and org-lparse-table-is-styled - (< i org-lparse-table-ncols) - (string-match org-table-number-regexp x) - (incf (aref org-lparse-table-num-numeric-items-per-column i))) - (org-lparse-format 'TABLE-CELL x org-lparse-table-rownum i)) + (let (col-cookie horiz-span) + (when org-lparse-table-is-styled + (when (and (< i org-lparse-table-ncols) + (string-match org-table-number-regexp x)) + (incf (aref org-lparse-table-num-numeric-items-per-column i))) + (setq col-cookie (cdr (assoc (1+ i) org-lparse-table-colalign-info)) + horiz-span (nth 1 col-cookie))) + (org-lparse-format + 'TABLE-CELL x org-lparse-table-rownum i (or horiz-span 0)))) fields "\n")))) (defun org-lparse-get (what &optional opt-plist) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index 5c3f7fb..f088b05 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -703,14 +703,20 @@ implementation filed under `org-odt-get-table-cell-styles'." (or label "") (or (nth 1 org-odt-table-style-spec) "OrgTable")) (setq org-lparse-table-begin-marker (point))) +(defvar org-lparse-table-colalign-info) (defun org-odt-end-table () (goto-char org-lparse-table-begin-marker) (loop for level from 0 below org-lparse-table-ncols - do (insert - (org-odt-format-tags - "<table:table-column table:style-name=\"%sColumn\"/>" - "" (or (nth 1 org-odt-table-style-spec) "OrgTable")))) - + do (let* ((col-cookie (and org-lparse-table-is-styled + (cdr (assoc (1+ level) + org-lparse-table-colalign-info)))) + (extra-columns (or (nth 1 col-cookie) 0))) + (dotimes (i (1+ extra-columns)) + (insert + (org-odt-format-tags + "<table:table-column table:style-name=\"%sColumn\"/>" + "" (or (nth 1 org-odt-table-style-spec) "OrgTable")))) + (insert "\n"))) ;; fill style attributes for table cells (when org-lparse-table-is-styled (while (re-search-forward "@@\\(table-cell:p\\|table-cell:style-name\\)@@\\([0-9]+\\)@@\\([0-9]+\\)@@" nil t) @@ -837,17 +843,26 @@ styles congruent with the ODF-1.2 specification." (when org-lparse-table-is-styled (format "@@table-cell:style-name@@%03d@@%03d@@" r c))) -(defun org-odt-format-table-cell (data r c) - (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 - '("<table:table-cell%s>" . "</table:table-cell>") - (if org-lparse-list-table-p data - (org-odt-format-stylized-paragraph paragraph-style-cookie data)) extra))) +(defun org-odt-format-table-cell (data r c horiz-span) + (concat + (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 (and style-name-cookie + (format " table:style-name=\"%s\"" style-name-cookie))) + (extra (concat extra + (and (> horiz-span 0) + (format " table:number-columns-spanned=\"%d\"" + (1+ horiz-span)))))) + (org-odt-format-tags + '("<table:table-cell%s>" . "</table:table-cell>") + (if org-lparse-list-table-p data + (org-odt-format-stylized-paragraph paragraph-style-cookie data)) extra)) + (let (s) + (dotimes (i horiz-span) + (setq s (concat s "\n<table:covered-table-cell/>"))) s) + "\n")) (defun org-odt-begin-footnote-definition (n) (org-lparse-begin-paragraph 'footnote)) diff --git a/contrib/lisp/org-xhtml.el b/contrib/lisp/org-xhtml.el index f4f9181..188678c 100644 --- a/contrib/lisp/org-xhtml.el +++ b/contrib/lisp/org-xhtml.el @@ -1558,7 +1558,7 @@ lang=\"%s\" xml:lang=\"%s\"> (cons (eval (car org-export-table-row-tags)) (eval (cdr org-export-table-row-tags))) row)) -(defun org-xhtml-format-table-cell (text r c) +(defun org-xhtml-format-table-cell (text r c horiz-span) (let ((cell-style-cookie (or (and org-lparse-table-is-styled (format "@@class%03d@@" c)) ""))) (cond |