com.jurismarches.vradi.services.managers
Class TemplateManager

java.lang.Object
  extended by com.jurismarches.vradi.services.managers.TemplateManager

public class TemplateManager
extends java.lang.Object

Template manager. Handle:

Author:
chatellier

Field Summary
protected  com.sun.star.uno.XComponentContext context
           
protected  com.sun.star.lang.XComponent document
           
protected  com.sun.star.frame.XComponentLoader loader
           
protected static java.lang.String USER_TEXT_FIELD_PREFIX
          Prefix des champs texte utilisateurs dans les template ODT.
 
Constructor Summary
TemplateManager(java.io.File templateFile)
          Init template with managed template file.
 
Method Summary
 com.sun.star.lang.XComponent createDoc(java.io.File templateFile)
          Créer un document.
protected  java.lang.String createUNOFileURL(java.io.File file)
          Creating a correct File URL that OpenOffice can handle.
protected  void fillFields(java.util.Map<java.lang.String,java.lang.Object> myValues)
          Remplir les champs de mailing.
 void generateDoc(java.lang.String targetFileName, java.util.Map<java.lang.String,java.lang.Object> myValues, java.io.File... images)
           
 java.util.List<java.lang.String> getDocumentFields()
          Gets the user fields or database fields of the ooo document.
protected  void initOpenOfficeContext()
          Init openoffice bootstrap?.
protected  void insertImageInEndOfDocument(java.io.File image)
          Inserts an image to the end of the document.
 void storeDocComponent(com.sun.star.lang.XComponent xDoc, java.lang.String storeUrl)
          Sauver un doc donné a l'url donnée au format pdf.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected com.sun.star.uno.XComponentContext context

loader

protected com.sun.star.frame.XComponentLoader loader

document

protected com.sun.star.lang.XComponent document

USER_TEXT_FIELD_PREFIX

protected static final java.lang.String USER_TEXT_FIELD_PREFIX
Prefix des champs texte utilisateurs dans les template ODT. TODO EC 20100528 according to documentation, it's "com.sun.star.text.textfield.User" En ooo2, la casse est differente : com.sun.star.text.FieldMaster.User

See Also:
Constant Field Values
Constructor Detail

TemplateManager

public TemplateManager(java.io.File templateFile)
                throws VradiException
Init template with managed template file.

Parameters:
templateFile -
Throws:
VradiException
Method Detail

initOpenOfficeContext

protected void initOpenOfficeContext()
                              throws VradiException
Init openoffice bootstrap?.

Throws:
VradiException

createDoc

public com.sun.star.lang.XComponent createDoc(java.io.File templateFile)
                                       throws VradiException
Créer un document.

Parameters:
templateFile - Le template du document
Returns:
le document construit
Throws:
VradiException - if document can't be created

generateDoc

public void generateDoc(java.lang.String targetFileName,
                        java.util.Map<java.lang.String,java.lang.Object> myValues,
                        java.io.File... images)
                 throws VradiException
Throws:
VradiException

storeDocComponent

public void storeDocComponent(com.sun.star.lang.XComponent xDoc,
                              java.lang.String storeUrl)
                       throws VradiException
Sauver un doc donné a l'url donnée au format pdf.

Parameters:
xDoc - Le document a sauvegarder (XComponent)
storeUrl - Url complete du fichier (String)
Throws:
VradiException - if pdf can't be exported

createUNOFileURL

protected java.lang.String createUNOFileURL(java.io.File file)
                                     throws VradiException
Creating a correct File URL that OpenOffice can handle. This is necessary to be platform independent.

Parameters:
filelocation -
Returns:
openoffice internal url
Throws:
VradiException - in cas of MalformedURLException

fillFields

protected void fillFields(java.util.Map<java.lang.String,java.lang.Object> myValues)
                   throws VradiException
Remplir les champs de mailing. Manage only com.sun.star.text.textfield.User.* fields.

Parameters:
myValues - value to replace into template fields
Throws:
VradiException - if values can't be replaced

insertImageInEndOfDocument

protected void insertImageInEndOfDocument(java.io.File image)
                                   throws VradiException
Inserts an image to the end of the document. Source : http://user.services.openoffice.org/fr/forum/viewtopic.php?f=15&t=6357&p=31958

Parameters:
image - the file containing the image to insert
Throws:
VradiException

getDocumentFields

public java.util.List<java.lang.String> getDocumentFields()
Gets the user fields or database fields of the ooo document. Some help : http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Fields Manage fields : - com.sun.star.text.textfield.User Variables - User Field. Creates a global document variable and displays it whenever this field occurs in the text.

Returns:
an array of String containing the field names


Copyright © 2009-2010 JurisMarches. All Rights Reserved.