DocFormatter : performance fix

This commit is contained in:
Yuriy Artamonov 2011-05-03 14:27:07 +00:00
parent bb247c84dd
commit e01d7097cd
3 changed files with 16 additions and 3 deletions

View File

@ -136,6 +136,8 @@ public class DocFormatter extends AbstractFormatter {
} }
saveXComponent(xComponent, ooos, filterName); saveXComponent(xComponent, ooos, filterName);
closeXComponent(xComponent); closeXComponent(xComponent);
officeComponent.getOfficeConnection().close();
} }
private void fillTables() throws com.sun.star.uno.Exception { private void fillTables() throws com.sun.star.uno.Exception {

View File

@ -16,14 +16,17 @@ import com.sun.star.frame.XDispatchHelper;
import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.Exception; import com.sun.star.uno.Exception;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import ooo.connector.BootstrapSocketConnector;
import static com.haulmont.cuba.report.formatters.oo.ODTUnoConverter.*; import static com.haulmont.cuba.report.formatters.oo.ODTUnoConverter.*;
public class OOOConnection { public class OOOConnection {
private XComponentContext xComponentContext; private XComponentContext xComponentContext;
private BootstrapSocketConnector bsc;
public OOOConnection(XComponentContext xComponentContext) { public OOOConnection(XComponentContext xComponentContext, BootstrapSocketConnector bsc) {
this.xComponentContext = xComponentContext; this.xComponentContext = xComponentContext;
this.bsc = bsc;
} }
public XMultiComponentFactory getXMultiComponentFactory() { public XMultiComponentFactory getXMultiComponentFactory() {
@ -49,4 +52,11 @@ public class OOOConnection {
public XComponentContext getxComponentContext() { public XComponentContext getxComponentContext() {
return xComponentContext; return xComponentContext;
} }
public void close() {
if (bsc != null) {
bsc.disconnect();
bsc = null;
}
}
} }

View File

@ -16,8 +16,9 @@ import ooo.connector.BootstrapSocketConnector;
public class OOOConnector { public class OOOConnector {
public static OOOConnection createConnection(String openOfficePath) throws BootstrapException { public static OOOConnection createConnection(String openOfficePath) throws BootstrapException {
XComponentContext xComponentContext = new BootstrapSocketConnector(openOfficePath).connect(); BootstrapSocketConnector bsc = new BootstrapSocketConnector(openOfficePath);
OOOConnection oooConnection = new OOOConnection(xComponentContext); XComponentContext xComponentContext = bsc.connect();
OOOConnection oooConnection = new OOOConnection(xComponentContext, bsc);
return oooConnection; return oooConnection;
} }
} }