From fb997f281f149bfc19eab63dd5cf5430f3ac8e72 Mon Sep 17 00:00:00 2001 From: Orcan Ogetbil Date: Sat, 9 May 2009 23:41:28 +0000 Subject: [PATCH 01/71] - Fix rpmlints - Prepare package for Fedora review Sun Feb 22 2009 Peter Hanecak 0.3-2 - used %%{?dist} in release number - license GPLv2 Wed Dec 19 2007 Dag Wieers - 0.3-2 - 5993+/dag - Fixed openoffice.org2 dependency on RHEL4. Sat Sep 01 2007 Dag Wieers - 0.3-1 - Updated to release 0.3. Sun May 20 2007 Dag Wieers - 0.2-1 - Updated to release 0.2. Sat May 19 2007 Dag Wieers - 0.1-1 - Initial package. (using DAR) --- .cvsignore | 1 + import.log | 1 + sources | 1 + unoconv.spec | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 import.log create mode 100644 unoconv.spec diff --git a/.cvsignore b/.cvsignore index e69de29..803be2e 100644 --- a/.cvsignore +++ b/.cvsignore @@ -0,0 +1 @@ +unoconv-0.3.tar.bz2 diff --git a/import.log b/import.log new file mode 100644 index 0000000..bf58fe0 --- /dev/null +++ b/import.log @@ -0,0 +1 @@ +unoconv-0_3-3_fc10:HEAD:unoconv-0.3-3.fc10.src.rpm:1241912460 diff --git a/sources b/sources index e69de29..6ab027c 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +e6b33a2041137d8ebae1b71396ec0641 unoconv-0.3.tar.bz2 diff --git a/unoconv.spec b/unoconv.spec new file mode 100644 index 0000000..dcbb321 --- /dev/null +++ b/unoconv.spec @@ -0,0 +1,66 @@ +Summary: Tool to convert between any document format supported by OpenOffice.org +Name: unoconv +Version: 0.3 +Release: 3%{?dist} +License: GPLv2 +Group: System Environment/Base +URL: http://dag.wieers.com/home-made/unoconv/ +Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.bz2 +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root + +BuildArch: noarch +Requires: openoffice.org-pyuno + + +%description +unoconv converts between any document format that OpenOffice.org understands. +It uses OpenOffice.org's UNO bindings for non-interactive conversion of +documents. + +Supported document formats include Open Document Format (.odf), MS Word (.doc), +MS Office Open/MS OOXML (.xml), Portable Document Format (.pdf), HTML, XHTML, +RTF, Docbook (.xml), and more. + +%prep +%setup -q + +# Fix EOL encoding +sed 's|\r||' docs/unoconv.1.xml > docs/unoconv.1.xml.tmp +touch -r docs/unoconv.1.xml docs/unoconv.1.xml.tmp +mv -f docs/unoconv.1.xml.tmp docs/unoconv.1.xml + +%build + +%install +rm -rf %{buildroot} +make install DESTDIR="%{buildroot}" + +%clean +rm -rf %{buildroot} + +%files +%defattr(-, root, root, -) +%doc AUTHORS ChangeLog COPYING README TODO WISHLIST docs/ tests/ +%{_mandir}/man1/%{name}.1* +%{_bindir}/%{name} + +%changelog +* Thu May 07 2009 Orcan Ogetbil - 0.3-3 +- Fix rpmlints +- Prepare package for Fedora review + +* Sun Feb 22 2009 Peter Hanecak 0.3-2 +- used %%{?dist} in release number +- license GPLv2 + +* Wed Dec 19 2007 Dag Wieers - 0.3-2 - 5993+/dag +- Fixed openoffice.org2 dependency on RHEL4. + +* Sat Sep 01 2007 Dag Wieers - 0.3-1 +- Updated to release 0.3. + +* Sun May 20 2007 Dag Wieers - 0.2-1 +- Updated to release 0.2. + +* Sat May 19 2007 Dag Wieers - 0.1-1 +- Initial package. (using DAR) From fa679247af4f10f67835ca4faff8ac72447386d8 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Mon, 27 Jul 2009 06:34:26 +0000 Subject: [PATCH 02/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index dcbb321..286aeb8 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by OpenOffice.org Name: unoconv Version: 0.3 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -45,6 +45,9 @@ rm -rf %{buildroot} %{_bindir}/%{name} %changelog +* Sun Jul 26 2009 Fedora Release Engineering - 0.3-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + * Thu May 07 2009 Orcan Ogetbil - 0.3-3 - Fix rpmlints - Prepare package for Fedora review From dbfeeea46cbd8f5f5a2d79a53c8ac5a8d87eafb7 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Wed, 25 Nov 2009 22:52:47 +0000 Subject: [PATCH 03/71] Fix typo that causes a failure to update the common directory. (releng #2781) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3c076e8..96d2ab4 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ NAME := unoconv SPECFILE = $(firstword $(wildcard *.spec)) define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done endef MAKEFILE_COMMON := $(shell $(find-makefile-common)) From 250cc0d1284e44843eff214d6e22faa58de71af0 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 29 Jul 2010 14:44:45 +0000 Subject: [PATCH 04/71] dist-git conversion --- .cvsignore => .gitignore | 0 Makefile | 21 --------------------- import.log | 1 - 3 files changed, 22 deletions(-) rename .cvsignore => .gitignore (100%) delete mode 100644 Makefile delete mode 100644 import.log diff --git a/.cvsignore b/.gitignore similarity index 100% rename from .cvsignore rename to .gitignore diff --git a/Makefile b/Makefile deleted file mode 100644 index 96d2ab4..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: unoconv -# $Id$ -NAME := unoconv -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/import.log b/import.log deleted file mode 100644 index bf58fe0..0000000 --- a/import.log +++ /dev/null @@ -1 +0,0 @@ -unoconv-0_3-3_fc10:HEAD:unoconv-0.3-3.fc10.src.rpm:1241912460 From ca9bb56cec89daf512adce518d8a0406aacc83c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sat, 30 Oct 2010 20:41:21 +0100 Subject: [PATCH 05/71] rebuild for LibreOffice --- unoconv.spec | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/unoconv.spec b/unoconv.spec index 286aeb8..9b2c235 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ -Summary: Tool to convert between any document format supported by OpenOffice.org +Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.3 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -9,12 +9,12 @@ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch -Requires: openoffice.org-pyuno +Requires: libreoffice-pyuno %description -unoconv converts between any document format that OpenOffice.org understands. -It uses OpenOffice.org's UNO bindings for non-interactive conversion of +unoconv converts between any document format that LibreOffice understands. +It uses LibreOffice's UNO bindings for non-interactive conversion of documents. Supported document formats include Open Document Format (.odf), MS Word (.doc), @@ -45,6 +45,9 @@ rm -rf %{buildroot} %{_bindir}/%{name} %changelog +* Sat Oct 30 2010 Caolán McNamara - 0.3-5 +- rebuild for LibreOffice + * Sun Jul 26 2009 Fedora Release Engineering - 0.3-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild From 905bb66d53b55c05a8af85c6edb1a2a129d14cc1 Mon Sep 17 00:00:00 2001 From: Orcan Ogetbil Date: Fri, 12 Nov 2010 23:59:13 -0500 Subject: [PATCH 06/71] - Update to 0.4 --- .gitignore | 1 + sources | 2 +- unoconv.spec | 17 +++++++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 803be2e..d22089f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ unoconv-0.3.tar.bz2 +/unoconv-0.4.tar.bz2 diff --git a/sources b/sources index 6ab027c..59e5e20 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -e6b33a2041137d8ebae1b71396ec0641 unoconv-0.3.tar.bz2 +64cd2c3b0823d329890c0bedffdfa6ae unoconv-0.4.tar.bz2 diff --git a/unoconv.spec b/unoconv.spec index 9b2c235..3783416 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv -Version: 0.3 -Release: 5%{?dist} +Version: 0.4 +Release: 1%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -9,8 +9,11 @@ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch +%if 0%{fedora} < 15 +Requires: openoffice.org-pyuno +%else Requires: libreoffice-pyuno - +%endif %description unoconv converts between any document format that LibreOffice understands. @@ -24,11 +27,6 @@ RTF, Docbook (.xml), and more. %prep %setup -q -# Fix EOL encoding -sed 's|\r||' docs/unoconv.1.xml > docs/unoconv.1.xml.tmp -touch -r docs/unoconv.1.xml docs/unoconv.1.xml.tmp -mv -f docs/unoconv.1.xml.tmp docs/unoconv.1.xml - %build %install @@ -45,6 +43,9 @@ rm -rf %{buildroot} %{_bindir}/%{name} %changelog +* Fri Nov 12 2010 Orcan Ogetbil - 0.4-1 +- Update to 0.4 + * Sat Oct 30 2010 Caolán McNamara - 0.3-5 - rebuild for LibreOffice From 178e4e6b1f6061c40852f4fcc5930fbfe3677308 Mon Sep 17 00:00:00 2001 From: Orcan Ogetbil Date: Sat, 13 Nov 2010 00:21:19 -0500 Subject: [PATCH 07/71] - Backport some upstream fixes (LD_LIBRARY_PATH issue and -o flag issue) --- unoconv-ld-path.patch | 81 ++++++++++++++++++++++++++++++++++++++ unoconv-output-files.patch | 74 ++++++++++++++++++++++++++++++++++ unoconv.spec | 11 +++++- 3 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 unoconv-ld-path.patch create mode 100644 unoconv-output-files.patch diff --git a/unoconv-ld-path.patch b/unoconv-ld-path.patch new file mode 100644 index 0000000..44d8f14 --- /dev/null +++ b/unoconv-ld-path.patch @@ -0,0 +1,81 @@ +--- trunk/tools/unoconv/unoconv 2010/10/25 08:46:13 9192 ++++ trunk/tools/unoconv/unoconv 2010/11/03 17:13:09 9235 +@@ -64,7 +64,10 @@ + sys.path.append(oolibpath) + import uno, unohelper + ### Export an environment that OpenOffice is pleased to work with +- os.environ['LD_LIBRARY_PATH'] = oolibpath + os.pathsep + os.environ['LD_LIBRARY_PATH'] ++ if 'LD_LIBRARY_PATH' in os.environ: ++ os.environ['LD_LIBRARY_PATH'] = oolibpath + os.pathsep + os.environ['LD_LIBRARY_PATH'] ++ else: ++ os.environ['LD_LIBRARY_PATH'] = oolibpath + break + except ImportError, e: + sys.path.remove(oolibpath) +@@ -583,7 +586,7 @@ + def convert(self, inputfn): + global exitcode + +- doc = None ++ document = None + outputfmt = self.getformat(inputfn) + + if op.verbose > 0: +@@ -602,9 +605,9 @@ + ) + + inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn)) +- doc = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) ++ document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) + +- if not doc: ++ if not document: + raise UnoException("File could not be loaded by OpenOffice", None) + + ### Import style template +@@ -616,7 +619,7 @@ + PropertyValue( "OverwriteStyles", 0, True, 0), + ) + templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template)) +- doc.StyleFamilies.loadStylesFromURL(templateurl, templateprops) ++ document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) + else: + print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template + exitcode = 1 +@@ -627,15 +630,15 @@ + + ### Update document links + try: +- doc.updateLinks() ++ document.updateLinks() + except AttributeError: + # the document doesn't implement the XLinkUpdate interface + pass + + ### Update document indexes + try: +- doc.refresh() +- indexes = doc.getDocumentIndexes() ++ document.refresh() ++ indexes = document.getDocumentIndexes() + except AttributeError: + # the document doesn't implement the XRefreshable and/or + # XDocumentIndexesSupplier interfaces +@@ -669,13 +672,13 @@ + outputfn = op.output + + outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) +- doc.storeToURL(outputurl, tuple(outputprops) ) ++ document.storeToURL(outputurl, tuple(outputprops) ) + info(1, "Output file: %s" % outputfn) + else: +- doc.storeToURL("private:stream", tuple(outputprops) ) ++ document.storeToURL("private:stream", tuple(outputprops) ) + +- doc.dispose() +- doc.close(True) ++ document.dispose() ++ document.close(True) + + except SystemError, e: + error("unoconv: SystemError during conversion: %s" % e) diff --git a/unoconv-output-files.patch b/unoconv-output-files.patch new file mode 100644 index 0000000..1ee1ee7 --- /dev/null +++ b/unoconv-output-files.patch @@ -0,0 +1,74 @@ +--- trunk/tools/unoconv/unoconv 2010/10/20 11:21:12 9187 ++++ trunk/tools/unoconv/unoconv 2010/10/25 08:46:13 9192 +@@ -105,7 +105,7 @@ + __version__ = "$Revision$" + # $Source$ + +-VERSION = '0.4' ++VERSION = '0.4svn' + + doctypes = ('document', 'graphics', 'presentation', 'spreadsheet') + +@@ -333,7 +333,7 @@ + self.format = None + self.importfilter = "" + self.listener = False +- self.outputpath = None ++ self.output = None + self.pipe = None + self.port = '2002' + self.server = 'localhost' +@@ -347,9 +347,9 @@ + try: + opts, args = getopt.getopt (args, 'c:d:e:f:hi:Llo:p:s:t:T:v', + ['connection=', 'doctype=', 'export', 'format=', 'help', +- 'import', 'listener', 'outputpath=', 'pipe=', 'port=', +- 'server=', 'timeout=', 'show', 'stdout', 'template', +- 'verbose', 'version'] ) ++ 'import', 'listener', 'output=', 'outputpath', 'pipe=', ++ 'port=', 'server=', 'timeout=', 'show', 'stdout', ++ 'template', 'verbose', 'version'] ) + except getopt.error, exc: + print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc) + sys.exit(255) +@@ -382,8 +382,11 @@ + self.importfilter = arg + elif opt in ['-l', '--listener']: + self.listener = True +- elif opt in ['-o', '--outputpath']: +- self.outputpath = arg ++ elif opt in ['-o', '--output']: ++ self.output = arg ++ elif opt in ['--outputpath']: ++ print >>sys.stderr, 'Warning: This option is deprecated by --output.' % arg ++ self.output = arg + elif opt in ['--pipe']: + self.pipe = arg + elif opt in ['-p', '--port']: +@@ -474,7 +477,7 @@ + -i, --import=string set import filter option string + eg. -i utf8 + -l, --listener start a listener to use by unoconv clients +- -o, --outputpath=name output directory ++ -o, --output=name output basename, filename or directory + --pipe=name alternative method of connection using a pipe + -p, --port=port specify the port (default: 2002) + to be used by client or listener +@@ -656,10 +659,15 @@ + + if not op.stdout: + (outputfn, ext) = os.path.splitext(inputfn) +- if not op.outputpath: ++ if not op.output: + outputfn = outputfn + os.extsep + outputfmt.extension ++ elif os.path.isdir(op.output): ++ outputfn = os.path.join(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension) ++ elif len(op.filenames) > 1: ++ outputfn = op.output + os.extsep + outputfmt.extension + else: +- outputfn = os.path.join(op.outputpath, os.path.basename(outputfn) + os.extsep + outputfmt.extension) ++ outputfn = op.output ++ + outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) + doc.storeToURL(outputurl, tuple(outputprops) ) + info(1, "Output file: %s" % outputfn) diff --git a/unoconv.spec b/unoconv.spec index 3783416..7f1ea08 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,11 +1,15 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.4 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.bz2 +# Allow -o flag to output to files +Patch0: unoconv-output-files.patch +# Fix LD_LIBRARY_PATH handling. From upstream trunk +Patch1: unoconv-ld-path.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch @@ -26,6 +30,8 @@ RTF, Docbook (.xml), and more. %prep %setup -q +%patch0 -p3 -b .o_flag +%patch1 -p3 -b .ld_library_path %build @@ -43,6 +49,9 @@ rm -rf %{buildroot} %{_bindir}/%{name} %changelog +* Sat Nov 13 2010 Orcan Ogetbil - 0.4-2 +- Backport some upstream fixes (LD_LIBRARY_PATH issue and -o flag issue) + * Fri Nov 12 2010 Orcan Ogetbil - 0.4-1 - Update to 0.4 From 76c079ec7fe78e54337af6fdeb0cb5c6cbcfcfbe Mon Sep 17 00:00:00 2001 From: Orcan Ogetbil Date: Tue, 30 Nov 2010 17:58:32 -0500 Subject: [PATCH 08/71] - Add missing Requires on openoffice.org-brand/libreoffice-core. RHBZ#658576 --- unoconv.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 7f1ea08..10c95a0 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.4 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -14,8 +14,10 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch %if 0%{fedora} < 15 +Requires: openoffice.org-brand Requires: openoffice.org-pyuno %else +Requires: libreoffice-core Requires: libreoffice-pyuno %endif @@ -49,6 +51,9 @@ rm -rf %{buildroot} %{_bindir}/%{name} %changelog +* Tue Nov 30 2010 Orcan Ogetbil - 0.4-3 +- Add missing Requires on openoffice.org-brand/libreoffice-core. RHBZ#658576 + * Sat Nov 13 2010 Orcan Ogetbil - 0.4-2 - Backport some upstream fixes (LD_LIBRARY_PATH issue and -o flag issue) From f8e232108f753c8ae190a300334e48127479ef89 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Mon, 7 Feb 2011 18:25:51 -0600 Subject: [PATCH 09/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 10c95a0..a78e27c 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.4 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -51,6 +51,9 @@ rm -rf %{buildroot} %{_bindir}/%{name} %changelog +* Mon Feb 07 2011 Fedora Release Engineering - 0.4-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + * Tue Nov 30 2010 Orcan Ogetbil - 0.4-3 - Add missing Requires on openoffice.org-brand/libreoffice-core. RHBZ#658576 From 41fa02a16868ec0a559386732aa3efb2f38609aa Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Sat, 14 Jan 2012 01:33:59 -0600 Subject: [PATCH 10/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index a78e27c..c09674f 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.4 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -51,6 +51,9 @@ rm -rf %{buildroot} %{_bindir}/%{name} %changelog +* Sat Jan 14 2012 Fedora Release Engineering - 0.4-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + * Mon Feb 07 2011 Fedora Release Engineering - 0.4-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild From 26d66ab309b2d19a88f64950bf8a43f8d312b2ef Mon Sep 17 00:00:00 2001 From: David Tardon Date: Mon, 26 Mar 2012 17:37:55 +0200 Subject: [PATCH 11/71] do not call libreoffice with --nocrashreport --- unoconv-nocrashreport.patch | 32 ++++++++++++++++++++++++++++++++ unoconv.spec | 8 +++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 unoconv-nocrashreport.patch diff --git a/unoconv-nocrashreport.patch b/unoconv-nocrashreport.patch new file mode 100644 index 0000000..f41aada --- /dev/null +++ b/unoconv-nocrashreport.patch @@ -0,0 +1,32 @@ +Common subdirectories: unoconv-0.4.orig/docs and unoconv-0.4/docs +Common subdirectories: unoconv-0.4.orig/tests and unoconv-0.4/tests +diff -u unoconv-0.4.orig/unoconv unoconv-0.4/unoconv +--- unoconv-0.4.orig/unoconv 2012-03-24 16:17:11.583352009 -0400 ++++ unoconv-0.4/unoconv 2012-03-24 16:18:52.198649000 -0400 +@@ -511,7 +511,7 @@ + ### Start our own OpenOffice instance + info(3, "Launching our own listener using %s." % oobin) + try: +- ooproc = subprocess.Popen([oobin, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection]) ++ ooproc = subprocess.Popen([oobin, "-headless", "-invisible", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection]) + info(2, 'OpenOffice listener successfully started. (pid=%s)' % ooproc.pid) + + ### Try connection to it for op.timeout seconds (flakky OpenOffice) +@@ -703,7 +703,7 @@ + def __init__(self): + info(1, "Start listener on %s:%s" % (op.server, op.port)) + try: +- subprocess.call([oobin, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection]) ++ subprocess.call([oobin, "-headless", "-invisible", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection]) + except Exception, e: + error("Launch of %s failed.\n%s" % (oobin, e)) + else: +@@ -733,7 +733,7 @@ + ### If there is a GUI now attached to the instance, disable listener + if convertor.desktop.getCurrentFrame(): + try: +- subprocess.Popen([oobin, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection]) ++ subprocess.Popen([oobin, "-headless", "-invisible", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection]) + info(2, 'OpenOffice listener successfully disabled.') + ooproc.wait() + except Exception, e: diff --git a/unoconv.spec b/unoconv.spec index c09674f..001869a 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.4 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -10,6 +10,9 @@ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.bz2 Patch0: unoconv-output-files.patch # Fix LD_LIBRARY_PATH handling. From upstream trunk Patch1: unoconv-ld-path.patch +# Fedora's libreoffice does not have --nocrashreport option +# https://github.com/dagwieers/unoconv/issues/45 +Patch2: unoconv-nocrashreport.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch @@ -34,6 +37,7 @@ RTF, Docbook (.xml), and more. %setup -q %patch0 -p3 -b .o_flag %patch1 -p3 -b .ld_library_path +%patch2 -p1 -b .nocrashreport %build @@ -51,6 +55,8 @@ rm -rf %{buildroot} %{_bindir}/%{name} %changelog +* Mon Mar 26 2012 David Tardon - 0.4-6 + * Sat Jan 14 2012 Fedora Release Engineering - 0.4-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild From 3689764536765611edf2b77ea986d8762c5cf2fe Mon Sep 17 00:00:00 2001 From: David Tardon Date: Mon, 26 Mar 2012 17:40:20 +0200 Subject: [PATCH 12/71] also use opt. names with two dashes --- unoconv-nocrashreport.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unoconv-nocrashreport.patch b/unoconv-nocrashreport.patch index f41aada..9ddb190 100644 --- a/unoconv-nocrashreport.patch +++ b/unoconv-nocrashreport.patch @@ -8,7 +8,7 @@ diff -u unoconv-0.4.orig/unoconv unoconv-0.4/unoconv info(3, "Launching our own listener using %s." % oobin) try: - ooproc = subprocess.Popen([oobin, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection]) -+ ooproc = subprocess.Popen([oobin, "-headless", "-invisible", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection]) ++ ooproc = subprocess.Popen([oobin, "--headless", "--invisible", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--accept=%s" % op.connection]) info(2, 'OpenOffice listener successfully started. (pid=%s)' % ooproc.pid) ### Try connection to it for op.timeout seconds (flakky OpenOffice) @@ -17,7 +17,7 @@ diff -u unoconv-0.4.orig/unoconv unoconv-0.4/unoconv info(1, "Start listener on %s:%s" % (op.server, op.port)) try: - subprocess.call([oobin, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection]) -+ subprocess.call([oobin, "-headless", "-invisible", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection]) ++ subprocess.call([oobin, "--headless", "--invisible", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection]) except Exception, e: error("Launch of %s failed.\n%s" % (oobin, e)) else: @@ -26,7 +26,7 @@ diff -u unoconv-0.4.orig/unoconv unoconv-0.4/unoconv if convertor.desktop.getCurrentFrame(): try: - subprocess.Popen([oobin, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection]) -+ subprocess.Popen([oobin, "-headless", "-invisible", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection]) ++ subprocess.Popen([oobin, "--headless", "--invisible", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection]) info(2, 'OpenOffice listener successfully disabled.') ooproc.wait() except Exception, e: From b014936d1a81c388d1041345e5b57d25ccc97e48 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 25 Apr 2012 17:43:28 +0200 Subject: [PATCH 13/71] new upstream release 0.5 --- .gitignore | 1 + sources | 2 +- unoconv-ld-path.patch | 81 ------------------------------------- unoconv-nocrashreport.patch | 32 --------------- unoconv-output-files.patch | 74 --------------------------------- unoconv.spec | 19 +++------ 6 files changed, 8 insertions(+), 201 deletions(-) delete mode 100644 unoconv-ld-path.patch delete mode 100644 unoconv-nocrashreport.patch delete mode 100644 unoconv-output-files.patch diff --git a/.gitignore b/.gitignore index d22089f..dcbb5d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ unoconv-0.3.tar.bz2 /unoconv-0.4.tar.bz2 +/unoconv-0.5.tar.bz2 diff --git a/sources b/sources index 59e5e20..c071b87 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -64cd2c3b0823d329890c0bedffdfa6ae unoconv-0.4.tar.bz2 +09a02fe3d258dd332826569026f84d6f unoconv-0.5.tar.bz2 diff --git a/unoconv-ld-path.patch b/unoconv-ld-path.patch deleted file mode 100644 index 44d8f14..0000000 --- a/unoconv-ld-path.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- trunk/tools/unoconv/unoconv 2010/10/25 08:46:13 9192 -+++ trunk/tools/unoconv/unoconv 2010/11/03 17:13:09 9235 -@@ -64,7 +64,10 @@ - sys.path.append(oolibpath) - import uno, unohelper - ### Export an environment that OpenOffice is pleased to work with -- os.environ['LD_LIBRARY_PATH'] = oolibpath + os.pathsep + os.environ['LD_LIBRARY_PATH'] -+ if 'LD_LIBRARY_PATH' in os.environ: -+ os.environ['LD_LIBRARY_PATH'] = oolibpath + os.pathsep + os.environ['LD_LIBRARY_PATH'] -+ else: -+ os.environ['LD_LIBRARY_PATH'] = oolibpath - break - except ImportError, e: - sys.path.remove(oolibpath) -@@ -583,7 +586,7 @@ - def convert(self, inputfn): - global exitcode - -- doc = None -+ document = None - outputfmt = self.getformat(inputfn) - - if op.verbose > 0: -@@ -602,9 +605,9 @@ - ) - - inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn)) -- doc = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) -+ document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) - -- if not doc: -+ if not document: - raise UnoException("File could not be loaded by OpenOffice", None) - - ### Import style template -@@ -616,7 +619,7 @@ - PropertyValue( "OverwriteStyles", 0, True, 0), - ) - templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template)) -- doc.StyleFamilies.loadStylesFromURL(templateurl, templateprops) -+ document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) - else: - print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template - exitcode = 1 -@@ -627,15 +630,15 @@ - - ### Update document links - try: -- doc.updateLinks() -+ document.updateLinks() - except AttributeError: - # the document doesn't implement the XLinkUpdate interface - pass - - ### Update document indexes - try: -- doc.refresh() -- indexes = doc.getDocumentIndexes() -+ document.refresh() -+ indexes = document.getDocumentIndexes() - except AttributeError: - # the document doesn't implement the XRefreshable and/or - # XDocumentIndexesSupplier interfaces -@@ -669,13 +672,13 @@ - outputfn = op.output - - outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) -- doc.storeToURL(outputurl, tuple(outputprops) ) -+ document.storeToURL(outputurl, tuple(outputprops) ) - info(1, "Output file: %s" % outputfn) - else: -- doc.storeToURL("private:stream", tuple(outputprops) ) -+ document.storeToURL("private:stream", tuple(outputprops) ) - -- doc.dispose() -- doc.close(True) -+ document.dispose() -+ document.close(True) - - except SystemError, e: - error("unoconv: SystemError during conversion: %s" % e) diff --git a/unoconv-nocrashreport.patch b/unoconv-nocrashreport.patch deleted file mode 100644 index 9ddb190..0000000 --- a/unoconv-nocrashreport.patch +++ /dev/null @@ -1,32 +0,0 @@ -Common subdirectories: unoconv-0.4.orig/docs and unoconv-0.4/docs -Common subdirectories: unoconv-0.4.orig/tests and unoconv-0.4/tests -diff -u unoconv-0.4.orig/unoconv unoconv-0.4/unoconv ---- unoconv-0.4.orig/unoconv 2012-03-24 16:17:11.583352009 -0400 -+++ unoconv-0.4/unoconv 2012-03-24 16:18:52.198649000 -0400 -@@ -511,7 +511,7 @@ - ### Start our own OpenOffice instance - info(3, "Launching our own listener using %s." % oobin) - try: -- ooproc = subprocess.Popen([oobin, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection]) -+ ooproc = subprocess.Popen([oobin, "--headless", "--invisible", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--accept=%s" % op.connection]) - info(2, 'OpenOffice listener successfully started. (pid=%s)' % ooproc.pid) - - ### Try connection to it for op.timeout seconds (flakky OpenOffice) -@@ -703,7 +703,7 @@ - def __init__(self): - info(1, "Start listener on %s:%s" % (op.server, op.port)) - try: -- subprocess.call([oobin, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection]) -+ subprocess.call([oobin, "--headless", "--invisible", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection]) - except Exception, e: - error("Launch of %s failed.\n%s" % (oobin, e)) - else: -@@ -733,7 +733,7 @@ - ### If there is a GUI now attached to the instance, disable listener - if convertor.desktop.getCurrentFrame(): - try: -- subprocess.Popen([oobin, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection]) -+ subprocess.Popen([oobin, "--headless", "--invisible", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection]) - info(2, 'OpenOffice listener successfully disabled.') - ooproc.wait() - except Exception, e: diff --git a/unoconv-output-files.patch b/unoconv-output-files.patch deleted file mode 100644 index 1ee1ee7..0000000 --- a/unoconv-output-files.patch +++ /dev/null @@ -1,74 +0,0 @@ ---- trunk/tools/unoconv/unoconv 2010/10/20 11:21:12 9187 -+++ trunk/tools/unoconv/unoconv 2010/10/25 08:46:13 9192 -@@ -105,7 +105,7 @@ - __version__ = "$Revision$" - # $Source$ - --VERSION = '0.4' -+VERSION = '0.4svn' - - doctypes = ('document', 'graphics', 'presentation', 'spreadsheet') - -@@ -333,7 +333,7 @@ - self.format = None - self.importfilter = "" - self.listener = False -- self.outputpath = None -+ self.output = None - self.pipe = None - self.port = '2002' - self.server = 'localhost' -@@ -347,9 +347,9 @@ - try: - opts, args = getopt.getopt (args, 'c:d:e:f:hi:Llo:p:s:t:T:v', - ['connection=', 'doctype=', 'export', 'format=', 'help', -- 'import', 'listener', 'outputpath=', 'pipe=', 'port=', -- 'server=', 'timeout=', 'show', 'stdout', 'template', -- 'verbose', 'version'] ) -+ 'import', 'listener', 'output=', 'outputpath', 'pipe=', -+ 'port=', 'server=', 'timeout=', 'show', 'stdout', -+ 'template', 'verbose', 'version'] ) - except getopt.error, exc: - print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc) - sys.exit(255) -@@ -382,8 +382,11 @@ - self.importfilter = arg - elif opt in ['-l', '--listener']: - self.listener = True -- elif opt in ['-o', '--outputpath']: -- self.outputpath = arg -+ elif opt in ['-o', '--output']: -+ self.output = arg -+ elif opt in ['--outputpath']: -+ print >>sys.stderr, 'Warning: This option is deprecated by --output.' % arg -+ self.output = arg - elif opt in ['--pipe']: - self.pipe = arg - elif opt in ['-p', '--port']: -@@ -474,7 +477,7 @@ - -i, --import=string set import filter option string - eg. -i utf8 - -l, --listener start a listener to use by unoconv clients -- -o, --outputpath=name output directory -+ -o, --output=name output basename, filename or directory - --pipe=name alternative method of connection using a pipe - -p, --port=port specify the port (default: 2002) - to be used by client or listener -@@ -656,10 +659,15 @@ - - if not op.stdout: - (outputfn, ext) = os.path.splitext(inputfn) -- if not op.outputpath: -+ if not op.output: - outputfn = outputfn + os.extsep + outputfmt.extension -+ elif os.path.isdir(op.output): -+ outputfn = os.path.join(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension) -+ elif len(op.filenames) > 1: -+ outputfn = op.output + os.extsep + outputfmt.extension - else: -- outputfn = os.path.join(op.outputpath, os.path.basename(outputfn) + os.extsep + outputfmt.extension) -+ outputfn = op.output -+ - outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) - doc.storeToURL(outputurl, tuple(outputprops) ) - info(1, "Output file: %s" % outputfn) diff --git a/unoconv.spec b/unoconv.spec index 001869a..0dbf367 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,18 +1,11 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv -Version: 0.4 -Release: 6%{?dist} +Version: 0.5 +Release: 1%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.bz2 -# Allow -o flag to output to files -Patch0: unoconv-output-files.patch -# Fix LD_LIBRARY_PATH handling. From upstream trunk -Patch1: unoconv-ld-path.patch -# Fedora's libreoffice does not have --nocrashreport option -# https://github.com/dagwieers/unoconv/issues/45 -Patch2: unoconv-nocrashreport.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch @@ -35,9 +28,6 @@ RTF, Docbook (.xml), and more. %prep %setup -q -%patch0 -p3 -b .o_flag -%patch1 -p3 -b .ld_library_path -%patch2 -p1 -b .nocrashreport %build @@ -50,11 +40,14 @@ rm -rf %{buildroot} %files %defattr(-, root, root, -) -%doc AUTHORS ChangeLog COPYING README TODO WISHLIST docs/ tests/ +%doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST docs/ tests/ %{_mandir}/man1/%{name}.1* %{_bindir}/%{name} %changelog +* Mon Mar 26 2012 David Tardon - 0.5-1 +- new upstream release + * Mon Mar 26 2012 David Tardon - 0.4-6 * Sat Jan 14 2012 Fedora Release Engineering - 0.4-5 From 8fe1005ca4b68d214047527f124553a8c27fd8dd Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Sat, 21 Jul 2012 20:51:14 -0500 Subject: [PATCH 14/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 0dbf367..57d4985 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.5 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -45,6 +45,9 @@ rm -rf %{buildroot} %{_bindir}/%{name} %changelog +* Sun Jul 22 2012 Fedora Release Engineering - 0.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + * Mon Mar 26 2012 David Tardon - 0.5-1 - new upstream release From 6aa08a5f34733e11979573d2c3e91e8cab01cd13 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Sat, 28 Jul 2012 08:04:50 +0200 Subject: [PATCH 15/71] drop obsolete cruft --- unoconv.spec | 6 ------ 1 file changed, 6 deletions(-) diff --git a/unoconv.spec b/unoconv.spec index 57d4985..7d35cf6 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -6,7 +6,6 @@ License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.bz2 -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildArch: noarch %if 0%{fedora} < 15 @@ -32,14 +31,9 @@ RTF, Docbook (.xml), and more. %build %install -rm -rf %{buildroot} make install DESTDIR="%{buildroot}" -%clean -rm -rf %{buildroot} - %files -%defattr(-, root, root, -) %doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST docs/ tests/ %{_mandir}/man1/%{name}.1* %{_bindir}/%{name} From d72144cd87609d08c6b6364c24ec5aa48cd62be3 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Sat, 28 Jul 2012 08:05:28 +0200 Subject: [PATCH 16/71] F-15 is EOL --- unoconv.spec | 5 ----- 1 file changed, 5 deletions(-) diff --git a/unoconv.spec b/unoconv.spec index 7d35cf6..a8a1f0f 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -8,13 +8,8 @@ URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.bz2 BuildArch: noarch -%if 0%{fedora} < 15 -Requires: openoffice.org-brand -Requires: openoffice.org-pyuno -%else Requires: libreoffice-core Requires: libreoffice-pyuno -%endif %description unoconv converts between any document format that LibreOffice understands. From 858ace99c1d2e2a31bc6940a25537ab596cb8717 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Mon, 5 Nov 2012 15:02:53 +0100 Subject: [PATCH 17/71] new upstream release --- .gitignore | 1 + sources | 2 +- unoconv.spec | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index dcbb5d7..fad94ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ unoconv-0.3.tar.bz2 /unoconv-0.4.tar.bz2 /unoconv-0.5.tar.bz2 +/unoconv-0.6.tar.gz diff --git a/sources b/sources index c071b87..23edf65 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -09a02fe3d258dd332826569026f84d6f unoconv-0.5.tar.bz2 +eeda0d358ce4bacd5dd84303012c416d unoconv-0.6.tar.gz diff --git a/unoconv.spec b/unoconv.spec index a8a1f0f..d9196d6 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,11 +1,11 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv -Version: 0.5 -Release: 2%{?dist} +Version: 0.6 +Release: 1%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ -Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.bz2 +Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz BuildArch: noarch Requires: libreoffice-core @@ -29,11 +29,14 @@ RTF, Docbook (.xml), and more. make install DESTDIR="%{buildroot}" %files -%doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST docs/ tests/ +%doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST doc/*.txt tests/ %{_mandir}/man1/%{name}.1* %{_bindir}/%{name} %changelog +* Mon Nov 05 2012 David Tardon - 0.6-1 +- new upstream release + * Sun Jul 22 2012 Fedora Release Engineering - 0.5-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild From 373013bf8c37d408763c5f3ac7f848a448a9750c Mon Sep 17 00:00:00 2001 From: David Tardon Date: Mon, 5 Nov 2012 15:18:51 +0100 Subject: [PATCH 18/71] update FSF address in COPYING --- 0001-update-FSF-address.patch | 147 ++++++++++++++++++++++++++++++++++ unoconv.spec | 2 + 2 files changed, 149 insertions(+) create mode 100644 0001-update-FSF-address.patch diff --git a/0001-update-FSF-address.patch b/0001-update-FSF-address.patch new file mode 100644 index 0000000..925cf4f --- /dev/null +++ b/0001-update-FSF-address.patch @@ -0,0 +1,147 @@ +From 4be0b90f1935120e4f9196b6fc126248079cbf11 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Mon, 5 Nov 2012 15:08:24 +0100 +Subject: [PATCH] update FSF address + +--- + COPYING | 41 ++++++++++++++++++++--------------------- + unoconv | 3 ++- + 2 files changed, 22 insertions(+), 22 deletions(-) + +diff --git a/COPYING b/COPYING +index d60c31a..d159169 100644 +--- a/COPYING ++++ b/COPYING +@@ -1,12 +1,12 @@ +- GNU GENERAL PUBLIC LICENSE +- Version 2, June 1991 ++ GNU GENERAL PUBLIC LICENSE ++ Version 2, June 1991 + +- Copyright (C) 1989, 1991 Free Software Foundation, Inc. +- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ Copyright (C) 1989, 1991 Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +- Preamble ++ Preamble + + The licenses for most software are designed to take away your + freedom to share and change it. By contrast, the GNU General Public +@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This + General Public License applies to most of the Free Software + Foundation's software and to any other program whose authors commit to + using it. (Some other Free Software Foundation software is covered by +-the GNU Library General Public License instead.) You can apply it to ++the GNU Lesser General Public License instead.) You can apply it to + your programs, too. + + When we speak of free software, we are referring to freedom, not +@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and + modification follow. +- +- GNU GENERAL PUBLIC LICENSE ++ ++ GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) +- ++ + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Program, + and can be reasonably considered independent and separate works in +@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. +- ++ + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is +@@ -225,7 +225,7 @@ impose that choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. +- ++ + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License +@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals + of preserving the free status of all derivatives of our free software and + of promoting the sharing and reuse of software generally. + +- NO WARRANTY ++ NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER + PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + +- END OF TERMS AND CONDITIONS +- +- How to Apply These Terms to Your New Programs ++ END OF TERMS AND CONDITIONS ++ ++ How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest + possible use to the public, the best way to achieve this is to make it +@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +- You should have received a copy of the GNU General Public License +- along with this program; if not, write to the Free Software +- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +- ++ You should have received a copy of the GNU General Public License along ++ with this program; if not, write to the Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Also add information on how to contact you by electronic and paper mail. + + If the program is interactive, make it output a short notice like this + when it starts in an interactive mode: + +- Gnomovision version 69, Copyright (C) year name of author ++ Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. +@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names: + This General Public License does not permit incorporating your program into + proprietary programs. If your program is a subroutine library, you may + consider it more useful to permit linking proprietary applications with the +-library. If this is what you want to do, use the GNU Library General ++library. If this is what you want to do, use the GNU Lesser General + Public License instead of this License. +diff --git a/unoconv b/unoconv +index 30e6706..e4a1ac8 100755 +--- a/unoconv ++++ b/unoconv +@@ -11,7 +11,8 @@ + ### + ### You should have received a copy of the GNU General Public License + ### along with this program; if not, write to the Free Software +-### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++### MA 02110-1301 USA. + ### Copyright 2007-2010 Dag Wieers + + from distutils.version import LooseVersion +-- +1.7.11.7 + diff --git a/unoconv.spec b/unoconv.spec index d9196d6..4b36144 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -6,6 +6,7 @@ License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz +Patch0: 0001-update-FSF-address.patch BuildArch: noarch Requires: libreoffice-core @@ -22,6 +23,7 @@ RTF, Docbook (.xml), and more. %prep %setup -q +%patch0 -p1 %build From c94818583fe08e38daf46022b6fa24dcf62ff644 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Thu, 14 Feb 2013 20:29:36 -0600 Subject: [PATCH 19/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 4b36144..2a4052c 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -36,6 +36,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Fri Feb 15 2013 Fedora Release Engineering - 0.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + * Mon Nov 05 2012 David Tardon - 0.6-1 - new upstream release From 2275d98e63668db885f0b82282dcb1df07371ca5 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Mon, 8 Apr 2013 09:43:51 +0200 Subject: [PATCH 20/71] Resolves: rhbz#947096 unoconv doesn't work with Libreoffice 4.0 --- ...ort-option-and-add-V-as-alternative-.patch | 38 + 0001-python3-added-compatibility.patch | 3628 +++++++++++++++++ 0001-update-FSF-address.patch | 28 + unoconv.spec | 16 +- 4 files changed, 3708 insertions(+), 2 deletions(-) create mode 100644 0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch create mode 100644 0001-python3-added-compatibility.patch diff --git a/0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch b/0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch new file mode 100644 index 0000000..264a279 --- /dev/null +++ b/0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch @@ -0,0 +1,38 @@ +From 3c20d6ec49a97c24cfb1fe9fd61ac80944819088 Mon Sep 17 00:00:00 2001 +From: Dag Wieers +Date: Fri, 28 Sep 2012 19:33:01 +0200 +Subject: [PATCH] Fix a broken --export option and add -V as alternative to + --version + +This closes #93. +--- + unoconv | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/unoconv b/unoconv +index 972e962..30e6706 100755 +--- a/unoconv ++++ b/unoconv +@@ -524,8 +524,8 @@ class Options: + + ### Get options from the commandline + try: +- opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:v', +- ['connection=', 'debug', 'doctype=', 'export', 'format=', ++ opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:vV', ++ ['connection=', 'debug', 'doctype=', 'export=', 'format=', + 'help', 'import', 'listener', 'no-launch', 'output=', + 'outputpath', 'password=', 'pipe=', 'port=', 'server=', + 'timeout=', 'show', 'stdout', 'template', 'verbose', +@@ -609,7 +609,7 @@ class Options: + self.timeout = int(arg) + elif opt in ['-v', '--verbose']: + self.verbose = self.verbose + 1 +- elif opt in ['--version']: ++ elif opt in ['-V', '--version']: + self.version() + sys.exit(255) + +-- +1.7.11.7 + diff --git a/0001-python3-added-compatibility.patch b/0001-python3-added-compatibility.patch new file mode 100644 index 0000000..c788e2d --- /dev/null +++ b/0001-python3-added-compatibility.patch @@ -0,0 +1,3628 @@ +From 6eba87f4654d3f142070c1fe9f272bf787885861 Mon Sep 17 00:00:00 2001 +From: Andres Gomez +Date: Thu, 4 Apr 2013 13:18:06 +0300 +Subject: [PATCH] python3: added compatibility + +Dodgy solution in which we create a python2 and +python3 compatible wrapper that would import the +old script, or a new automatically migrated +version. + +The automatic migration was done with the 2to3 +tool after modifying the original script so we can +invoke it as a module. + +This is needed since LibreOffice is providing its +own python3 bundled package since 4.x series. +--- + Makefile | 2 + + packaging/rpm/unoconv.spec | 2 + + unoconv | 1154 +----------------------------------------- + unoconv2.py | 1195 ++++++++++++++++++++++++++++++++++++++++++++ + unoconv3.py | 1195 ++++++++++++++++++++++++++++++++++++++++++++ + 5 files changed, 2406 insertions(+), 1142 deletions(-) + create mode 100755 unoconv2.py + create mode 100755 unoconv3.py + +diff --git a/Makefile b/Makefile +index 9bb18f6..b950583 100644 +--- a/Makefile ++++ b/Makefile +@@ -111,6 +111,8 @@ install: + install -d -m0755 $(DESTDIR)$(bindir) + install -d -m0755 $(DESTDIR)$(mandir)/man1/ + install -p -m0755 unoconv $(DESTDIR)$(bindir)/unoconv ++ install -p -m0755 unoconv2.py $(DESTDIR)$(bindir)/unoconv2.py ++ install -p -m0755 unoconv3.py $(DESTDIR)$(bindir)/unoconv3.py + install -p -m0644 doc/unoconv.1 $(DESTDIR)$(mandir)/man1/unoconv.1 + + install-links: $(links) +diff --git a/packaging/rpm/unoconv.spec b/packaging/rpm/unoconv.spec +index 4801dd3..c077fec 100644 +--- a/packaging/rpm/unoconv.spec ++++ b/packaging/rpm/unoconv.spec +@@ -49,6 +49,8 @@ and many more... + %doc AUTHORS ChangeLog COPYING README* WISHLIST doc/ tests/ + %doc %{_mandir}/man1/unoconv.1* + %{_bindir}/unoconv ++%{_bindir}/unoconv2.py ++%{_bindir}/unoconv3.py + + %changelog + * Mon Sep 10 2012 Dag Wieers - 0.6-1 +diff --git a/unoconv b/unoconv +index 30e6706..ed603af 100755 +--- a/unoconv ++++ b/unoconv +@@ -12,1154 +12,24 @@ + ### You should have received a copy of the GNU General Public License + ### along with this program; if not, write to the Free Software + ### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-### Copyright 2007-2010 Dag Wieers + +-from distutils.version import LooseVersion +-import getopt +-import glob +-import os +-import subprocess + import sys +-import time + +-__version__ = "$Revision$" +-# $Source$ ++### Extremely dodgy solution for running python2 or python3 versions ++### of the unoconv script + +-VERSION = '0.6' ++### This is needed since LibreOffice is providing its own python3 ++### bundled package since 4.x series + +-doctypes = ('document', 'graphics', 'presentation', 'spreadsheet') ++### A much more proper solution would be to modify the code so it ++### would be compatible with both versions or, if not possible, to ++### create real python modules out of the code and import them in a ++### proper way + +-global convertor, office, ooproc, product +-ooproc = None +-exitcode = 0 +- +-class Office: +- def __init__(self, basepath, urepath, unopath, pyuno, binary, python, pythonhome): +- self.basepath = basepath +- self.urepath = urepath +- self.unopath = unopath +- self.pyuno = pyuno +- self.binary = binary +- self.python = python +- self.pythonhome = pythonhome +- +- def __str__(self): +- return self.basepath +- +- def __repr__(self): +- return self.basepath +- +-### Implement a path normalizer in order to make unoconv work on MacOS X +-### (on which 'program' is a symlink to 'MacOSX' which seems to break unoconv) +-def realpath(*args): +- ''' Implement a combination of os.path.join(), os.path.abspath() and +- os.path.realpath() in order to normalize path constructions ''' +- ret = '' +- for arg in args: +- ret = os.path.join(ret, arg) +- return os.path.realpath(os.path.abspath(ret)) +- +-### The first thing we ought to do is find a suitable Office installation +-### with a compatible pyuno library that we can import. +-### +-### See: http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=36370&p=166783 +- +-def find_offices(): +- ret = [] +- extrapaths = [] +- +- ### Try using UNO_PATH first (in many incarnations, we'll see what sticks) +- if 'UNO_PATH' in os.environ: +- extrapaths += [ os.environ['UNO_PATH'], +- os.path.dirname(os.environ['UNO_PATH']), +- os.path.dirname(os.path.dirname(os.environ['UNO_PATH'])) ] +- +- else: +- +- if os.name in ( 'nt', 'os2' ): +- if 'PROGRAMFILES' in os.environ.keys(): +- extrapaths += glob.glob(os.environ['PROGRAMFILES']+'\\LibreOffice*') + \ +- glob.glob(os.environ['PROGRAMFILES']+'\\OpenOffice.org*') +- +- if 'PROGRAMFILES(X86)' in os.environ.keys(): +- extrapaths += glob.glob(os.environ['PROGRAMFILES(X86)']+'\\LibreOffice*') + \ +- glob.glob(os.environ['PROGRAMFILES(X86)']+'\\OpenOffice.org*') +- +- elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): +- extrapaths += [ '/Applications/LibreOffice.app/Contents', +- '/Applications/NeoOffice.app/Contents', +- '/Applications/OpenOffice.org.app/Contents' ] +- +- else: +- extrapaths += glob.glob('/usr/lib*/libreoffice*') + \ +- glob.glob('/usr/lib*/openoffice*') + \ +- glob.glob('/usr/lib*/ooo*') + \ +- glob.glob('/opt/libreoffice*') + \ +- glob.glob('/opt/openoffice*') + \ +- glob.glob('/opt/ooo*') + \ +- glob.glob('/usr/local/libreoffice*') + \ +- glob.glob('/usr/local/openoffice*') + \ +- glob.glob('/usr/local/ooo*') + \ +- glob.glob('/usr/local/lib/libreoffice*') +- +- ### Find a working set for python UNO bindings +- for basepath in extrapaths: +- if os.name in ( 'nt', 'os2' ): +- officelibraries = ( 'pyuno.pyd', ) +- officebinaries = ( 'soffice.exe' ,) +- pythonbinaries = ( 'python.exe', ) +- pythonhomes = () +- elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): +- officelibraries = ( 'pyuno.so', 'libpyuno.dylib' ) +- officebinaries = ( 'soffice.bin', ) +- pythonbinaries = ( 'python.bin', 'python' ) +- pythonhomes = ( 'OOoPython.framework/Versions/*/lib/python*', ) +- else: +- officelibraries = ( 'pyuno.so', ) +- officebinaries = ( 'soffice.bin', ) +- pythonbinaries = ( 'python.bin', 'python', ) +- pythonhomes = ( 'python-core-*', ) +- +- ### Older LibreOffice/OpenOffice and Windows use basis-link/ or basis/ +- libpath = 'error' +- for basis in ( 'basis-link', 'basis', '' ): +- for lib in officelibraries: +- if os.path.isfile(realpath(basepath, basis, 'program', lib)): +- libpath = realpath(basepath, basis, 'program') +- officelibrary = realpath(libpath, lib) +- info(3, "Found %s in %s" % (lib, libpath)) +- # Break the inner loop... +- break +- # Continue if the inner loop wasn't broken. +- else: +- continue +- # Inner loop was broken, break the outer. +- break +- else: +- continue +- +- ### MacOSX have soffice binaries installed in MacOS subdirectory, not program +- unopath = 'error' +- for basis in ( 'basis-link', 'basis', '' ): +- for bin in officebinaries: +- if os.path.isfile(realpath(basepath, basis, 'program', bin)): +- unopath = realpath(basepath, basis, 'program') +- officebinary = realpath(unopath, bin) +- info(3, "Found %s in %s" % (bin, unopath)) +- # Break the inner loop... +- break +- # Continue if the inner loop wasn't broken. +- else: +- continue +- # Inner loop was broken, break the outer. +- break +- else: +- continue +- +- ### Windows does not provide or need a URE/lib directory ? +- urepath = '' +- for basis in ( 'basis-link', 'basis', '' ): +- for ure in ( 'ure-link', 'ure', 'URE', '' ): +- if os.path.isfile(realpath(basepath, basis, ure, 'lib', 'unorc')): +- urepath = realpath(basepath, basis, ure) +- info(3, "Found %s in %s" % ('unorc', realpath(urepath, 'lib'))) +- # Break the inner loop... +- break +- # Continue if the inner loop wasn't broken. +- else: +- continue +- # Inner loop was broken, break the outer. +- break +- +- pythonhome = None +- for home in pythonhomes: +- if glob.glob(realpath(libpath, home)): +- pythonhome = glob.glob(realpath(libpath, home))[0] +- info(3, "Found %s in %s" % (home, pythonhome)) +- break +- +-# if not os.path.isfile(realpath(basepath, program, officebinary)): +-# continue +-# info(3, "Found %s in %s" % (officebinary, realpath(basepath, program))) +- +-# if not glob.glob(realpath(basepath, basis, program, 'python-core-*')): +-# continue +- +- for pythonbinary in pythonbinaries: +- if os.path.isfile(realpath(unopath, pythonbinary)): +- info(3, "Found %s in %s" % (pythonbinary, unopath)) +- ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, +- realpath(unopath, pythonbinary), pythonhome)) +- else: +- info(3, "Considering %s" % basepath) +- ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, +- sys.executable, None)) +- return ret +- +-def office_environ(office): +- ### Set PATH so that crash_report is found +- os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH'] +- +- ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: +- os.environ['UNO_PATH'] = office.unopath +- +- ### Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete +- ### UNO environment +- if os.name in ( 'nt', 'os2' ): +- os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') +- else: +- os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamentalrc') +- +- ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: +- if 'LD_LIBRARY_PATH' in os.environ: +- os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ +- realpath(office.urepath, 'lib') + os.pathsep + \ +- os.environ['LD_LIBRARY_PATH'] +- else: +- os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ +- realpath(office.urepath, 'lib') +- +- if office.pythonhome: +- for libpath in ( realpath(office.pythonhome, 'lib'), +- realpath(office.pythonhome, 'lib', 'lib-dynload'), +- realpath(office.pythonhome, 'lib', 'lib-tk'), +- realpath(office.pythonhome, 'lib', 'site-packages'), +- office.unopath): +- sys.path.insert(0, libpath) +- else: +- ### Still needed for system python using LibreOffice UNO bindings +- ### Although we prefer to use a system UNO binding in this case +- sys.path.append(office.unopath) +- +-def debug_office(): +- if 'URE_BOOTSTRAP' in os.environ: +- print >>sys.stderr, 'URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'] +- if 'UNO_PATH' in os.environ: +- print >>sys.stderr, 'UNO_PATH=%s' % os.environ['UNO_PATH'] +- if 'UNO_TYPES' in os.environ: +- print >>sys.stderr, 'UNO_TYPES=%s' % os.environ['UNO_TYPES'] +- print 'PATH=%s' % os.environ['PATH'] +- if 'PYTHONHOME' in os.environ: +- print >>sys.stderr, 'PYTHONHOME=%s' % os.environ['PYTHONHOME'] +- if 'PYTHONPATH' in os.environ: +- print >>sys.stderr, 'PYTHONPATH=%s' % os.environ['PYTHONPATH'] +- if 'LD_LIBRARY_PATH' in os.environ: +- print >>sys.stderr, 'LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'] +- +-def python_switch(office): +- if office.pythonhome: +- os.environ['PYTHONHOME'] = office.pythonhome +- os.environ['PYTHONPATH'] = realpath(office.pythonhome, 'lib') + os.pathsep + \ +- realpath(office.pythonhome, 'lib', 'lib-dynload') + os.pathsep + \ +- realpath(office.pythonhome, 'lib', 'lib-tk') + os.pathsep + \ +- realpath(office.pythonhome, 'lib', 'site-packages') + os.pathsep + \ +- office.unopath +- +- os.environ['UNO_PATH'] = office.unopath +- +- info(3, "-> Switching from %s to %s" % (sys.executable, office.python)) +- if os.name in ('nt', 'os2'): +- ### os.execv is broken on Windows and can't properly parse command line +- ### arguments and executable name if they contain whitespaces. subprocess +- ### fixes that behavior. +- ret = subprocess.call([office.python] + sys.argv[0:]) +- sys.exit(ret) +- else: +- +- ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: +- if 'LD_LIBRARY_PATH' in os.environ: +- os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ +- realpath(office.urepath, 'lib') + os.pathsep + \ +- os.environ['LD_LIBRARY_PATH'] +- else: +- os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ +- realpath(office.urepath, 'lib') +- +- try: +- os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) +- except OSError: +- ### Mac OS X versions prior to 10.6 do not support execv in +- ### a process that contains multiple threads. Instead of +- ### re-executing in the current process, start a new one +- ### and cause the current process to exit. This isn't +- ### ideal since the new process is detached from the parent +- ### terminal and thus cannot easily be killed with ctrl-C, +- ### but it's better than not being able to autoreload at +- ### all. +- ### Unfortunately the errno returned in this case does not +- ### appear to be consistent, so we can't easily check for +- ### this error specifically. +- ret = os.spawnvpe(os.P_WAIT, office.python, [office.python, ] + sys.argv[0:], os.environ) +- sys.exit(ret) +- +-class Fmt: +- def __init__(self, doctype, name, extension, summary, filter): +- self.doctype = doctype +- self.name = name +- self.extension = extension +- self.summary = summary +- self.filter = filter +- +- def __str__(self): +- return "%s [.%s]" % (self.summary, self.extension) +- +- def __repr__(self): +- return "%s/%s" % (self.name, self.doctype) +- +-class FmtList: +- def __init__(self): +- self.list = [] +- +- def add(self, doctype, name, extension, summary, filter): +- self.list.append(Fmt(doctype, name, extension, summary, filter)) +- +- def byname(self, name): +- ret = [] +- for fmt in self.list: +- if fmt.name == name: +- ret.append(fmt) +- return ret +- +- def byextension(self, extension): +- ret = [] +- for fmt in self.list: +- if os.extsep + fmt.extension == extension: +- ret.append(fmt) +- return ret +- +- def bydoctype(self, doctype, name): +- ret = [] +- for fmt in self.list: +- if fmt.name == name and fmt.doctype == doctype: +- ret.append(fmt) +- return ret +- +- def display(self, doctype): +- print >>sys.stderr, "The following list of %s formats are currently available:\n" % doctype +- for fmt in self.list: +- if fmt.doctype == doctype: +- print >>sys.stderr, " %-8s - %s" % (fmt.name, fmt) +- print >>sys.stderr +- +-fmts = FmtList() +- +-### TextDocument +-fmts.add('document', 'bib', 'bib', 'BibTeX', 'BibTeX_Writer') ### 22 +-fmts.add('document', 'doc', 'doc', 'Microsoft Word 97/2000/XP', 'MS Word 97') ### 29 +-fmts.add('document', 'doc6', 'doc', 'Microsoft Word 6.0', 'MS WinWord 6.0') ### 24 +-fmts.add('document', 'doc95', 'doc', 'Microsoft Word 95', 'MS Word 95') ### 28 +-fmts.add('document', 'docbook', 'xml', 'DocBook', 'DocBook File') ### 39 +-fmts.add('document', 'docx', 'docx', 'Microsoft Office Open XML', 'Office Open XML Text') +-fmts.add('document', 'docx7', 'docx', 'Microsoft Office Open XML', 'MS Word 2007 XML') +-fmts.add('document', 'fodt', 'fodt', 'OpenDocument Text (Flat XML)', 'OpenDocument Text Flat XML') +-fmts.add('document', 'html', 'html', 'HTML Document (OpenOffice.org Writer)', 'HTML (StarWriter)') ### 3 +-fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'LaTeX_Writer') ### 31 +-fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') +-fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 +-fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 +-fmts.add('document', 'ott', 'ott', 'Open Document Text', 'writer8_template') ### 21 +-fmts.add('document', 'pdb', 'pdb', 'AportisDoc (Palm)', 'AportisDoc Palm DB') +-fmts.add('document', 'pdf', 'pdf', 'Portable Document Format', 'writer_pdf_Export') ### 18 +-fmts.add('document', 'psw', 'psw', 'Pocket Word', 'PocketWord File') +-fmts.add('document', 'rtf', 'rtf', 'Rich Text Format', 'Rich Text Format') ### 16 +-fmts.add('document', 'sdw', 'sdw', 'StarWriter 5.0', 'StarWriter 5.0') ### 23 +-fmts.add('document', 'sdw4', 'sdw', 'StarWriter 4.0', 'StarWriter 4.0') ### 2 +-fmts.add('document', 'sdw3', 'sdw', 'StarWriter 3.0', 'StarWriter 3.0') ### 20 +-fmts.add('document', 'stw', 'stw', 'Open Office.org 1.0 Text Document Template', 'writer_StarOffice_XML_Writer_Template') ### 9 +-fmts.add('document', 'sxw', 'sxw', 'Open Office.org 1.0 Text Document', 'StarOffice XML (Writer)') ### 1 +-fmts.add('document', 'text', 'txt', 'Text Encoded', 'Text (encoded)') ### 26 +-fmts.add('document', 'txt', 'txt', 'Text', 'Text') ### 34 +-fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### 27 +-fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 +-fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 +-fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 +-fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 +- +-### WebDocument +-fmts.add('web', 'etext', 'txt', 'Text Encoded (OpenOffice.org Writer/Web)', 'Text (encoded) (StarWriter/Web)') ### 14 +-fmts.add('web', 'html10', 'html', 'OpenOffice.org 1.0 HTML Template', 'writer_web_StarOffice_XML_Writer_Web_Template') ### 11 +-fmts.add('web', 'html', 'html', 'HTML Document', 'HTML') ### 2 +-fmts.add('web', 'html', 'html', 'HTML Document Template', 'writerweb8_writer_template') ### 13 +-fmts.add('web', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki_Web') ### 9 +-fmts.add('web', 'pdf', 'pdf', 'PDF - Portable Document Format', 'writer_web_pdf_Export') ### 10 +-fmts.add('web', 'sdw3', 'sdw', 'StarWriter 3.0 (OpenOffice.org Writer/Web)', 'StarWriter 3.0 (StarWriter/Web)') ### 3 +-fmts.add('web', 'sdw4', 'sdw', 'StarWriter 4.0 (OpenOffice.org Writer/Web)', 'StarWriter 4.0 (StarWriter/Web)') ### 4 +-fmts.add('web', 'sdw', 'sdw', 'StarWriter 5.0 (OpenOffice.org Writer/Web)', 'StarWriter 5.0 (StarWriter/Web)') ### 5 +-fmts.add('web', 'txt', 'txt', 'OpenOffice.org Text (OpenOffice.org Writer/Web)', 'writerweb8_writer') ### 12 +-fmts.add('web', 'text10', 'txt', 'OpenOffice.org 1.0 Text Document (OpenOffice.org Writer/Web)', 'writer_web_StarOffice_XML_Writer') ### 15 +-fmts.add('web', 'text', 'txt', 'Text (OpenOffice.org Writer/Web)', 'Text (StarWriter/Web)') ### 8 +-fmts.add('web', 'vor4', 'vor', 'StarWriter/Web 4.0 Template', 'StarWriter/Web 4.0 Vorlage/Template') ### 6 +-fmts.add('web', 'vor', 'vor', 'StarWriter/Web 5.0 Template', 'StarWriter/Web 5.0 Vorlage/Template') ### 7 +- +-### Spreadsheet +-fmts.add('spreadsheet', 'csv', 'csv', 'Text CSV', 'Text - txt - csv (StarCalc)') ### 16 +-fmts.add('spreadsheet', 'dbf', 'dbf', 'dBASE', 'dBase') ### 22 +-fmts.add('spreadsheet', 'dif', 'dif', 'Data Interchange Format', 'DIF') ### 5 +-fmts.add('spreadsheet', 'fods', 'fods', 'OpenDocument Spreadsheet (Flat XML)', 'OpenDocument Spreadsheet Flat XML') +-fmts.add('spreadsheet', 'html', 'html', 'HTML Document (OpenOffice.org Calc)', 'HTML (StarCalc)') ### 7 +-fmts.add('spreadsheet', 'ods', 'ods', 'ODF Spreadsheet', 'calc8') ### 15 +-fmts.add('spreadsheet', 'ooxml', 'xml', 'Microsoft Excel 2003 XML', 'MS Excel 2003 XML') ### 23 +-fmts.add('spreadsheet', 'ots', 'ots', 'ODF Spreadsheet Template', 'calc8_template') ### 14 +-fmts.add('spreadsheet', 'pdf', 'pdf', 'Portable Document Format', 'calc_pdf_Export') ### 34 +-fmts.add('spreadsheet', 'pxl', 'pxl', 'Pocket Excel', 'Pocket Excel') +-fmts.add('spreadsheet', 'sdc', 'sdc', 'StarCalc 5.0', 'StarCalc 5.0') ### 31 +-fmts.add('spreadsheet', 'sdc4', 'sdc', 'StarCalc 4.0', 'StarCalc 4.0') ### 11 +-fmts.add('spreadsheet', 'sdc3', 'sdc', 'StarCalc 3.0', 'StarCalc 3.0') ### 29 +-fmts.add('spreadsheet', 'slk', 'slk', 'SYLK', 'SYLK') ### 35 +-fmts.add('spreadsheet', 'stc', 'stc', 'OpenOffice.org 1.0 Spreadsheet Template', 'calc_StarOffice_XML_Calc_Template') ### 2 +-fmts.add('spreadsheet', 'sxc', 'sxc', 'OpenOffice.org 1.0 Spreadsheet', 'StarOffice XML (Calc)') ### 3 +-fmts.add('spreadsheet', 'uos', 'uos', 'Unified Office Format spreadsheet', 'UOF spreadsheet') ### 9 +-fmts.add('spreadsheet', 'vor3', 'vor', 'StarCalc 3.0 Template', 'StarCalc 3.0 Vorlage/Template') ### 18 +-fmts.add('spreadsheet', 'vor4', 'vor', 'StarCalc 4.0 Template', 'StarCalc 4.0 Vorlage/Template') ### 19 +-fmts.add('spreadsheet', 'vor', 'vor', 'StarCalc 5.0 Template', 'StarCalc 5.0 Vorlage/Template') ### 20 +-fmts.add('spreadsheet', 'xhtml', 'xhtml', 'XHTML', 'XHTML Calc File') ### 26 +-fmts.add('spreadsheet', 'xls', 'xls', 'Microsoft Excel 97/2000/XP', 'MS Excel 97') ### 12 +-fmts.add('spreadsheet', 'xls5', 'xls', 'Microsoft Excel 5.0', 'MS Excel 5.0/95') ### 8 +-fmts.add('spreadsheet', 'xls95', 'xls', 'Microsoft Excel 95', 'MS Excel 95') ### 10 +-fmts.add('spreadsheet', 'xlt', 'xlt', 'Microsoft Excel 97/2000/XP Template', 'MS Excel 97 Vorlage/Template') ### 6 +-fmts.add('spreadsheet', 'xlt5', 'xlt', 'Microsoft Excel 5.0 Template', 'MS Excel 5.0/95 Vorlage/Template') ### 28 +-fmts.add('spreadsheet', 'xlt95', 'xlt', 'Microsoft Excel 95 Template', 'MS Excel 95 Vorlage/Template') ### 21 +- +-### Graphics +-fmts.add('graphics', 'bmp', 'bmp', 'Windows Bitmap', 'draw_bmp_Export') ### 21 +-fmts.add('graphics', 'emf', 'emf', 'Enhanced Metafile', 'draw_emf_Export') ### 15 +-fmts.add('graphics', 'eps', 'eps', 'Encapsulated PostScript', 'draw_eps_Export') ### 48 +-fmts.add('graphics', 'fodg', 'fodg', 'OpenDocument Drawing (Flat XML)', 'OpenDocument Drawing Flat XML') +-fmts.add('graphics', 'gif', 'gif', 'Graphics Interchange Format', 'draw_gif_Export') ### 30 +-fmts.add('graphics', 'html', 'html', 'HTML Document (OpenOffice.org Draw)', 'draw_html_Export') ### 37 +-fmts.add('graphics', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'draw_jpg_Export') ### 3 +-fmts.add('graphics', 'met', 'met', 'OS/2 Metafile', 'draw_met_Export') ### 43 +-fmts.add('graphics', 'odd', 'odd', 'OpenDocument Drawing', 'draw8') ### 6 +-fmts.add('graphics', 'otg', 'otg', 'OpenDocument Drawing Template', 'draw8_template') ### 20 +-fmts.add('graphics', 'pbm', 'pbm', 'Portable Bitmap', 'draw_pbm_Export') ### 14 +-fmts.add('graphics', 'pct', 'pct', 'Mac Pict', 'draw_pct_Export') ### 41 +-fmts.add('graphics', 'pdf', 'pdf', 'Portable Document Format', 'draw_pdf_Export') ### 28 +-fmts.add('graphics', 'pgm', 'pgm', 'Portable Graymap', 'draw_pgm_Export') ### 11 +-fmts.add('graphics', 'png', 'png', 'Portable Network Graphic', 'draw_png_Export') ### 2 +-fmts.add('graphics', 'ppm', 'ppm', 'Portable Pixelmap', 'draw_ppm_Export') ### 5 +-fmts.add('graphics', 'ras', 'ras', 'Sun Raster Image', 'draw_ras_Export') ## 31 +-fmts.add('graphics', 'std', 'std', 'OpenOffice.org 1.0 Drawing Template', 'draw_StarOffice_XML_Draw_Template') ### 53 +-fmts.add('graphics', 'svg', 'svg', 'Scalable Vector Graphics', 'draw_svg_Export') ### 50 +-fmts.add('graphics', 'svm', 'svm', 'StarView Metafile', 'draw_svm_Export') ### 55 +-fmts.add('graphics', 'swf', 'swf', 'Macromedia Flash (SWF)', 'draw_flash_Export') ### 23 +-fmts.add('graphics', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing', 'StarOffice XML (Draw)') ### 26 +-fmts.add('graphics', 'sxd3', 'sxd', 'StarDraw 3.0', 'StarDraw 3.0') ### 40 +-fmts.add('graphics', 'sxd5', 'sxd', 'StarDraw 5.0', 'StarDraw 5.0') ### 44 +-fmts.add('graphics', 'sxw', 'sxw', 'StarOffice XML (Draw)', 'StarOffice XML (Draw)') +-fmts.add('graphics', 'tiff', 'tiff', 'Tagged Image File Format', 'draw_tif_Export') ### 13 +-fmts.add('graphics', 'vor', 'vor', 'StarDraw 5.0 Template', 'StarDraw 5.0 Vorlage') ### 36 +-fmts.add('graphics', 'vor3', 'vor', 'StarDraw 3.0 Template', 'StarDraw 3.0 Vorlage') ### 35 +-fmts.add('graphics', 'wmf', 'wmf', 'Windows Metafile', 'draw_wmf_Export') ### 8 +-fmts.add('graphics', 'xhtml', 'xhtml', 'XHTML', 'XHTML Draw File') ### 45 +-fmts.add('graphics', 'xpm', 'xpm', 'X PixMap', 'draw_xpm_Export') ### 19 +- +-### Presentation +-fmts.add('presentation', 'bmp', 'bmp', 'Windows Bitmap', 'impress_bmp_Export') ### 15 +-fmts.add('presentation', 'emf', 'emf', 'Enhanced Metafile', 'impress_emf_Export') ### 16 +-fmts.add('presentation', 'eps', 'eps', 'Encapsulated PostScript', 'impress_eps_Export') ### 17 +-fmts.add('presentation', 'fodp', 'fodp', 'OpenDocument Presentation (Flat XML)', 'OpenDocument Presentation Flat XML') +-fmts.add('presentation', 'gif', 'gif', 'Graphics Interchange Format', 'impress_gif_Export') ### 18 +-fmts.add('presentation', 'html', 'html', 'HTML Document (OpenOffice.org Impress)', 'impress_html_Export') ### 43 +-fmts.add('presentation', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'impress_jpg_Export') ### 19 +-fmts.add('presentation', 'met', 'met', 'OS/2 Metafile', 'impress_met_Export') ### 20 +-fmts.add('presentation', 'odg', 'odg', 'ODF Drawing (Impress)', 'impress8_draw') ### 29 +-fmts.add('presentation', 'odp', 'odp', 'ODF Presentation', 'impress8') ### 9 +-fmts.add('presentation', 'otp', 'otp', 'ODF Presentation Template', 'impress8_template') ### 38 +-fmts.add('presentation', 'pbm', 'pbm', 'Portable Bitmap', 'impress_pbm_Export') ### 21 +-fmts.add('presentation', 'pct', 'pct', 'Mac Pict', 'impress_pct_Export') ### 22 +-fmts.add('presentation', 'pdf', 'pdf', 'Portable Document Format', 'impress_pdf_Export') ### 23 +-fmts.add('presentation', 'pgm', 'pgm', 'Portable Graymap', 'impress_pgm_Export') ### 24 +-fmts.add('presentation', 'png', 'png', 'Portable Network Graphic', 'impress_png_Export') ### 25 +-fmts.add('presentation', 'potm', 'potm', 'Microsoft PowerPoint 2007/2010 XML Template', 'Impress MS PowerPoint 2007 XML Template') +-fmts.add('presentation', 'pot', 'pot', 'Microsoft PowerPoint 97/2000/XP Template', 'MS PowerPoint 97 Vorlage') ### 3 +-fmts.add('presentation', 'ppm', 'ppm', 'Portable Pixelmap', 'impress_ppm_Export') ### 26 +-fmts.add('presentation', 'pptx', 'pptx', 'Microsoft PowerPoint 2007/2010 XML', 'Impress MS PowerPoint 2007 XML') ### 36 +-fmts.add('presentation', 'pps', 'pps', 'Microsoft PowerPoint 97/2000/XP (Autoplay)', 'MS PowerPoint 97 Autoplay') ### 36 +-fmts.add('presentation', 'ppt', 'ppt', 'Microsoft PowerPoint 97/2000/XP', 'MS PowerPoint 97') ### 36 +-fmts.add('presentation', 'pwp', 'pwp', 'PlaceWare', 'placeware_Export') ### 30 +-fmts.add('presentation', 'ras', 'ras', 'Sun Raster Image', 'impress_ras_Export') ### 27 +-fmts.add('presentation', 'sda', 'sda', 'StarDraw 5.0 (OpenOffice.org Impress)', 'StarDraw 5.0 (StarImpress)') ### 8 +-fmts.add('presentation', 'sdd', 'sdd', 'StarImpress 5.0', 'StarImpress 5.0') ### 6 +-fmts.add('presentation', 'sdd3', 'sdd', 'StarDraw 3.0 (OpenOffice.org Impress)', 'StarDraw 3.0 (StarImpress)') ### 42 +-fmts.add('presentation', 'sdd4', 'sdd', 'StarImpress 4.0', 'StarImpress 4.0') ### 37 +-fmts.add('presentation', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing (OpenOffice.org Impress)', 'impress_StarOffice_XML_Draw') ### 31 +-fmts.add('presentation', 'sti', 'sti', 'OpenOffice.org 1.0 Presentation Template', 'impress_StarOffice_XML_Impress_Template') ### 5 +-fmts.add('presentation', 'svg', 'svg', 'Scalable Vector Graphics', 'impress_svg_Export') ### 14 +-fmts.add('presentation', 'svm', 'svm', 'StarView Metafile', 'impress_svm_Export') ### 13 +-fmts.add('presentation', 'swf', 'swf', 'Macromedia Flash (SWF)', 'impress_flash_Export') ### 34 +-fmts.add('presentation', 'sxi', 'sxi', 'OpenOffice.org 1.0 Presentation', 'StarOffice XML (Impress)') ### 41 +-fmts.add('presentation', 'tiff', 'tiff', 'Tagged Image File Format', 'impress_tif_Export') ### 12 +-fmts.add('presentation', 'uop', 'uop', 'Unified Office Format presentation', 'UOF presentation') ### 4 +-fmts.add('presentation', 'vor', 'vor', 'StarImpress 5.0 Template', 'StarImpress 5.0 Vorlage') ### 40 +-fmts.add('presentation', 'vor3', 'vor', 'StarDraw 3.0 Template (OpenOffice.org Impress)', 'StarDraw 3.0 Vorlage (StarImpress)') ###1 +-fmts.add('presentation', 'vor4', 'vor', 'StarImpress 4.0 Template', 'StarImpress 4.0 Vorlage') ### 39 +-fmts.add('presentation', 'vor5', 'vor', 'StarDraw 5.0 Template (OpenOffice.org Impress)', 'StarDraw 5.0 Vorlage (StarImpress)') ### 2 +-fmts.add('presentation', 'wmf', 'wmf', 'Windows Metafile', 'impress_wmf_Export') ### 11 +-fmts.add('presentation', 'xhtml', 'xml', 'XHTML', 'XHTML Impress File') ### 33 +-fmts.add('presentation', 'xpm', 'xpm', 'X PixMap', 'impress_xpm_Export') ### 10 +- +-class Options: +- def __init__(self, args): +- self.connection = None +- self.debug = False +- self.doctype = None +- self.exportfilter = [] +- self.exportfilteroptions = "" +- self.filenames = [] +- self.format = None +- self.importfilter = [] +- self.importfilteroptions = "" +- self.listener = False +- self.nolaunch = False +- self.output = None +- self.password = None +- self.pipe = None +- self.port = '2002' +- self.server = '127.0.0.1' +- self.showlist = False +- self.stdout = False +- self.template = None +- self.timeout = 6 +- self.verbose = 0 +- +- ### Get options from the commandline +- try: +- opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:vV', +- ['connection=', 'debug', 'doctype=', 'export=', 'format=', +- 'help', 'import', 'listener', 'no-launch', 'output=', +- 'outputpath', 'password=', 'pipe=', 'port=', 'server=', +- 'timeout=', 'show', 'stdout', 'template', 'verbose', +- 'version'] ) +- except getopt.error, exc: +- print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc) +- sys.exit(255) +- +- for opt, arg in opts: +- if opt in ['-h', '--help']: +- self.usage() +- print +- self.help() +- sys.exit(1) +- elif opt in ['-c', '--connection']: +- self.connection = arg +- elif opt in ['--debug']: +- self.debug = True +- elif opt in ['-d', '--doctype']: +- self.doctype = arg +- elif opt in ['-e', '--export']: +- l = arg.split('=') +- if len(l) == 2: +- (name, value) = l +- if name in ('FilterOptions'): +- self.exportfilteroptions = value +- elif value in ('True', 'true'): +- self.exportfilter.append( PropertyValue( name, 0, True, 0 ) ) +- elif value in ('False', 'false'): +- self.exportfilter.append( PropertyValue( name, 0, False, 0 ) ) +- else: +- try: +- self.exportfilter.append( PropertyValue( name, 0, int(value), 0 ) ) +- except ValueError: +- self.exportfilter.append( PropertyValue( name, 0, value, 0 ) ) +- else: +- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg +- elif opt in ['-f', '--format']: +- self.format = arg +- elif opt in ['-i', '--import']: +- l = arg.split('=') +- if len(l) == 2: +- (name, value) = l +- if name in ('FilterOptions'): +- self.importfilteroptions = value +- elif value in ('True', 'true'): +- self.importfilter.append( PropertyValue( name, 0, True, 0 ) ) +- elif value in ('False', 'false'): +- self.importfilter.append( PropertyValue( name, 0, False, 0 ) ) +- else: +- try: +- self.importfilter.append( PropertyValue( name, 0, int(value), 0 ) ) +- except ValueError: +- self.importfilter.append( PropertyValue( name, 0, value, 0 ) ) +- else: +- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg +- elif opt in ['-l', '--listener']: +- self.listener = True +- elif opt in ['-n', '--no-launch']: +- self.nolaunch = True +- elif opt in ['-o', '--output']: +- self.output = arg +- elif opt in ['--outputpath']: +- print >>sys.stderr, 'Warning: This option is deprecated by --output.' +- self.output = arg +- elif opt in ['--password']: +- self.password = arg +- elif opt in ['--pipe']: +- self.pipe = arg +- elif opt in ['-p', '--port']: +- self.port = arg +- elif opt in ['-s', '--server']: +- self.server = arg +- elif opt in ['--show']: +- self.showlist = True +- elif opt in ['--stdout']: +- self.stdout = True +- elif opt in ['-t', '--template']: +- self.template = arg +- elif opt in ['-T', '--timeout']: +- self.timeout = int(arg) +- elif opt in ['-v', '--verbose']: +- self.verbose = self.verbose + 1 +- elif opt in ['-V', '--version']: +- self.version() +- sys.exit(255) +- +- ### Enable verbosity +- if self.verbose >= 2: +- print >>sys.stderr, 'Verbosity set to level %d' % self.verbose +- +- self.filenames = args +- +- if not self.listener and not self.showlist and self.doctype != 'list' and not self.filenames: +- print >>sys.stderr, 'unoconv: you have to provide a filename as argument' +- print >>sys.stderr, 'Try `unoconv -h\' for more information.' +- sys.exit(255) +- +- ### Set connection string +- if not self.connection: +- if not self.pipe: +- self.connection = "socket,host=%s,port=%s;urp;StarOffice.ComponentContext" % (self.server, self.port) +-# self.connection = "socket,host=%s,port=%s;urp;" % (self.server, self.port) +- else: +- self.connection = "pipe,name=%s;urp;StarOffice.ComponentContext" % (self.pipe) +- +- ### Make it easier for people to use a doctype (first letter is enough) +- if self.doctype: +- for doctype in doctypes: +- if doctype.startswith(self.doctype): +- self.doctype = doctype +- +- ### Check if the user request to see the list of formats +- if self.showlist or self.format == 'list': +- if self.doctype: +- fmts.display(self.doctype) +- else: +- for t in doctypes: +- fmts.display(t) +- sys.exit(0) +- +- ### If no format was specified, probe it or provide it +- if not self.format: +- l = sys.argv[0].split('2') +- if len(l) == 2: +- self.format = l[1] +- else: +- self.format = 'pdf' +- +- def version(self): +- ### Get office product information +- product = uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) +- +- print 'unoconv %s' % VERSION +- print 'Written by Dag Wieers ' +- print 'Homepage at http://dag.wieers.com/home-made/unoconv/' +- print +- print 'platform %s/%s' % (os.name, sys.platform) +- print 'python %s' % sys.version +- print product.ooName, product.ooSetupVersion +-# print +-# print 'build revision $Rev$' +- +- def usage(self): +- print >>sys.stderr, 'usage: unoconv [options] file [file2 ..]' +- +- def help(self): +- print >>sys.stderr, '''Convert from and to any format supported by LibreOffice +- +-unoconv options: +- -c, --connection=string use a custom connection string +- -d, --doctype=type specify document type +- (document, graphics, presentation, spreadsheet) +- -e, --export=name=value set export filter options +- eg. -e PageRange=1-2 +- -f, --format=format specify the output format +- -i, --import=string set import filter option string +- eg. -i utf8 +- -l, --listener start a permanent listener to use by unoconv clients +- -n, --no-launch fail if no listener is found (default: launch one) +- -o, --output=name output basename, filename or directory +- --pipe=name alternative method of connection using a pipe +- -p, --port=port specify the port (default: 2002) +- to be used by client or listener +- --password=string provide a password to decrypt the document +- -s, --server=server specify the server address (default: 127.0.0.1) +- to be used by client or listener +- --show list the available output formats +- --stdout write output to stdout +- -t, --template=file import the styles from template (.ott) +- -T, --timeout=secs timeout after secs if connection to listener fails +- -v, --verbose be more and more verbose (-vvv for debugging) +-''' +- +-class Convertor: +- def __init__(self): +- global exitcode, ooproc, office, product +- unocontext = None +- +- ### Do the LibreOffice component dance +- self.context = uno.getComponentContext() +- self.svcmgr = self.context.ServiceManager +- resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) +- +- ### Test for an existing connection +- info(3, 'Connection type: %s' % op.connection) +- try: +- unocontext = resolver.resolve("uno:%s" % op.connection) +- except NoConnectException, e: +-# info(3, "Existing listener not found.\n%s" % e) +- info(3, "Existing listener not found.") +- +- if op.nolaunch: +- die(113, "Existing listener not found. Unable start listener by parameters. Aborting.") +- +- ### Start our own OpenOffice instance +- info(3, "Launching our own listener using %s." % office.binary) +- try: +- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) +- if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): +- ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) +- else: +- ooproc = subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--accept=%s" % op.connection], env=os.environ) +- info(2, '%s listener successfully started. (pid=%s)' % (product.ooName, ooproc.pid)) +- +- ### Try connection to it for op.timeout seconds (flakky OpenOffice) +- timeout = 0 +- while timeout <= op.timeout: +- ### Is it already/still running ? +- retcode = ooproc.poll() +- if retcode != None: +- info(3, "Process %s (pid=%s) exited with %s." % (office.binary, ooproc.pid, retcode)) +- break +- try: +- unocontext = resolver.resolve("uno:%s" % op.connection) +- break +- except NoConnectException: +- time.sleep(0.5) +- timeout += 0.5 +- except: +- raise +- else: +- error("Failed to connect to %s (pid=%s) in %d seconds.\n%s" % (office.binary, ooproc.pid, op.timeout, e)) +- except Exception, e: +- raise +- error("Launch of %s failed.\n%s" % (office.binary, e)) +- +- if not unocontext: +- die(251, "Unable to connect or start own listener. Aborting.") +- +- ### And some more LibreOffice magic +- unosvcmgr = unocontext.ServiceManager +- self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) +- self.cwd = unohelper.systemPathToFileUrl( os.getcwd() ) +- +- ### List all filters +-# self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) +-# for filter in self.filters.getElementNames(): +-# print filter +-# #print dir(filter), dir(filter.format) +- +- def getformat(self, inputfn): +- doctype = None +- +- ### Get the output format from mapping +- if op.doctype: +- outputfmt = fmts.bydoctype(op.doctype, op.format) +- else: +- outputfmt = fmts.byname(op.format) +- +- if not outputfmt: +- outputfmt = fmts.byextension(os.extsep + op.format) +- +- ### If no doctype given, check list of acceptable formats for input file ext doctype +- ### FIXME: This should go into the for-loop to match each individual input filename +- if outputfmt: +- inputext = os.path.splitext(inputfn)[1] +- inputfmt = fmts.byextension(inputext) +- if inputfmt: +- for fmt in outputfmt: +- if inputfmt[0].doctype == fmt.doctype: +- doctype = inputfmt[0].doctype +- outputfmt = fmt +- break +- else: +- outputfmt = outputfmt[0] +- # print >>sys.stderr, 'unoconv: format `%s\' is part of multiple doctypes %s, selecting `%s\'.' % (format, [fmt.doctype for fmt in outputfmt], outputfmt[0].doctype) +- else: +- outputfmt = outputfmt[0] +- +- ### No format found, throw error +- if not outputfmt: +- if doctype: +- print >>sys.stderr, 'unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format) +- else: +- print >>sys.stderr, 'unoconv: format [%s] is not known to unoconv.' % op.format +- die(1) +- +- return outputfmt +- +- def convert(self, inputfn): +- global exitcode +- +- document = None +- outputfmt = self.getformat(inputfn) +- +- if op.verbose > 0: +- print >>sys.stderr, 'Input file:', inputfn +- +- if not os.path.exists(inputfn): +- print >>sys.stderr, 'unoconv: file `%s\' does not exist.' % inputfn +- exitcode = 1 +- +- try: +- ### Import phase +- phase = "import" +- +- ### Load inputfile +- inputprops = UnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=QUIET_UPDATE) +- +-# if op.password: +-# info = UnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") +-# inputprops += UnoProps(ModifyPasswordInfo=info) +- +- ### Cannot use UnoProps for FilterData property +- if op.importfilteroptions: +-# print "Import filter options: %s" % op.importfilteroptions +- inputprops += UnoProps(FilterOptions=op.importfilteroptions) +- +- ### Cannot use UnoProps for FilterData property +- if op.importfilter: +- inputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) +- +- inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn)) +- document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) +- +- if not document: +- raise UnoException("The document '%s' could not be opened." % inputurl, None) +- +- ### Import style template +- phase = "import-style" +- if op.template: +- if os.path.exists(op.template): +- info(1, "Template file: %s" % op.template) +- templateprops = UnoProps(OverwriteStyles=True) +- templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template)) +- document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) +- else: +- print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template +- exitcode = 1 +- +- ### Update document links +- phase = "update-links" +- try: +- document.updateLinks() +- except AttributeError: +- # the document doesn't implement the XLinkUpdate interface +- pass +- +- ### Update document indexes +- phase = "update-indexes" +- try: +- document.refresh() +- indexes = document.getDocumentIndexes() +- except AttributeError: +- # the document doesn't implement the XRefreshable and/or +- # XDocumentIndexesSupplier interfaces +- pass +- else: +- for i in range(0, indexes.getCount()): +- indexes.getByIndex(i).update() +- +- info(1, "Selected output format: %s" % outputfmt) +- info(2, "Selected office filter: %s" % outputfmt.filter) +- info(2, "Used doctype: %s" % outputfmt.doctype) +- +- ### Export phase +- phase = "export" +- +- outputprops = UnoProps(FilterName=outputfmt.filter, OutputStream=OutputStream(), Overwrite=True) +- +- ### Set default filter options +- if op.exportfilteroptions: +-# print "Export filter options: %s" % op.exportfilteroptions +- outputprops += UnoProps(FilterOptions=op.exportfilteroptions) +- else: +- if outputfmt.filter == 'Text (encoded)': +- outputprops += UnoProps(FilterOptions="76,LF") +- +- elif outputfmt.filter == 'Text': +- outputprops += UnoProps(FilterOptions="76") +- +- elif outputfmt.filter == 'Text - txt - csv (StarCalc)': +- outputprops += UnoProps(FilterOptions="44,34,76") +- +- +- ### Cannot use UnoProps for FilterData property +- if op.exportfilter: +- outputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) +- +- if not op.stdout: +- (outputfn, ext) = os.path.splitext(inputfn) +- if not op.output: +- outputfn = outputfn + os.extsep + outputfmt.extension +- elif os.path.isdir(op.output): +- outputfn = realpath(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension) +- elif len(op.filenames) > 1: +- outputfn = op.output + os.extsep + outputfmt.extension +- else: +- outputfn = op.output +- +- outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) +- info(1, "Output file: %s" % outputfn) +- else: +- outputurl = "private:stream" +- +- try: +- document.storeToURL(outputurl, tuple(outputprops) ) +- except IOException, e: +- raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) +- +- phase = "dispose" +- document.dispose() +- document.close(True) +- +- except SystemError, e: +- error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) +- exitcode = 1 +- +- except RuntimeException, e: +- error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) +- exitcode = 6 +- +- except DisposedException, e: +- error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) +- exitcode = 7 +- +- except IllegalArgumentException, e: +- error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) +- exitcode = 8 +- +- except IOException, e: +-# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) +- error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) +- exitcode = 3 +- +- except CannotConvertException, e: +-# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) +- error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) +- exitcode = 4 +- +- except UnoException, e: +- if hasattr(e, 'ErrCode'): +- error("unoconv: UnoException during %s phase in %s (ErrCode %d)" % (phase, repr(e.__class__), e.ErrCode)) +- exitcode = e.ErrCode +- pass +- if hasattr(e, 'Message'): +- error("unoconv: UnoException during %s phase:\n%s" % (phase, e.Message)) +- exitcode = 5 +- else: +- error("unoconv: UnoException during %s phase in %s" % (phase, repr(e.__class__))) +- exitcode = 2 +- pass +- +-class Listener: +- def __init__(self): +- global product +- +- info(1, "Start listener on %s:%s" % (op.server, op.port)) +- self.context = uno.getComponentContext() +- self.svcmgr = self.context.ServiceManager +- try: +- resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) +- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) +- try: +- unocontext = resolver.resolve("uno:%s" % op.connection) +- except NoConnectException, e: +- pass +- else: +- info(1, "Existing %s listener found, nothing to do." % product.ooName) +- return +- if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): +- subprocess.call([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection], env=os.environ) +- else: +- subprocess.call([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection], env=os.environ) +- except Exception, e: +- error("Launch of %s failed.\n%s" % (office.binary, e)) +- else: +- info(1, "Existing %s listener found, nothing to do." % product.ooName) +- +-def error(msg): +- "Output error message" +- print >>sys.stderr, msg +- +-def info(level, msg): +- "Output info message" +- if 'op' not in globals(): +- pass +- elif op.verbose >= 3 and level >= 3: +- print >>sys.stderr, "DEBUG:", msg +- elif not op.stdout and level <= op.verbose: +- print >>sys.stdout, msg +- elif level <= op.verbose: +- print >>sys.stderr, msg +- +-def die(ret, msg=None): +- "Print optional error and exit with errorcode" +- global convertor, ooproc, office +- +- if msg: +- error('Error: %s' % msg) +- +- ### Did we start our own listener instance ? +- if not op.listener and ooproc and convertor: +- +- ### If there is a GUI now attached to the instance, disable listener +- if convertor.desktop.getCurrentFrame(): +- info(2, 'Trying to stop %s GUI listener.' % product.ooName) +- try: +- if product.ooName != "LibreOffice" or product.ooSetupVersion <= 3.3: +- subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection], env=os.environ) +- else: +- subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection], env=os.environ) +- ooproc.wait() +- info(2, '%s listener successfully disabled.' % product.ooName) +- except Exception, e: +- error("Terminate using %s failed.\n%s" % (office.binary, e)) +- +- ### If there is no GUI attached to the instance, terminate instance +- else: +- info(3, 'Terminating %s instance.' % product.ooName) +- try: +- convertor.desktop.terminate() +- except DisposedException: +- info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) +- try: +- ooproc.terminate() +- except AttributeError: +- os.kill(ooproc.pid, 15) +- info(3, 'Waiting for %s instance to exit.' % product.ooName) +- ooproc.wait() +- +- ### LibreOffice processes may get stuck and we have to kill them +- ### Is it still running ? +- if ooproc.poll() == None: +- info(1, '%s instance still running, please investigate...' % product.ooName) +- ooproc.wait() +- info(2, '%s instance unsuccessfully terminated, sending KILL signal.' % product.ooName) +- try: +- ooproc.kill() +- except AttributeError: +- os.kill(ooproc.pid, 9) +- info(3, 'Waiting for %s with pid %s to disappear.' % (ooproc.pid, product.ooName)) +- ooproc.wait() +- +- # allow Python GC to garbage collect pyuno object *before* exit call +- # which avoids random segmentation faults --vpa +- convertor = None +- +- sys.exit(ret) +- +-def main(): +- global convertor, exitcode +- convertor = None +- +- try: +- if op.listener: +- listener = Listener() +- +- if op.filenames: +- convertor = Convertor() +- for inputfn in op.filenames: +- convertor.convert(inputfn) +- +- except NoConnectException, e: +- error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) +- if op.connection: +- info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) +- else: +- info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"socket,host=%s,port=%s;urp;\"" % (op.server, op.server, op.port, op.server, op.port)) +- info(0, "Please start an soffice instance on server '%s' by doing:\n\n soffice -nologo -nodefault -accept=\"socket,host=127.0.0.1,port=%s;urp;\"" % (op.server, op.port)) +- exitcode = 1 +-# except UnboundLocalError: +-# die(252, "Failed to connect to remote listener.") +- except OSError: +- error("Warning: failed to launch Office suite. Aborting.") +- +-### Main entrance + if __name__ == '__main__': +- exitcode = 0 +- +- info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) +- +- for of in find_offices(): +- if of.python != sys.executable and not sys.executable.startswith(of.basepath): +- python_switch(of) +- office_environ(of) +-# debug_office() +- try: +- import uno, unohelper +- office = of +- break +- except: +-# debug_office() +- print >>sys.stderr, "unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of +- print >>sys.stderr, "ERROR:", sys.exc_info()[1] +- print >>sys.stderr ++ if sys.version_info < (3,0): ++ from unoconv2 import run + else: +-# debug_office() +- print >>sys.stderr, "unoconv: Cannot find a suitable office installation on your system." +- print >>sys.stderr, "ERROR: Please locate your office installation and send your feedback to:" +- print >>sys.stderr, " http://github.com/dagwieers/unoconv/issues" +- sys.exit(1) +- +- ### Now that we have found a working pyuno library, let's import some classes +- from com.sun.star.beans import PropertyValue +- from com.sun.star.connection import NoConnectException +- from com.sun.star.document.UpdateDocMode import QUIET_UPDATE +- from com.sun.star.lang import DisposedException, IllegalArgumentException +- from com.sun.star.io import IOException, XOutputStream +- from com.sun.star.script import CannotConvertException +- from com.sun.star.uno import Exception as UnoException +- from com.sun.star.uno import RuntimeException +- +- ### And now that we have those classes, build on them +- class OutputStream( unohelper.Base, XOutputStream ): +- def __init__( self ): +- self.closed = 0 +- +- def closeOutput(self): +- self.closed = 1 +- +- def writeBytes( self, seq ): +- sys.stdout.write( seq.value ) +- +- def flush( self ): +- pass +- +- def UnoProps(**args): +- props = [] +- for key in args: +- prop = PropertyValue() +- prop.Name = key +- prop.Value = args[key] +- props.append(prop) +- return tuple(props) +- +- op = Options(sys.argv[1:]) +- +- info(2, "Using office base path: %s" % office.basepath) +- info(2, "Using office binary path: %s" % office.unopath) ++ from unoconv3 import run + +- try: +- main() +- except KeyboardInterrupt, e: +- die(6, 'Exiting on user request') +- die(exitcode) ++ run() +diff --git a/unoconv2.py b/unoconv2.py +new file mode 100755 +index 0000000..1aecbb6 +--- /dev/null ++++ b/unoconv2.py +@@ -0,0 +1,1195 @@ ++#!/usr/bin/env python ++ ++### This program is free software; you can redistribute it and/or modify ++### it under the terms of the GNU General Public License as published by ++### the Free Software Foundation; version 2 only ++### ++### This program is distributed in the hope that it will be useful, ++### but WITHOUT ANY WARRANTY; without even the implied warranty of ++### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++### GNU General Public License for more details. ++### ++### You should have received a copy of the GNU General Public License ++### along with this program; if not, write to the Free Software ++### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++### Copyright 2007-2010 Dag Wieers ++ ++from distutils.version import LooseVersion ++import getopt ++import glob ++import os ++import subprocess ++import sys ++import time ++ ++__version__ = "$Revision$" ++# $Source$ ++ ++VERSION = '0.6' ++ ++doctypes = ('document', 'graphics', 'presentation', 'spreadsheet') ++ ++global convertor, office, ooproc, product ++ooproc = None ++exitcode = 0 ++ ++class Office: ++ def __init__(self, basepath, urepath, unopath, pyuno, binary, python, pythonhome): ++ self.basepath = basepath ++ self.urepath = urepath ++ self.unopath = unopath ++ self.pyuno = pyuno ++ self.binary = binary ++ self.python = python ++ self.pythonhome = pythonhome ++ ++ def __str__(self): ++ return self.basepath ++ ++ def __repr__(self): ++ return self.basepath ++ ++### Implement a path normalizer in order to make unoconv work on MacOS X ++### (on which 'program' is a symlink to 'MacOSX' which seems to break unoconv) ++def realpath(*args): ++ ''' Implement a combination of os.path.join(), os.path.abspath() and ++ os.path.realpath() in order to normalize path constructions ''' ++ ret = '' ++ for arg in args: ++ ret = os.path.join(ret, arg) ++ return os.path.realpath(os.path.abspath(ret)) ++ ++### The first thing we ought to do is find a suitable Office installation ++### with a compatible pyuno library that we can import. ++### ++### See: http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=36370&p=166783 ++ ++def find_offices(): ++ ret = [] ++ extrapaths = [] ++ ++ ### Try using UNO_PATH first (in many incarnations, we'll see what sticks) ++ if 'UNO_PATH' in os.environ: ++ extrapaths += [ os.environ['UNO_PATH'], ++ os.path.dirname(os.environ['UNO_PATH']), ++ os.path.dirname(os.path.dirname(os.environ['UNO_PATH'])) ] ++ ++ else: ++ ++ if os.name in ( 'nt', 'os2' ): ++ if 'PROGRAMFILES' in os.environ.keys(): ++ extrapaths += glob.glob(os.environ['PROGRAMFILES']+'\\LibreOffice*') + \ ++ glob.glob(os.environ['PROGRAMFILES']+'\\OpenOffice.org*') ++ ++ if 'PROGRAMFILES(X86)' in os.environ.keys(): ++ extrapaths += glob.glob(os.environ['PROGRAMFILES(X86)']+'\\LibreOffice*') + \ ++ glob.glob(os.environ['PROGRAMFILES(X86)']+'\\OpenOffice.org*') ++ ++ elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): ++ extrapaths += [ '/Applications/LibreOffice.app/Contents', ++ '/Applications/NeoOffice.app/Contents', ++ '/Applications/OpenOffice.org.app/Contents' ] ++ ++ else: ++ extrapaths += glob.glob('/usr/lib*/libreoffice*') + \ ++ glob.glob('/usr/lib*/openoffice*') + \ ++ glob.glob('/usr/lib*/ooo*') + \ ++ glob.glob('/opt/libreoffice*') + \ ++ glob.glob('/opt/openoffice*') + \ ++ glob.glob('/opt/ooo*') + \ ++ glob.glob('/usr/local/libreoffice*') + \ ++ glob.glob('/usr/local/openoffice*') + \ ++ glob.glob('/usr/local/ooo*') + \ ++ glob.glob('/usr/local/lib/libreoffice*') ++ ++ ### Find a working set for python UNO bindings ++ for basepath in extrapaths: ++ if os.name in ( 'nt', 'os2' ): ++ officelibraries = ( 'pyuno.pyd', ) ++ officebinaries = ( 'soffice.exe' ,) ++ pythonbinaries = ( 'python.exe', ) ++ pythonhomes = () ++ elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): ++ officelibraries = ( 'pyuno.so', 'libpyuno.dylib' ) ++ officebinaries = ( 'soffice.bin', ) ++ pythonbinaries = ( 'python.bin', 'python' ) ++ pythonhomes = ( 'OOoPython.framework/Versions/*/lib/python*', ) ++ else: ++ officelibraries = ( 'pyuno.so', ) ++ officebinaries = ( 'soffice.bin', ) ++ pythonbinaries = ( 'python.bin', 'python', ) ++ pythonhomes = ( 'python-core-*', ) ++ ++ ### Older LibreOffice/OpenOffice and Windows use basis-link/ or basis/ ++ libpath = 'error' ++ for basis in ( 'basis-link', 'basis', '' ): ++ for lib in officelibraries: ++ if os.path.isfile(realpath(basepath, basis, 'program', lib)): ++ libpath = realpath(basepath, basis, 'program') ++ officelibrary = realpath(libpath, lib) ++ info(3, "Found %s in %s" % (lib, libpath)) ++ # Break the inner loop... ++ break ++ # Continue if the inner loop wasn't broken. ++ else: ++ continue ++ # Inner loop was broken, break the outer. ++ break ++ else: ++ continue ++ ++ ### MacOSX have soffice binaries installed in MacOS subdirectory, not program ++ unopath = 'error' ++ for basis in ( 'basis-link', 'basis', '' ): ++ for bin in officebinaries: ++ if os.path.isfile(realpath(basepath, basis, 'program', bin)): ++ unopath = realpath(basepath, basis, 'program') ++ officebinary = realpath(unopath, bin) ++ info(3, "Found %s in %s" % (bin, unopath)) ++ # Break the inner loop... ++ break ++ # Continue if the inner loop wasn't broken. ++ else: ++ continue ++ # Inner loop was broken, break the outer. ++ break ++ else: ++ continue ++ ++ ### Windows does not provide or need a URE/lib directory ? ++ urepath = '' ++ for basis in ( 'basis-link', 'basis', '' ): ++ for ure in ( 'ure-link', 'ure', 'URE', '' ): ++ if os.path.isfile(realpath(basepath, basis, ure, 'lib', 'unorc')): ++ urepath = realpath(basepath, basis, ure) ++ info(3, "Found %s in %s" % ('unorc', realpath(urepath, 'lib'))) ++ # Break the inner loop... ++ break ++ # Continue if the inner loop wasn't broken. ++ else: ++ continue ++ # Inner loop was broken, break the outer. ++ break ++ ++ pythonhome = None ++ for home in pythonhomes: ++ if glob.glob(realpath(libpath, home)): ++ pythonhome = glob.glob(realpath(libpath, home))[0] ++ info(3, "Found %s in %s" % (home, pythonhome)) ++ break ++ ++# if not os.path.isfile(realpath(basepath, program, officebinary)): ++# continue ++# info(3, "Found %s in %s" % (officebinary, realpath(basepath, program))) ++ ++# if not glob.glob(realpath(basepath, basis, program, 'python-core-*')): ++# continue ++ ++ for pythonbinary in pythonbinaries: ++ if os.path.isfile(realpath(unopath, pythonbinary)): ++ info(3, "Found %s in %s" % (pythonbinary, unopath)) ++ ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, ++ realpath(unopath, pythonbinary), pythonhome)) ++ else: ++ info(3, "Considering %s" % basepath) ++ ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, ++ sys.executable, None)) ++ return ret ++ ++def office_environ(office): ++ ### Set PATH so that crash_report is found ++ os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH'] ++ ++ ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: ++ os.environ['UNO_PATH'] = office.unopath ++ ++ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete ++ ### UNO environment ++ if os.name in ( 'nt', 'os2' ): ++ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') ++ else: ++ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamentalrc') ++ ++ ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: ++ if 'LD_LIBRARY_PATH' in os.environ: ++ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ ++ realpath(office.urepath, 'lib') + os.pathsep + \ ++ os.environ['LD_LIBRARY_PATH'] ++ else: ++ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ ++ realpath(office.urepath, 'lib') ++ ++ if office.pythonhome: ++ for libpath in ( realpath(office.pythonhome, 'lib'), ++ realpath(office.pythonhome, 'lib', 'lib-dynload'), ++ realpath(office.pythonhome, 'lib', 'lib-tk'), ++ realpath(office.pythonhome, 'lib', 'site-packages'), ++ office.unopath): ++ sys.path.insert(0, libpath) ++ else: ++ ### Still needed for system python using LibreOffice UNO bindings ++ ### Although we prefer to use a system UNO binding in this case ++ sys.path.append(office.unopath) ++ ++def debug_office(): ++ if 'URE_BOOTSTRAP' in os.environ: ++ print >>sys.stderr, 'URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'] ++ if 'UNO_PATH' in os.environ: ++ print >>sys.stderr, 'UNO_PATH=%s' % os.environ['UNO_PATH'] ++ if 'UNO_TYPES' in os.environ: ++ print >>sys.stderr, 'UNO_TYPES=%s' % os.environ['UNO_TYPES'] ++ print 'PATH=%s' % os.environ['PATH'] ++ if 'PYTHONHOME' in os.environ: ++ print >>sys.stderr, 'PYTHONHOME=%s' % os.environ['PYTHONHOME'] ++ if 'PYTHONPATH' in os.environ: ++ print >>sys.stderr, 'PYTHONPATH=%s' % os.environ['PYTHONPATH'] ++ if 'LD_LIBRARY_PATH' in os.environ: ++ print >>sys.stderr, 'LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'] ++ ++def python_switch(office): ++ if office.pythonhome: ++ os.environ['PYTHONHOME'] = office.pythonhome ++ os.environ['PYTHONPATH'] = realpath(office.pythonhome, 'lib') + os.pathsep + \ ++ realpath(office.pythonhome, 'lib', 'lib-dynload') + os.pathsep + \ ++ realpath(office.pythonhome, 'lib', 'lib-tk') + os.pathsep + \ ++ realpath(office.pythonhome, 'lib', 'site-packages') + os.pathsep + \ ++ office.unopath ++ ++ os.environ['UNO_PATH'] = office.unopath ++ ++ info(3, "-> Switching from %s to %s" % (sys.executable, office.python)) ++ if os.name in ('nt', 'os2'): ++ ### os.execv is broken on Windows and can't properly parse command line ++ ### arguments and executable name if they contain whitespaces. subprocess ++ ### fixes that behavior. ++ ret = subprocess.call([office.python] + sys.argv[0:]) ++ sys.exit(ret) ++ else: ++ ++ ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: ++ if 'LD_LIBRARY_PATH' in os.environ: ++ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ ++ realpath(office.urepath, 'lib') + os.pathsep + \ ++ os.environ['LD_LIBRARY_PATH'] ++ else: ++ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ ++ realpath(office.urepath, 'lib') ++ ++ try: ++ os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) ++ print(office.python, [office.python, ] + sys.argv[0:], osenviron) ++ except OSError: ++ ### Mac OS X versions prior to 10.6 do not support execv in ++ ### a process that contains multiple threads. Instead of ++ ### re-executing in the current process, start a new one ++ ### and cause the current process to exit. This isn't ++ ### ideal since the new process is detached from the parent ++ ### terminal and thus cannot easily be killed with ctrl-C, ++ ### but it's better than not being able to autoreload at ++ ### all. ++ ### Unfortunately the errno returned in this case does not ++ ### appear to be consistent, so we can't easily check for ++ ### this error specifically. ++ ret = os.spawnvpe(os.P_WAIT, office.python, [office.python, ] + sys.argv[0:], os.environ) ++ sys.exit(ret) ++ ++class Fmt: ++ def __init__(self, doctype, name, extension, summary, filter): ++ self.doctype = doctype ++ self.name = name ++ self.extension = extension ++ self.summary = summary ++ self.filter = filter ++ ++ def __str__(self): ++ return "%s [.%s]" % (self.summary, self.extension) ++ ++ def __repr__(self): ++ return "%s/%s" % (self.name, self.doctype) ++ ++class FmtList: ++ def __init__(self): ++ self.list = [] ++ ++ def add(self, doctype, name, extension, summary, filter): ++ self.list.append(Fmt(doctype, name, extension, summary, filter)) ++ ++ def byname(self, name): ++ ret = [] ++ for fmt in self.list: ++ if fmt.name == name: ++ ret.append(fmt) ++ return ret ++ ++ def byextension(self, extension): ++ ret = [] ++ for fmt in self.list: ++ if os.extsep + fmt.extension == extension: ++ ret.append(fmt) ++ return ret ++ ++ def bydoctype(self, doctype, name): ++ ret = [] ++ for fmt in self.list: ++ if fmt.name == name and fmt.doctype == doctype: ++ ret.append(fmt) ++ return ret ++ ++ def display(self, doctype): ++ print >>sys.stderr, "The following list of %s formats are currently available:\n" % doctype ++ for fmt in self.list: ++ if fmt.doctype == doctype: ++ print >>sys.stderr, " %-8s - %s" % (fmt.name, fmt) ++ print >>sys.stderr ++ ++fmts = FmtList() ++ ++### TextDocument ++fmts.add('document', 'bib', 'bib', 'BibTeX', 'BibTeX_Writer') ### 22 ++fmts.add('document', 'doc', 'doc', 'Microsoft Word 97/2000/XP', 'MS Word 97') ### 29 ++fmts.add('document', 'doc6', 'doc', 'Microsoft Word 6.0', 'MS WinWord 6.0') ### 24 ++fmts.add('document', 'doc95', 'doc', 'Microsoft Word 95', 'MS Word 95') ### 28 ++fmts.add('document', 'docbook', 'xml', 'DocBook', 'DocBook File') ### 39 ++fmts.add('document', 'docx', 'docx', 'Microsoft Office Open XML', 'Office Open XML Text') ++fmts.add('document', 'docx7', 'docx', 'Microsoft Office Open XML', 'MS Word 2007 XML') ++fmts.add('document', 'fodt', 'fodt', 'OpenDocument Text (Flat XML)', 'OpenDocument Text Flat XML') ++fmts.add('document', 'html', 'html', 'HTML Document (OpenOffice.org Writer)', 'HTML (StarWriter)') ### 3 ++fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'LaTeX_Writer') ### 31 ++fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') ++fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 ++fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 ++fmts.add('document', 'ott', 'ott', 'Open Document Text', 'writer8_template') ### 21 ++fmts.add('document', 'pdb', 'pdb', 'AportisDoc (Palm)', 'AportisDoc Palm DB') ++fmts.add('document', 'pdf', 'pdf', 'Portable Document Format', 'writer_pdf_Export') ### 18 ++fmts.add('document', 'psw', 'psw', 'Pocket Word', 'PocketWord File') ++fmts.add('document', 'rtf', 'rtf', 'Rich Text Format', 'Rich Text Format') ### 16 ++fmts.add('document', 'sdw', 'sdw', 'StarWriter 5.0', 'StarWriter 5.0') ### 23 ++fmts.add('document', 'sdw4', 'sdw', 'StarWriter 4.0', 'StarWriter 4.0') ### 2 ++fmts.add('document', 'sdw3', 'sdw', 'StarWriter 3.0', 'StarWriter 3.0') ### 20 ++fmts.add('document', 'stw', 'stw', 'Open Office.org 1.0 Text Document Template', 'writer_StarOffice_XML_Writer_Template') ### 9 ++fmts.add('document', 'sxw', 'sxw', 'Open Office.org 1.0 Text Document', 'StarOffice XML (Writer)') ### 1 ++fmts.add('document', 'text', 'txt', 'Text Encoded', 'Text (encoded)') ### 26 ++fmts.add('document', 'txt', 'txt', 'Text', 'Text') ### 34 ++fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### 27 ++fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 ++fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 ++fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 ++fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 ++ ++### WebDocument ++fmts.add('web', 'etext', 'txt', 'Text Encoded (OpenOffice.org Writer/Web)', 'Text (encoded) (StarWriter/Web)') ### 14 ++fmts.add('web', 'html10', 'html', 'OpenOffice.org 1.0 HTML Template', 'writer_web_StarOffice_XML_Writer_Web_Template') ### 11 ++fmts.add('web', 'html', 'html', 'HTML Document', 'HTML') ### 2 ++fmts.add('web', 'html', 'html', 'HTML Document Template', 'writerweb8_writer_template') ### 13 ++fmts.add('web', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki_Web') ### 9 ++fmts.add('web', 'pdf', 'pdf', 'PDF - Portable Document Format', 'writer_web_pdf_Export') ### 10 ++fmts.add('web', 'sdw3', 'sdw', 'StarWriter 3.0 (OpenOffice.org Writer/Web)', 'StarWriter 3.0 (StarWriter/Web)') ### 3 ++fmts.add('web', 'sdw4', 'sdw', 'StarWriter 4.0 (OpenOffice.org Writer/Web)', 'StarWriter 4.0 (StarWriter/Web)') ### 4 ++fmts.add('web', 'sdw', 'sdw', 'StarWriter 5.0 (OpenOffice.org Writer/Web)', 'StarWriter 5.0 (StarWriter/Web)') ### 5 ++fmts.add('web', 'txt', 'txt', 'OpenOffice.org Text (OpenOffice.org Writer/Web)', 'writerweb8_writer') ### 12 ++fmts.add('web', 'text10', 'txt', 'OpenOffice.org 1.0 Text Document (OpenOffice.org Writer/Web)', 'writer_web_StarOffice_XML_Writer') ### 15 ++fmts.add('web', 'text', 'txt', 'Text (OpenOffice.org Writer/Web)', 'Text (StarWriter/Web)') ### 8 ++fmts.add('web', 'vor4', 'vor', 'StarWriter/Web 4.0 Template', 'StarWriter/Web 4.0 Vorlage/Template') ### 6 ++fmts.add('web', 'vor', 'vor', 'StarWriter/Web 5.0 Template', 'StarWriter/Web 5.0 Vorlage/Template') ### 7 ++ ++### Spreadsheet ++fmts.add('spreadsheet', 'csv', 'csv', 'Text CSV', 'Text - txt - csv (StarCalc)') ### 16 ++fmts.add('spreadsheet', 'dbf', 'dbf', 'dBASE', 'dBase') ### 22 ++fmts.add('spreadsheet', 'dif', 'dif', 'Data Interchange Format', 'DIF') ### 5 ++fmts.add('spreadsheet', 'fods', 'fods', 'OpenDocument Spreadsheet (Flat XML)', 'OpenDocument Spreadsheet Flat XML') ++fmts.add('spreadsheet', 'html', 'html', 'HTML Document (OpenOffice.org Calc)', 'HTML (StarCalc)') ### 7 ++fmts.add('spreadsheet', 'ods', 'ods', 'ODF Spreadsheet', 'calc8') ### 15 ++fmts.add('spreadsheet', 'ooxml', 'xml', 'Microsoft Excel 2003 XML', 'MS Excel 2003 XML') ### 23 ++fmts.add('spreadsheet', 'ots', 'ots', 'ODF Spreadsheet Template', 'calc8_template') ### 14 ++fmts.add('spreadsheet', 'pdf', 'pdf', 'Portable Document Format', 'calc_pdf_Export') ### 34 ++fmts.add('spreadsheet', 'pxl', 'pxl', 'Pocket Excel', 'Pocket Excel') ++fmts.add('spreadsheet', 'sdc', 'sdc', 'StarCalc 5.0', 'StarCalc 5.0') ### 31 ++fmts.add('spreadsheet', 'sdc4', 'sdc', 'StarCalc 4.0', 'StarCalc 4.0') ### 11 ++fmts.add('spreadsheet', 'sdc3', 'sdc', 'StarCalc 3.0', 'StarCalc 3.0') ### 29 ++fmts.add('spreadsheet', 'slk', 'slk', 'SYLK', 'SYLK') ### 35 ++fmts.add('spreadsheet', 'stc', 'stc', 'OpenOffice.org 1.0 Spreadsheet Template', 'calc_StarOffice_XML_Calc_Template') ### 2 ++fmts.add('spreadsheet', 'sxc', 'sxc', 'OpenOffice.org 1.0 Spreadsheet', 'StarOffice XML (Calc)') ### 3 ++fmts.add('spreadsheet', 'uos', 'uos', 'Unified Office Format spreadsheet', 'UOF spreadsheet') ### 9 ++fmts.add('spreadsheet', 'vor3', 'vor', 'StarCalc 3.0 Template', 'StarCalc 3.0 Vorlage/Template') ### 18 ++fmts.add('spreadsheet', 'vor4', 'vor', 'StarCalc 4.0 Template', 'StarCalc 4.0 Vorlage/Template') ### 19 ++fmts.add('spreadsheet', 'vor', 'vor', 'StarCalc 5.0 Template', 'StarCalc 5.0 Vorlage/Template') ### 20 ++fmts.add('spreadsheet', 'xhtml', 'xhtml', 'XHTML', 'XHTML Calc File') ### 26 ++fmts.add('spreadsheet', 'xls', 'xls', 'Microsoft Excel 97/2000/XP', 'MS Excel 97') ### 12 ++fmts.add('spreadsheet', 'xls5', 'xls', 'Microsoft Excel 5.0', 'MS Excel 5.0/95') ### 8 ++fmts.add('spreadsheet', 'xls95', 'xls', 'Microsoft Excel 95', 'MS Excel 95') ### 10 ++fmts.add('spreadsheet', 'xlt', 'xlt', 'Microsoft Excel 97/2000/XP Template', 'MS Excel 97 Vorlage/Template') ### 6 ++fmts.add('spreadsheet', 'xlt5', 'xlt', 'Microsoft Excel 5.0 Template', 'MS Excel 5.0/95 Vorlage/Template') ### 28 ++fmts.add('spreadsheet', 'xlt95', 'xlt', 'Microsoft Excel 95 Template', 'MS Excel 95 Vorlage/Template') ### 21 ++ ++### Graphics ++fmts.add('graphics', 'bmp', 'bmp', 'Windows Bitmap', 'draw_bmp_Export') ### 21 ++fmts.add('graphics', 'emf', 'emf', 'Enhanced Metafile', 'draw_emf_Export') ### 15 ++fmts.add('graphics', 'eps', 'eps', 'Encapsulated PostScript', 'draw_eps_Export') ### 48 ++fmts.add('graphics', 'fodg', 'fodg', 'OpenDocument Drawing (Flat XML)', 'OpenDocument Drawing Flat XML') ++fmts.add('graphics', 'gif', 'gif', 'Graphics Interchange Format', 'draw_gif_Export') ### 30 ++fmts.add('graphics', 'html', 'html', 'HTML Document (OpenOffice.org Draw)', 'draw_html_Export') ### 37 ++fmts.add('graphics', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'draw_jpg_Export') ### 3 ++fmts.add('graphics', 'met', 'met', 'OS/2 Metafile', 'draw_met_Export') ### 43 ++fmts.add('graphics', 'odd', 'odd', 'OpenDocument Drawing', 'draw8') ### 6 ++fmts.add('graphics', 'otg', 'otg', 'OpenDocument Drawing Template', 'draw8_template') ### 20 ++fmts.add('graphics', 'pbm', 'pbm', 'Portable Bitmap', 'draw_pbm_Export') ### 14 ++fmts.add('graphics', 'pct', 'pct', 'Mac Pict', 'draw_pct_Export') ### 41 ++fmts.add('graphics', 'pdf', 'pdf', 'Portable Document Format', 'draw_pdf_Export') ### 28 ++fmts.add('graphics', 'pgm', 'pgm', 'Portable Graymap', 'draw_pgm_Export') ### 11 ++fmts.add('graphics', 'png', 'png', 'Portable Network Graphic', 'draw_png_Export') ### 2 ++fmts.add('graphics', 'ppm', 'ppm', 'Portable Pixelmap', 'draw_ppm_Export') ### 5 ++fmts.add('graphics', 'ras', 'ras', 'Sun Raster Image', 'draw_ras_Export') ## 31 ++fmts.add('graphics', 'std', 'std', 'OpenOffice.org 1.0 Drawing Template', 'draw_StarOffice_XML_Draw_Template') ### 53 ++fmts.add('graphics', 'svg', 'svg', 'Scalable Vector Graphics', 'draw_svg_Export') ### 50 ++fmts.add('graphics', 'svm', 'svm', 'StarView Metafile', 'draw_svm_Export') ### 55 ++fmts.add('graphics', 'swf', 'swf', 'Macromedia Flash (SWF)', 'draw_flash_Export') ### 23 ++fmts.add('graphics', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing', 'StarOffice XML (Draw)') ### 26 ++fmts.add('graphics', 'sxd3', 'sxd', 'StarDraw 3.0', 'StarDraw 3.0') ### 40 ++fmts.add('graphics', 'sxd5', 'sxd', 'StarDraw 5.0', 'StarDraw 5.0') ### 44 ++fmts.add('graphics', 'sxw', 'sxw', 'StarOffice XML (Draw)', 'StarOffice XML (Draw)') ++fmts.add('graphics', 'tiff', 'tiff', 'Tagged Image File Format', 'draw_tif_Export') ### 13 ++fmts.add('graphics', 'vor', 'vor', 'StarDraw 5.0 Template', 'StarDraw 5.0 Vorlage') ### 36 ++fmts.add('graphics', 'vor3', 'vor', 'StarDraw 3.0 Template', 'StarDraw 3.0 Vorlage') ### 35 ++fmts.add('graphics', 'wmf', 'wmf', 'Windows Metafile', 'draw_wmf_Export') ### 8 ++fmts.add('graphics', 'xhtml', 'xhtml', 'XHTML', 'XHTML Draw File') ### 45 ++fmts.add('graphics', 'xpm', 'xpm', 'X PixMap', 'draw_xpm_Export') ### 19 ++ ++### Presentation ++fmts.add('presentation', 'bmp', 'bmp', 'Windows Bitmap', 'impress_bmp_Export') ### 15 ++fmts.add('presentation', 'emf', 'emf', 'Enhanced Metafile', 'impress_emf_Export') ### 16 ++fmts.add('presentation', 'eps', 'eps', 'Encapsulated PostScript', 'impress_eps_Export') ### 17 ++fmts.add('presentation', 'fodp', 'fodp', 'OpenDocument Presentation (Flat XML)', 'OpenDocument Presentation Flat XML') ++fmts.add('presentation', 'gif', 'gif', 'Graphics Interchange Format', 'impress_gif_Export') ### 18 ++fmts.add('presentation', 'html', 'html', 'HTML Document (OpenOffice.org Impress)', 'impress_html_Export') ### 43 ++fmts.add('presentation', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'impress_jpg_Export') ### 19 ++fmts.add('presentation', 'met', 'met', 'OS/2 Metafile', 'impress_met_Export') ### 20 ++fmts.add('presentation', 'odg', 'odg', 'ODF Drawing (Impress)', 'impress8_draw') ### 29 ++fmts.add('presentation', 'odp', 'odp', 'ODF Presentation', 'impress8') ### 9 ++fmts.add('presentation', 'otp', 'otp', 'ODF Presentation Template', 'impress8_template') ### 38 ++fmts.add('presentation', 'pbm', 'pbm', 'Portable Bitmap', 'impress_pbm_Export') ### 21 ++fmts.add('presentation', 'pct', 'pct', 'Mac Pict', 'impress_pct_Export') ### 22 ++fmts.add('presentation', 'pdf', 'pdf', 'Portable Document Format', 'impress_pdf_Export') ### 23 ++fmts.add('presentation', 'pgm', 'pgm', 'Portable Graymap', 'impress_pgm_Export') ### 24 ++fmts.add('presentation', 'png', 'png', 'Portable Network Graphic', 'impress_png_Export') ### 25 ++fmts.add('presentation', 'potm', 'potm', 'Microsoft PowerPoint 2007/2010 XML Template', 'Impress MS PowerPoint 2007 XML Template') ++fmts.add('presentation', 'pot', 'pot', 'Microsoft PowerPoint 97/2000/XP Template', 'MS PowerPoint 97 Vorlage') ### 3 ++fmts.add('presentation', 'ppm', 'ppm', 'Portable Pixelmap', 'impress_ppm_Export') ### 26 ++fmts.add('presentation', 'pptx', 'pptx', 'Microsoft PowerPoint 2007/2010 XML', 'Impress MS PowerPoint 2007 XML') ### 36 ++fmts.add('presentation', 'pps', 'pps', 'Microsoft PowerPoint 97/2000/XP (Autoplay)', 'MS PowerPoint 97 Autoplay') ### 36 ++fmts.add('presentation', 'ppt', 'ppt', 'Microsoft PowerPoint 97/2000/XP', 'MS PowerPoint 97') ### 36 ++fmts.add('presentation', 'pwp', 'pwp', 'PlaceWare', 'placeware_Export') ### 30 ++fmts.add('presentation', 'ras', 'ras', 'Sun Raster Image', 'impress_ras_Export') ### 27 ++fmts.add('presentation', 'sda', 'sda', 'StarDraw 5.0 (OpenOffice.org Impress)', 'StarDraw 5.0 (StarImpress)') ### 8 ++fmts.add('presentation', 'sdd', 'sdd', 'StarImpress 5.0', 'StarImpress 5.0') ### 6 ++fmts.add('presentation', 'sdd3', 'sdd', 'StarDraw 3.0 (OpenOffice.org Impress)', 'StarDraw 3.0 (StarImpress)') ### 42 ++fmts.add('presentation', 'sdd4', 'sdd', 'StarImpress 4.0', 'StarImpress 4.0') ### 37 ++fmts.add('presentation', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing (OpenOffice.org Impress)', 'impress_StarOffice_XML_Draw') ### 31 ++fmts.add('presentation', 'sti', 'sti', 'OpenOffice.org 1.0 Presentation Template', 'impress_StarOffice_XML_Impress_Template') ### 5 ++fmts.add('presentation', 'svg', 'svg', 'Scalable Vector Graphics', 'impress_svg_Export') ### 14 ++fmts.add('presentation', 'svm', 'svm', 'StarView Metafile', 'impress_svm_Export') ### 13 ++fmts.add('presentation', 'swf', 'swf', 'Macromedia Flash (SWF)', 'impress_flash_Export') ### 34 ++fmts.add('presentation', 'sxi', 'sxi', 'OpenOffice.org 1.0 Presentation', 'StarOffice XML (Impress)') ### 41 ++fmts.add('presentation', 'tiff', 'tiff', 'Tagged Image File Format', 'impress_tif_Export') ### 12 ++fmts.add('presentation', 'uop', 'uop', 'Unified Office Format presentation', 'UOF presentation') ### 4 ++fmts.add('presentation', 'vor', 'vor', 'StarImpress 5.0 Template', 'StarImpress 5.0 Vorlage') ### 40 ++fmts.add('presentation', 'vor3', 'vor', 'StarDraw 3.0 Template (OpenOffice.org Impress)', 'StarDraw 3.0 Vorlage (StarImpress)') ###1 ++fmts.add('presentation', 'vor4', 'vor', 'StarImpress 4.0 Template', 'StarImpress 4.0 Vorlage') ### 39 ++fmts.add('presentation', 'vor5', 'vor', 'StarDraw 5.0 Template (OpenOffice.org Impress)', 'StarDraw 5.0 Vorlage (StarImpress)') ### 2 ++fmts.add('presentation', 'wmf', 'wmf', 'Windows Metafile', 'impress_wmf_Export') ### 11 ++fmts.add('presentation', 'xhtml', 'xml', 'XHTML', 'XHTML Impress File') ### 33 ++fmts.add('presentation', 'xpm', 'xpm', 'X PixMap', 'impress_xpm_Export') ### 10 ++ ++class Options: ++ def __init__(self, args): ++ self.connection = None ++ self.debug = False ++ self.doctype = None ++ self.exportfilter = [] ++ self.exportfilteroptions = "" ++ self.filenames = [] ++ self.format = None ++ self.importfilter = [] ++ self.importfilteroptions = "" ++ self.listener = False ++ self.nolaunch = False ++ self.output = None ++ self.password = None ++ self.pipe = None ++ self.port = '2002' ++ self.server = '127.0.0.1' ++ self.showlist = False ++ self.stdout = False ++ self.template = None ++ self.timeout = 6 ++ self.verbose = 0 ++ ++ ### Get options from the commandline ++ try: ++ opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:vV', ++ ['connection=', 'debug', 'doctype=', 'export=', 'format=', ++ 'help', 'import', 'listener', 'no-launch', 'output=', ++ 'outputpath', 'password=', 'pipe=', 'port=', 'server=', ++ 'timeout=', 'show', 'stdout', 'template', 'verbose', ++ 'version'] ) ++ except getopt.error, exc: ++ print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc) ++ sys.exit(255) ++ ++ for opt, arg in opts: ++ if opt in ['-h', '--help']: ++ self.usage() ++ print ++ self.help() ++ sys.exit(1) ++ elif opt in ['-c', '--connection']: ++ self.connection = arg ++ elif opt in ['--debug']: ++ self.debug = True ++ elif opt in ['-d', '--doctype']: ++ self.doctype = arg ++ elif opt in ['-e', '--export']: ++ l = arg.split('=') ++ if len(l) == 2: ++ (name, value) = l ++ if name in ('FilterOptions'): ++ self.exportfilteroptions = value ++ elif value in ('True', 'true'): ++ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) ++ elif value in ('False', 'false'): ++ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) ++ else: ++ try: ++ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) ++ except ValueError: ++ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) ++ else: ++ print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg ++ elif opt in ['-f', '--format']: ++ self.format = arg ++ elif opt in ['-i', '--import']: ++ l = arg.split('=') ++ if len(l) == 2: ++ (name, value) = l ++ if name in ('FilterOptions'): ++ self.importfilteroptions = value ++ elif value in ('True', 'true'): ++ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) ++ elif value in ('False', 'false'): ++ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) ++ else: ++ try: ++ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) ++ except ValueError: ++ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) ++ else: ++ print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg ++ elif opt in ['-l', '--listener']: ++ self.listener = True ++ elif opt in ['-n', '--no-launch']: ++ self.nolaunch = True ++ elif opt in ['-o', '--output']: ++ self.output = arg ++ elif opt in ['--outputpath']: ++ print >>sys.stderr, 'Warning: This option is deprecated by --output.' ++ self.output = arg ++ elif opt in ['--password']: ++ self.password = arg ++ elif opt in ['--pipe']: ++ self.pipe = arg ++ elif opt in ['-p', '--port']: ++ self.port = arg ++ elif opt in ['-s', '--server']: ++ self.server = arg ++ elif opt in ['--show']: ++ self.showlist = True ++ elif opt in ['--stdout']: ++ self.stdout = True ++ elif opt in ['-t', '--template']: ++ self.template = arg ++ elif opt in ['-T', '--timeout']: ++ self.timeout = int(arg) ++ elif opt in ['-v', '--verbose']: ++ self.verbose = self.verbose + 1 ++ elif opt in ['-V', '--version']: ++ self.version() ++ sys.exit(255) ++ ++ ### Enable verbosity ++ if self.verbose >= 2: ++ print >>sys.stderr, 'Verbosity set to level %d' % self.verbose ++ ++ self.filenames = args ++ ++ if not self.listener and not self.showlist and self.doctype != 'list' and not self.filenames: ++ print >>sys.stderr, 'unoconv: you have to provide a filename as argument' ++ print >>sys.stderr, 'Try `unoconv -h\' for more information.' ++ sys.exit(255) ++ ++ ### Set connection string ++ if not self.connection: ++ if not self.pipe: ++ self.connection = "socket,host=%s,port=%s;urp;StarOffice.ComponentContext" % (self.server, self.port) ++# self.connection = "socket,host=%s,port=%s;urp;" % (self.server, self.port) ++ else: ++ self.connection = "pipe,name=%s;urp;StarOffice.ComponentContext" % (self.pipe) ++ ++ ### Make it easier for people to use a doctype (first letter is enough) ++ if self.doctype: ++ for doctype in doctypes: ++ if doctype.startswith(self.doctype): ++ self.doctype = doctype ++ ++ ### Check if the user request to see the list of formats ++ if self.showlist or self.format == 'list': ++ if self.doctype: ++ fmts.display(self.doctype) ++ else: ++ for t in doctypes: ++ fmts.display(t) ++ sys.exit(0) ++ ++ ### If no format was specified, probe it or provide it ++ if not self.format: ++ l = sys.argv[0].split('2') ++ if len(l) == 2: ++ self.format = l[1] ++ else: ++ self.format = 'pdf' ++ ++ def version(self): ++ ### Get office product information ++ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) ++ ++ print 'unoconv %s' % VERSION ++ print 'Written by Dag Wieers ' ++ print 'Homepage at http://dag.wieers.com/home-made/unoconv/' ++ print ++ print 'platform %s/%s' % (os.name, sys.platform) ++ print 'python %s' % sys.version ++ print product.ooName, product.ooSetupVersion ++# print ++# print 'build revision $Rev$' ++ ++ def usage(self): ++ print >>sys.stderr, 'usage: unoconv [options] file [file2 ..]' ++ ++ def help(self): ++ print >>sys.stderr, '''Convert from and to any format supported by LibreOffice ++ ++unoconv options: ++ -c, --connection=string use a custom connection string ++ -d, --doctype=type specify document type ++ (document, graphics, presentation, spreadsheet) ++ -e, --export=name=value set export filter options ++ eg. -e PageRange=1-2 ++ -f, --format=format specify the output format ++ -i, --import=string set import filter option string ++ eg. -i utf8 ++ -l, --listener start a permanent listener to use by unoconv clients ++ -n, --no-launch fail if no listener is found (default: launch one) ++ -o, --output=name output basename, filename or directory ++ --pipe=name alternative method of connection using a pipe ++ -p, --port=port specify the port (default: 2002) ++ to be used by client or listener ++ --password=string provide a password to decrypt the document ++ -s, --server=server specify the server address (default: 127.0.0.1) ++ to be used by client or listener ++ --show list the available output formats ++ --stdout write output to stdout ++ -t, --template=file import the styles from template (.ott) ++ -T, --timeout=secs timeout after secs if connection to listener fails ++ -v, --verbose be more and more verbose (-vvv for debugging) ++''' ++ ++class Convertor: ++ def __init__(self): ++ global exitcode, ooproc, office, product ++ unocontext = None ++ ++ ### Do the LibreOffice component dance ++ self.context = global_uno.getComponentContext() ++ self.svcmgr = self.context.ServiceManager ++ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) ++ ++ ### Test for an existing connection ++ info(3, 'Connection type: %s' % op.connection) ++ try: ++ unocontext = resolver.resolve("uno:%s" % op.connection) ++ except UnoNoConnectException, e: ++# info(3, "Existing listener not found.\n%s" % e) ++ info(3, "Existing listener not found.") ++ ++ if op.nolaunch: ++ die(113, "Existing listener not found. Unable start listener by parameters. Aborting.") ++ ++ ### Start our own OpenOffice instance ++ info(3, "Launching our own listener using %s." % office.binary) ++ try: ++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) ++ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): ++ ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) ++ else: ++ ooproc = subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--accept=%s" % op.connection], env=os.environ) ++ info(2, '%s listener successfully started. (pid=%s)' % (product.ooName, ooproc.pid)) ++ ++ ### Try connection to it for op.timeout seconds (flakky OpenOffice) ++ timeout = 0 ++ while timeout <= op.timeout: ++ ### Is it already/still running ? ++ retcode = ooproc.poll() ++ if retcode != None: ++ info(3, "Process %s (pid=%s) exited with %s." % (office.binary, ooproc.pid, retcode)) ++ break ++ try: ++ unocontext = resolver.resolve("uno:%s" % op.connection) ++ break ++ except UnoNoConnectException: ++ time.sleep(0.5) ++ timeout += 0.5 ++ except: ++ raise ++ else: ++ error("Failed to connect to %s (pid=%s) in %d seconds.\n%s" % (office.binary, ooproc.pid, op.timeout, e)) ++ except Exception, e: ++ raise ++ error("Launch of %s failed.\n%s" % (office.binary, e)) ++ ++ if not unocontext: ++ die(251, "Unable to connect or start own listener. Aborting.") ++ ++ ### And some more LibreOffice magic ++ unosvcmgr = unocontext.ServiceManager ++ self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) ++ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() ) ++ ++ ### List all filters ++# self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) ++# for filter in self.filters.getElementNames(): ++# print filter ++# #print dir(filter), dir(filter.format) ++ ++ def getformat(self, inputfn): ++ doctype = None ++ ++ ### Get the output format from mapping ++ if op.doctype: ++ outputfmt = fmts.bydoctype(op.doctype, op.format) ++ else: ++ outputfmt = fmts.byname(op.format) ++ ++ if not outputfmt: ++ outputfmt = fmts.byextension(os.extsep + op.format) ++ ++ ### If no doctype given, check list of acceptable formats for input file ext doctype ++ ### FIXME: This should go into the for-loop to match each individual input filename ++ if outputfmt: ++ inputext = os.path.splitext(inputfn)[1] ++ inputfmt = fmts.byextension(inputext) ++ if inputfmt: ++ for fmt in outputfmt: ++ if inputfmt[0].doctype == fmt.doctype: ++ doctype = inputfmt[0].doctype ++ outputfmt = fmt ++ break ++ else: ++ outputfmt = outputfmt[0] ++ # print >>sys.stderr, 'unoconv: format `%s\' is part of multiple doctypes %s, selecting `%s\'.' % (format, [fmt.doctype for fmt in outputfmt], outputfmt[0].doctype) ++ else: ++ outputfmt = outputfmt[0] ++ ++ ### No format found, throw error ++ if not outputfmt: ++ if doctype: ++ print >>sys.stderr, 'unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format) ++ else: ++ print >>sys.stderr, 'unoconv: format [%s] is not known to unoconv.' % op.format ++ die(1) ++ ++ return outputfmt ++ ++ def convert(self, inputfn): ++ global exitcode ++ ++ document = None ++ outputfmt = self.getformat(inputfn) ++ ++ if op.verbose > 0: ++ print >>sys.stderr, 'Input file:', inputfn ++ ++ if not os.path.exists(inputfn): ++ print >>sys.stderr, 'unoconv: file `%s\' does not exist.' % inputfn ++ exitcode = 1 ++ ++ try: ++ ### Import phase ++ phase = "import" ++ ++ ### Load inputfile ++ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE) ++ ++# if op.password: ++# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") ++# inputprops += GlobalUnoProps(ModifyPasswordInfo=info) ++ ++ ### Cannot use GlobalUnoProps for FilterData property ++ if op.importfilteroptions: ++# print "Import filter options: %s" % op.importfilteroptions ++ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions) ++ ++ ### Cannot use GlobalUnoProps for FilterData property ++ if op.importfilter: ++ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) ++ ++ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn)) ++ document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) ++ ++ if not document: ++ raise UnoException("The document '%s' could not be opened." % inputurl, None) ++ ++ ### Import style template ++ phase = "import-style" ++ if op.template: ++ if os.path.exists(op.template): ++ info(1, "Template file: %s" % op.template) ++ templateprops = GlobalUnoProps(OverwriteStyles=True) ++ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template)) ++ document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) ++ else: ++ print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template ++ exitcode = 1 ++ ++ ### Update document links ++ phase = "update-links" ++ try: ++ document.updateLinks() ++ except AttributeError: ++ # the document doesn't implement the XLinkUpdate interface ++ pass ++ ++ ### Update document indexes ++ phase = "update-indexes" ++ try: ++ document.refresh() ++ indexes = document.getDocumentIndexes() ++ except AttributeError: ++ # the document doesn't implement the XRefreshable and/or ++ # XDocumentIndexesSupplier interfaces ++ pass ++ else: ++ for i in range(0, indexes.getCount()): ++ indexes.getByIndex(i).update() ++ ++ info(1, "Selected output format: %s" % outputfmt) ++ info(2, "Selected office filter: %s" % outputfmt.filter) ++ info(2, "Used doctype: %s" % outputfmt.doctype) ++ ++ ### Export phase ++ phase = "export" ++ ++ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True) ++ ++ ### Set default filter options ++ if op.exportfilteroptions: ++# print "Export filter options: %s" % op.exportfilteroptions ++ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions) ++ else: ++ if outputfmt.filter == 'Text (encoded)': ++ outputprops += GlobalUnoProps(FilterOptions="76,LF") ++ ++ elif outputfmt.filter == 'Text': ++ outputprops += GlobalUnoProps(FilterOptions="76") ++ ++ elif outputfmt.filter == 'Text - txt - csv (StarCalc)': ++ outputprops += GlobalUnoProps(FilterOptions="44,34,76") ++ ++ ++ ### Cannot use GlobalUnoProps for FilterData property ++ if op.exportfilter: ++ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) ++ ++ if not op.stdout: ++ (outputfn, ext) = os.path.splitext(inputfn) ++ if not op.output: ++ outputfn = outputfn + os.extsep + outputfmt.extension ++ elif os.path.isdir(op.output): ++ outputfn = realpath(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension) ++ elif len(op.filenames) > 1: ++ outputfn = op.output + os.extsep + outputfmt.extension ++ else: ++ outputfn = op.output ++ ++ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) ) ++ info(1, "Output file: %s" % outputfn) ++ else: ++ outputurl = "private:stream" ++ ++ try: ++ document.storeToURL(outputurl, tuple(outputprops) ) ++ except UnoIOException, e: ++ raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) ++ ++ phase = "dispose" ++ document.dispose() ++ document.close(True) ++ ++ except SystemError, e: ++ error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) ++ exitcode = 1 ++ ++ except UnoRuntimeException, e: ++ error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) ++ exitcode = 6 ++ ++ except UnoDisposedException, e: ++ error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) ++ exitcode = 7 ++ ++ except UnoIllegalArgumentException, e: ++ error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) ++ exitcode = 8 ++ ++ except UnoIOException, e: ++# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) ++ error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) ++ exitcode = 3 ++ ++ except UnoCannotConvertException, e: ++# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) ++ error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) ++ exitcode = 4 ++ ++ except UnoException, e: ++ if hasattr(e, 'ErrCode'): ++ error("unoconv: UnoException during %s phase in %s (ErrCode %d)" % (phase, repr(e.__class__), e.ErrCode)) ++ exitcode = e.ErrCode ++ pass ++ if hasattr(e, 'Message'): ++ error("unoconv: UnoException during %s phase:\n%s" % (phase, e.Message)) ++ exitcode = 5 ++ else: ++ error("unoconv: UnoException during %s phase in %s" % (phase, repr(e.__class__))) ++ exitcode = 2 ++ pass ++ ++class Listener: ++ def __init__(self): ++ global product ++ ++ info(1, "Start listener on %s:%s" % (op.server, op.port)) ++ self.context = global_uno.getComponentContext() ++ self.svcmgr = self.context.ServiceManager ++ try: ++ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) ++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) ++ try: ++ unocontext = resolver.resolve("uno:%s" % op.connection) ++ except UnoNoConnectException, e: ++ pass ++ else: ++ info(1, "Existing %s listener found, nothing to do." % product.ooName) ++ return ++ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): ++ subprocess.call([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection], env=os.environ) ++ else: ++ subprocess.call([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection], env=os.environ) ++ except Exception, e: ++ error("Launch of %s failed.\n%s" % (office.binary, e)) ++ else: ++ info(1, "Existing %s listener found, nothing to do." % product.ooName) ++ ++def error(msg): ++ "Output error message" ++ print >>sys.stderr, msg ++ ++def info(level, msg): ++ "Output info message" ++ if 'op' not in globals(): ++ pass ++ elif op.verbose >= 3 and level >= 3: ++ print >>sys.stderr, "DEBUG:", msg ++ elif not op.stdout and level <= op.verbose: ++ print >>sys.stdout, msg ++ elif level <= op.verbose: ++ print >>sys.stderr, msg ++ ++def die(ret, msg=None): ++ "Print optional error and exit with errorcode" ++ global convertor, ooproc, office ++ ++ if msg: ++ error('Error: %s' % msg) ++ ++ ### Did we start our own listener instance ? ++ if not op.listener and ooproc and convertor: ++ ++ ### If there is a GUI now attached to the instance, disable listener ++ if convertor.desktop.getCurrentFrame(): ++ info(2, 'Trying to stop %s GUI listener.' % product.ooName) ++ try: ++ if product.ooName != "LibreOffice" or product.ooSetupVersion <= 3.3: ++ subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection], env=os.environ) ++ else: ++ subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection], env=os.environ) ++ ooproc.wait() ++ info(2, '%s listener successfully disabled.' % product.ooName) ++ except Exception, e: ++ error("Terminate using %s failed.\n%s" % (office.binary, e)) ++ ++ ### If there is no GUI attached to the instance, terminate instance ++ else: ++ info(3, 'Terminating %s instance.' % product.ooName) ++ try: ++ convertor.desktop.terminate() ++ except UnoDisposedException: ++ info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) ++ try: ++ ooproc.terminate() ++ except AttributeError: ++ os.kill(ooproc.pid, 15) ++ info(3, 'Waiting for %s instance to exit.' % product.ooName) ++ ooproc.wait() ++ ++ ### LibreOffice processes may get stuck and we have to kill them ++ ### Is it still running ? ++ if ooproc.poll() == None: ++ info(1, '%s instance still running, please investigate...' % product.ooName) ++ ooproc.wait() ++ info(2, '%s instance unsuccessfully terminated, sending KILL signal.' % product.ooName) ++ try: ++ ooproc.kill() ++ except AttributeError: ++ os.kill(ooproc.pid, 9) ++ info(3, 'Waiting for %s with pid %s to disappear.' % (ooproc.pid, product.ooName)) ++ ooproc.wait() ++ ++ # allow Python GC to garbage collect pyuno object *before* exit call ++ # which avoids random segmentation faults --vpa ++ convertor = None ++ ++ sys.exit(ret) ++ ++def main(): ++ global convertor, exitcode ++ convertor = None ++ ++ try: ++ if op.listener: ++ listener = Listener() ++ ++ if op.filenames: ++ convertor = Convertor() ++ for inputfn in op.filenames: ++ convertor.convert(inputfn) ++ ++ except UnoNoConnectException, e: ++ error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) ++ if op.connection: ++ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) ++ else: ++ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"socket,host=%s,port=%s;urp;\"" % (op.server, op.server, op.port, op.server, op.port)) ++ info(0, "Please start an soffice instance on server '%s' by doing:\n\n soffice -nologo -nodefault -accept=\"socket,host=127.0.0.1,port=%s;urp;\"" % (op.server, op.port)) ++ exitcode = 1 ++# except UnboundLocalError: ++# die(252, "Failed to connect to remote listener.") ++ except OSError: ++ error("Warning: failed to launch Office suite. Aborting.") ++ ++### Main entrance ++def run(): ++ global exitcode ++ exitcode = 0 ++ ++ info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) ++ ++ for of in find_offices(): ++ if of.python != sys.executable and not sys.executable.startswith(of.basepath): ++ python_switch(of) ++ office_environ(of) ++# debug_office() ++ try: ++ global global_uno ++ global global_unohelper ++ ++ import uno as global_uno ++ import unohelper as global_unohelper ++ global office ++ office = of ++ break ++ except: ++# debug_office() ++ print >>sys.stderr, "unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of ++ print >>sys.stderr, "ERROR:", sys.exc_info()[1] ++ print >>sys.stderr ++ else: ++# debug_office() ++ print >>sys.stderr, "unoconv: Cannot find a suitable office installation on your system." ++ print >>sys.stderr, "ERROR: Please locate your office installation and send your feedback to:" ++ print >>sys.stderr, " http://github.com/dagwieers/unoconv/issues" ++ sys.exit(1) ++ ++ ### Now that we have found a working pyuno library, let's import some classes ++ global UnoPropertyValue ++ global UnoNoConnectException ++ global UNO_QUIET_UPDATE ++ global UnoDisposedException ++ global UnoIllegalArgumentException ++ global UnoIOException ++ global UnoXOutputStream ++ global UnoCannotConvertException ++ global UnoException ++ global UnoRuntimeException ++ ++ from com.sun.star.beans import PropertyValue as UnoPropertyValue ++ from com.sun.star.connection import NoConnectException as UnoNoConnectException ++ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE ++ from com.sun.star.lang import DisposedException as UnoDisposedException ++ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException ++ from com.sun.star.io import IOException as UnoIOException ++ from com.sun.star.io import XOutputStream as UnoXOutputStream ++ from com.sun.star.script import CannotConvertException as UnoCannotConvertException ++ from com.sun.star.uno import Exception as UnoException ++ from com.sun.star.uno import RuntimeException as UnoRuntimeException ++ ++ ### And now that we have those classes, build on them ++ class OutputStream( global_unohelper.Base, UnoXOutputStream ): ++ def __init__( self ): ++ self.closed = 0 ++ ++ def closeOutput(self): ++ self.closed = 1 ++ ++ def writeBytes( self, seq ): ++ sys.stdout.write( seq.value ) ++ ++ def flush( self ): ++ pass ++ ++ global GlobalOutputStream ++ GlobalOutputStream = OutputStream ++ ++ def UnoProps(**args): ++ props = [] ++ for key in args: ++ prop = UnoPropertyValue() ++ prop.Name = key ++ prop.Value = args[key] ++ props.append(prop) ++ return tuple(props) ++ ++ global GlobalUnoProps ++ GlobalUnoProps = UnoProps ++ ++ global op ++ op = Options(sys.argv[1:]) ++ ++ info(2, "Using office base path: %s" % office.basepath) ++ info(2, "Using office binary path: %s" % office.unopath) ++ ++ try: ++ main() ++ except KeyboardInterrupt, e: ++ die(6, 'Exiting on user request') ++ die(exitcode) ++ ++if __name__ == '__main__': ++ run() +diff --git a/unoconv3.py b/unoconv3.py +new file mode 100755 +index 0000000..09d88c2 +--- /dev/null ++++ b/unoconv3.py +@@ -0,0 +1,1195 @@ ++#!/usr/bin/env python ++ ++### This program is free software; you can redistribute it and/or modify ++### it under the terms of the GNU General Public License as published by ++### the Free Software Foundation; version 2 only ++### ++### This program is distributed in the hope that it will be useful, ++### but WITHOUT ANY WARRANTY; without even the implied warranty of ++### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++### GNU General Public License for more details. ++### ++### You should have received a copy of the GNU General Public License ++### along with this program; if not, write to the Free Software ++### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++### Copyright 2007-2010 Dag Wieers ++ ++from distutils.version import LooseVersion ++import getopt ++import glob ++import os ++import subprocess ++import sys ++import time ++ ++__version__ = "$Revision$" ++# $Source$ ++ ++VERSION = '0.6' ++ ++doctypes = ('document', 'graphics', 'presentation', 'spreadsheet') ++ ++global convertor, office, ooproc, product ++ooproc = None ++exitcode = 0 ++ ++class Office: ++ def __init__(self, basepath, urepath, unopath, pyuno, binary, python, pythonhome): ++ self.basepath = basepath ++ self.urepath = urepath ++ self.unopath = unopath ++ self.pyuno = pyuno ++ self.binary = binary ++ self.python = python ++ self.pythonhome = pythonhome ++ ++ def __str__(self): ++ return self.basepath ++ ++ def __repr__(self): ++ return self.basepath ++ ++### Implement a path normalizer in order to make unoconv work on MacOS X ++### (on which 'program' is a symlink to 'MacOSX' which seems to break unoconv) ++def realpath(*args): ++ ''' Implement a combination of os.path.join(), os.path.abspath() and ++ os.path.realpath() in order to normalize path constructions ''' ++ ret = '' ++ for arg in args: ++ ret = os.path.join(ret, arg) ++ return os.path.realpath(os.path.abspath(ret)) ++ ++### The first thing we ought to do is find a suitable Office installation ++### with a compatible pyuno library that we can import. ++### ++### See: http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=36370&p=166783 ++ ++def find_offices(): ++ ret = [] ++ extrapaths = [] ++ ++ ### Try using UNO_PATH first (in many incarnations, we'll see what sticks) ++ if 'UNO_PATH' in os.environ: ++ extrapaths += [ os.environ['UNO_PATH'], ++ os.path.dirname(os.environ['UNO_PATH']), ++ os.path.dirname(os.path.dirname(os.environ['UNO_PATH'])) ] ++ ++ else: ++ ++ if os.name in ( 'nt', 'os2' ): ++ if 'PROGRAMFILES' in list(os.environ.keys()): ++ extrapaths += glob.glob(os.environ['PROGRAMFILES']+'\\LibreOffice*') + \ ++ glob.glob(os.environ['PROGRAMFILES']+'\\OpenOffice.org*') ++ ++ if 'PROGRAMFILES(X86)' in list(os.environ.keys()): ++ extrapaths += glob.glob(os.environ['PROGRAMFILES(X86)']+'\\LibreOffice*') + \ ++ glob.glob(os.environ['PROGRAMFILES(X86)']+'\\OpenOffice.org*') ++ ++ elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): ++ extrapaths += [ '/Applications/LibreOffice.app/Contents', ++ '/Applications/NeoOffice.app/Contents', ++ '/Applications/OpenOffice.org.app/Contents' ] ++ ++ else: ++ extrapaths += glob.glob('/usr/lib*/libreoffice*') + \ ++ glob.glob('/usr/lib*/openoffice*') + \ ++ glob.glob('/usr/lib*/ooo*') + \ ++ glob.glob('/opt/libreoffice*') + \ ++ glob.glob('/opt/openoffice*') + \ ++ glob.glob('/opt/ooo*') + \ ++ glob.glob('/usr/local/libreoffice*') + \ ++ glob.glob('/usr/local/openoffice*') + \ ++ glob.glob('/usr/local/ooo*') + \ ++ glob.glob('/usr/local/lib/libreoffice*') ++ ++ ### Find a working set for python UNO bindings ++ for basepath in extrapaths: ++ if os.name in ( 'nt', 'os2' ): ++ officelibraries = ( 'pyuno.pyd', ) ++ officebinaries = ( 'soffice.exe' ,) ++ pythonbinaries = ( 'python.exe', ) ++ pythonhomes = () ++ elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): ++ officelibraries = ( 'pyuno.so', 'libpyuno.dylib' ) ++ officebinaries = ( 'soffice.bin', ) ++ pythonbinaries = ( 'python.bin', 'python' ) ++ pythonhomes = ( 'OOoPython.framework/Versions/*/lib/python*', ) ++ else: ++ officelibraries = ( 'pyuno.so', ) ++ officebinaries = ( 'soffice.bin', ) ++ pythonbinaries = ( 'python.bin', 'python', ) ++ pythonhomes = ( 'python-core-*', ) ++ ++ ### Older LibreOffice/OpenOffice and Windows use basis-link/ or basis/ ++ libpath = 'error' ++ for basis in ( 'basis-link', 'basis', '' ): ++ for lib in officelibraries: ++ if os.path.isfile(realpath(basepath, basis, 'program', lib)): ++ libpath = realpath(basepath, basis, 'program') ++ officelibrary = realpath(libpath, lib) ++ info(3, "Found %s in %s" % (lib, libpath)) ++ # Break the inner loop... ++ break ++ # Continue if the inner loop wasn't broken. ++ else: ++ continue ++ # Inner loop was broken, break the outer. ++ break ++ else: ++ continue ++ ++ ### MacOSX have soffice binaries installed in MacOS subdirectory, not program ++ unopath = 'error' ++ for basis in ( 'basis-link', 'basis', '' ): ++ for bin in officebinaries: ++ if os.path.isfile(realpath(basepath, basis, 'program', bin)): ++ unopath = realpath(basepath, basis, 'program') ++ officebinary = realpath(unopath, bin) ++ info(3, "Found %s in %s" % (bin, unopath)) ++ # Break the inner loop... ++ break ++ # Continue if the inner loop wasn't broken. ++ else: ++ continue ++ # Inner loop was broken, break the outer. ++ break ++ else: ++ continue ++ ++ ### Windows does not provide or need a URE/lib directory ? ++ urepath = '' ++ for basis in ( 'basis-link', 'basis', '' ): ++ for ure in ( 'ure-link', 'ure', 'URE', '' ): ++ if os.path.isfile(realpath(basepath, basis, ure, 'lib', 'unorc')): ++ urepath = realpath(basepath, basis, ure) ++ info(3, "Found %s in %s" % ('unorc', realpath(urepath, 'lib'))) ++ # Break the inner loop... ++ break ++ # Continue if the inner loop wasn't broken. ++ else: ++ continue ++ # Inner loop was broken, break the outer. ++ break ++ ++ pythonhome = None ++ for home in pythonhomes: ++ if glob.glob(realpath(libpath, home)): ++ pythonhome = glob.glob(realpath(libpath, home))[0] ++ info(3, "Found %s in %s" % (home, pythonhome)) ++ break ++ ++# if not os.path.isfile(realpath(basepath, program, officebinary)): ++# continue ++# info(3, "Found %s in %s" % (officebinary, realpath(basepath, program))) ++ ++# if not glob.glob(realpath(basepath, basis, program, 'python-core-*')): ++# continue ++ ++ for pythonbinary in pythonbinaries: ++ if os.path.isfile(realpath(unopath, pythonbinary)): ++ info(3, "Found %s in %s" % (pythonbinary, unopath)) ++ ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, ++ realpath(unopath, pythonbinary), pythonhome)) ++ else: ++ info(3, "Considering %s" % basepath) ++ ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, ++ sys.executable, None)) ++ return ret ++ ++def office_environ(office): ++ ### Set PATH so that crash_report is found ++ os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH'] ++ ++ ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: ++ os.environ['UNO_PATH'] = office.unopath ++ ++ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete ++ ### UNO environment ++ if os.name in ( 'nt', 'os2' ): ++ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') ++ else: ++ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamentalrc') ++ ++ ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: ++ if 'LD_LIBRARY_PATH' in os.environ: ++ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ ++ realpath(office.urepath, 'lib') + os.pathsep + \ ++ os.environ['LD_LIBRARY_PATH'] ++ else: ++ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ ++ realpath(office.urepath, 'lib') ++ ++ if office.pythonhome: ++ for libpath in ( realpath(office.pythonhome, 'lib'), ++ realpath(office.pythonhome, 'lib', 'lib-dynload'), ++ realpath(office.pythonhome, 'lib', 'lib-tk'), ++ realpath(office.pythonhome, 'lib', 'site-packages'), ++ office.unopath): ++ sys.path.insert(0, libpath) ++ else: ++ ### Still needed for system python using LibreOffice UNO bindings ++ ### Although we prefer to use a system UNO binding in this case ++ sys.path.append(office.unopath) ++ ++def debug_office(): ++ if 'URE_BOOTSTRAP' in os.environ: ++ print('URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'], file=sys.stderr) ++ if 'UNO_PATH' in os.environ: ++ print('UNO_PATH=%s' % os.environ['UNO_PATH'], file=sys.stderr) ++ if 'UNO_TYPES' in os.environ: ++ print('UNO_TYPES=%s' % os.environ['UNO_TYPES'], file=sys.stderr) ++ print('PATH=%s' % os.environ['PATH']) ++ if 'PYTHONHOME' in os.environ: ++ print('PYTHONHOME=%s' % os.environ['PYTHONHOME'], file=sys.stderr) ++ if 'PYTHONPATH' in os.environ: ++ print('PYTHONPATH=%s' % os.environ['PYTHONPATH'], file=sys.stderr) ++ if 'LD_LIBRARY_PATH' in os.environ: ++ print('LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'], file=sys.stderr) ++ ++def python_switch(office): ++ if office.pythonhome: ++ os.environ['PYTHONHOME'] = office.pythonhome ++ os.environ['PYTHONPATH'] = realpath(office.pythonhome, 'lib') + os.pathsep + \ ++ realpath(office.pythonhome, 'lib', 'lib-dynload') + os.pathsep + \ ++ realpath(office.pythonhome, 'lib', 'lib-tk') + os.pathsep + \ ++ realpath(office.pythonhome, 'lib', 'site-packages') + os.pathsep + \ ++ office.unopath ++ ++ os.environ['UNO_PATH'] = office.unopath ++ ++ info(3, "-> Switching from %s to %s" % (sys.executable, office.python)) ++ if os.name in ('nt', 'os2'): ++ ### os.execv is broken on Windows and can't properly parse command line ++ ### arguments and executable name if they contain whitespaces. subprocess ++ ### fixes that behavior. ++ ret = subprocess.call([office.python] + sys.argv[0:]) ++ sys.exit(ret) ++ else: ++ ++ ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: ++ if 'LD_LIBRARY_PATH' in os.environ: ++ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ ++ realpath(office.urepath, 'lib') + os.pathsep + \ ++ os.environ['LD_LIBRARY_PATH'] ++ else: ++ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ ++ realpath(office.urepath, 'lib') ++ ++ try: ++ os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) ++ print((office.python, [office.python, ] + sys.argv[0:], osenviron)) ++ except OSError: ++ ### Mac OS X versions prior to 10.6 do not support execv in ++ ### a process that contains multiple threads. Instead of ++ ### re-executing in the current process, start a new one ++ ### and cause the current process to exit. This isn't ++ ### ideal since the new process is detached from the parent ++ ### terminal and thus cannot easily be killed with ctrl-C, ++ ### but it's better than not being able to autoreload at ++ ### all. ++ ### Unfortunately the errno returned in this case does not ++ ### appear to be consistent, so we can't easily check for ++ ### this error specifically. ++ ret = os.spawnvpe(os.P_WAIT, office.python, [office.python, ] + sys.argv[0:], os.environ) ++ sys.exit(ret) ++ ++class Fmt: ++ def __init__(self, doctype, name, extension, summary, filter): ++ self.doctype = doctype ++ self.name = name ++ self.extension = extension ++ self.summary = summary ++ self.filter = filter ++ ++ def __str__(self): ++ return "%s [.%s]" % (self.summary, self.extension) ++ ++ def __repr__(self): ++ return "%s/%s" % (self.name, self.doctype) ++ ++class FmtList: ++ def __init__(self): ++ self.list = [] ++ ++ def add(self, doctype, name, extension, summary, filter): ++ self.list.append(Fmt(doctype, name, extension, summary, filter)) ++ ++ def byname(self, name): ++ ret = [] ++ for fmt in self.list: ++ if fmt.name == name: ++ ret.append(fmt) ++ return ret ++ ++ def byextension(self, extension): ++ ret = [] ++ for fmt in self.list: ++ if os.extsep + fmt.extension == extension: ++ ret.append(fmt) ++ return ret ++ ++ def bydoctype(self, doctype, name): ++ ret = [] ++ for fmt in self.list: ++ if fmt.name == name and fmt.doctype == doctype: ++ ret.append(fmt) ++ return ret ++ ++ def display(self, doctype): ++ print("The following list of %s formats are currently available:\n" % doctype, file=sys.stderr) ++ for fmt in self.list: ++ if fmt.doctype == doctype: ++ print(" %-8s - %s" % (fmt.name, fmt), file=sys.stderr) ++ print(file=sys.stderr) ++ ++fmts = FmtList() ++ ++### TextDocument ++fmts.add('document', 'bib', 'bib', 'BibTeX', 'BibTeX_Writer') ### 22 ++fmts.add('document', 'doc', 'doc', 'Microsoft Word 97/2000/XP', 'MS Word 97') ### 29 ++fmts.add('document', 'doc6', 'doc', 'Microsoft Word 6.0', 'MS WinWord 6.0') ### 24 ++fmts.add('document', 'doc95', 'doc', 'Microsoft Word 95', 'MS Word 95') ### 28 ++fmts.add('document', 'docbook', 'xml', 'DocBook', 'DocBook File') ### 39 ++fmts.add('document', 'docx', 'docx', 'Microsoft Office Open XML', 'Office Open XML Text') ++fmts.add('document', 'docx7', 'docx', 'Microsoft Office Open XML', 'MS Word 2007 XML') ++fmts.add('document', 'fodt', 'fodt', 'OpenDocument Text (Flat XML)', 'OpenDocument Text Flat XML') ++fmts.add('document', 'html', 'html', 'HTML Document (OpenOffice.org Writer)', 'HTML (StarWriter)') ### 3 ++fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'LaTeX_Writer') ### 31 ++fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') ++fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 ++fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 ++fmts.add('document', 'ott', 'ott', 'Open Document Text', 'writer8_template') ### 21 ++fmts.add('document', 'pdb', 'pdb', 'AportisDoc (Palm)', 'AportisDoc Palm DB') ++fmts.add('document', 'pdf', 'pdf', 'Portable Document Format', 'writer_pdf_Export') ### 18 ++fmts.add('document', 'psw', 'psw', 'Pocket Word', 'PocketWord File') ++fmts.add('document', 'rtf', 'rtf', 'Rich Text Format', 'Rich Text Format') ### 16 ++fmts.add('document', 'sdw', 'sdw', 'StarWriter 5.0', 'StarWriter 5.0') ### 23 ++fmts.add('document', 'sdw4', 'sdw', 'StarWriter 4.0', 'StarWriter 4.0') ### 2 ++fmts.add('document', 'sdw3', 'sdw', 'StarWriter 3.0', 'StarWriter 3.0') ### 20 ++fmts.add('document', 'stw', 'stw', 'Open Office.org 1.0 Text Document Template', 'writer_StarOffice_XML_Writer_Template') ### 9 ++fmts.add('document', 'sxw', 'sxw', 'Open Office.org 1.0 Text Document', 'StarOffice XML (Writer)') ### 1 ++fmts.add('document', 'text', 'txt', 'Text Encoded', 'Text (encoded)') ### 26 ++fmts.add('document', 'txt', 'txt', 'Text', 'Text') ### 34 ++fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### 27 ++fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 ++fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 ++fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 ++fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 ++ ++### WebDocument ++fmts.add('web', 'etext', 'txt', 'Text Encoded (OpenOffice.org Writer/Web)', 'Text (encoded) (StarWriter/Web)') ### 14 ++fmts.add('web', 'html10', 'html', 'OpenOffice.org 1.0 HTML Template', 'writer_web_StarOffice_XML_Writer_Web_Template') ### 11 ++fmts.add('web', 'html', 'html', 'HTML Document', 'HTML') ### 2 ++fmts.add('web', 'html', 'html', 'HTML Document Template', 'writerweb8_writer_template') ### 13 ++fmts.add('web', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki_Web') ### 9 ++fmts.add('web', 'pdf', 'pdf', 'PDF - Portable Document Format', 'writer_web_pdf_Export') ### 10 ++fmts.add('web', 'sdw3', 'sdw', 'StarWriter 3.0 (OpenOffice.org Writer/Web)', 'StarWriter 3.0 (StarWriter/Web)') ### 3 ++fmts.add('web', 'sdw4', 'sdw', 'StarWriter 4.0 (OpenOffice.org Writer/Web)', 'StarWriter 4.0 (StarWriter/Web)') ### 4 ++fmts.add('web', 'sdw', 'sdw', 'StarWriter 5.0 (OpenOffice.org Writer/Web)', 'StarWriter 5.0 (StarWriter/Web)') ### 5 ++fmts.add('web', 'txt', 'txt', 'OpenOffice.org Text (OpenOffice.org Writer/Web)', 'writerweb8_writer') ### 12 ++fmts.add('web', 'text10', 'txt', 'OpenOffice.org 1.0 Text Document (OpenOffice.org Writer/Web)', 'writer_web_StarOffice_XML_Writer') ### 15 ++fmts.add('web', 'text', 'txt', 'Text (OpenOffice.org Writer/Web)', 'Text (StarWriter/Web)') ### 8 ++fmts.add('web', 'vor4', 'vor', 'StarWriter/Web 4.0 Template', 'StarWriter/Web 4.0 Vorlage/Template') ### 6 ++fmts.add('web', 'vor', 'vor', 'StarWriter/Web 5.0 Template', 'StarWriter/Web 5.0 Vorlage/Template') ### 7 ++ ++### Spreadsheet ++fmts.add('spreadsheet', 'csv', 'csv', 'Text CSV', 'Text - txt - csv (StarCalc)') ### 16 ++fmts.add('spreadsheet', 'dbf', 'dbf', 'dBASE', 'dBase') ### 22 ++fmts.add('spreadsheet', 'dif', 'dif', 'Data Interchange Format', 'DIF') ### 5 ++fmts.add('spreadsheet', 'fods', 'fods', 'OpenDocument Spreadsheet (Flat XML)', 'OpenDocument Spreadsheet Flat XML') ++fmts.add('spreadsheet', 'html', 'html', 'HTML Document (OpenOffice.org Calc)', 'HTML (StarCalc)') ### 7 ++fmts.add('spreadsheet', 'ods', 'ods', 'ODF Spreadsheet', 'calc8') ### 15 ++fmts.add('spreadsheet', 'ooxml', 'xml', 'Microsoft Excel 2003 XML', 'MS Excel 2003 XML') ### 23 ++fmts.add('spreadsheet', 'ots', 'ots', 'ODF Spreadsheet Template', 'calc8_template') ### 14 ++fmts.add('spreadsheet', 'pdf', 'pdf', 'Portable Document Format', 'calc_pdf_Export') ### 34 ++fmts.add('spreadsheet', 'pxl', 'pxl', 'Pocket Excel', 'Pocket Excel') ++fmts.add('spreadsheet', 'sdc', 'sdc', 'StarCalc 5.0', 'StarCalc 5.0') ### 31 ++fmts.add('spreadsheet', 'sdc4', 'sdc', 'StarCalc 4.0', 'StarCalc 4.0') ### 11 ++fmts.add('spreadsheet', 'sdc3', 'sdc', 'StarCalc 3.0', 'StarCalc 3.0') ### 29 ++fmts.add('spreadsheet', 'slk', 'slk', 'SYLK', 'SYLK') ### 35 ++fmts.add('spreadsheet', 'stc', 'stc', 'OpenOffice.org 1.0 Spreadsheet Template', 'calc_StarOffice_XML_Calc_Template') ### 2 ++fmts.add('spreadsheet', 'sxc', 'sxc', 'OpenOffice.org 1.0 Spreadsheet', 'StarOffice XML (Calc)') ### 3 ++fmts.add('spreadsheet', 'uos', 'uos', 'Unified Office Format spreadsheet', 'UOF spreadsheet') ### 9 ++fmts.add('spreadsheet', 'vor3', 'vor', 'StarCalc 3.0 Template', 'StarCalc 3.0 Vorlage/Template') ### 18 ++fmts.add('spreadsheet', 'vor4', 'vor', 'StarCalc 4.0 Template', 'StarCalc 4.0 Vorlage/Template') ### 19 ++fmts.add('spreadsheet', 'vor', 'vor', 'StarCalc 5.0 Template', 'StarCalc 5.0 Vorlage/Template') ### 20 ++fmts.add('spreadsheet', 'xhtml', 'xhtml', 'XHTML', 'XHTML Calc File') ### 26 ++fmts.add('spreadsheet', 'xls', 'xls', 'Microsoft Excel 97/2000/XP', 'MS Excel 97') ### 12 ++fmts.add('spreadsheet', 'xls5', 'xls', 'Microsoft Excel 5.0', 'MS Excel 5.0/95') ### 8 ++fmts.add('spreadsheet', 'xls95', 'xls', 'Microsoft Excel 95', 'MS Excel 95') ### 10 ++fmts.add('spreadsheet', 'xlt', 'xlt', 'Microsoft Excel 97/2000/XP Template', 'MS Excel 97 Vorlage/Template') ### 6 ++fmts.add('spreadsheet', 'xlt5', 'xlt', 'Microsoft Excel 5.0 Template', 'MS Excel 5.0/95 Vorlage/Template') ### 28 ++fmts.add('spreadsheet', 'xlt95', 'xlt', 'Microsoft Excel 95 Template', 'MS Excel 95 Vorlage/Template') ### 21 ++ ++### Graphics ++fmts.add('graphics', 'bmp', 'bmp', 'Windows Bitmap', 'draw_bmp_Export') ### 21 ++fmts.add('graphics', 'emf', 'emf', 'Enhanced Metafile', 'draw_emf_Export') ### 15 ++fmts.add('graphics', 'eps', 'eps', 'Encapsulated PostScript', 'draw_eps_Export') ### 48 ++fmts.add('graphics', 'fodg', 'fodg', 'OpenDocument Drawing (Flat XML)', 'OpenDocument Drawing Flat XML') ++fmts.add('graphics', 'gif', 'gif', 'Graphics Interchange Format', 'draw_gif_Export') ### 30 ++fmts.add('graphics', 'html', 'html', 'HTML Document (OpenOffice.org Draw)', 'draw_html_Export') ### 37 ++fmts.add('graphics', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'draw_jpg_Export') ### 3 ++fmts.add('graphics', 'met', 'met', 'OS/2 Metafile', 'draw_met_Export') ### 43 ++fmts.add('graphics', 'odd', 'odd', 'OpenDocument Drawing', 'draw8') ### 6 ++fmts.add('graphics', 'otg', 'otg', 'OpenDocument Drawing Template', 'draw8_template') ### 20 ++fmts.add('graphics', 'pbm', 'pbm', 'Portable Bitmap', 'draw_pbm_Export') ### 14 ++fmts.add('graphics', 'pct', 'pct', 'Mac Pict', 'draw_pct_Export') ### 41 ++fmts.add('graphics', 'pdf', 'pdf', 'Portable Document Format', 'draw_pdf_Export') ### 28 ++fmts.add('graphics', 'pgm', 'pgm', 'Portable Graymap', 'draw_pgm_Export') ### 11 ++fmts.add('graphics', 'png', 'png', 'Portable Network Graphic', 'draw_png_Export') ### 2 ++fmts.add('graphics', 'ppm', 'ppm', 'Portable Pixelmap', 'draw_ppm_Export') ### 5 ++fmts.add('graphics', 'ras', 'ras', 'Sun Raster Image', 'draw_ras_Export') ## 31 ++fmts.add('graphics', 'std', 'std', 'OpenOffice.org 1.0 Drawing Template', 'draw_StarOffice_XML_Draw_Template') ### 53 ++fmts.add('graphics', 'svg', 'svg', 'Scalable Vector Graphics', 'draw_svg_Export') ### 50 ++fmts.add('graphics', 'svm', 'svm', 'StarView Metafile', 'draw_svm_Export') ### 55 ++fmts.add('graphics', 'swf', 'swf', 'Macromedia Flash (SWF)', 'draw_flash_Export') ### 23 ++fmts.add('graphics', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing', 'StarOffice XML (Draw)') ### 26 ++fmts.add('graphics', 'sxd3', 'sxd', 'StarDraw 3.0', 'StarDraw 3.0') ### 40 ++fmts.add('graphics', 'sxd5', 'sxd', 'StarDraw 5.0', 'StarDraw 5.0') ### 44 ++fmts.add('graphics', 'sxw', 'sxw', 'StarOffice XML (Draw)', 'StarOffice XML (Draw)') ++fmts.add('graphics', 'tiff', 'tiff', 'Tagged Image File Format', 'draw_tif_Export') ### 13 ++fmts.add('graphics', 'vor', 'vor', 'StarDraw 5.0 Template', 'StarDraw 5.0 Vorlage') ### 36 ++fmts.add('graphics', 'vor3', 'vor', 'StarDraw 3.0 Template', 'StarDraw 3.0 Vorlage') ### 35 ++fmts.add('graphics', 'wmf', 'wmf', 'Windows Metafile', 'draw_wmf_Export') ### 8 ++fmts.add('graphics', 'xhtml', 'xhtml', 'XHTML', 'XHTML Draw File') ### 45 ++fmts.add('graphics', 'xpm', 'xpm', 'X PixMap', 'draw_xpm_Export') ### 19 ++ ++### Presentation ++fmts.add('presentation', 'bmp', 'bmp', 'Windows Bitmap', 'impress_bmp_Export') ### 15 ++fmts.add('presentation', 'emf', 'emf', 'Enhanced Metafile', 'impress_emf_Export') ### 16 ++fmts.add('presentation', 'eps', 'eps', 'Encapsulated PostScript', 'impress_eps_Export') ### 17 ++fmts.add('presentation', 'fodp', 'fodp', 'OpenDocument Presentation (Flat XML)', 'OpenDocument Presentation Flat XML') ++fmts.add('presentation', 'gif', 'gif', 'Graphics Interchange Format', 'impress_gif_Export') ### 18 ++fmts.add('presentation', 'html', 'html', 'HTML Document (OpenOffice.org Impress)', 'impress_html_Export') ### 43 ++fmts.add('presentation', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'impress_jpg_Export') ### 19 ++fmts.add('presentation', 'met', 'met', 'OS/2 Metafile', 'impress_met_Export') ### 20 ++fmts.add('presentation', 'odg', 'odg', 'ODF Drawing (Impress)', 'impress8_draw') ### 29 ++fmts.add('presentation', 'odp', 'odp', 'ODF Presentation', 'impress8') ### 9 ++fmts.add('presentation', 'otp', 'otp', 'ODF Presentation Template', 'impress8_template') ### 38 ++fmts.add('presentation', 'pbm', 'pbm', 'Portable Bitmap', 'impress_pbm_Export') ### 21 ++fmts.add('presentation', 'pct', 'pct', 'Mac Pict', 'impress_pct_Export') ### 22 ++fmts.add('presentation', 'pdf', 'pdf', 'Portable Document Format', 'impress_pdf_Export') ### 23 ++fmts.add('presentation', 'pgm', 'pgm', 'Portable Graymap', 'impress_pgm_Export') ### 24 ++fmts.add('presentation', 'png', 'png', 'Portable Network Graphic', 'impress_png_Export') ### 25 ++fmts.add('presentation', 'potm', 'potm', 'Microsoft PowerPoint 2007/2010 XML Template', 'Impress MS PowerPoint 2007 XML Template') ++fmts.add('presentation', 'pot', 'pot', 'Microsoft PowerPoint 97/2000/XP Template', 'MS PowerPoint 97 Vorlage') ### 3 ++fmts.add('presentation', 'ppm', 'ppm', 'Portable Pixelmap', 'impress_ppm_Export') ### 26 ++fmts.add('presentation', 'pptx', 'pptx', 'Microsoft PowerPoint 2007/2010 XML', 'Impress MS PowerPoint 2007 XML') ### 36 ++fmts.add('presentation', 'pps', 'pps', 'Microsoft PowerPoint 97/2000/XP (Autoplay)', 'MS PowerPoint 97 Autoplay') ### 36 ++fmts.add('presentation', 'ppt', 'ppt', 'Microsoft PowerPoint 97/2000/XP', 'MS PowerPoint 97') ### 36 ++fmts.add('presentation', 'pwp', 'pwp', 'PlaceWare', 'placeware_Export') ### 30 ++fmts.add('presentation', 'ras', 'ras', 'Sun Raster Image', 'impress_ras_Export') ### 27 ++fmts.add('presentation', 'sda', 'sda', 'StarDraw 5.0 (OpenOffice.org Impress)', 'StarDraw 5.0 (StarImpress)') ### 8 ++fmts.add('presentation', 'sdd', 'sdd', 'StarImpress 5.0', 'StarImpress 5.0') ### 6 ++fmts.add('presentation', 'sdd3', 'sdd', 'StarDraw 3.0 (OpenOffice.org Impress)', 'StarDraw 3.0 (StarImpress)') ### 42 ++fmts.add('presentation', 'sdd4', 'sdd', 'StarImpress 4.0', 'StarImpress 4.0') ### 37 ++fmts.add('presentation', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing (OpenOffice.org Impress)', 'impress_StarOffice_XML_Draw') ### 31 ++fmts.add('presentation', 'sti', 'sti', 'OpenOffice.org 1.0 Presentation Template', 'impress_StarOffice_XML_Impress_Template') ### 5 ++fmts.add('presentation', 'svg', 'svg', 'Scalable Vector Graphics', 'impress_svg_Export') ### 14 ++fmts.add('presentation', 'svm', 'svm', 'StarView Metafile', 'impress_svm_Export') ### 13 ++fmts.add('presentation', 'swf', 'swf', 'Macromedia Flash (SWF)', 'impress_flash_Export') ### 34 ++fmts.add('presentation', 'sxi', 'sxi', 'OpenOffice.org 1.0 Presentation', 'StarOffice XML (Impress)') ### 41 ++fmts.add('presentation', 'tiff', 'tiff', 'Tagged Image File Format', 'impress_tif_Export') ### 12 ++fmts.add('presentation', 'uop', 'uop', 'Unified Office Format presentation', 'UOF presentation') ### 4 ++fmts.add('presentation', 'vor', 'vor', 'StarImpress 5.0 Template', 'StarImpress 5.0 Vorlage') ### 40 ++fmts.add('presentation', 'vor3', 'vor', 'StarDraw 3.0 Template (OpenOffice.org Impress)', 'StarDraw 3.0 Vorlage (StarImpress)') ###1 ++fmts.add('presentation', 'vor4', 'vor', 'StarImpress 4.0 Template', 'StarImpress 4.0 Vorlage') ### 39 ++fmts.add('presentation', 'vor5', 'vor', 'StarDraw 5.0 Template (OpenOffice.org Impress)', 'StarDraw 5.0 Vorlage (StarImpress)') ### 2 ++fmts.add('presentation', 'wmf', 'wmf', 'Windows Metafile', 'impress_wmf_Export') ### 11 ++fmts.add('presentation', 'xhtml', 'xml', 'XHTML', 'XHTML Impress File') ### 33 ++fmts.add('presentation', 'xpm', 'xpm', 'X PixMap', 'impress_xpm_Export') ### 10 ++ ++class Options: ++ def __init__(self, args): ++ self.connection = None ++ self.debug = False ++ self.doctype = None ++ self.exportfilter = [] ++ self.exportfilteroptions = "" ++ self.filenames = [] ++ self.format = None ++ self.importfilter = [] ++ self.importfilteroptions = "" ++ self.listener = False ++ self.nolaunch = False ++ self.output = None ++ self.password = None ++ self.pipe = None ++ self.port = '2002' ++ self.server = '127.0.0.1' ++ self.showlist = False ++ self.stdout = False ++ self.template = None ++ self.timeout = 6 ++ self.verbose = 0 ++ ++ ### Get options from the commandline ++ try: ++ opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:vV', ++ ['connection=', 'debug', 'doctype=', 'export=', 'format=', ++ 'help', 'import', 'listener', 'no-launch', 'output=', ++ 'outputpath', 'password=', 'pipe=', 'port=', 'server=', ++ 'timeout=', 'show', 'stdout', 'template', 'verbose', ++ 'version'] ) ++ except getopt.error as exc: ++ print('unoconv: %s, try unoconv -h for a list of all the options' % str(exc)) ++ sys.exit(255) ++ ++ for opt, arg in opts: ++ if opt in ['-h', '--help']: ++ self.usage() ++ print() ++ self.help() ++ sys.exit(1) ++ elif opt in ['-c', '--connection']: ++ self.connection = arg ++ elif opt in ['--debug']: ++ self.debug = True ++ elif opt in ['-d', '--doctype']: ++ self.doctype = arg ++ elif opt in ['-e', '--export']: ++ l = arg.split('=') ++ if len(l) == 2: ++ (name, value) = l ++ if name in ('FilterOptions'): ++ self.exportfilteroptions = value ++ elif value in ('True', 'true'): ++ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) ++ elif value in ('False', 'false'): ++ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) ++ else: ++ try: ++ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) ++ except ValueError: ++ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) ++ else: ++ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr) ++ elif opt in ['-f', '--format']: ++ self.format = arg ++ elif opt in ['-i', '--import']: ++ l = arg.split('=') ++ if len(l) == 2: ++ (name, value) = l ++ if name in ('FilterOptions'): ++ self.importfilteroptions = value ++ elif value in ('True', 'true'): ++ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) ++ elif value in ('False', 'false'): ++ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) ++ else: ++ try: ++ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) ++ except ValueError: ++ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) ++ else: ++ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr) ++ elif opt in ['-l', '--listener']: ++ self.listener = True ++ elif opt in ['-n', '--no-launch']: ++ self.nolaunch = True ++ elif opt in ['-o', '--output']: ++ self.output = arg ++ elif opt in ['--outputpath']: ++ print('Warning: This option is deprecated by --output.', file=sys.stderr) ++ self.output = arg ++ elif opt in ['--password']: ++ self.password = arg ++ elif opt in ['--pipe']: ++ self.pipe = arg ++ elif opt in ['-p', '--port']: ++ self.port = arg ++ elif opt in ['-s', '--server']: ++ self.server = arg ++ elif opt in ['--show']: ++ self.showlist = True ++ elif opt in ['--stdout']: ++ self.stdout = True ++ elif opt in ['-t', '--template']: ++ self.template = arg ++ elif opt in ['-T', '--timeout']: ++ self.timeout = int(arg) ++ elif opt in ['-v', '--verbose']: ++ self.verbose = self.verbose + 1 ++ elif opt in ['-V', '--version']: ++ self.version() ++ sys.exit(255) ++ ++ ### Enable verbosity ++ if self.verbose >= 2: ++ print('Verbosity set to level %d' % self.verbose, file=sys.stderr) ++ ++ self.filenames = args ++ ++ if not self.listener and not self.showlist and self.doctype != 'list' and not self.filenames: ++ print('unoconv: you have to provide a filename as argument', file=sys.stderr) ++ print('Try `unoconv -h\' for more information.', file=sys.stderr) ++ sys.exit(255) ++ ++ ### Set connection string ++ if not self.connection: ++ if not self.pipe: ++ self.connection = "socket,host=%s,port=%s;urp;StarOffice.ComponentContext" % (self.server, self.port) ++# self.connection = "socket,host=%s,port=%s;urp;" % (self.server, self.port) ++ else: ++ self.connection = "pipe,name=%s;urp;StarOffice.ComponentContext" % (self.pipe) ++ ++ ### Make it easier for people to use a doctype (first letter is enough) ++ if self.doctype: ++ for doctype in doctypes: ++ if doctype.startswith(self.doctype): ++ self.doctype = doctype ++ ++ ### Check if the user request to see the list of formats ++ if self.showlist or self.format == 'list': ++ if self.doctype: ++ fmts.display(self.doctype) ++ else: ++ for t in doctypes: ++ fmts.display(t) ++ sys.exit(0) ++ ++ ### If no format was specified, probe it or provide it ++ if not self.format: ++ l = sys.argv[0].split('2') ++ if len(l) == 2: ++ self.format = l[1] ++ else: ++ self.format = 'pdf' ++ ++ def version(self): ++ ### Get office product information ++ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) ++ ++ print('unoconv %s' % VERSION) ++ print('Written by Dag Wieers ') ++ print('Homepage at http://dag.wieers.com/home-made/unoconv/') ++ print() ++ print('platform %s/%s' % (os.name, sys.platform)) ++ print('python %s' % sys.version) ++ print(product.ooName, product.ooSetupVersion) ++# print ++# print 'build revision $Rev$' ++ ++ def usage(self): ++ print('usage: unoconv [options] file [file2 ..]', file=sys.stderr) ++ ++ def help(self): ++ print('''Convert from and to any format supported by LibreOffice ++ ++unoconv options: ++ -c, --connection=string use a custom connection string ++ -d, --doctype=type specify document type ++ (document, graphics, presentation, spreadsheet) ++ -e, --export=name=value set export filter options ++ eg. -e PageRange=1-2 ++ -f, --format=format specify the output format ++ -i, --import=string set import filter option string ++ eg. -i utf8 ++ -l, --listener start a permanent listener to use by unoconv clients ++ -n, --no-launch fail if no listener is found (default: launch one) ++ -o, --output=name output basename, filename or directory ++ --pipe=name alternative method of connection using a pipe ++ -p, --port=port specify the port (default: 2002) ++ to be used by client or listener ++ --password=string provide a password to decrypt the document ++ -s, --server=server specify the server address (default: 127.0.0.1) ++ to be used by client or listener ++ --show list the available output formats ++ --stdout write output to stdout ++ -t, --template=file import the styles from template (.ott) ++ -T, --timeout=secs timeout after secs if connection to listener fails ++ -v, --verbose be more and more verbose (-vvv for debugging) ++''', file=sys.stderr) ++ ++class Convertor: ++ def __init__(self): ++ global exitcode, ooproc, office, product ++ unocontext = None ++ ++ ### Do the LibreOffice component dance ++ self.context = global_uno.getComponentContext() ++ self.svcmgr = self.context.ServiceManager ++ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) ++ ++ ### Test for an existing connection ++ info(3, 'Connection type: %s' % op.connection) ++ try: ++ unocontext = resolver.resolve("uno:%s" % op.connection) ++ except UnoNoConnectException as e: ++# info(3, "Existing listener not found.\n%s" % e) ++ info(3, "Existing listener not found.") ++ ++ if op.nolaunch: ++ die(113, "Existing listener not found. Unable start listener by parameters. Aborting.") ++ ++ ### Start our own OpenOffice instance ++ info(3, "Launching our own listener using %s." % office.binary) ++ try: ++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) ++ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): ++ ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) ++ else: ++ ooproc = subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--accept=%s" % op.connection], env=os.environ) ++ info(2, '%s listener successfully started. (pid=%s)' % (product.ooName, ooproc.pid)) ++ ++ ### Try connection to it for op.timeout seconds (flakky OpenOffice) ++ timeout = 0 ++ while timeout <= op.timeout: ++ ### Is it already/still running ? ++ retcode = ooproc.poll() ++ if retcode != None: ++ info(3, "Process %s (pid=%s) exited with %s." % (office.binary, ooproc.pid, retcode)) ++ break ++ try: ++ unocontext = resolver.resolve("uno:%s" % op.connection) ++ break ++ except UnoNoConnectException: ++ time.sleep(0.5) ++ timeout += 0.5 ++ except: ++ raise ++ else: ++ error("Failed to connect to %s (pid=%s) in %d seconds.\n%s" % (office.binary, ooproc.pid, op.timeout, e)) ++ except Exception as e: ++ raise ++ error("Launch of %s failed.\n%s" % (office.binary, e)) ++ ++ if not unocontext: ++ die(251, "Unable to connect or start own listener. Aborting.") ++ ++ ### And some more LibreOffice magic ++ unosvcmgr = unocontext.ServiceManager ++ self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) ++ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() ) ++ ++ ### List all filters ++# self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) ++# for filter in self.filters.getElementNames(): ++# print filter ++# #print dir(filter), dir(filter.format) ++ ++ def getformat(self, inputfn): ++ doctype = None ++ ++ ### Get the output format from mapping ++ if op.doctype: ++ outputfmt = fmts.bydoctype(op.doctype, op.format) ++ else: ++ outputfmt = fmts.byname(op.format) ++ ++ if not outputfmt: ++ outputfmt = fmts.byextension(os.extsep + op.format) ++ ++ ### If no doctype given, check list of acceptable formats for input file ext doctype ++ ### FIXME: This should go into the for-loop to match each individual input filename ++ if outputfmt: ++ inputext = os.path.splitext(inputfn)[1] ++ inputfmt = fmts.byextension(inputext) ++ if inputfmt: ++ for fmt in outputfmt: ++ if inputfmt[0].doctype == fmt.doctype: ++ doctype = inputfmt[0].doctype ++ outputfmt = fmt ++ break ++ else: ++ outputfmt = outputfmt[0] ++ # print >>sys.stderr, 'unoconv: format `%s\' is part of multiple doctypes %s, selecting `%s\'.' % (format, [fmt.doctype for fmt in outputfmt], outputfmt[0].doctype) ++ else: ++ outputfmt = outputfmt[0] ++ ++ ### No format found, throw error ++ if not outputfmt: ++ if doctype: ++ print('unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format), file=sys.stderr) ++ else: ++ print('unoconv: format [%s] is not known to unoconv.' % op.format, file=sys.stderr) ++ die(1) ++ ++ return outputfmt ++ ++ def convert(self, inputfn): ++ global exitcode ++ ++ document = None ++ outputfmt = self.getformat(inputfn) ++ ++ if op.verbose > 0: ++ print('Input file:', inputfn, file=sys.stderr) ++ ++ if not os.path.exists(inputfn): ++ print('unoconv: file `%s\' does not exist.' % inputfn, file=sys.stderr) ++ exitcode = 1 ++ ++ try: ++ ### Import phase ++ phase = "import" ++ ++ ### Load inputfile ++ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE) ++ ++# if op.password: ++# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") ++# inputprops += GlobalUnoProps(ModifyPasswordInfo=info) ++ ++ ### Cannot use GlobalUnoProps for FilterData property ++ if op.importfilteroptions: ++# print "Import filter options: %s" % op.importfilteroptions ++ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions) ++ ++ ### Cannot use GlobalUnoProps for FilterData property ++ if op.importfilter: ++ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) ++ ++ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn)) ++ document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) ++ ++ if not document: ++ raise UnoException("The document '%s' could not be opened." % inputurl, None) ++ ++ ### Import style template ++ phase = "import-style" ++ if op.template: ++ if os.path.exists(op.template): ++ info(1, "Template file: %s" % op.template) ++ templateprops = GlobalUnoProps(OverwriteStyles=True) ++ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template)) ++ document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) ++ else: ++ print('unoconv: template file `%s\' does not exist.' % op.template, file=sys.stderr) ++ exitcode = 1 ++ ++ ### Update document links ++ phase = "update-links" ++ try: ++ document.updateLinks() ++ except AttributeError: ++ # the document doesn't implement the XLinkUpdate interface ++ pass ++ ++ ### Update document indexes ++ phase = "update-indexes" ++ try: ++ document.refresh() ++ indexes = document.getDocumentIndexes() ++ except AttributeError: ++ # the document doesn't implement the XRefreshable and/or ++ # XDocumentIndexesSupplier interfaces ++ pass ++ else: ++ for i in range(0, indexes.getCount()): ++ indexes.getByIndex(i).update() ++ ++ info(1, "Selected output format: %s" % outputfmt) ++ info(2, "Selected office filter: %s" % outputfmt.filter) ++ info(2, "Used doctype: %s" % outputfmt.doctype) ++ ++ ### Export phase ++ phase = "export" ++ ++ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True) ++ ++ ### Set default filter options ++ if op.exportfilteroptions: ++# print "Export filter options: %s" % op.exportfilteroptions ++ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions) ++ else: ++ if outputfmt.filter == 'Text (encoded)': ++ outputprops += GlobalUnoProps(FilterOptions="76,LF") ++ ++ elif outputfmt.filter == 'Text': ++ outputprops += GlobalUnoProps(FilterOptions="76") ++ ++ elif outputfmt.filter == 'Text - txt - csv (StarCalc)': ++ outputprops += GlobalUnoProps(FilterOptions="44,34,76") ++ ++ ++ ### Cannot use GlobalUnoProps for FilterData property ++ if op.exportfilter: ++ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) ++ ++ if not op.stdout: ++ (outputfn, ext) = os.path.splitext(inputfn) ++ if not op.output: ++ outputfn = outputfn + os.extsep + outputfmt.extension ++ elif os.path.isdir(op.output): ++ outputfn = realpath(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension) ++ elif len(op.filenames) > 1: ++ outputfn = op.output + os.extsep + outputfmt.extension ++ else: ++ outputfn = op.output ++ ++ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) ) ++ info(1, "Output file: %s" % outputfn) ++ else: ++ outputurl = "private:stream" ++ ++ try: ++ document.storeToURL(outputurl, tuple(outputprops) ) ++ except UnoIOException as e: ++ raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) ++ ++ phase = "dispose" ++ document.dispose() ++ document.close(True) ++ ++ except SystemError as e: ++ error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) ++ exitcode = 1 ++ ++ except UnoRuntimeException as e: ++ error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) ++ exitcode = 6 ++ ++ except UnoDisposedException as e: ++ error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) ++ exitcode = 7 ++ ++ except UnoIllegalArgumentException as e: ++ error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) ++ exitcode = 8 ++ ++ except UnoIOException as e: ++# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) ++ error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) ++ exitcode = 3 ++ ++ except UnoCannotConvertException as e: ++# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) ++ error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) ++ exitcode = 4 ++ ++ except UnoException as e: ++ if hasattr(e, 'ErrCode'): ++ error("unoconv: UnoException during %s phase in %s (ErrCode %d)" % (phase, repr(e.__class__), e.ErrCode)) ++ exitcode = e.ErrCode ++ pass ++ if hasattr(e, 'Message'): ++ error("unoconv: UnoException during %s phase:\n%s" % (phase, e.Message)) ++ exitcode = 5 ++ else: ++ error("unoconv: UnoException during %s phase in %s" % (phase, repr(e.__class__))) ++ exitcode = 2 ++ pass ++ ++class Listener: ++ def __init__(self): ++ global product ++ ++ info(1, "Start listener on %s:%s" % (op.server, op.port)) ++ self.context = global_uno.getComponentContext() ++ self.svcmgr = self.context.ServiceManager ++ try: ++ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) ++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) ++ try: ++ unocontext = resolver.resolve("uno:%s" % op.connection) ++ except UnoNoConnectException as e: ++ pass ++ else: ++ info(1, "Existing %s listener found, nothing to do." % product.ooName) ++ return ++ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): ++ subprocess.call([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection], env=os.environ) ++ else: ++ subprocess.call([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection], env=os.environ) ++ except Exception as e: ++ error("Launch of %s failed.\n%s" % (office.binary, e)) ++ else: ++ info(1, "Existing %s listener found, nothing to do." % product.ooName) ++ ++def error(msg): ++ "Output error message" ++ print(msg, file=sys.stderr) ++ ++def info(level, msg): ++ "Output info message" ++ if 'op' not in globals(): ++ pass ++ elif op.verbose >= 3 and level >= 3: ++ print("DEBUG:", msg, file=sys.stderr) ++ elif not op.stdout and level <= op.verbose: ++ print(msg, file=sys.stdout) ++ elif level <= op.verbose: ++ print(msg, file=sys.stderr) ++ ++def die(ret, msg=None): ++ "Print optional error and exit with errorcode" ++ global convertor, ooproc, office ++ ++ if msg: ++ error('Error: %s' % msg) ++ ++ ### Did we start our own listener instance ? ++ if not op.listener and ooproc and convertor: ++ ++ ### If there is a GUI now attached to the instance, disable listener ++ if convertor.desktop.getCurrentFrame(): ++ info(2, 'Trying to stop %s GUI listener.' % product.ooName) ++ try: ++ if product.ooName != "LibreOffice" or product.ooSetupVersion <= 3.3: ++ subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection], env=os.environ) ++ else: ++ subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection], env=os.environ) ++ ooproc.wait() ++ info(2, '%s listener successfully disabled.' % product.ooName) ++ except Exception as e: ++ error("Terminate using %s failed.\n%s" % (office.binary, e)) ++ ++ ### If there is no GUI attached to the instance, terminate instance ++ else: ++ info(3, 'Terminating %s instance.' % product.ooName) ++ try: ++ convertor.desktop.terminate() ++ except UnoDisposedException: ++ info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) ++ try: ++ ooproc.terminate() ++ except AttributeError: ++ os.kill(ooproc.pid, 15) ++ info(3, 'Waiting for %s instance to exit.' % product.ooName) ++ ooproc.wait() ++ ++ ### LibreOffice processes may get stuck and we have to kill them ++ ### Is it still running ? ++ if ooproc.poll() == None: ++ info(1, '%s instance still running, please investigate...' % product.ooName) ++ ooproc.wait() ++ info(2, '%s instance unsuccessfully terminated, sending KILL signal.' % product.ooName) ++ try: ++ ooproc.kill() ++ except AttributeError: ++ os.kill(ooproc.pid, 9) ++ info(3, 'Waiting for %s with pid %s to disappear.' % (ooproc.pid, product.ooName)) ++ ooproc.wait() ++ ++ # allow Python GC to garbage collect pyuno object *before* exit call ++ # which avoids random segmentation faults --vpa ++ convertor = None ++ ++ sys.exit(ret) ++ ++def main(): ++ global convertor, exitcode ++ convertor = None ++ ++ try: ++ if op.listener: ++ listener = Listener() ++ ++ if op.filenames: ++ convertor = Convertor() ++ for inputfn in op.filenames: ++ convertor.convert(inputfn) ++ ++ except UnoNoConnectException as e: ++ error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) ++ if op.connection: ++ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) ++ else: ++ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"socket,host=%s,port=%s;urp;\"" % (op.server, op.server, op.port, op.server, op.port)) ++ info(0, "Please start an soffice instance on server '%s' by doing:\n\n soffice -nologo -nodefault -accept=\"socket,host=127.0.0.1,port=%s;urp;\"" % (op.server, op.port)) ++ exitcode = 1 ++# except UnboundLocalError: ++# die(252, "Failed to connect to remote listener.") ++ except OSError: ++ error("Warning: failed to launch Office suite. Aborting.") ++ ++### Main entrance ++def run(): ++ global exitcode ++ exitcode = 0 ++ ++ info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) ++ ++ for of in find_offices(): ++ if of.python != sys.executable and not sys.executable.startswith(of.basepath): ++ python_switch(of) ++ office_environ(of) ++# debug_office() ++ try: ++ global global_uno ++ global global_unohelper ++ ++ import uno as global_uno ++ import unohelper as global_unohelper ++ global office ++ office = of ++ break ++ except: ++# debug_office() ++ print("unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of, file=sys.stderr) ++ print("ERROR:", sys.exc_info()[1], file=sys.stderr) ++ print(file=sys.stderr) ++ else: ++# debug_office() ++ print("unoconv: Cannot find a suitable office installation on your system.", file=sys.stderr) ++ print("ERROR: Please locate your office installation and send your feedback to:", file=sys.stderr) ++ print(" http://github.com/dagwieers/unoconv/issues", file=sys.stderr) ++ sys.exit(1) ++ ++ ### Now that we have found a working pyuno library, let's import some classes ++ global UnoPropertyValue ++ global UnoNoConnectException ++ global UNO_QUIET_UPDATE ++ global UnoDisposedException ++ global UnoIllegalArgumentException ++ global UnoIOException ++ global UnoXOutputStream ++ global UnoCannotConvertException ++ global UnoException ++ global UnoRuntimeException ++ ++ from com.sun.star.beans import PropertyValue as UnoPropertyValue ++ from com.sun.star.connection import NoConnectException as UnoNoConnectException ++ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE ++ from com.sun.star.lang import DisposedException as UnoDisposedException ++ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException ++ from com.sun.star.io import IOException as UnoIOException ++ from com.sun.star.io import XOutputStream as UnoXOutputStream ++ from com.sun.star.script import CannotConvertException as UnoCannotConvertException ++ from com.sun.star.uno import Exception as UnoException ++ from com.sun.star.uno import RuntimeException as UnoRuntimeException ++ ++ ### And now that we have those classes, build on them ++ class OutputStream( global_unohelper.Base, UnoXOutputStream ): ++ def __init__( self ): ++ self.closed = 0 ++ ++ def closeOutput(self): ++ self.closed = 1 ++ ++ def writeBytes( self, seq ): ++ sys.stdout.write( seq.value ) ++ ++ def flush( self ): ++ pass ++ ++ global GlobalOutputStream ++ GlobalOutputStream = OutputStream ++ ++ def UnoProps(**args): ++ props = [] ++ for key in args: ++ prop = UnoPropertyValue() ++ prop.Name = key ++ prop.Value = args[key] ++ props.append(prop) ++ return tuple(props) ++ ++ global GlobalUnoProps ++ GlobalUnoProps = UnoProps ++ ++ global op ++ op = Options(sys.argv[1:]) ++ ++ info(2, "Using office base path: %s" % office.basepath) ++ info(2, "Using office binary path: %s" % office.unopath) ++ ++ try: ++ main() ++ except KeyboardInterrupt as e: ++ die(6, 'Exiting on user request') ++ die(exitcode) ++ ++if __name__ == '__main__': ++ run() +-- +1.7.11.7 + diff --git a/0001-update-FSF-address.patch b/0001-update-FSF-address.patch index 925cf4f..da5f208 100644 --- a/0001-update-FSF-address.patch +++ b/0001-update-FSF-address.patch @@ -138,6 +138,34 @@ index 30e6706..e4a1ac8 100755 ### along with this program; if not, write to the Free Software -### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++### MA 02110-1301 USA. + + import sys + +diff --git a/unoconv2.py b/unoconv2.py +index 30e6706..e4a1ac8 100755 +--- a/unoconv2.py ++++ b/unoconv2.py +@@ -11,7 +11,8 @@ + ### + ### You should have received a copy of the GNU General Public License + ### along with this program; if not, write to the Free Software +-### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++### MA 02110-1301 USA. + ### Copyright 2007-2010 Dag Wieers + + from distutils.version import LooseVersion +diff --git a/unoconv3.py b/unoconv3.py +index 30e6706..e4a1ac8 100755 +--- a/unoconv3.py ++++ b/unoconv3.py +@@ -11,7 +11,8 @@ + ### + ### You should have received a copy of the GNU General Public License + ### along with this program; if not, write to the Free Software +-### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +### MA 02110-1301 USA. ### Copyright 2007-2010 Dag Wieers diff --git a/unoconv.spec b/unoconv.spec index 2a4052c..5991fcb 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,12 +1,14 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz -Patch0: 0001-update-FSF-address.patch +Patch0: 0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch +Patch1: 0001-python3-added-compatibility.patch +Patch2: 0001-update-FSF-address.patch BuildArch: noarch Requires: libreoffice-core @@ -24,18 +26,28 @@ RTF, Docbook (.xml), and more. %prep %setup -q %patch0 -p1 +%patch1 -p1 +%patch2 -p1 %build %install make install DESTDIR="%{buildroot}" +sed -i -e 1s/python/python3/ %{buildroot}/%{_bindir}/%{name} +# we are forcing use of python3 anyway +rm %{buildroot}/%{_bindir}/%{name}2.py + %files %doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST doc/*.txt tests/ %{_mandir}/man1/%{name}.1* %{_bindir}/%{name} +%{_bindir}/%{name}3.py %changelog +* Mon Apr 08 2013 David Tardon - 0.6-3 +- Resolves: rhbz#947096 unoconv doesn't work with Libreoffice 4.0 + * Fri Feb 15 2013 Fedora Release Engineering - 0.6-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild From b4d2c6e6ba092825649f2c9588dbe9f50915151c Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 29 May 2013 14:34:29 +0200 Subject: [PATCH 21/71] fix unoconv on rhel --- 0001-python3-added-compatibility.patch | 2 +- unoconv.spec | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/0001-python3-added-compatibility.patch b/0001-python3-added-compatibility.patch index c788e2d..bbf638d 100644 --- a/0001-python3-added-compatibility.patch +++ b/0001-python3-added-compatibility.patch @@ -2428,7 +2428,7 @@ index 0000000..09d88c2 --- /dev/null +++ b/unoconv3.py @@ -0,0 +1,1195 @@ -+#!/usr/bin/env python ++#!/usr/bin/env python3 + +### This program is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by diff --git a/unoconv.spec b/unoconv.spec index 5991fcb..02c098a 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -33,18 +33,26 @@ RTF, Docbook (.xml), and more. %install make install DESTDIR="%{buildroot}" -sed -i -e 1s/python/python3/ %{buildroot}/%{_bindir}/%{name} -# we are forcing use of python3 anyway -rm %{buildroot}/%{_bindir}/%{name}2.py +pushd %{buildroot}/%{_bindir} +%if 0%{?fedora} >= 19 + mv %{name}3.py %{name} + rm %{name}2.py +%else + mv %{name}2.py %{name} + rm %{name}3.py +%endif +popd %files %doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST doc/*.txt tests/ %{_mandir}/man1/%{name}.1* %{_bindir}/%{name} -%{_bindir}/%{name}3.py %changelog +* Wed May 29 2013 David Tardon - 0.6-4 +- rhbz#957776 cannot open office documents + * Mon Apr 08 2013 David Tardon - 0.6-3 - Resolves: rhbz#947096 unoconv doesn't work with Libreoffice 4.0 From 39c1900e82323fd040d36ed4e520042060cf2b4d Mon Sep 17 00:00:00 2001 From: David Tardon Date: Tue, 23 Jul 2013 09:45:56 +0200 Subject: [PATCH 22/71] Resolves: rhbz#987046 drop env from shebang --- 0001-python3-added-compatibility.patch | 4 ++-- unoconv.spec | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/0001-python3-added-compatibility.patch b/0001-python3-added-compatibility.patch index bbf638d..e8d3bca 100644 --- a/0001-python3-added-compatibility.patch +++ b/0001-python3-added-compatibility.patch @@ -1227,7 +1227,7 @@ index 0000000..1aecbb6 --- /dev/null +++ b/unoconv2.py @@ -0,0 +1,1195 @@ -+#!/usr/bin/env python ++#!/usr/bin/python + +### This program is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by @@ -2428,7 +2428,7 @@ index 0000000..09d88c2 --- /dev/null +++ b/unoconv3.py @@ -0,0 +1,1195 @@ -+#!/usr/bin/env python3 ++#!/usr/bin/python3 + +### This program is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by diff --git a/unoconv.spec b/unoconv.spec index 02c098a..5f34c62 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -50,6 +50,9 @@ popd %{_bindir}/%{name} %changelog +* Tue Jul 23 2013 David Tardon - 0.6-5 +- Resolves: rhbz#987046 drop env from shebang + * Wed May 29 2013 David Tardon - 0.6-4 - rhbz#957776 cannot open office documents From 4c0137d0b30b104c19e65e88a895f92f8a6d941d Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Sun, 4 Aug 2013 00:39:21 -0500 Subject: [PATCH 23/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 5f34c62..82bd936 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -50,6 +50,9 @@ popd %{_bindir}/%{name} %changelog +* Sun Aug 04 2013 Fedora Release Engineering - 0.6-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + * Tue Jul 23 2013 David Tardon - 0.6-5 - Resolves: rhbz#987046 drop env from shebang From 74c88738c8f34911971a968055e206b08f6444e5 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 30 Jan 2014 16:43:32 +0100 Subject: [PATCH 24/71] pull in all libreoffice filters --- unoconv.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unoconv.spec b/unoconv.spec index 82bd936..9624e03 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -11,7 +11,7 @@ Patch1: 0001-python3-added-compatibility.patch Patch2: 0001-update-FSF-address.patch BuildArch: noarch -Requires: libreoffice-core +Requires: libreoffice-filters Requires: libreoffice-pyuno %description @@ -50,6 +50,9 @@ popd %{_bindir}/%{name} %changelog +* Thu Jan 30 2014 David Tardon - 0.6-7 +- pull in all libreoffice filters + * Sun Aug 04 2013 Fedora Release Engineering - 0.6-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild From 941033dfd6361b62239cc95ed8b8208228255e90 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 12 Feb 2014 11:16:16 +0100 Subject: [PATCH 25/71] Resolves: rhbz#1047539 --stdout option does not work --- ...09-can-t-write-bytes-direct-to-stdou.patch | 39 +++++++++++++++++++ unoconv.spec | 7 +++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch diff --git a/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch b/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch new file mode 100644 index 0000000..24dca0d --- /dev/null +++ b/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch @@ -0,0 +1,39 @@ +From 3249fd3df136f1a859ac0272f75fcbf010926d58 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Thu, 7 Nov 2013 13:33:37 +0000 +Subject: [PATCH] Resolves: fdo#70309 can't write bytes direct to stdout in + python3 + +--- + unoconv | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/unoconv2.py b/unoconv2.py +index a4f9490..2b0b0eb 100755 +--- a/unoconv2.py ++++ b/unoconv2.py +@@ -1146,7 +1146,7 @@ if __name__ == '__main__': + self.closed = 1 + + def writeBytes( self, seq ): +- sys.stdout.write( seq.value ) ++ sys.stdout.buffer.write( seq.value ) + + def flush( self ): + pass +diff --git a/unoconv3.py b/unoconv3.py +index a4f9490..2b0b0eb 100755 +--- a/unoconv3.py ++++ b/unoconv3.py +@@ -1146,7 +1146,7 @@ if __name__ == '__main__': + self.closed = 1 + + def writeBytes( self, seq ): +- sys.stdout.write( seq.value ) ++ sys.stdout.buffer.write( seq.value ) + + def flush( self ): + pass +-- +1.8.5.3 + diff --git a/unoconv.spec b/unoconv.spec index 9624e03..8f0544b 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -9,6 +9,7 @@ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz Patch0: 0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch Patch1: 0001-python3-added-compatibility.patch Patch2: 0001-update-FSF-address.patch +Patch3: 0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch BuildArch: noarch Requires: libreoffice-filters @@ -28,6 +29,7 @@ RTF, Docbook (.xml), and more. %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 %build @@ -50,6 +52,9 @@ popd %{_bindir}/%{name} %changelog +* Wed Feb 12 2014 David Tardon - 0.6-8 +- Resolves: rhbz#1047539 --stdout option does not work + * Thu Jan 30 2014 David Tardon - 0.6-7 - pull in all libreoffice filters From 94b2acba1f94be880dfd890789160c14d47fa123 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 12 Feb 2014 21:19:43 +0100 Subject: [PATCH 26/71] use %autosetup --- unoconv.spec | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/unoconv.spec b/unoconv.spec index 8f0544b..7aa3659 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -25,11 +25,7 @@ MS Office Open/MS OOXML (.xml), Portable Document Format (.pdf), HTML, XHTML, RTF, Docbook (.xml), and more. %prep -%setup -q -%patch0 -p1 -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 +%autosetup -p1 %build From eb557f114f40b586899d06cab2fc72be84da1f0e Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 17 Apr 2014 14:41:29 +0200 Subject: [PATCH 27/71] Resolves: rhbz#1076275 unonconv trips over '-f latex' --- unoconv.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 7aa3659..5fe9657 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -14,6 +14,7 @@ Patch3: 0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch BuildArch: noarch Requires: libreoffice-filters Requires: libreoffice-pyuno +Requires: libreoffice-writer2latex %description unoconv converts between any document format that LibreOffice understands. @@ -48,6 +49,9 @@ popd %{_bindir}/%{name} %changelog +* Thu Apr 17 2014 David Tardon - 0.6-9 +- Resolves: rhbz#1076275 unonconv trips over '-f latex' + * Wed Feb 12 2014 David Tardon - 0.6-8 - Resolves: rhbz#1047539 --stdout option does not work From e94c2df7ec6b331ddb4833146c389e6445b22183 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Sat, 19 Apr 2014 12:11:44 +0200 Subject: [PATCH 28/71] simplify python3 patch --- ...09-can-t-write-bytes-direct-to-stdou.patch | 19 +- 0001-python3-added-compatibility.2.patch | 384 ++ 0001-python3-added-compatibility.3.patch | 629 +++ 0001-python3-added-compatibility.patch | 3628 ----------------- 0001-update-FSF-address.patch | 28 - unoconv.spec | 16 +- 6 files changed, 1021 insertions(+), 3683 deletions(-) create mode 100644 0001-python3-added-compatibility.2.patch create mode 100644 0001-python3-added-compatibility.3.patch delete mode 100644 0001-python3-added-compatibility.patch diff --git a/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch b/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch index 24dca0d..e96aa8c 100644 --- a/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch +++ b/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch @@ -8,23 +8,10 @@ Subject: [PATCH] Resolves: fdo#70309 can't write bytes direct to stdout in unoconv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/unoconv2.py b/unoconv2.py +diff --git a/unoconv b/unoconv index a4f9490..2b0b0eb 100755 ---- a/unoconv2.py -+++ b/unoconv2.py -@@ -1146,7 +1146,7 @@ if __name__ == '__main__': - self.closed = 1 - - def writeBytes( self, seq ): -- sys.stdout.write( seq.value ) -+ sys.stdout.buffer.write( seq.value ) - - def flush( self ): - pass -diff --git a/unoconv3.py b/unoconv3.py -index a4f9490..2b0b0eb 100755 ---- a/unoconv3.py -+++ b/unoconv3.py +--- a/unoconv ++++ b/unoconv @@ -1146,7 +1146,7 @@ if __name__ == '__main__': self.closed = 1 diff --git a/0001-python3-added-compatibility.2.patch b/0001-python3-added-compatibility.2.patch new file mode 100644 index 0000000..d5416c7 --- /dev/null +++ b/0001-python3-added-compatibility.2.patch @@ -0,0 +1,384 @@ +From 34bbe9fa679d39921fd67002e01e7a9bf93b009a Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Sat, 19 Apr 2014 12:05:04 +0200 +Subject: [PATCH] 0001-python3-added-compatibility.2.patch + +--- + unoconv | 142 +++++++++++++++++++++++++++++++++++++++------------------------- + 1 file changed, 86 insertions(+), 56 deletions(-) + +diff --git a/unoconv b/unoconv +index 30e6706..8c45ad9 100755 +--- a/unoconv ++++ b/unoconv +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python + + ### This program is free software; you can redistribute it and/or modify + ### it under the terms of the GNU General Public License as published by +@@ -203,7 +203,7 @@ def office_environ(office): + ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: + os.environ['UNO_PATH'] = office.unopath + +- ### Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete ++ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete + ### UNO environment + if os.name in ( 'nt', 'os2' ): + os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') +@@ -277,6 +277,7 @@ def python_switch(office): + + try: + os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) ++ print(office.python, [office.python, ] + sys.argv[0:], osenviron) + except OSError: + ### Mac OS X versions prior to 10.6 do not support execv in + ### a process that contains multiple threads. Instead of +@@ -553,14 +554,14 @@ class Options: + if name in ('FilterOptions'): + self.exportfilteroptions = value + elif value in ('True', 'true'): +- self.exportfilter.append( PropertyValue( name, 0, True, 0 ) ) ++ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) + elif value in ('False', 'false'): +- self.exportfilter.append( PropertyValue( name, 0, False, 0 ) ) ++ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) + else: + try: +- self.exportfilter.append( PropertyValue( name, 0, int(value), 0 ) ) ++ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) + except ValueError: +- self.exportfilter.append( PropertyValue( name, 0, value, 0 ) ) ++ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) + else: + print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg + elif opt in ['-f', '--format']: +@@ -572,14 +573,14 @@ class Options: + if name in ('FilterOptions'): + self.importfilteroptions = value + elif value in ('True', 'true'): +- self.importfilter.append( PropertyValue( name, 0, True, 0 ) ) ++ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) + elif value in ('False', 'false'): +- self.importfilter.append( PropertyValue( name, 0, False, 0 ) ) ++ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) + else: + try: +- self.importfilter.append( PropertyValue( name, 0, int(value), 0 ) ) ++ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) + except ValueError: +- self.importfilter.append( PropertyValue( name, 0, value, 0 ) ) ++ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) + else: + print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg + elif opt in ['-l', '--listener']: +@@ -657,7 +658,7 @@ class Options: + + def version(self): + ### Get office product information +- product = uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) ++ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) + + print 'unoconv %s' % VERSION + print 'Written by Dag Wieers ' +@@ -706,7 +707,7 @@ class Convertor: + unocontext = None + + ### Do the LibreOffice component dance +- self.context = uno.getComponentContext() ++ self.context = global_uno.getComponentContext() + self.svcmgr = self.context.ServiceManager + resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) + +@@ -714,7 +715,7 @@ class Convertor: + info(3, 'Connection type: %s' % op.connection) + try: + unocontext = resolver.resolve("uno:%s" % op.connection) +- except NoConnectException, e: ++ except UnoNoConnectException, e: + # info(3, "Existing listener not found.\n%s" % e) + info(3, "Existing listener not found.") + +@@ -724,7 +725,7 @@ class Convertor: + ### Start our own OpenOffice instance + info(3, "Launching our own listener using %s." % office.binary) + try: +- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) ++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) + if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): + ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) + else: +@@ -742,7 +743,7 @@ class Convertor: + try: + unocontext = resolver.resolve("uno:%s" % op.connection) + break +- except NoConnectException: ++ except UnoNoConnectException: + time.sleep(0.5) + timeout += 0.5 + except: +@@ -759,7 +760,7 @@ class Convertor: + ### And some more LibreOffice magic + unosvcmgr = unocontext.ServiceManager + self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) +- self.cwd = unohelper.systemPathToFileUrl( os.getcwd() ) ++ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() ) + + ### List all filters + # self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) +@@ -824,22 +825,22 @@ class Convertor: + phase = "import" + + ### Load inputfile +- inputprops = UnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=QUIET_UPDATE) ++ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE) + + # if op.password: +-# info = UnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") +-# inputprops += UnoProps(ModifyPasswordInfo=info) ++# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") ++# inputprops += GlobalUnoProps(ModifyPasswordInfo=info) + +- ### Cannot use UnoProps for FilterData property ++ ### Cannot use GlobalUnoProps for FilterData property + if op.importfilteroptions: + # print "Import filter options: %s" % op.importfilteroptions +- inputprops += UnoProps(FilterOptions=op.importfilteroptions) ++ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions) + +- ### Cannot use UnoProps for FilterData property ++ ### Cannot use GlobalUnoProps for FilterData property + if op.importfilter: +- inputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) ++ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) + +- inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn)) ++ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn)) + document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) + + if not document: +@@ -850,8 +851,8 @@ class Convertor: + if op.template: + if os.path.exists(op.template): + info(1, "Template file: %s" % op.template) +- templateprops = UnoProps(OverwriteStyles=True) +- templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template)) ++ templateprops = GlobalUnoProps(OverwriteStyles=True) ++ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template)) + document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) + else: + print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template +@@ -885,26 +886,26 @@ class Convertor: + ### Export phase + phase = "export" + +- outputprops = UnoProps(FilterName=outputfmt.filter, OutputStream=OutputStream(), Overwrite=True) ++ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True) + + ### Set default filter options + if op.exportfilteroptions: + # print "Export filter options: %s" % op.exportfilteroptions +- outputprops += UnoProps(FilterOptions=op.exportfilteroptions) ++ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions) + else: + if outputfmt.filter == 'Text (encoded)': +- outputprops += UnoProps(FilterOptions="76,LF") ++ outputprops += GlobalUnoProps(FilterOptions="76,LF") + + elif outputfmt.filter == 'Text': +- outputprops += UnoProps(FilterOptions="76") ++ outputprops += GlobalUnoProps(FilterOptions="76") + + elif outputfmt.filter == 'Text - txt - csv (StarCalc)': +- outputprops += UnoProps(FilterOptions="44,34,76") ++ outputprops += GlobalUnoProps(FilterOptions="44,34,76") + + +- ### Cannot use UnoProps for FilterData property ++ ### Cannot use GlobalUnoProps for FilterData property + if op.exportfilter: +- outputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) ++ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) + + if not op.stdout: + (outputfn, ext) = os.path.splitext(inputfn) +@@ -917,14 +918,14 @@ class Convertor: + else: + outputfn = op.output + +- outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) ++ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) ) + info(1, "Output file: %s" % outputfn) + else: + outputurl = "private:stream" + + try: + document.storeToURL(outputurl, tuple(outputprops) ) +- except IOException, e: ++ except UnoIOException, e: + raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) + + phase = "dispose" +@@ -935,24 +936,24 @@ class Convertor: + error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) + exitcode = 1 + +- except RuntimeException, e: ++ except UnoRuntimeException, e: + error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) + exitcode = 6 + +- except DisposedException, e: ++ except UnoDisposedException, e: + error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) + exitcode = 7 + +- except IllegalArgumentException, e: ++ except UnoIllegalArgumentException, e: + error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) + exitcode = 8 + +- except IOException, e: ++ except UnoIOException, e: + # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) + error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) + exitcode = 3 + +- except CannotConvertException, e: ++ except UnoCannotConvertException, e: + # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) + error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) + exitcode = 4 +@@ -975,14 +976,14 @@ class Listener: + global product + + info(1, "Start listener on %s:%s" % (op.server, op.port)) +- self.context = uno.getComponentContext() ++ self.context = global_uno.getComponentContext() + self.svcmgr = self.context.ServiceManager + try: + resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) +- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) ++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) + try: + unocontext = resolver.resolve("uno:%s" % op.connection) +- except NoConnectException, e: ++ except UnoNoConnectException, e: + pass + else: + info(1, "Existing %s listener found, nothing to do." % product.ooName) +@@ -1039,7 +1040,7 @@ def die(ret, msg=None): + info(3, 'Terminating %s instance.' % product.ooName) + try: + convertor.desktop.terminate() +- except DisposedException: ++ except UnoDisposedException: + info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) + try: + ooproc.terminate() +@@ -1080,7 +1081,7 @@ def main(): + for inputfn in op.filenames: + convertor.convert(inputfn) + +- except NoConnectException, e: ++ except UnoNoConnectException, e: + error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) + if op.connection: + info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) +@@ -1094,7 +1095,8 @@ def main(): + error("Warning: failed to launch Office suite. Aborting.") + + ### Main entrance +-if __name__ == '__main__': ++def run(): ++ global exitcode + exitcode = 0 + + info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) +@@ -1105,7 +1107,12 @@ if __name__ == '__main__': + office_environ(of) + # debug_office() + try: +- import uno, unohelper ++ global global_uno ++ global global_unohelper ++ ++ import uno as global_uno ++ import unohelper as global_unohelper ++ global office + office = of + break + except: +@@ -1121,17 +1128,30 @@ if __name__ == '__main__': + sys.exit(1) + + ### Now that we have found a working pyuno library, let's import some classes +- from com.sun.star.beans import PropertyValue +- from com.sun.star.connection import NoConnectException +- from com.sun.star.document.UpdateDocMode import QUIET_UPDATE +- from com.sun.star.lang import DisposedException, IllegalArgumentException +- from com.sun.star.io import IOException, XOutputStream +- from com.sun.star.script import CannotConvertException ++ global UnoPropertyValue ++ global UnoNoConnectException ++ global UNO_QUIET_UPDATE ++ global UnoDisposedException ++ global UnoIllegalArgumentException ++ global UnoIOException ++ global UnoXOutputStream ++ global UnoCannotConvertException ++ global UnoException ++ global UnoRuntimeException ++ ++ from com.sun.star.beans import PropertyValue as UnoPropertyValue ++ from com.sun.star.connection import NoConnectException as UnoNoConnectException ++ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE ++ from com.sun.star.lang import DisposedException as UnoDisposedException ++ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException ++ from com.sun.star.io import IOException as UnoIOException ++ from com.sun.star.io import XOutputStream as UnoXOutputStream ++ from com.sun.star.script import CannotConvertException as UnoCannotConvertException + from com.sun.star.uno import Exception as UnoException +- from com.sun.star.uno import RuntimeException ++ from com.sun.star.uno import RuntimeException as UnoRuntimeException + + ### And now that we have those classes, build on them +- class OutputStream( unohelper.Base, XOutputStream ): ++ class OutputStream( global_unohelper.Base, UnoXOutputStream ): + def __init__( self ): + self.closed = 0 + +@@ -1144,15 +1164,22 @@ if __name__ == '__main__': + def flush( self ): + pass + ++ global GlobalOutputStream ++ GlobalOutputStream = OutputStream ++ + def UnoProps(**args): + props = [] + for key in args: +- prop = PropertyValue() ++ prop = UnoPropertyValue() + prop.Name = key + prop.Value = args[key] + props.append(prop) + return tuple(props) + ++ global GlobalUnoProps ++ GlobalUnoProps = UnoProps ++ ++ global op + op = Options(sys.argv[1:]) + + info(2, "Using office base path: %s" % office.basepath) +@@ -1163,3 +1190,6 @@ if __name__ == '__main__': + except KeyboardInterrupt, e: + die(6, 'Exiting on user request') + die(exitcode) ++ ++if __name__ == '__main__': ++ run() +-- +1.9.0 + diff --git a/0001-python3-added-compatibility.3.patch b/0001-python3-added-compatibility.3.patch new file mode 100644 index 0000000..18216c9 --- /dev/null +++ b/0001-python3-added-compatibility.3.patch @@ -0,0 +1,629 @@ +From 21b9a845ac7e8805b41d7dab1a6fbf8076689ae8 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Sat, 19 Apr 2014 12:06:27 +0200 +Subject: [PATCH] 0001-python3-added-compatibility.3.patch + +--- + unoconv | 248 ++++++++++++++++++++++++++++++++++++---------------------------- + 1 file changed, 139 insertions(+), 109 deletions(-) + +diff --git a/unoconv b/unoconv +index 30e6706..a13db44 100755 +--- a/unoconv ++++ b/unoconv +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python3 + + ### This program is free software; you can redistribute it and/or modify + ### it under the terms of the GNU General Public License as published by +@@ -77,11 +77,11 @@ def find_offices(): + else: + + if os.name in ( 'nt', 'os2' ): +- if 'PROGRAMFILES' in os.environ.keys(): ++ if 'PROGRAMFILES' in list(os.environ.keys()): + extrapaths += glob.glob(os.environ['PROGRAMFILES']+'\\LibreOffice*') + \ + glob.glob(os.environ['PROGRAMFILES']+'\\OpenOffice.org*') + +- if 'PROGRAMFILES(X86)' in os.environ.keys(): ++ if 'PROGRAMFILES(X86)' in list(os.environ.keys()): + extrapaths += glob.glob(os.environ['PROGRAMFILES(X86)']+'\\LibreOffice*') + \ + glob.glob(os.environ['PROGRAMFILES(X86)']+'\\OpenOffice.org*') + +@@ -203,7 +203,7 @@ def office_environ(office): + ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: + os.environ['UNO_PATH'] = office.unopath + +- ### Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete ++ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete + ### UNO environment + if os.name in ( 'nt', 'os2' ): + os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') +@@ -233,18 +233,18 @@ def office_environ(office): + + def debug_office(): + if 'URE_BOOTSTRAP' in os.environ: +- print >>sys.stderr, 'URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'] ++ print('URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'], file=sys.stderr) + if 'UNO_PATH' in os.environ: +- print >>sys.stderr, 'UNO_PATH=%s' % os.environ['UNO_PATH'] ++ print('UNO_PATH=%s' % os.environ['UNO_PATH'], file=sys.stderr) + if 'UNO_TYPES' in os.environ: +- print >>sys.stderr, 'UNO_TYPES=%s' % os.environ['UNO_TYPES'] +- print 'PATH=%s' % os.environ['PATH'] ++ print('UNO_TYPES=%s' % os.environ['UNO_TYPES'], file=sys.stderr) ++ print('PATH=%s' % os.environ['PATH']) + if 'PYTHONHOME' in os.environ: +- print >>sys.stderr, 'PYTHONHOME=%s' % os.environ['PYTHONHOME'] ++ print('PYTHONHOME=%s' % os.environ['PYTHONHOME'], file=sys.stderr) + if 'PYTHONPATH' in os.environ: +- print >>sys.stderr, 'PYTHONPATH=%s' % os.environ['PYTHONPATH'] ++ print('PYTHONPATH=%s' % os.environ['PYTHONPATH'], file=sys.stderr) + if 'LD_LIBRARY_PATH' in os.environ: +- print >>sys.stderr, 'LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'] ++ print('LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'], file=sys.stderr) + + def python_switch(office): + if office.pythonhome: +@@ -277,6 +277,7 @@ def python_switch(office): + + try: + os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) ++ print((office.python, [office.python, ] + sys.argv[0:], osenviron)) + except OSError: + ### Mac OS X versions prior to 10.6 do not support execv in + ### a process that contains multiple threads. Instead of +@@ -335,11 +336,11 @@ class FmtList: + return ret + + def display(self, doctype): +- print >>sys.stderr, "The following list of %s formats are currently available:\n" % doctype ++ print("The following list of %s formats are currently available:\n" % doctype, file=sys.stderr) + for fmt in self.list: + if fmt.doctype == doctype: +- print >>sys.stderr, " %-8s - %s" % (fmt.name, fmt) +- print >>sys.stderr ++ print(" %-8s - %s" % (fmt.name, fmt), file=sys.stderr) ++ print(file=sys.stderr) + + fmts = FmtList() + +@@ -530,14 +531,14 @@ class Options: + 'outputpath', 'password=', 'pipe=', 'port=', 'server=', + 'timeout=', 'show', 'stdout', 'template', 'verbose', + 'version'] ) +- except getopt.error, exc: +- print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc) ++ except getopt.error as exc: ++ print('unoconv: %s, try unoconv -h for a list of all the options' % str(exc)) + sys.exit(255) + + for opt, arg in opts: + if opt in ['-h', '--help']: + self.usage() +- print ++ print() + self.help() + sys.exit(1) + elif opt in ['-c', '--connection']: +@@ -553,16 +554,16 @@ class Options: + if name in ('FilterOptions'): + self.exportfilteroptions = value + elif value in ('True', 'true'): +- self.exportfilter.append( PropertyValue( name, 0, True, 0 ) ) ++ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) + elif value in ('False', 'false'): +- self.exportfilter.append( PropertyValue( name, 0, False, 0 ) ) ++ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) + else: + try: +- self.exportfilter.append( PropertyValue( name, 0, int(value), 0 ) ) ++ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) + except ValueError: +- self.exportfilter.append( PropertyValue( name, 0, value, 0 ) ) ++ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) + else: +- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg ++ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr) + elif opt in ['-f', '--format']: + self.format = arg + elif opt in ['-i', '--import']: +@@ -572,16 +573,16 @@ class Options: + if name in ('FilterOptions'): + self.importfilteroptions = value + elif value in ('True', 'true'): +- self.importfilter.append( PropertyValue( name, 0, True, 0 ) ) ++ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) + elif value in ('False', 'false'): +- self.importfilter.append( PropertyValue( name, 0, False, 0 ) ) ++ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) + else: + try: +- self.importfilter.append( PropertyValue( name, 0, int(value), 0 ) ) ++ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) + except ValueError: +- self.importfilter.append( PropertyValue( name, 0, value, 0 ) ) ++ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) + else: +- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg ++ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr) + elif opt in ['-l', '--listener']: + self.listener = True + elif opt in ['-n', '--no-launch']: +@@ -589,7 +590,7 @@ class Options: + elif opt in ['-o', '--output']: + self.output = arg + elif opt in ['--outputpath']: +- print >>sys.stderr, 'Warning: This option is deprecated by --output.' ++ print('Warning: This option is deprecated by --output.', file=sys.stderr) + self.output = arg + elif opt in ['--password']: + self.password = arg +@@ -615,13 +616,13 @@ class Options: + + ### Enable verbosity + if self.verbose >= 2: +- print >>sys.stderr, 'Verbosity set to level %d' % self.verbose ++ print('Verbosity set to level %d' % self.verbose, file=sys.stderr) + + self.filenames = args + + if not self.listener and not self.showlist and self.doctype != 'list' and not self.filenames: +- print >>sys.stderr, 'unoconv: you have to provide a filename as argument' +- print >>sys.stderr, 'Try `unoconv -h\' for more information.' ++ print('unoconv: you have to provide a filename as argument', file=sys.stderr) ++ print('Try `unoconv -h\' for more information.', file=sys.stderr) + sys.exit(255) + + ### Set connection string +@@ -657,23 +658,23 @@ class Options: + + def version(self): + ### Get office product information +- product = uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) +- +- print 'unoconv %s' % VERSION +- print 'Written by Dag Wieers ' +- print 'Homepage at http://dag.wieers.com/home-made/unoconv/' +- print +- print 'platform %s/%s' % (os.name, sys.platform) +- print 'python %s' % sys.version +- print product.ooName, product.ooSetupVersion ++ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) ++ ++ print('unoconv %s' % VERSION) ++ print('Written by Dag Wieers ') ++ print('Homepage at http://dag.wieers.com/home-made/unoconv/') ++ print() ++ print('platform %s/%s' % (os.name, sys.platform)) ++ print('python %s' % sys.version) ++ print(product.ooName, product.ooSetupVersion) + # print + # print 'build revision $Rev$' + + def usage(self): +- print >>sys.stderr, 'usage: unoconv [options] file [file2 ..]' ++ print('usage: unoconv [options] file [file2 ..]', file=sys.stderr) + + def help(self): +- print >>sys.stderr, '''Convert from and to any format supported by LibreOffice ++ print('''Convert from and to any format supported by LibreOffice + + unoconv options: + -c, --connection=string use a custom connection string +@@ -698,7 +699,7 @@ unoconv options: + -t, --template=file import the styles from template (.ott) + -T, --timeout=secs timeout after secs if connection to listener fails + -v, --verbose be more and more verbose (-vvv for debugging) +-''' ++''', file=sys.stderr) + + class Convertor: + def __init__(self): +@@ -706,7 +707,7 @@ class Convertor: + unocontext = None + + ### Do the LibreOffice component dance +- self.context = uno.getComponentContext() ++ self.context = global_uno.getComponentContext() + self.svcmgr = self.context.ServiceManager + resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) + +@@ -714,7 +715,7 @@ class Convertor: + info(3, 'Connection type: %s' % op.connection) + try: + unocontext = resolver.resolve("uno:%s" % op.connection) +- except NoConnectException, e: ++ except UnoNoConnectException as e: + # info(3, "Existing listener not found.\n%s" % e) + info(3, "Existing listener not found.") + +@@ -724,7 +725,7 @@ class Convertor: + ### Start our own OpenOffice instance + info(3, "Launching our own listener using %s." % office.binary) + try: +- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) ++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) + if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): + ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) + else: +@@ -742,14 +743,14 @@ class Convertor: + try: + unocontext = resolver.resolve("uno:%s" % op.connection) + break +- except NoConnectException: ++ except UnoNoConnectException: + time.sleep(0.5) + timeout += 0.5 + except: + raise + else: + error("Failed to connect to %s (pid=%s) in %d seconds.\n%s" % (office.binary, ooproc.pid, op.timeout, e)) +- except Exception, e: ++ except Exception as e: + raise + error("Launch of %s failed.\n%s" % (office.binary, e)) + +@@ -759,7 +760,7 @@ class Convertor: + ### And some more LibreOffice magic + unosvcmgr = unocontext.ServiceManager + self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) +- self.cwd = unohelper.systemPathToFileUrl( os.getcwd() ) ++ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() ) + + ### List all filters + # self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) +@@ -799,9 +800,9 @@ class Convertor: + ### No format found, throw error + if not outputfmt: + if doctype: +- print >>sys.stderr, 'unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format) ++ print('unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format), file=sys.stderr) + else: +- print >>sys.stderr, 'unoconv: format [%s] is not known to unoconv.' % op.format ++ print('unoconv: format [%s] is not known to unoconv.' % op.format, file=sys.stderr) + die(1) + + return outputfmt +@@ -813,10 +814,10 @@ class Convertor: + outputfmt = self.getformat(inputfn) + + if op.verbose > 0: +- print >>sys.stderr, 'Input file:', inputfn ++ print('Input file:', inputfn, file=sys.stderr) + + if not os.path.exists(inputfn): +- print >>sys.stderr, 'unoconv: file `%s\' does not exist.' % inputfn ++ print('unoconv: file `%s\' does not exist.' % inputfn, file=sys.stderr) + exitcode = 1 + + try: +@@ -824,22 +825,22 @@ class Convertor: + phase = "import" + + ### Load inputfile +- inputprops = UnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=QUIET_UPDATE) ++ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE) + + # if op.password: +-# info = UnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") +-# inputprops += UnoProps(ModifyPasswordInfo=info) ++# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") ++# inputprops += GlobalUnoProps(ModifyPasswordInfo=info) + +- ### Cannot use UnoProps for FilterData property ++ ### Cannot use GlobalUnoProps for FilterData property + if op.importfilteroptions: + # print "Import filter options: %s" % op.importfilteroptions +- inputprops += UnoProps(FilterOptions=op.importfilteroptions) ++ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions) + +- ### Cannot use UnoProps for FilterData property ++ ### Cannot use GlobalUnoProps for FilterData property + if op.importfilter: +- inputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) ++ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) + +- inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn)) ++ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn)) + document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) + + if not document: +@@ -850,11 +851,11 @@ class Convertor: + if op.template: + if os.path.exists(op.template): + info(1, "Template file: %s" % op.template) +- templateprops = UnoProps(OverwriteStyles=True) +- templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template)) ++ templateprops = GlobalUnoProps(OverwriteStyles=True) ++ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template)) + document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) + else: +- print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template ++ print('unoconv: template file `%s\' does not exist.' % op.template, file=sys.stderr) + exitcode = 1 + + ### Update document links +@@ -885,26 +886,26 @@ class Convertor: + ### Export phase + phase = "export" + +- outputprops = UnoProps(FilterName=outputfmt.filter, OutputStream=OutputStream(), Overwrite=True) ++ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True) + + ### Set default filter options + if op.exportfilteroptions: + # print "Export filter options: %s" % op.exportfilteroptions +- outputprops += UnoProps(FilterOptions=op.exportfilteroptions) ++ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions) + else: + if outputfmt.filter == 'Text (encoded)': +- outputprops += UnoProps(FilterOptions="76,LF") ++ outputprops += GlobalUnoProps(FilterOptions="76,LF") + + elif outputfmt.filter == 'Text': +- outputprops += UnoProps(FilterOptions="76") ++ outputprops += GlobalUnoProps(FilterOptions="76") + + elif outputfmt.filter == 'Text - txt - csv (StarCalc)': +- outputprops += UnoProps(FilterOptions="44,34,76") ++ outputprops += GlobalUnoProps(FilterOptions="44,34,76") + + +- ### Cannot use UnoProps for FilterData property ++ ### Cannot use GlobalUnoProps for FilterData property + if op.exportfilter: +- outputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) ++ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) + + if not op.stdout: + (outputfn, ext) = os.path.splitext(inputfn) +@@ -917,47 +918,47 @@ class Convertor: + else: + outputfn = op.output + +- outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) ++ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) ) + info(1, "Output file: %s" % outputfn) + else: + outputurl = "private:stream" + + try: + document.storeToURL(outputurl, tuple(outputprops) ) +- except IOException, e: ++ except UnoIOException as e: + raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) + + phase = "dispose" + document.dispose() + document.close(True) + +- except SystemError, e: ++ except SystemError as e: + error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) + exitcode = 1 + +- except RuntimeException, e: ++ except UnoRuntimeException as e: + error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) + exitcode = 6 + +- except DisposedException, e: ++ except UnoDisposedException as e: + error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) + exitcode = 7 + +- except IllegalArgumentException, e: ++ except UnoIllegalArgumentException as e: + error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) + exitcode = 8 + +- except IOException, e: ++ except UnoIOException as e: + # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) + error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) + exitcode = 3 + +- except CannotConvertException, e: ++ except UnoCannotConvertException as e: + # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) + error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) + exitcode = 4 + +- except UnoException, e: ++ except UnoException as e: + if hasattr(e, 'ErrCode'): + error("unoconv: UnoException during %s phase in %s (ErrCode %d)" % (phase, repr(e.__class__), e.ErrCode)) + exitcode = e.ErrCode +@@ -975,14 +976,14 @@ class Listener: + global product + + info(1, "Start listener on %s:%s" % (op.server, op.port)) +- self.context = uno.getComponentContext() ++ self.context = global_uno.getComponentContext() + self.svcmgr = self.context.ServiceManager + try: + resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) +- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) ++ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) + try: + unocontext = resolver.resolve("uno:%s" % op.connection) +- except NoConnectException, e: ++ except UnoNoConnectException as e: + pass + else: + info(1, "Existing %s listener found, nothing to do." % product.ooName) +@@ -991,25 +992,25 @@ class Listener: + subprocess.call([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection], env=os.environ) + else: + subprocess.call([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection], env=os.environ) +- except Exception, e: ++ except Exception as e: + error("Launch of %s failed.\n%s" % (office.binary, e)) + else: + info(1, "Existing %s listener found, nothing to do." % product.ooName) + + def error(msg): + "Output error message" +- print >>sys.stderr, msg ++ print(msg, file=sys.stderr) + + def info(level, msg): + "Output info message" + if 'op' not in globals(): + pass + elif op.verbose >= 3 and level >= 3: +- print >>sys.stderr, "DEBUG:", msg ++ print("DEBUG:", msg, file=sys.stderr) + elif not op.stdout and level <= op.verbose: +- print >>sys.stdout, msg ++ print(msg, file=sys.stdout) + elif level <= op.verbose: +- print >>sys.stderr, msg ++ print(msg, file=sys.stderr) + + def die(ret, msg=None): + "Print optional error and exit with errorcode" +@@ -1031,7 +1032,7 @@ def die(ret, msg=None): + subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection], env=os.environ) + ooproc.wait() + info(2, '%s listener successfully disabled.' % product.ooName) +- except Exception, e: ++ except Exception as e: + error("Terminate using %s failed.\n%s" % (office.binary, e)) + + ### If there is no GUI attached to the instance, terminate instance +@@ -1039,7 +1040,7 @@ def die(ret, msg=None): + info(3, 'Terminating %s instance.' % product.ooName) + try: + convertor.desktop.terminate() +- except DisposedException: ++ except UnoDisposedException: + info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) + try: + ooproc.terminate() +@@ -1080,7 +1081,7 @@ def main(): + for inputfn in op.filenames: + convertor.convert(inputfn) + +- except NoConnectException, e: ++ except UnoNoConnectException as e: + error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) + if op.connection: + info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) +@@ -1094,7 +1095,8 @@ def main(): + error("Warning: failed to launch Office suite. Aborting.") + + ### Main entrance +-if __name__ == '__main__': ++def run(): ++ global exitcode + exitcode = 0 + + info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) +@@ -1105,33 +1107,51 @@ if __name__ == '__main__': + office_environ(of) + # debug_office() + try: +- import uno, unohelper ++ global global_uno ++ global global_unohelper ++ ++ import uno as global_uno ++ import unohelper as global_unohelper ++ global office + office = of + break + except: + # debug_office() +- print >>sys.stderr, "unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of +- print >>sys.stderr, "ERROR:", sys.exc_info()[1] +- print >>sys.stderr ++ print("unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of, file=sys.stderr) ++ print("ERROR:", sys.exc_info()[1], file=sys.stderr) ++ print(file=sys.stderr) + else: + # debug_office() +- print >>sys.stderr, "unoconv: Cannot find a suitable office installation on your system." +- print >>sys.stderr, "ERROR: Please locate your office installation and send your feedback to:" +- print >>sys.stderr, " http://github.com/dagwieers/unoconv/issues" ++ print("unoconv: Cannot find a suitable office installation on your system.", file=sys.stderr) ++ print("ERROR: Please locate your office installation and send your feedback to:", file=sys.stderr) ++ print(" http://github.com/dagwieers/unoconv/issues", file=sys.stderr) + sys.exit(1) + + ### Now that we have found a working pyuno library, let's import some classes +- from com.sun.star.beans import PropertyValue +- from com.sun.star.connection import NoConnectException +- from com.sun.star.document.UpdateDocMode import QUIET_UPDATE +- from com.sun.star.lang import DisposedException, IllegalArgumentException +- from com.sun.star.io import IOException, XOutputStream +- from com.sun.star.script import CannotConvertException ++ global UnoPropertyValue ++ global UnoNoConnectException ++ global UNO_QUIET_UPDATE ++ global UnoDisposedException ++ global UnoIllegalArgumentException ++ global UnoIOException ++ global UnoXOutputStream ++ global UnoCannotConvertException ++ global UnoException ++ global UnoRuntimeException ++ ++ from com.sun.star.beans import PropertyValue as UnoPropertyValue ++ from com.sun.star.connection import NoConnectException as UnoNoConnectException ++ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE ++ from com.sun.star.lang import DisposedException as UnoDisposedException ++ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException ++ from com.sun.star.io import IOException as UnoIOException ++ from com.sun.star.io import XOutputStream as UnoXOutputStream ++ from com.sun.star.script import CannotConvertException as UnoCannotConvertException + from com.sun.star.uno import Exception as UnoException +- from com.sun.star.uno import RuntimeException ++ from com.sun.star.uno import RuntimeException as UnoRuntimeException + + ### And now that we have those classes, build on them +- class OutputStream( unohelper.Base, XOutputStream ): ++ class OutputStream( global_unohelper.Base, UnoXOutputStream ): + def __init__( self ): + self.closed = 0 + +@@ -1144,15 +1164,22 @@ if __name__ == '__main__': + def flush( self ): + pass + ++ global GlobalOutputStream ++ GlobalOutputStream = OutputStream ++ + def UnoProps(**args): + props = [] + for key in args: +- prop = PropertyValue() ++ prop = UnoPropertyValue() + prop.Name = key + prop.Value = args[key] + props.append(prop) + return tuple(props) + ++ global GlobalUnoProps ++ GlobalUnoProps = UnoProps ++ ++ global op + op = Options(sys.argv[1:]) + + info(2, "Using office base path: %s" % office.basepath) +@@ -1160,6 +1187,9 @@ if __name__ == '__main__': + + try: + main() +- except KeyboardInterrupt, e: ++ except KeyboardInterrupt as e: + die(6, 'Exiting on user request') + die(exitcode) ++ ++if __name__ == '__main__': ++ run() +-- +1.9.0 + diff --git a/0001-python3-added-compatibility.patch b/0001-python3-added-compatibility.patch deleted file mode 100644 index e8d3bca..0000000 --- a/0001-python3-added-compatibility.patch +++ /dev/null @@ -1,3628 +0,0 @@ -From 6eba87f4654d3f142070c1fe9f272bf787885861 Mon Sep 17 00:00:00 2001 -From: Andres Gomez -Date: Thu, 4 Apr 2013 13:18:06 +0300 -Subject: [PATCH] python3: added compatibility - -Dodgy solution in which we create a python2 and -python3 compatible wrapper that would import the -old script, or a new automatically migrated -version. - -The automatic migration was done with the 2to3 -tool after modifying the original script so we can -invoke it as a module. - -This is needed since LibreOffice is providing its -own python3 bundled package since 4.x series. ---- - Makefile | 2 + - packaging/rpm/unoconv.spec | 2 + - unoconv | 1154 +----------------------------------------- - unoconv2.py | 1195 ++++++++++++++++++++++++++++++++++++++++++++ - unoconv3.py | 1195 ++++++++++++++++++++++++++++++++++++++++++++ - 5 files changed, 2406 insertions(+), 1142 deletions(-) - create mode 100755 unoconv2.py - create mode 100755 unoconv3.py - -diff --git a/Makefile b/Makefile -index 9bb18f6..b950583 100644 ---- a/Makefile -+++ b/Makefile -@@ -111,6 +111,8 @@ install: - install -d -m0755 $(DESTDIR)$(bindir) - install -d -m0755 $(DESTDIR)$(mandir)/man1/ - install -p -m0755 unoconv $(DESTDIR)$(bindir)/unoconv -+ install -p -m0755 unoconv2.py $(DESTDIR)$(bindir)/unoconv2.py -+ install -p -m0755 unoconv3.py $(DESTDIR)$(bindir)/unoconv3.py - install -p -m0644 doc/unoconv.1 $(DESTDIR)$(mandir)/man1/unoconv.1 - - install-links: $(links) -diff --git a/packaging/rpm/unoconv.spec b/packaging/rpm/unoconv.spec -index 4801dd3..c077fec 100644 ---- a/packaging/rpm/unoconv.spec -+++ b/packaging/rpm/unoconv.spec -@@ -49,6 +49,8 @@ and many more... - %doc AUTHORS ChangeLog COPYING README* WISHLIST doc/ tests/ - %doc %{_mandir}/man1/unoconv.1* - %{_bindir}/unoconv -+%{_bindir}/unoconv2.py -+%{_bindir}/unoconv3.py - - %changelog - * Mon Sep 10 2012 Dag Wieers - 0.6-1 -diff --git a/unoconv b/unoconv -index 30e6706..ed603af 100755 ---- a/unoconv -+++ b/unoconv -@@ -12,1154 +12,24 @@ - ### You should have received a copy of the GNU General Public License - ### along with this program; if not, write to the Free Software - ### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --### Copyright 2007-2010 Dag Wieers - --from distutils.version import LooseVersion --import getopt --import glob --import os --import subprocess - import sys --import time - --__version__ = "$Revision$" --# $Source$ -+### Extremely dodgy solution for running python2 or python3 versions -+### of the unoconv script - --VERSION = '0.6' -+### This is needed since LibreOffice is providing its own python3 -+### bundled package since 4.x series - --doctypes = ('document', 'graphics', 'presentation', 'spreadsheet') -+### A much more proper solution would be to modify the code so it -+### would be compatible with both versions or, if not possible, to -+### create real python modules out of the code and import them in a -+### proper way - --global convertor, office, ooproc, product --ooproc = None --exitcode = 0 -- --class Office: -- def __init__(self, basepath, urepath, unopath, pyuno, binary, python, pythonhome): -- self.basepath = basepath -- self.urepath = urepath -- self.unopath = unopath -- self.pyuno = pyuno -- self.binary = binary -- self.python = python -- self.pythonhome = pythonhome -- -- def __str__(self): -- return self.basepath -- -- def __repr__(self): -- return self.basepath -- --### Implement a path normalizer in order to make unoconv work on MacOS X --### (on which 'program' is a symlink to 'MacOSX' which seems to break unoconv) --def realpath(*args): -- ''' Implement a combination of os.path.join(), os.path.abspath() and -- os.path.realpath() in order to normalize path constructions ''' -- ret = '' -- for arg in args: -- ret = os.path.join(ret, arg) -- return os.path.realpath(os.path.abspath(ret)) -- --### The first thing we ought to do is find a suitable Office installation --### with a compatible pyuno library that we can import. --### --### See: http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=36370&p=166783 -- --def find_offices(): -- ret = [] -- extrapaths = [] -- -- ### Try using UNO_PATH first (in many incarnations, we'll see what sticks) -- if 'UNO_PATH' in os.environ: -- extrapaths += [ os.environ['UNO_PATH'], -- os.path.dirname(os.environ['UNO_PATH']), -- os.path.dirname(os.path.dirname(os.environ['UNO_PATH'])) ] -- -- else: -- -- if os.name in ( 'nt', 'os2' ): -- if 'PROGRAMFILES' in os.environ.keys(): -- extrapaths += glob.glob(os.environ['PROGRAMFILES']+'\\LibreOffice*') + \ -- glob.glob(os.environ['PROGRAMFILES']+'\\OpenOffice.org*') -- -- if 'PROGRAMFILES(X86)' in os.environ.keys(): -- extrapaths += glob.glob(os.environ['PROGRAMFILES(X86)']+'\\LibreOffice*') + \ -- glob.glob(os.environ['PROGRAMFILES(X86)']+'\\OpenOffice.org*') -- -- elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): -- extrapaths += [ '/Applications/LibreOffice.app/Contents', -- '/Applications/NeoOffice.app/Contents', -- '/Applications/OpenOffice.org.app/Contents' ] -- -- else: -- extrapaths += glob.glob('/usr/lib*/libreoffice*') + \ -- glob.glob('/usr/lib*/openoffice*') + \ -- glob.glob('/usr/lib*/ooo*') + \ -- glob.glob('/opt/libreoffice*') + \ -- glob.glob('/opt/openoffice*') + \ -- glob.glob('/opt/ooo*') + \ -- glob.glob('/usr/local/libreoffice*') + \ -- glob.glob('/usr/local/openoffice*') + \ -- glob.glob('/usr/local/ooo*') + \ -- glob.glob('/usr/local/lib/libreoffice*') -- -- ### Find a working set for python UNO bindings -- for basepath in extrapaths: -- if os.name in ( 'nt', 'os2' ): -- officelibraries = ( 'pyuno.pyd', ) -- officebinaries = ( 'soffice.exe' ,) -- pythonbinaries = ( 'python.exe', ) -- pythonhomes = () -- elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): -- officelibraries = ( 'pyuno.so', 'libpyuno.dylib' ) -- officebinaries = ( 'soffice.bin', ) -- pythonbinaries = ( 'python.bin', 'python' ) -- pythonhomes = ( 'OOoPython.framework/Versions/*/lib/python*', ) -- else: -- officelibraries = ( 'pyuno.so', ) -- officebinaries = ( 'soffice.bin', ) -- pythonbinaries = ( 'python.bin', 'python', ) -- pythonhomes = ( 'python-core-*', ) -- -- ### Older LibreOffice/OpenOffice and Windows use basis-link/ or basis/ -- libpath = 'error' -- for basis in ( 'basis-link', 'basis', '' ): -- for lib in officelibraries: -- if os.path.isfile(realpath(basepath, basis, 'program', lib)): -- libpath = realpath(basepath, basis, 'program') -- officelibrary = realpath(libpath, lib) -- info(3, "Found %s in %s" % (lib, libpath)) -- # Break the inner loop... -- break -- # Continue if the inner loop wasn't broken. -- else: -- continue -- # Inner loop was broken, break the outer. -- break -- else: -- continue -- -- ### MacOSX have soffice binaries installed in MacOS subdirectory, not program -- unopath = 'error' -- for basis in ( 'basis-link', 'basis', '' ): -- for bin in officebinaries: -- if os.path.isfile(realpath(basepath, basis, 'program', bin)): -- unopath = realpath(basepath, basis, 'program') -- officebinary = realpath(unopath, bin) -- info(3, "Found %s in %s" % (bin, unopath)) -- # Break the inner loop... -- break -- # Continue if the inner loop wasn't broken. -- else: -- continue -- # Inner loop was broken, break the outer. -- break -- else: -- continue -- -- ### Windows does not provide or need a URE/lib directory ? -- urepath = '' -- for basis in ( 'basis-link', 'basis', '' ): -- for ure in ( 'ure-link', 'ure', 'URE', '' ): -- if os.path.isfile(realpath(basepath, basis, ure, 'lib', 'unorc')): -- urepath = realpath(basepath, basis, ure) -- info(3, "Found %s in %s" % ('unorc', realpath(urepath, 'lib'))) -- # Break the inner loop... -- break -- # Continue if the inner loop wasn't broken. -- else: -- continue -- # Inner loop was broken, break the outer. -- break -- -- pythonhome = None -- for home in pythonhomes: -- if glob.glob(realpath(libpath, home)): -- pythonhome = glob.glob(realpath(libpath, home))[0] -- info(3, "Found %s in %s" % (home, pythonhome)) -- break -- --# if not os.path.isfile(realpath(basepath, program, officebinary)): --# continue --# info(3, "Found %s in %s" % (officebinary, realpath(basepath, program))) -- --# if not glob.glob(realpath(basepath, basis, program, 'python-core-*')): --# continue -- -- for pythonbinary in pythonbinaries: -- if os.path.isfile(realpath(unopath, pythonbinary)): -- info(3, "Found %s in %s" % (pythonbinary, unopath)) -- ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, -- realpath(unopath, pythonbinary), pythonhome)) -- else: -- info(3, "Considering %s" % basepath) -- ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, -- sys.executable, None)) -- return ret -- --def office_environ(office): -- ### Set PATH so that crash_report is found -- os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH'] -- -- ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: -- os.environ['UNO_PATH'] = office.unopath -- -- ### Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete -- ### UNO environment -- if os.name in ( 'nt', 'os2' ): -- os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') -- else: -- os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamentalrc') -- -- ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: -- if 'LD_LIBRARY_PATH' in os.environ: -- os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -- realpath(office.urepath, 'lib') + os.pathsep + \ -- os.environ['LD_LIBRARY_PATH'] -- else: -- os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -- realpath(office.urepath, 'lib') -- -- if office.pythonhome: -- for libpath in ( realpath(office.pythonhome, 'lib'), -- realpath(office.pythonhome, 'lib', 'lib-dynload'), -- realpath(office.pythonhome, 'lib', 'lib-tk'), -- realpath(office.pythonhome, 'lib', 'site-packages'), -- office.unopath): -- sys.path.insert(0, libpath) -- else: -- ### Still needed for system python using LibreOffice UNO bindings -- ### Although we prefer to use a system UNO binding in this case -- sys.path.append(office.unopath) -- --def debug_office(): -- if 'URE_BOOTSTRAP' in os.environ: -- print >>sys.stderr, 'URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'] -- if 'UNO_PATH' in os.environ: -- print >>sys.stderr, 'UNO_PATH=%s' % os.environ['UNO_PATH'] -- if 'UNO_TYPES' in os.environ: -- print >>sys.stderr, 'UNO_TYPES=%s' % os.environ['UNO_TYPES'] -- print 'PATH=%s' % os.environ['PATH'] -- if 'PYTHONHOME' in os.environ: -- print >>sys.stderr, 'PYTHONHOME=%s' % os.environ['PYTHONHOME'] -- if 'PYTHONPATH' in os.environ: -- print >>sys.stderr, 'PYTHONPATH=%s' % os.environ['PYTHONPATH'] -- if 'LD_LIBRARY_PATH' in os.environ: -- print >>sys.stderr, 'LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'] -- --def python_switch(office): -- if office.pythonhome: -- os.environ['PYTHONHOME'] = office.pythonhome -- os.environ['PYTHONPATH'] = realpath(office.pythonhome, 'lib') + os.pathsep + \ -- realpath(office.pythonhome, 'lib', 'lib-dynload') + os.pathsep + \ -- realpath(office.pythonhome, 'lib', 'lib-tk') + os.pathsep + \ -- realpath(office.pythonhome, 'lib', 'site-packages') + os.pathsep + \ -- office.unopath -- -- os.environ['UNO_PATH'] = office.unopath -- -- info(3, "-> Switching from %s to %s" % (sys.executable, office.python)) -- if os.name in ('nt', 'os2'): -- ### os.execv is broken on Windows and can't properly parse command line -- ### arguments and executable name if they contain whitespaces. subprocess -- ### fixes that behavior. -- ret = subprocess.call([office.python] + sys.argv[0:]) -- sys.exit(ret) -- else: -- -- ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: -- if 'LD_LIBRARY_PATH' in os.environ: -- os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -- realpath(office.urepath, 'lib') + os.pathsep + \ -- os.environ['LD_LIBRARY_PATH'] -- else: -- os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -- realpath(office.urepath, 'lib') -- -- try: -- os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) -- except OSError: -- ### Mac OS X versions prior to 10.6 do not support execv in -- ### a process that contains multiple threads. Instead of -- ### re-executing in the current process, start a new one -- ### and cause the current process to exit. This isn't -- ### ideal since the new process is detached from the parent -- ### terminal and thus cannot easily be killed with ctrl-C, -- ### but it's better than not being able to autoreload at -- ### all. -- ### Unfortunately the errno returned in this case does not -- ### appear to be consistent, so we can't easily check for -- ### this error specifically. -- ret = os.spawnvpe(os.P_WAIT, office.python, [office.python, ] + sys.argv[0:], os.environ) -- sys.exit(ret) -- --class Fmt: -- def __init__(self, doctype, name, extension, summary, filter): -- self.doctype = doctype -- self.name = name -- self.extension = extension -- self.summary = summary -- self.filter = filter -- -- def __str__(self): -- return "%s [.%s]" % (self.summary, self.extension) -- -- def __repr__(self): -- return "%s/%s" % (self.name, self.doctype) -- --class FmtList: -- def __init__(self): -- self.list = [] -- -- def add(self, doctype, name, extension, summary, filter): -- self.list.append(Fmt(doctype, name, extension, summary, filter)) -- -- def byname(self, name): -- ret = [] -- for fmt in self.list: -- if fmt.name == name: -- ret.append(fmt) -- return ret -- -- def byextension(self, extension): -- ret = [] -- for fmt in self.list: -- if os.extsep + fmt.extension == extension: -- ret.append(fmt) -- return ret -- -- def bydoctype(self, doctype, name): -- ret = [] -- for fmt in self.list: -- if fmt.name == name and fmt.doctype == doctype: -- ret.append(fmt) -- return ret -- -- def display(self, doctype): -- print >>sys.stderr, "The following list of %s formats are currently available:\n" % doctype -- for fmt in self.list: -- if fmt.doctype == doctype: -- print >>sys.stderr, " %-8s - %s" % (fmt.name, fmt) -- print >>sys.stderr -- --fmts = FmtList() -- --### TextDocument --fmts.add('document', 'bib', 'bib', 'BibTeX', 'BibTeX_Writer') ### 22 --fmts.add('document', 'doc', 'doc', 'Microsoft Word 97/2000/XP', 'MS Word 97') ### 29 --fmts.add('document', 'doc6', 'doc', 'Microsoft Word 6.0', 'MS WinWord 6.0') ### 24 --fmts.add('document', 'doc95', 'doc', 'Microsoft Word 95', 'MS Word 95') ### 28 --fmts.add('document', 'docbook', 'xml', 'DocBook', 'DocBook File') ### 39 --fmts.add('document', 'docx', 'docx', 'Microsoft Office Open XML', 'Office Open XML Text') --fmts.add('document', 'docx7', 'docx', 'Microsoft Office Open XML', 'MS Word 2007 XML') --fmts.add('document', 'fodt', 'fodt', 'OpenDocument Text (Flat XML)', 'OpenDocument Text Flat XML') --fmts.add('document', 'html', 'html', 'HTML Document (OpenOffice.org Writer)', 'HTML (StarWriter)') ### 3 --fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'LaTeX_Writer') ### 31 --fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') --fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 --fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 --fmts.add('document', 'ott', 'ott', 'Open Document Text', 'writer8_template') ### 21 --fmts.add('document', 'pdb', 'pdb', 'AportisDoc (Palm)', 'AportisDoc Palm DB') --fmts.add('document', 'pdf', 'pdf', 'Portable Document Format', 'writer_pdf_Export') ### 18 --fmts.add('document', 'psw', 'psw', 'Pocket Word', 'PocketWord File') --fmts.add('document', 'rtf', 'rtf', 'Rich Text Format', 'Rich Text Format') ### 16 --fmts.add('document', 'sdw', 'sdw', 'StarWriter 5.0', 'StarWriter 5.0') ### 23 --fmts.add('document', 'sdw4', 'sdw', 'StarWriter 4.0', 'StarWriter 4.0') ### 2 --fmts.add('document', 'sdw3', 'sdw', 'StarWriter 3.0', 'StarWriter 3.0') ### 20 --fmts.add('document', 'stw', 'stw', 'Open Office.org 1.0 Text Document Template', 'writer_StarOffice_XML_Writer_Template') ### 9 --fmts.add('document', 'sxw', 'sxw', 'Open Office.org 1.0 Text Document', 'StarOffice XML (Writer)') ### 1 --fmts.add('document', 'text', 'txt', 'Text Encoded', 'Text (encoded)') ### 26 --fmts.add('document', 'txt', 'txt', 'Text', 'Text') ### 34 --fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### 27 --fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 --fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 --fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 --fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 -- --### WebDocument --fmts.add('web', 'etext', 'txt', 'Text Encoded (OpenOffice.org Writer/Web)', 'Text (encoded) (StarWriter/Web)') ### 14 --fmts.add('web', 'html10', 'html', 'OpenOffice.org 1.0 HTML Template', 'writer_web_StarOffice_XML_Writer_Web_Template') ### 11 --fmts.add('web', 'html', 'html', 'HTML Document', 'HTML') ### 2 --fmts.add('web', 'html', 'html', 'HTML Document Template', 'writerweb8_writer_template') ### 13 --fmts.add('web', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki_Web') ### 9 --fmts.add('web', 'pdf', 'pdf', 'PDF - Portable Document Format', 'writer_web_pdf_Export') ### 10 --fmts.add('web', 'sdw3', 'sdw', 'StarWriter 3.0 (OpenOffice.org Writer/Web)', 'StarWriter 3.0 (StarWriter/Web)') ### 3 --fmts.add('web', 'sdw4', 'sdw', 'StarWriter 4.0 (OpenOffice.org Writer/Web)', 'StarWriter 4.0 (StarWriter/Web)') ### 4 --fmts.add('web', 'sdw', 'sdw', 'StarWriter 5.0 (OpenOffice.org Writer/Web)', 'StarWriter 5.0 (StarWriter/Web)') ### 5 --fmts.add('web', 'txt', 'txt', 'OpenOffice.org Text (OpenOffice.org Writer/Web)', 'writerweb8_writer') ### 12 --fmts.add('web', 'text10', 'txt', 'OpenOffice.org 1.0 Text Document (OpenOffice.org Writer/Web)', 'writer_web_StarOffice_XML_Writer') ### 15 --fmts.add('web', 'text', 'txt', 'Text (OpenOffice.org Writer/Web)', 'Text (StarWriter/Web)') ### 8 --fmts.add('web', 'vor4', 'vor', 'StarWriter/Web 4.0 Template', 'StarWriter/Web 4.0 Vorlage/Template') ### 6 --fmts.add('web', 'vor', 'vor', 'StarWriter/Web 5.0 Template', 'StarWriter/Web 5.0 Vorlage/Template') ### 7 -- --### Spreadsheet --fmts.add('spreadsheet', 'csv', 'csv', 'Text CSV', 'Text - txt - csv (StarCalc)') ### 16 --fmts.add('spreadsheet', 'dbf', 'dbf', 'dBASE', 'dBase') ### 22 --fmts.add('spreadsheet', 'dif', 'dif', 'Data Interchange Format', 'DIF') ### 5 --fmts.add('spreadsheet', 'fods', 'fods', 'OpenDocument Spreadsheet (Flat XML)', 'OpenDocument Spreadsheet Flat XML') --fmts.add('spreadsheet', 'html', 'html', 'HTML Document (OpenOffice.org Calc)', 'HTML (StarCalc)') ### 7 --fmts.add('spreadsheet', 'ods', 'ods', 'ODF Spreadsheet', 'calc8') ### 15 --fmts.add('spreadsheet', 'ooxml', 'xml', 'Microsoft Excel 2003 XML', 'MS Excel 2003 XML') ### 23 --fmts.add('spreadsheet', 'ots', 'ots', 'ODF Spreadsheet Template', 'calc8_template') ### 14 --fmts.add('spreadsheet', 'pdf', 'pdf', 'Portable Document Format', 'calc_pdf_Export') ### 34 --fmts.add('spreadsheet', 'pxl', 'pxl', 'Pocket Excel', 'Pocket Excel') --fmts.add('spreadsheet', 'sdc', 'sdc', 'StarCalc 5.0', 'StarCalc 5.0') ### 31 --fmts.add('spreadsheet', 'sdc4', 'sdc', 'StarCalc 4.0', 'StarCalc 4.0') ### 11 --fmts.add('spreadsheet', 'sdc3', 'sdc', 'StarCalc 3.0', 'StarCalc 3.0') ### 29 --fmts.add('spreadsheet', 'slk', 'slk', 'SYLK', 'SYLK') ### 35 --fmts.add('spreadsheet', 'stc', 'stc', 'OpenOffice.org 1.0 Spreadsheet Template', 'calc_StarOffice_XML_Calc_Template') ### 2 --fmts.add('spreadsheet', 'sxc', 'sxc', 'OpenOffice.org 1.0 Spreadsheet', 'StarOffice XML (Calc)') ### 3 --fmts.add('spreadsheet', 'uos', 'uos', 'Unified Office Format spreadsheet', 'UOF spreadsheet') ### 9 --fmts.add('spreadsheet', 'vor3', 'vor', 'StarCalc 3.0 Template', 'StarCalc 3.0 Vorlage/Template') ### 18 --fmts.add('spreadsheet', 'vor4', 'vor', 'StarCalc 4.0 Template', 'StarCalc 4.0 Vorlage/Template') ### 19 --fmts.add('spreadsheet', 'vor', 'vor', 'StarCalc 5.0 Template', 'StarCalc 5.0 Vorlage/Template') ### 20 --fmts.add('spreadsheet', 'xhtml', 'xhtml', 'XHTML', 'XHTML Calc File') ### 26 --fmts.add('spreadsheet', 'xls', 'xls', 'Microsoft Excel 97/2000/XP', 'MS Excel 97') ### 12 --fmts.add('spreadsheet', 'xls5', 'xls', 'Microsoft Excel 5.0', 'MS Excel 5.0/95') ### 8 --fmts.add('spreadsheet', 'xls95', 'xls', 'Microsoft Excel 95', 'MS Excel 95') ### 10 --fmts.add('spreadsheet', 'xlt', 'xlt', 'Microsoft Excel 97/2000/XP Template', 'MS Excel 97 Vorlage/Template') ### 6 --fmts.add('spreadsheet', 'xlt5', 'xlt', 'Microsoft Excel 5.0 Template', 'MS Excel 5.0/95 Vorlage/Template') ### 28 --fmts.add('spreadsheet', 'xlt95', 'xlt', 'Microsoft Excel 95 Template', 'MS Excel 95 Vorlage/Template') ### 21 -- --### Graphics --fmts.add('graphics', 'bmp', 'bmp', 'Windows Bitmap', 'draw_bmp_Export') ### 21 --fmts.add('graphics', 'emf', 'emf', 'Enhanced Metafile', 'draw_emf_Export') ### 15 --fmts.add('graphics', 'eps', 'eps', 'Encapsulated PostScript', 'draw_eps_Export') ### 48 --fmts.add('graphics', 'fodg', 'fodg', 'OpenDocument Drawing (Flat XML)', 'OpenDocument Drawing Flat XML') --fmts.add('graphics', 'gif', 'gif', 'Graphics Interchange Format', 'draw_gif_Export') ### 30 --fmts.add('graphics', 'html', 'html', 'HTML Document (OpenOffice.org Draw)', 'draw_html_Export') ### 37 --fmts.add('graphics', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'draw_jpg_Export') ### 3 --fmts.add('graphics', 'met', 'met', 'OS/2 Metafile', 'draw_met_Export') ### 43 --fmts.add('graphics', 'odd', 'odd', 'OpenDocument Drawing', 'draw8') ### 6 --fmts.add('graphics', 'otg', 'otg', 'OpenDocument Drawing Template', 'draw8_template') ### 20 --fmts.add('graphics', 'pbm', 'pbm', 'Portable Bitmap', 'draw_pbm_Export') ### 14 --fmts.add('graphics', 'pct', 'pct', 'Mac Pict', 'draw_pct_Export') ### 41 --fmts.add('graphics', 'pdf', 'pdf', 'Portable Document Format', 'draw_pdf_Export') ### 28 --fmts.add('graphics', 'pgm', 'pgm', 'Portable Graymap', 'draw_pgm_Export') ### 11 --fmts.add('graphics', 'png', 'png', 'Portable Network Graphic', 'draw_png_Export') ### 2 --fmts.add('graphics', 'ppm', 'ppm', 'Portable Pixelmap', 'draw_ppm_Export') ### 5 --fmts.add('graphics', 'ras', 'ras', 'Sun Raster Image', 'draw_ras_Export') ## 31 --fmts.add('graphics', 'std', 'std', 'OpenOffice.org 1.0 Drawing Template', 'draw_StarOffice_XML_Draw_Template') ### 53 --fmts.add('graphics', 'svg', 'svg', 'Scalable Vector Graphics', 'draw_svg_Export') ### 50 --fmts.add('graphics', 'svm', 'svm', 'StarView Metafile', 'draw_svm_Export') ### 55 --fmts.add('graphics', 'swf', 'swf', 'Macromedia Flash (SWF)', 'draw_flash_Export') ### 23 --fmts.add('graphics', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing', 'StarOffice XML (Draw)') ### 26 --fmts.add('graphics', 'sxd3', 'sxd', 'StarDraw 3.0', 'StarDraw 3.0') ### 40 --fmts.add('graphics', 'sxd5', 'sxd', 'StarDraw 5.0', 'StarDraw 5.0') ### 44 --fmts.add('graphics', 'sxw', 'sxw', 'StarOffice XML (Draw)', 'StarOffice XML (Draw)') --fmts.add('graphics', 'tiff', 'tiff', 'Tagged Image File Format', 'draw_tif_Export') ### 13 --fmts.add('graphics', 'vor', 'vor', 'StarDraw 5.0 Template', 'StarDraw 5.0 Vorlage') ### 36 --fmts.add('graphics', 'vor3', 'vor', 'StarDraw 3.0 Template', 'StarDraw 3.0 Vorlage') ### 35 --fmts.add('graphics', 'wmf', 'wmf', 'Windows Metafile', 'draw_wmf_Export') ### 8 --fmts.add('graphics', 'xhtml', 'xhtml', 'XHTML', 'XHTML Draw File') ### 45 --fmts.add('graphics', 'xpm', 'xpm', 'X PixMap', 'draw_xpm_Export') ### 19 -- --### Presentation --fmts.add('presentation', 'bmp', 'bmp', 'Windows Bitmap', 'impress_bmp_Export') ### 15 --fmts.add('presentation', 'emf', 'emf', 'Enhanced Metafile', 'impress_emf_Export') ### 16 --fmts.add('presentation', 'eps', 'eps', 'Encapsulated PostScript', 'impress_eps_Export') ### 17 --fmts.add('presentation', 'fodp', 'fodp', 'OpenDocument Presentation (Flat XML)', 'OpenDocument Presentation Flat XML') --fmts.add('presentation', 'gif', 'gif', 'Graphics Interchange Format', 'impress_gif_Export') ### 18 --fmts.add('presentation', 'html', 'html', 'HTML Document (OpenOffice.org Impress)', 'impress_html_Export') ### 43 --fmts.add('presentation', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'impress_jpg_Export') ### 19 --fmts.add('presentation', 'met', 'met', 'OS/2 Metafile', 'impress_met_Export') ### 20 --fmts.add('presentation', 'odg', 'odg', 'ODF Drawing (Impress)', 'impress8_draw') ### 29 --fmts.add('presentation', 'odp', 'odp', 'ODF Presentation', 'impress8') ### 9 --fmts.add('presentation', 'otp', 'otp', 'ODF Presentation Template', 'impress8_template') ### 38 --fmts.add('presentation', 'pbm', 'pbm', 'Portable Bitmap', 'impress_pbm_Export') ### 21 --fmts.add('presentation', 'pct', 'pct', 'Mac Pict', 'impress_pct_Export') ### 22 --fmts.add('presentation', 'pdf', 'pdf', 'Portable Document Format', 'impress_pdf_Export') ### 23 --fmts.add('presentation', 'pgm', 'pgm', 'Portable Graymap', 'impress_pgm_Export') ### 24 --fmts.add('presentation', 'png', 'png', 'Portable Network Graphic', 'impress_png_Export') ### 25 --fmts.add('presentation', 'potm', 'potm', 'Microsoft PowerPoint 2007/2010 XML Template', 'Impress MS PowerPoint 2007 XML Template') --fmts.add('presentation', 'pot', 'pot', 'Microsoft PowerPoint 97/2000/XP Template', 'MS PowerPoint 97 Vorlage') ### 3 --fmts.add('presentation', 'ppm', 'ppm', 'Portable Pixelmap', 'impress_ppm_Export') ### 26 --fmts.add('presentation', 'pptx', 'pptx', 'Microsoft PowerPoint 2007/2010 XML', 'Impress MS PowerPoint 2007 XML') ### 36 --fmts.add('presentation', 'pps', 'pps', 'Microsoft PowerPoint 97/2000/XP (Autoplay)', 'MS PowerPoint 97 Autoplay') ### 36 --fmts.add('presentation', 'ppt', 'ppt', 'Microsoft PowerPoint 97/2000/XP', 'MS PowerPoint 97') ### 36 --fmts.add('presentation', 'pwp', 'pwp', 'PlaceWare', 'placeware_Export') ### 30 --fmts.add('presentation', 'ras', 'ras', 'Sun Raster Image', 'impress_ras_Export') ### 27 --fmts.add('presentation', 'sda', 'sda', 'StarDraw 5.0 (OpenOffice.org Impress)', 'StarDraw 5.0 (StarImpress)') ### 8 --fmts.add('presentation', 'sdd', 'sdd', 'StarImpress 5.0', 'StarImpress 5.0') ### 6 --fmts.add('presentation', 'sdd3', 'sdd', 'StarDraw 3.0 (OpenOffice.org Impress)', 'StarDraw 3.0 (StarImpress)') ### 42 --fmts.add('presentation', 'sdd4', 'sdd', 'StarImpress 4.0', 'StarImpress 4.0') ### 37 --fmts.add('presentation', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing (OpenOffice.org Impress)', 'impress_StarOffice_XML_Draw') ### 31 --fmts.add('presentation', 'sti', 'sti', 'OpenOffice.org 1.0 Presentation Template', 'impress_StarOffice_XML_Impress_Template') ### 5 --fmts.add('presentation', 'svg', 'svg', 'Scalable Vector Graphics', 'impress_svg_Export') ### 14 --fmts.add('presentation', 'svm', 'svm', 'StarView Metafile', 'impress_svm_Export') ### 13 --fmts.add('presentation', 'swf', 'swf', 'Macromedia Flash (SWF)', 'impress_flash_Export') ### 34 --fmts.add('presentation', 'sxi', 'sxi', 'OpenOffice.org 1.0 Presentation', 'StarOffice XML (Impress)') ### 41 --fmts.add('presentation', 'tiff', 'tiff', 'Tagged Image File Format', 'impress_tif_Export') ### 12 --fmts.add('presentation', 'uop', 'uop', 'Unified Office Format presentation', 'UOF presentation') ### 4 --fmts.add('presentation', 'vor', 'vor', 'StarImpress 5.0 Template', 'StarImpress 5.0 Vorlage') ### 40 --fmts.add('presentation', 'vor3', 'vor', 'StarDraw 3.0 Template (OpenOffice.org Impress)', 'StarDraw 3.0 Vorlage (StarImpress)') ###1 --fmts.add('presentation', 'vor4', 'vor', 'StarImpress 4.0 Template', 'StarImpress 4.0 Vorlage') ### 39 --fmts.add('presentation', 'vor5', 'vor', 'StarDraw 5.0 Template (OpenOffice.org Impress)', 'StarDraw 5.0 Vorlage (StarImpress)') ### 2 --fmts.add('presentation', 'wmf', 'wmf', 'Windows Metafile', 'impress_wmf_Export') ### 11 --fmts.add('presentation', 'xhtml', 'xml', 'XHTML', 'XHTML Impress File') ### 33 --fmts.add('presentation', 'xpm', 'xpm', 'X PixMap', 'impress_xpm_Export') ### 10 -- --class Options: -- def __init__(self, args): -- self.connection = None -- self.debug = False -- self.doctype = None -- self.exportfilter = [] -- self.exportfilteroptions = "" -- self.filenames = [] -- self.format = None -- self.importfilter = [] -- self.importfilteroptions = "" -- self.listener = False -- self.nolaunch = False -- self.output = None -- self.password = None -- self.pipe = None -- self.port = '2002' -- self.server = '127.0.0.1' -- self.showlist = False -- self.stdout = False -- self.template = None -- self.timeout = 6 -- self.verbose = 0 -- -- ### Get options from the commandline -- try: -- opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:vV', -- ['connection=', 'debug', 'doctype=', 'export=', 'format=', -- 'help', 'import', 'listener', 'no-launch', 'output=', -- 'outputpath', 'password=', 'pipe=', 'port=', 'server=', -- 'timeout=', 'show', 'stdout', 'template', 'verbose', -- 'version'] ) -- except getopt.error, exc: -- print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc) -- sys.exit(255) -- -- for opt, arg in opts: -- if opt in ['-h', '--help']: -- self.usage() -- print -- self.help() -- sys.exit(1) -- elif opt in ['-c', '--connection']: -- self.connection = arg -- elif opt in ['--debug']: -- self.debug = True -- elif opt in ['-d', '--doctype']: -- self.doctype = arg -- elif opt in ['-e', '--export']: -- l = arg.split('=') -- if len(l) == 2: -- (name, value) = l -- if name in ('FilterOptions'): -- self.exportfilteroptions = value -- elif value in ('True', 'true'): -- self.exportfilter.append( PropertyValue( name, 0, True, 0 ) ) -- elif value in ('False', 'false'): -- self.exportfilter.append( PropertyValue( name, 0, False, 0 ) ) -- else: -- try: -- self.exportfilter.append( PropertyValue( name, 0, int(value), 0 ) ) -- except ValueError: -- self.exportfilter.append( PropertyValue( name, 0, value, 0 ) ) -- else: -- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg -- elif opt in ['-f', '--format']: -- self.format = arg -- elif opt in ['-i', '--import']: -- l = arg.split('=') -- if len(l) == 2: -- (name, value) = l -- if name in ('FilterOptions'): -- self.importfilteroptions = value -- elif value in ('True', 'true'): -- self.importfilter.append( PropertyValue( name, 0, True, 0 ) ) -- elif value in ('False', 'false'): -- self.importfilter.append( PropertyValue( name, 0, False, 0 ) ) -- else: -- try: -- self.importfilter.append( PropertyValue( name, 0, int(value), 0 ) ) -- except ValueError: -- self.importfilter.append( PropertyValue( name, 0, value, 0 ) ) -- else: -- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg -- elif opt in ['-l', '--listener']: -- self.listener = True -- elif opt in ['-n', '--no-launch']: -- self.nolaunch = True -- elif opt in ['-o', '--output']: -- self.output = arg -- elif opt in ['--outputpath']: -- print >>sys.stderr, 'Warning: This option is deprecated by --output.' -- self.output = arg -- elif opt in ['--password']: -- self.password = arg -- elif opt in ['--pipe']: -- self.pipe = arg -- elif opt in ['-p', '--port']: -- self.port = arg -- elif opt in ['-s', '--server']: -- self.server = arg -- elif opt in ['--show']: -- self.showlist = True -- elif opt in ['--stdout']: -- self.stdout = True -- elif opt in ['-t', '--template']: -- self.template = arg -- elif opt in ['-T', '--timeout']: -- self.timeout = int(arg) -- elif opt in ['-v', '--verbose']: -- self.verbose = self.verbose + 1 -- elif opt in ['-V', '--version']: -- self.version() -- sys.exit(255) -- -- ### Enable verbosity -- if self.verbose >= 2: -- print >>sys.stderr, 'Verbosity set to level %d' % self.verbose -- -- self.filenames = args -- -- if not self.listener and not self.showlist and self.doctype != 'list' and not self.filenames: -- print >>sys.stderr, 'unoconv: you have to provide a filename as argument' -- print >>sys.stderr, 'Try `unoconv -h\' for more information.' -- sys.exit(255) -- -- ### Set connection string -- if not self.connection: -- if not self.pipe: -- self.connection = "socket,host=%s,port=%s;urp;StarOffice.ComponentContext" % (self.server, self.port) --# self.connection = "socket,host=%s,port=%s;urp;" % (self.server, self.port) -- else: -- self.connection = "pipe,name=%s;urp;StarOffice.ComponentContext" % (self.pipe) -- -- ### Make it easier for people to use a doctype (first letter is enough) -- if self.doctype: -- for doctype in doctypes: -- if doctype.startswith(self.doctype): -- self.doctype = doctype -- -- ### Check if the user request to see the list of formats -- if self.showlist or self.format == 'list': -- if self.doctype: -- fmts.display(self.doctype) -- else: -- for t in doctypes: -- fmts.display(t) -- sys.exit(0) -- -- ### If no format was specified, probe it or provide it -- if not self.format: -- l = sys.argv[0].split('2') -- if len(l) == 2: -- self.format = l[1] -- else: -- self.format = 'pdf' -- -- def version(self): -- ### Get office product information -- product = uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) -- -- print 'unoconv %s' % VERSION -- print 'Written by Dag Wieers ' -- print 'Homepage at http://dag.wieers.com/home-made/unoconv/' -- print -- print 'platform %s/%s' % (os.name, sys.platform) -- print 'python %s' % sys.version -- print product.ooName, product.ooSetupVersion --# print --# print 'build revision $Rev$' -- -- def usage(self): -- print >>sys.stderr, 'usage: unoconv [options] file [file2 ..]' -- -- def help(self): -- print >>sys.stderr, '''Convert from and to any format supported by LibreOffice -- --unoconv options: -- -c, --connection=string use a custom connection string -- -d, --doctype=type specify document type -- (document, graphics, presentation, spreadsheet) -- -e, --export=name=value set export filter options -- eg. -e PageRange=1-2 -- -f, --format=format specify the output format -- -i, --import=string set import filter option string -- eg. -i utf8 -- -l, --listener start a permanent listener to use by unoconv clients -- -n, --no-launch fail if no listener is found (default: launch one) -- -o, --output=name output basename, filename or directory -- --pipe=name alternative method of connection using a pipe -- -p, --port=port specify the port (default: 2002) -- to be used by client or listener -- --password=string provide a password to decrypt the document -- -s, --server=server specify the server address (default: 127.0.0.1) -- to be used by client or listener -- --show list the available output formats -- --stdout write output to stdout -- -t, --template=file import the styles from template (.ott) -- -T, --timeout=secs timeout after secs if connection to listener fails -- -v, --verbose be more and more verbose (-vvv for debugging) --''' -- --class Convertor: -- def __init__(self): -- global exitcode, ooproc, office, product -- unocontext = None -- -- ### Do the LibreOffice component dance -- self.context = uno.getComponentContext() -- self.svcmgr = self.context.ServiceManager -- resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) -- -- ### Test for an existing connection -- info(3, 'Connection type: %s' % op.connection) -- try: -- unocontext = resolver.resolve("uno:%s" % op.connection) -- except NoConnectException, e: --# info(3, "Existing listener not found.\n%s" % e) -- info(3, "Existing listener not found.") -- -- if op.nolaunch: -- die(113, "Existing listener not found. Unable start listener by parameters. Aborting.") -- -- ### Start our own OpenOffice instance -- info(3, "Launching our own listener using %s." % office.binary) -- try: -- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) -- if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): -- ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) -- else: -- ooproc = subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--accept=%s" % op.connection], env=os.environ) -- info(2, '%s listener successfully started. (pid=%s)' % (product.ooName, ooproc.pid)) -- -- ### Try connection to it for op.timeout seconds (flakky OpenOffice) -- timeout = 0 -- while timeout <= op.timeout: -- ### Is it already/still running ? -- retcode = ooproc.poll() -- if retcode != None: -- info(3, "Process %s (pid=%s) exited with %s." % (office.binary, ooproc.pid, retcode)) -- break -- try: -- unocontext = resolver.resolve("uno:%s" % op.connection) -- break -- except NoConnectException: -- time.sleep(0.5) -- timeout += 0.5 -- except: -- raise -- else: -- error("Failed to connect to %s (pid=%s) in %d seconds.\n%s" % (office.binary, ooproc.pid, op.timeout, e)) -- except Exception, e: -- raise -- error("Launch of %s failed.\n%s" % (office.binary, e)) -- -- if not unocontext: -- die(251, "Unable to connect or start own listener. Aborting.") -- -- ### And some more LibreOffice magic -- unosvcmgr = unocontext.ServiceManager -- self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) -- self.cwd = unohelper.systemPathToFileUrl( os.getcwd() ) -- -- ### List all filters --# self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) --# for filter in self.filters.getElementNames(): --# print filter --# #print dir(filter), dir(filter.format) -- -- def getformat(self, inputfn): -- doctype = None -- -- ### Get the output format from mapping -- if op.doctype: -- outputfmt = fmts.bydoctype(op.doctype, op.format) -- else: -- outputfmt = fmts.byname(op.format) -- -- if not outputfmt: -- outputfmt = fmts.byextension(os.extsep + op.format) -- -- ### If no doctype given, check list of acceptable formats for input file ext doctype -- ### FIXME: This should go into the for-loop to match each individual input filename -- if outputfmt: -- inputext = os.path.splitext(inputfn)[1] -- inputfmt = fmts.byextension(inputext) -- if inputfmt: -- for fmt in outputfmt: -- if inputfmt[0].doctype == fmt.doctype: -- doctype = inputfmt[0].doctype -- outputfmt = fmt -- break -- else: -- outputfmt = outputfmt[0] -- # print >>sys.stderr, 'unoconv: format `%s\' is part of multiple doctypes %s, selecting `%s\'.' % (format, [fmt.doctype for fmt in outputfmt], outputfmt[0].doctype) -- else: -- outputfmt = outputfmt[0] -- -- ### No format found, throw error -- if not outputfmt: -- if doctype: -- print >>sys.stderr, 'unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format) -- else: -- print >>sys.stderr, 'unoconv: format [%s] is not known to unoconv.' % op.format -- die(1) -- -- return outputfmt -- -- def convert(self, inputfn): -- global exitcode -- -- document = None -- outputfmt = self.getformat(inputfn) -- -- if op.verbose > 0: -- print >>sys.stderr, 'Input file:', inputfn -- -- if not os.path.exists(inputfn): -- print >>sys.stderr, 'unoconv: file `%s\' does not exist.' % inputfn -- exitcode = 1 -- -- try: -- ### Import phase -- phase = "import" -- -- ### Load inputfile -- inputprops = UnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=QUIET_UPDATE) -- --# if op.password: --# info = UnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") --# inputprops += UnoProps(ModifyPasswordInfo=info) -- -- ### Cannot use UnoProps for FilterData property -- if op.importfilteroptions: --# print "Import filter options: %s" % op.importfilteroptions -- inputprops += UnoProps(FilterOptions=op.importfilteroptions) -- -- ### Cannot use UnoProps for FilterData property -- if op.importfilter: -- inputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) -- -- inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn)) -- document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) -- -- if not document: -- raise UnoException("The document '%s' could not be opened." % inputurl, None) -- -- ### Import style template -- phase = "import-style" -- if op.template: -- if os.path.exists(op.template): -- info(1, "Template file: %s" % op.template) -- templateprops = UnoProps(OverwriteStyles=True) -- templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template)) -- document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) -- else: -- print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template -- exitcode = 1 -- -- ### Update document links -- phase = "update-links" -- try: -- document.updateLinks() -- except AttributeError: -- # the document doesn't implement the XLinkUpdate interface -- pass -- -- ### Update document indexes -- phase = "update-indexes" -- try: -- document.refresh() -- indexes = document.getDocumentIndexes() -- except AttributeError: -- # the document doesn't implement the XRefreshable and/or -- # XDocumentIndexesSupplier interfaces -- pass -- else: -- for i in range(0, indexes.getCount()): -- indexes.getByIndex(i).update() -- -- info(1, "Selected output format: %s" % outputfmt) -- info(2, "Selected office filter: %s" % outputfmt.filter) -- info(2, "Used doctype: %s" % outputfmt.doctype) -- -- ### Export phase -- phase = "export" -- -- outputprops = UnoProps(FilterName=outputfmt.filter, OutputStream=OutputStream(), Overwrite=True) -- -- ### Set default filter options -- if op.exportfilteroptions: --# print "Export filter options: %s" % op.exportfilteroptions -- outputprops += UnoProps(FilterOptions=op.exportfilteroptions) -- else: -- if outputfmt.filter == 'Text (encoded)': -- outputprops += UnoProps(FilterOptions="76,LF") -- -- elif outputfmt.filter == 'Text': -- outputprops += UnoProps(FilterOptions="76") -- -- elif outputfmt.filter == 'Text - txt - csv (StarCalc)': -- outputprops += UnoProps(FilterOptions="44,34,76") -- -- -- ### Cannot use UnoProps for FilterData property -- if op.exportfilter: -- outputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) -- -- if not op.stdout: -- (outputfn, ext) = os.path.splitext(inputfn) -- if not op.output: -- outputfn = outputfn + os.extsep + outputfmt.extension -- elif os.path.isdir(op.output): -- outputfn = realpath(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension) -- elif len(op.filenames) > 1: -- outputfn = op.output + os.extsep + outputfmt.extension -- else: -- outputfn = op.output -- -- outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) -- info(1, "Output file: %s" % outputfn) -- else: -- outputurl = "private:stream" -- -- try: -- document.storeToURL(outputurl, tuple(outputprops) ) -- except IOException, e: -- raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) -- -- phase = "dispose" -- document.dispose() -- document.close(True) -- -- except SystemError, e: -- error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) -- exitcode = 1 -- -- except RuntimeException, e: -- error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) -- exitcode = 6 -- -- except DisposedException, e: -- error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) -- exitcode = 7 -- -- except IllegalArgumentException, e: -- error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) -- exitcode = 8 -- -- except IOException, e: --# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) -- error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) -- exitcode = 3 -- -- except CannotConvertException, e: --# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) -- error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) -- exitcode = 4 -- -- except UnoException, e: -- if hasattr(e, 'ErrCode'): -- error("unoconv: UnoException during %s phase in %s (ErrCode %d)" % (phase, repr(e.__class__), e.ErrCode)) -- exitcode = e.ErrCode -- pass -- if hasattr(e, 'Message'): -- error("unoconv: UnoException during %s phase:\n%s" % (phase, e.Message)) -- exitcode = 5 -- else: -- error("unoconv: UnoException during %s phase in %s" % (phase, repr(e.__class__))) -- exitcode = 2 -- pass -- --class Listener: -- def __init__(self): -- global product -- -- info(1, "Start listener on %s:%s" % (op.server, op.port)) -- self.context = uno.getComponentContext() -- self.svcmgr = self.context.ServiceManager -- try: -- resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) -- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) -- try: -- unocontext = resolver.resolve("uno:%s" % op.connection) -- except NoConnectException, e: -- pass -- else: -- info(1, "Existing %s listener found, nothing to do." % product.ooName) -- return -- if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): -- subprocess.call([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection], env=os.environ) -- else: -- subprocess.call([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection], env=os.environ) -- except Exception, e: -- error("Launch of %s failed.\n%s" % (office.binary, e)) -- else: -- info(1, "Existing %s listener found, nothing to do." % product.ooName) -- --def error(msg): -- "Output error message" -- print >>sys.stderr, msg -- --def info(level, msg): -- "Output info message" -- if 'op' not in globals(): -- pass -- elif op.verbose >= 3 and level >= 3: -- print >>sys.stderr, "DEBUG:", msg -- elif not op.stdout and level <= op.verbose: -- print >>sys.stdout, msg -- elif level <= op.verbose: -- print >>sys.stderr, msg -- --def die(ret, msg=None): -- "Print optional error and exit with errorcode" -- global convertor, ooproc, office -- -- if msg: -- error('Error: %s' % msg) -- -- ### Did we start our own listener instance ? -- if not op.listener and ooproc and convertor: -- -- ### If there is a GUI now attached to the instance, disable listener -- if convertor.desktop.getCurrentFrame(): -- info(2, 'Trying to stop %s GUI listener.' % product.ooName) -- try: -- if product.ooName != "LibreOffice" or product.ooSetupVersion <= 3.3: -- subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection], env=os.environ) -- else: -- subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection], env=os.environ) -- ooproc.wait() -- info(2, '%s listener successfully disabled.' % product.ooName) -- except Exception, e: -- error("Terminate using %s failed.\n%s" % (office.binary, e)) -- -- ### If there is no GUI attached to the instance, terminate instance -- else: -- info(3, 'Terminating %s instance.' % product.ooName) -- try: -- convertor.desktop.terminate() -- except DisposedException: -- info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) -- try: -- ooproc.terminate() -- except AttributeError: -- os.kill(ooproc.pid, 15) -- info(3, 'Waiting for %s instance to exit.' % product.ooName) -- ooproc.wait() -- -- ### LibreOffice processes may get stuck and we have to kill them -- ### Is it still running ? -- if ooproc.poll() == None: -- info(1, '%s instance still running, please investigate...' % product.ooName) -- ooproc.wait() -- info(2, '%s instance unsuccessfully terminated, sending KILL signal.' % product.ooName) -- try: -- ooproc.kill() -- except AttributeError: -- os.kill(ooproc.pid, 9) -- info(3, 'Waiting for %s with pid %s to disappear.' % (ooproc.pid, product.ooName)) -- ooproc.wait() -- -- # allow Python GC to garbage collect pyuno object *before* exit call -- # which avoids random segmentation faults --vpa -- convertor = None -- -- sys.exit(ret) -- --def main(): -- global convertor, exitcode -- convertor = None -- -- try: -- if op.listener: -- listener = Listener() -- -- if op.filenames: -- convertor = Convertor() -- for inputfn in op.filenames: -- convertor.convert(inputfn) -- -- except NoConnectException, e: -- error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) -- if op.connection: -- info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) -- else: -- info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"socket,host=%s,port=%s;urp;\"" % (op.server, op.server, op.port, op.server, op.port)) -- info(0, "Please start an soffice instance on server '%s' by doing:\n\n soffice -nologo -nodefault -accept=\"socket,host=127.0.0.1,port=%s;urp;\"" % (op.server, op.port)) -- exitcode = 1 --# except UnboundLocalError: --# die(252, "Failed to connect to remote listener.") -- except OSError: -- error("Warning: failed to launch Office suite. Aborting.") -- --### Main entrance - if __name__ == '__main__': -- exitcode = 0 -- -- info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) -- -- for of in find_offices(): -- if of.python != sys.executable and not sys.executable.startswith(of.basepath): -- python_switch(of) -- office_environ(of) --# debug_office() -- try: -- import uno, unohelper -- office = of -- break -- except: --# debug_office() -- print >>sys.stderr, "unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of -- print >>sys.stderr, "ERROR:", sys.exc_info()[1] -- print >>sys.stderr -+ if sys.version_info < (3,0): -+ from unoconv2 import run - else: --# debug_office() -- print >>sys.stderr, "unoconv: Cannot find a suitable office installation on your system." -- print >>sys.stderr, "ERROR: Please locate your office installation and send your feedback to:" -- print >>sys.stderr, " http://github.com/dagwieers/unoconv/issues" -- sys.exit(1) -- -- ### Now that we have found a working pyuno library, let's import some classes -- from com.sun.star.beans import PropertyValue -- from com.sun.star.connection import NoConnectException -- from com.sun.star.document.UpdateDocMode import QUIET_UPDATE -- from com.sun.star.lang import DisposedException, IllegalArgumentException -- from com.sun.star.io import IOException, XOutputStream -- from com.sun.star.script import CannotConvertException -- from com.sun.star.uno import Exception as UnoException -- from com.sun.star.uno import RuntimeException -- -- ### And now that we have those classes, build on them -- class OutputStream( unohelper.Base, XOutputStream ): -- def __init__( self ): -- self.closed = 0 -- -- def closeOutput(self): -- self.closed = 1 -- -- def writeBytes( self, seq ): -- sys.stdout.write( seq.value ) -- -- def flush( self ): -- pass -- -- def UnoProps(**args): -- props = [] -- for key in args: -- prop = PropertyValue() -- prop.Name = key -- prop.Value = args[key] -- props.append(prop) -- return tuple(props) -- -- op = Options(sys.argv[1:]) -- -- info(2, "Using office base path: %s" % office.basepath) -- info(2, "Using office binary path: %s" % office.unopath) -+ from unoconv3 import run - -- try: -- main() -- except KeyboardInterrupt, e: -- die(6, 'Exiting on user request') -- die(exitcode) -+ run() -diff --git a/unoconv2.py b/unoconv2.py -new file mode 100755 -index 0000000..1aecbb6 ---- /dev/null -+++ b/unoconv2.py -@@ -0,0 +1,1195 @@ -+#!/usr/bin/python -+ -+### This program is free software; you can redistribute it and/or modify -+### it under the terms of the GNU General Public License as published by -+### the Free Software Foundation; version 2 only -+### -+### This program is distributed in the hope that it will be useful, -+### but WITHOUT ANY WARRANTY; without even the implied warranty of -+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+### GNU General Public License for more details. -+### -+### You should have received a copy of the GNU General Public License -+### along with this program; if not, write to the Free Software -+### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+### Copyright 2007-2010 Dag Wieers -+ -+from distutils.version import LooseVersion -+import getopt -+import glob -+import os -+import subprocess -+import sys -+import time -+ -+__version__ = "$Revision$" -+# $Source$ -+ -+VERSION = '0.6' -+ -+doctypes = ('document', 'graphics', 'presentation', 'spreadsheet') -+ -+global convertor, office, ooproc, product -+ooproc = None -+exitcode = 0 -+ -+class Office: -+ def __init__(self, basepath, urepath, unopath, pyuno, binary, python, pythonhome): -+ self.basepath = basepath -+ self.urepath = urepath -+ self.unopath = unopath -+ self.pyuno = pyuno -+ self.binary = binary -+ self.python = python -+ self.pythonhome = pythonhome -+ -+ def __str__(self): -+ return self.basepath -+ -+ def __repr__(self): -+ return self.basepath -+ -+### Implement a path normalizer in order to make unoconv work on MacOS X -+### (on which 'program' is a symlink to 'MacOSX' which seems to break unoconv) -+def realpath(*args): -+ ''' Implement a combination of os.path.join(), os.path.abspath() and -+ os.path.realpath() in order to normalize path constructions ''' -+ ret = '' -+ for arg in args: -+ ret = os.path.join(ret, arg) -+ return os.path.realpath(os.path.abspath(ret)) -+ -+### The first thing we ought to do is find a suitable Office installation -+### with a compatible pyuno library that we can import. -+### -+### See: http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=36370&p=166783 -+ -+def find_offices(): -+ ret = [] -+ extrapaths = [] -+ -+ ### Try using UNO_PATH first (in many incarnations, we'll see what sticks) -+ if 'UNO_PATH' in os.environ: -+ extrapaths += [ os.environ['UNO_PATH'], -+ os.path.dirname(os.environ['UNO_PATH']), -+ os.path.dirname(os.path.dirname(os.environ['UNO_PATH'])) ] -+ -+ else: -+ -+ if os.name in ( 'nt', 'os2' ): -+ if 'PROGRAMFILES' in os.environ.keys(): -+ extrapaths += glob.glob(os.environ['PROGRAMFILES']+'\\LibreOffice*') + \ -+ glob.glob(os.environ['PROGRAMFILES']+'\\OpenOffice.org*') -+ -+ if 'PROGRAMFILES(X86)' in os.environ.keys(): -+ extrapaths += glob.glob(os.environ['PROGRAMFILES(X86)']+'\\LibreOffice*') + \ -+ glob.glob(os.environ['PROGRAMFILES(X86)']+'\\OpenOffice.org*') -+ -+ elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): -+ extrapaths += [ '/Applications/LibreOffice.app/Contents', -+ '/Applications/NeoOffice.app/Contents', -+ '/Applications/OpenOffice.org.app/Contents' ] -+ -+ else: -+ extrapaths += glob.glob('/usr/lib*/libreoffice*') + \ -+ glob.glob('/usr/lib*/openoffice*') + \ -+ glob.glob('/usr/lib*/ooo*') + \ -+ glob.glob('/opt/libreoffice*') + \ -+ glob.glob('/opt/openoffice*') + \ -+ glob.glob('/opt/ooo*') + \ -+ glob.glob('/usr/local/libreoffice*') + \ -+ glob.glob('/usr/local/openoffice*') + \ -+ glob.glob('/usr/local/ooo*') + \ -+ glob.glob('/usr/local/lib/libreoffice*') -+ -+ ### Find a working set for python UNO bindings -+ for basepath in extrapaths: -+ if os.name in ( 'nt', 'os2' ): -+ officelibraries = ( 'pyuno.pyd', ) -+ officebinaries = ( 'soffice.exe' ,) -+ pythonbinaries = ( 'python.exe', ) -+ pythonhomes = () -+ elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): -+ officelibraries = ( 'pyuno.so', 'libpyuno.dylib' ) -+ officebinaries = ( 'soffice.bin', ) -+ pythonbinaries = ( 'python.bin', 'python' ) -+ pythonhomes = ( 'OOoPython.framework/Versions/*/lib/python*', ) -+ else: -+ officelibraries = ( 'pyuno.so', ) -+ officebinaries = ( 'soffice.bin', ) -+ pythonbinaries = ( 'python.bin', 'python', ) -+ pythonhomes = ( 'python-core-*', ) -+ -+ ### Older LibreOffice/OpenOffice and Windows use basis-link/ or basis/ -+ libpath = 'error' -+ for basis in ( 'basis-link', 'basis', '' ): -+ for lib in officelibraries: -+ if os.path.isfile(realpath(basepath, basis, 'program', lib)): -+ libpath = realpath(basepath, basis, 'program') -+ officelibrary = realpath(libpath, lib) -+ info(3, "Found %s in %s" % (lib, libpath)) -+ # Break the inner loop... -+ break -+ # Continue if the inner loop wasn't broken. -+ else: -+ continue -+ # Inner loop was broken, break the outer. -+ break -+ else: -+ continue -+ -+ ### MacOSX have soffice binaries installed in MacOS subdirectory, not program -+ unopath = 'error' -+ for basis in ( 'basis-link', 'basis', '' ): -+ for bin in officebinaries: -+ if os.path.isfile(realpath(basepath, basis, 'program', bin)): -+ unopath = realpath(basepath, basis, 'program') -+ officebinary = realpath(unopath, bin) -+ info(3, "Found %s in %s" % (bin, unopath)) -+ # Break the inner loop... -+ break -+ # Continue if the inner loop wasn't broken. -+ else: -+ continue -+ # Inner loop was broken, break the outer. -+ break -+ else: -+ continue -+ -+ ### Windows does not provide or need a URE/lib directory ? -+ urepath = '' -+ for basis in ( 'basis-link', 'basis', '' ): -+ for ure in ( 'ure-link', 'ure', 'URE', '' ): -+ if os.path.isfile(realpath(basepath, basis, ure, 'lib', 'unorc')): -+ urepath = realpath(basepath, basis, ure) -+ info(3, "Found %s in %s" % ('unorc', realpath(urepath, 'lib'))) -+ # Break the inner loop... -+ break -+ # Continue if the inner loop wasn't broken. -+ else: -+ continue -+ # Inner loop was broken, break the outer. -+ break -+ -+ pythonhome = None -+ for home in pythonhomes: -+ if glob.glob(realpath(libpath, home)): -+ pythonhome = glob.glob(realpath(libpath, home))[0] -+ info(3, "Found %s in %s" % (home, pythonhome)) -+ break -+ -+# if not os.path.isfile(realpath(basepath, program, officebinary)): -+# continue -+# info(3, "Found %s in %s" % (officebinary, realpath(basepath, program))) -+ -+# if not glob.glob(realpath(basepath, basis, program, 'python-core-*')): -+# continue -+ -+ for pythonbinary in pythonbinaries: -+ if os.path.isfile(realpath(unopath, pythonbinary)): -+ info(3, "Found %s in %s" % (pythonbinary, unopath)) -+ ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, -+ realpath(unopath, pythonbinary), pythonhome)) -+ else: -+ info(3, "Considering %s" % basepath) -+ ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, -+ sys.executable, None)) -+ return ret -+ -+def office_environ(office): -+ ### Set PATH so that crash_report is found -+ os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH'] -+ -+ ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: -+ os.environ['UNO_PATH'] = office.unopath -+ -+ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete -+ ### UNO environment -+ if os.name in ( 'nt', 'os2' ): -+ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') -+ else: -+ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamentalrc') -+ -+ ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: -+ if 'LD_LIBRARY_PATH' in os.environ: -+ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -+ realpath(office.urepath, 'lib') + os.pathsep + \ -+ os.environ['LD_LIBRARY_PATH'] -+ else: -+ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -+ realpath(office.urepath, 'lib') -+ -+ if office.pythonhome: -+ for libpath in ( realpath(office.pythonhome, 'lib'), -+ realpath(office.pythonhome, 'lib', 'lib-dynload'), -+ realpath(office.pythonhome, 'lib', 'lib-tk'), -+ realpath(office.pythonhome, 'lib', 'site-packages'), -+ office.unopath): -+ sys.path.insert(0, libpath) -+ else: -+ ### Still needed for system python using LibreOffice UNO bindings -+ ### Although we prefer to use a system UNO binding in this case -+ sys.path.append(office.unopath) -+ -+def debug_office(): -+ if 'URE_BOOTSTRAP' in os.environ: -+ print >>sys.stderr, 'URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'] -+ if 'UNO_PATH' in os.environ: -+ print >>sys.stderr, 'UNO_PATH=%s' % os.environ['UNO_PATH'] -+ if 'UNO_TYPES' in os.environ: -+ print >>sys.stderr, 'UNO_TYPES=%s' % os.environ['UNO_TYPES'] -+ print 'PATH=%s' % os.environ['PATH'] -+ if 'PYTHONHOME' in os.environ: -+ print >>sys.stderr, 'PYTHONHOME=%s' % os.environ['PYTHONHOME'] -+ if 'PYTHONPATH' in os.environ: -+ print >>sys.stderr, 'PYTHONPATH=%s' % os.environ['PYTHONPATH'] -+ if 'LD_LIBRARY_PATH' in os.environ: -+ print >>sys.stderr, 'LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'] -+ -+def python_switch(office): -+ if office.pythonhome: -+ os.environ['PYTHONHOME'] = office.pythonhome -+ os.environ['PYTHONPATH'] = realpath(office.pythonhome, 'lib') + os.pathsep + \ -+ realpath(office.pythonhome, 'lib', 'lib-dynload') + os.pathsep + \ -+ realpath(office.pythonhome, 'lib', 'lib-tk') + os.pathsep + \ -+ realpath(office.pythonhome, 'lib', 'site-packages') + os.pathsep + \ -+ office.unopath -+ -+ os.environ['UNO_PATH'] = office.unopath -+ -+ info(3, "-> Switching from %s to %s" % (sys.executable, office.python)) -+ if os.name in ('nt', 'os2'): -+ ### os.execv is broken on Windows and can't properly parse command line -+ ### arguments and executable name if they contain whitespaces. subprocess -+ ### fixes that behavior. -+ ret = subprocess.call([office.python] + sys.argv[0:]) -+ sys.exit(ret) -+ else: -+ -+ ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: -+ if 'LD_LIBRARY_PATH' in os.environ: -+ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -+ realpath(office.urepath, 'lib') + os.pathsep + \ -+ os.environ['LD_LIBRARY_PATH'] -+ else: -+ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -+ realpath(office.urepath, 'lib') -+ -+ try: -+ os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) -+ print(office.python, [office.python, ] + sys.argv[0:], osenviron) -+ except OSError: -+ ### Mac OS X versions prior to 10.6 do not support execv in -+ ### a process that contains multiple threads. Instead of -+ ### re-executing in the current process, start a new one -+ ### and cause the current process to exit. This isn't -+ ### ideal since the new process is detached from the parent -+ ### terminal and thus cannot easily be killed with ctrl-C, -+ ### but it's better than not being able to autoreload at -+ ### all. -+ ### Unfortunately the errno returned in this case does not -+ ### appear to be consistent, so we can't easily check for -+ ### this error specifically. -+ ret = os.spawnvpe(os.P_WAIT, office.python, [office.python, ] + sys.argv[0:], os.environ) -+ sys.exit(ret) -+ -+class Fmt: -+ def __init__(self, doctype, name, extension, summary, filter): -+ self.doctype = doctype -+ self.name = name -+ self.extension = extension -+ self.summary = summary -+ self.filter = filter -+ -+ def __str__(self): -+ return "%s [.%s]" % (self.summary, self.extension) -+ -+ def __repr__(self): -+ return "%s/%s" % (self.name, self.doctype) -+ -+class FmtList: -+ def __init__(self): -+ self.list = [] -+ -+ def add(self, doctype, name, extension, summary, filter): -+ self.list.append(Fmt(doctype, name, extension, summary, filter)) -+ -+ def byname(self, name): -+ ret = [] -+ for fmt in self.list: -+ if fmt.name == name: -+ ret.append(fmt) -+ return ret -+ -+ def byextension(self, extension): -+ ret = [] -+ for fmt in self.list: -+ if os.extsep + fmt.extension == extension: -+ ret.append(fmt) -+ return ret -+ -+ def bydoctype(self, doctype, name): -+ ret = [] -+ for fmt in self.list: -+ if fmt.name == name and fmt.doctype == doctype: -+ ret.append(fmt) -+ return ret -+ -+ def display(self, doctype): -+ print >>sys.stderr, "The following list of %s formats are currently available:\n" % doctype -+ for fmt in self.list: -+ if fmt.doctype == doctype: -+ print >>sys.stderr, " %-8s - %s" % (fmt.name, fmt) -+ print >>sys.stderr -+ -+fmts = FmtList() -+ -+### TextDocument -+fmts.add('document', 'bib', 'bib', 'BibTeX', 'BibTeX_Writer') ### 22 -+fmts.add('document', 'doc', 'doc', 'Microsoft Word 97/2000/XP', 'MS Word 97') ### 29 -+fmts.add('document', 'doc6', 'doc', 'Microsoft Word 6.0', 'MS WinWord 6.0') ### 24 -+fmts.add('document', 'doc95', 'doc', 'Microsoft Word 95', 'MS Word 95') ### 28 -+fmts.add('document', 'docbook', 'xml', 'DocBook', 'DocBook File') ### 39 -+fmts.add('document', 'docx', 'docx', 'Microsoft Office Open XML', 'Office Open XML Text') -+fmts.add('document', 'docx7', 'docx', 'Microsoft Office Open XML', 'MS Word 2007 XML') -+fmts.add('document', 'fodt', 'fodt', 'OpenDocument Text (Flat XML)', 'OpenDocument Text Flat XML') -+fmts.add('document', 'html', 'html', 'HTML Document (OpenOffice.org Writer)', 'HTML (StarWriter)') ### 3 -+fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'LaTeX_Writer') ### 31 -+fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') -+fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 -+fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 -+fmts.add('document', 'ott', 'ott', 'Open Document Text', 'writer8_template') ### 21 -+fmts.add('document', 'pdb', 'pdb', 'AportisDoc (Palm)', 'AportisDoc Palm DB') -+fmts.add('document', 'pdf', 'pdf', 'Portable Document Format', 'writer_pdf_Export') ### 18 -+fmts.add('document', 'psw', 'psw', 'Pocket Word', 'PocketWord File') -+fmts.add('document', 'rtf', 'rtf', 'Rich Text Format', 'Rich Text Format') ### 16 -+fmts.add('document', 'sdw', 'sdw', 'StarWriter 5.0', 'StarWriter 5.0') ### 23 -+fmts.add('document', 'sdw4', 'sdw', 'StarWriter 4.0', 'StarWriter 4.0') ### 2 -+fmts.add('document', 'sdw3', 'sdw', 'StarWriter 3.0', 'StarWriter 3.0') ### 20 -+fmts.add('document', 'stw', 'stw', 'Open Office.org 1.0 Text Document Template', 'writer_StarOffice_XML_Writer_Template') ### 9 -+fmts.add('document', 'sxw', 'sxw', 'Open Office.org 1.0 Text Document', 'StarOffice XML (Writer)') ### 1 -+fmts.add('document', 'text', 'txt', 'Text Encoded', 'Text (encoded)') ### 26 -+fmts.add('document', 'txt', 'txt', 'Text', 'Text') ### 34 -+fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### 27 -+fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 -+fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 -+fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 -+fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 -+ -+### WebDocument -+fmts.add('web', 'etext', 'txt', 'Text Encoded (OpenOffice.org Writer/Web)', 'Text (encoded) (StarWriter/Web)') ### 14 -+fmts.add('web', 'html10', 'html', 'OpenOffice.org 1.0 HTML Template', 'writer_web_StarOffice_XML_Writer_Web_Template') ### 11 -+fmts.add('web', 'html', 'html', 'HTML Document', 'HTML') ### 2 -+fmts.add('web', 'html', 'html', 'HTML Document Template', 'writerweb8_writer_template') ### 13 -+fmts.add('web', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki_Web') ### 9 -+fmts.add('web', 'pdf', 'pdf', 'PDF - Portable Document Format', 'writer_web_pdf_Export') ### 10 -+fmts.add('web', 'sdw3', 'sdw', 'StarWriter 3.0 (OpenOffice.org Writer/Web)', 'StarWriter 3.0 (StarWriter/Web)') ### 3 -+fmts.add('web', 'sdw4', 'sdw', 'StarWriter 4.0 (OpenOffice.org Writer/Web)', 'StarWriter 4.0 (StarWriter/Web)') ### 4 -+fmts.add('web', 'sdw', 'sdw', 'StarWriter 5.0 (OpenOffice.org Writer/Web)', 'StarWriter 5.0 (StarWriter/Web)') ### 5 -+fmts.add('web', 'txt', 'txt', 'OpenOffice.org Text (OpenOffice.org Writer/Web)', 'writerweb8_writer') ### 12 -+fmts.add('web', 'text10', 'txt', 'OpenOffice.org 1.0 Text Document (OpenOffice.org Writer/Web)', 'writer_web_StarOffice_XML_Writer') ### 15 -+fmts.add('web', 'text', 'txt', 'Text (OpenOffice.org Writer/Web)', 'Text (StarWriter/Web)') ### 8 -+fmts.add('web', 'vor4', 'vor', 'StarWriter/Web 4.0 Template', 'StarWriter/Web 4.0 Vorlage/Template') ### 6 -+fmts.add('web', 'vor', 'vor', 'StarWriter/Web 5.0 Template', 'StarWriter/Web 5.0 Vorlage/Template') ### 7 -+ -+### Spreadsheet -+fmts.add('spreadsheet', 'csv', 'csv', 'Text CSV', 'Text - txt - csv (StarCalc)') ### 16 -+fmts.add('spreadsheet', 'dbf', 'dbf', 'dBASE', 'dBase') ### 22 -+fmts.add('spreadsheet', 'dif', 'dif', 'Data Interchange Format', 'DIF') ### 5 -+fmts.add('spreadsheet', 'fods', 'fods', 'OpenDocument Spreadsheet (Flat XML)', 'OpenDocument Spreadsheet Flat XML') -+fmts.add('spreadsheet', 'html', 'html', 'HTML Document (OpenOffice.org Calc)', 'HTML (StarCalc)') ### 7 -+fmts.add('spreadsheet', 'ods', 'ods', 'ODF Spreadsheet', 'calc8') ### 15 -+fmts.add('spreadsheet', 'ooxml', 'xml', 'Microsoft Excel 2003 XML', 'MS Excel 2003 XML') ### 23 -+fmts.add('spreadsheet', 'ots', 'ots', 'ODF Spreadsheet Template', 'calc8_template') ### 14 -+fmts.add('spreadsheet', 'pdf', 'pdf', 'Portable Document Format', 'calc_pdf_Export') ### 34 -+fmts.add('spreadsheet', 'pxl', 'pxl', 'Pocket Excel', 'Pocket Excel') -+fmts.add('spreadsheet', 'sdc', 'sdc', 'StarCalc 5.0', 'StarCalc 5.0') ### 31 -+fmts.add('spreadsheet', 'sdc4', 'sdc', 'StarCalc 4.0', 'StarCalc 4.0') ### 11 -+fmts.add('spreadsheet', 'sdc3', 'sdc', 'StarCalc 3.0', 'StarCalc 3.0') ### 29 -+fmts.add('spreadsheet', 'slk', 'slk', 'SYLK', 'SYLK') ### 35 -+fmts.add('spreadsheet', 'stc', 'stc', 'OpenOffice.org 1.0 Spreadsheet Template', 'calc_StarOffice_XML_Calc_Template') ### 2 -+fmts.add('spreadsheet', 'sxc', 'sxc', 'OpenOffice.org 1.0 Spreadsheet', 'StarOffice XML (Calc)') ### 3 -+fmts.add('spreadsheet', 'uos', 'uos', 'Unified Office Format spreadsheet', 'UOF spreadsheet') ### 9 -+fmts.add('spreadsheet', 'vor3', 'vor', 'StarCalc 3.0 Template', 'StarCalc 3.0 Vorlage/Template') ### 18 -+fmts.add('spreadsheet', 'vor4', 'vor', 'StarCalc 4.0 Template', 'StarCalc 4.0 Vorlage/Template') ### 19 -+fmts.add('spreadsheet', 'vor', 'vor', 'StarCalc 5.0 Template', 'StarCalc 5.0 Vorlage/Template') ### 20 -+fmts.add('spreadsheet', 'xhtml', 'xhtml', 'XHTML', 'XHTML Calc File') ### 26 -+fmts.add('spreadsheet', 'xls', 'xls', 'Microsoft Excel 97/2000/XP', 'MS Excel 97') ### 12 -+fmts.add('spreadsheet', 'xls5', 'xls', 'Microsoft Excel 5.0', 'MS Excel 5.0/95') ### 8 -+fmts.add('spreadsheet', 'xls95', 'xls', 'Microsoft Excel 95', 'MS Excel 95') ### 10 -+fmts.add('spreadsheet', 'xlt', 'xlt', 'Microsoft Excel 97/2000/XP Template', 'MS Excel 97 Vorlage/Template') ### 6 -+fmts.add('spreadsheet', 'xlt5', 'xlt', 'Microsoft Excel 5.0 Template', 'MS Excel 5.0/95 Vorlage/Template') ### 28 -+fmts.add('spreadsheet', 'xlt95', 'xlt', 'Microsoft Excel 95 Template', 'MS Excel 95 Vorlage/Template') ### 21 -+ -+### Graphics -+fmts.add('graphics', 'bmp', 'bmp', 'Windows Bitmap', 'draw_bmp_Export') ### 21 -+fmts.add('graphics', 'emf', 'emf', 'Enhanced Metafile', 'draw_emf_Export') ### 15 -+fmts.add('graphics', 'eps', 'eps', 'Encapsulated PostScript', 'draw_eps_Export') ### 48 -+fmts.add('graphics', 'fodg', 'fodg', 'OpenDocument Drawing (Flat XML)', 'OpenDocument Drawing Flat XML') -+fmts.add('graphics', 'gif', 'gif', 'Graphics Interchange Format', 'draw_gif_Export') ### 30 -+fmts.add('graphics', 'html', 'html', 'HTML Document (OpenOffice.org Draw)', 'draw_html_Export') ### 37 -+fmts.add('graphics', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'draw_jpg_Export') ### 3 -+fmts.add('graphics', 'met', 'met', 'OS/2 Metafile', 'draw_met_Export') ### 43 -+fmts.add('graphics', 'odd', 'odd', 'OpenDocument Drawing', 'draw8') ### 6 -+fmts.add('graphics', 'otg', 'otg', 'OpenDocument Drawing Template', 'draw8_template') ### 20 -+fmts.add('graphics', 'pbm', 'pbm', 'Portable Bitmap', 'draw_pbm_Export') ### 14 -+fmts.add('graphics', 'pct', 'pct', 'Mac Pict', 'draw_pct_Export') ### 41 -+fmts.add('graphics', 'pdf', 'pdf', 'Portable Document Format', 'draw_pdf_Export') ### 28 -+fmts.add('graphics', 'pgm', 'pgm', 'Portable Graymap', 'draw_pgm_Export') ### 11 -+fmts.add('graphics', 'png', 'png', 'Portable Network Graphic', 'draw_png_Export') ### 2 -+fmts.add('graphics', 'ppm', 'ppm', 'Portable Pixelmap', 'draw_ppm_Export') ### 5 -+fmts.add('graphics', 'ras', 'ras', 'Sun Raster Image', 'draw_ras_Export') ## 31 -+fmts.add('graphics', 'std', 'std', 'OpenOffice.org 1.0 Drawing Template', 'draw_StarOffice_XML_Draw_Template') ### 53 -+fmts.add('graphics', 'svg', 'svg', 'Scalable Vector Graphics', 'draw_svg_Export') ### 50 -+fmts.add('graphics', 'svm', 'svm', 'StarView Metafile', 'draw_svm_Export') ### 55 -+fmts.add('graphics', 'swf', 'swf', 'Macromedia Flash (SWF)', 'draw_flash_Export') ### 23 -+fmts.add('graphics', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing', 'StarOffice XML (Draw)') ### 26 -+fmts.add('graphics', 'sxd3', 'sxd', 'StarDraw 3.0', 'StarDraw 3.0') ### 40 -+fmts.add('graphics', 'sxd5', 'sxd', 'StarDraw 5.0', 'StarDraw 5.0') ### 44 -+fmts.add('graphics', 'sxw', 'sxw', 'StarOffice XML (Draw)', 'StarOffice XML (Draw)') -+fmts.add('graphics', 'tiff', 'tiff', 'Tagged Image File Format', 'draw_tif_Export') ### 13 -+fmts.add('graphics', 'vor', 'vor', 'StarDraw 5.0 Template', 'StarDraw 5.0 Vorlage') ### 36 -+fmts.add('graphics', 'vor3', 'vor', 'StarDraw 3.0 Template', 'StarDraw 3.0 Vorlage') ### 35 -+fmts.add('graphics', 'wmf', 'wmf', 'Windows Metafile', 'draw_wmf_Export') ### 8 -+fmts.add('graphics', 'xhtml', 'xhtml', 'XHTML', 'XHTML Draw File') ### 45 -+fmts.add('graphics', 'xpm', 'xpm', 'X PixMap', 'draw_xpm_Export') ### 19 -+ -+### Presentation -+fmts.add('presentation', 'bmp', 'bmp', 'Windows Bitmap', 'impress_bmp_Export') ### 15 -+fmts.add('presentation', 'emf', 'emf', 'Enhanced Metafile', 'impress_emf_Export') ### 16 -+fmts.add('presentation', 'eps', 'eps', 'Encapsulated PostScript', 'impress_eps_Export') ### 17 -+fmts.add('presentation', 'fodp', 'fodp', 'OpenDocument Presentation (Flat XML)', 'OpenDocument Presentation Flat XML') -+fmts.add('presentation', 'gif', 'gif', 'Graphics Interchange Format', 'impress_gif_Export') ### 18 -+fmts.add('presentation', 'html', 'html', 'HTML Document (OpenOffice.org Impress)', 'impress_html_Export') ### 43 -+fmts.add('presentation', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'impress_jpg_Export') ### 19 -+fmts.add('presentation', 'met', 'met', 'OS/2 Metafile', 'impress_met_Export') ### 20 -+fmts.add('presentation', 'odg', 'odg', 'ODF Drawing (Impress)', 'impress8_draw') ### 29 -+fmts.add('presentation', 'odp', 'odp', 'ODF Presentation', 'impress8') ### 9 -+fmts.add('presentation', 'otp', 'otp', 'ODF Presentation Template', 'impress8_template') ### 38 -+fmts.add('presentation', 'pbm', 'pbm', 'Portable Bitmap', 'impress_pbm_Export') ### 21 -+fmts.add('presentation', 'pct', 'pct', 'Mac Pict', 'impress_pct_Export') ### 22 -+fmts.add('presentation', 'pdf', 'pdf', 'Portable Document Format', 'impress_pdf_Export') ### 23 -+fmts.add('presentation', 'pgm', 'pgm', 'Portable Graymap', 'impress_pgm_Export') ### 24 -+fmts.add('presentation', 'png', 'png', 'Portable Network Graphic', 'impress_png_Export') ### 25 -+fmts.add('presentation', 'potm', 'potm', 'Microsoft PowerPoint 2007/2010 XML Template', 'Impress MS PowerPoint 2007 XML Template') -+fmts.add('presentation', 'pot', 'pot', 'Microsoft PowerPoint 97/2000/XP Template', 'MS PowerPoint 97 Vorlage') ### 3 -+fmts.add('presentation', 'ppm', 'ppm', 'Portable Pixelmap', 'impress_ppm_Export') ### 26 -+fmts.add('presentation', 'pptx', 'pptx', 'Microsoft PowerPoint 2007/2010 XML', 'Impress MS PowerPoint 2007 XML') ### 36 -+fmts.add('presentation', 'pps', 'pps', 'Microsoft PowerPoint 97/2000/XP (Autoplay)', 'MS PowerPoint 97 Autoplay') ### 36 -+fmts.add('presentation', 'ppt', 'ppt', 'Microsoft PowerPoint 97/2000/XP', 'MS PowerPoint 97') ### 36 -+fmts.add('presentation', 'pwp', 'pwp', 'PlaceWare', 'placeware_Export') ### 30 -+fmts.add('presentation', 'ras', 'ras', 'Sun Raster Image', 'impress_ras_Export') ### 27 -+fmts.add('presentation', 'sda', 'sda', 'StarDraw 5.0 (OpenOffice.org Impress)', 'StarDraw 5.0 (StarImpress)') ### 8 -+fmts.add('presentation', 'sdd', 'sdd', 'StarImpress 5.0', 'StarImpress 5.0') ### 6 -+fmts.add('presentation', 'sdd3', 'sdd', 'StarDraw 3.0 (OpenOffice.org Impress)', 'StarDraw 3.0 (StarImpress)') ### 42 -+fmts.add('presentation', 'sdd4', 'sdd', 'StarImpress 4.0', 'StarImpress 4.0') ### 37 -+fmts.add('presentation', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing (OpenOffice.org Impress)', 'impress_StarOffice_XML_Draw') ### 31 -+fmts.add('presentation', 'sti', 'sti', 'OpenOffice.org 1.0 Presentation Template', 'impress_StarOffice_XML_Impress_Template') ### 5 -+fmts.add('presentation', 'svg', 'svg', 'Scalable Vector Graphics', 'impress_svg_Export') ### 14 -+fmts.add('presentation', 'svm', 'svm', 'StarView Metafile', 'impress_svm_Export') ### 13 -+fmts.add('presentation', 'swf', 'swf', 'Macromedia Flash (SWF)', 'impress_flash_Export') ### 34 -+fmts.add('presentation', 'sxi', 'sxi', 'OpenOffice.org 1.0 Presentation', 'StarOffice XML (Impress)') ### 41 -+fmts.add('presentation', 'tiff', 'tiff', 'Tagged Image File Format', 'impress_tif_Export') ### 12 -+fmts.add('presentation', 'uop', 'uop', 'Unified Office Format presentation', 'UOF presentation') ### 4 -+fmts.add('presentation', 'vor', 'vor', 'StarImpress 5.0 Template', 'StarImpress 5.0 Vorlage') ### 40 -+fmts.add('presentation', 'vor3', 'vor', 'StarDraw 3.0 Template (OpenOffice.org Impress)', 'StarDraw 3.0 Vorlage (StarImpress)') ###1 -+fmts.add('presentation', 'vor4', 'vor', 'StarImpress 4.0 Template', 'StarImpress 4.0 Vorlage') ### 39 -+fmts.add('presentation', 'vor5', 'vor', 'StarDraw 5.0 Template (OpenOffice.org Impress)', 'StarDraw 5.0 Vorlage (StarImpress)') ### 2 -+fmts.add('presentation', 'wmf', 'wmf', 'Windows Metafile', 'impress_wmf_Export') ### 11 -+fmts.add('presentation', 'xhtml', 'xml', 'XHTML', 'XHTML Impress File') ### 33 -+fmts.add('presentation', 'xpm', 'xpm', 'X PixMap', 'impress_xpm_Export') ### 10 -+ -+class Options: -+ def __init__(self, args): -+ self.connection = None -+ self.debug = False -+ self.doctype = None -+ self.exportfilter = [] -+ self.exportfilteroptions = "" -+ self.filenames = [] -+ self.format = None -+ self.importfilter = [] -+ self.importfilteroptions = "" -+ self.listener = False -+ self.nolaunch = False -+ self.output = None -+ self.password = None -+ self.pipe = None -+ self.port = '2002' -+ self.server = '127.0.0.1' -+ self.showlist = False -+ self.stdout = False -+ self.template = None -+ self.timeout = 6 -+ self.verbose = 0 -+ -+ ### Get options from the commandline -+ try: -+ opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:vV', -+ ['connection=', 'debug', 'doctype=', 'export=', 'format=', -+ 'help', 'import', 'listener', 'no-launch', 'output=', -+ 'outputpath', 'password=', 'pipe=', 'port=', 'server=', -+ 'timeout=', 'show', 'stdout', 'template', 'verbose', -+ 'version'] ) -+ except getopt.error, exc: -+ print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc) -+ sys.exit(255) -+ -+ for opt, arg in opts: -+ if opt in ['-h', '--help']: -+ self.usage() -+ print -+ self.help() -+ sys.exit(1) -+ elif opt in ['-c', '--connection']: -+ self.connection = arg -+ elif opt in ['--debug']: -+ self.debug = True -+ elif opt in ['-d', '--doctype']: -+ self.doctype = arg -+ elif opt in ['-e', '--export']: -+ l = arg.split('=') -+ if len(l) == 2: -+ (name, value) = l -+ if name in ('FilterOptions'): -+ self.exportfilteroptions = value -+ elif value in ('True', 'true'): -+ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) -+ elif value in ('False', 'false'): -+ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) -+ else: -+ try: -+ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) -+ except ValueError: -+ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) -+ else: -+ print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg -+ elif opt in ['-f', '--format']: -+ self.format = arg -+ elif opt in ['-i', '--import']: -+ l = arg.split('=') -+ if len(l) == 2: -+ (name, value) = l -+ if name in ('FilterOptions'): -+ self.importfilteroptions = value -+ elif value in ('True', 'true'): -+ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) -+ elif value in ('False', 'false'): -+ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) -+ else: -+ try: -+ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) -+ except ValueError: -+ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) -+ else: -+ print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg -+ elif opt in ['-l', '--listener']: -+ self.listener = True -+ elif opt in ['-n', '--no-launch']: -+ self.nolaunch = True -+ elif opt in ['-o', '--output']: -+ self.output = arg -+ elif opt in ['--outputpath']: -+ print >>sys.stderr, 'Warning: This option is deprecated by --output.' -+ self.output = arg -+ elif opt in ['--password']: -+ self.password = arg -+ elif opt in ['--pipe']: -+ self.pipe = arg -+ elif opt in ['-p', '--port']: -+ self.port = arg -+ elif opt in ['-s', '--server']: -+ self.server = arg -+ elif opt in ['--show']: -+ self.showlist = True -+ elif opt in ['--stdout']: -+ self.stdout = True -+ elif opt in ['-t', '--template']: -+ self.template = arg -+ elif opt in ['-T', '--timeout']: -+ self.timeout = int(arg) -+ elif opt in ['-v', '--verbose']: -+ self.verbose = self.verbose + 1 -+ elif opt in ['-V', '--version']: -+ self.version() -+ sys.exit(255) -+ -+ ### Enable verbosity -+ if self.verbose >= 2: -+ print >>sys.stderr, 'Verbosity set to level %d' % self.verbose -+ -+ self.filenames = args -+ -+ if not self.listener and not self.showlist and self.doctype != 'list' and not self.filenames: -+ print >>sys.stderr, 'unoconv: you have to provide a filename as argument' -+ print >>sys.stderr, 'Try `unoconv -h\' for more information.' -+ sys.exit(255) -+ -+ ### Set connection string -+ if not self.connection: -+ if not self.pipe: -+ self.connection = "socket,host=%s,port=%s;urp;StarOffice.ComponentContext" % (self.server, self.port) -+# self.connection = "socket,host=%s,port=%s;urp;" % (self.server, self.port) -+ else: -+ self.connection = "pipe,name=%s;urp;StarOffice.ComponentContext" % (self.pipe) -+ -+ ### Make it easier for people to use a doctype (first letter is enough) -+ if self.doctype: -+ for doctype in doctypes: -+ if doctype.startswith(self.doctype): -+ self.doctype = doctype -+ -+ ### Check if the user request to see the list of formats -+ if self.showlist or self.format == 'list': -+ if self.doctype: -+ fmts.display(self.doctype) -+ else: -+ for t in doctypes: -+ fmts.display(t) -+ sys.exit(0) -+ -+ ### If no format was specified, probe it or provide it -+ if not self.format: -+ l = sys.argv[0].split('2') -+ if len(l) == 2: -+ self.format = l[1] -+ else: -+ self.format = 'pdf' -+ -+ def version(self): -+ ### Get office product information -+ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) -+ -+ print 'unoconv %s' % VERSION -+ print 'Written by Dag Wieers ' -+ print 'Homepage at http://dag.wieers.com/home-made/unoconv/' -+ print -+ print 'platform %s/%s' % (os.name, sys.platform) -+ print 'python %s' % sys.version -+ print product.ooName, product.ooSetupVersion -+# print -+# print 'build revision $Rev$' -+ -+ def usage(self): -+ print >>sys.stderr, 'usage: unoconv [options] file [file2 ..]' -+ -+ def help(self): -+ print >>sys.stderr, '''Convert from and to any format supported by LibreOffice -+ -+unoconv options: -+ -c, --connection=string use a custom connection string -+ -d, --doctype=type specify document type -+ (document, graphics, presentation, spreadsheet) -+ -e, --export=name=value set export filter options -+ eg. -e PageRange=1-2 -+ -f, --format=format specify the output format -+ -i, --import=string set import filter option string -+ eg. -i utf8 -+ -l, --listener start a permanent listener to use by unoconv clients -+ -n, --no-launch fail if no listener is found (default: launch one) -+ -o, --output=name output basename, filename or directory -+ --pipe=name alternative method of connection using a pipe -+ -p, --port=port specify the port (default: 2002) -+ to be used by client or listener -+ --password=string provide a password to decrypt the document -+ -s, --server=server specify the server address (default: 127.0.0.1) -+ to be used by client or listener -+ --show list the available output formats -+ --stdout write output to stdout -+ -t, --template=file import the styles from template (.ott) -+ -T, --timeout=secs timeout after secs if connection to listener fails -+ -v, --verbose be more and more verbose (-vvv for debugging) -+''' -+ -+class Convertor: -+ def __init__(self): -+ global exitcode, ooproc, office, product -+ unocontext = None -+ -+ ### Do the LibreOffice component dance -+ self.context = global_uno.getComponentContext() -+ self.svcmgr = self.context.ServiceManager -+ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) -+ -+ ### Test for an existing connection -+ info(3, 'Connection type: %s' % op.connection) -+ try: -+ unocontext = resolver.resolve("uno:%s" % op.connection) -+ except UnoNoConnectException, e: -+# info(3, "Existing listener not found.\n%s" % e) -+ info(3, "Existing listener not found.") -+ -+ if op.nolaunch: -+ die(113, "Existing listener not found. Unable start listener by parameters. Aborting.") -+ -+ ### Start our own OpenOffice instance -+ info(3, "Launching our own listener using %s." % office.binary) -+ try: -+ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) -+ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): -+ ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) -+ else: -+ ooproc = subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--accept=%s" % op.connection], env=os.environ) -+ info(2, '%s listener successfully started. (pid=%s)' % (product.ooName, ooproc.pid)) -+ -+ ### Try connection to it for op.timeout seconds (flakky OpenOffice) -+ timeout = 0 -+ while timeout <= op.timeout: -+ ### Is it already/still running ? -+ retcode = ooproc.poll() -+ if retcode != None: -+ info(3, "Process %s (pid=%s) exited with %s." % (office.binary, ooproc.pid, retcode)) -+ break -+ try: -+ unocontext = resolver.resolve("uno:%s" % op.connection) -+ break -+ except UnoNoConnectException: -+ time.sleep(0.5) -+ timeout += 0.5 -+ except: -+ raise -+ else: -+ error("Failed to connect to %s (pid=%s) in %d seconds.\n%s" % (office.binary, ooproc.pid, op.timeout, e)) -+ except Exception, e: -+ raise -+ error("Launch of %s failed.\n%s" % (office.binary, e)) -+ -+ if not unocontext: -+ die(251, "Unable to connect or start own listener. Aborting.") -+ -+ ### And some more LibreOffice magic -+ unosvcmgr = unocontext.ServiceManager -+ self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) -+ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() ) -+ -+ ### List all filters -+# self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) -+# for filter in self.filters.getElementNames(): -+# print filter -+# #print dir(filter), dir(filter.format) -+ -+ def getformat(self, inputfn): -+ doctype = None -+ -+ ### Get the output format from mapping -+ if op.doctype: -+ outputfmt = fmts.bydoctype(op.doctype, op.format) -+ else: -+ outputfmt = fmts.byname(op.format) -+ -+ if not outputfmt: -+ outputfmt = fmts.byextension(os.extsep + op.format) -+ -+ ### If no doctype given, check list of acceptable formats for input file ext doctype -+ ### FIXME: This should go into the for-loop to match each individual input filename -+ if outputfmt: -+ inputext = os.path.splitext(inputfn)[1] -+ inputfmt = fmts.byextension(inputext) -+ if inputfmt: -+ for fmt in outputfmt: -+ if inputfmt[0].doctype == fmt.doctype: -+ doctype = inputfmt[0].doctype -+ outputfmt = fmt -+ break -+ else: -+ outputfmt = outputfmt[0] -+ # print >>sys.stderr, 'unoconv: format `%s\' is part of multiple doctypes %s, selecting `%s\'.' % (format, [fmt.doctype for fmt in outputfmt], outputfmt[0].doctype) -+ else: -+ outputfmt = outputfmt[0] -+ -+ ### No format found, throw error -+ if not outputfmt: -+ if doctype: -+ print >>sys.stderr, 'unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format) -+ else: -+ print >>sys.stderr, 'unoconv: format [%s] is not known to unoconv.' % op.format -+ die(1) -+ -+ return outputfmt -+ -+ def convert(self, inputfn): -+ global exitcode -+ -+ document = None -+ outputfmt = self.getformat(inputfn) -+ -+ if op.verbose > 0: -+ print >>sys.stderr, 'Input file:', inputfn -+ -+ if not os.path.exists(inputfn): -+ print >>sys.stderr, 'unoconv: file `%s\' does not exist.' % inputfn -+ exitcode = 1 -+ -+ try: -+ ### Import phase -+ phase = "import" -+ -+ ### Load inputfile -+ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE) -+ -+# if op.password: -+# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") -+# inputprops += GlobalUnoProps(ModifyPasswordInfo=info) -+ -+ ### Cannot use GlobalUnoProps for FilterData property -+ if op.importfilteroptions: -+# print "Import filter options: %s" % op.importfilteroptions -+ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions) -+ -+ ### Cannot use GlobalUnoProps for FilterData property -+ if op.importfilter: -+ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) -+ -+ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn)) -+ document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) -+ -+ if not document: -+ raise UnoException("The document '%s' could not be opened." % inputurl, None) -+ -+ ### Import style template -+ phase = "import-style" -+ if op.template: -+ if os.path.exists(op.template): -+ info(1, "Template file: %s" % op.template) -+ templateprops = GlobalUnoProps(OverwriteStyles=True) -+ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template)) -+ document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) -+ else: -+ print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template -+ exitcode = 1 -+ -+ ### Update document links -+ phase = "update-links" -+ try: -+ document.updateLinks() -+ except AttributeError: -+ # the document doesn't implement the XLinkUpdate interface -+ pass -+ -+ ### Update document indexes -+ phase = "update-indexes" -+ try: -+ document.refresh() -+ indexes = document.getDocumentIndexes() -+ except AttributeError: -+ # the document doesn't implement the XRefreshable and/or -+ # XDocumentIndexesSupplier interfaces -+ pass -+ else: -+ for i in range(0, indexes.getCount()): -+ indexes.getByIndex(i).update() -+ -+ info(1, "Selected output format: %s" % outputfmt) -+ info(2, "Selected office filter: %s" % outputfmt.filter) -+ info(2, "Used doctype: %s" % outputfmt.doctype) -+ -+ ### Export phase -+ phase = "export" -+ -+ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True) -+ -+ ### Set default filter options -+ if op.exportfilteroptions: -+# print "Export filter options: %s" % op.exportfilteroptions -+ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions) -+ else: -+ if outputfmt.filter == 'Text (encoded)': -+ outputprops += GlobalUnoProps(FilterOptions="76,LF") -+ -+ elif outputfmt.filter == 'Text': -+ outputprops += GlobalUnoProps(FilterOptions="76") -+ -+ elif outputfmt.filter == 'Text - txt - csv (StarCalc)': -+ outputprops += GlobalUnoProps(FilterOptions="44,34,76") -+ -+ -+ ### Cannot use GlobalUnoProps for FilterData property -+ if op.exportfilter: -+ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) -+ -+ if not op.stdout: -+ (outputfn, ext) = os.path.splitext(inputfn) -+ if not op.output: -+ outputfn = outputfn + os.extsep + outputfmt.extension -+ elif os.path.isdir(op.output): -+ outputfn = realpath(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension) -+ elif len(op.filenames) > 1: -+ outputfn = op.output + os.extsep + outputfmt.extension -+ else: -+ outputfn = op.output -+ -+ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) ) -+ info(1, "Output file: %s" % outputfn) -+ else: -+ outputurl = "private:stream" -+ -+ try: -+ document.storeToURL(outputurl, tuple(outputprops) ) -+ except UnoIOException, e: -+ raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) -+ -+ phase = "dispose" -+ document.dispose() -+ document.close(True) -+ -+ except SystemError, e: -+ error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) -+ exitcode = 1 -+ -+ except UnoRuntimeException, e: -+ error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) -+ exitcode = 6 -+ -+ except UnoDisposedException, e: -+ error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) -+ exitcode = 7 -+ -+ except UnoIllegalArgumentException, e: -+ error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) -+ exitcode = 8 -+ -+ except UnoIOException, e: -+# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) -+ error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) -+ exitcode = 3 -+ -+ except UnoCannotConvertException, e: -+# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) -+ error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) -+ exitcode = 4 -+ -+ except UnoException, e: -+ if hasattr(e, 'ErrCode'): -+ error("unoconv: UnoException during %s phase in %s (ErrCode %d)" % (phase, repr(e.__class__), e.ErrCode)) -+ exitcode = e.ErrCode -+ pass -+ if hasattr(e, 'Message'): -+ error("unoconv: UnoException during %s phase:\n%s" % (phase, e.Message)) -+ exitcode = 5 -+ else: -+ error("unoconv: UnoException during %s phase in %s" % (phase, repr(e.__class__))) -+ exitcode = 2 -+ pass -+ -+class Listener: -+ def __init__(self): -+ global product -+ -+ info(1, "Start listener on %s:%s" % (op.server, op.port)) -+ self.context = global_uno.getComponentContext() -+ self.svcmgr = self.context.ServiceManager -+ try: -+ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) -+ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) -+ try: -+ unocontext = resolver.resolve("uno:%s" % op.connection) -+ except UnoNoConnectException, e: -+ pass -+ else: -+ info(1, "Existing %s listener found, nothing to do." % product.ooName) -+ return -+ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): -+ subprocess.call([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection], env=os.environ) -+ else: -+ subprocess.call([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection], env=os.environ) -+ except Exception, e: -+ error("Launch of %s failed.\n%s" % (office.binary, e)) -+ else: -+ info(1, "Existing %s listener found, nothing to do." % product.ooName) -+ -+def error(msg): -+ "Output error message" -+ print >>sys.stderr, msg -+ -+def info(level, msg): -+ "Output info message" -+ if 'op' not in globals(): -+ pass -+ elif op.verbose >= 3 and level >= 3: -+ print >>sys.stderr, "DEBUG:", msg -+ elif not op.stdout and level <= op.verbose: -+ print >>sys.stdout, msg -+ elif level <= op.verbose: -+ print >>sys.stderr, msg -+ -+def die(ret, msg=None): -+ "Print optional error and exit with errorcode" -+ global convertor, ooproc, office -+ -+ if msg: -+ error('Error: %s' % msg) -+ -+ ### Did we start our own listener instance ? -+ if not op.listener and ooproc and convertor: -+ -+ ### If there is a GUI now attached to the instance, disable listener -+ if convertor.desktop.getCurrentFrame(): -+ info(2, 'Trying to stop %s GUI listener.' % product.ooName) -+ try: -+ if product.ooName != "LibreOffice" or product.ooSetupVersion <= 3.3: -+ subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection], env=os.environ) -+ else: -+ subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection], env=os.environ) -+ ooproc.wait() -+ info(2, '%s listener successfully disabled.' % product.ooName) -+ except Exception, e: -+ error("Terminate using %s failed.\n%s" % (office.binary, e)) -+ -+ ### If there is no GUI attached to the instance, terminate instance -+ else: -+ info(3, 'Terminating %s instance.' % product.ooName) -+ try: -+ convertor.desktop.terminate() -+ except UnoDisposedException: -+ info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) -+ try: -+ ooproc.terminate() -+ except AttributeError: -+ os.kill(ooproc.pid, 15) -+ info(3, 'Waiting for %s instance to exit.' % product.ooName) -+ ooproc.wait() -+ -+ ### LibreOffice processes may get stuck and we have to kill them -+ ### Is it still running ? -+ if ooproc.poll() == None: -+ info(1, '%s instance still running, please investigate...' % product.ooName) -+ ooproc.wait() -+ info(2, '%s instance unsuccessfully terminated, sending KILL signal.' % product.ooName) -+ try: -+ ooproc.kill() -+ except AttributeError: -+ os.kill(ooproc.pid, 9) -+ info(3, 'Waiting for %s with pid %s to disappear.' % (ooproc.pid, product.ooName)) -+ ooproc.wait() -+ -+ # allow Python GC to garbage collect pyuno object *before* exit call -+ # which avoids random segmentation faults --vpa -+ convertor = None -+ -+ sys.exit(ret) -+ -+def main(): -+ global convertor, exitcode -+ convertor = None -+ -+ try: -+ if op.listener: -+ listener = Listener() -+ -+ if op.filenames: -+ convertor = Convertor() -+ for inputfn in op.filenames: -+ convertor.convert(inputfn) -+ -+ except UnoNoConnectException, e: -+ error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) -+ if op.connection: -+ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) -+ else: -+ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"socket,host=%s,port=%s;urp;\"" % (op.server, op.server, op.port, op.server, op.port)) -+ info(0, "Please start an soffice instance on server '%s' by doing:\n\n soffice -nologo -nodefault -accept=\"socket,host=127.0.0.1,port=%s;urp;\"" % (op.server, op.port)) -+ exitcode = 1 -+# except UnboundLocalError: -+# die(252, "Failed to connect to remote listener.") -+ except OSError: -+ error("Warning: failed to launch Office suite. Aborting.") -+ -+### Main entrance -+def run(): -+ global exitcode -+ exitcode = 0 -+ -+ info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) -+ -+ for of in find_offices(): -+ if of.python != sys.executable and not sys.executable.startswith(of.basepath): -+ python_switch(of) -+ office_environ(of) -+# debug_office() -+ try: -+ global global_uno -+ global global_unohelper -+ -+ import uno as global_uno -+ import unohelper as global_unohelper -+ global office -+ office = of -+ break -+ except: -+# debug_office() -+ print >>sys.stderr, "unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of -+ print >>sys.stderr, "ERROR:", sys.exc_info()[1] -+ print >>sys.stderr -+ else: -+# debug_office() -+ print >>sys.stderr, "unoconv: Cannot find a suitable office installation on your system." -+ print >>sys.stderr, "ERROR: Please locate your office installation and send your feedback to:" -+ print >>sys.stderr, " http://github.com/dagwieers/unoconv/issues" -+ sys.exit(1) -+ -+ ### Now that we have found a working pyuno library, let's import some classes -+ global UnoPropertyValue -+ global UnoNoConnectException -+ global UNO_QUIET_UPDATE -+ global UnoDisposedException -+ global UnoIllegalArgumentException -+ global UnoIOException -+ global UnoXOutputStream -+ global UnoCannotConvertException -+ global UnoException -+ global UnoRuntimeException -+ -+ from com.sun.star.beans import PropertyValue as UnoPropertyValue -+ from com.sun.star.connection import NoConnectException as UnoNoConnectException -+ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE -+ from com.sun.star.lang import DisposedException as UnoDisposedException -+ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException -+ from com.sun.star.io import IOException as UnoIOException -+ from com.sun.star.io import XOutputStream as UnoXOutputStream -+ from com.sun.star.script import CannotConvertException as UnoCannotConvertException -+ from com.sun.star.uno import Exception as UnoException -+ from com.sun.star.uno import RuntimeException as UnoRuntimeException -+ -+ ### And now that we have those classes, build on them -+ class OutputStream( global_unohelper.Base, UnoXOutputStream ): -+ def __init__( self ): -+ self.closed = 0 -+ -+ def closeOutput(self): -+ self.closed = 1 -+ -+ def writeBytes( self, seq ): -+ sys.stdout.write( seq.value ) -+ -+ def flush( self ): -+ pass -+ -+ global GlobalOutputStream -+ GlobalOutputStream = OutputStream -+ -+ def UnoProps(**args): -+ props = [] -+ for key in args: -+ prop = UnoPropertyValue() -+ prop.Name = key -+ prop.Value = args[key] -+ props.append(prop) -+ return tuple(props) -+ -+ global GlobalUnoProps -+ GlobalUnoProps = UnoProps -+ -+ global op -+ op = Options(sys.argv[1:]) -+ -+ info(2, "Using office base path: %s" % office.basepath) -+ info(2, "Using office binary path: %s" % office.unopath) -+ -+ try: -+ main() -+ except KeyboardInterrupt, e: -+ die(6, 'Exiting on user request') -+ die(exitcode) -+ -+if __name__ == '__main__': -+ run() -diff --git a/unoconv3.py b/unoconv3.py -new file mode 100755 -index 0000000..09d88c2 ---- /dev/null -+++ b/unoconv3.py -@@ -0,0 +1,1195 @@ -+#!/usr/bin/python3 -+ -+### This program is free software; you can redistribute it and/or modify -+### it under the terms of the GNU General Public License as published by -+### the Free Software Foundation; version 2 only -+### -+### This program is distributed in the hope that it will be useful, -+### but WITHOUT ANY WARRANTY; without even the implied warranty of -+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+### GNU General Public License for more details. -+### -+### You should have received a copy of the GNU General Public License -+### along with this program; if not, write to the Free Software -+### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+### Copyright 2007-2010 Dag Wieers -+ -+from distutils.version import LooseVersion -+import getopt -+import glob -+import os -+import subprocess -+import sys -+import time -+ -+__version__ = "$Revision$" -+# $Source$ -+ -+VERSION = '0.6' -+ -+doctypes = ('document', 'graphics', 'presentation', 'spreadsheet') -+ -+global convertor, office, ooproc, product -+ooproc = None -+exitcode = 0 -+ -+class Office: -+ def __init__(self, basepath, urepath, unopath, pyuno, binary, python, pythonhome): -+ self.basepath = basepath -+ self.urepath = urepath -+ self.unopath = unopath -+ self.pyuno = pyuno -+ self.binary = binary -+ self.python = python -+ self.pythonhome = pythonhome -+ -+ def __str__(self): -+ return self.basepath -+ -+ def __repr__(self): -+ return self.basepath -+ -+### Implement a path normalizer in order to make unoconv work on MacOS X -+### (on which 'program' is a symlink to 'MacOSX' which seems to break unoconv) -+def realpath(*args): -+ ''' Implement a combination of os.path.join(), os.path.abspath() and -+ os.path.realpath() in order to normalize path constructions ''' -+ ret = '' -+ for arg in args: -+ ret = os.path.join(ret, arg) -+ return os.path.realpath(os.path.abspath(ret)) -+ -+### The first thing we ought to do is find a suitable Office installation -+### with a compatible pyuno library that we can import. -+### -+### See: http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=36370&p=166783 -+ -+def find_offices(): -+ ret = [] -+ extrapaths = [] -+ -+ ### Try using UNO_PATH first (in many incarnations, we'll see what sticks) -+ if 'UNO_PATH' in os.environ: -+ extrapaths += [ os.environ['UNO_PATH'], -+ os.path.dirname(os.environ['UNO_PATH']), -+ os.path.dirname(os.path.dirname(os.environ['UNO_PATH'])) ] -+ -+ else: -+ -+ if os.name in ( 'nt', 'os2' ): -+ if 'PROGRAMFILES' in list(os.environ.keys()): -+ extrapaths += glob.glob(os.environ['PROGRAMFILES']+'\\LibreOffice*') + \ -+ glob.glob(os.environ['PROGRAMFILES']+'\\OpenOffice.org*') -+ -+ if 'PROGRAMFILES(X86)' in list(os.environ.keys()): -+ extrapaths += glob.glob(os.environ['PROGRAMFILES(X86)']+'\\LibreOffice*') + \ -+ glob.glob(os.environ['PROGRAMFILES(X86)']+'\\OpenOffice.org*') -+ -+ elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): -+ extrapaths += [ '/Applications/LibreOffice.app/Contents', -+ '/Applications/NeoOffice.app/Contents', -+ '/Applications/OpenOffice.org.app/Contents' ] -+ -+ else: -+ extrapaths += glob.glob('/usr/lib*/libreoffice*') + \ -+ glob.glob('/usr/lib*/openoffice*') + \ -+ glob.glob('/usr/lib*/ooo*') + \ -+ glob.glob('/opt/libreoffice*') + \ -+ glob.glob('/opt/openoffice*') + \ -+ glob.glob('/opt/ooo*') + \ -+ glob.glob('/usr/local/libreoffice*') + \ -+ glob.glob('/usr/local/openoffice*') + \ -+ glob.glob('/usr/local/ooo*') + \ -+ glob.glob('/usr/local/lib/libreoffice*') -+ -+ ### Find a working set for python UNO bindings -+ for basepath in extrapaths: -+ if os.name in ( 'nt', 'os2' ): -+ officelibraries = ( 'pyuno.pyd', ) -+ officebinaries = ( 'soffice.exe' ,) -+ pythonbinaries = ( 'python.exe', ) -+ pythonhomes = () -+ elif os.name in ( 'mac', ) or sys.platform in ( 'darwin', ): -+ officelibraries = ( 'pyuno.so', 'libpyuno.dylib' ) -+ officebinaries = ( 'soffice.bin', ) -+ pythonbinaries = ( 'python.bin', 'python' ) -+ pythonhomes = ( 'OOoPython.framework/Versions/*/lib/python*', ) -+ else: -+ officelibraries = ( 'pyuno.so', ) -+ officebinaries = ( 'soffice.bin', ) -+ pythonbinaries = ( 'python.bin', 'python', ) -+ pythonhomes = ( 'python-core-*', ) -+ -+ ### Older LibreOffice/OpenOffice and Windows use basis-link/ or basis/ -+ libpath = 'error' -+ for basis in ( 'basis-link', 'basis', '' ): -+ for lib in officelibraries: -+ if os.path.isfile(realpath(basepath, basis, 'program', lib)): -+ libpath = realpath(basepath, basis, 'program') -+ officelibrary = realpath(libpath, lib) -+ info(3, "Found %s in %s" % (lib, libpath)) -+ # Break the inner loop... -+ break -+ # Continue if the inner loop wasn't broken. -+ else: -+ continue -+ # Inner loop was broken, break the outer. -+ break -+ else: -+ continue -+ -+ ### MacOSX have soffice binaries installed in MacOS subdirectory, not program -+ unopath = 'error' -+ for basis in ( 'basis-link', 'basis', '' ): -+ for bin in officebinaries: -+ if os.path.isfile(realpath(basepath, basis, 'program', bin)): -+ unopath = realpath(basepath, basis, 'program') -+ officebinary = realpath(unopath, bin) -+ info(3, "Found %s in %s" % (bin, unopath)) -+ # Break the inner loop... -+ break -+ # Continue if the inner loop wasn't broken. -+ else: -+ continue -+ # Inner loop was broken, break the outer. -+ break -+ else: -+ continue -+ -+ ### Windows does not provide or need a URE/lib directory ? -+ urepath = '' -+ for basis in ( 'basis-link', 'basis', '' ): -+ for ure in ( 'ure-link', 'ure', 'URE', '' ): -+ if os.path.isfile(realpath(basepath, basis, ure, 'lib', 'unorc')): -+ urepath = realpath(basepath, basis, ure) -+ info(3, "Found %s in %s" % ('unorc', realpath(urepath, 'lib'))) -+ # Break the inner loop... -+ break -+ # Continue if the inner loop wasn't broken. -+ else: -+ continue -+ # Inner loop was broken, break the outer. -+ break -+ -+ pythonhome = None -+ for home in pythonhomes: -+ if glob.glob(realpath(libpath, home)): -+ pythonhome = glob.glob(realpath(libpath, home))[0] -+ info(3, "Found %s in %s" % (home, pythonhome)) -+ break -+ -+# if not os.path.isfile(realpath(basepath, program, officebinary)): -+# continue -+# info(3, "Found %s in %s" % (officebinary, realpath(basepath, program))) -+ -+# if not glob.glob(realpath(basepath, basis, program, 'python-core-*')): -+# continue -+ -+ for pythonbinary in pythonbinaries: -+ if os.path.isfile(realpath(unopath, pythonbinary)): -+ info(3, "Found %s in %s" % (pythonbinary, unopath)) -+ ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, -+ realpath(unopath, pythonbinary), pythonhome)) -+ else: -+ info(3, "Considering %s" % basepath) -+ ret.append(Office(basepath, urepath, unopath, officelibrary, officebinary, -+ sys.executable, None)) -+ return ret -+ -+def office_environ(office): -+ ### Set PATH so that crash_report is found -+ os.environ['PATH'] = realpath(office.basepath, 'program') + os.pathsep + os.environ['PATH'] -+ -+ ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: -+ os.environ['UNO_PATH'] = office.unopath -+ -+ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete -+ ### UNO environment -+ if os.name in ( 'nt', 'os2' ): -+ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') -+ else: -+ os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamentalrc') -+ -+ ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: -+ if 'LD_LIBRARY_PATH' in os.environ: -+ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -+ realpath(office.urepath, 'lib') + os.pathsep + \ -+ os.environ['LD_LIBRARY_PATH'] -+ else: -+ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -+ realpath(office.urepath, 'lib') -+ -+ if office.pythonhome: -+ for libpath in ( realpath(office.pythonhome, 'lib'), -+ realpath(office.pythonhome, 'lib', 'lib-dynload'), -+ realpath(office.pythonhome, 'lib', 'lib-tk'), -+ realpath(office.pythonhome, 'lib', 'site-packages'), -+ office.unopath): -+ sys.path.insert(0, libpath) -+ else: -+ ### Still needed for system python using LibreOffice UNO bindings -+ ### Although we prefer to use a system UNO binding in this case -+ sys.path.append(office.unopath) -+ -+def debug_office(): -+ if 'URE_BOOTSTRAP' in os.environ: -+ print('URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'], file=sys.stderr) -+ if 'UNO_PATH' in os.environ: -+ print('UNO_PATH=%s' % os.environ['UNO_PATH'], file=sys.stderr) -+ if 'UNO_TYPES' in os.environ: -+ print('UNO_TYPES=%s' % os.environ['UNO_TYPES'], file=sys.stderr) -+ print('PATH=%s' % os.environ['PATH']) -+ if 'PYTHONHOME' in os.environ: -+ print('PYTHONHOME=%s' % os.environ['PYTHONHOME'], file=sys.stderr) -+ if 'PYTHONPATH' in os.environ: -+ print('PYTHONPATH=%s' % os.environ['PYTHONPATH'], file=sys.stderr) -+ if 'LD_LIBRARY_PATH' in os.environ: -+ print('LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'], file=sys.stderr) -+ -+def python_switch(office): -+ if office.pythonhome: -+ os.environ['PYTHONHOME'] = office.pythonhome -+ os.environ['PYTHONPATH'] = realpath(office.pythonhome, 'lib') + os.pathsep + \ -+ realpath(office.pythonhome, 'lib', 'lib-dynload') + os.pathsep + \ -+ realpath(office.pythonhome, 'lib', 'lib-tk') + os.pathsep + \ -+ realpath(office.pythonhome, 'lib', 'site-packages') + os.pathsep + \ -+ office.unopath -+ -+ os.environ['UNO_PATH'] = office.unopath -+ -+ info(3, "-> Switching from %s to %s" % (sys.executable, office.python)) -+ if os.name in ('nt', 'os2'): -+ ### os.execv is broken on Windows and can't properly parse command line -+ ### arguments and executable name if they contain whitespaces. subprocess -+ ### fixes that behavior. -+ ret = subprocess.call([office.python] + sys.argv[0:]) -+ sys.exit(ret) -+ else: -+ -+ ### Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so: -+ if 'LD_LIBRARY_PATH' in os.environ: -+ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -+ realpath(office.urepath, 'lib') + os.pathsep + \ -+ os.environ['LD_LIBRARY_PATH'] -+ else: -+ os.environ['LD_LIBRARY_PATH'] = office.unopath + os.pathsep + \ -+ realpath(office.urepath, 'lib') -+ -+ try: -+ os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) -+ print((office.python, [office.python, ] + sys.argv[0:], osenviron)) -+ except OSError: -+ ### Mac OS X versions prior to 10.6 do not support execv in -+ ### a process that contains multiple threads. Instead of -+ ### re-executing in the current process, start a new one -+ ### and cause the current process to exit. This isn't -+ ### ideal since the new process is detached from the parent -+ ### terminal and thus cannot easily be killed with ctrl-C, -+ ### but it's better than not being able to autoreload at -+ ### all. -+ ### Unfortunately the errno returned in this case does not -+ ### appear to be consistent, so we can't easily check for -+ ### this error specifically. -+ ret = os.spawnvpe(os.P_WAIT, office.python, [office.python, ] + sys.argv[0:], os.environ) -+ sys.exit(ret) -+ -+class Fmt: -+ def __init__(self, doctype, name, extension, summary, filter): -+ self.doctype = doctype -+ self.name = name -+ self.extension = extension -+ self.summary = summary -+ self.filter = filter -+ -+ def __str__(self): -+ return "%s [.%s]" % (self.summary, self.extension) -+ -+ def __repr__(self): -+ return "%s/%s" % (self.name, self.doctype) -+ -+class FmtList: -+ def __init__(self): -+ self.list = [] -+ -+ def add(self, doctype, name, extension, summary, filter): -+ self.list.append(Fmt(doctype, name, extension, summary, filter)) -+ -+ def byname(self, name): -+ ret = [] -+ for fmt in self.list: -+ if fmt.name == name: -+ ret.append(fmt) -+ return ret -+ -+ def byextension(self, extension): -+ ret = [] -+ for fmt in self.list: -+ if os.extsep + fmt.extension == extension: -+ ret.append(fmt) -+ return ret -+ -+ def bydoctype(self, doctype, name): -+ ret = [] -+ for fmt in self.list: -+ if fmt.name == name and fmt.doctype == doctype: -+ ret.append(fmt) -+ return ret -+ -+ def display(self, doctype): -+ print("The following list of %s formats are currently available:\n" % doctype, file=sys.stderr) -+ for fmt in self.list: -+ if fmt.doctype == doctype: -+ print(" %-8s - %s" % (fmt.name, fmt), file=sys.stderr) -+ print(file=sys.stderr) -+ -+fmts = FmtList() -+ -+### TextDocument -+fmts.add('document', 'bib', 'bib', 'BibTeX', 'BibTeX_Writer') ### 22 -+fmts.add('document', 'doc', 'doc', 'Microsoft Word 97/2000/XP', 'MS Word 97') ### 29 -+fmts.add('document', 'doc6', 'doc', 'Microsoft Word 6.0', 'MS WinWord 6.0') ### 24 -+fmts.add('document', 'doc95', 'doc', 'Microsoft Word 95', 'MS Word 95') ### 28 -+fmts.add('document', 'docbook', 'xml', 'DocBook', 'DocBook File') ### 39 -+fmts.add('document', 'docx', 'docx', 'Microsoft Office Open XML', 'Office Open XML Text') -+fmts.add('document', 'docx7', 'docx', 'Microsoft Office Open XML', 'MS Word 2007 XML') -+fmts.add('document', 'fodt', 'fodt', 'OpenDocument Text (Flat XML)', 'OpenDocument Text Flat XML') -+fmts.add('document', 'html', 'html', 'HTML Document (OpenOffice.org Writer)', 'HTML (StarWriter)') ### 3 -+fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'LaTeX_Writer') ### 31 -+fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') -+fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 -+fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 -+fmts.add('document', 'ott', 'ott', 'Open Document Text', 'writer8_template') ### 21 -+fmts.add('document', 'pdb', 'pdb', 'AportisDoc (Palm)', 'AportisDoc Palm DB') -+fmts.add('document', 'pdf', 'pdf', 'Portable Document Format', 'writer_pdf_Export') ### 18 -+fmts.add('document', 'psw', 'psw', 'Pocket Word', 'PocketWord File') -+fmts.add('document', 'rtf', 'rtf', 'Rich Text Format', 'Rich Text Format') ### 16 -+fmts.add('document', 'sdw', 'sdw', 'StarWriter 5.0', 'StarWriter 5.0') ### 23 -+fmts.add('document', 'sdw4', 'sdw', 'StarWriter 4.0', 'StarWriter 4.0') ### 2 -+fmts.add('document', 'sdw3', 'sdw', 'StarWriter 3.0', 'StarWriter 3.0') ### 20 -+fmts.add('document', 'stw', 'stw', 'Open Office.org 1.0 Text Document Template', 'writer_StarOffice_XML_Writer_Template') ### 9 -+fmts.add('document', 'sxw', 'sxw', 'Open Office.org 1.0 Text Document', 'StarOffice XML (Writer)') ### 1 -+fmts.add('document', 'text', 'txt', 'Text Encoded', 'Text (encoded)') ### 26 -+fmts.add('document', 'txt', 'txt', 'Text', 'Text') ### 34 -+fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### 27 -+fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 -+fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 -+fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 -+fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 -+ -+### WebDocument -+fmts.add('web', 'etext', 'txt', 'Text Encoded (OpenOffice.org Writer/Web)', 'Text (encoded) (StarWriter/Web)') ### 14 -+fmts.add('web', 'html10', 'html', 'OpenOffice.org 1.0 HTML Template', 'writer_web_StarOffice_XML_Writer_Web_Template') ### 11 -+fmts.add('web', 'html', 'html', 'HTML Document', 'HTML') ### 2 -+fmts.add('web', 'html', 'html', 'HTML Document Template', 'writerweb8_writer_template') ### 13 -+fmts.add('web', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki_Web') ### 9 -+fmts.add('web', 'pdf', 'pdf', 'PDF - Portable Document Format', 'writer_web_pdf_Export') ### 10 -+fmts.add('web', 'sdw3', 'sdw', 'StarWriter 3.0 (OpenOffice.org Writer/Web)', 'StarWriter 3.0 (StarWriter/Web)') ### 3 -+fmts.add('web', 'sdw4', 'sdw', 'StarWriter 4.0 (OpenOffice.org Writer/Web)', 'StarWriter 4.0 (StarWriter/Web)') ### 4 -+fmts.add('web', 'sdw', 'sdw', 'StarWriter 5.0 (OpenOffice.org Writer/Web)', 'StarWriter 5.0 (StarWriter/Web)') ### 5 -+fmts.add('web', 'txt', 'txt', 'OpenOffice.org Text (OpenOffice.org Writer/Web)', 'writerweb8_writer') ### 12 -+fmts.add('web', 'text10', 'txt', 'OpenOffice.org 1.0 Text Document (OpenOffice.org Writer/Web)', 'writer_web_StarOffice_XML_Writer') ### 15 -+fmts.add('web', 'text', 'txt', 'Text (OpenOffice.org Writer/Web)', 'Text (StarWriter/Web)') ### 8 -+fmts.add('web', 'vor4', 'vor', 'StarWriter/Web 4.0 Template', 'StarWriter/Web 4.0 Vorlage/Template') ### 6 -+fmts.add('web', 'vor', 'vor', 'StarWriter/Web 5.0 Template', 'StarWriter/Web 5.0 Vorlage/Template') ### 7 -+ -+### Spreadsheet -+fmts.add('spreadsheet', 'csv', 'csv', 'Text CSV', 'Text - txt - csv (StarCalc)') ### 16 -+fmts.add('spreadsheet', 'dbf', 'dbf', 'dBASE', 'dBase') ### 22 -+fmts.add('spreadsheet', 'dif', 'dif', 'Data Interchange Format', 'DIF') ### 5 -+fmts.add('spreadsheet', 'fods', 'fods', 'OpenDocument Spreadsheet (Flat XML)', 'OpenDocument Spreadsheet Flat XML') -+fmts.add('spreadsheet', 'html', 'html', 'HTML Document (OpenOffice.org Calc)', 'HTML (StarCalc)') ### 7 -+fmts.add('spreadsheet', 'ods', 'ods', 'ODF Spreadsheet', 'calc8') ### 15 -+fmts.add('spreadsheet', 'ooxml', 'xml', 'Microsoft Excel 2003 XML', 'MS Excel 2003 XML') ### 23 -+fmts.add('spreadsheet', 'ots', 'ots', 'ODF Spreadsheet Template', 'calc8_template') ### 14 -+fmts.add('spreadsheet', 'pdf', 'pdf', 'Portable Document Format', 'calc_pdf_Export') ### 34 -+fmts.add('spreadsheet', 'pxl', 'pxl', 'Pocket Excel', 'Pocket Excel') -+fmts.add('spreadsheet', 'sdc', 'sdc', 'StarCalc 5.0', 'StarCalc 5.0') ### 31 -+fmts.add('spreadsheet', 'sdc4', 'sdc', 'StarCalc 4.0', 'StarCalc 4.0') ### 11 -+fmts.add('spreadsheet', 'sdc3', 'sdc', 'StarCalc 3.0', 'StarCalc 3.0') ### 29 -+fmts.add('spreadsheet', 'slk', 'slk', 'SYLK', 'SYLK') ### 35 -+fmts.add('spreadsheet', 'stc', 'stc', 'OpenOffice.org 1.0 Spreadsheet Template', 'calc_StarOffice_XML_Calc_Template') ### 2 -+fmts.add('spreadsheet', 'sxc', 'sxc', 'OpenOffice.org 1.0 Spreadsheet', 'StarOffice XML (Calc)') ### 3 -+fmts.add('spreadsheet', 'uos', 'uos', 'Unified Office Format spreadsheet', 'UOF spreadsheet') ### 9 -+fmts.add('spreadsheet', 'vor3', 'vor', 'StarCalc 3.0 Template', 'StarCalc 3.0 Vorlage/Template') ### 18 -+fmts.add('spreadsheet', 'vor4', 'vor', 'StarCalc 4.0 Template', 'StarCalc 4.0 Vorlage/Template') ### 19 -+fmts.add('spreadsheet', 'vor', 'vor', 'StarCalc 5.0 Template', 'StarCalc 5.0 Vorlage/Template') ### 20 -+fmts.add('spreadsheet', 'xhtml', 'xhtml', 'XHTML', 'XHTML Calc File') ### 26 -+fmts.add('spreadsheet', 'xls', 'xls', 'Microsoft Excel 97/2000/XP', 'MS Excel 97') ### 12 -+fmts.add('spreadsheet', 'xls5', 'xls', 'Microsoft Excel 5.0', 'MS Excel 5.0/95') ### 8 -+fmts.add('spreadsheet', 'xls95', 'xls', 'Microsoft Excel 95', 'MS Excel 95') ### 10 -+fmts.add('spreadsheet', 'xlt', 'xlt', 'Microsoft Excel 97/2000/XP Template', 'MS Excel 97 Vorlage/Template') ### 6 -+fmts.add('spreadsheet', 'xlt5', 'xlt', 'Microsoft Excel 5.0 Template', 'MS Excel 5.0/95 Vorlage/Template') ### 28 -+fmts.add('spreadsheet', 'xlt95', 'xlt', 'Microsoft Excel 95 Template', 'MS Excel 95 Vorlage/Template') ### 21 -+ -+### Graphics -+fmts.add('graphics', 'bmp', 'bmp', 'Windows Bitmap', 'draw_bmp_Export') ### 21 -+fmts.add('graphics', 'emf', 'emf', 'Enhanced Metafile', 'draw_emf_Export') ### 15 -+fmts.add('graphics', 'eps', 'eps', 'Encapsulated PostScript', 'draw_eps_Export') ### 48 -+fmts.add('graphics', 'fodg', 'fodg', 'OpenDocument Drawing (Flat XML)', 'OpenDocument Drawing Flat XML') -+fmts.add('graphics', 'gif', 'gif', 'Graphics Interchange Format', 'draw_gif_Export') ### 30 -+fmts.add('graphics', 'html', 'html', 'HTML Document (OpenOffice.org Draw)', 'draw_html_Export') ### 37 -+fmts.add('graphics', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'draw_jpg_Export') ### 3 -+fmts.add('graphics', 'met', 'met', 'OS/2 Metafile', 'draw_met_Export') ### 43 -+fmts.add('graphics', 'odd', 'odd', 'OpenDocument Drawing', 'draw8') ### 6 -+fmts.add('graphics', 'otg', 'otg', 'OpenDocument Drawing Template', 'draw8_template') ### 20 -+fmts.add('graphics', 'pbm', 'pbm', 'Portable Bitmap', 'draw_pbm_Export') ### 14 -+fmts.add('graphics', 'pct', 'pct', 'Mac Pict', 'draw_pct_Export') ### 41 -+fmts.add('graphics', 'pdf', 'pdf', 'Portable Document Format', 'draw_pdf_Export') ### 28 -+fmts.add('graphics', 'pgm', 'pgm', 'Portable Graymap', 'draw_pgm_Export') ### 11 -+fmts.add('graphics', 'png', 'png', 'Portable Network Graphic', 'draw_png_Export') ### 2 -+fmts.add('graphics', 'ppm', 'ppm', 'Portable Pixelmap', 'draw_ppm_Export') ### 5 -+fmts.add('graphics', 'ras', 'ras', 'Sun Raster Image', 'draw_ras_Export') ## 31 -+fmts.add('graphics', 'std', 'std', 'OpenOffice.org 1.0 Drawing Template', 'draw_StarOffice_XML_Draw_Template') ### 53 -+fmts.add('graphics', 'svg', 'svg', 'Scalable Vector Graphics', 'draw_svg_Export') ### 50 -+fmts.add('graphics', 'svm', 'svm', 'StarView Metafile', 'draw_svm_Export') ### 55 -+fmts.add('graphics', 'swf', 'swf', 'Macromedia Flash (SWF)', 'draw_flash_Export') ### 23 -+fmts.add('graphics', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing', 'StarOffice XML (Draw)') ### 26 -+fmts.add('graphics', 'sxd3', 'sxd', 'StarDraw 3.0', 'StarDraw 3.0') ### 40 -+fmts.add('graphics', 'sxd5', 'sxd', 'StarDraw 5.0', 'StarDraw 5.0') ### 44 -+fmts.add('graphics', 'sxw', 'sxw', 'StarOffice XML (Draw)', 'StarOffice XML (Draw)') -+fmts.add('graphics', 'tiff', 'tiff', 'Tagged Image File Format', 'draw_tif_Export') ### 13 -+fmts.add('graphics', 'vor', 'vor', 'StarDraw 5.0 Template', 'StarDraw 5.0 Vorlage') ### 36 -+fmts.add('graphics', 'vor3', 'vor', 'StarDraw 3.0 Template', 'StarDraw 3.0 Vorlage') ### 35 -+fmts.add('graphics', 'wmf', 'wmf', 'Windows Metafile', 'draw_wmf_Export') ### 8 -+fmts.add('graphics', 'xhtml', 'xhtml', 'XHTML', 'XHTML Draw File') ### 45 -+fmts.add('graphics', 'xpm', 'xpm', 'X PixMap', 'draw_xpm_Export') ### 19 -+ -+### Presentation -+fmts.add('presentation', 'bmp', 'bmp', 'Windows Bitmap', 'impress_bmp_Export') ### 15 -+fmts.add('presentation', 'emf', 'emf', 'Enhanced Metafile', 'impress_emf_Export') ### 16 -+fmts.add('presentation', 'eps', 'eps', 'Encapsulated PostScript', 'impress_eps_Export') ### 17 -+fmts.add('presentation', 'fodp', 'fodp', 'OpenDocument Presentation (Flat XML)', 'OpenDocument Presentation Flat XML') -+fmts.add('presentation', 'gif', 'gif', 'Graphics Interchange Format', 'impress_gif_Export') ### 18 -+fmts.add('presentation', 'html', 'html', 'HTML Document (OpenOffice.org Impress)', 'impress_html_Export') ### 43 -+fmts.add('presentation', 'jpg', 'jpg', 'Joint Photographic Experts Group', 'impress_jpg_Export') ### 19 -+fmts.add('presentation', 'met', 'met', 'OS/2 Metafile', 'impress_met_Export') ### 20 -+fmts.add('presentation', 'odg', 'odg', 'ODF Drawing (Impress)', 'impress8_draw') ### 29 -+fmts.add('presentation', 'odp', 'odp', 'ODF Presentation', 'impress8') ### 9 -+fmts.add('presentation', 'otp', 'otp', 'ODF Presentation Template', 'impress8_template') ### 38 -+fmts.add('presentation', 'pbm', 'pbm', 'Portable Bitmap', 'impress_pbm_Export') ### 21 -+fmts.add('presentation', 'pct', 'pct', 'Mac Pict', 'impress_pct_Export') ### 22 -+fmts.add('presentation', 'pdf', 'pdf', 'Portable Document Format', 'impress_pdf_Export') ### 23 -+fmts.add('presentation', 'pgm', 'pgm', 'Portable Graymap', 'impress_pgm_Export') ### 24 -+fmts.add('presentation', 'png', 'png', 'Portable Network Graphic', 'impress_png_Export') ### 25 -+fmts.add('presentation', 'potm', 'potm', 'Microsoft PowerPoint 2007/2010 XML Template', 'Impress MS PowerPoint 2007 XML Template') -+fmts.add('presentation', 'pot', 'pot', 'Microsoft PowerPoint 97/2000/XP Template', 'MS PowerPoint 97 Vorlage') ### 3 -+fmts.add('presentation', 'ppm', 'ppm', 'Portable Pixelmap', 'impress_ppm_Export') ### 26 -+fmts.add('presentation', 'pptx', 'pptx', 'Microsoft PowerPoint 2007/2010 XML', 'Impress MS PowerPoint 2007 XML') ### 36 -+fmts.add('presentation', 'pps', 'pps', 'Microsoft PowerPoint 97/2000/XP (Autoplay)', 'MS PowerPoint 97 Autoplay') ### 36 -+fmts.add('presentation', 'ppt', 'ppt', 'Microsoft PowerPoint 97/2000/XP', 'MS PowerPoint 97') ### 36 -+fmts.add('presentation', 'pwp', 'pwp', 'PlaceWare', 'placeware_Export') ### 30 -+fmts.add('presentation', 'ras', 'ras', 'Sun Raster Image', 'impress_ras_Export') ### 27 -+fmts.add('presentation', 'sda', 'sda', 'StarDraw 5.0 (OpenOffice.org Impress)', 'StarDraw 5.0 (StarImpress)') ### 8 -+fmts.add('presentation', 'sdd', 'sdd', 'StarImpress 5.0', 'StarImpress 5.0') ### 6 -+fmts.add('presentation', 'sdd3', 'sdd', 'StarDraw 3.0 (OpenOffice.org Impress)', 'StarDraw 3.0 (StarImpress)') ### 42 -+fmts.add('presentation', 'sdd4', 'sdd', 'StarImpress 4.0', 'StarImpress 4.0') ### 37 -+fmts.add('presentation', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing (OpenOffice.org Impress)', 'impress_StarOffice_XML_Draw') ### 31 -+fmts.add('presentation', 'sti', 'sti', 'OpenOffice.org 1.0 Presentation Template', 'impress_StarOffice_XML_Impress_Template') ### 5 -+fmts.add('presentation', 'svg', 'svg', 'Scalable Vector Graphics', 'impress_svg_Export') ### 14 -+fmts.add('presentation', 'svm', 'svm', 'StarView Metafile', 'impress_svm_Export') ### 13 -+fmts.add('presentation', 'swf', 'swf', 'Macromedia Flash (SWF)', 'impress_flash_Export') ### 34 -+fmts.add('presentation', 'sxi', 'sxi', 'OpenOffice.org 1.0 Presentation', 'StarOffice XML (Impress)') ### 41 -+fmts.add('presentation', 'tiff', 'tiff', 'Tagged Image File Format', 'impress_tif_Export') ### 12 -+fmts.add('presentation', 'uop', 'uop', 'Unified Office Format presentation', 'UOF presentation') ### 4 -+fmts.add('presentation', 'vor', 'vor', 'StarImpress 5.0 Template', 'StarImpress 5.0 Vorlage') ### 40 -+fmts.add('presentation', 'vor3', 'vor', 'StarDraw 3.0 Template (OpenOffice.org Impress)', 'StarDraw 3.0 Vorlage (StarImpress)') ###1 -+fmts.add('presentation', 'vor4', 'vor', 'StarImpress 4.0 Template', 'StarImpress 4.0 Vorlage') ### 39 -+fmts.add('presentation', 'vor5', 'vor', 'StarDraw 5.0 Template (OpenOffice.org Impress)', 'StarDraw 5.0 Vorlage (StarImpress)') ### 2 -+fmts.add('presentation', 'wmf', 'wmf', 'Windows Metafile', 'impress_wmf_Export') ### 11 -+fmts.add('presentation', 'xhtml', 'xml', 'XHTML', 'XHTML Impress File') ### 33 -+fmts.add('presentation', 'xpm', 'xpm', 'X PixMap', 'impress_xpm_Export') ### 10 -+ -+class Options: -+ def __init__(self, args): -+ self.connection = None -+ self.debug = False -+ self.doctype = None -+ self.exportfilter = [] -+ self.exportfilteroptions = "" -+ self.filenames = [] -+ self.format = None -+ self.importfilter = [] -+ self.importfilteroptions = "" -+ self.listener = False -+ self.nolaunch = False -+ self.output = None -+ self.password = None -+ self.pipe = None -+ self.port = '2002' -+ self.server = '127.0.0.1' -+ self.showlist = False -+ self.stdout = False -+ self.template = None -+ self.timeout = 6 -+ self.verbose = 0 -+ -+ ### Get options from the commandline -+ try: -+ opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:vV', -+ ['connection=', 'debug', 'doctype=', 'export=', 'format=', -+ 'help', 'import', 'listener', 'no-launch', 'output=', -+ 'outputpath', 'password=', 'pipe=', 'port=', 'server=', -+ 'timeout=', 'show', 'stdout', 'template', 'verbose', -+ 'version'] ) -+ except getopt.error as exc: -+ print('unoconv: %s, try unoconv -h for a list of all the options' % str(exc)) -+ sys.exit(255) -+ -+ for opt, arg in opts: -+ if opt in ['-h', '--help']: -+ self.usage() -+ print() -+ self.help() -+ sys.exit(1) -+ elif opt in ['-c', '--connection']: -+ self.connection = arg -+ elif opt in ['--debug']: -+ self.debug = True -+ elif opt in ['-d', '--doctype']: -+ self.doctype = arg -+ elif opt in ['-e', '--export']: -+ l = arg.split('=') -+ if len(l) == 2: -+ (name, value) = l -+ if name in ('FilterOptions'): -+ self.exportfilteroptions = value -+ elif value in ('True', 'true'): -+ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) -+ elif value in ('False', 'false'): -+ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) -+ else: -+ try: -+ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) -+ except ValueError: -+ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) -+ else: -+ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr) -+ elif opt in ['-f', '--format']: -+ self.format = arg -+ elif opt in ['-i', '--import']: -+ l = arg.split('=') -+ if len(l) == 2: -+ (name, value) = l -+ if name in ('FilterOptions'): -+ self.importfilteroptions = value -+ elif value in ('True', 'true'): -+ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) -+ elif value in ('False', 'false'): -+ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) -+ else: -+ try: -+ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) -+ except ValueError: -+ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) -+ else: -+ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr) -+ elif opt in ['-l', '--listener']: -+ self.listener = True -+ elif opt in ['-n', '--no-launch']: -+ self.nolaunch = True -+ elif opt in ['-o', '--output']: -+ self.output = arg -+ elif opt in ['--outputpath']: -+ print('Warning: This option is deprecated by --output.', file=sys.stderr) -+ self.output = arg -+ elif opt in ['--password']: -+ self.password = arg -+ elif opt in ['--pipe']: -+ self.pipe = arg -+ elif opt in ['-p', '--port']: -+ self.port = arg -+ elif opt in ['-s', '--server']: -+ self.server = arg -+ elif opt in ['--show']: -+ self.showlist = True -+ elif opt in ['--stdout']: -+ self.stdout = True -+ elif opt in ['-t', '--template']: -+ self.template = arg -+ elif opt in ['-T', '--timeout']: -+ self.timeout = int(arg) -+ elif opt in ['-v', '--verbose']: -+ self.verbose = self.verbose + 1 -+ elif opt in ['-V', '--version']: -+ self.version() -+ sys.exit(255) -+ -+ ### Enable verbosity -+ if self.verbose >= 2: -+ print('Verbosity set to level %d' % self.verbose, file=sys.stderr) -+ -+ self.filenames = args -+ -+ if not self.listener and not self.showlist and self.doctype != 'list' and not self.filenames: -+ print('unoconv: you have to provide a filename as argument', file=sys.stderr) -+ print('Try `unoconv -h\' for more information.', file=sys.stderr) -+ sys.exit(255) -+ -+ ### Set connection string -+ if not self.connection: -+ if not self.pipe: -+ self.connection = "socket,host=%s,port=%s;urp;StarOffice.ComponentContext" % (self.server, self.port) -+# self.connection = "socket,host=%s,port=%s;urp;" % (self.server, self.port) -+ else: -+ self.connection = "pipe,name=%s;urp;StarOffice.ComponentContext" % (self.pipe) -+ -+ ### Make it easier for people to use a doctype (first letter is enough) -+ if self.doctype: -+ for doctype in doctypes: -+ if doctype.startswith(self.doctype): -+ self.doctype = doctype -+ -+ ### Check if the user request to see the list of formats -+ if self.showlist or self.format == 'list': -+ if self.doctype: -+ fmts.display(self.doctype) -+ else: -+ for t in doctypes: -+ fmts.display(t) -+ sys.exit(0) -+ -+ ### If no format was specified, probe it or provide it -+ if not self.format: -+ l = sys.argv[0].split('2') -+ if len(l) == 2: -+ self.format = l[1] -+ else: -+ self.format = 'pdf' -+ -+ def version(self): -+ ### Get office product information -+ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) -+ -+ print('unoconv %s' % VERSION) -+ print('Written by Dag Wieers ') -+ print('Homepage at http://dag.wieers.com/home-made/unoconv/') -+ print() -+ print('platform %s/%s' % (os.name, sys.platform)) -+ print('python %s' % sys.version) -+ print(product.ooName, product.ooSetupVersion) -+# print -+# print 'build revision $Rev$' -+ -+ def usage(self): -+ print('usage: unoconv [options] file [file2 ..]', file=sys.stderr) -+ -+ def help(self): -+ print('''Convert from and to any format supported by LibreOffice -+ -+unoconv options: -+ -c, --connection=string use a custom connection string -+ -d, --doctype=type specify document type -+ (document, graphics, presentation, spreadsheet) -+ -e, --export=name=value set export filter options -+ eg. -e PageRange=1-2 -+ -f, --format=format specify the output format -+ -i, --import=string set import filter option string -+ eg. -i utf8 -+ -l, --listener start a permanent listener to use by unoconv clients -+ -n, --no-launch fail if no listener is found (default: launch one) -+ -o, --output=name output basename, filename or directory -+ --pipe=name alternative method of connection using a pipe -+ -p, --port=port specify the port (default: 2002) -+ to be used by client or listener -+ --password=string provide a password to decrypt the document -+ -s, --server=server specify the server address (default: 127.0.0.1) -+ to be used by client or listener -+ --show list the available output formats -+ --stdout write output to stdout -+ -t, --template=file import the styles from template (.ott) -+ -T, --timeout=secs timeout after secs if connection to listener fails -+ -v, --verbose be more and more verbose (-vvv for debugging) -+''', file=sys.stderr) -+ -+class Convertor: -+ def __init__(self): -+ global exitcode, ooproc, office, product -+ unocontext = None -+ -+ ### Do the LibreOffice component dance -+ self.context = global_uno.getComponentContext() -+ self.svcmgr = self.context.ServiceManager -+ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) -+ -+ ### Test for an existing connection -+ info(3, 'Connection type: %s' % op.connection) -+ try: -+ unocontext = resolver.resolve("uno:%s" % op.connection) -+ except UnoNoConnectException as e: -+# info(3, "Existing listener not found.\n%s" % e) -+ info(3, "Existing listener not found.") -+ -+ if op.nolaunch: -+ die(113, "Existing listener not found. Unable start listener by parameters. Aborting.") -+ -+ ### Start our own OpenOffice instance -+ info(3, "Launching our own listener using %s." % office.binary) -+ try: -+ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) -+ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): -+ ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) -+ else: -+ ooproc = subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--accept=%s" % op.connection], env=os.environ) -+ info(2, '%s listener successfully started. (pid=%s)' % (product.ooName, ooproc.pid)) -+ -+ ### Try connection to it for op.timeout seconds (flakky OpenOffice) -+ timeout = 0 -+ while timeout <= op.timeout: -+ ### Is it already/still running ? -+ retcode = ooproc.poll() -+ if retcode != None: -+ info(3, "Process %s (pid=%s) exited with %s." % (office.binary, ooproc.pid, retcode)) -+ break -+ try: -+ unocontext = resolver.resolve("uno:%s" % op.connection) -+ break -+ except UnoNoConnectException: -+ time.sleep(0.5) -+ timeout += 0.5 -+ except: -+ raise -+ else: -+ error("Failed to connect to %s (pid=%s) in %d seconds.\n%s" % (office.binary, ooproc.pid, op.timeout, e)) -+ except Exception as e: -+ raise -+ error("Launch of %s failed.\n%s" % (office.binary, e)) -+ -+ if not unocontext: -+ die(251, "Unable to connect or start own listener. Aborting.") -+ -+ ### And some more LibreOffice magic -+ unosvcmgr = unocontext.ServiceManager -+ self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) -+ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() ) -+ -+ ### List all filters -+# self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) -+# for filter in self.filters.getElementNames(): -+# print filter -+# #print dir(filter), dir(filter.format) -+ -+ def getformat(self, inputfn): -+ doctype = None -+ -+ ### Get the output format from mapping -+ if op.doctype: -+ outputfmt = fmts.bydoctype(op.doctype, op.format) -+ else: -+ outputfmt = fmts.byname(op.format) -+ -+ if not outputfmt: -+ outputfmt = fmts.byextension(os.extsep + op.format) -+ -+ ### If no doctype given, check list of acceptable formats for input file ext doctype -+ ### FIXME: This should go into the for-loop to match each individual input filename -+ if outputfmt: -+ inputext = os.path.splitext(inputfn)[1] -+ inputfmt = fmts.byextension(inputext) -+ if inputfmt: -+ for fmt in outputfmt: -+ if inputfmt[0].doctype == fmt.doctype: -+ doctype = inputfmt[0].doctype -+ outputfmt = fmt -+ break -+ else: -+ outputfmt = outputfmt[0] -+ # print >>sys.stderr, 'unoconv: format `%s\' is part of multiple doctypes %s, selecting `%s\'.' % (format, [fmt.doctype for fmt in outputfmt], outputfmt[0].doctype) -+ else: -+ outputfmt = outputfmt[0] -+ -+ ### No format found, throw error -+ if not outputfmt: -+ if doctype: -+ print('unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format), file=sys.stderr) -+ else: -+ print('unoconv: format [%s] is not known to unoconv.' % op.format, file=sys.stderr) -+ die(1) -+ -+ return outputfmt -+ -+ def convert(self, inputfn): -+ global exitcode -+ -+ document = None -+ outputfmt = self.getformat(inputfn) -+ -+ if op.verbose > 0: -+ print('Input file:', inputfn, file=sys.stderr) -+ -+ if not os.path.exists(inputfn): -+ print('unoconv: file `%s\' does not exist.' % inputfn, file=sys.stderr) -+ exitcode = 1 -+ -+ try: -+ ### Import phase -+ phase = "import" -+ -+ ### Load inputfile -+ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE) -+ -+# if op.password: -+# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") -+# inputprops += GlobalUnoProps(ModifyPasswordInfo=info) -+ -+ ### Cannot use GlobalUnoProps for FilterData property -+ if op.importfilteroptions: -+# print "Import filter options: %s" % op.importfilteroptions -+ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions) -+ -+ ### Cannot use GlobalUnoProps for FilterData property -+ if op.importfilter: -+ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) -+ -+ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn)) -+ document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) -+ -+ if not document: -+ raise UnoException("The document '%s' could not be opened." % inputurl, None) -+ -+ ### Import style template -+ phase = "import-style" -+ if op.template: -+ if os.path.exists(op.template): -+ info(1, "Template file: %s" % op.template) -+ templateprops = GlobalUnoProps(OverwriteStyles=True) -+ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template)) -+ document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) -+ else: -+ print('unoconv: template file `%s\' does not exist.' % op.template, file=sys.stderr) -+ exitcode = 1 -+ -+ ### Update document links -+ phase = "update-links" -+ try: -+ document.updateLinks() -+ except AttributeError: -+ # the document doesn't implement the XLinkUpdate interface -+ pass -+ -+ ### Update document indexes -+ phase = "update-indexes" -+ try: -+ document.refresh() -+ indexes = document.getDocumentIndexes() -+ except AttributeError: -+ # the document doesn't implement the XRefreshable and/or -+ # XDocumentIndexesSupplier interfaces -+ pass -+ else: -+ for i in range(0, indexes.getCount()): -+ indexes.getByIndex(i).update() -+ -+ info(1, "Selected output format: %s" % outputfmt) -+ info(2, "Selected office filter: %s" % outputfmt.filter) -+ info(2, "Used doctype: %s" % outputfmt.doctype) -+ -+ ### Export phase -+ phase = "export" -+ -+ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True) -+ -+ ### Set default filter options -+ if op.exportfilteroptions: -+# print "Export filter options: %s" % op.exportfilteroptions -+ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions) -+ else: -+ if outputfmt.filter == 'Text (encoded)': -+ outputprops += GlobalUnoProps(FilterOptions="76,LF") -+ -+ elif outputfmt.filter == 'Text': -+ outputprops += GlobalUnoProps(FilterOptions="76") -+ -+ elif outputfmt.filter == 'Text - txt - csv (StarCalc)': -+ outputprops += GlobalUnoProps(FilterOptions="44,34,76") -+ -+ -+ ### Cannot use GlobalUnoProps for FilterData property -+ if op.exportfilter: -+ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) -+ -+ if not op.stdout: -+ (outputfn, ext) = os.path.splitext(inputfn) -+ if not op.output: -+ outputfn = outputfn + os.extsep + outputfmt.extension -+ elif os.path.isdir(op.output): -+ outputfn = realpath(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension) -+ elif len(op.filenames) > 1: -+ outputfn = op.output + os.extsep + outputfmt.extension -+ else: -+ outputfn = op.output -+ -+ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) ) -+ info(1, "Output file: %s" % outputfn) -+ else: -+ outputurl = "private:stream" -+ -+ try: -+ document.storeToURL(outputurl, tuple(outputprops) ) -+ except UnoIOException as e: -+ raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) -+ -+ phase = "dispose" -+ document.dispose() -+ document.close(True) -+ -+ except SystemError as e: -+ error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) -+ exitcode = 1 -+ -+ except UnoRuntimeException as e: -+ error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) -+ exitcode = 6 -+ -+ except UnoDisposedException as e: -+ error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) -+ exitcode = 7 -+ -+ except UnoIllegalArgumentException as e: -+ error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) -+ exitcode = 8 -+ -+ except UnoIOException as e: -+# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) -+ error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) -+ exitcode = 3 -+ -+ except UnoCannotConvertException as e: -+# for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) -+ error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) -+ exitcode = 4 -+ -+ except UnoException as e: -+ if hasattr(e, 'ErrCode'): -+ error("unoconv: UnoException during %s phase in %s (ErrCode %d)" % (phase, repr(e.__class__), e.ErrCode)) -+ exitcode = e.ErrCode -+ pass -+ if hasattr(e, 'Message'): -+ error("unoconv: UnoException during %s phase:\n%s" % (phase, e.Message)) -+ exitcode = 5 -+ else: -+ error("unoconv: UnoException during %s phase in %s" % (phase, repr(e.__class__))) -+ exitcode = 2 -+ pass -+ -+class Listener: -+ def __init__(self): -+ global product -+ -+ info(1, "Start listener on %s:%s" % (op.server, op.port)) -+ self.context = global_uno.getComponentContext() -+ self.svcmgr = self.context.ServiceManager -+ try: -+ resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) -+ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) -+ try: -+ unocontext = resolver.resolve("uno:%s" % op.connection) -+ except UnoNoConnectException as e: -+ pass -+ else: -+ info(1, "Existing %s listener found, nothing to do." % product.ooName) -+ return -+ if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): -+ subprocess.call([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection], env=os.environ) -+ else: -+ subprocess.call([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection], env=os.environ) -+ except Exception as e: -+ error("Launch of %s failed.\n%s" % (office.binary, e)) -+ else: -+ info(1, "Existing %s listener found, nothing to do." % product.ooName) -+ -+def error(msg): -+ "Output error message" -+ print(msg, file=sys.stderr) -+ -+def info(level, msg): -+ "Output info message" -+ if 'op' not in globals(): -+ pass -+ elif op.verbose >= 3 and level >= 3: -+ print("DEBUG:", msg, file=sys.stderr) -+ elif not op.stdout and level <= op.verbose: -+ print(msg, file=sys.stdout) -+ elif level <= op.verbose: -+ print(msg, file=sys.stderr) -+ -+def die(ret, msg=None): -+ "Print optional error and exit with errorcode" -+ global convertor, ooproc, office -+ -+ if msg: -+ error('Error: %s' % msg) -+ -+ ### Did we start our own listener instance ? -+ if not op.listener and ooproc and convertor: -+ -+ ### If there is a GUI now attached to the instance, disable listener -+ if convertor.desktop.getCurrentFrame(): -+ info(2, 'Trying to stop %s GUI listener.' % product.ooName) -+ try: -+ if product.ooName != "LibreOffice" or product.ooSetupVersion <= 3.3: -+ subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-unaccept=%s" % op.connection], env=os.environ) -+ else: -+ subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection], env=os.environ) -+ ooproc.wait() -+ info(2, '%s listener successfully disabled.' % product.ooName) -+ except Exception as e: -+ error("Terminate using %s failed.\n%s" % (office.binary, e)) -+ -+ ### If there is no GUI attached to the instance, terminate instance -+ else: -+ info(3, 'Terminating %s instance.' % product.ooName) -+ try: -+ convertor.desktop.terminate() -+ except UnoDisposedException: -+ info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) -+ try: -+ ooproc.terminate() -+ except AttributeError: -+ os.kill(ooproc.pid, 15) -+ info(3, 'Waiting for %s instance to exit.' % product.ooName) -+ ooproc.wait() -+ -+ ### LibreOffice processes may get stuck and we have to kill them -+ ### Is it still running ? -+ if ooproc.poll() == None: -+ info(1, '%s instance still running, please investigate...' % product.ooName) -+ ooproc.wait() -+ info(2, '%s instance unsuccessfully terminated, sending KILL signal.' % product.ooName) -+ try: -+ ooproc.kill() -+ except AttributeError: -+ os.kill(ooproc.pid, 9) -+ info(3, 'Waiting for %s with pid %s to disappear.' % (ooproc.pid, product.ooName)) -+ ooproc.wait() -+ -+ # allow Python GC to garbage collect pyuno object *before* exit call -+ # which avoids random segmentation faults --vpa -+ convertor = None -+ -+ sys.exit(ret) -+ -+def main(): -+ global convertor, exitcode -+ convertor = None -+ -+ try: -+ if op.listener: -+ listener = Listener() -+ -+ if op.filenames: -+ convertor = Convertor() -+ for inputfn in op.filenames: -+ convertor.convert(inputfn) -+ -+ except UnoNoConnectException as e: -+ error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) -+ if op.connection: -+ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) -+ else: -+ info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"socket,host=%s,port=%s;urp;\"" % (op.server, op.server, op.port, op.server, op.port)) -+ info(0, "Please start an soffice instance on server '%s' by doing:\n\n soffice -nologo -nodefault -accept=\"socket,host=127.0.0.1,port=%s;urp;\"" % (op.server, op.port)) -+ exitcode = 1 -+# except UnboundLocalError: -+# die(252, "Failed to connect to remote listener.") -+ except OSError: -+ error("Warning: failed to launch Office suite. Aborting.") -+ -+### Main entrance -+def run(): -+ global exitcode -+ exitcode = 0 -+ -+ info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) -+ -+ for of in find_offices(): -+ if of.python != sys.executable and not sys.executable.startswith(of.basepath): -+ python_switch(of) -+ office_environ(of) -+# debug_office() -+ try: -+ global global_uno -+ global global_unohelper -+ -+ import uno as global_uno -+ import unohelper as global_unohelper -+ global office -+ office = of -+ break -+ except: -+# debug_office() -+ print("unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of, file=sys.stderr) -+ print("ERROR:", sys.exc_info()[1], file=sys.stderr) -+ print(file=sys.stderr) -+ else: -+# debug_office() -+ print("unoconv: Cannot find a suitable office installation on your system.", file=sys.stderr) -+ print("ERROR: Please locate your office installation and send your feedback to:", file=sys.stderr) -+ print(" http://github.com/dagwieers/unoconv/issues", file=sys.stderr) -+ sys.exit(1) -+ -+ ### Now that we have found a working pyuno library, let's import some classes -+ global UnoPropertyValue -+ global UnoNoConnectException -+ global UNO_QUIET_UPDATE -+ global UnoDisposedException -+ global UnoIllegalArgumentException -+ global UnoIOException -+ global UnoXOutputStream -+ global UnoCannotConvertException -+ global UnoException -+ global UnoRuntimeException -+ -+ from com.sun.star.beans import PropertyValue as UnoPropertyValue -+ from com.sun.star.connection import NoConnectException as UnoNoConnectException -+ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE -+ from com.sun.star.lang import DisposedException as UnoDisposedException -+ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException -+ from com.sun.star.io import IOException as UnoIOException -+ from com.sun.star.io import XOutputStream as UnoXOutputStream -+ from com.sun.star.script import CannotConvertException as UnoCannotConvertException -+ from com.sun.star.uno import Exception as UnoException -+ from com.sun.star.uno import RuntimeException as UnoRuntimeException -+ -+ ### And now that we have those classes, build on them -+ class OutputStream( global_unohelper.Base, UnoXOutputStream ): -+ def __init__( self ): -+ self.closed = 0 -+ -+ def closeOutput(self): -+ self.closed = 1 -+ -+ def writeBytes( self, seq ): -+ sys.stdout.write( seq.value ) -+ -+ def flush( self ): -+ pass -+ -+ global GlobalOutputStream -+ GlobalOutputStream = OutputStream -+ -+ def UnoProps(**args): -+ props = [] -+ for key in args: -+ prop = UnoPropertyValue() -+ prop.Name = key -+ prop.Value = args[key] -+ props.append(prop) -+ return tuple(props) -+ -+ global GlobalUnoProps -+ GlobalUnoProps = UnoProps -+ -+ global op -+ op = Options(sys.argv[1:]) -+ -+ info(2, "Using office base path: %s" % office.basepath) -+ info(2, "Using office binary path: %s" % office.unopath) -+ -+ try: -+ main() -+ except KeyboardInterrupt as e: -+ die(6, 'Exiting on user request') -+ die(exitcode) -+ -+if __name__ == '__main__': -+ run() --- -1.7.11.7 - diff --git a/0001-update-FSF-address.patch b/0001-update-FSF-address.patch index da5f208..925cf4f 100644 --- a/0001-update-FSF-address.patch +++ b/0001-update-FSF-address.patch @@ -138,34 +138,6 @@ index 30e6706..e4a1ac8 100755 ### along with this program; if not, write to the Free Software -### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+### MA 02110-1301 USA. - - import sys - -diff --git a/unoconv2.py b/unoconv2.py -index 30e6706..e4a1ac8 100755 ---- a/unoconv2.py -+++ b/unoconv2.py -@@ -11,7 +11,8 @@ - ### - ### You should have received a copy of the GNU General Public License - ### along with this program; if not, write to the Free Software --### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+### MA 02110-1301 USA. - ### Copyright 2007-2010 Dag Wieers - - from distutils.version import LooseVersion -diff --git a/unoconv3.py b/unoconv3.py -index 30e6706..e4a1ac8 100755 ---- a/unoconv3.py -+++ b/unoconv3.py -@@ -11,7 +11,8 @@ - ### - ### You should have received a copy of the GNU General Public License - ### along with this program; if not, write to the Free Software --### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +### MA 02110-1301 USA. ### Copyright 2007-2010 Dag Wieers diff --git a/unoconv.spec b/unoconv.spec index 5fe9657..bb314cf 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -7,7 +7,11 @@ Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz Patch0: 0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch -Patch1: 0001-python3-added-compatibility.patch +%if 0%{?rhel} +Patch1: 0001-python3-added-compatibility.2.patch +%else +Patch1: 0001-python3-added-compatibility.3.patch +%endif Patch2: 0001-update-FSF-address.patch Patch3: 0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch @@ -32,16 +36,6 @@ RTF, Docbook (.xml), and more. %install make install DESTDIR="%{buildroot}" -pushd %{buildroot}/%{_bindir} -%if 0%{?fedora} >= 19 - mv %{name}3.py %{name} - rm %{name}2.py -%else - mv %{name}2.py %{name} - rm %{name}3.py -%endif -popd - %files %doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST doc/*.txt tests/ From 354045273a16b08234a38ce8827e9866db5dab61 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Sat, 19 Apr 2014 12:13:05 +0200 Subject: [PATCH 29/71] Resolves: rhbz#1076275 unoconv trips over '-f latex' --- ...-export-usable-with-writer2latex-ext.patch | 34 +++++++++++++++++++ unoconv.spec | 6 +++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch diff --git a/0001-make-LaTeX-export-usable-with-writer2latex-ext.patch b/0001-make-LaTeX-export-usable-with-writer2latex-ext.patch new file mode 100644 index 0000000..07e9947 --- /dev/null +++ b/0001-make-LaTeX-export-usable-with-writer2latex-ext.patch @@ -0,0 +1,34 @@ +From 7b17d0160d9bd940e40c906684646ad7e4024c24 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Sat, 19 Apr 2014 11:18:41 +0200 +Subject: [PATCH 1/2] make LaTeX export usable with writer2latex ext. + +--- + unoconv | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/unoconv b/unoconv +index 30e6706..dd73799 100755 +--- a/unoconv ++++ b/unoconv +@@ -344,7 +344,7 @@ class FmtList: + fmts = FmtList() + + ### TextDocument +-fmts.add('document', 'bib', 'bib', 'BibTeX', 'BibTeX_Writer') ### 22 ++fmts.add('document', 'bib', 'bib', 'BibTeX', 'org.openoffice.da.writer2bibtex') ### 22 + fmts.add('document', 'doc', 'doc', 'Microsoft Word 97/2000/XP', 'MS Word 97') ### 29 + fmts.add('document', 'doc6', 'doc', 'Microsoft Word 6.0', 'MS WinWord 6.0') ### 24 + fmts.add('document', 'doc95', 'doc', 'Microsoft Word 95', 'MS Word 95') ### 28 +@@ -353,7 +353,7 @@ fmts.add('document', 'docx', 'docx', 'Microsoft Office Open XML', 'Office Open X + fmts.add('document', 'docx7', 'docx', 'Microsoft Office Open XML', 'MS Word 2007 XML') + fmts.add('document', 'fodt', 'fodt', 'OpenDocument Text (Flat XML)', 'OpenDocument Text Flat XML') + fmts.add('document', 'html', 'html', 'HTML Document (OpenOffice.org Writer)', 'HTML (StarWriter)') ### 3 +-fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'LaTeX_Writer') ### 31 ++fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'org.openoffice.da.writer2latex') ### 31 + fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') + fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 + fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 +-- +1.9.0 + diff --git a/unoconv.spec b/unoconv.spec index bb314cf..0ff7eaa 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 9%{?dist} +Release: 10%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -14,6 +14,7 @@ Patch1: 0001-python3-added-compatibility.3.patch %endif Patch2: 0001-update-FSF-address.patch Patch3: 0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch +Patch4: 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch BuildArch: noarch Requires: libreoffice-filters @@ -43,6 +44,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sat Apr 19 2014 David Tardon - 0.6-10 +- Resolves: rhbz#1076275 unoconv trips over '-f latex' + * Thu Apr 17 2014 David Tardon - 0.6-9 - Resolves: rhbz#1076275 unonconv trips over '-f latex' From 1ea68ab0583b48bcf016102bef6f6251e87c4906 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Sat, 19 Apr 2014 12:13:53 +0200 Subject: [PATCH 30/71] do not show unusable export formats --- ...xport-formats-dropped-by-LibreOffice.patch | 105 ++++++++++++++++++ unoconv.spec | 2 + 2 files changed, 107 insertions(+) create mode 100644 0002-remove-export-formats-dropped-by-LibreOffice.patch diff --git a/0002-remove-export-formats-dropped-by-LibreOffice.patch b/0002-remove-export-formats-dropped-by-LibreOffice.patch new file mode 100644 index 0000000..f46a52b --- /dev/null +++ b/0002-remove-export-formats-dropped-by-LibreOffice.patch @@ -0,0 +1,105 @@ +From da17429f0deed3999ffeb98fc0f3688c6e413765 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Sat, 19 Apr 2014 11:26:26 +0200 +Subject: [PATCH 2/2] remove export formats dropped by LibreOffice + +--- + unoconv | 32 -------------------------------- + 1 file changed, 32 deletions(-) + +diff --git a/unoconv b/unoconv +index dd73799..a5d29da 100755 +--- a/unoconv ++++ b/unoconv +@@ -358,21 +358,13 @@ fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') + fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 + fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 + fmts.add('document', 'ott', 'ott', 'Open Document Text', 'writer8_template') ### 21 +-fmts.add('document', 'pdb', 'pdb', 'AportisDoc (Palm)', 'AportisDoc Palm DB') + fmts.add('document', 'pdf', 'pdf', 'Portable Document Format', 'writer_pdf_Export') ### 18 +-fmts.add('document', 'psw', 'psw', 'Pocket Word', 'PocketWord File') + fmts.add('document', 'rtf', 'rtf', 'Rich Text Format', 'Rich Text Format') ### 16 +-fmts.add('document', 'sdw', 'sdw', 'StarWriter 5.0', 'StarWriter 5.0') ### 23 +-fmts.add('document', 'sdw4', 'sdw', 'StarWriter 4.0', 'StarWriter 4.0') ### 2 +-fmts.add('document', 'sdw3', 'sdw', 'StarWriter 3.0', 'StarWriter 3.0') ### 20 + fmts.add('document', 'stw', 'stw', 'Open Office.org 1.0 Text Document Template', 'writer_StarOffice_XML_Writer_Template') ### 9 + fmts.add('document', 'sxw', 'sxw', 'Open Office.org 1.0 Text Document', 'StarOffice XML (Writer)') ### 1 + fmts.add('document', 'text', 'txt', 'Text Encoded', 'Text (encoded)') ### 26 + fmts.add('document', 'txt', 'txt', 'Text', 'Text') ### 34 + fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### 27 +-fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 +-fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 +-fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 + fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 + + ### WebDocument +@@ -382,14 +374,9 @@ fmts.add('web', 'html', 'html', 'HTML Document', 'HTML') ### 2 + fmts.add('web', 'html', 'html', 'HTML Document Template', 'writerweb8_writer_template') ### 13 + fmts.add('web', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki_Web') ### 9 + fmts.add('web', 'pdf', 'pdf', 'PDF - Portable Document Format', 'writer_web_pdf_Export') ### 10 +-fmts.add('web', 'sdw3', 'sdw', 'StarWriter 3.0 (OpenOffice.org Writer/Web)', 'StarWriter 3.0 (StarWriter/Web)') ### 3 +-fmts.add('web', 'sdw4', 'sdw', 'StarWriter 4.0 (OpenOffice.org Writer/Web)', 'StarWriter 4.0 (StarWriter/Web)') ### 4 +-fmts.add('web', 'sdw', 'sdw', 'StarWriter 5.0 (OpenOffice.org Writer/Web)', 'StarWriter 5.0 (StarWriter/Web)') ### 5 + fmts.add('web', 'txt', 'txt', 'OpenOffice.org Text (OpenOffice.org Writer/Web)', 'writerweb8_writer') ### 12 + fmts.add('web', 'text10', 'txt', 'OpenOffice.org 1.0 Text Document (OpenOffice.org Writer/Web)', 'writer_web_StarOffice_XML_Writer') ### 15 + fmts.add('web', 'text', 'txt', 'Text (OpenOffice.org Writer/Web)', 'Text (StarWriter/Web)') ### 8 +-fmts.add('web', 'vor4', 'vor', 'StarWriter/Web 4.0 Template', 'StarWriter/Web 4.0 Vorlage/Template') ### 6 +-fmts.add('web', 'vor', 'vor', 'StarWriter/Web 5.0 Template', 'StarWriter/Web 5.0 Vorlage/Template') ### 7 + + ### Spreadsheet + fmts.add('spreadsheet', 'csv', 'csv', 'Text CSV', 'Text - txt - csv (StarCalc)') ### 16 +@@ -401,17 +388,10 @@ fmts.add('spreadsheet', 'ods', 'ods', 'ODF Spreadsheet', 'calc8') ### 15 + fmts.add('spreadsheet', 'ooxml', 'xml', 'Microsoft Excel 2003 XML', 'MS Excel 2003 XML') ### 23 + fmts.add('spreadsheet', 'ots', 'ots', 'ODF Spreadsheet Template', 'calc8_template') ### 14 + fmts.add('spreadsheet', 'pdf', 'pdf', 'Portable Document Format', 'calc_pdf_Export') ### 34 +-fmts.add('spreadsheet', 'pxl', 'pxl', 'Pocket Excel', 'Pocket Excel') +-fmts.add('spreadsheet', 'sdc', 'sdc', 'StarCalc 5.0', 'StarCalc 5.0') ### 31 +-fmts.add('spreadsheet', 'sdc4', 'sdc', 'StarCalc 4.0', 'StarCalc 4.0') ### 11 +-fmts.add('spreadsheet', 'sdc3', 'sdc', 'StarCalc 3.0', 'StarCalc 3.0') ### 29 + fmts.add('spreadsheet', 'slk', 'slk', 'SYLK', 'SYLK') ### 35 + fmts.add('spreadsheet', 'stc', 'stc', 'OpenOffice.org 1.0 Spreadsheet Template', 'calc_StarOffice_XML_Calc_Template') ### 2 + fmts.add('spreadsheet', 'sxc', 'sxc', 'OpenOffice.org 1.0 Spreadsheet', 'StarOffice XML (Calc)') ### 3 + fmts.add('spreadsheet', 'uos', 'uos', 'Unified Office Format spreadsheet', 'UOF spreadsheet') ### 9 +-fmts.add('spreadsheet', 'vor3', 'vor', 'StarCalc 3.0 Template', 'StarCalc 3.0 Vorlage/Template') ### 18 +-fmts.add('spreadsheet', 'vor4', 'vor', 'StarCalc 4.0 Template', 'StarCalc 4.0 Vorlage/Template') ### 19 +-fmts.add('spreadsheet', 'vor', 'vor', 'StarCalc 5.0 Template', 'StarCalc 5.0 Vorlage/Template') ### 20 + fmts.add('spreadsheet', 'xhtml', 'xhtml', 'XHTML', 'XHTML Calc File') ### 26 + fmts.add('spreadsheet', 'xls', 'xls', 'Microsoft Excel 97/2000/XP', 'MS Excel 97') ### 12 + fmts.add('spreadsheet', 'xls5', 'xls', 'Microsoft Excel 5.0', 'MS Excel 5.0/95') ### 8 +@@ -443,12 +423,7 @@ fmts.add('graphics', 'svg', 'svg', 'Scalable Vector Graphics', 'draw_svg_Export' + fmts.add('graphics', 'svm', 'svm', 'StarView Metafile', 'draw_svm_Export') ### 55 + fmts.add('graphics', 'swf', 'swf', 'Macromedia Flash (SWF)', 'draw_flash_Export') ### 23 + fmts.add('graphics', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing', 'StarOffice XML (Draw)') ### 26 +-fmts.add('graphics', 'sxd3', 'sxd', 'StarDraw 3.0', 'StarDraw 3.0') ### 40 +-fmts.add('graphics', 'sxd5', 'sxd', 'StarDraw 5.0', 'StarDraw 5.0') ### 44 +-fmts.add('graphics', 'sxw', 'sxw', 'StarOffice XML (Draw)', 'StarOffice XML (Draw)') + fmts.add('graphics', 'tiff', 'tiff', 'Tagged Image File Format', 'draw_tif_Export') ### 13 +-fmts.add('graphics', 'vor', 'vor', 'StarDraw 5.0 Template', 'StarDraw 5.0 Vorlage') ### 36 +-fmts.add('graphics', 'vor3', 'vor', 'StarDraw 3.0 Template', 'StarDraw 3.0 Vorlage') ### 35 + fmts.add('graphics', 'wmf', 'wmf', 'Windows Metafile', 'draw_wmf_Export') ### 8 + fmts.add('graphics', 'xhtml', 'xhtml', 'XHTML', 'XHTML Draw File') ### 45 + fmts.add('graphics', 'xpm', 'xpm', 'X PixMap', 'draw_xpm_Export') ### 19 +@@ -479,9 +454,6 @@ fmts.add('presentation', 'ppt', 'ppt', 'Microsoft PowerPoint 97/2000/XP', 'MS Po + fmts.add('presentation', 'pwp', 'pwp', 'PlaceWare', 'placeware_Export') ### 30 + fmts.add('presentation', 'ras', 'ras', 'Sun Raster Image', 'impress_ras_Export') ### 27 + fmts.add('presentation', 'sda', 'sda', 'StarDraw 5.0 (OpenOffice.org Impress)', 'StarDraw 5.0 (StarImpress)') ### 8 +-fmts.add('presentation', 'sdd', 'sdd', 'StarImpress 5.0', 'StarImpress 5.0') ### 6 +-fmts.add('presentation', 'sdd3', 'sdd', 'StarDraw 3.0 (OpenOffice.org Impress)', 'StarDraw 3.0 (StarImpress)') ### 42 +-fmts.add('presentation', 'sdd4', 'sdd', 'StarImpress 4.0', 'StarImpress 4.0') ### 37 + fmts.add('presentation', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing (OpenOffice.org Impress)', 'impress_StarOffice_XML_Draw') ### 31 + fmts.add('presentation', 'sti', 'sti', 'OpenOffice.org 1.0 Presentation Template', 'impress_StarOffice_XML_Impress_Template') ### 5 + fmts.add('presentation', 'svg', 'svg', 'Scalable Vector Graphics', 'impress_svg_Export') ### 14 +@@ -490,10 +462,6 @@ fmts.add('presentation', 'swf', 'swf', 'Macromedia Flash (SWF)', 'impress_flash_ + fmts.add('presentation', 'sxi', 'sxi', 'OpenOffice.org 1.0 Presentation', 'StarOffice XML (Impress)') ### 41 + fmts.add('presentation', 'tiff', 'tiff', 'Tagged Image File Format', 'impress_tif_Export') ### 12 + fmts.add('presentation', 'uop', 'uop', 'Unified Office Format presentation', 'UOF presentation') ### 4 +-fmts.add('presentation', 'vor', 'vor', 'StarImpress 5.0 Template', 'StarImpress 5.0 Vorlage') ### 40 +-fmts.add('presentation', 'vor3', 'vor', 'StarDraw 3.0 Template (OpenOffice.org Impress)', 'StarDraw 3.0 Vorlage (StarImpress)') ###1 +-fmts.add('presentation', 'vor4', 'vor', 'StarImpress 4.0 Template', 'StarImpress 4.0 Vorlage') ### 39 +-fmts.add('presentation', 'vor5', 'vor', 'StarDraw 5.0 Template (OpenOffice.org Impress)', 'StarDraw 5.0 Vorlage (StarImpress)') ### 2 + fmts.add('presentation', 'wmf', 'wmf', 'Windows Metafile', 'impress_wmf_Export') ### 11 + fmts.add('presentation', 'xhtml', 'xml', 'XHTML', 'XHTML Impress File') ### 33 + fmts.add('presentation', 'xpm', 'xpm', 'X PixMap', 'impress_xpm_Export') ### 10 +-- +1.9.0 + diff --git a/unoconv.spec b/unoconv.spec index 0ff7eaa..e7c7e83 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -15,6 +15,7 @@ Patch1: 0001-python3-added-compatibility.3.patch Patch2: 0001-update-FSF-address.patch Patch3: 0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch Patch4: 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch +Patch5: 0002-remove-export-formats-dropped-by-LibreOffice.patch BuildArch: noarch Requires: libreoffice-filters @@ -46,6 +47,7 @@ make install DESTDIR="%{buildroot}" %changelog * Sat Apr 19 2014 David Tardon - 0.6-10 - Resolves: rhbz#1076275 unoconv trips over '-f latex' +- do not show unusable export formats * Thu Apr 17 2014 David Tardon - 0.6-9 - Resolves: rhbz#1076275 unonconv trips over '-f latex' From 955f9ef50bca656ddfc50d434e4665daf7a7fa49 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Sat, 19 Apr 2014 12:14:42 +0200 Subject: [PATCH 31/71] allow import from Dia too --- unoconv.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/unoconv.spec b/unoconv.spec index e7c7e83..28e7069 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -21,6 +21,7 @@ BuildArch: noarch Requires: libreoffice-filters Requires: libreoffice-pyuno Requires: libreoffice-writer2latex +Requires: openoffice.org-diafilter %description unoconv converts between any document format that LibreOffice understands. From 14c3386a4777e3b242e0803e56f0ef0c8d22b2e0 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Sat, 7 Jun 2014 21:54:06 -0500 Subject: [PATCH 32/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 28e7069..3470698 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 10%{?dist} +Release: 11%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -46,6 +46,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sun Jun 08 2014 Fedora Release Engineering - 0.6-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + * Sat Apr 19 2014 David Tardon - 0.6-10 - Resolves: rhbz#1076275 unoconv trips over '-f latex' - do not show unusable export formats From d1934682f146c34a3dca1e6ecca6eee7e01359b8 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Fri, 19 Jun 2015 01:36:13 +0000 Subject: [PATCH 33/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 3470698..f87068b 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.6 -Release: 11%{?dist} +Release: 12%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -46,6 +46,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Fri Jun 19 2015 Fedora Release Engineering - 0.6-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + * Sun Jun 08 2014 Fedora Release Engineering - 0.6-11 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild From 7dd2537c94a992f456da85236fe70be2d93e2a60 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Fri, 10 Jul 2015 12:50:22 +0200 Subject: [PATCH 34/71] new upstream release 0.7 --- .gitignore | 1 + ...ort-option-and-add-V-as-alternative-.patch | 38 -- ...09-can-t-write-bytes-direct-to-stdou.patch | 26 - 0001-Updated-ChangeLog.patch | 40 ++ ...ice-or-OO.o-has-never-had-wps-export.patch | 24 + 0001-python3-added-compatibility.2.patch | 384 ----------- 0001-python3-added-compatibility.3.patch | 629 ------------------ 0001-python3-added-compatibility.patch | 22 + sources | 2 +- unoconv.spec | 26 +- 10 files changed, 101 insertions(+), 1091 deletions(-) delete mode 100644 0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch delete mode 100644 0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch create mode 100644 0001-Updated-ChangeLog.patch create mode 100644 0001-libreoffice-or-OO.o-has-never-had-wps-export.patch delete mode 100644 0001-python3-added-compatibility.2.patch delete mode 100644 0001-python3-added-compatibility.3.patch create mode 100644 0001-python3-added-compatibility.patch diff --git a/.gitignore b/.gitignore index fad94ff..a1bdbc0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ unoconv-0.3.tar.bz2 /unoconv-0.4.tar.bz2 /unoconv-0.5.tar.bz2 /unoconv-0.6.tar.gz +/unoconv-0.7.tar.gz diff --git a/0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch b/0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch deleted file mode 100644 index 264a279..0000000 --- a/0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 3c20d6ec49a97c24cfb1fe9fd61ac80944819088 Mon Sep 17 00:00:00 2001 -From: Dag Wieers -Date: Fri, 28 Sep 2012 19:33:01 +0200 -Subject: [PATCH] Fix a broken --export option and add -V as alternative to - --version - -This closes #93. ---- - unoconv | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/unoconv b/unoconv -index 972e962..30e6706 100755 ---- a/unoconv -+++ b/unoconv -@@ -524,8 +524,8 @@ class Options: - - ### Get options from the commandline - try: -- opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:v', -- ['connection=', 'debug', 'doctype=', 'export', 'format=', -+ opts, args = getopt.getopt (args, 'c:Dd:e:f:hi:Llo:np:s:T:t:vV', -+ ['connection=', 'debug', 'doctype=', 'export=', 'format=', - 'help', 'import', 'listener', 'no-launch', 'output=', - 'outputpath', 'password=', 'pipe=', 'port=', 'server=', - 'timeout=', 'show', 'stdout', 'template', 'verbose', -@@ -609,7 +609,7 @@ class Options: - self.timeout = int(arg) - elif opt in ['-v', '--verbose']: - self.verbose = self.verbose + 1 -- elif opt in ['--version']: -+ elif opt in ['-V', '--version']: - self.version() - sys.exit(255) - --- -1.7.11.7 - diff --git a/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch b/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch deleted file mode 100644 index e96aa8c..0000000 --- a/0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 3249fd3df136f1a859ac0272f75fcbf010926d58 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= -Date: Thu, 7 Nov 2013 13:33:37 +0000 -Subject: [PATCH] Resolves: fdo#70309 can't write bytes direct to stdout in - python3 - ---- - unoconv | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/unoconv b/unoconv -index a4f9490..2b0b0eb 100755 ---- a/unoconv -+++ b/unoconv -@@ -1146,7 +1146,7 @@ if __name__ == '__main__': - self.closed = 1 - - def writeBytes( self, seq ): -- sys.stdout.write( seq.value ) -+ sys.stdout.buffer.write( seq.value ) - - def flush( self ): - pass --- -1.8.5.3 - diff --git a/0001-Updated-ChangeLog.patch b/0001-Updated-ChangeLog.patch new file mode 100644 index 0000000..66c477b --- /dev/null +++ b/0001-Updated-ChangeLog.patch @@ -0,0 +1,40 @@ +From b02c77cc669715858a2e6a658cb1988e5e89cf3b Mon Sep 17 00:00:00 2001 +From: Dag Wieers +Date: Thu, 9 Jul 2015 01:47:52 +0200 +Subject: [PATCH] Updated ChangeLog + +--- + ChangeLog | 19 ++++++++++++++++++- + 1 file changed, 18 insertions(+), 1 deletion(-) + +diff --git a/ChangeLog b/ChangeLog +index 0c21fb4..7ca8755 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,5 +1,22 @@ + * 0.7 - released 2015-07-09 +-- ++- Ported to Python 3 (Riccardo Magliocchetti) ++- Update Indexes (eg. TOC) during conversion (Peter Demin) ++- Added XLSX support (Josias Montag) ++- Fix output to non-existing directory ++- Ensure that LibreOfficeDev release are using new long options (Chia-liang Kao) ++- Set output format based on output filename extension (Patrick McAndrew) ++- Accept 'office' as binary on MacOSX (Andreas Jung) ++- Added Microsoft WPS import filter (Josias Montag) ++- Fix --stdout output on Python 3 (Caolán McNamara) ++- Added -F/--field option to update user fields during conversion (Raphaël Pinson) ++- Added OpenOffice search path on MacOSX (Vittal Aithal) ++- Cycle through all images references before conversion ++- Added --preserve option to preserve timestamp and permissions (Vincent Bernat) ++- Added --stdin option to read from standard input ++- Accept remote URLs as input filename ++- Fix exit code 81 and recover from initial failure (Daniel Vandersluis) ++- Improve documentation related to error codes and using unoconv with Nginx/Apache/PHP ++ + + * 0.6 - released 2012-09-10 + - Implement debugging output (-vvv) +-- +2.1.0 + diff --git a/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch b/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch new file mode 100644 index 0000000..70c24f4 --- /dev/null +++ b/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch @@ -0,0 +1,24 @@ +From aa46d3cbcec14ae46a176165852089558c524ff2 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Fri, 10 Jul 2015 12:55:13 +0200 +Subject: [PATCH] libreoffice (or OO.o) has never had wps export + +--- + unoconv | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/unoconv b/unoconv +index 2e56d3c..1158374 100755 +--- a/unoconv ++++ b/unoconv +@@ -377,7 +377,6 @@ fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### + fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 + fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 + fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 +-fmts.add('document', 'wps', 'wps', 'Microsoft Works', 'MS_Works') + fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 + + ### WebDocument +-- +2.1.0 + diff --git a/0001-python3-added-compatibility.2.patch b/0001-python3-added-compatibility.2.patch deleted file mode 100644 index d5416c7..0000000 --- a/0001-python3-added-compatibility.2.patch +++ /dev/null @@ -1,384 +0,0 @@ -From 34bbe9fa679d39921fd67002e01e7a9bf93b009a Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Sat, 19 Apr 2014 12:05:04 +0200 -Subject: [PATCH] 0001-python3-added-compatibility.2.patch - ---- - unoconv | 142 +++++++++++++++++++++++++++++++++++++++------------------------- - 1 file changed, 86 insertions(+), 56 deletions(-) - -diff --git a/unoconv b/unoconv -index 30e6706..8c45ad9 100755 ---- a/unoconv -+++ b/unoconv -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/python - - ### This program is free software; you can redistribute it and/or modify - ### it under the terms of the GNU General Public License as published by -@@ -203,7 +203,7 @@ def office_environ(office): - ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: - os.environ['UNO_PATH'] = office.unopath - -- ### Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete -+ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete - ### UNO environment - if os.name in ( 'nt', 'os2' ): - os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') -@@ -277,6 +277,7 @@ def python_switch(office): - - try: - os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) -+ print(office.python, [office.python, ] + sys.argv[0:], osenviron) - except OSError: - ### Mac OS X versions prior to 10.6 do not support execv in - ### a process that contains multiple threads. Instead of -@@ -553,14 +554,14 @@ class Options: - if name in ('FilterOptions'): - self.exportfilteroptions = value - elif value in ('True', 'true'): -- self.exportfilter.append( PropertyValue( name, 0, True, 0 ) ) -+ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) - elif value in ('False', 'false'): -- self.exportfilter.append( PropertyValue( name, 0, False, 0 ) ) -+ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) - else: - try: -- self.exportfilter.append( PropertyValue( name, 0, int(value), 0 ) ) -+ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) - except ValueError: -- self.exportfilter.append( PropertyValue( name, 0, value, 0 ) ) -+ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) - else: - print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg - elif opt in ['-f', '--format']: -@@ -572,14 +573,14 @@ class Options: - if name in ('FilterOptions'): - self.importfilteroptions = value - elif value in ('True', 'true'): -- self.importfilter.append( PropertyValue( name, 0, True, 0 ) ) -+ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) - elif value in ('False', 'false'): -- self.importfilter.append( PropertyValue( name, 0, False, 0 ) ) -+ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) - else: - try: -- self.importfilter.append( PropertyValue( name, 0, int(value), 0 ) ) -+ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) - except ValueError: -- self.importfilter.append( PropertyValue( name, 0, value, 0 ) ) -+ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) - else: - print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg - elif opt in ['-l', '--listener']: -@@ -657,7 +658,7 @@ class Options: - - def version(self): - ### Get office product information -- product = uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) -+ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) - - print 'unoconv %s' % VERSION - print 'Written by Dag Wieers ' -@@ -706,7 +707,7 @@ class Convertor: - unocontext = None - - ### Do the LibreOffice component dance -- self.context = uno.getComponentContext() -+ self.context = global_uno.getComponentContext() - self.svcmgr = self.context.ServiceManager - resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) - -@@ -714,7 +715,7 @@ class Convertor: - info(3, 'Connection type: %s' % op.connection) - try: - unocontext = resolver.resolve("uno:%s" % op.connection) -- except NoConnectException, e: -+ except UnoNoConnectException, e: - # info(3, "Existing listener not found.\n%s" % e) - info(3, "Existing listener not found.") - -@@ -724,7 +725,7 @@ class Convertor: - ### Start our own OpenOffice instance - info(3, "Launching our own listener using %s." % office.binary) - try: -- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) -+ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) - if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): - ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) - else: -@@ -742,7 +743,7 @@ class Convertor: - try: - unocontext = resolver.resolve("uno:%s" % op.connection) - break -- except NoConnectException: -+ except UnoNoConnectException: - time.sleep(0.5) - timeout += 0.5 - except: -@@ -759,7 +760,7 @@ class Convertor: - ### And some more LibreOffice magic - unosvcmgr = unocontext.ServiceManager - self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) -- self.cwd = unohelper.systemPathToFileUrl( os.getcwd() ) -+ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() ) - - ### List all filters - # self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) -@@ -824,22 +825,22 @@ class Convertor: - phase = "import" - - ### Load inputfile -- inputprops = UnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=QUIET_UPDATE) -+ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE) - - # if op.password: --# info = UnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") --# inputprops += UnoProps(ModifyPasswordInfo=info) -+# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") -+# inputprops += GlobalUnoProps(ModifyPasswordInfo=info) - -- ### Cannot use UnoProps for FilterData property -+ ### Cannot use GlobalUnoProps for FilterData property - if op.importfilteroptions: - # print "Import filter options: %s" % op.importfilteroptions -- inputprops += UnoProps(FilterOptions=op.importfilteroptions) -+ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions) - -- ### Cannot use UnoProps for FilterData property -+ ### Cannot use GlobalUnoProps for FilterData property - if op.importfilter: -- inputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) -+ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) - -- inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn)) -+ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn)) - document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) - - if not document: -@@ -850,8 +851,8 @@ class Convertor: - if op.template: - if os.path.exists(op.template): - info(1, "Template file: %s" % op.template) -- templateprops = UnoProps(OverwriteStyles=True) -- templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template)) -+ templateprops = GlobalUnoProps(OverwriteStyles=True) -+ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template)) - document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) - else: - print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template -@@ -885,26 +886,26 @@ class Convertor: - ### Export phase - phase = "export" - -- outputprops = UnoProps(FilterName=outputfmt.filter, OutputStream=OutputStream(), Overwrite=True) -+ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True) - - ### Set default filter options - if op.exportfilteroptions: - # print "Export filter options: %s" % op.exportfilteroptions -- outputprops += UnoProps(FilterOptions=op.exportfilteroptions) -+ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions) - else: - if outputfmt.filter == 'Text (encoded)': -- outputprops += UnoProps(FilterOptions="76,LF") -+ outputprops += GlobalUnoProps(FilterOptions="76,LF") - - elif outputfmt.filter == 'Text': -- outputprops += UnoProps(FilterOptions="76") -+ outputprops += GlobalUnoProps(FilterOptions="76") - - elif outputfmt.filter == 'Text - txt - csv (StarCalc)': -- outputprops += UnoProps(FilterOptions="44,34,76") -+ outputprops += GlobalUnoProps(FilterOptions="44,34,76") - - -- ### Cannot use UnoProps for FilterData property -+ ### Cannot use GlobalUnoProps for FilterData property - if op.exportfilter: -- outputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) -+ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) - - if not op.stdout: - (outputfn, ext) = os.path.splitext(inputfn) -@@ -917,14 +918,14 @@ class Convertor: - else: - outputfn = op.output - -- outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) -+ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) ) - info(1, "Output file: %s" % outputfn) - else: - outputurl = "private:stream" - - try: - document.storeToURL(outputurl, tuple(outputprops) ) -- except IOException, e: -+ except UnoIOException, e: - raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) - - phase = "dispose" -@@ -935,24 +936,24 @@ class Convertor: - error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) - exitcode = 1 - -- except RuntimeException, e: -+ except UnoRuntimeException, e: - error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) - exitcode = 6 - -- except DisposedException, e: -+ except UnoDisposedException, e: - error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) - exitcode = 7 - -- except IllegalArgumentException, e: -+ except UnoIllegalArgumentException, e: - error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) - exitcode = 8 - -- except IOException, e: -+ except UnoIOException, e: - # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) - error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) - exitcode = 3 - -- except CannotConvertException, e: -+ except UnoCannotConvertException, e: - # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) - error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) - exitcode = 4 -@@ -975,14 +976,14 @@ class Listener: - global product - - info(1, "Start listener on %s:%s" % (op.server, op.port)) -- self.context = uno.getComponentContext() -+ self.context = global_uno.getComponentContext() - self.svcmgr = self.context.ServiceManager - try: - resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) -- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) -+ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) - try: - unocontext = resolver.resolve("uno:%s" % op.connection) -- except NoConnectException, e: -+ except UnoNoConnectException, e: - pass - else: - info(1, "Existing %s listener found, nothing to do." % product.ooName) -@@ -1039,7 +1040,7 @@ def die(ret, msg=None): - info(3, 'Terminating %s instance.' % product.ooName) - try: - convertor.desktop.terminate() -- except DisposedException: -+ except UnoDisposedException: - info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) - try: - ooproc.terminate() -@@ -1080,7 +1081,7 @@ def main(): - for inputfn in op.filenames: - convertor.convert(inputfn) - -- except NoConnectException, e: -+ except UnoNoConnectException, e: - error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) - if op.connection: - info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) -@@ -1094,7 +1095,8 @@ def main(): - error("Warning: failed to launch Office suite. Aborting.") - - ### Main entrance --if __name__ == '__main__': -+def run(): -+ global exitcode - exitcode = 0 - - info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) -@@ -1105,7 +1107,12 @@ if __name__ == '__main__': - office_environ(of) - # debug_office() - try: -- import uno, unohelper -+ global global_uno -+ global global_unohelper -+ -+ import uno as global_uno -+ import unohelper as global_unohelper -+ global office - office = of - break - except: -@@ -1121,17 +1128,30 @@ if __name__ == '__main__': - sys.exit(1) - - ### Now that we have found a working pyuno library, let's import some classes -- from com.sun.star.beans import PropertyValue -- from com.sun.star.connection import NoConnectException -- from com.sun.star.document.UpdateDocMode import QUIET_UPDATE -- from com.sun.star.lang import DisposedException, IllegalArgumentException -- from com.sun.star.io import IOException, XOutputStream -- from com.sun.star.script import CannotConvertException -+ global UnoPropertyValue -+ global UnoNoConnectException -+ global UNO_QUIET_UPDATE -+ global UnoDisposedException -+ global UnoIllegalArgumentException -+ global UnoIOException -+ global UnoXOutputStream -+ global UnoCannotConvertException -+ global UnoException -+ global UnoRuntimeException -+ -+ from com.sun.star.beans import PropertyValue as UnoPropertyValue -+ from com.sun.star.connection import NoConnectException as UnoNoConnectException -+ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE -+ from com.sun.star.lang import DisposedException as UnoDisposedException -+ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException -+ from com.sun.star.io import IOException as UnoIOException -+ from com.sun.star.io import XOutputStream as UnoXOutputStream -+ from com.sun.star.script import CannotConvertException as UnoCannotConvertException - from com.sun.star.uno import Exception as UnoException -- from com.sun.star.uno import RuntimeException -+ from com.sun.star.uno import RuntimeException as UnoRuntimeException - - ### And now that we have those classes, build on them -- class OutputStream( unohelper.Base, XOutputStream ): -+ class OutputStream( global_unohelper.Base, UnoXOutputStream ): - def __init__( self ): - self.closed = 0 - -@@ -1144,15 +1164,22 @@ if __name__ == '__main__': - def flush( self ): - pass - -+ global GlobalOutputStream -+ GlobalOutputStream = OutputStream -+ - def UnoProps(**args): - props = [] - for key in args: -- prop = PropertyValue() -+ prop = UnoPropertyValue() - prop.Name = key - prop.Value = args[key] - props.append(prop) - return tuple(props) - -+ global GlobalUnoProps -+ GlobalUnoProps = UnoProps -+ -+ global op - op = Options(sys.argv[1:]) - - info(2, "Using office base path: %s" % office.basepath) -@@ -1163,3 +1190,6 @@ if __name__ == '__main__': - except KeyboardInterrupt, e: - die(6, 'Exiting on user request') - die(exitcode) -+ -+if __name__ == '__main__': -+ run() --- -1.9.0 - diff --git a/0001-python3-added-compatibility.3.patch b/0001-python3-added-compatibility.3.patch deleted file mode 100644 index 18216c9..0000000 --- a/0001-python3-added-compatibility.3.patch +++ /dev/null @@ -1,629 +0,0 @@ -From 21b9a845ac7e8805b41d7dab1a6fbf8076689ae8 Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Sat, 19 Apr 2014 12:06:27 +0200 -Subject: [PATCH] 0001-python3-added-compatibility.3.patch - ---- - unoconv | 248 ++++++++++++++++++++++++++++++++++++---------------------------- - 1 file changed, 139 insertions(+), 109 deletions(-) - -diff --git a/unoconv b/unoconv -index 30e6706..a13db44 100755 ---- a/unoconv -+++ b/unoconv -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/python3 - - ### This program is free software; you can redistribute it and/or modify - ### it under the terms of the GNU General Public License as published by -@@ -77,11 +77,11 @@ def find_offices(): - else: - - if os.name in ( 'nt', 'os2' ): -- if 'PROGRAMFILES' in os.environ.keys(): -+ if 'PROGRAMFILES' in list(os.environ.keys()): - extrapaths += glob.glob(os.environ['PROGRAMFILES']+'\\LibreOffice*') + \ - glob.glob(os.environ['PROGRAMFILES']+'\\OpenOffice.org*') - -- if 'PROGRAMFILES(X86)' in os.environ.keys(): -+ if 'PROGRAMFILES(X86)' in list(os.environ.keys()): - extrapaths += glob.glob(os.environ['PROGRAMFILES(X86)']+'\\LibreOffice*') + \ - glob.glob(os.environ['PROGRAMFILES(X86)']+'\\OpenOffice.org*') - -@@ -203,7 +203,7 @@ def office_environ(office): - ### Set UNO_PATH so that "officehelper.bootstrap()" can find soffice executable: - os.environ['UNO_PATH'] = office.unopath - -- ### Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete -+ ### Set URE_BOOTSTRAP so that "global_uno.getComponentContext()" bootstraps a complete - ### UNO environment - if os.name in ( 'nt', 'os2' ): - os.environ['URE_BOOTSTRAP'] = 'vnd.sun.star.pathname:' + realpath(office.basepath, 'program', 'fundamental.ini') -@@ -233,18 +233,18 @@ def office_environ(office): - - def debug_office(): - if 'URE_BOOTSTRAP' in os.environ: -- print >>sys.stderr, 'URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'] -+ print('URE_BOOTSTRAP=%s' % os.environ['URE_BOOTSTRAP'], file=sys.stderr) - if 'UNO_PATH' in os.environ: -- print >>sys.stderr, 'UNO_PATH=%s' % os.environ['UNO_PATH'] -+ print('UNO_PATH=%s' % os.environ['UNO_PATH'], file=sys.stderr) - if 'UNO_TYPES' in os.environ: -- print >>sys.stderr, 'UNO_TYPES=%s' % os.environ['UNO_TYPES'] -- print 'PATH=%s' % os.environ['PATH'] -+ print('UNO_TYPES=%s' % os.environ['UNO_TYPES'], file=sys.stderr) -+ print('PATH=%s' % os.environ['PATH']) - if 'PYTHONHOME' in os.environ: -- print >>sys.stderr, 'PYTHONHOME=%s' % os.environ['PYTHONHOME'] -+ print('PYTHONHOME=%s' % os.environ['PYTHONHOME'], file=sys.stderr) - if 'PYTHONPATH' in os.environ: -- print >>sys.stderr, 'PYTHONPATH=%s' % os.environ['PYTHONPATH'] -+ print('PYTHONPATH=%s' % os.environ['PYTHONPATH'], file=sys.stderr) - if 'LD_LIBRARY_PATH' in os.environ: -- print >>sys.stderr, 'LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'] -+ print('LD_LIBRARY_PATH=%s' % os.environ['LD_LIBRARY_PATH'], file=sys.stderr) - - def python_switch(office): - if office.pythonhome: -@@ -277,6 +277,7 @@ def python_switch(office): - - try: - os.execvpe(office.python, [office.python, ] + sys.argv[0:], os.environ) -+ print((office.python, [office.python, ] + sys.argv[0:], osenviron)) - except OSError: - ### Mac OS X versions prior to 10.6 do not support execv in - ### a process that contains multiple threads. Instead of -@@ -335,11 +336,11 @@ class FmtList: - return ret - - def display(self, doctype): -- print >>sys.stderr, "The following list of %s formats are currently available:\n" % doctype -+ print("The following list of %s formats are currently available:\n" % doctype, file=sys.stderr) - for fmt in self.list: - if fmt.doctype == doctype: -- print >>sys.stderr, " %-8s - %s" % (fmt.name, fmt) -- print >>sys.stderr -+ print(" %-8s - %s" % (fmt.name, fmt), file=sys.stderr) -+ print(file=sys.stderr) - - fmts = FmtList() - -@@ -530,14 +531,14 @@ class Options: - 'outputpath', 'password=', 'pipe=', 'port=', 'server=', - 'timeout=', 'show', 'stdout', 'template', 'verbose', - 'version'] ) -- except getopt.error, exc: -- print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc) -+ except getopt.error as exc: -+ print('unoconv: %s, try unoconv -h for a list of all the options' % str(exc)) - sys.exit(255) - - for opt, arg in opts: - if opt in ['-h', '--help']: - self.usage() -- print -+ print() - self.help() - sys.exit(1) - elif opt in ['-c', '--connection']: -@@ -553,16 +554,16 @@ class Options: - if name in ('FilterOptions'): - self.exportfilteroptions = value - elif value in ('True', 'true'): -- self.exportfilter.append( PropertyValue( name, 0, True, 0 ) ) -+ self.exportfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) - elif value in ('False', 'false'): -- self.exportfilter.append( PropertyValue( name, 0, False, 0 ) ) -+ self.exportfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) - else: - try: -- self.exportfilter.append( PropertyValue( name, 0, int(value), 0 ) ) -+ self.exportfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) - except ValueError: -- self.exportfilter.append( PropertyValue( name, 0, value, 0 ) ) -+ self.exportfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) - else: -- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg -+ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr) - elif opt in ['-f', '--format']: - self.format = arg - elif opt in ['-i', '--import']: -@@ -572,16 +573,16 @@ class Options: - if name in ('FilterOptions'): - self.importfilteroptions = value - elif value in ('True', 'true'): -- self.importfilter.append( PropertyValue( name, 0, True, 0 ) ) -+ self.importfilter.append( UnoPropertyValue( name, 0, True, 0 ) ) - elif value in ('False', 'false'): -- self.importfilter.append( PropertyValue( name, 0, False, 0 ) ) -+ self.importfilter.append( UnoPropertyValue( name, 0, False, 0 ) ) - else: - try: -- self.importfilter.append( PropertyValue( name, 0, int(value), 0 ) ) -+ self.importfilter.append( UnoPropertyValue( name, 0, int(value), 0 ) ) - except ValueError: -- self.importfilter.append( PropertyValue( name, 0, value, 0 ) ) -+ self.importfilter.append( UnoPropertyValue( name, 0, value, 0 ) ) - else: -- print >>sys.stderr, 'Warning: Option %s cannot be parsed, ignoring.' % arg -+ print('Warning: Option %s cannot be parsed, ignoring.' % arg, file=sys.stderr) - elif opt in ['-l', '--listener']: - self.listener = True - elif opt in ['-n', '--no-launch']: -@@ -589,7 +590,7 @@ class Options: - elif opt in ['-o', '--output']: - self.output = arg - elif opt in ['--outputpath']: -- print >>sys.stderr, 'Warning: This option is deprecated by --output.' -+ print('Warning: This option is deprecated by --output.', file=sys.stderr) - self.output = arg - elif opt in ['--password']: - self.password = arg -@@ -615,13 +616,13 @@ class Options: - - ### Enable verbosity - if self.verbose >= 2: -- print >>sys.stderr, 'Verbosity set to level %d' % self.verbose -+ print('Verbosity set to level %d' % self.verbose, file=sys.stderr) - - self.filenames = args - - if not self.listener and not self.showlist and self.doctype != 'list' and not self.filenames: -- print >>sys.stderr, 'unoconv: you have to provide a filename as argument' -- print >>sys.stderr, 'Try `unoconv -h\' for more information.' -+ print('unoconv: you have to provide a filename as argument', file=sys.stderr) -+ print('Try `unoconv -h\' for more information.', file=sys.stderr) - sys.exit(255) - - ### Set connection string -@@ -657,23 +658,23 @@ class Options: - - def version(self): - ### Get office product information -- product = uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) -- -- print 'unoconv %s' % VERSION -- print 'Written by Dag Wieers ' -- print 'Homepage at http://dag.wieers.com/home-made/unoconv/' -- print -- print 'platform %s/%s' % (os.name, sys.platform) -- print 'python %s' % sys.version -- print product.ooName, product.ooSetupVersion -+ product = global_uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) -+ -+ print('unoconv %s' % VERSION) -+ print('Written by Dag Wieers ') -+ print('Homepage at http://dag.wieers.com/home-made/unoconv/') -+ print() -+ print('platform %s/%s' % (os.name, sys.platform)) -+ print('python %s' % sys.version) -+ print(product.ooName, product.ooSetupVersion) - # print - # print 'build revision $Rev$' - - def usage(self): -- print >>sys.stderr, 'usage: unoconv [options] file [file2 ..]' -+ print('usage: unoconv [options] file [file2 ..]', file=sys.stderr) - - def help(self): -- print >>sys.stderr, '''Convert from and to any format supported by LibreOffice -+ print('''Convert from and to any format supported by LibreOffice - - unoconv options: - -c, --connection=string use a custom connection string -@@ -698,7 +699,7 @@ unoconv options: - -t, --template=file import the styles from template (.ott) - -T, --timeout=secs timeout after secs if connection to listener fails - -v, --verbose be more and more verbose (-vvv for debugging) --''' -+''', file=sys.stderr) - - class Convertor: - def __init__(self): -@@ -706,7 +707,7 @@ class Convertor: - unocontext = None - - ### Do the LibreOffice component dance -- self.context = uno.getComponentContext() -+ self.context = global_uno.getComponentContext() - self.svcmgr = self.context.ServiceManager - resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) - -@@ -714,7 +715,7 @@ class Convertor: - info(3, 'Connection type: %s' % op.connection) - try: - unocontext = resolver.resolve("uno:%s" % op.connection) -- except NoConnectException, e: -+ except UnoNoConnectException as e: - # info(3, "Existing listener not found.\n%s" % e) - info(3, "Existing listener not found.") - -@@ -724,7 +725,7 @@ class Convertor: - ### Start our own OpenOffice instance - info(3, "Launching our own listener using %s." % office.binary) - try: -- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) -+ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) - if product.ooName != "LibreOffice" or LooseVersion(product.ooSetupVersion) <= LooseVersion('3.3'): - ooproc = subprocess.Popen([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nofirststartwizard", "-nologo", "-norestore", "-accept=%s" % op.connection], env=os.environ) - else: -@@ -742,14 +743,14 @@ class Convertor: - try: - unocontext = resolver.resolve("uno:%s" % op.connection) - break -- except NoConnectException: -+ except UnoNoConnectException: - time.sleep(0.5) - timeout += 0.5 - except: - raise - else: - error("Failed to connect to %s (pid=%s) in %d seconds.\n%s" % (office.binary, ooproc.pid, op.timeout, e)) -- except Exception, e: -+ except Exception as e: - raise - error("Launch of %s failed.\n%s" % (office.binary, e)) - -@@ -759,7 +760,7 @@ class Convertor: - ### And some more LibreOffice magic - unosvcmgr = unocontext.ServiceManager - self.desktop = unosvcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", unocontext) -- self.cwd = unohelper.systemPathToFileUrl( os.getcwd() ) -+ self.cwd = global_unohelper.systemPathToFileUrl( os.getcwd() ) - - ### List all filters - # self.filters = unosvcmgr.createInstanceWithContext( "com.sun.star.document.FilterFactory", unocontext) -@@ -799,9 +800,9 @@ class Convertor: - ### No format found, throw error - if not outputfmt: - if doctype: -- print >>sys.stderr, 'unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format) -+ print('unoconv: format [%s/%s] is not known to unoconv.' % (op.doctype, op.format), file=sys.stderr) - else: -- print >>sys.stderr, 'unoconv: format [%s] is not known to unoconv.' % op.format -+ print('unoconv: format [%s] is not known to unoconv.' % op.format, file=sys.stderr) - die(1) - - return outputfmt -@@ -813,10 +814,10 @@ class Convertor: - outputfmt = self.getformat(inputfn) - - if op.verbose > 0: -- print >>sys.stderr, 'Input file:', inputfn -+ print('Input file:', inputfn, file=sys.stderr) - - if not os.path.exists(inputfn): -- print >>sys.stderr, 'unoconv: file `%s\' does not exist.' % inputfn -+ print('unoconv: file `%s\' does not exist.' % inputfn, file=sys.stderr) - exitcode = 1 - - try: -@@ -824,22 +825,22 @@ class Convertor: - phase = "import" - - ### Load inputfile -- inputprops = UnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=QUIET_UPDATE) -+ inputprops = GlobalUnoProps(Hidden=True, ReadOnly=True, UpdateDocMode=UNO_QUIET_UPDATE) - - # if op.password: --# info = UnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") --# inputprops += UnoProps(ModifyPasswordInfo=info) -+# info = GlobalUnoProps(algorithm-name="PBKDF2", salt="salt", iteration-count=1024, hash="hash") -+# inputprops += GlobalUnoProps(ModifyPasswordInfo=info) - -- ### Cannot use UnoProps for FilterData property -+ ### Cannot use GlobalUnoProps for FilterData property - if op.importfilteroptions: - # print "Import filter options: %s" % op.importfilteroptions -- inputprops += UnoProps(FilterOptions=op.importfilteroptions) -+ inputprops += GlobalUnoProps(FilterOptions=op.importfilteroptions) - -- ### Cannot use UnoProps for FilterData property -+ ### Cannot use GlobalUnoProps for FilterData property - if op.importfilter: -- inputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) -+ inputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.importfilter ), ), 0 ), ) - -- inputurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(inputfn)) -+ inputurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(inputfn)) - document = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops ) - - if not document: -@@ -850,11 +851,11 @@ class Convertor: - if op.template: - if os.path.exists(op.template): - info(1, "Template file: %s" % op.template) -- templateprops = UnoProps(OverwriteStyles=True) -- templateurl = unohelper.absolutize(self.cwd, unohelper.systemPathToFileUrl(op.template)) -+ templateprops = GlobalUnoProps(OverwriteStyles=True) -+ templateurl = global_unohelper.absolutize(self.cwd, global_unohelper.systemPathToFileUrl(op.template)) - document.StyleFamilies.loadStylesFromURL(templateurl, templateprops) - else: -- print >>sys.stderr, 'unoconv: template file `%s\' does not exist.' % op.template -+ print('unoconv: template file `%s\' does not exist.' % op.template, file=sys.stderr) - exitcode = 1 - - ### Update document links -@@ -885,26 +886,26 @@ class Convertor: - ### Export phase - phase = "export" - -- outputprops = UnoProps(FilterName=outputfmt.filter, OutputStream=OutputStream(), Overwrite=True) -+ outputprops = GlobalUnoProps(FilterName=outputfmt.filter, OutputStream=GlobalOutputStream(), Overwrite=True) - - ### Set default filter options - if op.exportfilteroptions: - # print "Export filter options: %s" % op.exportfilteroptions -- outputprops += UnoProps(FilterOptions=op.exportfilteroptions) -+ outputprops += GlobalUnoProps(FilterOptions=op.exportfilteroptions) - else: - if outputfmt.filter == 'Text (encoded)': -- outputprops += UnoProps(FilterOptions="76,LF") -+ outputprops += GlobalUnoProps(FilterOptions="76,LF") - - elif outputfmt.filter == 'Text': -- outputprops += UnoProps(FilterOptions="76") -+ outputprops += GlobalUnoProps(FilterOptions="76") - - elif outputfmt.filter == 'Text - txt - csv (StarCalc)': -- outputprops += UnoProps(FilterOptions="44,34,76") -+ outputprops += GlobalUnoProps(FilterOptions="44,34,76") - - -- ### Cannot use UnoProps for FilterData property -+ ### Cannot use GlobalUnoProps for FilterData property - if op.exportfilter: -- outputprops += ( PropertyValue( "FilterData", 0, uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) -+ outputprops += ( UnoPropertyValue( "FilterData", 0, global_uno.Any("[]com.sun.star.beans.PropertyValue", tuple( op.exportfilter ), ), 0 ), ) - - if not op.stdout: - (outputfn, ext) = os.path.splitext(inputfn) -@@ -917,47 +918,47 @@ class Convertor: - else: - outputfn = op.output - -- outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) ) -+ outputurl = global_unohelper.absolutize( self.cwd, global_unohelper.systemPathToFileUrl(outputfn) ) - info(1, "Output file: %s" % outputfn) - else: - outputurl = "private:stream" - - try: - document.storeToURL(outputurl, tuple(outputprops) ) -- except IOException, e: -+ except UnoIOException as e: - raise UnoException("Unable to store document to %s (ErrCode %d)\n\nProperties: %s" % (outputurl, e.ErrCode, outputprops), None) - - phase = "dispose" - document.dispose() - document.close(True) - -- except SystemError, e: -+ except SystemError as e: - error("unoconv: SystemError during %s phase:\n%s" % (phase, e)) - exitcode = 1 - -- except RuntimeException, e: -+ except UnoRuntimeException as e: - error("unoconv: RuntimeException during %s phase:\nOffice probably died. %s" % (phase, e)) - exitcode = 6 - -- except DisposedException, e: -+ except UnoDisposedException as e: - error("unoconv: DisposedException during %s phase:\nOffice probably died. %s" % (phase, e)) - exitcode = 7 - -- except IllegalArgumentException, e: -+ except UnoIllegalArgumentException as e: - error("UNO IllegalArgument during %s phase:\nSource file cannot be read. %s" % (phase, e)) - exitcode = 8 - -- except IOException, e: -+ except UnoIOException as e: - # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) - error("unoconv: IOException during %s phase:\n%s" % (phase, e.Message)) - exitcode = 3 - -- except CannotConvertException, e: -+ except UnoCannotConvertException as e: - # for attr in dir(e): print '%s: %s', (attr, getattr(e, attr)) - error("unoconv: CannotConvertException during %s phase:\n%s" % (phase, e.Message)) - exitcode = 4 - -- except UnoException, e: -+ except UnoException as e: - if hasattr(e, 'ErrCode'): - error("unoconv: UnoException during %s phase in %s (ErrCode %d)" % (phase, repr(e.__class__), e.ErrCode)) - exitcode = e.ErrCode -@@ -975,14 +976,14 @@ class Listener: - global product - - info(1, "Start listener on %s:%s" % (op.server, op.port)) -- self.context = uno.getComponentContext() -+ self.context = global_uno.getComponentContext() - self.svcmgr = self.context.ServiceManager - try: - resolver = self.svcmgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", self.context) -- product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", UnoProps(nodepath="/org.openoffice.Setup/Product")) -+ product = self.svcmgr.createInstance("com.sun.star.configuration.ConfigurationProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", GlobalUnoProps(nodepath="/org.openoffice.Setup/Product")) - try: - unocontext = resolver.resolve("uno:%s" % op.connection) -- except NoConnectException, e: -+ except UnoNoConnectException as e: - pass - else: - info(1, "Existing %s listener found, nothing to do." % product.ooName) -@@ -991,25 +992,25 @@ class Listener: - subprocess.call([office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection], env=os.environ) - else: - subprocess.call([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection], env=os.environ) -- except Exception, e: -+ except Exception as e: - error("Launch of %s failed.\n%s" % (office.binary, e)) - else: - info(1, "Existing %s listener found, nothing to do." % product.ooName) - - def error(msg): - "Output error message" -- print >>sys.stderr, msg -+ print(msg, file=sys.stderr) - - def info(level, msg): - "Output info message" - if 'op' not in globals(): - pass - elif op.verbose >= 3 and level >= 3: -- print >>sys.stderr, "DEBUG:", msg -+ print("DEBUG:", msg, file=sys.stderr) - elif not op.stdout and level <= op.verbose: -- print >>sys.stdout, msg -+ print(msg, file=sys.stdout) - elif level <= op.verbose: -- print >>sys.stderr, msg -+ print(msg, file=sys.stderr) - - def die(ret, msg=None): - "Print optional error and exit with errorcode" -@@ -1031,7 +1032,7 @@ def die(ret, msg=None): - subprocess.Popen([office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--unaccept=%s" % op.connection], env=os.environ) - ooproc.wait() - info(2, '%s listener successfully disabled.' % product.ooName) -- except Exception, e: -+ except Exception as e: - error("Terminate using %s failed.\n%s" % (office.binary, e)) - - ### If there is no GUI attached to the instance, terminate instance -@@ -1039,7 +1040,7 @@ def die(ret, msg=None): - info(3, 'Terminating %s instance.' % product.ooName) - try: - convertor.desktop.terminate() -- except DisposedException: -+ except UnoDisposedException: - info(2, '%s instance unsuccessfully closed, sending TERM signal.' % product.ooName) - try: - ooproc.terminate() -@@ -1080,7 +1081,7 @@ def main(): - for inputfn in op.filenames: - convertor.convert(inputfn) - -- except NoConnectException, e: -+ except UnoNoConnectException as e: - error("unoconv: could not find an existing connection to LibreOffice at %s:%s." % (op.server, op.port)) - if op.connection: - info(0, "Please start an LibreOffice instance on server '%s' by doing:\n\n unoconv --listener --server %s --port %s\n\nor alternatively:\n\n soffice -nologo -nodefault -accept=\"%s\"" % (op.server, op.server, op.port, op.connection)) -@@ -1094,7 +1095,8 @@ def main(): - error("Warning: failed to launch Office suite. Aborting.") - - ### Main entrance --if __name__ == '__main__': -+def run(): -+ global exitcode - exitcode = 0 - - info(3, 'sysname=%s, platform=%s, python=%s, python-version=%s' % (os.name, sys.platform, sys.executable, sys.version)) -@@ -1105,33 +1107,51 @@ if __name__ == '__main__': - office_environ(of) - # debug_office() - try: -- import uno, unohelper -+ global global_uno -+ global global_unohelper -+ -+ import uno as global_uno -+ import unohelper as global_unohelper -+ global office - office = of - break - except: - # debug_office() -- print >>sys.stderr, "unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of -- print >>sys.stderr, "ERROR:", sys.exc_info()[1] -- print >>sys.stderr -+ print("unoconv: Cannot find a suitable pyuno library and python binary combination in %s" % of, file=sys.stderr) -+ print("ERROR:", sys.exc_info()[1], file=sys.stderr) -+ print(file=sys.stderr) - else: - # debug_office() -- print >>sys.stderr, "unoconv: Cannot find a suitable office installation on your system." -- print >>sys.stderr, "ERROR: Please locate your office installation and send your feedback to:" -- print >>sys.stderr, " http://github.com/dagwieers/unoconv/issues" -+ print("unoconv: Cannot find a suitable office installation on your system.", file=sys.stderr) -+ print("ERROR: Please locate your office installation and send your feedback to:", file=sys.stderr) -+ print(" http://github.com/dagwieers/unoconv/issues", file=sys.stderr) - sys.exit(1) - - ### Now that we have found a working pyuno library, let's import some classes -- from com.sun.star.beans import PropertyValue -- from com.sun.star.connection import NoConnectException -- from com.sun.star.document.UpdateDocMode import QUIET_UPDATE -- from com.sun.star.lang import DisposedException, IllegalArgumentException -- from com.sun.star.io import IOException, XOutputStream -- from com.sun.star.script import CannotConvertException -+ global UnoPropertyValue -+ global UnoNoConnectException -+ global UNO_QUIET_UPDATE -+ global UnoDisposedException -+ global UnoIllegalArgumentException -+ global UnoIOException -+ global UnoXOutputStream -+ global UnoCannotConvertException -+ global UnoException -+ global UnoRuntimeException -+ -+ from com.sun.star.beans import PropertyValue as UnoPropertyValue -+ from com.sun.star.connection import NoConnectException as UnoNoConnectException -+ from com.sun.star.document.UpdateDocMode import QUIET_UPDATE as UNO_QUIET_UPDATE -+ from com.sun.star.lang import DisposedException as UnoDisposedException -+ from com.sun.star.lang import IllegalArgumentException as UnoIllegalArgumentException -+ from com.sun.star.io import IOException as UnoIOException -+ from com.sun.star.io import XOutputStream as UnoXOutputStream -+ from com.sun.star.script import CannotConvertException as UnoCannotConvertException - from com.sun.star.uno import Exception as UnoException -- from com.sun.star.uno import RuntimeException -+ from com.sun.star.uno import RuntimeException as UnoRuntimeException - - ### And now that we have those classes, build on them -- class OutputStream( unohelper.Base, XOutputStream ): -+ class OutputStream( global_unohelper.Base, UnoXOutputStream ): - def __init__( self ): - self.closed = 0 - -@@ -1144,15 +1164,22 @@ if __name__ == '__main__': - def flush( self ): - pass - -+ global GlobalOutputStream -+ GlobalOutputStream = OutputStream -+ - def UnoProps(**args): - props = [] - for key in args: -- prop = PropertyValue() -+ prop = UnoPropertyValue() - prop.Name = key - prop.Value = args[key] - props.append(prop) - return tuple(props) - -+ global GlobalUnoProps -+ GlobalUnoProps = UnoProps -+ -+ global op - op = Options(sys.argv[1:]) - - info(2, "Using office base path: %s" % office.basepath) -@@ -1160,6 +1187,9 @@ if __name__ == '__main__': - - try: - main() -- except KeyboardInterrupt, e: -+ except KeyboardInterrupt as e: - die(6, 'Exiting on user request') - die(exitcode) -+ -+if __name__ == '__main__': -+ run() --- -1.9.0 - diff --git a/0001-python3-added-compatibility.patch b/0001-python3-added-compatibility.patch new file mode 100644 index 0000000..84ed36b --- /dev/null +++ b/0001-python3-added-compatibility.patch @@ -0,0 +1,22 @@ +From 21b9a845ac7e8805b41d7dab1a6fbf8076689ae8 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Sat, 19 Apr 2014 12:06:27 +0200 +Subject: [PATCH] 0001-python3-added-compatibility.3.patch + +--- + unoconv | 248 ++++++++++++++++++++++++++++++++++++---------------------------- + 1 file changed, 139 insertions(+), 109 deletions(-) + +diff --git a/unoconv b/unoconv +index 30e6706..a13db44 100755 +--- a/unoconv ++++ b/unoconv +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python3 + + ### This program is free software; you can redistribute it and/or modify + ### it under the terms of the GNU General Public License as published by +-- +1.9.0 + diff --git a/sources b/sources index 23edf65..1971310 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -eeda0d358ce4bacd5dd84303012c416d unoconv-0.6.tar.gz +eff96b17a62876abfef09c16d0516d09 unoconv-0.7.tar.gz diff --git a/unoconv.spec b/unoconv.spec index f87068b..d5bcaa6 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,21 +1,18 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv -Version: 0.6 -Release: 12%{?dist} +Version: 0.7 +Release: 1%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz -Patch0: 0001-Fix-a-broken-export-option-and-add-V-as-alternative-.patch -%if 0%{?rhel} -Patch1: 0001-python3-added-compatibility.2.patch -%else -Patch1: 0001-python3-added-compatibility.3.patch -%endif -Patch2: 0001-update-FSF-address.patch -Patch3: 0001-Resolves-fdo-70309-can-t-write-bytes-direct-to-stdou.patch -Patch4: 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch -Patch5: 0002-remove-export-formats-dropped-by-LibreOffice.patch + +Patch0: 0001-python3-added-compatibility.patch +Patch1: 0001-update-FSF-address.patch +Patch2: 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch +Patch3: 0001-libreoffice-or-OO.o-has-never-had-wps-export.patch +Patch4: 0002-remove-export-formats-dropped-by-LibreOffice.patch +Patch5: 0001-Updated-ChangeLog.patch BuildArch: noarch Requires: libreoffice-filters @@ -41,11 +38,14 @@ RTF, Docbook (.xml), and more. make install DESTDIR="%{buildroot}" %files -%doc AUTHORS ChangeLog COPYING README.asciidoc WISHLIST doc/*.txt tests/ +%doc AUTHORS ChangeLog COPYING README.adoc doc/*.adoc %{_mandir}/man1/%{name}.1* %{_bindir}/%{name} %changelog +* Fri Jul 10 2015 David Tardon - 0.7-1 +- new upstream release + * Fri Jun 19 2015 Fedora Release Engineering - 0.6-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild From cc7f25979475983f2440a567393ff28cd75e900a Mon Sep 17 00:00:00 2001 From: David Tardon Date: Fri, 10 Jul 2015 13:34:28 +0200 Subject: [PATCH 35/71] build HTML docs --- unoconv.spec | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index d5bcaa6..baf0aec 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -15,6 +15,10 @@ Patch4: 0002-remove-export-formats-dropped-by-LibreOffice.patch Patch5: 0001-Updated-ChangeLog.patch BuildArch: noarch + +BuildRequires: asciidoc +BuildRequires: xmlto + Requires: libreoffice-filters Requires: libreoffice-pyuno Requires: libreoffice-writer2latex @@ -31,14 +35,18 @@ RTF, Docbook (.xml), and more. %prep %autosetup -p1 +rm doc/%{name}.1 %build +make %{?_smp_mflags} +asciidoc README.adoc %install make install DESTDIR="%{buildroot}" %files -%doc AUTHORS ChangeLog COPYING README.adoc doc/*.adoc +%doc AUTHORS ChangeLog COPYING README.html +%doc doc/errcode.html doc/filters.html doc/formats.html doc/selinux.html %{_mandir}/man1/%{name}.1* %{_bindir}/%{name} From 79883f8c2e5fb1c420bcd405bfb803f73acdbee3 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Tue, 5 Jan 2016 20:38:58 +0100 Subject: [PATCH 36/71] don't install obscure filter deps by default --- unoconv.spec | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/unoconv.spec b/unoconv.spec index baf0aec..16be6f0 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: Tool to convert between any document format supported by LibreOffice Name: unoconv Version: 0.7 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2 Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ @@ -21,8 +21,8 @@ BuildRequires: xmlto Requires: libreoffice-filters Requires: libreoffice-pyuno -Requires: libreoffice-writer2latex -Requires: openoffice.org-diafilter +Suggests: libreoffice-writer2latex +Suggests: openoffice.org-diafilter %description unoconv converts between any document format that LibreOffice understands. @@ -51,6 +51,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Tue Jan 05 2016 David Tardon - 0.7-2 +- don't install obscure filter deps by default + * Fri Jul 10 2015 David Tardon - 0.7-1 - new upstream release From 6112c6791ad6ad0711506893b35df78e5c463412 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Tue, 5 Jan 2016 20:40:26 +0100 Subject: [PATCH 37/71] use %license --- unoconv.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 16be6f0..811db90 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -45,8 +45,9 @@ asciidoc README.adoc make install DESTDIR="%{buildroot}" %files -%doc AUTHORS ChangeLog COPYING README.html +%doc AUTHORS ChangeLog README.html %doc doc/errcode.html doc/filters.html doc/formats.html doc/selinux.html +%license COPYING %{_mandir}/man1/%{name}.1* %{_bindir}/%{name} From 555bdde264f40855d31cadc147207c50d9b77435 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Tue, 5 Jan 2016 20:43:13 +0100 Subject: [PATCH 38/71] drop obsolete Group tag --- unoconv.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 811db90..0402e22 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -3,7 +3,6 @@ Name: unoconv Version: 0.7 Release: 2%{?dist} License: GPLv2 -Group: System Environment/Base URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz From 2e6dcbdfcedec4e41c727412c9bc94dd226bbf4a Mon Sep 17 00:00:00 2001 From: David Tardon Date: Tue, 5 Jan 2016 20:47:42 +0100 Subject: [PATCH 39/71] update description --- unoconv.spec | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/unoconv.spec b/unoconv.spec index 0402e22..91cd1c3 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,4 +1,4 @@ -Summary: Tool to convert between any document format supported by LibreOffice +Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.7 Release: 2%{?dist} @@ -24,13 +24,14 @@ Suggests: libreoffice-writer2latex Suggests: openoffice.org-diafilter %description -unoconv converts between any document format that LibreOffice understands. -It uses LibreOffice's UNO bindings for non-interactive conversion of -documents. +Universal Office Converter (unoconv) is a command line tool to convert any +document format that LibreOffice can import to any document format that +LibreOffice can export. It makes use of the LibreOffice's UNO bindings for +non-interactive conversion of documents. -Supported document formats include Open Document Format (.odf), MS Word (.doc), -MS Office Open/MS OOXML (.xml), Portable Document Format (.pdf), HTML, XHTML, -RTF, Docbook (.xml), and more. +Supported document formats include Open Document Format (.odg, .odp, .ods, +.odt), MS Word (.doc), MS Office Open/MS OOXML (.docx, .pptx, .xlsx), PDF, +HTML, RTF, and many more. %prep %autosetup -p1 From 124a40caba1e70cc598b367639ccd75239131aaa Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 5 Feb 2016 02:23:26 +0000 Subject: [PATCH 40/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 91cd1c3..0677a1c 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.7 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Fri Feb 05 2016 Fedora Release Engineering - 0.7-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + * Tue Jan 05 2016 David Tardon - 0.7-2 - don't install obscure filter deps by default From 242c6006e0006c47c1b6818d0def059bb55b48b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 19 Dec 2016 18:20:38 +0100 Subject: [PATCH 41/71] Rebuild for Python 3.6 --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 0677a1c..1567bd0 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.7 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Mon Dec 19 2016 Miro Hrončok - 0.7-4 +- Rebuild for Python 3.6 + * Fri Feb 05 2016 Fedora Release Engineering - 0.7-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild From 935281c71a2d8d9b2964c5493664e2af6887b276 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 11 Feb 2017 16:46:06 +0000 Subject: [PATCH 42/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 1567bd0..3b42c8a 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.7 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sat Feb 11 2017 Fedora Release Engineering - 0.7-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + * Mon Dec 19 2016 Miro Hrončok - 0.7-4 - Rebuild for Python 3.6 From 46fe13c0a91be958fce4ebf9d64bf499d842aa24 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 23 Feb 2017 10:20:46 +0100 Subject: [PATCH 43/71] fix up patch --- 0001-update-FSF-address.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0001-update-FSF-address.patch b/0001-update-FSF-address.patch index 925cf4f..b1c357b 100644 --- a/0001-update-FSF-address.patch +++ b/0001-update-FSF-address.patch @@ -141,7 +141,7 @@ index 30e6706..e4a1ac8 100755 +### MA 02110-1301 USA. ### Copyright 2007-2010 Dag Wieers - from distutils.version import LooseVersion + from __future__ import print_function -- 1.7.11.7 From 2e06fda8a33c7006cbd8d56986e1cdc099222f30 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 27 Jul 2017 21:01:39 +0000 Subject: [PATCH 44/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 3b42c8a..250a8c0 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.7 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Thu Jul 27 2017 Fedora Release Engineering - 0.7-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + * Sat Feb 11 2017 Fedora Release Engineering - 0.7-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild From 2d7afba06a103723af94fda3db1e739c7e001d42 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 9 Feb 2018 20:04:42 +0000 Subject: [PATCH 45/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 250a8c0..f39d8c9 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.7 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2 URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Fri Feb 09 2018 Fedora Release Engineering - 0.7-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + * Thu Jul 27 2017 Fedora Release Engineering - 0.7-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild From 8e71bd84710ac66717dffea2ae2cbdaa1a3cf923 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 14 Jul 2018 08:16:16 +0000 Subject: [PATCH 46/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index f39d8c9..6a24892 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.7 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2 URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sat Jul 14 2018 Fedora Release Engineering - 0.7-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + * Fri Feb 09 2018 Fedora Release Engineering - 0.7-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild From 588fa43bcf6710ff4088d7f155edf524db33a1d2 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sun, 3 Feb 2019 10:51:33 +0000 Subject: [PATCH 47/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 6a24892..308babf 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.7 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv2 URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sun Feb 03 2019 Fedora Release Engineering - 0.7-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + * Sat Jul 14 2018 Fedora Release Engineering - 0.7-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild From 940ac0994fe9b57265054cde26e514b33140d842 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 27 Jul 2019 02:33:03 +0000 Subject: [PATCH 48/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 308babf..49620e6 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.7 -Release: 9%{?dist} +Release: 10%{?dist} License: GPLv2 URL: http://dag.wieers.com/home-made/unoconv/ Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sat Jul 27 2019 Fedora Release Engineering - 0.7-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + * Sun Feb 03 2019 Fedora Release Engineering - 0.7-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild From 48d4749f2b57207c89e285cb7dcc98a17f876b9b Mon Sep 17 00:00:00 2001 From: David Tardon Date: Sat, 31 Aug 2019 17:01:19 +0200 Subject: [PATCH 49/71] new upstream release 0.8.2 --- .gitignore | 1 + 0001-Updated-ChangeLog.patch | 40 ------------------------------------ sources | 2 +- unoconv.spec | 12 ++++++----- 4 files changed, 9 insertions(+), 46 deletions(-) delete mode 100644 0001-Updated-ChangeLog.patch diff --git a/.gitignore b/.gitignore index a1bdbc0..06cfde5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ unoconv-0.3.tar.bz2 /unoconv-0.5.tar.bz2 /unoconv-0.6.tar.gz /unoconv-0.7.tar.gz +/0.8.2.tar.gz diff --git a/0001-Updated-ChangeLog.patch b/0001-Updated-ChangeLog.patch deleted file mode 100644 index 66c477b..0000000 --- a/0001-Updated-ChangeLog.patch +++ /dev/null @@ -1,40 +0,0 @@ -From b02c77cc669715858a2e6a658cb1988e5e89cf3b Mon Sep 17 00:00:00 2001 -From: Dag Wieers -Date: Thu, 9 Jul 2015 01:47:52 +0200 -Subject: [PATCH] Updated ChangeLog - ---- - ChangeLog | 19 ++++++++++++++++++- - 1 file changed, 18 insertions(+), 1 deletion(-) - -diff --git a/ChangeLog b/ChangeLog -index 0c21fb4..7ca8755 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,5 +1,22 @@ - * 0.7 - released 2015-07-09 --- -+- Ported to Python 3 (Riccardo Magliocchetti) -+- Update Indexes (eg. TOC) during conversion (Peter Demin) -+- Added XLSX support (Josias Montag) -+- Fix output to non-existing directory -+- Ensure that LibreOfficeDev release are using new long options (Chia-liang Kao) -+- Set output format based on output filename extension (Patrick McAndrew) -+- Accept 'office' as binary on MacOSX (Andreas Jung) -+- Added Microsoft WPS import filter (Josias Montag) -+- Fix --stdout output on Python 3 (Caolán McNamara) -+- Added -F/--field option to update user fields during conversion (Raphaël Pinson) -+- Added OpenOffice search path on MacOSX (Vittal Aithal) -+- Cycle through all images references before conversion -+- Added --preserve option to preserve timestamp and permissions (Vincent Bernat) -+- Added --stdin option to read from standard input -+- Accept remote URLs as input filename -+- Fix exit code 81 and recover from initial failure (Daniel Vandersluis) -+- Improve documentation related to error codes and using unoconv with Nginx/Apache/PHP -+ - - * 0.6 - released 2012-09-10 - - Implement debugging output (-vvv) --- -2.1.0 - diff --git a/sources b/sources index 1971310..bd0bd87 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -eff96b17a62876abfef09c16d0516d09 unoconv-0.7.tar.gz +SHA512 (0.8.2.tar.gz) = cd6a4d06559895c0aebb5fda51ca86928474dd0ca0aa908e81762643186c29cf8436c889eedbb18bc74ed6016414d1aa831cd034614244d5aae677a6b4cdd4c9 diff --git a/unoconv.spec b/unoconv.spec index 49620e6..d2bb009 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,17 +1,16 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv -Version: 0.7 -Release: 10%{?dist} +Version: 0.8.2 +Release: 1%{?dist} License: GPLv2 -URL: http://dag.wieers.com/home-made/unoconv/ -Source: http://dag.wieers.com/home-made/%{name}/%{name}-%{version}.tar.gz +URL: https://github.com/unoconv/unoconv/ +Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz Patch0: 0001-python3-added-compatibility.patch Patch1: 0001-update-FSF-address.patch Patch2: 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch Patch3: 0001-libreoffice-or-OO.o-has-never-had-wps-export.patch Patch4: 0002-remove-export-formats-dropped-by-LibreOffice.patch -Patch5: 0001-Updated-ChangeLog.patch BuildArch: noarch @@ -52,6 +51,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sat Aug 31 2019 David Tardon - 0.8.2-1 +- new upstream release + * Sat Jul 27 2019 Fedora Release Engineering - 0.7-10 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild From a407717de75e47599824352af8c593b6566ca283 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Sat, 28 Sep 2019 14:30:03 +0200 Subject: [PATCH 50/71] new upstream release 0.9.0 --- .gitignore | 1 + 0001-libreoffice-or-OO.o-has-never-had-wps-export.patch | 2 +- 0002-remove-export-formats-dropped-by-LibreOffice.patch | 2 +- sources | 2 +- unoconv.spec | 5 ++++- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 06cfde5..a5a6998 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ unoconv-0.3.tar.bz2 /unoconv-0.6.tar.gz /unoconv-0.7.tar.gz /0.8.2.tar.gz +/0.9.tar.gz diff --git a/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch b/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch index 70c24f4..051e355 100644 --- a/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch +++ b/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch @@ -17,8 +17,8 @@ index 2e56d3c..1158374 100755 fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 -fmts.add('document', 'wps', 'wps', 'Microsoft Works', 'MS_Works') fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 + fmts.add('document', 'epub', 'epub', 'Electronic Publication', 'EPUB') - ### WebDocument -- 2.1.0 diff --git a/0002-remove-export-formats-dropped-by-LibreOffice.patch b/0002-remove-export-formats-dropped-by-LibreOffice.patch index f46a52b..22fc6a6 100644 --- a/0002-remove-export-formats-dropped-by-LibreOffice.patch +++ b/0002-remove-export-formats-dropped-by-LibreOffice.patch @@ -31,8 +31,8 @@ index dd73799..a5d29da 100755 -fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 -fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 + fmts.add('document', 'epub', 'epub', 'Electronic Publication', 'EPUB') - ### WebDocument @@ -382,14 +374,9 @@ fmts.add('web', 'html', 'html', 'HTML Document', 'HTML') ### 2 fmts.add('web', 'html', 'html', 'HTML Document Template', 'writerweb8_writer_template') ### 13 fmts.add('web', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki_Web') ### 9 diff --git a/sources b/sources index bd0bd87..daf6bac 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (0.8.2.tar.gz) = cd6a4d06559895c0aebb5fda51ca86928474dd0ca0aa908e81762643186c29cf8436c889eedbb18bc74ed6016414d1aa831cd034614244d5aae677a6b4cdd4c9 +SHA512 (0.9.tar.gz) = 1d6448154ec41776ed4d2ffd87b1caa15e231676a1161072676b1f5a466ea6dbae904de3eafb9ab2718fe4ed0ab7a2c9a91b1d19d79ea382c1e7576ea21e7f04 diff --git a/unoconv.spec b/unoconv.spec index d2bb009..abf9c3d 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,6 +1,6 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv -Version: 0.8.2 +Version: 0.9 Release: 1%{?dist} License: GPLv2 URL: https://github.com/unoconv/unoconv/ @@ -51,6 +51,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sat Sep 28 2019 David Tardon - 0.9-1 +- new upstream release + * Sat Aug 31 2019 David Tardon - 0.8.2-1 - new upstream release From 79badfe66de88d23110c3dd7a237a07c55cfc539 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Sun, 22 Dec 2019 09:58:04 +0100 Subject: [PATCH 51/71] upload fixed tarball --- .gitignore | 1 + sources | 2 +- unoconv.spec | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a5a6998..fdb7625 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ unoconv-0.3.tar.bz2 /unoconv-0.7.tar.gz /0.8.2.tar.gz /0.9.tar.gz +/0.9.0.tar.gz diff --git a/sources b/sources index daf6bac..c565d13 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (0.9.tar.gz) = 1d6448154ec41776ed4d2ffd87b1caa15e231676a1161072676b1f5a466ea6dbae904de3eafb9ab2718fe4ed0ab7a2c9a91b1d19d79ea382c1e7576ea21e7f04 +SHA512 (0.9.0.tar.gz) = 37d63ada32675fd0ebd089a74db453fdb7332a24e62cbf3e060d6d15cc503c76ede9ccc5e09467f4a38833a8358c09fde23cc8780a77c343268f20e0c37f2469 diff --git a/unoconv.spec b/unoconv.spec index abf9c3d..03e17f6 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv -Version: 0.9 -Release: 1%{?dist} +Version: 0.9.0 +Release: 2%{?dist} License: GPLv2 URL: https://github.com/unoconv/unoconv/ Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz @@ -51,6 +51,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sun Dec 22 2019 David Tardon - 0.9.0-2 +- upload fixed tarball + * Sat Sep 28 2019 David Tardon - 0.9-1 - new upstream release From 2a1fe5c02850fb78e2b054862535a6635ca9d04d Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 25 Dec 2019 21:18:24 +0100 Subject: [PATCH 52/71] "Adding package.cfg file" --- package.cfg | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 package.cfg diff --git a/package.cfg b/package.cfg new file mode 100644 index 0000000..66ea79d --- /dev/null +++ b/package.cfg @@ -0,0 +1,2 @@ +[koji] +targets = epel8 epel8-playground \ No newline at end of file From 657e2284a8e2be9e9de9a312ea6f82bdea35fca2 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 26 Dec 2019 08:55:39 +0100 Subject: [PATCH 53/71] Resolves: rhbz#1752953 import from Rawhide --- .cvsignore | 0 .gitignore | 1 + ...ice-or-OO.o-has-never-had-wps-export.patch | 24 +++ ...-export-usable-with-writer2latex-ext.patch | 34 ++++ 0001-python3-added-compatibility.patch | 22 +++ 0001-update-FSF-address.patch | 147 +++++++++++++++ ...xport-formats-dropped-by-LibreOffice.patch | 105 +++++++++++ Makefile | 21 --- package.cfg | 2 - sources | 1 + unoconv.spec | 177 ++++++++++++++++++ 11 files changed, 511 insertions(+), 23 deletions(-) delete mode 100644 .cvsignore create mode 100644 .gitignore create mode 100644 0001-libreoffice-or-OO.o-has-never-had-wps-export.patch create mode 100644 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch create mode 100644 0001-python3-added-compatibility.patch create mode 100644 0001-update-FSF-address.patch create mode 100644 0002-remove-export-formats-dropped-by-LibreOffice.patch delete mode 100644 Makefile delete mode 100644 package.cfg create mode 100644 unoconv.spec diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index e69de29..0000000 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..abe309c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/0.9.0.tar.gz diff --git a/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch b/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch new file mode 100644 index 0000000..051e355 --- /dev/null +++ b/0001-libreoffice-or-OO.o-has-never-had-wps-export.patch @@ -0,0 +1,24 @@ +From aa46d3cbcec14ae46a176165852089558c524ff2 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Fri, 10 Jul 2015 12:55:13 +0200 +Subject: [PATCH] libreoffice (or OO.o) has never had wps export + +--- + unoconv | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/unoconv b/unoconv +index 2e56d3c..1158374 100755 +--- a/unoconv ++++ b/unoconv +@@ -377,7 +377,6 @@ fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### + fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 + fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 + fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 +-fmts.add('document', 'wps', 'wps', 'Microsoft Works', 'MS_Works') + fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 + fmts.add('document', 'epub', 'epub', 'Electronic Publication', 'EPUB') + +-- +2.1.0 + diff --git a/0001-make-LaTeX-export-usable-with-writer2latex-ext.patch b/0001-make-LaTeX-export-usable-with-writer2latex-ext.patch new file mode 100644 index 0000000..07e9947 --- /dev/null +++ b/0001-make-LaTeX-export-usable-with-writer2latex-ext.patch @@ -0,0 +1,34 @@ +From 7b17d0160d9bd940e40c906684646ad7e4024c24 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Sat, 19 Apr 2014 11:18:41 +0200 +Subject: [PATCH 1/2] make LaTeX export usable with writer2latex ext. + +--- + unoconv | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/unoconv b/unoconv +index 30e6706..dd73799 100755 +--- a/unoconv ++++ b/unoconv +@@ -344,7 +344,7 @@ class FmtList: + fmts = FmtList() + + ### TextDocument +-fmts.add('document', 'bib', 'bib', 'BibTeX', 'BibTeX_Writer') ### 22 ++fmts.add('document', 'bib', 'bib', 'BibTeX', 'org.openoffice.da.writer2bibtex') ### 22 + fmts.add('document', 'doc', 'doc', 'Microsoft Word 97/2000/XP', 'MS Word 97') ### 29 + fmts.add('document', 'doc6', 'doc', 'Microsoft Word 6.0', 'MS WinWord 6.0') ### 24 + fmts.add('document', 'doc95', 'doc', 'Microsoft Word 95', 'MS Word 95') ### 28 +@@ -353,7 +353,7 @@ fmts.add('document', 'docx', 'docx', 'Microsoft Office Open XML', 'Office Open X + fmts.add('document', 'docx7', 'docx', 'Microsoft Office Open XML', 'MS Word 2007 XML') + fmts.add('document', 'fodt', 'fodt', 'OpenDocument Text (Flat XML)', 'OpenDocument Text Flat XML') + fmts.add('document', 'html', 'html', 'HTML Document (OpenOffice.org Writer)', 'HTML (StarWriter)') ### 3 +-fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'LaTeX_Writer') ### 31 ++fmts.add('document', 'latex', 'ltx', 'LaTeX 2e', 'org.openoffice.da.writer2latex') ### 31 + fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') + fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 + fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 +-- +1.9.0 + diff --git a/0001-python3-added-compatibility.patch b/0001-python3-added-compatibility.patch new file mode 100644 index 0000000..84ed36b --- /dev/null +++ b/0001-python3-added-compatibility.patch @@ -0,0 +1,22 @@ +From 21b9a845ac7e8805b41d7dab1a6fbf8076689ae8 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Sat, 19 Apr 2014 12:06:27 +0200 +Subject: [PATCH] 0001-python3-added-compatibility.3.patch + +--- + unoconv | 248 ++++++++++++++++++++++++++++++++++++---------------------------- + 1 file changed, 139 insertions(+), 109 deletions(-) + +diff --git a/unoconv b/unoconv +index 30e6706..a13db44 100755 +--- a/unoconv ++++ b/unoconv +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/python3 + + ### This program is free software; you can redistribute it and/or modify + ### it under the terms of the GNU General Public License as published by +-- +1.9.0 + diff --git a/0001-update-FSF-address.patch b/0001-update-FSF-address.patch new file mode 100644 index 0000000..b1c357b --- /dev/null +++ b/0001-update-FSF-address.patch @@ -0,0 +1,147 @@ +From 4be0b90f1935120e4f9196b6fc126248079cbf11 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Mon, 5 Nov 2012 15:08:24 +0100 +Subject: [PATCH] update FSF address + +--- + COPYING | 41 ++++++++++++++++++++--------------------- + unoconv | 3 ++- + 2 files changed, 22 insertions(+), 22 deletions(-) + +diff --git a/COPYING b/COPYING +index d60c31a..d159169 100644 +--- a/COPYING ++++ b/COPYING +@@ -1,12 +1,12 @@ +- GNU GENERAL PUBLIC LICENSE +- Version 2, June 1991 ++ GNU GENERAL PUBLIC LICENSE ++ Version 2, June 1991 + +- Copyright (C) 1989, 1991 Free Software Foundation, Inc. +- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ Copyright (C) 1989, 1991 Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +- Preamble ++ Preamble + + The licenses for most software are designed to take away your + freedom to share and change it. By contrast, the GNU General Public +@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This + General Public License applies to most of the Free Software + Foundation's software and to any other program whose authors commit to + using it. (Some other Free Software Foundation software is covered by +-the GNU Library General Public License instead.) You can apply it to ++the GNU Lesser General Public License instead.) You can apply it to + your programs, too. + + When we speak of free software, we are referring to freedom, not +@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and + modification follow. +- +- GNU GENERAL PUBLIC LICENSE ++ ++ GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) +- ++ + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Program, + and can be reasonably considered independent and separate works in +@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. +- ++ + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is +@@ -225,7 +225,7 @@ impose that choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. +- ++ + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License +@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals + of preserving the free status of all derivatives of our free software and + of promoting the sharing and reuse of software generally. + +- NO WARRANTY ++ NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER + PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + +- END OF TERMS AND CONDITIONS +- +- How to Apply These Terms to Your New Programs ++ END OF TERMS AND CONDITIONS ++ ++ How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest + possible use to the public, the best way to achieve this is to make it +@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +- You should have received a copy of the GNU General Public License +- along with this program; if not, write to the Free Software +- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +- ++ You should have received a copy of the GNU General Public License along ++ with this program; if not, write to the Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Also add information on how to contact you by electronic and paper mail. + + If the program is interactive, make it output a short notice like this + when it starts in an interactive mode: + +- Gnomovision version 69, Copyright (C) year name of author ++ Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. +@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names: + This General Public License does not permit incorporating your program into + proprietary programs. If your program is a subroutine library, you may + consider it more useful to permit linking proprietary applications with the +-library. If this is what you want to do, use the GNU Library General ++library. If this is what you want to do, use the GNU Lesser General + Public License instead of this License. +diff --git a/unoconv b/unoconv +index 30e6706..e4a1ac8 100755 +--- a/unoconv ++++ b/unoconv +@@ -11,7 +11,8 @@ + ### + ### You should have received a copy of the GNU General Public License + ### along with this program; if not, write to the Free Software +-### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++### Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++### MA 02110-1301 USA. + ### Copyright 2007-2010 Dag Wieers + + from __future__ import print_function +-- +1.7.11.7 + diff --git a/0002-remove-export-formats-dropped-by-LibreOffice.patch b/0002-remove-export-formats-dropped-by-LibreOffice.patch new file mode 100644 index 0000000..22fc6a6 --- /dev/null +++ b/0002-remove-export-formats-dropped-by-LibreOffice.patch @@ -0,0 +1,105 @@ +From da17429f0deed3999ffeb98fc0f3688c6e413765 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Sat, 19 Apr 2014 11:26:26 +0200 +Subject: [PATCH 2/2] remove export formats dropped by LibreOffice + +--- + unoconv | 32 -------------------------------- + 1 file changed, 32 deletions(-) + +diff --git a/unoconv b/unoconv +index dd73799..a5d29da 100755 +--- a/unoconv ++++ b/unoconv +@@ -358,21 +358,13 @@ fmts.add('document', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki') + fmts.add('document', 'odt', 'odt', 'ODF Text Document', 'writer8') ### 10 + fmts.add('document', 'ooxml', 'xml', 'Microsoft Office Open XML', 'MS Word 2003 XML') ### 11 + fmts.add('document', 'ott', 'ott', 'Open Document Text', 'writer8_template') ### 21 +-fmts.add('document', 'pdb', 'pdb', 'AportisDoc (Palm)', 'AportisDoc Palm DB') + fmts.add('document', 'pdf', 'pdf', 'Portable Document Format', 'writer_pdf_Export') ### 18 +-fmts.add('document', 'psw', 'psw', 'Pocket Word', 'PocketWord File') + fmts.add('document', 'rtf', 'rtf', 'Rich Text Format', 'Rich Text Format') ### 16 +-fmts.add('document', 'sdw', 'sdw', 'StarWriter 5.0', 'StarWriter 5.0') ### 23 +-fmts.add('document', 'sdw4', 'sdw', 'StarWriter 4.0', 'StarWriter 4.0') ### 2 +-fmts.add('document', 'sdw3', 'sdw', 'StarWriter 3.0', 'StarWriter 3.0') ### 20 + fmts.add('document', 'stw', 'stw', 'Open Office.org 1.0 Text Document Template', 'writer_StarOffice_XML_Writer_Template') ### 9 + fmts.add('document', 'sxw', 'sxw', 'Open Office.org 1.0 Text Document', 'StarOffice XML (Writer)') ### 1 + fmts.add('document', 'text', 'txt', 'Text Encoded', 'Text (encoded)') ### 26 + fmts.add('document', 'txt', 'txt', 'Text', 'Text') ### 34 + fmts.add('document', 'uot', 'uot', 'Unified Office Format text','UOF text') ### 27 +-fmts.add('document', 'vor', 'vor', 'StarWriter 5.0 Template', 'StarWriter 5.0 Vorlage/Template') ### 6 +-fmts.add('document', 'vor4', 'vor', 'StarWriter 4.0 Template', 'StarWriter 4.0 Vorlage/Template') ### 5 +-fmts.add('document', 'vor3', 'vor', 'StarWriter 3.0 Template', 'StarWriter 3.0 Vorlage/Template') ### 4 + fmts.add('document', 'xhtml', 'html', 'XHTML Document', 'XHTML Writer File') ### 33 + fmts.add('document', 'epub', 'epub', 'Electronic Publication', 'EPUB') + +@@ -382,14 +374,9 @@ fmts.add('web', 'html', 'html', 'HTML Document', 'HTML') ### 2 + fmts.add('web', 'html', 'html', 'HTML Document Template', 'writerweb8_writer_template') ### 13 + fmts.add('web', 'mediawiki', 'txt', 'MediaWiki', 'MediaWiki_Web') ### 9 + fmts.add('web', 'pdf', 'pdf', 'PDF - Portable Document Format', 'writer_web_pdf_Export') ### 10 +-fmts.add('web', 'sdw3', 'sdw', 'StarWriter 3.0 (OpenOffice.org Writer/Web)', 'StarWriter 3.0 (StarWriter/Web)') ### 3 +-fmts.add('web', 'sdw4', 'sdw', 'StarWriter 4.0 (OpenOffice.org Writer/Web)', 'StarWriter 4.0 (StarWriter/Web)') ### 4 +-fmts.add('web', 'sdw', 'sdw', 'StarWriter 5.0 (OpenOffice.org Writer/Web)', 'StarWriter 5.0 (StarWriter/Web)') ### 5 + fmts.add('web', 'txt', 'txt', 'OpenOffice.org Text (OpenOffice.org Writer/Web)', 'writerweb8_writer') ### 12 + fmts.add('web', 'text10', 'txt', 'OpenOffice.org 1.0 Text Document (OpenOffice.org Writer/Web)', 'writer_web_StarOffice_XML_Writer') ### 15 + fmts.add('web', 'text', 'txt', 'Text (OpenOffice.org Writer/Web)', 'Text (StarWriter/Web)') ### 8 +-fmts.add('web', 'vor4', 'vor', 'StarWriter/Web 4.0 Template', 'StarWriter/Web 4.0 Vorlage/Template') ### 6 +-fmts.add('web', 'vor', 'vor', 'StarWriter/Web 5.0 Template', 'StarWriter/Web 5.0 Vorlage/Template') ### 7 + + ### Spreadsheet + fmts.add('spreadsheet', 'csv', 'csv', 'Text CSV', 'Text - txt - csv (StarCalc)') ### 16 +@@ -401,17 +388,10 @@ fmts.add('spreadsheet', 'ods', 'ods', 'ODF Spreadsheet', 'calc8') ### 15 + fmts.add('spreadsheet', 'ooxml', 'xml', 'Microsoft Excel 2003 XML', 'MS Excel 2003 XML') ### 23 + fmts.add('spreadsheet', 'ots', 'ots', 'ODF Spreadsheet Template', 'calc8_template') ### 14 + fmts.add('spreadsheet', 'pdf', 'pdf', 'Portable Document Format', 'calc_pdf_Export') ### 34 +-fmts.add('spreadsheet', 'pxl', 'pxl', 'Pocket Excel', 'Pocket Excel') +-fmts.add('spreadsheet', 'sdc', 'sdc', 'StarCalc 5.0', 'StarCalc 5.0') ### 31 +-fmts.add('spreadsheet', 'sdc4', 'sdc', 'StarCalc 4.0', 'StarCalc 4.0') ### 11 +-fmts.add('spreadsheet', 'sdc3', 'sdc', 'StarCalc 3.0', 'StarCalc 3.0') ### 29 + fmts.add('spreadsheet', 'slk', 'slk', 'SYLK', 'SYLK') ### 35 + fmts.add('spreadsheet', 'stc', 'stc', 'OpenOffice.org 1.0 Spreadsheet Template', 'calc_StarOffice_XML_Calc_Template') ### 2 + fmts.add('spreadsheet', 'sxc', 'sxc', 'OpenOffice.org 1.0 Spreadsheet', 'StarOffice XML (Calc)') ### 3 + fmts.add('spreadsheet', 'uos', 'uos', 'Unified Office Format spreadsheet', 'UOF spreadsheet') ### 9 +-fmts.add('spreadsheet', 'vor3', 'vor', 'StarCalc 3.0 Template', 'StarCalc 3.0 Vorlage/Template') ### 18 +-fmts.add('spreadsheet', 'vor4', 'vor', 'StarCalc 4.0 Template', 'StarCalc 4.0 Vorlage/Template') ### 19 +-fmts.add('spreadsheet', 'vor', 'vor', 'StarCalc 5.0 Template', 'StarCalc 5.0 Vorlage/Template') ### 20 + fmts.add('spreadsheet', 'xhtml', 'xhtml', 'XHTML', 'XHTML Calc File') ### 26 + fmts.add('spreadsheet', 'xls', 'xls', 'Microsoft Excel 97/2000/XP', 'MS Excel 97') ### 12 + fmts.add('spreadsheet', 'xls5', 'xls', 'Microsoft Excel 5.0', 'MS Excel 5.0/95') ### 8 +@@ -443,12 +423,7 @@ fmts.add('graphics', 'svg', 'svg', 'Scalable Vector Graphics', 'draw_svg_Export' + fmts.add('graphics', 'svm', 'svm', 'StarView Metafile', 'draw_svm_Export') ### 55 + fmts.add('graphics', 'swf', 'swf', 'Macromedia Flash (SWF)', 'draw_flash_Export') ### 23 + fmts.add('graphics', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing', 'StarOffice XML (Draw)') ### 26 +-fmts.add('graphics', 'sxd3', 'sxd', 'StarDraw 3.0', 'StarDraw 3.0') ### 40 +-fmts.add('graphics', 'sxd5', 'sxd', 'StarDraw 5.0', 'StarDraw 5.0') ### 44 +-fmts.add('graphics', 'sxw', 'sxw', 'StarOffice XML (Draw)', 'StarOffice XML (Draw)') + fmts.add('graphics', 'tiff', 'tiff', 'Tagged Image File Format', 'draw_tif_Export') ### 13 +-fmts.add('graphics', 'vor', 'vor', 'StarDraw 5.0 Template', 'StarDraw 5.0 Vorlage') ### 36 +-fmts.add('graphics', 'vor3', 'vor', 'StarDraw 3.0 Template', 'StarDraw 3.0 Vorlage') ### 35 + fmts.add('graphics', 'wmf', 'wmf', 'Windows Metafile', 'draw_wmf_Export') ### 8 + fmts.add('graphics', 'xhtml', 'xhtml', 'XHTML', 'XHTML Draw File') ### 45 + fmts.add('graphics', 'xpm', 'xpm', 'X PixMap', 'draw_xpm_Export') ### 19 +@@ -479,9 +454,6 @@ fmts.add('presentation', 'ppt', 'ppt', 'Microsoft PowerPoint 97/2000/XP', 'MS Po + fmts.add('presentation', 'pwp', 'pwp', 'PlaceWare', 'placeware_Export') ### 30 + fmts.add('presentation', 'ras', 'ras', 'Sun Raster Image', 'impress_ras_Export') ### 27 + fmts.add('presentation', 'sda', 'sda', 'StarDraw 5.0 (OpenOffice.org Impress)', 'StarDraw 5.0 (StarImpress)') ### 8 +-fmts.add('presentation', 'sdd', 'sdd', 'StarImpress 5.0', 'StarImpress 5.0') ### 6 +-fmts.add('presentation', 'sdd3', 'sdd', 'StarDraw 3.0 (OpenOffice.org Impress)', 'StarDraw 3.0 (StarImpress)') ### 42 +-fmts.add('presentation', 'sdd4', 'sdd', 'StarImpress 4.0', 'StarImpress 4.0') ### 37 + fmts.add('presentation', 'sxd', 'sxd', 'OpenOffice.org 1.0 Drawing (OpenOffice.org Impress)', 'impress_StarOffice_XML_Draw') ### 31 + fmts.add('presentation', 'sti', 'sti', 'OpenOffice.org 1.0 Presentation Template', 'impress_StarOffice_XML_Impress_Template') ### 5 + fmts.add('presentation', 'svg', 'svg', 'Scalable Vector Graphics', 'impress_svg_Export') ### 14 +@@ -490,10 +462,6 @@ fmts.add('presentation', 'swf', 'swf', 'Macromedia Flash (SWF)', 'impress_flash_ + fmts.add('presentation', 'sxi', 'sxi', 'OpenOffice.org 1.0 Presentation', 'StarOffice XML (Impress)') ### 41 + fmts.add('presentation', 'tiff', 'tiff', 'Tagged Image File Format', 'impress_tif_Export') ### 12 + fmts.add('presentation', 'uop', 'uop', 'Unified Office Format presentation', 'UOF presentation') ### 4 +-fmts.add('presentation', 'vor', 'vor', 'StarImpress 5.0 Template', 'StarImpress 5.0 Vorlage') ### 40 +-fmts.add('presentation', 'vor3', 'vor', 'StarDraw 3.0 Template (OpenOffice.org Impress)', 'StarDraw 3.0 Vorlage (StarImpress)') ###1 +-fmts.add('presentation', 'vor4', 'vor', 'StarImpress 4.0 Template', 'StarImpress 4.0 Vorlage') ### 39 +-fmts.add('presentation', 'vor5', 'vor', 'StarDraw 5.0 Template (OpenOffice.org Impress)', 'StarDraw 5.0 Vorlage (StarImpress)') ### 2 + fmts.add('presentation', 'wmf', 'wmf', 'Windows Metafile', 'impress_wmf_Export') ### 11 + fmts.add('presentation', 'xhtml', 'xml', 'XHTML', 'XHTML Impress File') ### 33 + fmts.add('presentation', 'xpm', 'xpm', 'X PixMap', 'impress_xpm_Export') ### 10 +-- +1.9.0 + diff --git a/Makefile b/Makefile deleted file mode 100644 index 3c076e8..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: unoconv -# $Id$ -NAME := unoconv -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/package.cfg b/package.cfg deleted file mode 100644 index 66ea79d..0000000 --- a/package.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[koji] -targets = epel8 epel8-playground \ No newline at end of file diff --git a/sources b/sources index e69de29..c565d13 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +SHA512 (0.9.0.tar.gz) = 37d63ada32675fd0ebd089a74db453fdb7332a24e62cbf3e060d6d15cc503c76ede9ccc5e09467f4a38833a8358c09fde23cc8780a77c343268f20e0c37f2469 diff --git a/unoconv.spec b/unoconv.spec new file mode 100644 index 0000000..03e17f6 --- /dev/null +++ b/unoconv.spec @@ -0,0 +1,177 @@ +Summary: A tool to convert documents from/to any format supported by LibreOffice +Name: unoconv +Version: 0.9.0 +Release: 2%{?dist} +License: GPLv2 +URL: https://github.com/unoconv/unoconv/ +Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz + +Patch0: 0001-python3-added-compatibility.patch +Patch1: 0001-update-FSF-address.patch +Patch2: 0001-make-LaTeX-export-usable-with-writer2latex-ext.patch +Patch3: 0001-libreoffice-or-OO.o-has-never-had-wps-export.patch +Patch4: 0002-remove-export-formats-dropped-by-LibreOffice.patch + +BuildArch: noarch + +BuildRequires: asciidoc +BuildRequires: xmlto + +Requires: libreoffice-filters +Requires: libreoffice-pyuno +Suggests: libreoffice-writer2latex +Suggests: openoffice.org-diafilter + +%description +Universal Office Converter (unoconv) is a command line tool to convert any +document format that LibreOffice can import to any document format that +LibreOffice can export. It makes use of the LibreOffice's UNO bindings for +non-interactive conversion of documents. + +Supported document formats include Open Document Format (.odg, .odp, .ods, +.odt), MS Word (.doc), MS Office Open/MS OOXML (.docx, .pptx, .xlsx), PDF, +HTML, RTF, and many more. + +%prep +%autosetup -p1 +rm doc/%{name}.1 + +%build +make %{?_smp_mflags} +asciidoc README.adoc + +%install +make install DESTDIR="%{buildroot}" + +%files +%doc AUTHORS ChangeLog README.html +%doc doc/errcode.html doc/filters.html doc/formats.html doc/selinux.html +%license COPYING +%{_mandir}/man1/%{name}.1* +%{_bindir}/%{name} + +%changelog +* Sun Dec 22 2019 David Tardon - 0.9.0-2 +- upload fixed tarball + +* Sat Sep 28 2019 David Tardon - 0.9-1 +- new upstream release + +* Sat Aug 31 2019 David Tardon - 0.8.2-1 +- new upstream release + +* Sat Jul 27 2019 Fedora Release Engineering - 0.7-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Sun Feb 03 2019 Fedora Release Engineering - 0.7-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Sat Jul 14 2018 Fedora Release Engineering - 0.7-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri Feb 09 2018 Fedora Release Engineering - 0.7-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 0.7-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Sat Feb 11 2017 Fedora Release Engineering - 0.7-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Mon Dec 19 2016 Miro Hrončok - 0.7-4 +- Rebuild for Python 3.6 + +* Fri Feb 05 2016 Fedora Release Engineering - 0.7-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Tue Jan 05 2016 David Tardon - 0.7-2 +- don't install obscure filter deps by default + +* Fri Jul 10 2015 David Tardon - 0.7-1 +- new upstream release + +* Fri Jun 19 2015 Fedora Release Engineering - 0.6-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sun Jun 08 2014 Fedora Release Engineering - 0.6-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sat Apr 19 2014 David Tardon - 0.6-10 +- Resolves: rhbz#1076275 unoconv trips over '-f latex' +- do not show unusable export formats + +* Thu Apr 17 2014 David Tardon - 0.6-9 +- Resolves: rhbz#1076275 unonconv trips over '-f latex' + +* Wed Feb 12 2014 David Tardon - 0.6-8 +- Resolves: rhbz#1047539 --stdout option does not work + +* Thu Jan 30 2014 David Tardon - 0.6-7 +- pull in all libreoffice filters + +* Sun Aug 04 2013 Fedora Release Engineering - 0.6-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Tue Jul 23 2013 David Tardon - 0.6-5 +- Resolves: rhbz#987046 drop env from shebang + +* Wed May 29 2013 David Tardon - 0.6-4 +- rhbz#957776 cannot open office documents + +* Mon Apr 08 2013 David Tardon - 0.6-3 +- Resolves: rhbz#947096 unoconv doesn't work with Libreoffice 4.0 + +* Fri Feb 15 2013 Fedora Release Engineering - 0.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Mon Nov 05 2012 David Tardon - 0.6-1 +- new upstream release + +* Sun Jul 22 2012 Fedora Release Engineering - 0.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Mon Mar 26 2012 David Tardon - 0.5-1 +- new upstream release + +* Mon Mar 26 2012 David Tardon - 0.4-6 + +* Sat Jan 14 2012 Fedora Release Engineering - 0.4-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Feb 07 2011 Fedora Release Engineering - 0.4-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Tue Nov 30 2010 Orcan Ogetbil - 0.4-3 +- Add missing Requires on openoffice.org-brand/libreoffice-core. RHBZ#658576 + +* Sat Nov 13 2010 Orcan Ogetbil - 0.4-2 +- Backport some upstream fixes (LD_LIBRARY_PATH issue and -o flag issue) + +* Fri Nov 12 2010 Orcan Ogetbil - 0.4-1 +- Update to 0.4 + +* Sat Oct 30 2010 Caolán McNamara - 0.3-5 +- rebuild for LibreOffice + +* Sun Jul 26 2009 Fedora Release Engineering - 0.3-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Thu May 07 2009 Orcan Ogetbil - 0.3-3 +- Fix rpmlints +- Prepare package for Fedora review + +* Sun Feb 22 2009 Peter Hanecak 0.3-2 +- used %%{?dist} in release number +- license GPLv2 + +* Wed Dec 19 2007 Dag Wieers - 0.3-2 - 5993+/dag +- Fixed openoffice.org2 dependency on RHEL4. + +* Sat Sep 01 2007 Dag Wieers - 0.3-1 +- Updated to release 0.3. + +* Sun May 20 2007 Dag Wieers - 0.2-1 +- Updated to release 0.2. + +* Sat May 19 2007 Dag Wieers - 0.1-1 +- Initial package. (using DAR) From ae2d607aeb001d45e259c081fe5f3dfd9501e5b3 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 31 Jan 2020 02:39:18 +0000 Subject: [PATCH 54/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 03e17f6..9148d0e 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.9.0 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 URL: https://github.com/unoconv/unoconv/ Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz @@ -51,6 +51,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Fri Jan 31 2020 Fedora Release Engineering - 0.9.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + * Sun Dec 22 2019 David Tardon - 0.9.0-2 - upload fixed tarball From 21f8cf544b1218d4ac51e65de90015122aa3b730 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 29 Jul 2020 13:20:06 +0000 Subject: [PATCH 55/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 9148d0e..df17794 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.9.0 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 URL: https://github.com/unoconv/unoconv/ Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz @@ -51,6 +51,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Wed Jul 29 2020 Fedora Release Engineering - 0.9.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Fri Jan 31 2020 Fedora Release Engineering - 0.9.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild From 304426b2522148201db391ee8b3ec037017fb874 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Sat, 9 Jan 2021 00:25:32 +0000 Subject: [PATCH 56/71] Add BuildRequires: make https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot --- unoconv.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/unoconv.spec b/unoconv.spec index df17794..e20a16e 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -14,6 +14,7 @@ Patch4: 0002-remove-export-formats-dropped-by-LibreOffice.patch BuildArch: noarch +BuildRequires: make BuildRequires: asciidoc BuildRequires: xmlto From ed579deeb78573c1feced160baaf38939519033a Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 27 Jan 2021 22:42:23 +0000 Subject: [PATCH 57/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index e20a16e..8484dc8 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.9.0 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2 URL: https://github.com/unoconv/unoconv/ Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Wed Jan 27 2021 Fedora Release Engineering - 0.9.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + * Wed Jul 29 2020 Fedora Release Engineering - 0.9.0-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From f0c29806cb7a18de2af828c471e1bfe715ccde9c Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 23 Jul 2021 20:04:36 +0000 Subject: [PATCH 58/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 8484dc8..11424ce 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.9.0 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2 URL: https://github.com/unoconv/unoconv/ Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Fri Jul 23 2021 Fedora Release Engineering - 0.9.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + * Wed Jan 27 2021 Fedora Release Engineering - 0.9.0-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild From c31a44baae26a6ce9de4f94d01a7fa80477b7e9a Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 22 Jan 2022 03:33:39 +0000 Subject: [PATCH 59/71] - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 11424ce..37c89fc 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.9.0 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2 URL: https://github.com/unoconv/unoconv/ Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sat Jan 22 2022 Fedora Release Engineering - 0.9.0-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + * Fri Jul 23 2021 Fedora Release Engineering - 0.9.0-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild From 5a556492d04dcc64de68151fd8ddf0a725812115 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 23 Jul 2022 11:26:06 +0000 Subject: [PATCH 60/71] Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- unoconv.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 37c89fc..4dd2850 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.9.0 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2 URL: https://github.com/unoconv/unoconv/ Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Sat Jul 23 2022 Fedora Release Engineering - 0.9.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + * Sat Jan 22 2022 Fedora Release Engineering - 0.9.0-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild From e4d96466c9fb7bde2ec3d52d8220da132cd1ea2d Mon Sep 17 00:00:00 2001 From: David Tardon Date: Mon, 21 Nov 2022 20:24:16 +0100 Subject: [PATCH 61/71] Convert license to SPDX --- unoconv.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unoconv.spec b/unoconv.spec index 4dd2850..c879156 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,8 +1,8 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.9.0 -Release: 8%{?dist} -License: GPLv2 +Release: 9%{?dist} +License: GPL-2.0-only URL: https://github.com/unoconv/unoconv/ Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz @@ -52,6 +52,9 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog +* Mon Nov 21 2022 David Tardon - 0.9.0-9 +- Convert license to SPDX + * Sat Jul 23 2022 Fedora Release Engineering - 0.9.0-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild From 30266292fa4b597698efab695dc4a99e69124390 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Mon, 21 Nov 2022 20:24:18 +0100 Subject: [PATCH 62/71] Convert to rpmautospec --- changelog | 145 +++++++++++++++++++++++++++++++++++++++++++++++++ unoconv.spec | 148 +-------------------------------------------------- 2 files changed, 147 insertions(+), 146 deletions(-) create mode 100644 changelog diff --git a/changelog b/changelog new file mode 100644 index 0000000..31d4940 --- /dev/null +++ b/changelog @@ -0,0 +1,145 @@ +* Mon Nov 21 2022 David Tardon - 0.9.0-9 +- Convert license to SPDX + +* Sat Jul 23 2022 Fedora Release Engineering - 0.9.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Sat Jan 22 2022 Fedora Release Engineering - 0.9.0-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Fri Jul 23 2021 Fedora Release Engineering - 0.9.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Wed Jan 27 2021 Fedora Release Engineering - 0.9.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Wed Jul 29 2020 Fedora Release Engineering - 0.9.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Fri Jan 31 2020 Fedora Release Engineering - 0.9.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Sun Dec 22 2019 David Tardon - 0.9.0-2 +- upload fixed tarball + +* Sat Sep 28 2019 David Tardon - 0.9-1 +- new upstream release + +* Sat Aug 31 2019 David Tardon - 0.8.2-1 +- new upstream release + +* Sat Jul 27 2019 Fedora Release Engineering - 0.7-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Sun Feb 03 2019 Fedora Release Engineering - 0.7-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Sat Jul 14 2018 Fedora Release Engineering - 0.7-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri Feb 09 2018 Fedora Release Engineering - 0.7-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 0.7-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Sat Feb 11 2017 Fedora Release Engineering - 0.7-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Mon Dec 19 2016 Miro Hrončok - 0.7-4 +- Rebuild for Python 3.6 + +* Fri Feb 05 2016 Fedora Release Engineering - 0.7-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Tue Jan 05 2016 David Tardon - 0.7-2 +- don't install obscure filter deps by default + +* Fri Jul 10 2015 David Tardon - 0.7-1 +- new upstream release + +* Fri Jun 19 2015 Fedora Release Engineering - 0.6-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sun Jun 08 2014 Fedora Release Engineering - 0.6-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sat Apr 19 2014 David Tardon - 0.6-10 +- Resolves: rhbz#1076275 unoconv trips over '-f latex' +- do not show unusable export formats + +* Thu Apr 17 2014 David Tardon - 0.6-9 +- Resolves: rhbz#1076275 unonconv trips over '-f latex' + +* Wed Feb 12 2014 David Tardon - 0.6-8 +- Resolves: rhbz#1047539 --stdout option does not work + +* Thu Jan 30 2014 David Tardon - 0.6-7 +- pull in all libreoffice filters + +* Sun Aug 04 2013 Fedora Release Engineering - 0.6-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Tue Jul 23 2013 David Tardon - 0.6-5 +- Resolves: rhbz#987046 drop env from shebang + +* Wed May 29 2013 David Tardon - 0.6-4 +- rhbz#957776 cannot open office documents + +* Mon Apr 08 2013 David Tardon - 0.6-3 +- Resolves: rhbz#947096 unoconv doesn't work with Libreoffice 4.0 + +* Fri Feb 15 2013 Fedora Release Engineering - 0.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Mon Nov 05 2012 David Tardon - 0.6-1 +- new upstream release + +* Sun Jul 22 2012 Fedora Release Engineering - 0.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Mon Mar 26 2012 David Tardon - 0.5-1 +- new upstream release + +* Mon Mar 26 2012 David Tardon - 0.4-6 + +* Sat Jan 14 2012 Fedora Release Engineering - 0.4-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Feb 07 2011 Fedora Release Engineering - 0.4-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Tue Nov 30 2010 Orcan Ogetbil - 0.4-3 +- Add missing Requires on openoffice.org-brand/libreoffice-core. RHBZ#658576 + +* Sat Nov 13 2010 Orcan Ogetbil - 0.4-2 +- Backport some upstream fixes (LD_LIBRARY_PATH issue and -o flag issue) + +* Fri Nov 12 2010 Orcan Ogetbil - 0.4-1 +- Update to 0.4 + +* Sat Oct 30 2010 Caolán McNamara - 0.3-5 +- rebuild for LibreOffice + +* Sun Jul 26 2009 Fedora Release Engineering - 0.3-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Thu May 07 2009 Orcan Ogetbil - 0.3-3 +- Fix rpmlints +- Prepare package for Fedora review + +* Sun Feb 22 2009 Peter Hanecak 0.3-2 +- used %%{?dist} in release number +- license GPLv2 + +* Wed Dec 19 2007 Dag Wieers - 0.3-2 - 5993+/dag +- Fixed openoffice.org2 dependency on RHEL4. + +* Sat Sep 01 2007 Dag Wieers - 0.3-1 +- Updated to release 0.3. + +* Sun May 20 2007 Dag Wieers - 0.2-1 +- Updated to release 0.2. + +* Sat May 19 2007 Dag Wieers - 0.1-1 +- Initial package. (using DAR) diff --git a/unoconv.spec b/unoconv.spec index c879156..4bd034a 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -1,7 +1,7 @@ Summary: A tool to convert documents from/to any format supported by LibreOffice Name: unoconv Version: 0.9.0 -Release: 9%{?dist} +Release: %autorelease License: GPL-2.0-only URL: https://github.com/unoconv/unoconv/ Source: https://github.com/unoconv/unoconv/archive/%{version}.tar.gz @@ -52,148 +52,4 @@ make install DESTDIR="%{buildroot}" %{_bindir}/%{name} %changelog -* Mon Nov 21 2022 David Tardon - 0.9.0-9 -- Convert license to SPDX - -* Sat Jul 23 2022 Fedora Release Engineering - 0.9.0-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - -* Sat Jan 22 2022 Fedora Release Engineering - 0.9.0-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - -* Fri Jul 23 2021 Fedora Release Engineering - 0.9.0-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - -* Wed Jan 27 2021 Fedora Release Engineering - 0.9.0-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - -* Wed Jul 29 2020 Fedora Release Engineering - 0.9.0-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - -* Fri Jan 31 2020 Fedora Release Engineering - 0.9.0-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild - -* Sun Dec 22 2019 David Tardon - 0.9.0-2 -- upload fixed tarball - -* Sat Sep 28 2019 David Tardon - 0.9-1 -- new upstream release - -* Sat Aug 31 2019 David Tardon - 0.8.2-1 -- new upstream release - -* Sat Jul 27 2019 Fedora Release Engineering - 0.7-10 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - -* Sun Feb 03 2019 Fedora Release Engineering - 0.7-9 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild - -* Sat Jul 14 2018 Fedora Release Engineering - 0.7-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild - -* Fri Feb 09 2018 Fedora Release Engineering - 0.7-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - -* Thu Jul 27 2017 Fedora Release Engineering - 0.7-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild - -* Sat Feb 11 2017 Fedora Release Engineering - 0.7-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild - -* Mon Dec 19 2016 Miro Hrončok - 0.7-4 -- Rebuild for Python 3.6 - -* Fri Feb 05 2016 Fedora Release Engineering - 0.7-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - -* Tue Jan 05 2016 David Tardon - 0.7-2 -- don't install obscure filter deps by default - -* Fri Jul 10 2015 David Tardon - 0.7-1 -- new upstream release - -* Fri Jun 19 2015 Fedora Release Engineering - 0.6-12 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild - -* Sun Jun 08 2014 Fedora Release Engineering - 0.6-11 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild - -* Sat Apr 19 2014 David Tardon - 0.6-10 -- Resolves: rhbz#1076275 unoconv trips over '-f latex' -- do not show unusable export formats - -* Thu Apr 17 2014 David Tardon - 0.6-9 -- Resolves: rhbz#1076275 unonconv trips over '-f latex' - -* Wed Feb 12 2014 David Tardon - 0.6-8 -- Resolves: rhbz#1047539 --stdout option does not work - -* Thu Jan 30 2014 David Tardon - 0.6-7 -- pull in all libreoffice filters - -* Sun Aug 04 2013 Fedora Release Engineering - 0.6-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild - -* Tue Jul 23 2013 David Tardon - 0.6-5 -- Resolves: rhbz#987046 drop env from shebang - -* Wed May 29 2013 David Tardon - 0.6-4 -- rhbz#957776 cannot open office documents - -* Mon Apr 08 2013 David Tardon - 0.6-3 -- Resolves: rhbz#947096 unoconv doesn't work with Libreoffice 4.0 - -* Fri Feb 15 2013 Fedora Release Engineering - 0.6-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild - -* Mon Nov 05 2012 David Tardon - 0.6-1 -- new upstream release - -* Sun Jul 22 2012 Fedora Release Engineering - 0.5-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild - -* Mon Mar 26 2012 David Tardon - 0.5-1 -- new upstream release - -* Mon Mar 26 2012 David Tardon - 0.4-6 - -* Sat Jan 14 2012 Fedora Release Engineering - 0.4-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild - -* Mon Feb 07 2011 Fedora Release Engineering - 0.4-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild - -* Tue Nov 30 2010 Orcan Ogetbil - 0.4-3 -- Add missing Requires on openoffice.org-brand/libreoffice-core. RHBZ#658576 - -* Sat Nov 13 2010 Orcan Ogetbil - 0.4-2 -- Backport some upstream fixes (LD_LIBRARY_PATH issue and -o flag issue) - -* Fri Nov 12 2010 Orcan Ogetbil - 0.4-1 -- Update to 0.4 - -* Sat Oct 30 2010 Caolán McNamara - 0.3-5 -- rebuild for LibreOffice - -* Sun Jul 26 2009 Fedora Release Engineering - 0.3-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild - -* Thu May 07 2009 Orcan Ogetbil - 0.3-3 -- Fix rpmlints -- Prepare package for Fedora review - -* Sun Feb 22 2009 Peter Hanecak 0.3-2 -- used %%{?dist} in release number -- license GPLv2 - -* Wed Dec 19 2007 Dag Wieers - 0.3-2 - 5993+/dag -- Fixed openoffice.org2 dependency on RHEL4. - -* Sat Sep 01 2007 Dag Wieers - 0.3-1 -- Updated to release 0.3. - -* Sun May 20 2007 Dag Wieers - 0.2-1 -- Updated to release 0.2. - -* Sat May 19 2007 Dag Wieers - 0.1-1 -- Initial package. (using DAR) +%autochangelog From 89d9cb7460796638a5087f077e0987eeb96b3282 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 21 Jan 2023 05:51:27 +0000 Subject: [PATCH 63/71] Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild Signed-off-by: Fedora Release Engineering From 6de094c51996d204bf8e82a58f89ac098d4e3c82 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 22 Jul 2023 17:09:29 +0000 Subject: [PATCH 64/71] Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild Signed-off-by: Fedora Release Engineering From 4e42a7778518895959a502fa79c9336b21efed4c Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 27 Jan 2024 07:09:31 +0000 Subject: [PATCH 65/71] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 21ce03b7403e343abf184475e6cbd54b01f4c5ab Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Thu, 29 Feb 2024 13:46:27 -0500 Subject: [PATCH 66/71] Fix flatpak build Flatpaks are built into /app, so %_prefix must be used for installing. --- unoconv.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unoconv.spec b/unoconv.spec index 4bd034a..5dbf050 100644 --- a/unoconv.spec +++ b/unoconv.spec @@ -42,7 +42,7 @@ make %{?_smp_mflags} asciidoc README.adoc %install -make install DESTDIR="%{buildroot}" +make install DESTDIR="%{buildroot}" prefix=%{_prefix} %files %doc AUTHORS ChangeLog README.html From a82df2df5aa7b3e7cd86a5a4048f7318a7efe298 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 20 Jul 2024 08:18:35 +0000 Subject: [PATCH 67/71] Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild From bc3a714e26f93e981631021683c19cc446e2bfcf Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sun, 19 Jan 2025 13:48:40 +0000 Subject: [PATCH 68/71] Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild From 880a421ce2e83f1f76b33b315ec201001e2504dc Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 25 Jul 2025 19:48:37 +0000 Subject: [PATCH 69/71] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild From b06dc5d6b2dcabe2e2e10d53b5edf29f07c1a7e5 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 17 Jan 2026 19:38:00 +0000 Subject: [PATCH 70/71] Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild From 8dcec8459d3415ac669938411fec10356753836a Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 17 Jul 2026 08:12:39 +0000 Subject: [PATCH 71/71] Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild