[Castore-commits] OOInputStream.java 1.1.2.4 1.1.2.5 OOOutputStream.java 1.1.2.1 1.1.2.2 OOOConverter.java 1.3.2.4 1.3.2.5

Stéphane Bouchet sbouchet at adullact1.hosting.cri74.org
Lun 6 Mar 12:13:51 CET 2006


Update of /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/retro
In directory adullact1:/tmp/cvs-serv11793/src/java/fr/emn/castor/documents/retro

Modified Files:
      Tag: v1_1_branch
	OOInputStream.java OOOutputStream.java OOOConverter.java 
Log Message:
mise en page

Index: OOOutputStream.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/retro/Attic/OOOutputStream.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** OOOutputStream.java	16 Feb 2006 16:24:31 -0000	1.1.2.1
--- OOOutputStream.java	6 Mar 2006 11:13:49 -0000	1.1.2.2
***************
*** 1,5 ****
  /*
!  * $$Id$$
!  * 
   * Plateforme CASTORE
   * CeCILL Copyright (C) 2005-2006 by EMN
--- 1,5 ----
  /*
!  * $Id$
!  *
   * Plateforme CASTORE
   * CeCILL Copyright (C) 2005-2006 by EMN
***************
*** 48,60 ****
  import com.sun.star.io.XOutputStream;
  
- 
- 
  /**
!  * Code inspiré de : 
!  * 	http://www.oooforum.org/forum/viewtopic.phtml?p=51854&highlight
!  * 
!  * En modification, le ByteArrayOutputStream a été changé pour un FileOutputStream
!  * afin d'écrire directement le fichier de destination.
!  * Cette classe est utilisée lorsqu'on attaque un serveur Openoffice sur une 
   * machine différente de celle de Tomcat.
   *
--- 48,58 ----
  import com.sun.star.io.XOutputStream;
  
  /**
!  * Code inspiré de :
!  * http://www.oooforum.org/forum/viewtopic.phtml?p=51854&highlight
!  *
!  * En modification, le ByteArrayOutputStream a été changé pour un
!  * FileOutputStream afin d'écrire directement le fichier de destination.
!  * Cette classe est utilisée lorsqu'on attaque un serveur Openoffice sur une
   * machine différente de celle de Tomcat.
   *
***************
*** 64,111 ****
   */
  public class OOOutputStream extends FileOutputStream implements
! 		XOutputStream {
  
! 	/**
! 	 * Constructeur à appeler avec le fichier de sortie à utiliser
! 	 * @param fichier
! 	 * @throws FileNotFoundException
! 	 */
! 	public OOOutputStream(File fichier) throws FileNotFoundException {
! 		super(fichier);
! 	}
  
! 	/**
! 	 * @see com.sun.star.io.XOutputStream#writeBytes(byte[])
! 	 */
! 	public void writeBytes(byte[] values) throws NotConnectedException,
! 			BufferSizeExceededException, com.sun.star.io.IOException {
! 		try {
! 			this.write(values);
! 		} catch (java.io.IOException ioe) {
! 			throw (new com.sun.star.io.IOException(ioe.getMessage()));
! 		}
! 	}
  
! 	/**
! 	 * @see com.sun.star.io.XOutputStream#closeOutput()
! 	 */
! 	public void closeOutput() throws NotConnectedException,
! 			BufferSizeExceededException, com.sun.star.io.IOException {
! 		try {
! 			super.flush();
! 			super.close();
! 		} catch (java.io.IOException ioe) {
! 			throw (new com.sun.star.io.IOException(ioe.getMessage()));
! 		}
! 	}
  
! 	/**
! 	 * @see java.io.Flushable#flush()
! 	 */
! 	public void flush() {
! 		try {
! 			super.flush();
! 		} catch (java.io.IOException ignored) {
! 		}
! 	}
  }
\ No newline at end of file
--- 62,109 ----
   */
  public class OOOutputStream extends FileOutputStream implements
