Ver Fonte

Pull up ODT files from "maint" to "master" levels

2012-01-17   Jambunathan K   <kjambunathan@gmail.com>

* etc/styles/OrgOdtContentTemplate.xml
(OrgIndentedSection-Level-*): New section styles. These
sections are indented to the same level as the corresponding
list entries.  These sections hold tables that occur within a
list.
(OrgTable): Increased relative width from 90% to 96% for
aesthetic reasons.

* lisp/org-odt.el (org-odt-table-indentedp): New variable
(org-odt-begin-table): Modified.  If the table is within a
list, temporarily leave the list and begin an indented section
before emitting the table.
(org-odt-end-table): Modified.  If the table was within a
list, close the indented section and re-open the list
immediately after ending the table.
(org-odt-continue-list, org-odt-discontinue-list): Helper
routines to temporarily discontinue and continue a list.
(org-odt-list-stack-stashed): New variable to hold the state
of a pending list.
(org-odt-begin-list, org-odt-begin-list-item)
(org-odt-end-list-item): Modified. Handle nitty-gritties for
continuing a list and list item.
(org-odt-section-count): New variable that keeps track of
section count.  Used in conjunction with naming of sections.
(org-odt-begin-section, org-odt-end-section): New defuns.
(org-odt-init-outfile): Initialize
`org-odt-list-stack-stashed' and `org-odt-section-count'.

* lisp/org-lparse.el (org-lparse-list-item-count): Removed. Was a
superfluous variable.
(org-lparse-list-level): Removed.  Now derived from
`org-lparse-list-stack'.
(org-lparse-list-stack): New.  List that records the list
types - ordered, unordered or descriptive - in the following
order: self, parent, grand-parent etc.
(org-do-lparse): Added, removed above let-bound vars.
Disallowed regular tables within list-table block.
(org-lparse-begin-list, org-lparse-end-list)
(org-lparse-begin-list-item, org-lparse-end-list-item):
Propagate above changes.

OpenDocument doesn't permit tables to occur in the middle of a
list.  Use list continuations and indented sections to typeset
indented tables.

Fixes the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00515.html

Add support for indented tables in ODT export

2012-01-20   Jambunathan K   <kjambunathan@gmail.com>

* lisp/org-odt.el (org-odt-format-textbox): Honor user-specified
width in captioned images.

Fix for bug reported here:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00641.html

Honor user-specified width in captioned images

2012-01-23   Jambunathan K   <kjambunathan@gmail.com>

* lisp/org-odt.el (org-odt-table-style-format): New.  Template for
auto-generated table styles.
(org-odt-automatic-styles, org-odt-object-counters): New
variables.
(org-odt-add-automatic-style): New function.
(org-odt-write-automatic-styles): New function.  Create
automatic styles for tables that have custom :rel-width.
(org-odt-begin-table): Parse attributes specified with
"#+ATTR_ODT: " option and use it to create an automatic table
style.
(org-odt-save-as-outfile): Call
`org-odt-add-write-automatic-styles'.
(org-odt-init-outfile): Init newly add variables.
(org-odt-section-count): Remove it.
(org-odt-begin-section): Use `org-odt-add-automatic-style' to
generate an automatic section name.

Customize table width using :rel-width option.  For example,
to create a table of width 60% use:

    #+attr_odt: :rel-width 60
    | A | B |
    |---+---|
    |   |   |

org-odt.el: Put table width under user-control

2012-01-23   Jambunathan K   <kjambunathan@gmail.com>

* lisp/org-odt.el (org-odt-label-styles): Add a new style.
(org-odt-category-map-alist):  Use it.

Andreas Leha writes:

The following snippet exports correctly to LaTeX and to html, but
produces the text "Figure Figure" in odt.

Could the behaviour be synchronized?

=== example.org ==========================
* Test ref
  plot(1:10, 1:10)

Here is a reference to Figure \ref{fig:bar}
=== example.org ==========================

org-odt.el: Make label references consistent with LaTeX export

2012-01-24   Jambunathan K   <kjambunathan@gmail.com>

* lisp/org-odt.el (org-odt-entity-frame-styles): Add frame params
for images that are anchored as character.
(org-export-odt-format-image): Handle new anchor type
"as-char".
(org-export-odt-default-image-sizes-alist): Misc. change.
(org-export-odt-format-formula): Misc. change.

With this change, one can use the below snippet to produce
images that are laid out side-by-side.
    #+ATTR_ODT: :width 7 :height 7 :anchor as-char
    #+header: :file foo.png
    [[./foo.png]]
    #+caption: bar
    #+ATTR_ODT: :width 7 :height 7 :anchor as-char
    #+header: :file bar.png
    [[./bar.png]]

See http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00677.html.

org-odt.el: Allow images to be anchored as characters

2012-01-24   Jambunathan K   <kjambunathan@gmail.com>

* lisp/org-odt.el (org-export-odt-format-formula): Use :style
property to specify custom table styles.

Continuation of the earlier commit titled: "Put table width
under user-control".

org-odt.el: Fix regression in typesetting of MathML formulae

2012-01-27   Jambunathan K   <kjambunathan@gmail.com>

* lisp/org-odt.el (org-odt-format-preamble): Don't insert TOC here.
Delay it till the end of export.
(org-odt-begin-document-body): Make a note of the default
position of TOC in `org-lparse-dyn-first-heading-pos'.
(org-odt-insert-toc): Insert TOC as directed by
[TABLE-OF-CONTENTS] line or at the default position.
(org-odt-end-export): Call `org-odt-insert-toc'.

Fix for the following bug:
http://lists.gnu.org/archive/html/emacs-orgmode/2012-01/msg00974.html

org-odt.el: Honor "[TABLE-OF-CONTENTS]" directive

2012-01-27   Jambunathan K   <kjambunathan@gmail.com>

org-odt.el: Fix earlier commit

2012-01-30   Jambunathan K   <kjambunathan@gmail.com>

* OrgOdtStyles.xml (OrgTitlePage): New page style.  Include no
footer.  Use "OrgFrontMatterPage" for the following page.
(OrgFrontMatterPage): New page style.  Include a footer that
displays page numbers in Roman style.  Use mirrored pages.
Use "OrgFrontMatterPage" for the following page.
(OrgPage): New page style.  Include a footer that displays
page numbers.  Use mirrored pages.  Use "OrgPage" for the
following page.
(OrgFirstPage): New page style.  Include a footer that
displays page numbers.  Right page only.  Use "OrgPage" for
the following page.
(Standard): Modify to include a footer that displays page
numbers.  Use mirrored pages.  Use "Standard" for the
following page.

None of the above page styles have a header.

The newly added page styles are not used as yet.

org-odt.el: By default, include page numbers in the page footer

2012-01-31   Jambunathan K   <kjambunathan@gmail.com>

org-odt.el: Do `clear-image-cache' before `create-image'

2012-02-03   Jambunathan K   <kjambunathan@gmail.com>

* lisp/org-lparse.el (org-lparse-do-convert): Replace
`call-process' with `shell-command-to-string'.

* lisp/org-odt.el (org-export-odt-convert-processes): Add a new
converter which depends solely on LibreOffice and nothing
else.
(org-export-odt-convert-process): Make the above native
converter the default.

Thanks to Giles for introducing the "--convert-to" option of
soffice.exe.  The option seems to be a fairly recent
development.

http://imperfectsoftware.blogspot.in/2012/01/one-of-my-less-enjoyable-tasks-is-to.html

With this change, one can export to pdf via odt by a simple
  (setq org-export-odt-preferred-output-format "pdf")
There is no need to install additional converters.

org-odt.el: Make LibreOffice the default converter

2012-02-09   Jambunathan K   <kjambunathan@gmail.com>

* org-odt.el (org-export-odt-convert-capabilities): Change the
default value.

See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00293.html.

