Hi,
I have a patch ready to
1.) new format (pdf9) + conversion 'docbook5->pdf9'
  This is using pandoc, so that one can display the docbook data
2.) A wrapper/filter around ssconvert for converting spreadsheets
  to be inserted in docbook5 documents
  
The first part should be uncontroversial.
For the second there may be objections, because the wrapper is
written in perl.

I'd like to publish, but only if it is acceptable.


        Kornel
diff --git a/development/cmake/Install.cmake b/development/cmake/Install.cmake
index befe55681f..4077c14c05 100755
--- a/development/cmake/Install.cmake
+++ b/development/cmake/Install.cmake
@@ -121,10 +121,13 @@ foreach(_sd "kbd" "layouts" "ui" ".")
 endforeach()
 
 foreach(_sd "lyx2lyx" "scripts" ".")
   lyx_install("data" ${TOP_SRC_DIR}/lib ${_sd}     *.py .  )
 endforeach()
+foreach(_script wssconvert listerrors)
+  lyx_install("data" ${TOP_SRC_DIR}/lib scripts ${_script} . )
+endforeach()
 
 foreach(_imgext "png" "svgz" "gif" "xpm")
   lyx_install("data" ${TOP_SRC_DIR}/lib images       "*.${_imgext}"      . ipa classic oxygen)
   lyx_install("data" ${TOP_SRC_DIR}/lib images/math  "*.${_imgext}"      . oxygen)
 endforeach()
diff --git a/lib/Makefile.am b/lib/Makefile.am
index dca5e0e8c6..3b0bd60784 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2523,11 +2523,12 @@ dist_scripts_DATA += \
 	scripts/prefs2prefs.py \
 	scripts/prefs2prefs_lfuns.py \
 	scripts/prefs2prefs_prefs.py \
 	scripts/prefTest.pl.in \
 	scripts/tex_copy.py \
-	scripts/TeXFiles.py
+	scripts/TeXFiles.py \
+	scripts/wssconvert
 
 templatesdir = $(pkgdatadir)/templates
 dist_templates_DATA = \
 	templates/EPS_%28cropped%29.lyx \
 	templates/PDF_%28cropped%29.lyx \
@@ -2783,11 +2784,11 @@ exampleandtemplate_files = \
 			   $(dist_examples_DATA) \
 			   $(dist_templates_DATA)
 
 install-data-hook:
 	$(CHMOD) 755 $(DESTDIR)$(pkgdatadir)/configure.py