!         XOutputStream {
  
!     /**
!      * Constructeur à appeler avec le fichier de sortie à utiliser
!      * @param fichier
!      * @throws FileNotFoundException
!      */
!     public OOOutputStream (File fichier) throws FileNotFoundException {
!         super(fichier);
!     }
  
!     /**
!      * @see com.sun.star.io.XOutputStream#writeBytes(byte[])
!      */
!     public void writeBytes(byte[] values) throws NotConnectedException,
!             BufferSizeExceededException, com.sun.star.io.IOException {
!         try {
!             this.write(values);
!         } catch (java.io.IOException ioe) {
!             throw (new com.sun.star.io.IOException(ioe.getMessage()));
!         }
!     }
  
!     /**
!      * @see com.sun.star.io.XOutputStream#closeOutput()
!      */
!     public void closeOutput() throws NotConnectedException,
!             BufferSizeExceededException, com.sun.star.io.IOException {
!         try {
!             super.flush();
!             super.close();
!         } catch (java.io.IOException ioe) {
!             throw (new com.sun.star.io.IOException(ioe.getMessage()));
!         }
!     }
  
!     /**
!      * @see java.io.Flushable#flush()
!      */
!     public void flush() {
!         try {
!             super.flush();
!         } catch (java.io.IOException ignored) {
!         }
!     }
  }
\ No newline at end of file

Index: OOInputStream.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/retro/OOInputStream.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** OOInputStream.java	16 Feb 2006 16:21:26 -0000	1.1.2.4
--- OOInputStream.java	6 Mar 2006 11:13:49 -0000	1.1.2.5
***************
*** 52,56 ****
   * Classe permettant de retro-convertir des fichiers Texte bruts et lorsque le serveur
   * OpenOffice n'est pas sur la même machine que Tomcat.
!  * 
   * Cela permet d'ouvrir un inputstream directement sur le fichier pour le
   * lire dans OpenOffice.
--- 52,56 ----
   * Classe permettant de retro-convertir des fichiers Texte bruts et lorsque le serveur
   * OpenOffice n'est pas sur la même machine que Tomcat.
!  *
   * Cela permet d'ouvrir un inputstream directement sur le fichier pour le
   * lire dans OpenOffice.
***************
*** 58,74 ****
   * <a href=http://www.oooforum.org/forum/viewtopic.phtml?p=51854&highlight=>
   * ici </a>
!  * 
   * Modification : passage du ByteArrayInputStream au FileInputStream.
   * L'interface XSeekable est-elle utile ?
!  * 
   * @author $Author$
   * @version $Revision$
   */