Offer "docx" as an option in `org-export-odt-preferred-output-format'

2012-02-12   Jambunathan K   <kjambunathan@gmail.com>

org-odt.el: Fix indentation

2012-02-12   Jambunathan K   <kjambunathan@gmail.com>

org-odt.el: Tag all custom variables with Emacs version

2012-02-12   Jambunathan K   <kjambunathan@gmail.com>

* lisp/org-odt.el (org-export-odt-convert-processes): Re-define
(org-export-odt-convert-capabilities): Fix an accidental
regression.

* lisp/org-lparse.el (org-lparse-do-convert): Related change.

Simplify definition of `org-export-odt-convert-processes'

2012-02-12   Jambunathan K   <kjambunathan@gmail.com>

Retire support for BasicODConverter

2012-02-14   Jambunathan K   <kjambunathan@gmail.com>

* org-odt.el (org-export-as-odt-to-buffer)
(org-replace-region-by-odt, org-export-region-as-odt): Remove
these interactive functions.  They are of questionable value.

org-odt.el: Remove interactive functions of questionable value

2012-02-15   Jambunathan K   <kjambunathan@gmail.com>

Improve converting from ODT to other formats

2012-02-15   Jambunathan K   <kjambunathan@gmail.com>

* org-odt.el (org-export-odt-image-size-probe-method)
(org-odt-do-image-size): Use imagemagick preferentially to
determine image sizes.

See http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00288.html

org-odt.el: Use imagemagick to determine image sizes

2012-02-16   Jambunathan K   <kjambunathan@gmail.com>

* org.texi (Top, OpenDocument Text export)
(ODT export commands, Extending ODT export)
(Images in ODT export, Tables in ODT export)
(Configuring a document converter): Add or Update.

org.texi: Update ODT section
Jambunathan K há 13 anos atrás
pai
commit
92da128bf9
6 ficheiros alterados com 431 adições e 256 exclusões
  1. 120 77
      doc/org.texi
  2. 1 0
      etc/styles/OrgOdtContentTemplate.xml
  3. 64 3
      etc/styles/OrgOdtStyles.xml
  4. 9 9
      etc/styles/README
  5. 16 20
      lisp/org-lparse.el
  6. 221 147
      lisp/org-odt.el

+ 120 - 77
doc/org.texi

@@ -614,6 +614,7 @@ OpenDocument Text export
 
 * Pre-requisites for @acronym{ODT} export::  What packages @acronym{ODT} exporter relies on
 * @acronym{ODT} export commands::  How to invoke @acronym{ODT} export
+* Extending @acronym{ODT} export:: How to produce @samp{doc}, @samp{pdf} files
 * Applying custom styles::      How to apply custom styles to the output
 * Links in @acronym{ODT} export::  How links will be interpreted and formatted
 * Tables in @acronym{ODT} export::  How Tables are exported
@@ -629,7 +630,7 @@ Math formatting in @acronym{ODT} export
 
 Advanced topics in @acronym{ODT} export
 
-* Exporting and converting to other formats::  How to produce @samp{pdf} and other formats
+* Configuring a document converter::  How to register a document converter
 * Working with OpenDocument style files::  Explore the internals
 * Creating one-off styles::     How to produce custom highlighting etc
 * Customizing tables in @acronym{ODT} export::  How to define and use Table templates
@@ -10801,6 +10802,7 @@ are compatible with LibreOffice 3.4.
 @menu
 * Pre-requisites for @acronym{ODT} export::  What packages @acronym{ODT} exporter relies on
 * @acronym{ODT} export commands::  How to invoke @acronym{ODT} export
+* Extending @acronym{ODT} export:: How to produce @samp{doc}, @samp{pdf} files
 * Applying custom styles::      How to apply custom styles to the output
 * Links in @acronym{ODT} export::  How links will be interpreted and formatted
 * Tables in @acronym{ODT} export::  How Tables are exported
@@ -10816,7 +10818,7 @@ are compatible with LibreOffice 3.4.
 The @acronym{ODT} exporter relies on the @file{zip} program to create the final
 output.  Check the availability of this program before proceeding further.
 
-@node @acronym{ODT} export commands, Applying custom styles, Pre-requisites for @acronym{ODT} export, OpenDocument Text export
+@node @acronym{ODT} export commands, Extending @acronym{ODT} export, Pre-requisites for @acronym{ODT} export, OpenDocument Text export
 @subsection @acronym{ODT} export commands
 
 @subsubheading Exporting to @acronym{ODT}
@@ -10830,10 +10832,11 @@ output.  Check the availability of this program before proceeding further.
 @cindex property EXPORT_FILE_NAME
 
 Export as OpenDocument Text file.
+
 @vindex org-export-odt-preferred-output-format
 If @code{org-export-odt-preferred-output-format} is specified, automatically
-convert the exported file to that format.
-@xref{x-export-to-other-formats,,Automatically exporting to other formats}.
+convert the exported file to that format.  @xref{x-export-to-other-formats, ,
+Automatically exporting to other formats}.
 
 For an Org file @file{myfile.org}, the @acronym{ODT} file will be
 @file{myfile.odt}.  The file will be overwritten without warning.  If there
@@ -10846,25 +10849,61 @@ export.
 
 @orgcmd{C-c C-e O,org-export-as-odt-and-open}
 Export as OpenDocument Text file and open the resulting file.
+
 @vindex org-export-odt-preferred-output-format
 If @code{org-export-odt-preferred-output-format} is specified, open the
-converted file instead.
-@xref{x-export-to-other-formats,,Automatically exporting to other formats}.
+converted file instead.  @xref{x-export-to-other-formats, , Automatically
+exporting to other formats}.
 @end table
 
-@subsubheading Automatically exporting to other formats
+@node Extending @acronym{ODT} export, Applying custom styles, @acronym{ODT} export commands, OpenDocument Text export
+@subsection Extending @acronym{ODT} export
+
+The @acronym{ODT} exporter can interface with a variety of document
+converters and supports popular converters out of the box.  As a result, you
+can use it to export to formats like @samp{doc} or convert a document from
+one format (say @samp{csv}) to another format (say @samp{ods} or @samp{xls}).
+
+@cindex @file{unoconv}
+@cindex LibreOffice
+If you have a working installation of LibreOffice, a document converter is
+pre-configured for you and you can use it right away.  If you would like to
+use @file{unoconv} as your preferred converter, customize the variable
+@code{org-export-odt-convert-process} to point to @code{unoconv}.  If you
+would like to use a converter of your own choosing or tweak the default
+settings of the default @file{LibreOffice} and @samp{unoconv} converters
+@xref{Configuring a document converter}.
+
+@subsubsection Automatically exporting to other formats
 @anchor{x-export-to-other-formats}
+
 @vindex org-export-odt-preferred-output-format
 Very often, you will find yourself exporting to @acronym{ODT} format, only to
-immediately save the exported document to a different format like @samp{pdf}.
-In such cases, you will find it convenient to configure a converter
-(@pxref{Exporting and converting to other formats}) and specify your
+immediately save the exported document to other formats like @samp{doc},
+@samp{docx}, @samp{rtf}, @samp{pdf} etc.  In such cases, you can specify your
 preferred output format by customizing the variable
 @code{org-export-odt-preferred-output-format}.  This way, the export commands
-(@pxref{x-export-to-odt,,Exporting to ODT}) can be extended to also export to
-the preferred format.
+(@pxref{x-export-to-odt,,Exporting to ODT}) can be extended to export to a
+format that is of immediate interest to you.
+
+@subsubsection Converting between document formats
+@anchor{x-convert-to-other-formats}
+
+There are many document converters in the wild which support conversion to
+and from various file formats, including, but not limited to the
+@acronym{ODT} format.  LibreOffice converter, mentioned above, is one such
+converter.  Once a converter is configured, you can interact with it using
+the following command.
+
+@vindex org-export-odt-convert
+@table @kbd
 
-@node Applying custom styles, Links in @acronym{ODT} export, @acronym{ODT} export commands, OpenDocument Text export
+@item M-x org-export-odt-convert
+Convert an existing document from one format to another.  With a prefix
+argument, also open the newly produced file.
+@end table
+
+@node Applying custom styles, Links in @acronym{ODT} export, Extending @acronym{ODT} export, OpenDocument Text export
 @subsection Applying custom styles
 @cindex styles, custom
 @cindex template, custom
