elexis/elexis-3-base

TextTemplator fails in 3.4

Closed this issue · 4 comments

rgwch commented

In Elexis 3.4, The OpenOffice Processor is not able to launch LibreOffice with a file name as argument. Here's a fix:

diff --git a/ch.medelexis.text.templator/src/ch/medelexis/templator/model/OpenOfficeProcessor.java b/ch.medelexis.text.templator/src/ch/medelexis/templator/model/OpenOfficeProcessor.java
index eeae864..a2d9f52 100644
--- a/ch.medelexis.text.templator/src/ch/medelexis/templator/model/OpenOfficeProcessor.java
+++ b/ch.medelexis.text.templator/src/ch/medelexis/templator/model/OpenOfficeProcessor.java
@@ -14,6 +14,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.InputStream;
 import java.text.MessageFormat;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
@@ -78,9 +79,14 @@
 			if (i != -1) {
 				param = param.substring(0, i) + output.getAbsolutePath() + param.substring(i + 1);
 			}
-			/* Process process = */Runtime.getRuntime().exec(new String[] {
-				cmd, param
-			});
+			String[] params_=param.split(" +");
+			String[] params=new String[params_.length+1];
+			params[0]=cmd;
+			for(i=0;i<params_.length;i++){
+				params[i+1]=params_[i];
+			}
+					
+			/* Process process = */ Runtime.getRuntime().exec(params);
 			return true;
 		} catch (Exception e) {
 			ExHandler.handle(e);

Discussion: This splits the command line parameters which were concatenated incorrectly. Obviously, java 8 or LibreOffice treats this more strictly now
(The error message was: Error in option: --nologo --writer /tmp/elexis3751865523900345250templator.odt)

I'd like to have a look at this, but I have only LibreOffice installed. Does LibreOffice generally work (no swriter here, only soffice)?

rgwch commented

I have also LibreOffice here. You run the writer with: soffice --writer --nologo or with libreoffice --writer

I've set up the PreferencePage "Textverarbeitung/Schablonenprozessor/OpenOffice.org Processor" as follows: "Befehl: libreoffice", "Parameter: --nologo --writer %"

Thanks a lot! I could re-enact it. I did some minor modifications to the documentation where I was confused resp. configuration and applied your patch to master! Will backport to 3.4 asap!

rgwch commented

Great, thanks!