Le 07/07/2013 20:14, Dag Wieers a écrit :
Question : Can we set ODF document properties from asciidoc source using
asciidoc-odf ? Some of my documents use them in page footers. In practice, exact footer text (and document subtitle) definitely needs to be different in different documents: it includes a kind of document ID currently fetched
using an ODF document property.

There are two ways to do this.

 - You make use of an ODF stylesheet when producing an .fodt file
 - You make use of an ODF template to produce a real .odt file

The first one works best if you prefer to tinker with the file by hand, the second one works best if you like to tinker with the look&feel using LibreOffice. The first method gives the most possibilities (as the LibreOffice interface does not give 100% control of what ODF can do).

I use the first method, the second method, while it should work has not been tested as much and probably could use some more work to get it finished.

The other benefit of the first method is that it generates an .fodt (Flat ODT file) that you can inspect using a text-editor. Once modified with LibreOffice to your liking, you can copy over the important changes back into the ODT stylesheet for future document output. So once your stylesheet is as you want it to look, you can reuse the stylesheet for all future (and older) AsciiDoc files.

Thanks for your explanation, which if I understand covers the backend part, not the front. Let me take an example.


     Expected workflow

The expected way would be to add in asciidoc source

= My invoice title
:lang: en
:Ref_devis: abc123
:invoiceid: def456

And have asciidoc-odf generate something like :

  <meta:user-defined meta:name="*Ref_devis">abc123*</meta:user-defined>

(...)

     <style:master-page style:name="Standard" style:page-layout-name="Mpm1">
<style:footer> <text:p text:style-name="MP1"> réf. devis n° <text:user-defined style:data-style-name="N0" text:name="*Ref_devis">ABC123*</text:user-defined> Page <text:page-number text:select-page="current"/>/<text:page-count>1</text:page-count> </text:p> <text:p text:style-name="MP1">...Legal stuff...</text:p> </style:footer> </style:master-page>


     The "document properties" approach, from existing

I got the code from git (will report some glitches separately) and ran asciidoc -b odt README.asciidoc .

The generated file contains :

 <meta:user-defined meta:name="author">Dag Wieers</meta:user-defined>
 <meta:user-defined meta:name="email">[email protected]</meta:user-defined>
which seem to come from
:author: Dag Wieers
:email: [email protected]
but if I add another attribute, e.g. :quoteid: abc123, it won't get included in fodt output.

curriculum-vitae-dag-wieers.txt contains :
:linux-experience: {sys:echo $(( $(date +%Y) - 1995))}
I wish curriculum-vitae-dag-wieers.fodt would contain :

 <meta:user-defined meta:name="linux-experience">18</meta:user-defined>

But it didn't.

Looking at source code I see in odt.conf :

 <meta:user-defined meta:name="author">{author}</meta:user-defined>
 <meta:user-defined meta:name="email">{email}</meta:user-defined>
 <meta:user-defined meta:name="version">{version}</meta:user-defined>

So, it looks like in current code author, email and version can be user-defined document properties. Including the others would need to make a loop turning more asciidoc-level properties into ODF-level meta:user-defined.


     The asciidoc string substitution approach

Another solution might work : drop user-defined document properties altogether and just use asciidoc-based string substitution. Just put in asciidoc some header like :

and try method 1 or 2 that you described, like putting a footer section with {invoiceid}.

But I'm fearing that :

 * it may work ok with method 1 (not tested)
 * it would only work once with method 2, because after the document is
   edited and saved in LibreOffice, the substituted value becomes the
   constant def456, losing the reference to invoiceid.

What do you think ?

--
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/asciidoc.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to