@@ -10941,16 +10980,42 @@ tables is supported.  However, export of complex @file{table.el} tables -
 tables that have column or row spans - is not supported.  Such tables are
 stripped from the exported document.
 
-By default, a table is exported with top and bottom frames and with
-rules separating row and column groups (@pxref{Column groups}).  If the table
-specifies alignment and relative width for its columns (@pxref{Column width
-and alignment}) then these are honored on export.@footnote{The column widths
-are interpreted as weighted ratios with the default weight being 1}
+By default, a table is exported with top and bottom frames and with rules
+separating row and column groups (@pxref{Column groups}).  Furthermore, all
+tables are typeset to occupy the same width.  If the table specifies
+alignment and relative width for its columns (@pxref{Column width and
+alignment}) then these are honored on export.@footnote{The column widths are
+interpreted as weighted ratios with the default weight being 1}
 
 @cindex #+ATTR_ODT
-If you are not satisfied with the default formatting of tables, you can
-create custom table styles and associate them with a table using
-the @code{#+ATTR_ODT} line.  @xref{Customizing tables in @acronym{ODT} export}.
+You can control the width of the table by specifying @code{:rel-width}
+property using an @code{#+ATTR_ODT} line.
+
+For example, consider the following table which makes use of all the rules
+mentoned above.
+
+@example
+#+ATTR_ODT: :rel-width 50
+| Area/Month    |   Jan |   Feb |   Mar |   Sum |
+|---------------+-------+-------+-------+-------|
+| /             |     < |       |       |     < |
+| <l13>         |  <r5> |  <r5> |  <r5> |  <r6> |
+| North America |     1 |    21 |   926 |   948 |
+| Middle East   |     6 |    75 |   844 |   925 |
+| Asia Pacific  |     9 |    27 |   790 |   826 |
+|---------------+-------+-------+-------+-------|
+| Sum           |    16 |   123 |  2560 |  2699 |
+@end example
+
+On export, the table will occupy 50% of text area.  The columns will be sized
+(roughly) in the ratio of 13:5:5:5:6.  The first column will be left-aligned
+and rest of the columns will be right-aligned.  There will be vertical rules
+after separating the header and last columns from other columns.  There will
+be horizontal rules separating the header and last rows from other rows.
+
+If you are not satisfied with the above formatting options, you can create
+custom table styles and associate them with a table using the
+@code{#+ATTR_ODT} line.  @xref{Customizing tables in @acronym{ODT} export}.
 
 @node Images in @acronym{ODT} export, Math formatting in @acronym{ODT} export, Tables in @acronym{ODT} export, OpenDocument Text export
 @subsection Images in @acronym{ODT} export
@@ -10982,14 +11047,21 @@ link to an image file.  For example, to embed a image
 
 @subsubheading Sizing and scaling of embedded images
 
+@cindex #+ATTR_ODT
 You can control the size and scale of the embedded images using the
 @code{#+ATTR_ODT} attribute.
 
+@cindex identify, ImageMagick
 @vindex org-export-odt-pixels-per-inch
-Note that the exporter specifies the desired size of the image in the final
-document in units of centimeters.  In order to scale the embedded images, the
-exporter needs to compute the size of the image.  This is done by retrieving
-the image size in pixels and converting the pixel units to centimeters using
+The exporter specifies the desired size of the image in the final document in
+units of centimeters.  In order to scale the embedded images, the exporter
+queries for pixel dimensions of the images using one of a) ImageMagick's
+@file{identify} program or b) Emacs `create-image' and `image-size'
+APIs.@footnote{Use of @file{ImageMagick} is only desirable.  However, if you
+routinely produce documents that have large images or you export your Org
+files that has images using a Emacs batch script, then the use of
+@file{ImageMagick} is mandatory.} The pixel dimensions are subsequently
+converted in to units of centimeters using
 @code{org-export-odt-pixels-per-inch}.  The default value of this variable is
 set to @code{display-pixels-per-inch}.  You can tweak this variable to
 achieve the best results.
@@ -10997,7 +11069,6 @@ achieve the best results.
 The examples below illustrate the various possibilities.
 
 @table @asis
-
 @item Explicitly size the image
 To embed @file{img.png} as a 10 cm x 10 cm image, do the following:
 
@@ -11033,6 +11104,20 @@ height:width ratio, do the following
 @end example
 @end table
 
+@subsubheading Anchoring of images
+
+@cindex #+ATTR_ODT
+You can control the manner in which an image is anchored by setting the
+@code{:anchor} property of it's @code{#+ATTR_ODT} line.  You can specify one
+of the the following three values for the @code{:anchor} property -
+@samp{"as-char"}, @samp{"paragraph"} and @samp{"page"}.
+
+To create an image that is anchored to a page, do the following:
+@example
+#+ATTR_ODT: :anchor "page"
+[[./img.png]]
+@end example
+
 @node Math formatting in @acronym{ODT} export, Literal examples in @acronym{ODT} export, Images in @acronym{ODT} export, OpenDocument Text export
 @subsection Math formatting in @acronym{ODT} export
 
@@ -11164,65 +11249,23 @@ set of features that the exporter offers.  This section describes features
 that would be of interest to power users.
 
 @menu
-* Exporting and converting to other formats::  How to produce @samp{pdf} and other formats
+* Configuring a document converter::  How to register a document converter
 * Working with OpenDocument style files::  Explore the internals
 * Creating one-off styles::     How to produce custom highlighting etc
 * Customizing tables in @acronym{ODT} export::  How to define and use Table templates
 * Validating OpenDocument XML::  How to debug corrupt OpenDocument files
 @end menu
 
-@node Exporting and converting to other formats, Working with OpenDocument style files, Advanced topics in @acronym{ODT} export, Advanced topics in @acronym{ODT} export
-@subsubsection Exporting and converting to other formats
+@node Configuring a document converter, Working with OpenDocument style files, Advanced topics in @acronym{ODT} export, Advanced topics in @acronym{ODT} export
+@subsubsection Configuring a document converter
 @cindex convert
-@cindex doc, docx
-
-The @acronym{ODT} exporter adds support for exporting Org outlines to formats
-that are not supported natively by Org.  It also adds support to convert
-document from one format to another.  To use these features, you need to
-configure a command-line converter.  Once a command-line converter is
-configured you can use it to extend the list of formats to which Org can
-export.  @xref{x-export-to-other-formats,,Automatically exporting to other
-formats}.  You can also use it to perform one-off document conversion as
-detailed below.
-
-@vindex org-export-odt-convert
-@table @kbd
-
-@item M-x org-export-odt-convert
-Convert an existing document from one format to another as determined by the
-variable @code{org-export-odt-convert-capabilities}
-(@pxref{x-odt-converter-capabilities,,Configure converter
-capabilities}).  @strong{Please note} that you can use this command to even
-convert documents that are produced outside of Org and in other formats than
-@acronym{ODT} format.
-@end table
-
-@subsubheading Pre-configured converters
-
+@cindex doc, docx, rtf
 @cindex converter
-The @acronym{ODT} exporter supports two converters out of the box:
-
-@enumerate
-
-@cindex @file{unoconv}
-@item @file{unoconv}
-
-This converter is available as an installable package in your favorite
-distribution.
-
-@cindex @file{BasicODConverter}
-@item @file{BasicODConverter}
-
-@vindex org-odt-data-dir
-This converter is distributed as a LibreOffice extension and can be found in
-your Org distribution.  See the subdirectory pointed to by the variable
-@code{org-odt-data-dir}.
-
-@end enumerate
 
-@subsubheading Installing a new converter
-If you prefer to use a converter other than the two mentioned above, then you
-may have to do additional configuration.  You can proceed as follows:
+The @acronym{ODT} exporter can work with popular converters with little or no
+extra configuration from your side. @xref{Extending @acronym{ODT} export}.
+If you are using a converter that is not supported by default or if you would
+like to tweak the default converter settings, proceed as below.
 
 @enumerate
 @item Register the converter
@@ -11251,7 +11294,7 @@ Select the newly added converter as the preferred one by customizing the
 variable @code{org-export-odt-convert-process}.
 @end enumerate
 
-@node Working with OpenDocument style files, Creating one-off styles, Exporting and converting to other formats, Advanced topics in @acronym{ODT} export
+@node Working with OpenDocument style files, Creating one-off styles, Configuring a document converter, Advanced topics in @acronym{ODT} export
 @subsubsection Working with OpenDocument style files
 @cindex styles, custom
 @cindex template, custom

+ 1 - 0
etc/styles/OrgOdtContentTemplate.xml

@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- See etc/org/README for copyright information -->
 <office:document-content
     xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
     xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"

+ 64 - 3
etc/styles/OrgOdtStyles.xml

@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- See etc/org/README for copyright information -->
 <office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" office:version="1.2">
  <office:font-face-decls>
   <style:font-face style:name="OpenSymbol" svg:font-family="OpenSymbol"/>
@@ -717,15 +718,75 @@
   <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>
  </office:styles>
  <office:automatic-styles>
-  <style:page-layout style:name="Mpm1">
+  <style:style style:name="MP1" style:family="paragraph" style:parent-style-name="Footer">
+   <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>
+  </style:style>
+  <style:page-layout style:name="Mpm1" style:page-usage="mirrored">
    <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
-    <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+    <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="none" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+   </style:page-layout-properties>
+   <style:header-style/>
+   <style:footer-style>
+    <style:header-footer-properties fo:min-height="0.6cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.499cm" style:dynamic-spacing="false"/>
+   </style:footer-style>
+  </style:page-layout>
+  <style:page-layout style:name="Mpm2">
+   <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
+    <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
    </style:page-layout-properties>
    <style:header-style/>
    <style:footer-style/>
   </style:page-layout>
+  <style:page-layout style:name="Mpm3" style:page-usage="mirrored">
+   <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="i" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
+    <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+   </style:page-layout-properties>
+   <style:header-style/>
+   <style:footer-style>
+    <style:header-footer-properties fo:min-height="0cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.499cm"/>
+   </style:footer-style>
+  </style:page-layout>
+  <style:page-layout style:name="Mpm4" style:page-usage="right">
+   <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" fo:background-color="transparent" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
+    <style:background-image/>
+    <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+   </style:page-layout-properties>
+   <style:header-style/>
+   <style:footer-style>
+    <style:header-footer-properties fo:min-height="0.6cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.499cm" style:dynamic-spacing="false"/>
+   </style:footer-style>
+  </style:page-layout>
+  <style:page-layout style:name="Mpm5" style:page-usage="mirrored">
+   <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
+    <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+   </style:page-layout-properties>
+   <style:header-style/>
+   <style:footer-style>
+    <style:header-footer-properties fo:min-height="0.6cm" fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0.499cm" style:dynamic-spacing="false"/>
+   </style:footer-style>
+  </style:page-layout>
  </office:automatic-styles>
  <office:master-styles>
-  <style:master-page style:name="Standard" style:page-layout-name="Mpm1"/>
+  <style:master-page style:name="Standard" style:page-layout-name="Mpm1">
+   <style:footer>
+    <text:p text:style-name="MP1"><text:page-number text:select-page="current"></text:page-number></text:p>
+   </style:footer>
+  </style:master-page>
+  <style:master-page style:name="OrgTitlePage" style:page-layout-name="Mpm2" style:next-style-name="OrgFrontMatterPage"/>
+  <style:master-page style:name="OrgFrontMatterPage" style:page-layout-name="Mpm3">
+   <style:footer>
+    <text:p text:style-name="MP1"><text:page-number text:select-page="current"/></text:p>
+   </style:footer>
+  </style:master-page>
+  <style:master-page style:name="OrgFirstPage" style:page-layout-name="Mpm4" style:next-style-name="OrgPage">
+   <style:footer>
+    <text:p text:style-name="MP1"><text:page-number text:select-page="current"/></text:p>
+   </style:footer>
+  </style:master-page>
+  <style:master-page style:name="OrgPage" style:page-layout-name="Mpm5">
+   <style:footer>
+    <text:p text:style-name="MP1"><text:page-number text:select-page="current"/></text:p>
+   </style:footer>
+  </style:master-page>
  </office:master-styles>
 </office:document-styles>

+ 9 - 9
etc/styles/COPYRIGHT-AND-LICENSE → etc/styles/README

@@ -1,14 +1,9 @@
-OrgOdtContentTemplate.xml --- Aux XML file (Org-mode's OpenDocument export)
-OrgOdtStyles.xml	  --- Aux XML file (Org-mode's OpenDocument export)
+The files OrgOdtContentTemplate.xml and OrgOdtStyles.xml have the
+following copyright information:
 
 Copyright (C) 2010-2011 Free Software Foundation, Inc.
 
-Author: Jambunathan K <kjambunathan at gmail dot com>
-Keywords: outlines, hypermedia, calendar, wp
-Homepage: http://orgmode.org
-
-These file are not (yet) part of GNU Emacs.
-However, it is distributed under the same license.
+These files are part of GNU Emacs.
 
 GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -23,9 +18,14 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
+
+Author: Jambunathan K <kjambunathan at gmail dot com>
+Keywords: outlines, hypermedia, calendar, wp
+Homepage: http://orgmode.org
+
 Commentary:
 
-Above files are part of Org-mode's OpenDocument export module.
+These files are part of Org-mode's OpenDocument export module.
 
 OrgOdtContentTemplate.xml provides a template within which the content
 of an exported document is enclosed.  This file contributes to

+ 16 - 20
lisp/org-lparse.el

@@ -484,37 +484,33 @@ This is a helper routine for interactive use."
 		  (error "Cannot convert from %s format to %s format?"
 			 in-fmt out-fmt)))
 	 (convert-process (car how))
-	 (program (car convert-process))
-	 (dummy (and (or program (error "Converter not configured"))
-		     (or (executable-find program)
-			 (error "Cannot find converter %s" program))))
 	 (out-file (concat (file-name-sans-extension in-file) "."
 			   (nth 1 (or (cdr how) out-fmt))))
+	 (extra-options (or (nth 2 (cdr how)) ""))
 	 (out-dir (file-name-directory in-file))
-	 (arglist (mapcar (lambda (arg)
-			    (format-spec
-			     arg `((?i . ,in-file)
-				   (?I . ,(browse-url-file-url in-file))
-				   (?f . ,out-fmt)
-				   (?o . ,out-file)
-				   (?O . ,(browse-url-file-url out-file))
-				   (?d . ,out-dir)
-				   (?D . ,(browse-url-file-url out-dir)))))
-			  (cdr convert-process))))
+	 (cmd (format-spec convert-process
+			   `((?i . ,(shell-quote-argument in-file))
+			     (?I . ,(browse-url-file-url in-file))
+			     (?f . ,out-fmt)
+			     (?o . ,out-file)
+			     (?O . ,(browse-url-file-url out-file))
+			     (?d . , (shell-quote-argument out-dir))
+			     (?D . ,(browse-url-file-url out-dir))
+			     (?x . ,extra-options)))))
     (when (file-exists-p out-file)
       (delete-file out-file))
 
-    (message "Executing %s %s" program (mapconcat 'identity arglist " "))
-    (apply 'call-process program nil nil nil arglist)
+    (message "Executing %s" cmd)
+    (let ((cmd-output (shell-command-to-string cmd)))
+      (message "%s" cmd-output))
+
     (cond
      ((file-exists-p out-file)
-      (message "Exported to %s using %s" out-file program)
+      (message "Exported to %s" out-file)
       (when prefix-arg
 	(message "Opening %s..."  out-file)
 	(org-open-file out-file))
-      out-file
-      ;; (set-buffer (find-file-noselect out-file))
-      )
+      out-file)
      (t
       (message "Export to %s failed" out-file)
       nil))))

+ 221 - 147
lisp/org-odt.el

@@ -1,4 +1,4 @@
-;;; org-odt.el --- OpenDocumentText export for Org-mode
+;;; org-odt.el --- OpenDocument Text exporter for Org-mode
 
 ;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
 
@@ -31,7 +31,20 @@
 (defgroup org-export-odt nil
   "Options specific for ODT export of Org-mode files."
   :tag "Org Export ODT"
-  :group 'org-export)
+  :group 'org-export
+  :version "24.1")
+
+(defvar org-lparse-dyn-first-heading-pos) ; let bound during org-do-lparse
+(defun org-odt-insert-toc ()
+  (goto-char (point-min))
+  (cond
+   ((re-search-forward
+     "\\(<text:p [^>]*>\\)?\\s-*\\[TABLE-OF-CONTENTS\\]\\s-*\\(</text:p>\\)?"
+     nil t)
+    (replace-match ""))
+   (t
+    (goto-char org-lparse-dyn-first-heading-pos)))
+  (insert (org-odt-format-toc)))
 
 (defun org-odt-insert-toc ()
   (goto-char (point-min))
@@ -152,6 +165,7 @@ with GNU ELPA tar or standard Emacs distribution."
 	  (const :tag "Not set" nil)
 	  (directory :tag "Schema directory"))
   :group 'org-export-odt
+  :version "24.1"
   :set
   (lambda (var value)
     "Set `org-export-odt-schema-dir'.
@@ -271,7 +285,8 @@ The exporter embeds the exported content just before
 If unspecified, the file named \"OrgOdtContentTemplate.xml\"
 under `org-odt-styles-dir' is used."
   :type 'file
-  :group 'org-export-odt)
+  :group 'org-export-odt
+  :version "24.1")
 
 (defcustom org-export-odt-styles-file nil
   "Default styles file for use with ODT export.
@@ -305,6 +320,7 @@ a per-file basis.  For example,
 #+ODT_STYLES_FILE: \"/path/to/styles.xml\" or
 #+ODT_STYLES_FILE: (\"/path/to/file.ott\" (\"styles.xml\" \"image/hdr.png\"))."
   :group 'org-export-odt
+  :version "24.1"
   :type
   '(choice
     (const :tag "Factory settings" nil)
@@ -326,20 +342,21 @@ a per-file basis.  For example,
 (defvar org-export-odt-embed-images t
   "Should the images be copied in to the odt file or just linked?")
 
-(defvar org-export-odt-inline-images 'maybe) ; counterpart of
-					     ; `org-export-html-inline-images'
-
+(defvar org-export-odt-inline-images 'maybe)
 (defcustom org-export-odt-inline-image-extensions
   '("png" "jpeg" "jpg" "gif")
   "Extensions of image files that can be inlined into HTML."
   :type '(repeat (string :tag "Extension"))
-  :group 'org-export-odt)
+  :group 'org-export-odt
+  :version "24.1")
 
 (defcustom org-export-odt-pixels-per-inch display-pixels-per-inch
-  ;; FIXME add docstring
-  ""
+  "Scaling factor for converting images pixels to inches.
+Use this for sizing of embedded images.  See Info node `(org)
+Images in ODT export' for more information."
   :type 'float
-  :group 'org-export-odt)
+  :group 'org-export-odt
+  :version "24.1")
 
 (defcustom org-export-odt-create-custom-styles-for-srcblocks t
   "Whether custom styles for colorized source blocks be automatically created.
@@ -357,6 +374,7 @@ styles.xml already contains needed styles for colorizing to work.
 This variable is effective only if
 `org-export-odt-fontify-srcblocks' is turned on."
   :group 'org-export-odt
+  :version "24.1"
   :type 'boolean)
 
 (defvar org-export-odt-default-org-styles-alist
@@ -409,6 +427,7 @@ resulting document to this format.  During customization of this
 variable, the list of valid values are populated based on
 `org-export-odt-convert-capabilities'."
   :group 'org-export-odt
+  :version "24.1"
   :type '(choice :convert-widget
 		 (lambda (w)
 		   (apply 'widget-convert (widget-type w)
@@ -438,40 +457,6 @@ emacs   --batch
         --visit=MyFile --funcall org-export-as-odt-batch"
   (org-lparse-batch "odt"))
 
-;;;###autoload
-(defun org-export-as-odt-to-buffer (arg)
-  "Call `org-lparse-odt` with output to a temporary buffer.
-No file is created.  The prefix ARG is passed through to `org-lparse-to-buffer'."
-  (interactive "P")
-  (org-lparse-to-buffer "odt" arg))
-
-;;;###autoload
-(defun org-replace-region-by-odt (beg end)
-  "Assume the current region has org-mode syntax, and convert it to ODT.
-This can be used in any buffer.  For example, you could write an
-itemized list in org-mode syntax in an ODT buffer and then use this
-command to convert it."
-  (interactive "r")
-  (org-replace-region-by "odt" beg end))
-
-;;;###autoload
-(defun org-export-region-as-odt (beg end &optional body-only buffer)
-  "Convert region from BEG to END in org-mode buffer to ODT.
-If prefix arg BODY-ONLY is set, omit file header, footer, and table of
-contents, and only produce the region of converted text, useful for
-cut-and-paste operations.
-If BUFFER is a buffer or a string, use/create that buffer as a target
-of the converted ODT.  If BUFFER is the symbol `string', return the
-produced ODT as a string and leave not buffer behind.  For example,
-a Lisp program could call this function in the following way:
-
-  (setq odt (org-export-region-as-odt beg end t 'string))
-
-When called interactively, the output buffer is selected, and shown
-in a window.  A non-interactive call will only return the buffer."
-  (interactive "r\nP")
-  (org-lparse-region "odt" beg end body-only buffer))
-
 ;;; org-export-as-odt
 ;;;###autoload
 (defun org-export-as-odt (arg &optional hidden ext-plist
@@ -658,11 +643,11 @@ PUB-DIR is set, use this as the publishing directory."
 (defun org-odt-end-outline-text ()
   (ignore))
 
-(defvar org-odt-section-count 0)
 (defun org-odt-begin-section (style &optional name)
-  (setq name (or name (format "Section-%d" (incf org-odt-section-count))))
-  (org-lparse-insert-tag
-   "<text:section text:style-name=\"%s\" text:name=\"%s\">" style name))
+  (let ((default-name (car (org-odt-add-automatic-style "Section"))))
+    (org-lparse-insert-tag
+     "<text:section text:style-name=\"%s\" text:name=\"%s\">"
+     style (or name default-name))))
 
 (defun org-odt-end-section ()
   (org-lparse-insert-tag "</text:section>"))
@@ -928,6 +913,7 @@ The TABLE-STYLE-NAME \"OrgEquation\" is used internally for
 formatting of numbered display equations.  Do not delete this
 style from the list."
   :group 'org-export-odt
+  :version "24.1"
   :type '(choice
           (const :tag "None" nil)
           (repeat :tag "Table Styles"
@@ -943,6 +929,75 @@ style from the list."
 			       :key-type symbol
 			       :value-type (const :tag "True" t))))))
 
+(defvar org-odt-table-style-format
+  "
+<style:style style:name=\"%s\" style:family=\"table\">
+  <style:table-properties style:rel-width=\"%d%%\" fo:margin-top=\"0cm\" fo:margin-bottom=\"0.20cm\" table:align=\"center\"/>
+</style:style>
+"
+  "Template for auto-generated Table styles.")
+
+(defvar org-odt-automatic-styles '()
+  "Registry of automatic styles for various OBJECT-TYPEs.
+The variable has the following form:
+\(\(OBJECT-TYPE-A
+  \(\(OBJECT-NAME-A.1 OBJECT-PROPS-A.1\)
+   \(OBJECT-NAME-A.2 OBJECT-PROPS-A.2\) ...\)\)
+ \(OBJECT-TYPE-B
+  \(\(OBJECT-NAME-B.1 OBJECT-PROPS-B.1\)
+   \(OBJECT-NAME-B.2 OBJECT-PROPS-B.2\) ...\)\)
+ ...\).
+
+OBJECT-TYPEs could be \"Section\", \"Table\", \"Figure\" etc.
+OBJECT-PROPS is (typically) a plist created by passing
+\"#+ATTR_ODT: \" option to `org-lparse-get-block-params'.
+
+Use `org-odt-add-automatic-style' to add update this variable.'")
+
+(defvar org-odt-object-counters nil
+  "Running counters for various OBJECT-TYPEs.
+Use this to generate automatic names and style-names. See
+`org-odt-add-automatic-style'.")
+
+(defun org-odt-write-automatic-styles ()
+  "Write automatic styles to \"content.xml\"."
+  (with-current-buffer
+      (find-file-noselect (expand-file-name "content.xml") t)
+    ;; position the cursor
+    (goto-char (point-min))
+    (re-search-forward "  </office:automatic-styles>" nil t)
+    (goto-char (match-beginning 0))
+    ;; write automatic table styles
+    (loop for (style-name props) in
+	  (plist-get org-odt-automatic-styles 'Table) do
+	  (when (setq props (or (plist-get props :rel-width) 96))
+	    (insert (format org-odt-table-style-format style-name props))))))
+
+(defun org-odt-add-automatic-style (object-type &optional object-props)
+  "Create an automatic style of type OBJECT-TYPE with param OBJECT-PROPS.
+OBJECT-PROPS is (typically) a plist created by passing
+\"#+ATTR_ODT: \" option of the object in question to
+`org-lparse-get-block-params'.
+
+Use `org-odt-object-counters' to generate an automatic
+OBJECT-NAME and STYLE-NAME.  If OBJECT-PROPS is non-nil, add a
+new entry in `org-odt-automatic-styles'.  Return (OBJECT-NAME
+. STYLE-NAME)."
+  (assert (stringp object-type))
+  (let* ((object (intern object-type))
+	 (seqvar object)
+	 (seqno (1+ (or (plist-get org-odt-object-counters seqvar) 0)))
+	 (object-name (format "%s%d" object-type seqno)) style-name)
+    (setq org-odt-object-counters
+	  (plist-put org-odt-object-counters seqvar seqno))
+    (when object-props
+      (setq style-name (format "Org%s" object-name))
+      (setq org-odt-automatic-styles
+	    (plist-put org-odt-automatic-styles object
+		       (append (list (list style-name object-props))
+			       (plist-get org-odt-automatic-styles object)))))
+    (cons object-name style-name)))
+
 (defvar org-odt-table-indentedp nil)
 (defun org-odt-begin-table (caption label attributes)
   (setq org-odt-table-indentedp (not (null org-lparse-list-stack)))
@@ -955,17 +1010,18 @@ style from the list."
     ;; Put the Table in an indented section.
     (let ((level (length org-odt-list-stack-stashed)))
       (org-odt-begin-section (format "OrgIndentedSection-Level-%d" level))))
-
-  (setq org-odt-table-style attributes)
+  (setq attributes (org-lparse-get-block-params attributes))
+  (setq org-odt-table-style (plist-get attributes :style))
   (setq org-odt-table-style-spec
 	(assoc org-odt-table-style org-export-odt-table-styles))
-  (when label
-    (insert
-     (org-odt-format-stylized-paragraph
-      'table (org-odt-format-entity-caption label caption "__Table__"))))
-  (org-lparse-insert-tag
-   "<table:table table:name=\"%s\" table:style-name=\"%s\">"
-   (or label "") (or (nth 1 org-odt-table-style-spec) "OrgTable"))
+  (insert
+   (org-odt-format-stylized-paragraph
+    'table (org-odt-format-entity-caption label caption "__Table__")))
+  (let ((name-and-style (org-odt-add-automatic-style "Table" attributes)))
+    (org-lparse-insert-tag
+     "<table:table table:name=\"%s\" table:style-name=\"%s\">"
+     (car name-and-style) (or (nth 1 org-odt-table-style-spec)
+			      (cdr name-and-style) "OrgTable")))
   (setq org-lparse-table-begin-marker (point)))
 
 (defvar org-lparse-table-colalign-info)
@@ -1007,8 +1063,8 @@ style from the list."
   (when org-lparse-table-rowgrp-open
     (org-lparse-end 'TABLE-ROWGROUP))
   (org-lparse-insert-tag (if is-header-row
-			   "<table:table-header-rows>"
-			 "<table:table-rows>"))
+			     "<table:table-header-rows>"
+			   "<table:table-rows>"))
   (setq org-lparse-table-rowgrp-open t)
   (setq org-lparse-table-cur-rowgrp-is-hdr is-header-row))
 
@@ -1178,9 +1234,9 @@ styles congruent with the ODF-1.2 specification."
 		       (concat snumber ". "))
 		  headline
 		  (and tags
-		    (concat
-		     (org-lparse-format 'SPACES 3)
-		     (org-lparse-format 'FONTIFY tags "tag")))))
+		       (concat
+			(org-lparse-format 'SPACES 3)
+			(org-lparse-format 'FONTIFY tags "tag")))))
   (when todo
     (setq headline (org-lparse-format 'FONTIFY headline "todo")))
 
@@ -1265,7 +1321,8 @@ Turn this option on if you want to colorize the source code
 blocks in the exported file.  For colorization to work, you need
 to make available an enhanced version of `htmlfontify' library."
   :type 'boolean
-  :group 'org-export-odt)
+  :group 'org-export-odt
+  :version "24.1")
 
 (defun org-odt-format-source-line-with-line-number-and-label
   (line rpllbl num fontifier par-style)
@@ -1476,15 +1533,13 @@ value of `org-export-odt-fontify-srcblocks."
 	       (org-odt-copy-image-file thefile) thelink))))
     (org-export-odt-format-image thefile href)))
 
-(defun org-export-odt-format-formula (src href &optional embed-as)
-  "Create image tag with source and attributes."
+(defun org-export-odt-format-formula (src href)
   (save-match-data
     (let* ((caption (org-find-text-property-in-string 'org-caption src))
 	   (caption (and caption (org-xml-format-desc caption)))
 	   (label (org-find-text-property-in-string 'org-label src))
 	   (latex-frag (org-find-text-property-in-string 'org-latex-src src))
-	   (embed-as (or embed-as
-			 (and latex-frag
+	   (embed-as (or (and latex-frag
 			      (org-find-text-property-in-string
 			       'org-latex-src-embed-type src))
 			 (if (or caption label) 'paragraph 'character)))
@@ -1503,7 +1558,7 @@ value of `org-export-odt-fontify-srcblocks."
 	      href width height :caption caption :label nil)
 	    ,(if (not label) ""
 	       (org-odt-format-entity-caption label nil "__MathFormula__"))))
-	 nil nil nil "OrgEquation" nil '((1 "c" 8) (2 "c" 1)))
+	 nil nil nil ":style \"OrgEquation\"" nil '((1 "c" 8) (2 "c" 1)))
 	(throw 'nextline nil))))))
 
 (defvar org-odt-embedded-formulas-count 0)
@@ -1518,19 +1573,19 @@ value of `org-export-odt-fontify-srcblocks."
       (message "Embedding %s as %s ..."
 	       (substring-no-properties path) target-file)
 
-	(make-directory target-dir)
-	(org-odt-create-manifest-file-entry
-	 "application/vnd.oasis.opendocument.formula" target-dir "1.2")
-
-	(case (org-odt-is-formula-link-p src-file)
-	  (mathml
-	   (copy-file src-file target-file 'overwrite))
-	  (odf
-	   (org-odt-zip-extract-one src-file "content.xml" target-dir))
-	  (t
-	   (error "%s is not a formula file" src-file)))
-
-	(org-odt-create-manifest-file-entry "text/xml" target-file))
+      (make-directory target-dir)
+      (org-odt-create-manifest-file-entry
+       "application/vnd.oasis.opendocument.formula" target-dir "1.2")
+
+      (case (org-odt-is-formula-link-p src-file)
+	(mathml
+	 (copy-file src-file target-file 'overwrite))
+	(odf
+	 (org-odt-zip-extract-one src-file "content.xml" target-dir))
+	(t
+	 (error "%s is not a formula file" src-file)))
+
+      (org-odt-create-manifest-file-entry "text/xml" target-file))
     target-file))
 
 (defun org-odt-format-inline-formula (thefile)
@@ -1635,7 +1690,7 @@ ATTR is a string of other attributes of the a element."
        "</text:h>") text level level)))
 
 (defun org-odt-format-headline (title extra-targets tags
-					    &optional snumber level)
+				      &optional snumber level)
   (concat
    (org-lparse-format 'EXTRA-TARGETS extra-targets)
 
@@ -1715,9 +1770,7 @@ ATTR is a string of other attributes of the a element."
 	   (attr-plist (org-lparse-get-block-params attr))
 	   (user-frame-anchor
 	    (car (assoc-string (plist-get attr-plist :anchor)
-			       (if (or caption label)
-				   '(("paragraph") ("page"))
-				 '(("character") ("paragraph") ("page"))) t)))
+			       '(("as-char") ("paragraph") ("page")) t)))
 	   (user-frame-style
 	    (and user-frame-anchor (plist-get attr-plist :style)))
 	   (user-frame-attrs
@@ -1727,8 +1780,10 @@ ATTR is a string of other attributes of the a element."
 	   (embed-as (cond
 		      (latex-frag
 		       (symbol-name
-			(or (org-find-text-property-in-string
-			     'org-latex-src-embed-type src) 'character)))
+			(case (org-find-text-property-in-string
+			       'org-latex-src-embed-type src)
+			  (paragraph 'paragraph)
+			  (t 'as-char))))
 		      (user-frame-anchor)
 		      (t "paragraph")))
 	   (size (org-odt-image-size-from-file
@@ -1791,9 +1846,13 @@ ATTR is a string of other attributes of the a element."
 		content) nil nil "OrgInlineTaskFrame" " style:rel-width=\"100%\"")))
 
 (defvar org-odt-entity-frame-styles
-  '(("CharacterImage" "__Figure__" ("OrgInlineImage" nil "as-char"))
+  '(("As-CharImage" "__Figure__" ("OrgInlineImage" nil "as-char"))
     ("ParagraphImage" "__Figure__" ("OrgDisplayImage" nil "paragraph"))
     ("PageImage" "__Figure__" ("OrgPageImage" nil "page"))
+    ("CaptionedAs-CharImage" "__Figure__"
+     ("OrgCaptionedImage"
+      " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
+     ("OrgInlineImage" nil "as-char"))
     ("CaptionedParagraphImage" "__Figure__"
      ("OrgCaptionedImage"
       " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
@@ -1865,12 +1924,12 @@ ATTR is a string of other attributes of the a element."
     target-file))
 
 (defvar org-export-odt-image-size-probe-method
-  '(emacs imagemagick force)
-  "Ordered list of methods by for determining size of an embedded
-  image.")
+  (append (and (executable-find "identify") '(imagemagick)) ; See Bug#10675
+	  '(emacs fixed))
+  "Ordered list of methods for determining image sizes.")
 
 (defvar org-export-odt-default-image-sizes-alist
-  '(("character" . (5 . 0.4))
+  '(("as-char" . (5 . 0.4))
     ("paragraph" . (5 . 5)))
   "Hardcoded image dimensions one for each of the anchor
   methods.")
@@ -1894,7 +1953,9 @@ ATTR is a string of other attributes of the a element."
 				   (pixels-to-cms (cdr size-in-pixels)))))))
     (case probe-method
       (emacs
-       (size-in-cms (ignore-errors (image-size (create-image file) 'pixels))))
+       (size-in-cms (ignore-errors	; Emacs could be in batch mode
+		      (clear-image-cache)
+		      (image-size (create-image file) 'pixels))))
       (imagemagick
        (size-in-cms
 	(let ((dim (shell-command-to-string
@@ -1959,7 +2020,8 @@ See `org-odt-entity-labels-alist' for known CATEGORY-NAMEs.")
 
 (defvar org-odt-label-styles
   '(("text" "(%n)" "text" "(%n)")
-    ("category-and-value" "%e %n%c" "category-and-value" "%e %n"))
+    ("category-and-value" "%e %n%c" "category-and-value" "%e %n")
+    ("value" "%e %n%c" "value" "%n"))
   "Specify how labels are applied and referenced.
 This is an alist where each element is of the
 form (LABEL-STYLE-NAME LABEL-ATTACH-FMT LABEL-REF-MODE
@@ -1981,10 +2043,14 @@ specifiers - %e and %n.  %e is replaced with the CATEGORY-NAME.
 `org-odt-format-label-reference'.")
 
 (defvar org-odt-category-map-alist
-  '(("__Table__" "Table" "category-and-value")
-    ("__Figure__" "Figure" "category-and-value")
+  '(("__Table__" "Table" "value")
+    ("__Figure__" "Figure" "value")
     ("__MathFormula__" "Equation" "text")
-    ("__DvipngImage__" "Equation" "category-and-value"))
+    ("__DvipngImage__" "Equation" "value")
+    ;; ("__Table__" "Table" "category-and-value")
+    ;; ("__Figure__" "Figure" "category-and-value")
+    ;; ("__DvipngImage__" "Equation" "category-and-value")
+    )
   "Map a CATEGORY-HANDLE to CATEGORY-NAME and LABEL-STYLE.
 This is an alist where each element is of the form
 \\(CATEGORY-HANDLE CATEGORY-NAME LABEL-STYLE\\).  CATEGORY_HANDLE
@@ -2118,6 +2184,8 @@ CATEGORY-HANDLE is used.  See
 	  org-odt-section-count 0
 	  org-odt-entity-labels-alist nil
 	  org-odt-list-stack-stashed nil
+	  org-odt-automatic-styles nil
+	  org-odt-object-counters nil
 	  org-odt-entity-counts-plist nil)
     content-file))
 
@@ -2128,10 +2196,14 @@ component xml buffers before they are saved.  Turn this off for
 regular use.  Turn this on if you need to examine the xml
 visually."
   :group 'org-export-odt
+  :version "24.1"
   :type 'boolean)
 
 (defvar hfy-user-sheet-assoc)		; bound during org-do-lparse
 (defun org-odt-save-as-outfile (target opt-plist)
+  ;; write automatic styles
+  (org-odt-write-automatic-styles)
+
   ;; write meta file
   (org-odt-update-meta-file opt-plist)
 
@@ -2247,21 +2319,21 @@ visually."
          xmlns:ooo=\"http://openoffice.org/2004/office\"
          office:version=\"1.2\">
        <office:meta>" "\n"
-      (org-odt-format-author)
-      (org-odt-format-tags
-       '("\n<meta:initial-creator>" . "</meta:initial-creator>") author)
-      (org-odt-format-tags '("\n<dc:date>" . "</dc:date>") date)
-      (org-odt-format-tags
-       '("\n<meta:creation-date>" . "</meta:creation-date>") date)
-      (org-odt-format-tags '("\n<meta:generator>" . "</meta:generator>")
-			   (when org-export-creator-info
-			     (format "Org-%s/Emacs-%s"
-				     org-version emacs-version)))
-      (org-odt-format-tags '("\n<meta:keyword>" . "</meta:keyword>") keywords)
-      (org-odt-format-tags '("\n<dc:subject>" . "</dc:subject>") description)
-      (org-odt-format-tags '("\n<dc:title>" . "</dc:title>") title)
-      "\n"
-      "  </office:meta>" "</office:document-meta>")
+       (org-odt-format-author)
+       (org-odt-format-tags
+	'("\n<meta:initial-creator>" . "</meta:initial-creator>") author)
+       (org-odt-format-tags '("\n<dc:date>" . "</dc:date>") date)
+       (org-odt-format-tags
+	'("\n<meta:creation-date>" . "</meta:creation-date>") date)
+       (org-odt-format-tags '("\n<meta:generator>" . "</meta:generator>")
+			    (when org-export-creator-info
+			      (format "Org-%s/Emacs-%s"
+				      org-version emacs-version)))
+       (org-odt-format-tags '("\n<meta:keyword>" . "</meta:keyword>") keywords)
+       (org-odt-format-tags '("\n<dc:subject>" . "</dc:subject>") description)
+       (org-odt-format-tags '("\n<dc:title>" . "</dc:title>") title)
+       "\n"
+       "  </office:meta>" "</office:document-meta>")
      nil (expand-file-name "meta.xml")))
 
   ;; create a manifest entry for meta.xml
@@ -2320,23 +2392,19 @@ visually."
       (replace-match ""))))
 
 (defcustom org-export-odt-convert-processes
-  '(("BasicODConverter"
-     ("soffice" "-norestore" "-invisible" "-headless"
-      "\"macro:///BasicODConverter.Main.Convert(%I,%f,%O)\""))
+  '(("LibreOffice"
+     "soffice --headless --convert-to %f%x --outdir %d %i")
     ("unoconv"
-     ("unoconv" "-f" "%f" "-o" "%d" "%i")))
+     "unoconv -f %f -o %d %i"))
   "Specify a list of document converters and their usage.
 The converters in this list are offered as choices while
 customizing `org-export-odt-convert-process'.
 
-This variable is an alist where each element is of the
-form (CONVERTER-NAME CONVERTER-PROCESS).  CONVERTER-NAME is name
-of the converter.  CONVERTER-PROCESS specifies the command-line
-syntax of the converter and is of the form (CONVERTER-PROGRAM
-ARG1 ARG2 ...).  CONVERTER-PROGRAM is the name of the executable.
-ARG1, ARG2 etc are command line options that are passed to
-CONVERTER-PROGRAM.  Format specifiers can be used in the ARGs and
-they are interpreted as below:
+This variable is a list where each element is of the
+form (CONVERTER-NAME CONVERTER-CMD).  CONVERTER-NAME is the name
+of the converter.  CONVERTER-CMD is the shell command for the
+converter and can contain format specifiers.  These format
+specifiers are interpreted as below:
 
 %i input file name in full
 %I input file name as a URL
@@ -2344,21 +2412,23 @@ they are interpreted as below:
 %o output file name in full
 %O output file name as a URL
 %d output dir in full
-%D output dir as a URL."
+%D output dir as a URL.
+%x extra options as set in `org-export-odt-convert-capabilities'."
   :group 'org-export-odt
+  :version "24.1"
   :type
   '(choice
     (const :tag "None" nil)
     (alist :tag "Converters"
 	   :key-type (string :tag "Converter Name")
-	   :value-type (group (cons (string :tag "Executable")
-				    (repeat (string :tag "Command line args")))))))
+	   :value-type (group (string :tag "Command line")))))
 
-(defcustom org-export-odt-convert-process nil
+(defcustom org-export-odt-convert-process "LibreOffice"
   "Use this converter to convert from \"odt\" format to other formats.
 During customization, the list of converter names are populated
 from `org-export-odt-convert-processes'."
   :group 'org-export-odt
+  :version "24.1"
   :type '(choice :convert-widget
 		 (lambda (w)
 		   (apply 'widget-convert (widget-type w)
@@ -2370,19 +2440,20 @@ from `org-export-odt-convert-processes'."
 
 (defcustom org-export-odt-convert-capabilities
   '(("Text"
-     ("odt" "ott" "doc" "rtf")
-     (("pdf" "pdf") ("odt" "odt") ("xhtml" "html") ("rtf" "rtf")
-      ("ott" "ott") ("doc" "doc") ("ooxml" "xml") ("html" "html")))
+     ("odt" "ott" "doc" "rtf" "docx")
+     (("pdf" "pdf") ("odt" "odt") ("rtf" "rtf") ("ott" "ott")
+      ("doc" "doc" ":\"MS Word 97\"") ("docx" "docx") ("html" "html")))
     ("Web"
-     ("html" "xhtml") (("pdf" "pdf") ("odt" "txt") ("html" "html")))
+     ("html")
+     (("pdf" "pdf") ("odt" "odt") ("html" "html")))
     ("Spreadsheet"
-     ("ods" "ots" "xls" "csv")
-     (("pdf" "pdf") ("ots" "ots") ("html" "html") ("csv" "csv")
-      ("ods" "ods") ("xls" "xls") ("xhtml" "xhtml") ("ooxml" "xml")))
+     ("ods" "ots" "xls" "csv" "xlsx")
+     (("pdf" "pdf") ("ots" "ots") ("html" "html") ("csv" "csv") ("ods" "ods")
+      ("xls" "xls") ("xlsx" "xlsx")))
     ("Presentation"
-     ("odp" "otp" "ppt")
-     (("pdf" "pdf") ("swf" "swf") ("odp" "odp") ("xhtml" "xml")
-      ("otp" "otp") ("ppt" "ppt") ("odg" "odg") ("html" "html"))))
+     ("odp" "otp" "ppt" "pptx")
+     (("pdf" "pdf") ("swf" "swf") ("odp" "odp") ("otp" "otp") ("ppt" "ppt")
+      ("pptx" "pptx") ("odg" "odg"))))
   "Specify input and output formats of `org-export-odt-convert-process'.
 More correctly, specify the set of input and output formats that
 the user is actually interested in.
@@ -2391,7 +2462,7 @@ This variable is an alist where each element is of the
 form (DOCUMENT-CLASS INPUT-FMT-LIST OUTPUT-FMT-ALIST).
 INPUT-FMT-LIST is a list of INPUT-FMTs.  OUTPUT-FMT-ALIST is an
 alist where each element is of the form (OUTPUT-FMT
-OUTPUT-FILE-EXTENSION).
+OUTPUT-FILE-EXTENSION EXTRA-OPTIONS).
 
 The variable is interpreted as follows:
 `org-export-odt-convert-process' can take any document that is in
@@ -2404,6 +2475,9 @@ serves dual purposes:
 - It is used as the value of \"%f\" specifier in
   `org-export-odt-convert-process'.
 
+EXTRA-OPTIONS is used as the value of \"%x\" specifier in
+`org-export-odt-convert-process'.
+
 DOCUMENT-CLASS is used to group a set of file formats in
 INPUT-FMT-LIST in to a single class.
 
@@ -2417,16 +2491,21 @@ with that class.
 See default setting of this variable for an typical
 configuration."
   :group 'org-export-odt
+  :version "24.1"
   :type
   '(choice
     (const :tag "None" nil)
-    (alist :key-type (string :tag "Document Class")
+    (alist :tag "Capabilities"
+	   :key-type (string :tag "Document Class")
 	   :value-type
 	   (group (repeat :tag "Input formats" (string :tag "Input format"))
 		  (alist :tag "Output formats"
 			 :key-type (string :tag "Output format")
 			 :value-type
-			 (group (string :tag "Output file extension")))))))
+			 (group (string :tag "Output file extension")
+				(choice
+				 (const :tag "None" nil)
+				 (string :tag "Extra options"))))))))
 
 (declare-function org-create-math-formula "org"
 		  (latex-frag &optional mathml-file))
@@ -2608,10 +2687,6 @@ Do this when translation to MathML fails."
   ;; create a manifest entry for styles.xml
   (org-odt-create-manifest-file-entry "text/xml" "styles.xml"))
 
-(defvar org-export-odt-factory-settings
-  "d4328fb9d1b6cb211d4320ff546829f26700dc5e"
-  "SHA1 hash of OrgOdtStyles.xml.")
-
 (defun org-odt-configure-outline-numbering (level)
   "Outline numbering is retained only upto LEVEL.
 To disable outline numbering pass a LEVEL of 0."
@@ -2649,7 +2724,6 @@ non-nil."
 			     (or (file-name-nondirectory buffer-file-name)))
 			    "." "odf")
 			   (file-name-directory buffer-file-name))))
-	(message "default val is %s"  odf-filename)
 	(read-file-name "ODF filename: " nil odf-filename nil
 			(file-name-nondirectory odf-filename)))))
   (let* ((org-lparse-backend 'odf)
@@ -2676,7 +2750,7 @@ non-nil."
 
 ;;;###autoload
 (defun org-export-as-odf-and-open ()
- "Export LaTeX fragment as OpenDocument formula and immediately open it.
+  "Export LaTeX fragment as OpenDocument formula and immediately open it.
 Use `org-export-as-odf' to read LaTeX fragment and OpenDocument
 formula file."
   (interactive)