-	for i in $(DESTDIR)$(scriptsdir)/*.py $(DESTDIR)$(scriptsdir)/listerrors ; do \
+	for i in $(DESTDIR)$(scriptsdir)/*.py $(DESTDIR)$(scriptsdir)/listerrors $(DESTDIR)$(scriptsdir)/wssconvert ; do \
 		$(CHMOD) 755 $$i; \
 	done
 	for i in $(exampleandtemplate_files); do \
 		if $(EGREP) -q "^\\\\origin " "$(DESTDIR)$(pkgdatadir)/$$i"; then \
 			origin=`dirname "/systemlyxdir/$$i"`/; \
diff --git a/lib/configure.py b/lib/configure.py
index 7d996be549..0534a35f61 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -711,10 +711,11 @@ def checkFormatEntries(dtl_tools):
     checkViewer('gnumeric spreadsheet software', ['gnumeric'],
       rc_entry = [r'''\Format gnumeric gnumeric "Gnumeric spreadsheet" "" ""    "%%"   "document"	"application/x-gnumeric"
 \Format excel      xls    "Excel spreadsheet"      "" "" "%%"    "document"	"application/vnd.ms-excel"
 \Format excel2     xlsx   "MS Excel Office Open XML" "" "" "%%" "document"	"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
 \Format html_table html   "HTML Table (for spreadsheets)"      "" "" "%%"    "document"	""
+\Format xhtml_table xhtml "XHTML Table (for spreadsheets)"     "" "" "%%"    "document"	""
 \Format oocalc     ods    "OpenDocument spreadsheet" "" "" "%%"    "document"	"application/vnd.oasis.opendocument.spreadsheet"'''])
  #
     checkViewer('an HTML previewer', ['firefox', 'mozilla file://$$p$$i', 'netscape'],
         rc_entry = [r'\Format xhtml      xhtml   "LyXHTML"              y "%%" ""    "document,menu=export"	"application/xhtml+xml"'])
  #
@@ -747,11 +748,12 @@ def checkFormatEntries(dtl_tools):
 \Format pdf3       pdf    "PDF (dvipdfm)"         m  "%%"	""	"document,vector,menu=export"	""
 \Format pdf4       pdf    "PDF (XeTeX)"           X  "%%"	""	"document,vector,menu=export"	""
 \Format pdf5       pdf    "PDF (LuaTeX)"          u  "%%"	""	"document,vector,menu=export"	""
 \Format pdf6       pdf    "PDF (graphics)"        "" "%%"	""	"vector"	"application/pdf"
 \Format pdf7       pdf    "PDF (cropped)"         "" "%%"	""	"document,vector"	""
-\Format pdf8       pdf    "PDF (lower resolution)"         "" "%%"	""	"document,vector"	""'''])
+\Format pdf8       pdf    "PDF (lower resolution)"         "" "%%"	""	"document,vector"	""
+\Format pdf9       pdf    "PDF (docbook)"         "" "%%"	""	"document,vector,menu=export"	""'''])
     #
     checkViewer('a DVI previewer', ['xdvi', 'kdvi', 'okular',
                                     'evince', 'xreader',
                                     'yap', 'dviout -Set=!m'],
         rc_entry = [r'''\Format dvi        dvi     DVI                    D  "%%"	""	"document,vector,menu=export"	"application/x-dvi"
@@ -928,10 +930,13 @@ def checkConverterEntries():
         rc_entry = [ r'\converter odt        latex      "%%"	""' ])
     #
     checkProg('an Open Document (Pandoc) -> LaTeX converter', ['pandoc -s -f odt -o $$o -t latex $$i'],
         rc_entry = [ r'\converter odt3        latex      "%%"	""' ])
     #
+    checkProg('DocBook converter -> PDF (docbook)', ['pandoc -f docbook -t latex --latex-engine=lualatex --toc --template=lyx.latex -o $$o $$i'],
+        rc_entry = [ r'\converter docbook5      pdf9      "%%"	""' ])
+    #
     checkProg('a MS Word Office Open XML converter -> LaTeX', ['pandoc -s -f docx -o $$o -t latex $$i'],
         rc_entry = [ r'\converter word2      latex      "%%"	""' ])
     # Only define a converter to pdf6, otherwise the odt format could be
     # used as an intermediate step for export to pdf, which is not wanted.
     checkProg('an OpenDocument -> PDF converter', ['unoconv -f pdf --stdout $$i > $$o'],
@@ -1161,18 +1166,22 @@ def checkConverterEntries():
         rc_entry = [ r'''\Format gnuplot     "gp, gnuplot"    "Gnuplot"     "" "" ""  "vector"	"text/plain"
 \converter gnuplot      pdf6      "python -tt $$s/scripts/gnuplot2pdf.py $$i $$o"    "needauth"''' ])
     #
     # gnumeric/xls/ods to tex
     checkProg('a spreadsheet -> latex converter', ['ssconvert'],
-       rc_entry = [ r'''\converter gnumeric latex "ssconvert --export-type=Gnumeric_html:latex $$i $$o" ""
-\converter oocalc latex "ssconvert --export-type=Gnumeric_html:latex $$i $$o" ""
-\converter excel  latex "ssconvert --export-type=Gnumeric_html:latex $$i $$o" ""
-\converter excel2 latex "ssconvert --export-type=Gnumeric_html:latex $$i $$o" ""
-\converter gnumeric html_table "ssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
-\converter oocalc html_table "ssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
-\converter excel  html_table "ssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
-\converter excel2 html_table "ssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
+       rc_entry = [ r'''\converter gnumeric latex "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:latex $$i $$o" ""
+\converter oocalc latex "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:latex $$i $$o" ""
+\converter excel  latex "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:latex $$i $$o" ""
+\converter excel2 latex "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:latex $$i $$o" ""
+\converter gnumeric html_table "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
+\converter oocalc html_table "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
+\converter excel  html_table "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
+\converter excel2 html_table "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
+\converter gnumeric xhtml_table "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:xhtml $$i $$o" ""
+\converter oocalc xhtml_table "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:xhtml $$i $$o" ""
+\converter excel  xhtml_table "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:xhtml $$i $$o" ""
+\converter excel2 xhtml_table "perl $$s/scripts/wssconvert --export-type=Gnumeric_html:xhtml $$i $$o" ""
 '''])
 
     path, lilypond = checkProg('a LilyPond -> EPS/PDF/PNG converter', ['lilypond'])
     if (lilypond):
         version_string = cmdOutput("lilypond --version")
diff --git a/lib/scripts/wssconvert b/lib/scripts/wssconvert
new file mode 100644
index 0000000000..f72f9b11d0
--- /dev/null
+++ b/lib/scripts/wssconvert
@@ -0,0 +1,106 @@
+#! /usr/bin/env perl
+
+use strict;
+
+# extracted params
+my @argv = ("ssconvert");
+my $input = undef;
+my $output = undef;
+my $getnext = 0;
+my $first = "undef";		# if ($first eq "prepend") prepend "<p>" else append "<p>"
+my $isexport = 0;
+my $expType1 = "Gnumeric_html:html40frag";
+my $expType2 = "Gnumeric_html:xhtml";
+my $exptype = undef;
+my $stdout = "fd://1";
+my $doFilter = 0;
+
+for my $arg (@ARGV) {
+  if ($getnext) {
+    push(@argv, $arg);
+    $getnext = 0;
+    if ($isexport) {
+      if ($arg =~ $expType1) {
+	$doFilter = 1;
+	$exptype = "html";
+      }
+      elsif ($arg eq $expType2) {
+	$doFilter = 1;
+	$exptype = "xhtml";
+      }
+    }
+  }
+  elsif ($arg =~ /^\-/) {
+    # some option
+    if ($arg =~ /^\-[TOEMS]$/) {
+      # needs a param
+      $getnext = 1;
+      if ($arg eq "-E") {
+	$isexport = 1;
+      }
+    }
+    elsif ($arg =~ /^\-\-export\-type=$expType1/) {
+      $doFilter = 1;
+      $exptype = "html";
+    }
+    elsif ($arg =~ /^\-\-export\-type=$expType2/) {
+      $doFilter = 1;
+      $exptype = "xhtml";
+    }
+    push(@argv, $arg);
+  }
+  else {
+    # input/output handling
+    if (! defined($input)) {
+      $input = $arg;
+      push(@argv, $arg);
+    }
+    elsif (! defined($output)) {
+      $output = $arg;
+    }
+    else {
+      die("Too many params");
+    }
+  }
+}
+
+if ($getnext || ! $doFilter || ! defined($input)) {
+  exit(system($argv[0], @ARGV));
+}
+
+if (! defined($output)) {
+  ($output = $input) =~ s/\.[^\.\/]+$/.$exptype/;
+}
+die("Wrong output") if ($input eq $output);
+push(@argv, $stdout);
+
+if (! open(FI, join(' ', @argv) . "|")) {
+  die("could not start $argv[0]");
+}
+
+my $out;
+if ($output eq $stdout) {
+  $out = *STDOUT;
+}
+else {
+  die("Could not write to $output") if (!open($out, ">", $output));
+}
+print $out "<p>\n" if ($first eq "prepend");
+if ($exptype eq "xhtml") {
+  # discard everything until table start
+  while (my $l = <FI>) {
+    last if ($l =~ /^<body>/);
+  }
+}
+while (my $l = <FI>) {
+  next if ($l =~ /^<caption>Ark/);
+  if ($exptype eq "xhtml") {
+    last if ($l =~ /^<\/body>/);
+  }
+  print $out $l;
+}
+print $out "<p>\n" if ($first eq "append");
+close($out) if ($output ne $stdout);
+close(FI);
+exit(0);
+
diff --git a/lib/xtemplates/gnumeric.xtemplate b/lib/xtemplates/gnumeric.xtemplate
index 56dbe97f60..2bbee1c8d1 100644
--- a/lib/xtemplates/gnumeric.xtemplate
+++ b/lib/xtemplates/gnumeric.xtemplate
@@ -50,11 +50,13 @@ Template GnumericSpreadsheet
 	FormatEnd
 	Format Ascii
 		Product "[Spreadsheet: $$FName]"
 	FormatEnd
 	Format DocBook
-		Product "[Spreadsheet: $$FName]"
+		Product "$$Contents(\"$$AbsPath$$Basename.xhtml\")"
+		UpdateFormat xhtml_table
+		UpdateResult "$$AbsPath$$Basename.xhtml"
 	FormatEnd
 	Format XHTML
 		Product "$$Contents(\"$$AbsPath$$Basename.html\")"
 		UpdateFormat html_table
 		UpdateResult "$$AbsPath$$Basename.html"

Attachment: pgpo53Hg65Xg2.pgp
Description: Digitale Signatur von OpenPGP

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to