[OFBiz] SVN: r7237 - in trunk/applications/content: src/org/ofbiz/content/openoffice widget/compdoc
jonesde@svn.ofbiz.org
jonesde at svn.ofbiz.org
Sat Apr 8 02:16:17 CDT 2006
Author: jonesde
Date: 2006-04-08 02:16:12 -0500 (Sat, 08 Apr 2006)
New Revision: 7237
Modified:
trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java
trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java
trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java
trunk/applications/content/widget/compdoc/CompDocScreens.xml
Log:
A few cleanups and fixes in the CompDoc and OpenOffice stuff; still doing OO UNO testing
Modified: trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java
===================================================================
--- trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java 2006-04-07 18:50:13 UTC (rev 7236)
+++ trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java 2006-04-08 07:16:12 UTC (rev 7237)
@@ -29,10 +29,6 @@
* OpenOfficeByteArrayInputStream Class
*
* @author <a href="mailto:byersa at automationgroups.com">Al Byers</a>
- * @version $Rev: 5462 $
- * @since 3.2
- *
- *
*/
public class OpenOfficeByteArrayInputStream extends ByteArrayInputStream implements XInputStream, XSeekable {
Modified: trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java
===================================================================
--- trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java 2006-04-07 18:50:13 UTC (rev 7236)
+++ trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java 2006-04-08 07:16:12 UTC (rev 7237)
@@ -48,10 +48,6 @@
* OpenOfficeServices Class
*
* @author <a href="mailto:byersa at automationgroups.com">Al Byers</a>
- * @version $Rev: 5462 $
- * @since 3.2
- *
- *
*/
public class OpenOfficeServices {
public static final String module = OpenOfficeServices.class.getName();
@@ -65,14 +61,16 @@
ByteWrapper inByteWrapper = (ByteWrapper) context.get("inByteWrapper");
String inputMimeType = (String) context.get("inputMimeType");
String outputMimeType = (String) context.get("outputMimeType");
+
+ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it
String oooHost = (String) context.get("oooHost");
- if (UtilValidate.isEmpty(oooHost)) oooHost = "localhost";
String oooPort = (String) context.get("oooPort");
- if (UtilValidate.isEmpty(oooPort)) oooPort = "8100";
try {
xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort);
- OpenOfficeByteArrayInputStream oobais = new OpenOfficeByteArrayInputStream(inByteWrapper.getBytes());
+ byte[] inByteArray = inByteWrapper.getBytes();
+ OpenOfficeByteArrayInputStream oobais = new OpenOfficeByteArrayInputStream(inByteArray);
+ Debug.logInfo("Doing convertDocumentByteWrapper, inBytes size is [" + inByteArray.length + "]", module);
OpenOfficeByteArrayOutputStream oobaos = OpenOfficeWorker.convertOODocByteStreamToByteStream(xmulticomponentfactory, oobais, inputMimeType, outputMimeType);
Map results = ServiceUtil.returnSuccess();
@@ -99,10 +97,10 @@
String stringUrl = "file:///" + context.get("filenameFrom");
String stringConvertedFile = "file:///" + context.get("filenameTo");
String filterName = "file:///" + context.get("filterName");
+
+ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it
String oooHost = (String) context.get("oooHost");
- if (UtilValidate.isEmpty(oooHost)) oooHost = "localhost";
String oooPort = (String) context.get("oooPort");
- if (UtilValidate.isEmpty(oooPort)) oooPort = "8100";
try {
xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort);
@@ -129,10 +127,10 @@
String stringConvertedFile = (String) context.get("filenameTo");
String inputMimeType = (String) context.get("inputMimeType");
String outputMimeType = (String) context.get("outputMimeType");
+
+ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it
String oooHost = (String) context.get("oooHost");
- if (UtilValidate.isEmpty(oooHost)) oooHost = "localhost";
String oooPort = (String) context.get("oooPort");
- if (UtilValidate.isEmpty(oooPort)) oooPort = "8100";
try {
xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort);
@@ -164,7 +162,6 @@
}
}
-
/**
* Use OpenOffice to convert documents between types
*/
@@ -173,12 +170,12 @@
String stringUrl = "file:///" + context.get("filenameFrom");
String stringConvertedFile = "file:///" + context.get("filenameTo");
- String inputMimeType = (String)context.get("inputMimeType");
- String outputMimeType = (String)context.get("outputMimeType");
- String oooHost = (String)context.get("oooHost");
- if (UtilValidate.isEmpty(oooHost)) oooHost = "localhost";
- String oooPort = (String)context.get("oooPort");
- if (UtilValidate.isEmpty(oooPort)) oooPort = "8100";
+ String inputMimeType = (String) context.get("inputMimeType");
+ String outputMimeType = (String) context.get("outputMimeType");
+
+ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it
+ String oooHost = (String) context.get("oooHost");
+ String oooPort = (String) context.get("oooPort");
try {
xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort);
@@ -219,10 +216,10 @@
String stringUrl = "file:///" + context.get("filenameFrom");
String stringOriginalFile = "file:///" + context.get("filenameOriginal");
String stringOutFile = "file:///" + context.get("filenameOut");
+
+ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it
String oooHost = (String)context.get("oooHost");
- if (UtilValidate.isEmpty(oooHost)) oooHost = "localHost";
String oooPort = (String)context.get("oooPort");
- if (UtilValidate.isEmpty(oooPort)) oooPort = "8100";
try {
xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort);
Modified: trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java
===================================================================
--- trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java 2006-04-07 18:50:13 UTC (rev 7236)
+++ trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java 2006-04-08 07:16:12 UTC (rev 7237)
@@ -17,7 +17,6 @@
*/
package org.ofbiz.content.openoffice;
-
import java.io.IOException;
import java.util.List;
@@ -40,25 +39,26 @@
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
-
/**
* OpenOfficeWorker Class
*
+ * Note that for this to work you must start OpenOffice with a command such as the following:
+ * <code>soffice -accept=socket,host=localhost,port=8100;urp;</code>
+ *
* @author <a href="mailto:byersa at automationgroups.com">Al Byers</a>
- * @version $Rev: 5462 $
- * @since 3.2
- *
- *
*/
public class OpenOfficeWorker{
public static final String module = OpenOfficeWorker.class.getName();
-
+
/**
* Use OpenOffice to convert documents between types
*/
public static XMultiComponentFactory getRemoteServer(String host, String port) throws IOException, Exception {
+ if (UtilValidate.isEmpty(host)) host = UtilProperties.getPropertyValue("openoffice-uno", "oo.host", "localhost");
+ if (UtilValidate.isEmpty(port)) port = UtilProperties.getPropertyValue("openoffice-uno", "oo.port", "8100");
+
XMultiComponentFactory xmulticomponentfactory = null;
XComponentContext xcomponentcontext = null;
Object objectUrlResolver = null;
@@ -91,9 +91,9 @@
xmulticomponentfactory = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class, objectInitial);
} catch(Exception e) {
// TODO: None of this works. Need a programmable start solution.
- //String ooxvfb = UtilProperties.getPropertyValue("openoffice", "oo.start.xvfb");
- //String ooexport = UtilProperties.getPropertyValue("openoffice", "oo.start.export");
- String oosoffice = UtilProperties.getPropertyValue("openoffice", "oo.start.soffice");
+ //String ooxvfb = UtilProperties.getPropertyValue("openoffice-uno", "oo.start.xvfb");
+ //String ooexport = UtilProperties.getPropertyValue("openoffice-uno", "oo.start.export");
+ String oosoffice = UtilProperties.getPropertyValue("openoffice-uno", "oo.start.soffice");
//Process procXvfb = Runtime.getRuntime().exec(ooxvfb);
//Process procExport = Runtime.getRuntime().exec(ooexport);
/*
@@ -238,21 +238,27 @@
XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj);
// Preparing properties for loading the document
- PropertyValue propertyvalue[] = new PropertyValue[ 2 ];
+ PropertyValue propertyvalue[] = new PropertyValue[2];
// Setting the flag for hidding the open document
- propertyvalue[ 0 ] = new PropertyValue();
- propertyvalue[ 0 ].Name = "Hidden";
- propertyvalue[ 0 ].Value = new Boolean(true);
+ propertyvalue[0] = new PropertyValue();
+ propertyvalue[0].Name = "Hidden";
+ propertyvalue[0].Value = Boolean.TRUE;
//
- propertyvalue[ 1 ] = new PropertyValue();
- propertyvalue[ 1 ].Name = "InputStream";
- propertyvalue[ 1 ].Value = is;
+ propertyvalue[1] = new PropertyValue();
+ propertyvalue[1].Name = "InputStream";
+ propertyvalue[1].Value = is;
// Loading the wanted document
Object objectDocumentToStore = xcomponentloader.loadComponentFromURL("private:stream", "_blank", 0, propertyvalue);
+ if (objectDocumentToStore == null) {
+ Debug.logError("Could not get objectDocumentToStore object from xcomponentloader.loadComponentFromURL", module);
+ }
// Getting an object that will offer a simple way to store a document to a URL.
XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore);
+ if (xstorable == null) {
+ Debug.logError("Could not get XStorable object from UnoRuntime.queryInterface", module);
+ }
// Preparing properties for converting the document
String filterName = "";
@@ -267,26 +273,25 @@
} else {
filterName = "HTML";
}
- propertyvalue = new PropertyValue[ 4 ];
+ propertyvalue = new PropertyValue[4];
+ propertyvalue[0] = new PropertyValue();
+ propertyvalue[0].Name = "OutputStream";
+ OpenOfficeByteArrayOutputStream os = new OpenOfficeByteArrayOutputStream();
+ propertyvalue[0].Value = os;
+ // Setting the filter name
+ propertyvalue[1] = new PropertyValue();
+ propertyvalue[1].Name = "FilterName";
+ propertyvalue[1].Value = filterName;
// Setting the flag for overwriting
- propertyvalue[ 3 ] = new PropertyValue();
- propertyvalue[ 3 ].Name = "Overwrite";
- propertyvalue[ 3 ].Value = new Boolean(true);
- // Setting the filter name
- propertyvalue[ 1 ] = new PropertyValue();
- propertyvalue[ 1 ].Name = "FilterName";
- propertyvalue[ 1 ].Value = filterName;
+ propertyvalue[3] = new PropertyValue();
+ propertyvalue[3].Name = "Overwrite";
+ propertyvalue[3].Value = Boolean.TRUE;
// For PDFs
- propertyvalue[ 2 ] = new PropertyValue();
- propertyvalue[ 2 ].Name = "CompressionMode";
- propertyvalue[ 2 ].Value = "1";
+ propertyvalue[2] = new PropertyValue();
+ propertyvalue[2].Name = "CompressionMode";
+ propertyvalue[2].Value = "1";
- propertyvalue[ 0 ] = new PropertyValue();
- propertyvalue[ 0 ].Name = "OutputStream";
- OpenOfficeByteArrayOutputStream os = new OpenOfficeByteArrayOutputStream();
- propertyvalue[ 0 ].Value = os;
-
xstorable.storeToURL("private:stream", propertyvalue);
//xstorable.storeToURL("file:///home/byersa/testdoc1_file.pdf", propertyvalue);
Modified: trunk/applications/content/widget/compdoc/CompDocScreens.xml
===================================================================
--- trunk/applications/content/widget/compdoc/CompDocScreens.xml 2006-04-07 18:50:13 UTC (rev 7236)
+++ trunk/applications/content/widget/compdoc/CompDocScreens.xml 2006-04-08 07:16:12 UTC (rev 7237)
@@ -790,7 +790,7 @@
</screen>
<screen name="AddRootCompDocTemplate">
<section>
- <condition>
+ <condition>
<if-has-permission permission="CONTENTMGR" action="CREATE"/>
</condition>
<actions>
@@ -826,11 +826,14 @@
<get-related-one value-name="templateContent" relation-name="DataResource" to-value-name="templateDataResource"/>
<set field="templateDataResourceTypeId" from-field="templateDataResource.dataResourceTypeId"/>
<set field="mimeTypeId" from-field="templateDataResource.mimeTypeId"/>
+
<set field="contentAssocTypeId" value="COMPDOC_PART"/>
<set field="contentTypeId" value="DOCUMENT"/>
<set field="sequenceNum" from-field="parameters.caSequenceNum" default-value="${parameters.sequenceNum}"/>
<set field="childCompDocTarget" value="createChildCompDocInstance"/>
<set field="contentId" from-field="parameters.contentId"/>
+
+ <set field="rootContentId" from-field="parameters.rootContentId" default-value="${parameters.contentIdTo}"/>
</actions>
<widgets>
<decorator-screen name="commonCompDocDecorator" location="component://content/widget/CommonScreens.xml">
More information about the Svn
mailing list