From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Kellermann Subject: [PATCH] Improve usage of odt content templates Date: Mon, 19 May 2014 12:42:54 +0200 Message-ID: <20140519104254.GX15335@pestilenz.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="DBIVS5p969aUjpLe" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmLV4-0007hN-K6 for emacs-orgmode@gnu.org; Mon, 19 May 2014 07:12:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmLUx-0001BB-PI for emacs-orgmode@gnu.org; Mon, 19 May 2014 07:12:58 -0400 Received: from pestilenz.org ([2001:780:3:170::2]:48227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmLUx-0001AE-C9 for emacs-orgmode@gnu.org; Mon, 19 May 2014 07:12:51 -0400 Received: from pestilenz.org (localhost [127.0.0.1]) by pestilenz.org (8.14.7/8.14.7) with ESMTP id s4JAgsd6022302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 19 May 2014 12:42:55 +0200 (CEST) Received: (from ckeen@localhost) by pestilenz.org (8.14.7/8.14.3/Submit) id s4JAgsUU010223 for emacs-orgmode@gnu.org; Mon, 19 May 2014 12:42:54 +0200 (CEST) Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --DBIVS5p969aUjpLe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, I have been using org-mode's odt exporter heavily for the last days with the attached patches. These scratch an itch I have and I submit them to this list in the hope of being useful to others. Rationale: I am using the odt exporter to fill in a project description document at work with has strict specified layout and template. Fortunately just using an existing empty document and org-mode's content template setting is sufficient for my needs to create the OO documents without having to touch OpenOffice. However the current master code misses two things I need: * Possibility to override the globally defined org-odt-content-template-file variable in the document * Avoid inserting the document title as the first thing in the document contents, as there already is a title set in a title page in the template. As org-mode already sets the title data tag this can be used in the template to generate the correct title. However inserting the title as text is not desireable in that scenario. I have attached patches that address these two issues. The latter adds yet another option to the exporter mode to suppress title insertion. I offer these patches as the base of a discussion as I am not sure whether these small changes fit the overall "org-mode" way. Or maybe there already is an easier way to achieve what I want, I don't know. As these are my first org-mode patches I hope I have read the guidelines for commit messages correctly. I am grateful for any comments or advise you may have. Kind regards, Christian -- May you be peaceful, may you live in safety, may you be free from suffering, and may you live with ease. --DBIVS5p969aUjpLe Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-ox-odt-Expose-content-template-file-setting.patch" >From a6a84ae372ce1d755292da7559afde1c9bfbfc7d Mon Sep 17 00:00:00 2001 From: Christian Kellermann Date: Mon, 19 May 2014 12:11:28 +0200 Subject: [PATCH 1/2] ox-odt: Expose content template file setting * ox-odt.el (odt): Add ODT_CONTENT_TEMPLATE_FILE option. org-odt-content-template-file is not changeable in the org buffer. * ox-odt.el (org-odt-template): Prefer local content template Prefer the locally set #+ODT_CONTENT_TEMPLATE_FILE over the global org-odt-content-template-file variable. TINYCHANGE --- lisp/ox-odt.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 4d2f257..1d4e796 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -97,6 +97,7 @@ (org-open-file (org-odt-export-to-odt nil s v) 'system)))))) :options-alist '((:odt-styles-file "ODT_STYLES_FILE" nil nil t) + (:odt-content-template-file "ODT_CONTENT_TEMPLATE_FILE" nil nil t) ;; Redefine regular option. (:with-latex nil "tex" org-odt-with-latex))) @@ -1450,7 +1451,8 @@ original parsed data. INFO is a plist holding export options." '("%Y-%M-%d %a" . "%Y-%M-%d %a %H:%M")))) (with-temp-buffer (insert-file-contents - (or org-odt-content-template-file + (or (plist-get info :odt-content-template-file) + org-odt-content-template-file (expand-file-name "OrgOdtContentTemplate.xml" org-odt-styles-dir))) ;; Write automatic styles. -- 1.9.2 --DBIVS5p969aUjpLe Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0002-ox-odt-Optionally-suppress-title-insertion.patch" >From e1e171a12b0ad0d29881a27688d578fba1ac4a75 Mon Sep 17 00:00:00 2001 From: Christian Kellermann Date: Mon, 19 May 2014 12:14:50 +0200 Subject: [PATCH 2/2] ox-odt: Optionally suppress title insertion * ox-odt.el (odt): Add ODT_INSERT_TITLE to option list. This allows the user to suppress the insertion of the document title in the openoffice document. * ox-odt.el (org-odt-template): optionally skip title insertion. If ODT_INSERT_TITLE is set to a false value, skip title insertion. As the odt exporter also sets the title metadata tag, this allows the user to use the title elsewhere, for example in a fancier title page. TINYCHANGE --- lisp/ox-odt.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 1d4e796..6268e51 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -97,6 +97,7 @@ (org-open-file (org-odt-export-to-odt nil s v) 'system)))))) :options-alist '((:odt-styles-file "ODT_STYLES_FILE" nil nil t) + (:odt-insert-title "ODT_INSERT_TITLE" nil nil t) (:odt-content-template-file "ODT_CONTENT_TEMPLATE_FILE" nil nil t) ;; Redefine regular option. (:with-latex nil "tex" org-odt-with-latex))) @@ -1504,7 +1505,7 @@ original parsed data. INFO is a plist holding export options." (email (and (plist-get info :with-email) email))) (concat ;; Title. - (when (org-string-nw-p title) + (when (and (plist-get info :odt-insert-title) (org-string-nw-p title)) (concat (format "\n%s" "OrgTitle" (format "\n%s" title)) -- 1.9.2 --DBIVS5p969aUjpLe--