diff --git a/modules/core/src/com/haulmont/cuba/report/formatters/DocFormatter.java b/modules/core/src/com/haulmont/cuba/report/formatters/DocFormatter.java index 2cce7297b4..8969d19db0 100644 --- a/modules/core/src/com/haulmont/cuba/report/formatters/DocFormatter.java +++ b/modules/core/src/com/haulmont/cuba/report/formatters/DocFormatter.java @@ -136,6 +136,8 @@ public class DocFormatter extends AbstractFormatter { } saveXComponent(xComponent, ooos, filterName); closeXComponent(xComponent); + + officeComponent.getOfficeConnection().close(); } private void fillTables() throws com.sun.star.uno.Exception { diff --git a/modules/core/src/com/haulmont/cuba/report/formatters/oo/OOOConnection.java b/modules/core/src/com/haulmont/cuba/report/formatters/oo/OOOConnection.java index 10bdcee4d6..4fc76341b9 100644 --- a/modules/core/src/com/haulmont/cuba/report/formatters/oo/OOOConnection.java +++ b/modules/core/src/com/haulmont/cuba/report/formatters/oo/OOOConnection.java @@ -16,14 +16,17 @@ import com.sun.star.frame.XDispatchHelper; import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.uno.Exception; import com.sun.star.uno.XComponentContext; +import ooo.connector.BootstrapSocketConnector; import static com.haulmont.cuba.report.formatters.oo.ODTUnoConverter.*; public class OOOConnection { private XComponentContext xComponentContext; + private BootstrapSocketConnector bsc; - public OOOConnection(XComponentContext xComponentContext) { + public OOOConnection(XComponentContext xComponentContext, BootstrapSocketConnector bsc) { this.xComponentContext = xComponentContext; + this.bsc = bsc; } public XMultiComponentFactory getXMultiComponentFactory() { @@ -49,4 +52,11 @@ public class OOOConnection { public XComponentContext getxComponentContext() { return xComponentContext; } + + public void close() { + if (bsc != null) { + bsc.disconnect(); + bsc = null; + } + } } diff --git a/modules/core/src/com/haulmont/cuba/report/formatters/oo/OOOConnector.java b/modules/core/src/com/haulmont/cuba/report/formatters/oo/OOOConnector.java index 42fa0e51ae..9e17aa25a8 100644 --- a/modules/core/src/com/haulmont/cuba/report/formatters/oo/OOOConnector.java +++ b/modules/core/src/com/haulmont/cuba/report/formatters/oo/OOOConnector.java @@ -16,8 +16,9 @@ import ooo.connector.BootstrapSocketConnector; public class OOOConnector { public static OOOConnection createConnection(String openOfficePath) throws BootstrapException { - XComponentContext xComponentContext = new BootstrapSocketConnector(openOfficePath).connect(); - OOOConnection oooConnection = new OOOConnection(xComponentContext); + BootstrapSocketConnector bsc = new BootstrapSocketConnector(openOfficePath); + XComponentContext xComponentContext = bsc.connect(); + OOOConnection oooConnection = new OOOConnection(xComponentContext, bsc); return oooConnection; } }