File | Date | Author | Commit |
---|---|---|---|
bin | 2020-02-06 |
![]() |
[88ca67] Port binaries to Py3, update README |
ooopy | 2022-03-30 |
![]() |
[1cf1ff] Close all ooopy instances |
testfiles | 2014-05-16 |
![]() |
[69b0f8] Fix --delimiter option of ooo_mailmerge |
.gitignore | 2020-02-06 |
![]() |
[88ca67] Port binaries to Py3, update README |
MANIFEST.in | 2014-04-05 |
![]() |
[27ff67] Rename README -> README.rst for SF |
Makefile | 2022-03-30 |
![]() |
[7e3b1c] Latest releasetools |
README.rst | 2022-03-30 |
![]() |
[07ca66] Document changes in doctest in README |
run_doctest.py | 2022-03-30 |
![]() |
[59d86d] Remove doctest workaround for python2.3 |
setup.py | 2022-03-30 |
![]() |
[8dc0f7] Fix setup, patch from Hans-Peter Jansen |
Author: | Ralf Schlatterbeck <rsc@runtux.com> |
---|
OpenOffice.org (OOo) documents are ZIP archives containing several XML files. Therefore it is easy to inspect, create, or modify OOo documents. OOoPy is a library in Python for these tasks with OOo documents. To not reinvent the wheel, OOoPy uses an existing XML library, ElementTree by Fredrik Lundh (which is in the Python standard library for quite some time now). OOoPy is a thin wrapper around ElementTree using Python's ZipFile to read and write OOo documents.
In addition to being a wrapper for ElementTree, OOoPy contains a framework for applying XML transforms to OOo documents. Several Transforms for OOo documents exist, e.g., for changing OOo fields (OOo Insert-Fields menu) or using OOo fields for a mail merge application. Some other transformations for modifying OOo settings and meta information are also given as examples.
Applications like this come in handy in applications where calling native OOo is not an option, e.g., in server-side Web applications.
If the mailmerge transform doesn't work for your document: The OOo format is well documented but there are ordering constraints in the body of an OOo document. I've not yet figured out all the tags and their order in the OOo body. Individual elements in an OOo document (like e.g., frames, sections, tables) need to have their own unique names. After a mailmerge, there are duplicate names for some items. So far I'm renumbering only frames, sections, and tables. See the renumber objects at the end of ooopy/Transforms.py. So if you encounter missing parts of the mailmerged document, check if there are some renumberings missing or send me a bug report, see section Reporting Bugs
There is currently not much documentation except for a python doctest in OOoPy.py and Transformer.py and the command-line utilities. For running these test, after installing ooopy (assuming here you installed using python into /usr/local):
cd /usr/local/share/ooopy python run_doctest.py /usr/local/lib/python2.X/site-packages/ooopy/Transformer.py python run_doctest.py /usr/local/lib/python2.X/site-packages/ooopy/OOoPy.py
Both should report no failed tests.
See the online documentation, e.g.:
% python >>> from ooopy.OOoPy import OOoPy >>> help (OOoPy) >>> from ooopy.Transformer import Transformer >>> help (Transformer)
A, well, there are command-line utilities now:
All utilities take a --help option.
You usually want to install via pip. Typically you would do something like:
python3 -m pip install ooopy
For the sourcecode: This is both available on Github and on Sourceforge.
You need at least version 2.7 of python. Now also tested with 3.7 and 3.9, will probably work with later versions, too. In the future only Python3 will be supported.
For documentation about the OOo XML file format there is a reference document you may want to check out the XML File Format Specification (PDF) by OpenOffice.org.
Please use the Sourceforge Bug Tracker or the Github Bug Tracker and
Version 2.1: Test with newer versions of Python3
This will probably be the last version explicitly supporting Python2. I'm only testing against 2.7.16 shipped with debian buster. Since I'm going to upgrade and python2 is end-of-life for a long time now I will no longer test Python2 in the future.
Version 2.0: Port to Python3
Still working with lower python versions but I'm only able to test with 2.7, nothing earlier. Bug fixes where sometimes multiple Set_Attribute transformations (e.g. when concatenating OO documents) would be applied to the same tag/attribute combination. Also fix a bug with the computation of default tabulators when concatenating documents.
Version 1.11: Small Bug fix ooo_mailmerge
Now ooo_mailmerge uses the delimiter option, it was ignored before. Thanks to Bob Danek for report and test.
Version 1.10: Fix table styles when concatenating
Now ooo_cat fixes tables styles when concatenating (renaming): We optimize style usage by re-using existing styles. But for some table styles the original names were not renamed to the re-used ones. Fixes SF Bug 10, thanks to Claudio Girlanda for reporting.
Version 1.9: Add Picture Handling for Concatenation
Now ooo_cat supports pictures, thanks to Antonio Sánchez for reporting that this wasn't working.
Version 1.8: Minor bugfixes
Distribute a missing file that is used in the doctest. Fix directory structure. Thanks to Michael Nagel for suggesting the change and reporting the bug.
Version 1.7: Minor feature additions
Add --newlines option to ooo_as_text: With this option the paragraphs in the office document are preserved in the text output. Fix assertion error with python2.7, thanks to Hans-Peter Jansen for the report. Several other small fixes for python2.7 vs. 2.6.
Version 1.6: Minor bugfixes
Fix compression: when writing new XML-files these would be stored instead of compressed in the OOo zip-file resulting in big documents. Thanks to Hans-Peter Jansen for the patch. Add copyright notice to command-line utils (SF Bug 2650042). Fix mailmerge for OOo 3.X lists (SF Bug 2949643).
Version 1.5: Minor feature enhancements
Add ooo_grep to search for OOo files containing a pattern. Thanks to Mathieu Chauvinc for the reporting the problems with modified manifest.xml. Support python2.6, thanks to Erik Myllymaki for reporting and anonymous contributor(s) for confirming the bug.
Version 1.4: Minor bugfixes
Fix Doctest to hopefully run on windows. Thanks to Dani Budinova for testing thoroughly under windows.
Version 1.3: Minor bugfixes
Regression-test failed because some files were not distributed. Fixes SF Bugs 1970389 and 1972900.
Version 1.2: Major feature enhancements
Add ooo_fieldreplace, ooo_cat, ooo_mailmerge command-line utilities. Fix ooo_as_text to allow specification of output-file. Note that handling of non-seekable input/output (pipes) for command-line utils will work only starting with python2.5. Minor bug-fix when concatenating documents.
Version 1.1: Minor bugfixes
Small Documentation changes
Version 1.0: Major feature enhancements
Now works with version 2.X of OpenOffice.org. Minor API changes.