! public class OOInputStream extends FileInputStream implements XInputStream, XSeekable {
  
- 	private File fichier;
- 	
      /**
!      * Constructeur avec le fichier à lire en parametre
       * @param fichier
       * @throws FileNotFoundException
--- 58,75 ----
   * <a href=http://www.oooforum.org/forum/viewtopic.phtml?p=51854&highlight=>
   * ici </a>
!  *
   * Modification : passage du ByteArrayInputStream au FileInputStream.
   * L'interface XSeekable est-elle utile ?
!  *
   * @author $Author$
   * @version $Revision$
   */
! public class OOInputStream extends FileInputStream implements XInputStream,
!         XSeekable {
! 
!     private File fichier;
  
      /**
!      * Constructeur avec le fichier à lire en parametre.
       * @param fichier
       * @throws FileNotFoundException
***************
*** 78,122 ****
          this.fichier = fichier;
      }
!     
      /**
       * @see java.io.InputStream#available()
       */
      public int available() {
!     	try {
!     		return super.available();
!     	} catch (IOException e) {
!     		return 0;
!     	}
      }
!     
      /**
       * @see com.sun.star.io.XSeekable#getLength()
       */
      public long getLength() throws com.sun.star.io.IOException {
! 		return this.fichier.length();
! 	}
!     
! 	/**
! 	 * @see com.sun.star.io.XSeekable#getPosition()
! 	 */
! 	public long getPosition() throws com.sun.star.io.IOException {
! 		try {
! 			return super.getChannel().position();
! 		} catch (IOException e) {
! 	    	throw new com.sun.star.io.IOException(e.getMessage(), this);
! 	    }
! 	}
! 	
! 	/**
! 	 * @see com.sun.star.io.XSeekable#seek(long)
! 	 */
! 	public void seek(long arg0) throws IllegalArgumentException, com.sun.star.io.IOException {
! 		try {
! 			super.getChannel().position(arg0);
! 		} catch (IOException e) {
! 	    	throw new com.sun.star.io.IOException(e.getMessage(), this);
! 	    }
! 	}
! 	
      /**
       * @see com.sun.star.io.XInputStream#readBytes(byte[][], int)
--- 79,124 ----
          this.fichier = fichier;
      }
! 
      /**
       * @see java.io.InputStream#available()
       */
      public int available() {
!         try {
!             return super.available();
!         } catch (IOException e) {
!             return 0;
!         }
      }
! 
      /**
       * @see com.sun.star.io.XSeekable#getLength()
       */
      public long getLength() throws com.sun.star.io.IOException {
!         return this.fichier.length();
!     }
! 
!     /**
!      * @see com.sun.star.io.XSeekable#getPosition()
!      */
!     public long getPosition() throws com.sun.star.io.IOException {
!         try {
!             return super.getChannel().position();
!         } catch (IOException e) {
!             throw new com.sun.star.io.IOException(e.getMessage(), this);
!         }
!     }
! 
!     /**
!      * @see com.sun.star.io.XSeekable#seek(long)
!      */
!     public void seek(long arg0) throws IllegalArgumentException,
!             com.sun.star.io.IOException {
!         try {
!             super.getChannel().position(arg0);
!         } catch (IOException e) {
!             throw new com.sun.star.io.IOException(e.getMessage(), this);
!         }
!     }
! 
      /**
       * @see com.sun.star.io.XInputStream#readBytes(byte[][], int)
***************
*** 143,147 ****
          }
      }
!     
      /**
       * @see com.sun.star.io.XInputStream#skipBytes(int)
--- 145,149 ----
          }
      }
! 
      /**
       * @see com.sun.star.io.XInputStream#skipBytes(int)
***************
*** 150,156 ****
              throws com.sun.star.io.IOException {
          try {
!         	skip(p1);
          } catch (IOException e) {
!         	throw new com.sun.star.io.IOException(e.getMessage(), this);
          }
      }
--- 152,158 ----
              throws com.sun.star.io.IOException {
          try {
!             skip(p1);
          } catch (IOException e) {
!             throw new com.sun.star.io.IOException(e.getMessage(), this);
          }
      }

Index: OOOConverter.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/retro/OOOConverter.java,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -C2 -d -r1.3.2.4 -r1.3.2.5
*** OOOConverter.java	16 Feb 2006 16:23:07 -0000	1.3.2.4
--- OOOConverter.java	6 Mar 2006 11:13:49 -0000	1.3.2.5
***************
*** 67,81 ****
   * - inputDocumentFormat : le type du document à convertir
   *
!  * Par ailleurs, ces attributs peuvent également être spécifiés via castor.properties :
!  * - host : l'adresse du serveur OpenOffice.org (par défaut localhost).
!  * - port : le port sur lequel contacter le serveur OpenOffice.org par défaut 2809).
!  * - executable : l'executable à utiliser, 
   * 		chemin absolu ou seulement la commande si présente dans le PATH
   *
   * S'il n'y a pas de serveur OpenOffice.org sur cette machine et sur ce port,
   * alors la tâche va tenter d'en démarrer un, en utilisant l'exécutable
!  * OpenOffice.org spécifié par l'attribut ooExecutable, ou la commande soffice si cet
!  * attribut n'est pas spécifié. On ne tente de démarrer le serveur que s'il est 
!  * censé tourner en local.
   *
   * @author $Author$
--- 67,82 ----
   * - inputDocumentFormat : le type du document à convertir
   *
!  * Par ailleurs, ces attributs peuvent également être spécifiés via
!  * castor.properties :
!  * - host : l'adresse du serveur OpenOffice.org (défaut=localhost).
!  * - port : le port sur lequel contacter le serveur (défaut=2809).
!  * - executable : l'executable à utiliser,
   * 		chemin absolu ou seulement la commande si présente dans le PATH
   *
   * S'il n'y a pas de serveur OpenOffice.org sur cette machine et sur ce port,
   * alors la tâche va tenter d'en démarrer un, en utilisant l'exécutable
!  * OpenOffice.org spécifié par l'attribut ooExecutable, ou la commande soffice
!  * si cet attribut n'est pas spécifié.
!  * On ne tente de démarrer le serveur que s'il est censé tourner en local.
   *
   * @author $Author$
***************
*** 99,104 ****
      public String outputDocument;
  
!     /** L'endroit où se trouve l'exécutable OpenOffice. 
!      * 	Selon castor.properties si spécifié.
       * */
      public String ooExecutable = "soffice";
--- 100,106 ----
      public String outputDocument;
  
!     /**
!      * L'endroit où se trouve l'exécutable OpenOffice. 
!      * Selon castor.properties si spécifié.
       * */
      public String ooExecutable = "soffice";
***************
*** 121,125 ****
          this.inputDocumentFormat = id;
      }
!     
      /**
       * Reçoit l'attribut ouputDocument depuis ANT.
--- 123,127 ----
          this.inputDocumentFormat = id;
      }
! 
      /**
       * Reçoit l'attribut ouputDocument depuis ANT.
***************
*** 164,169 ****
       */
      public final void execute() throws BuildException {
! 
!     	// On commence par vérifier si on a un bon fichier
          if (this.inputDocument == null) {
              throw new BuildException(
--- 166,170 ----
       */
      public final void execute() throws BuildException {
!         // On commence par vérifier si on a un bon fichier
          if (this.inputDocument == null) {
              throw new BuildException(
***************
*** 176,180 ****
          }
          String inUrl = formatOOUrl(inputFile.getAbsolutePath());
!         
          // Ensuite si on peut écrire dans le fichier de sortie
          if (this.outputDocument == null) {
--- 177,181 ----
          }
          String inUrl = formatOOUrl(inputFile.getAbsolutePath());
! 
          // Ensuite si on peut écrire dans le fichier de sortie
          if (this.outputDocument == null) {
***************
*** 190,203 ****
          }
          String outUrl = formatOOUrl(outputFile.getAbsolutePath());
!         
          // On va maintenant vérifier s'il est nécessaire d'effectuer la
          // tâche, c'est-à-dire si la date du fichier
          // d'entrée est plus récente que la date du fichier de sortie
!         if (inputFile.lastModified() > outputFile.lastModified()) {        	
!         
!         	// récupération des paramètres de la chaine serveur OpenOffice 
!         	// et détermination du mode local ou a distance
!         	boolean enLocal = initialiseParametres();
!         	
              // Ensuite on vérifie si le serveur OpenOffice est en route.
              try {
--- 191,204 ----
          }
          String outUrl = formatOOUrl(outputFile.getAbsolutePath());
! 
          // On va maintenant vérifier s'il est nécessaire d'effectuer la
          // tâche, c'est-à-dire si la date du fichier
          // d'entrée est plus récente que la date du fichier de sortie
!         if (inputFile.lastModified() > outputFile.lastModified()) {
! 
!             // récupération des paramètres de la chaine serveur OpenOffice
!             // et détermination du mode local ou a distance
!             boolean enLocal = initialiseParametres();
! 
              // Ensuite on vérifie si le serveur OpenOffice est en route.
              try {
***************
*** 215,223 ****
                  XUnoUrlResolver xurlresolver = (XUnoUrlResolver) UnoRuntime
                      .queryInterface(XUnoUrlResolver.class, objectUrlResolver);
!                 
                  // On détermine l'adresse du serveur et du service
                  String ooConnect = "socket,host=" + this.host + ",port="
                          + this.port + ";urp";
!                 
                  // On fait une tentative de connection ;
                  // si elle échoue, on essaie de démarrer le serveur
--- 216,224 ----
                  XUnoUrlResolver xurlresolver = (XUnoUrlResolver) UnoRuntime
                      .queryInterface(XUnoUrlResolver.class, objectUrlResolver);
! 
                  // On détermine l'adresse du serveur et du service
                  String ooConnect = "socket,host=" + this.host + ",port="
                          + this.port + ";urp";
! 
                  // On fait une tentative de connection ;
                  // si elle échoue, on essaie de démarrer le serveur
***************
*** 227,272 ****
                              + ";StarOffice.ServiceManager");
                  } catch (Exception e) {
!                 	
!                 	// On tente de démarrer le serveur OpenOffice, 
!                 	// seulement si le serveur est en local !
!                 	if (enLocal) {
! 	                    // La commande est telle que :
! 	                    // soffice -accept=socket,host=localhost,port=2809;urp;StarOffice.ServiceManager
! 	                    String osName = System.getProperties().getProperty(
! 	                        "os.name");
! 	                    String arg = null;
! 	                    if (osName.startsWith("Windows")) {
! 	                        // on rajoute le demarrage rapide sous windows
! 	                        arg = " -accept=socket,host="
! 	                                + this.host
! 	                                + ",port="
! 	                                + this.port
! 	                                + ";urp;StarOffice.ServiceManager -quickstart";
! 	                    } else if (osName.startsWith("SunOS")) {
! 	                        // pas de demarrage rapide sous Unix
! 	                        // necessité d'avoir un client X !!!!
! 	                        arg = " \"-accept=socket,host="
! 	                                + this.host
! 	                                + ",port="
! 	                                + this.port
! 	                                + ";urp;StarOffice.ServiceManager\" -headless -display :1 &";
! 	                    } else if (osName.startsWith("Linux")) {
! 	                        // Démarrage sous Linux
! 	                        arg = " \"-accept=socket,host="
! 	                                + this.host
! 	                                + ",port="
! 	                                + this.port
! 	                                + ";urp;StarOffice.ServiceManager\" -headless -display :1 &";
! 	                    }
! 	                    Runtime.getRuntime().exec(this.ooExecutable + arg);
! 	                    // On va attendre 15 secondes le démarrage correct de OO
! 	                    Thread.sleep(15000);
! 	                    // Et on essaie de nouveau, s'il y a toujours erreur
! 	                    // tant pis...
! 	                    objectInitial = xurlresolver.resolve("uno:" + ooConnect
! 	                            + ";StarOffice.ServiceManager");
!                 	}
                  }
!                 
                  xmulticomponentfactory = (XMultiComponentFactory) UnoRuntime
                      .queryInterface(
--- 228,273 ----
                              + ";StarOffice.ServiceManager");
                  } catch (Exception e) {
! 
!                     // On tente de démarrer le serveur OpenOffice,
!                     // seulement si le serveur est en local !
!                     if (enLocal) {
!                         // La commande est telle que :
!                         // soffice -accept=socket,host=localhost,port=2809;urp;StarOffice.ServiceManager
!                         String osName = System.getProperties().getProperty(
!                             "os.name");
!                         String arg = null;
!                         if (osName.startsWith("Windows")) {
!                             // on rajoute le demarrage rapide sous windows
!                             arg = " -accept=socket,host="
!                                     + this.host
!                                     + ",port="
!                                     + this.port
!                                     + ";urp;StarOffice.ServiceManager -quickstart";
!                         } else if (osName.startsWith("SunOS")) {
!                             // pas de demarrage rapide sous Unix
!                             // necessité d'avoir un client X !!!!
!                             arg = " \"-accept=socket,host="
!                                     + this.host
!                                     + ",port="
!                                     + this.port
!                                     + ";urp;StarOffice.ServiceManager\" -headless -display :1 &";
!                         } else if (osName.startsWith("Linux")) {
!                             // Démarrage sous Linux
!                             arg = " \"-accept=socket,host="
!                                     + this.host
!                                     + ",port="
!                                     + this.port
!                                     + ";urp;StarOffice.ServiceManager\" -headless -display :1 &";
!                         }
!                         Runtime.getRuntime().exec(this.ooExecutable + arg);
!                         // On va attendre 15 secondes le démarrage correct de OO
!                         Thread.sleep(15000);
!                         // Et on essaie de nouveau, s'il y a toujours erreur
!                         // tant pis...
!                         objectInitial = xurlresolver.resolve("uno:"
!                                 + ooConnect + ";StarOffice.ServiceManager");
!                     }
                  }
! 
                  xmulticomponentfactory = (XMultiComponentFactory) UnoRuntime
                      .queryInterface(
***************
*** 286,305 ****
                                  "com.sun.star.frame.Desktop",
                                  xcomponentcontext));
!                 
                  // Ces propriétés permettent de charger le document
                  // sans montrer la fenêtre
                  PropertyValue[] propertyvalue;
!                 
                  // On charge le fichier dans OO suivant son format
                  Object objectDocumentToStore = null;
!                 
                  // pour appeler un serveur OO à distance, il faut que le fichier à traiter soit directement
                  // dans l'appel d'OO. En effet les lien file://... ne sont valables qu'en local.
!                 
                  OOInputStream inputStream = null;
!                 if (this.inputDocumentFormat.equals("InputStream") || !enLocal) {
!                 	// Cas où le type de document est un inputStream ou bien si le serveur est à distance. 
!                 	inputStream = new OOInputStream(inputFile);
!                 	
                      // parametres
                      propertyvalue = new PropertyValue[2];
--- 287,307 ----
                                  "com.sun.star.frame.Desktop",
                                  xcomponentcontext));
! 
                  // Ces propriétés permettent de charger le document
                  // sans montrer la fenêtre
                  PropertyValue[] propertyvalue;
! 
                  // On charge le fichier dans OO suivant son format
                  Object objectDocumentToStore = null;
! 
                  // pour appeler un serveur OO à distance, il faut que le fichier à traiter soit directement
                  // dans l'appel d'OO. En effet les lien file://... ne sont valables qu'en local.
! 
                  OOInputStream inputStream = null;
!                 if (this.inputDocumentFormat.equals("InputStream")
!                         || !enLocal) {
!                     // Cas où le type de document est un inputStream ou bien si le serveur est à distance. 
!                     inputStream = new OOInputStream(inputFile);
! 
                      // parametres
                      propertyvalue = new PropertyValue[2];
***************
*** 310,318 ****
                      propertyvalue[1].Name = "InputStream";
                      propertyvalue[1].Value = inputStream;
!                     
                      objectDocumentToStore = xcomponentloader
                          .loadComponentFromURL(
                              "private:stream", "_blank", 0, propertyvalue);
!                     
                  } else {
                      propertyvalue = new PropertyValue[1];
--- 312,320 ----
                      propertyvalue[1].Name = "InputStream";
                      propertyvalue[1].Value = inputStream;
! 
                      objectDocumentToStore = xcomponentloader
                          .loadComponentFromURL(
                              "private:stream", "_blank", 0, propertyvalue);
! 
                  } else {
                      propertyvalue = new PropertyValue[1];
***************
*** 320,329 ****
                      propertyvalue[0].Name = "Hidden";
                      propertyvalue[0].Value = Boolean.valueOf(true);
!                     
                      objectDocumentToStore = xcomponentloader
                          .loadComponentFromURL(
                              inUrl, "_blank", 0, propertyvalue);
                  }
!                 
                  // Si l'URL n'est pas bonne, on aura un null ici...
                  if (objectDocumentToStore == null) {
--- 322,331 ----
                      propertyvalue[0].Name = "Hidden";
                      propertyvalue[0].Value = Boolean.valueOf(true);
! 
                      objectDocumentToStore = xcomponentloader
                          .loadComponentFromURL(
                              inUrl, "_blank", 0, propertyvalue);
                  }
! 
                  // Si l'URL n'est pas bonne, on aura un null ici...
                  if (objectDocumentToStore == null) {
***************
*** 333,357 ****
                                  + " avec OpenOffice ; est-ce que ce fichier existe bien ?");
                  }
!                 
                  // On crée un objet qui nous permettra de réenregistrer
                  // le document
                  XStorable xstorable = (XStorable) UnoRuntime.queryInterface(
                      XStorable.class, objectDocumentToStore);
!                 
                  // Les propriétés suivantes déterminent quel format de
                  // fichier et indiquent d'écraser le fichier existant
!                 
                  OOOutputStream outputStream = null;
                  if (enLocal) {
!                 	propertyvalue = new PropertyValue[2];
                  } else {
!                 	outputStream = new OOOutputStream(outputFile);
!                 	propertyvalue = new PropertyValue[3];
!                 	// la sortie se fait via un FileOutputStream
                      propertyvalue[2] = new PropertyValue();
                      propertyvalue[2].Name = "OutputStream";
                      propertyvalue[2].Value = outputStream;
                  }
!                 
                  propertyvalue[0] = new PropertyValue();
                  propertyvalue[0].Name = "FilterName";
--- 335,359 ----
                                  + " avec OpenOffice ; est-ce que ce fichier existe bien ?");
                  }
! 
                  // On crée un objet qui nous permettra de réenregistrer
                  // le document
                  XStorable xstorable = (XStorable) UnoRuntime.queryInterface(
                      XStorable.class, objectDocumentToStore);
! 
                  // Les propriétés suivantes déterminent quel format de
                  // fichier et indiquent d'écraser le fichier existant
! 
                  OOOutputStream outputStream = null;
                  if (enLocal) {
!                     propertyvalue = new PropertyValue[2];
                  } else {
!                     outputStream = new OOOutputStream(outputFile);
!                     propertyvalue = new PropertyValue[3];
!                     // la sortie se fait via un FileOutputStream
                      propertyvalue[2] = new PropertyValue();
                      propertyvalue[2].Name = "OutputStream";
                      propertyvalue[2].Value = outputStream;
                  }
! 
                  propertyvalue[0] = new PropertyValue();
                  propertyvalue[0].Name = "FilterName";
***************
*** 361,389 ****
                      propertyvalue[0].Value = "StarOffice XML (Writer)";
                  }
