Alguem ja viu esse erro??
erro java.io.IOException: com.sun.star.io.IOException:
java.net.SocketException: Connection reset
com.sun.star.lang.DisposedException: java.io.IOException:
com.sun.star.io.IOException: java.net.SocketException: Connection reset
at
com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge$MessageDispatcher.run(java_remote_bridge.java:176)
ele acontece qdo eu executo o seguinte codigo pela 2 vez(cada hora eu abro um
documento diferente, e copio o conteudo para um outro q esta abeto desde o
inicio)
private void qualificaPartesCasadas(String tipoChave, String qualificacao,
XTextDocument textoDocumentoModelo) throws IllegalArgumentException, Exception,
IOException {
PropertyValue[] propertyValue = new PropertyValue[1];
propertyValue[0] = new com.sun.star.beans.PropertyValue();
// propertyValue[0].Name = "Hidden";
// propertyValue[0].Value = new Boolean(true);
File modeloParteCasada = verificaArquivo(nmDiretorioModelo,
"PARTECASADA" + ".odt");
if (modeloParteCasada.exists()) {
this.xModeloParteCasada = abrirDocumento(xContext,
modeloParteCasada, propertyValue);
} else {
throw new Exception("Modelo para qualificar a Parte Casada não
encontrado");
}
List<TbParte> partesQualificadas = new ArrayList<TbParte>();
for (TbParte parteCasada : this.listaPartesCasadas) {
if (!(partesQualificadas.contains(parteCasada))) {
if
((qualificacao.equals(parteCasada.getCdQualificacaoParte().getIcTipoQualificacao()))
||
(qualificacao.equals(parteCasada.getCdQualificacaoParte().getNmQualificacao())))
{
partesQualificadas.add(parteCasada);
XTextDocument xTextDocumentParteCasada = (XTextDocument)
UnoRuntime.queryInterface(XTextDocument.class, xModeloParteCasada);
XReplaceable xReplaceableParte = (XReplaceable)
UnoRuntime.queryInterface(XReplaceable.class, xTextDocumentParteCasada);
XReplaceDescriptor xReplaceDescrParte =
(XReplaceDescriptor) xReplaceableParte.createReplaceDescriptor();
//Substitui Variaveis Fixas Parte
for (ParteVariaveisFixas parteVariavelFixa :
ParteVariaveisFixas.values()) {
String substituicao =
parteVariavelFixa.obterDadoObjeto(parteCasada);
if (substituicao == null) {
xReplaceDescrParte.setSearchString("[[" +
parteVariavelFixa.name() + "]]");
xReplaceDescrParte.setReplaceString("");
xReplaceableParte.replaceAll(xReplaceDescrParte);
} else {
xReplaceDescrParte.setSearchString("[[" +
parteVariavelFixa.name() + "]]");
xReplaceDescrParte.setReplaceString(substituicao);
xReplaceableParte.replaceAll(xReplaceDescrParte);
}
}
GeneroParteFACADE generoParteFacade = new
GeneroParteFACADE();
List<TbGeneroParte> listaGeneros =
generoParteFacade.getAcaoQualificacao();
for (TbGeneroParte generoParte : listaGeneros) {
if (parteCasada.getIcSexoParte().equals("F")) {
xReplaceDescrParte.setSearchString("((" +
generoParte.getNmChaveGenero() + "))");
xReplaceDescrParte.setReplaceString(generoParte.getNmChaveFeminino());
xReplaceableParte.replaceAll(xReplaceDescrParte);
} else {
xReplaceDescrParte.setSearchString("((" +
generoParte.getNmChaveGenero() + "))");
xReplaceDescrParte.setReplaceString(generoParte.getNmChaveMasculino());
xReplaceableParte.replaceAll(xReplaceDescrParte);
}
}
for (TbParte parteCasadaConjuge : this.listaPartesCasadas) {
if
(parteCasadaConjuge.getCdParteConjuge().equals(parteCasada.getCdParteConjuge()))
{
if
((!partesQualificadas.contains(parteCasadaConjuge))) {
partesQualificadas.add(parteCasadaConjuge);
//Substitui Variaveis Fixas Parte
for (ConjugeVariaveisFixas conjugeVariavelFixa
: ConjugeVariaveisFixas.values()) {
String substituicao =
conjugeVariavelFixa.obterDadoObjeto(parteCasadaConjuge);
if (substituicao == null) {
xReplaceDescrParte.setSearchString("[["
+ conjugeVariavelFixa.name() +"]]");
xReplaceDescrParte.setReplaceString("");
xReplaceableParte.replaceAll(xReplaceDescrParte);
} else {
xReplaceDescrParte.setSearchString("[["
+ conjugeVariavelFixa.name() + "]]");
xReplaceDescrParte.setReplaceString(substituicao);
xReplaceableParte.replaceAll(xReplaceDescrParte);
}
}
for (TbGeneroParte generoParte : listaGeneros) {
if
(parteCasada.getIcSexoParte().equals("F")) {
xReplaceDescrParte.setSearchString("(("
+ generoParte.getNmChaveGenero() + "_CONJUGE))");
xReplaceDescrParte.setReplaceString(generoParte.getNmChaveFeminino());
xReplaceableParte.replaceAll(xReplaceDescrParte);
} else {
xReplaceDescrParte.setSearchString("(("
+ generoParte.getNmChaveGenero() + "_CONJUGE))");
xReplaceDescrParte.setReplaceString(generoParte.getNmChaveMasculino());
xReplaceableParte.replaceAll(xReplaceDescrParte);
}
}
}
}
}
// the controllers
XController xController_sourceDoc =
xTextDocumentParteCasada.getCurrentController();
XController xController_targetDoc =
xTextDocumentoModelo.getCurrentController();
// the cursor for the source document
XTextViewCursorSupplier xViewCursorSupplier_sourceDoc =
(XTextViewCursorSupplier)
UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController_sourceDoc);
// selecting the whole source document
XModel xModel = (XModel)
UnoRuntime.queryInterface(XModel.class, xTextDocumentoModelo);
XController xController = xModel.getCurrentController();
XSelectionSupplier x = (XSelectionSupplier)
UnoRuntime.queryInterface(XSelectionSupplier.class, xController);
x.select(xTextDocumentParteCasada.getText());
// getting the data supplier of our source doc
XTransferableSupplier xTransferableSupplier_sourceDoc =
(XTransferableSupplier) UnoRuntime.queryInterface(XTransferableSupplier.class,
xController_sourceDoc);
// saving the selected contents
XTransferable xTransferable =
xTransferableSupplier_sourceDoc.getTransferable();
// getting the data supplier of our target doc
XTransferableSupplier xTransferableSupplier_targetDoc =
(XTransferableSupplier) UnoRuntime.queryInterface(XTransferableSupplier.class,
xController_targetDoc);
// the cursor for the target document
XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
(XTextViewCursorSupplier)
UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController_targetDoc);
// going to the end of the source document
XTextViewCursor xTextViewCursor_targetDoc =
xViewCursorSupplier_targetDoc.getViewCursor();
xTextViewCursor_targetDoc.gotoEnd(false);
XSearchable xSearchable = (XSearchable)
UnoRuntime.queryInterface(XSearchable.class, documento);
XSearchDescriptor xsd = (XSearchDescriptor)
xSearchable.createSearchDescriptor();
xsd.setSearchString(tipoChave + qualificacao + tipoChave);
XInterface xfi = (XInterface) xSearchable.findFirst(xsd);
if (xfi != null) {
XTextRange xStart = (com.sun.star.text.XTextRange)
UnoRuntime.queryInterface(
com.sun.star.text.XTextRange.class, xfi);
XTextCursor yCursor = (XTextCursor)
this.xTextDocumentoModelo.getText().createTextCursorByRange(xStart);
//if(range == null){
xTextViewCursor_targetDoc.gotoRange(xStart, false);
//range = xTextViewCursor_targetDoc.getStart();
} else {
xTextViewCursor_targetDoc.gotoRange(range, false);
}
// inserting the source document there
try {
xTransferableSupplier_targetDoc.insertTransferable(xTransferable);
range = xTextViewCursor_targetDoc.getEnd();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
this.xModeloParteCasada.dispose();
}