!                 
                  propertyvalue[1] = new PropertyValue();
                  propertyvalue[1].Name = "Overwrite";
                  propertyvalue[1].Value = Boolean.valueOf(true);
!                 
                  // Et maintenant on demande d'enregistrer le document
                  if (enLocal) {
!                 	xstorable.storeAsURL(outUrl, propertyvalue);
!                 } else {                	
!                 	xstorable.storeAsURL("private:stream", propertyvalue);
!                 	// Fermeture des flux
                      outputStream.closeOutput();
                      inputStream.closeInput();
                  }
!                 
                  // Et on fait le ménage...
                  XComponent xcomponent = (XComponent) UnoRuntime
                      .queryInterface(XComponent.class, xstorable);
!                 
                  xcomponent.dispose();
!                 
              } catch (Exception e) {
                  throw new BuildException(
!                     "Problème à l'appel d'OpenOffice : " + e.getMessage(),
!                     e);
              }
          }
--- 363,390 ----
                      propertyvalue[0].Value = "StarOffice XML (Writer)";
                  }
! 
                  propertyvalue[1] = new PropertyValue();
                  propertyvalue[1].Name = "Overwrite";
                  propertyvalue[1].Value = Boolean.valueOf(true);
! 
                  // Et maintenant on demande d'enregistrer le document
                  if (enLocal) {
!                     xstorable.storeAsURL(outUrl, propertyvalue);
!                 } else {
!                     xstorable.storeAsURL("private:stream", propertyvalue);
!                     // Fermeture des flux
                      outputStream.closeOutput();
                      inputStream.closeInput();
                  }
! 
                  // Et on fait le ménage...
                  XComponent xcomponent = (XComponent) UnoRuntime
                      .queryInterface(XComponent.class, xstorable);
! 
                  xcomponent.dispose();
! 
              } catch (Exception e) {
                  throw new BuildException(
!                     "Problème à l'appel d'OpenOffice : " + e.getMessage(), e);
              }
          }
***************
*** 412,416 ****
          return prefixe + f.replace('\\', '/');
      }
!     
      /**
       * Récupération des paramètres du serveur OpenOffice, 
--- 413,417 ----
          return prefixe + f.replace('\\', '/');
      }
! 
      /**
       * Récupération des paramètres du serveur OpenOffice, 
***************
*** 419,444 ****
       */
      private boolean initialiseParametres() {
!     	
!     	boolean enLocal = true;
!     	
!     	// Host, port et executable
!     	String host = PropertiesHelper.getProperty("openoffice.host");
!     	if (host != null && host.trim().length() > 0) {
! 			this.host = host.trim();
! 			
! 			if (!("localhost".equals(this.host) || "127.0.0.1".equals(this.host))) {
! 				enLocal = false;
! 			}
! 		}
!     	String port = PropertiesHelper.getProperty("openoffice.port"); 
! 		if (port != null && port.trim().length() > 0) {
! 			this.port = port.trim();
! 		}
! 		String ooExecutable = PropertiesHelper.getProperty("openoffice.executable"); 
! 		if (ooExecutable != null && ooExecutable.trim().length() > 0) {
! 			this.ooExecutable = ooExecutable.trim();
! 		}
! 		
! 		return enLocal;
      }
  }
\ No newline at end of file
--- 420,447 ----
       */
      private boolean initialiseParametres() {
! 
!         boolean enLocal = true;
! 
!         // Host, port et executable
!         String host = PropertiesHelper.getProperty("openoffice.host");
!         if (host != null && host.trim().length() > 0) {
!             this.host = host.trim();
! 
!             if (!("localhost".equals(this.host) || "127.0.0.1"
!                 .equals(this.host))) {
!                 enLocal = false;
!             }
!         }
!         String port = PropertiesHelper.getProperty("openoffice.port");
!         if (port != null && port.trim().length() > 0) {
!             this.port = port.trim();
!         }
!         String ooExecutable = PropertiesHelper
!             .getProperty("openoffice.executable");
!         if (ooExecutable != null && ooExecutable.trim().length() > 0) {
!             this.ooExecutable = ooExecutable.trim();
!         }
! 
!         return enLocal;
      }
  }
\ No newline at end of file




Plus d'informations sur la liste de diffusion Castore-commits