[api-dev] OOeBean error in a swt / standalone application

View: New views
5 Messages — Rating Filter:   Alert me  

[api-dev] OOeBean error in a swt / standalone application

by info-1250 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear community, mailing-list, and sun/openoffice developer,

please help meeeeeee......!

I have a big problem (see the end of this posting), when i make a .jar  
(standalone application) out from eclipse i become the error. In  
eclipse my aplication was work. When i start the application with  
"java -verbose" i see more, it´s comes a URISyntaxException. By i can  
not see, why!

ok, follow you can finde...(search for "my")

1. my main.class
2. my ControllerOOo.jar (Composite with swt/awt)
3. my SwtViewerOOo.jar (class with OOeBean)
4. my environment
5. my error

Please help me, i work full on this the last three day.

On the end i must say sorry for my english and my mixed german/english  
source code, i hope you can understand them.
Thanks and by
from Hamburg/Germany
Erik

............
my main.class
............
package de.zuehlke_it.sgv;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
//import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.sun.star.comp.beans.NoConnectionException;

import de.zuehlke_it.sgv.model.vorgang.Vorgang;
import de.zuehlke_it.sgv.model.vorgang.VorgangsListe;
import de.zuehlke_it.sgv.model.vorgang.VorgangsListeEintrag;
import de.zuehlke_it.sgv.other.InfoScreen;
import de.zuehlke_it.sgv.storage.DB_connect;
import de.zuehlke_it.sgv.view.MainComp;
import de.zuehlke_it.sgv.view.menue.MainMenue;
import de.zuehlke_it.sgv.view.ooo.ControllerOOo;
import de.zuehlke_it.sgv.view.ooo.SwtViewerOOo;

/* Variablen
  * ---------
  * Grundsätzlich jede Instanzierung einer Klasse verursacht jeweils
  * eine eigene Deklaration der Variablen für die jeweilige Instanz.
  *
  * Ausnahme ist erreichbar durch den Zusatz ...
  * ... static [Typ] [variable] : die Gültigkeit der Variable wird einheitliche
  *                                für alle Instanzen der Klasse gesetzt
  *
  * ... final  [Typ] [variable] : definiert feste Werte [Konstanten]
  *
  * Sichtbarkeit / Zugriffsrecht auf Variablen
  *  
-----------------------------------------------------------------------------
  * public     [Typ] [variable] : überall, auch außerhalb des Packet
  * protected  [Typ] [variable] : überall, nur in diesem Packet
  * privat     [Typ] [variable] : nur in dieser Klasse
  *
  * (Standardschutz , oder auch umgangssprachlich [package] [~])
  *  [Typ] [variable] : alle Klassen dieses Packetes
  *  - Eingrenzung durch Blöcke (lokal) möglich
  *
  */


public class SGV {


   private static Properties einstellungen;
   private static String pfad = "";
   private static String version="V 0.003.010 (14.07.2006)";
   private static String firma="Zuehlke IT GbR";


   // private static String pfadGfx = "\\images\\";
        private static String pfadVorlagen = "\\oov";
        private static String pfadDokumente = "\\dokumente";


        public static final int VORLAGE = 1;
        public static final int BERICHT = 2;
        public static final int BAUSTEIN = 3;
        public static final int KAPITEL = 4;

        public  static InfoScreen infoScreen;
        private static Display display;
        private static Shell shell;

   private static Vorgang aktVorgang;

        private static void vorbereiten(){

     einstellungen = new Properties();
     try {
       einstellungen.load(new FileInputStream("./conf.sgv"));
       pfad = einstellungen.getProperty("pfad");
       firma = einstellungen.getProperty("firma");
     } catch (FileNotFoundException e) {
       // TODO Automatisch erstellter Catch-Block
       e.printStackTrace();
     } catch (IOException e) {
       // TODO Automatisch erstellter Catch-Block
       e.printStackTrace();
     }

// infoScreen = new InfoScreen(pfadGfx + "splash-vsg.jpg");
// infoScreen.addProgressBar();
// infoScreen.showSplash();
// infoScreen.setProgressBarString("Start der Anwendung ...");
// Basis.appWait(warten);

                  DB_connect.getConnection();
//        if ( mySQL != null ){
//         infoScreen.setProgressBarString("Öffnen der Datenbank war  
erfolgreich!");
//        } else {
//         infoScreen.setProgressBarString("Öffnen der Datenbank war  
NICHT erfolgreich!");
//        }


       aktVorgang = Vorgang.getInstance();
       aktVorgang.setMandantID(1);
      List vListe = VorgangsListe.getListe();
      int letztePos = vListe.size() -1;

      if (vListe.size() > 0) {
        VorgangsListeEintrag dummy = (VorgangsListeEintrag)  
vListe.get(letztePos);
        aktVorgang.getVorgang(dummy.getId());
      }

        }

     public static void  beenden() {
     }

     /**
       * @param args
       */

     public static void main(String[] args) {

     Properties props = System.getProperties();
     Iterator iter = props.keySet().iterator();
     while (iter.hasNext()) {
         String propName = (String)iter.next();
         System.out.print(propName);
         System.out.print("\t=\t");
         System.out.println(props.getProperty(propName));
     }


     vorbereiten();

     display = new Display();
     shell = new Shell(display);
     shell.setText("SGV : " + firma + " " + version);

// Display Zeichensatz relevante Daten
     Font font = display.getSystemFont();
     FontData[] fd = font.getFontData();

     int zHoehe = fd[0].getHeight();
     int zWeite = zHoehe;

// Breite : shell.getSize().x;
// Hoehe  : shell.getSize().y;

     shell.setMaximized(true);
     shell.setBackground(new Color(display, 160, 160, 255));
     GridLayout shellGL = new GridLayout();
     shell.setLayout(shellGL);

     shell.setMenuBar(new MainMenue(shell).getMenu());

//    Point size = shell.getSize();
     new MainComp(shell,zHoehe,zWeite);

        //new MasterInit(shell);

// splash.dispose();

     shell.pack();
     shell.open();

     ControllerOOo.initViewOOo();
     SwtViewerOOo.getInstance().setDocument("private:factory/swriter",null);

     shell.addDisposeListener(new DisposeListener(){
       public void widgetDisposed(DisposeEvent arg0) {
         try {
           SwtViewerOOo.getInstance().terminate();
         } catch (NoConnectionException e) {
           // TODO Automatisch erstellter Catch-Block
           e.printStackTrace();
         }
       }
     });

     // Ereignisschleife
     while (!shell.isDisposed()) {
       // Prüfen, ob Ereignisse warten
        if (!display.readAndDispatch())
             display.sleep();
        }
        beenden();
     }

     // .....
}


............
my ControllerOOo.jar (makes a Composite for a Stacklayout-Container)
............
package de.zuehlke_it.sgv.view.ooo;


import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.net.URISyntaxException;

import javax.swing.JRootPane;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;

import com.sun.star.comp.beans.NoConnectionException;

import de.zuehlke_it.sgv.model.bbv.Dokument;


public class ControllerOOo {

   private static ControllerOOo instance = null;
   private static SwtViewerOOo viewerOOo = null;
   private static Composite comp;

   private static Frame frame;
   private static Panel panel;

   
//===========================================================================

   private ControllerOOo() {
   }

   public static ControllerOOo getInstance(){
     if (instance == null){
      instance = new ControllerOOo();
     }
     return instance;
   }

   public static void initViewOOo(){
     /* Create and setting up frame */
     frame = SWT_AWT.new_Frame(comp);
     panel = new Panel(new BorderLayout()) {
             public void update(java.awt.Graphics g) {
                     paint(g);
             }
     };
     frame.add(panel);
     JRootPane root = new JRootPane();
     panel.add(root);
     java.awt.Container contentPane = root.getContentPane();

     viewerOOo = new SwtViewerOOo();
     contentPane.add(viewerOOo);

   }

   public Composite init(Composite parent) {
     comp = new Composite(parent, SWT.NO_BACKGROUND |  SWT.EMBEDDED);
     return comp;
   }


   public void closeOOoViewer(){
     try {
       viewerOOo.terminate();
     } catch (NoConnectionException e) {
       // TODO Automatisch erstellter Catch-Block
       e.printStackTrace();
     }
   }
   //=== OPENOFFICE ===================================

   public void oeffnen(Dokument dokument){
     viewerOOo.ladeDokument(false,dokument);

   }

   public void drucken(Dokument dokument) {
     viewerOOo.ladeDokument(true,dokument);
     viewerOOo.drucken();
   }
}


............
my SwtViewerOOo.jar (my "little" OpenOffice-Monster...incl. OOoBean-Connect)
............
package de.zuehlke_it.sgv.view.ooo;

import java.awt.Panel;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.PropertyVetoException;
import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.beans.XPropertySet;
import com.sun.star.comp.beans.NoConnectionException;
import com.sun.star.comp.beans.OOoBean;
import com.sun.star.comp.beans.SystemWindowException;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.container.XEnumerationAccess;
import com.sun.star.container.XNameAccess;
import com.sun.star.frame.XDesktop;
import com.sun.star.lang.DisposedException;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.lang.XComponent;
import com.sun.star.text.ControlCharacter;
import com.sun.star.text.XText;
import com.sun.star.text.XTextCursor;
import com.sun.star.text.XTextDocument;
import com.sun.star.text.XTextFieldsSupplier;
import com.sun.star.text.XTextRange;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.util.CloseVetoException;
import com.sun.star.util.XRefreshable;
import com.sun.star.util.XSearchDescriptor;
import com.sun.star.util.XSearchable;
import com.sun.star.view.XPrintable;

import de.zuehlke_it.sgv.SGV;
import de.zuehlke_it.sgv.model.bbv.Baustein;
import de.zuehlke_it.sgv.model.bbv.Dokument;
import de.zuehlke_it.sgv.model.bbv.Kapitel;
import de.zuehlke_it.sgv.model.vorgang.Person;
import de.zuehlke_it.sgv.model.vorgang.Rechnung;
import de.zuehlke_it.sgv.model.vorgang.Schaden;
import de.zuehlke_it.sgv.model.vorgang.Versicherer;
import de.zuehlke_it.sgv.model.vorgang.Vorgang;
import de.zuehlke_it.sgv.other.Basis;

public class SwtViewerOOo extends Panel {

  private static SwtViewerOOo instance = null;
  public final String SWRITER = "private:factory/swriter";
  private static final long serialVersionUID = -1408623115735065822L;

  private OOoBean aBean = null;
  private XDesktop xDesktop = null;

  private Dokument dokument;          // Objekt aus der Anwendung
  private String loadUrl;
  private StringBuffer loadUrlSB;

  private XComponent xComponent;
  private XTextDocument xTextDocument;

  private XTextCursor aktCursor;        // aktueller Cursor zum durchlaufen


  public SwtViewerOOo() {
   super();
   instance = this;
   try {

//    OfficeConnection officeConnection = new LocalOfficeConnection();
//    officeConnection.setUnoUrl(
//    
"uno:localoffice,path=/home/user/staroffice6.0/program;urp;StarOffice.NamingService");
//    aBean = new OOoBean( officeConnection );

     aBean = new OOoBean();
     setLayout(new java.awt.BorderLayout());
     add(aBean, java.awt.BorderLayout.CENTER);
     xDesktop = null;
     xDesktop = aBean.getOOoDesktop();
   } catch (NoConnectionException e) {
     e.printStackTrace();
   }
  }

  public static SwtViewerOOo getInstance(){
    return instance;
  }


  /*
   *  closes the bean viewer and tries to terminate OOo.
   */

  public void terminate() throws NoConnectionException {
    setVisible(false);
    XDesktop xDesktop = null;
    xDesktop = aBean.getOOoDesktop();
    aBean.stopOOoConnection();
    if (xDesktop != null) {
      try {
        xDesktop.terminate();
      } catch (DisposedException e){}
    }

  }

  /*
   * closes the bean viewer, leaves OOo running.
   */
  public void close() {
    setVisible(false);
    aBean.stopOOoConnection();
  }

  public void ladeDokument(boolean hidden, Dokument dokument) {
    this.dokument = dokument;

    String datei = dokument.getDatei();

    // den Dateinamen für eine gültige (uno)URL aufbereiten
    try {
      java.io.File sourceFile = new java.io.File(datei);
      loadUrlSB = new StringBuffer("file:///");
      loadUrlSB.append(sourceFile.getCanonicalPath().replace('\\', '/'));
      loadUrl = loadUrlSB.toString();
    } catch (IOException e) {
      e.printStackTrace();
    }

    // Eigenschaften für das Laden (siehe  
com.sun.star.document.MediaDescriptor )
    PropertyValue[] loadProps = null;
    if (hidden){
      loadProps = new PropertyValue[2];
      loadProps[0] = new PropertyValue();
      loadProps[0].Name = "NoRestore";
      loadProps[0].Value = new Boolean(true);
      loadProps[1] = new PropertyValue();
      loadProps[1].Name = "Hidden";
      loadProps[1].Value = new Boolean(true);
    } else {
      loadProps = new PropertyValue[1];
      loadProps[0] = new PropertyValue();
      loadProps[0].Name = "NoRestore";
      loadProps[0].Value = new Boolean(true);
//     loadProps[1] = new PropertyValue();
//     loadProps[1].Name = "AsTemplate";
//     loadProps[1].Value = new Boolean(false);
    }

    setDocument(loadUrl,loadProps);

    if ( xDesktop.getCurrentComponent() != null ) {

      xComponent = xDesktop.getCurrentComponent();
      xTextDocument = (XTextDocument)UnoRuntime.queryInterface(
                       XTextDocument.class, xComponent);

      if (dokument.getTyp() == SGV.BERICHT){
        variablenEinfuegen();
        kapitelListeEinfuegen();
      }
    }

  }

  public void setDocument(String url, PropertyValue[] loadProps) {

    try {
     // aBean.clearDocument(true);
     aBean.loadFromURL(url, loadProps);
     aBean.aquireSystemWindow();

   } catch (IllegalArgumentException e) {
     e.printStackTrace();
   } catch (CloseVetoException e) {
     e.printStackTrace();
   } catch (NoConnectionException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } catch (SystemWindowException e) {
     e.printStackTrace();
   }
  }

  public void drucken() {
    // query the XPrintable interface from your document
    XPrintable xPrintable =  
(XPrintable)UnoRuntime.queryInterface(XPrintable.class, xComponent);

    // create an empty printOptions array
    PropertyValue[] printOpts = new PropertyValue[0];

//Beispiel 1: Druckoptionen
//  PropertyValue[] printerDesc = new PropertyValue[1];
//  printerDesc[0] = new PropertyValue();
//  printerDesc[0].Name = "Name";
//  printerDesc[0].Value = "5D PDF Creator";
//  xPrintable.setPrinter(printerDesc);

//Beispiel 2: Druckoptionen
//  PropertyValue[] printOpts = new PropertyValue[1];
//  printOpts[0] = new PropertyValue();
//  printOpts[0].Name = "Pages";
//  printOpts[0].Value = "1,7";
//  xPrintable.print(printOpts);

    // Drucken des Dokumentes
     try {
      xPrintable.print(printOpts);
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
    }

  }

  /*
   *  ====== einfügen einzelnen Stammdatenfelder ============================
   *
   *  über festgelegte Benutzerfelder im Dokument
   */

  public void variablenEinfuegen(){
    Vorgang vorgang = Vorgang.getInstance();
    Schaden schaden = vorgang.getSchaden();
    Person schadenOrt = schaden.getSchOrt();
    Rechnung rechnung = vorgang.getRechnung();
    Versicherer versicherer = vorgang.getVersicherer();
    Person versicherter = vorgang.getPerson();
    Person versichererAp = vorgang.getVersichererAp();
    Person ast = schaden.getPerson();

    feldEinfuegen("VR_BEZEICHNUNG", versicherer.getBezeichnung());
    feldEinfuegen("VR_NAME",       versichererAp.getName());
    feldEinfuegen("VR_VORNAME",    versichererAp.getVorname());
    feldEinfuegen("VR_NACHNAME",   versichererAp.getNachname());
    feldEinfuegen("VR_STRASSE",    versichererAp.getStrasse());
    feldEinfuegen("VR_PLZ",        versichererAp.getPlz());
    feldEinfuegen("VR_ORT",        versichererAp.getOrt());
    feldEinfuegen("VR_PLZORT",     versichererAp.getPlzOrt());

    // ....

    feldEinfuegen("TITEL",          dokument.getTitel());
  }

  public void feldEinfuegen (String benutzerfeld, String text){
    try {
      // get XTextFieldsSupplier, XBookmarksSupplier interfaces
      XTextFieldsSupplier xTextFieldsSupplier = (XTextFieldsSupplier)
          UnoRuntime.queryInterface(XTextFieldsSupplier.class,
                                    xComponent);

      if (xTextFieldsSupplier != null) {
        // access the TextFields and the TextFieldMasters collections
        XNameAccess xNamedFieldMasters =  
xTextFieldsSupplier.getTextFieldMasters();
        XEnumerationAccess xEnumeratedFields =  
xTextFieldsSupplier.getTextFields();

        Object fieldMaster = xNamedFieldMasters.getByName(
            "com.sun.star.text.FieldMaster.User." + benutzerfeld);

        // query the XPropertySet interface, we need to set the  
Content property
        XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(
            XPropertySet.class, fieldMaster);

        // insert the column value into field master
        xPropertySet.setPropertyValue("Content", text);
        //  afterwards we must refresh the textfields collection
        XRefreshable xRefreshable = (XRefreshable)UnoRuntime.queryInterface(
            XRefreshable.class, xEnumeratedFields);
        xRefreshable.refresh();
      }

    } catch (NoSuchElementException e) {
    } catch (UnknownPropertyException e) {
    } catch (PropertyVetoException e) {
    } catch (IllegalArgumentException e) {
    } catch (WrappedTargetException e) {
    }
  }

  /*
   *  ====== einfügen der einzelnen Kapitel im definierten Bereich ===========
   *
   *  KapitelListe = Objekt Liste aus der Anwendung, mit ...
   *  - Kapitel = Objekt aus der Anwendung, mit ...
   *   - BausteinListe = Objekt Liste aus der Anwendung, mit ...
   *    - Baustein = Bausteintext
   *
   */


  void kapitelListeEinfuegen() {
    /*
     * Position im Dokument ermitteln
     * 1.Fall : noch nicht vorhanden, dann am Ende des Dok. einfügen
     * 2.Fall : Start zwar vorhanden, aber das Ende ist vorloren gegangen
     * 3.Fall : Bereich besteht bereits, dann an diesen aktualisieren
     *
     */

    XTextRange start = wortSuchen("KSTART");
    XTextRange ende = wortSuchen("KENDE");
    aktCursor = null;

    // Position der Kapitel im Dokument ermitteln ggf. am Ende anhängen
    if (start != null && ende != null){
//     String debugStr;
//     String debugStr2;

      aktCursor = xTextDocument.getText().createTextCursor();
//     debugStr = aktCursor.getString();        // "" (leer)

      aktCursor.gotoRange(start,false);
//     debugStr = aktCursor.getString();        // "KSTART"  
(versteckter Text1)

      aktCursor.collapseToEnd();
//     debugStr = aktCursor.getString();        // "" (leer, steht  
hinter KSTART ?)

//     debugStr2 = ende.getString();            // "KENDE"  
(versteckter Text2)
      aktCursor.gotoRange(ende,true);
//     debugStr = aktCursor.getString();        // markierter Text bis  
ans Ende "KENDE"

    } else {
      XText text = xTextDocument.getText();
      aktCursor = text.createTextCursor();
      aktCursor.gotoEnd(false);
      verstecktenTextEinfuegen(" KSTART ");
    }

    kapitelEinfuegen();
  }

  private void zeilenumbruch(){
    try {
      XText bereich = aktCursor.getText();
      aktCursor.collapseToEnd();
      bereich.insertControlCharacter (
          aktCursor, ControlCharacter.LINE_BREAK, false );
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
    }
  }

  private void kapitelEinfuegen(){
    aktCursor.setString("");
    /*
     * Alle Kapitel mit den jeweiligen Bausteinen einfügen
     * 1. Schritt : Kapitel.Titel (Fett) einsetzen, "versteckt" aufheben
     * 2. Schritt : Kapitel.Baustein.Inhalt (nicht Fett) x mal einsetzen
     * 3. Schritt : nach allen Kapitel, Bereich abschließen
     */

    List kapitelListe = dokument.getKapitelListe();
    List bausteinListe = new ArrayList();
    if (kapitelListe.size() > 0){
      for (int i = 0; i < kapitelListe.size(); i++) {
        Kapitel kapitel = (Kapitel) kapitelListe.get(i);
        if (kapitel.getDrucken()){
          kapitelEinfuegenTitel(kapitel.getTitel());
          zeilenumbruch();

          bausteinListe = kapitel.getBausteine();
          if (bausteinListe.size() > 0){
            for (int j = 0; j < bausteinListe.size(); j++) {
              kapitelEinfuegenBaustein((Baustein) bausteinListe.get(j) );
              zeilenumbruch();
            }
          }
          zeilenumbruch();
        }
      }
      kapitelEinfuegenBeenden();
    }
  }

  private XTextRange wortSuchen(String gesucht) {
    // Ein bestimmtes Wort im Dokument suchen und Position zurückgeben

    XInterface result = null;
    XTextRange range = null;
    try {

      XSearchable xSearchable =
        (com.sun.star.util.XSearchable)
          UnoRuntime.queryInterface(
            com.sun.star.util.XSearchable.class, xTextDocument);

      XSearchDescriptor xSearchDescr =
        (com.sun.star.util.XSearchDescriptor)
           xSearchable.createSearchDescriptor();

      xSearchDescr.setSearchString(gesucht);

      XPropertySet xSearchProp =
        (com.sun.star.beans.XPropertySet)
           UnoRuntime.queryInterface(
             com.sun.star.beans.XPropertySet.class, xSearchDescr);
      xSearchProp.setPropertyValue("SearchCaseSensitive",new Boolean(true));
      xSearchProp.setPropertyValue("SearchWords",new Boolean(true));
      result = (XInterface) xSearchable.findFirst(xSearchDescr);
      if (result != null){
        range = (XTextRange)UnoRuntime.queryInterface(
            com.sun.star.text.XTextRange.class,result);
      }

    } catch( Exception e) {}
    return range;
  }


  private void verstecktenTextEinfuegen(String text){

    XPropertySet xCursorProps = null;
    try {
      aktCursor.collapseToEnd();
      // Text verstecken (ausblenden,hidden) einfuegen
      aktCursor.setString(text);
      xCursorProps =
        (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,  
aktCursor );
      xCursorProps.setPropertyValue ( "CharHidden", new Boolean (true) );

      aktCursor.collapseToEnd();
      xCursorProps =
        (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,  
aktCursor );
      xCursorProps.setPropertyValue ( "CharHidden", new Boolean (false) );

    } catch (UnknownPropertyException e) {
    } catch (PropertyVetoException e) {
    } catch (IllegalArgumentException e) {
    } catch (WrappedTargetException e) {
    }

  }

  private void kapitelEinfuegenTitel(String titel) {

    aktCursor.collapseToEnd();
    try {
      aktCursor.getString();
      aktCursor.setString(titel);

      // Schriftbild formatieren
      XPropertySet xCursorProps =
        (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,  
aktCursor );
      xCursorProps.setPropertyValue ( "CharWeight",
                       new Float(com.sun.star.awt.FontWeight.BOLD) );
      xCursorProps =
        (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,  
aktCursor );
      xCursorProps.setPropertyValue ( "CharHidden", new Boolean (false) );

    } catch (UnknownPropertyException e) {
    } catch (PropertyVetoException e) {
    } catch (IllegalArgumentException e) {
    } catch (WrappedTargetException e) {
    }
  }

  private void kapitelEinfuegenBaustein(Baustein baustein) {

    if (baustein.getInhalt().compareTo("") != 0){
      try {
        aktCursor.collapseToEnd();
        aktCursor.setString(baustein.getInhalt());

        // Schriftbild formatieren
        XPropertySet xCursorProps =
          (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,  
aktCursor );
        xCursorProps.setPropertyValue ( "CharWeight",
                         new Float(com.sun.star.awt.FontWeight.NORMAL) );

      } catch (UnknownPropertyException e) {
      } catch (PropertyVetoException e) {
      } catch (IllegalArgumentException e) {
      } catch (WrappedTargetException e) {
      }
    }


  }

  private void kapitelEinfuegenBeenden(){
    try {
      aktCursor.collapseToEnd();
      XText bereich = aktCursor.getText();
      bereich.insertControlCharacter (
          aktCursor, ControlCharacter.LINE_BREAK, false );
      verstecktenTextEinfuegen(" KENDE ");
    } catch (IllegalArgumentException e) {
    }
  }

}



............
my environment and the error below
............

java.vm.specification.vendor    =       Sun Microsystems Inc.
user.variant    =
os.name =       Windows XP
sun.jnu.encoding        =       Cp1252
java.library.path       =        
C:\WINDOWS\system32;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;D:\dev-database\mysql5\bin;c:\Programme\OpenOffice2\program\classes;
java.specification.name =       Java Platform API Specification
java.class.version      =       49.0
sun.management.compiler =       HotSpot Client Compiler
os.version      =       5.1
user.home       =       C:\Dokumente und Einstellungen\Erik Z³hlke
user.timezone   =
java.awt.printerjob     =       sun.awt.windows.WPrinterJob
file.encoding   =       Cp1252
java.specification.version      =       1.5
java.class.path =       Starter.jar
user.name       =       Erik Z³hlke
java.vm.specification.version   =       1.0
java.home       =       D:\dev-java\jre1.5
sun.arch.data.model     =       32
user.language   =       de
java.specification.vendor       =       Sun Microsystems Inc.
awt.toolkit     =       sun.awt.windows.WToolkit
java.vm.info    =       mixed mode
java.version    =       1.5.0_05
java.ext.dirs   =       D:\dev-java\jre1.5\lib\ext
sun.boot.class.path     =        
D:\dev-java\jre1.5\lib\rt.jar;D:\dev-java\jre1.5\lib\i18n.jar;D:\dev-java\jre1.5\lib\sunrsasign.jar;D:\dev-java\jre1.5\lib\jsse.jar;D:\dev
-java\jre1.5\lib\jce.jar;D:\dev-java\jre1.5\lib\charsets.jar;D:\dev-java\jre1.5\classes
java.vendor     =       Sun Microsystems Inc.
file.separator  =       \
java.vendor.url.bug     =       http://java.sun.com/cgi-bin/bugreport.cgi
sun.io.unicode.encoding =       UnicodeLittle
sun.cpu.endian  =       little
sun.desktop     =       windows
sun.cpu.isalist =       pentium_pro+mmx pentium_pro pentium+mmx  
pentium i486 i386 i86
Exception in thread "main" java.lang.UnsatisfiedLinkError: no  
officebean in java.library.path
         at java.lang.ClassLoader.loadLibrary(Unknown Source)
         at java.lang.Runtime.loadLibrary0(Unknown Source)
         at java.lang.System.loadLibrary(Unknown Source)
         at  
com.sun.star.lib.util.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:72)
         at  
com.sun.star.comp.beans.LocalOfficeConnection.<clinit>(LocalOfficeConnection.java:153)
         at com.sun.star.comp.beans.OOoBean.getOOoConnection(OOoBean.java:288)
         at  
com.sun.star.comp.beans.OOoBean.getMultiServiceFactory(OOoBean.java:308)
         at com.sun.star.comp.beans.OOoBean.getOOoDesktop(OOoBean.java:343)
         at  
de.zuehlke_it.sgv.view.ooo.SwtViewerOOo.<init>(SwtViewerOOo.java:83)
         at  
de.zuehlke_it.sgv.view.ooo.ControllerOOo.initViewOOo(ControllerOOo.java:54)
         at de.zuehlke_it.sgv.SGV.main(SGV.java:181)


......
my error with "java -verbose -jar Starter.jar"
......

[Loaded sun.awt.NullComponentPeer from D:\dev-java\jre1.5\lib\rt.jar]
[Loaded com.sun.star.uno.Exception from file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.lang.IllegalArgumentException from  
file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.uno.XInterface from file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.text.XTextRange from file:/C:/sgv/libs/unoil.jar]
[Loaded com.sun.star.text.XSimpleText from file:/C:/sgv/libs/unoil.jar]
[Loaded com.sun.star.text.XText from file:/C:/sgv/libs/unoil.jar]
[Loaded com.sun.star.lang.WrappedTargetException from  
file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.beans.PropertyVetoException from  
file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.beans.UnknownPropertyException from  
file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.beans.XPropertySet from file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.util.XSearchable from file:/C:/sgv/libs/unoil.jar]
[Loaded com.sun.star.container.NoSuchElementException from  
file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.text.XTextFieldsSupplier from  
file:/C:/sgv/libs/unoil.jar]
[Loaded com.sun.star.uno.RuntimeException from file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.lang.DisposedException from file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.comp.beans.SystemWindowException from  
file:/C:/sgv/libs/officebean.jar]
[Loaded com.sun.star.util.CloseVetoException from file:/C:/sgv/libs/unoil.jar]
[Loaded java.io.Externalizable from D:\dev-java\jre1.5\lib\rt.jar]
[Loaded com.sun.star.comp.beans.OOoBean from file:/C:/sgv/libs/officebean.jar]
[Loaded com.sun.star.io.IOException from file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.io.BufferSizeExceededException from  
file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.io.NotConnectedException from file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.comp.beans.NoDocumentException from  
file:/C:/sgv/libs/officebean.jar]
[Loaded com.sun.star.comp.beans.OOoBean$1 from  
file:/C:/sgv/libs/officebean.jar]
[Loaded com.sun.star.comp.beans.HasConnectionException from  
file:/C:/sgv/libs/officebean.jar]
[Loaded com.sun.star.lang.XComponent from file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.comp.beans.OfficeConnection from  
file:/C:/sgv/libs/officebean.jar]
[Loaded com.sun.star.frame.XFrame from file:/C:/sgv/libs/unoil.jar]
[Loaded com.sun.star.frame.XComponentLoader from file:/C:/sgv/libs/unoil.jar]
[Loaded com.sun.star.comp.beans.CallWatchThread from  
file:/C:/sgv/libs/officebean.jar]
[Loaded com.sun.star.comp.beans.LocalOfficeConnection from  
file:/C:/sgv/libs/officebean.jar]
[Loaded com.sun.star.comp.beans.OfficeWindow from  
file:/C:/sgv/libs/officebean.jar]
[Loaded com.sun.star.connection.ConnectionSetupException from  
file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.connection.NoConnectException from  
file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.bridge.BridgeExistsException from  
file:/C:/sgv/libs/ridl.jar]
[Loaded com.sun.star.lib.util.NativeLibraryLoader from  
file:/C:/sgv/libs/jurt.jar]
[Loaded com.sun.star.lib.util.UrlToFileMapper from file:/C:/sgv/libs/jurt.jar]
[Loaded java.net.URISyntaxException from D:\dev-java\jre1.5\lib\rt.jar]
Exception in thread "main" java.lang.UnsatisfiedLinkError: no  
officebean in java.library.path
         at java.lang.ClassLoader.loadLibrary(Unknown Source)
         at java.lang.Runtime.loadLibrary0(Unknown Source)
         at java.lang.System.loadLibrary(Unknown Source)
         at  
com.sun.star.lib.util.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:72)
         at  
com.sun.star.comp.beans.LocalOfficeConnection.<clinit>(LocalOfficeConnection.java:153)
         at com.sun.star.comp.beans.OOoBean.getOOoConnection(OOoBean.java:288)
         at  
com.sun.star.comp.beans.OOoBean.getMultiServiceFactory(OOoBean.java:308)
         at com.sun.star.comp.beans.OOoBean.getOOoDesktop(OOoBean.java:343)
         at  
de.zuehlke_it.sgv.view.ooo.SwtViewerOOo.<init>(SwtViewerOOo.java:83)
         at  
de.zuehlke_it.sgv.view.ooo.ControllerOOo.initViewOOo(ControllerOOo.java:54)
         at de.zuehlke_it.sgv.SGV.main(SGV.java:181)



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Parent Message unknown Re: [api-dev] OOeBean error in a swt / standalone application

by Stephan Bergmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

info@... wrote:

> Dear community, mailing-list, and sun/openoffice developer,
>
> please help meeeeeee......!
>
> I have a big problem (see the end of this posting), when i make a .jar
> (standalone application) out from eclipse i become the error. In eclipse
> my aplication was work. When i start the application with "java
> -verbose" i see more, it´s comes a URISyntaxException. By i can not see,
> why!
>
> ok, follow you can finde...(search for "my")
>
> 1. my main.class
> 2. my ControllerOOo.jar (Composite with swt/awt)
> 3. my SwtViewerOOo.jar (class with OOeBean)
> 4. my environment
> 5. my error
>
> Please help me, i work full on this the last three day.
>
> On the end i must say sorry for my english and my mixed german/english
> source code, i hope you can understand them.
> Thanks and by
> from Hamburg/Germany
> Erik
[...]

> ............
> my environment and the error below
> ............
>
> java.vm.specification.vendor    =       Sun Microsystems Inc.
> user.variant    =
> os.name =       Windows XP
> sun.jnu.encoding        =       Cp1252
> java.library.path       =      
> C:\WINDOWS\system32;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;D:\dev-database\mysql5\bin;c:\Programme\OpenOffice2\program\classes;
>
> java.specification.name =       Java Platform API Specification
> java.class.version      =       49.0
> sun.management.compiler =       HotSpot Client Compiler
> os.version      =       5.1
> user.home       =       C:\Dokumente und Einstellungen\Erik Z³hlke
> user.timezone   =
> java.awt.printerjob     =       sun.awt.windows.WPrinterJob
> file.encoding   =       Cp1252
> java.specification.version      =       1.5
> java.class.path =       Starter.jar
> user.name       =       Erik Z³hlke
> java.vm.specification.version   =       1.0
> java.home       =       D:\dev-java\jre1.5
> sun.arch.data.model     =       32
> user.language   =       de
> java.specification.vendor       =       Sun Microsystems Inc.
> awt.toolkit     =       sun.awt.windows.WToolkit
> java.vm.info    =       mixed mode
> java.version    =       1.5.0_05
> java.ext.dirs   =       D:\dev-java\jre1.5\lib\ext
> sun.boot.class.path     =      
> D:\dev-java\jre1.5\lib\rt.jar;D:\dev-java\jre1.5\lib\i18n.jar;D:\dev-java\jre1.5\lib\sunrsasign.jar;D:\dev-java\jre1.5\lib\jsse.jar;D:\dev
>
> -java\jre1.5\lib\jce.jar;D:\dev-java\jre1.5\lib\charsets.jar;D:\dev-java\jre1.5\classes
>
> java.vendor     =       Sun Microsystems Inc.
> file.separator  =       \
> java.vendor.url.bug     =       http://java.sun.com/cgi-bin/bugreport.cgi
> sun.io.unicode.encoding =       UnicodeLittle
> sun.cpu.endian  =       little
> sun.desktop     =       windows
> sun.cpu.isalist =       pentium_pro+mmx pentium_pro pentium+mmx pentium
> i486 i386 i86
> Exception in thread "main" java.lang.UnsatisfiedLinkError: no officebean
> in java.library.path
>         at java.lang.ClassLoader.loadLibrary(Unknown Source)
>         at java.lang.Runtime.loadLibrary0(Unknown Source)
>         at java.lang.System.loadLibrary(Unknown Source)
>         at
> com.sun.star.lib.util.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:72)
>
>         at
> com.sun.star.comp.beans.LocalOfficeConnection.<clinit>(LocalOfficeConnection.java:153)
>
>         at
> com.sun.star.comp.beans.OOoBean.getOOoConnection(OOoBean.java:288)
>         at
> com.sun.star.comp.beans.OOoBean.getMultiServiceFactory(OOoBean.java:308)
>         at com.sun.star.comp.beans.OOoBean.getOOoDesktop(OOoBean.java:343)
>         at
> de.zuehlke_it.sgv.view.ooo.SwtViewerOOo.<init>(SwtViewerOOo.java:83)
>         at
> de.zuehlke_it.sgv.view.ooo.ControllerOOo.initViewOOo(ControllerOOo.java:54)
>         at de.zuehlke_it.sgv.SGV.main(SGV.java:181)

<OOo-installation>\program\classes\officebean.jar must be in the CLASSPATH.

-Stephan

[...]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: [api-dev] OOeBean error in a swt / standalone application

by info-1250 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

(Dear mailinglist, sorry for my last big posting...)
-----------------------

Quoting Stephan Bergmann <stephan.bergmann@...>:

>
> <OOo-installation>\program\classes\officebean.jar must be in the CLASSPATH.
>
> -Stephan
>
> [...]
>

Hello Stephan,

thank you for your references, thus I looked for again for the  
differences between Eclipse and mine ?java? call.

Under Eclipse I merged the OOo libraries directly out  
[installdir\program\classes], but i use in my MANIFEST.MF copies from  
there in the [application]\libs dir.

After the following call get ahead I then also a ?small? piece:

>> java -verbose -cp C:\programme\OpenOffice2\program\classes -jar Starter.jar

But a new error was displaying, if I had not already despaired, comes  
then now became I this to. The Error...a conection Error.

>> [Loaded de.zuehlke_it.sgv.view.bbv.BausteineWG$4 from  
>> file:/C:/sgv/Starter.jar]
>> [Loaded de.zuehlke_it.sgv.view.bbv.BausteineWG$5 from  
>> file:/C:/sgv/Starter.jar]
>> [Loaded de.zuehlke_it.sgv.view.bbv.BausteineWG$6 from  
>> file:/C:/sgv/Starter.jar]
>> [Loaded de.zuehlke_it.sgv.view.bbv.BausteineWG$7 from  
>> file:/C:/sgv/Starter.jar]
>> [Loaded de.zuehlke_it.sgv.view.bbv.EditorWG from file:/C:/sgv/Starter.jar]
>> [Loaded de.zuehlke_it.sgv.view.bbv.EditorWG$1 from file:/C:/sgv/Starter.jar]
>> [Loaded de.zuehlke_it.sgv.view.bbv.EditorWG$2 from file:/C:/sgv/Starter.jar]
>> [Loaded de.zuehlke_it.sgv.view.ooo.ControllerOOo from  
>> file:/C:/sgv/Starter.jar]
>> Exception in thread "main" java.lang.NoClassDefFoundError:  
>> >>com/sun/star/comp/beans/NoConnectionException
>>        at de.zuehlke_it.sgv.view.StackView.init(StackView.java:43)
>>        at de.zuehlke_it.sgv.view.MainComp.<init>(MainComp.java:31)
>>        at de.zuehlke_it.sgv.SGV.main(SGV.java:171)

regards...

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Parent Message unknown Re: [api-dev] OOeBean error in a swt / standalone application

by Joachim Lingner - Sun Germany Software Engineer - ham02 - Hamburg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 >>> Exception in thread "main" java.lang.NoClassDefFoundError:
 >>> >>com/sun/star/comp/beans/NoConnectionException
 >>>        at de.zuehlke_it.sgv.view.StackView.init(StackView.java:43)
 >>>        at de.zuehlke_it.sgv.view.MainComp.<init>(MainComp.java:31)
 >>>        at de.zuehlke_it.sgv.SGV.main(SGV.java:171)
 >

this error indicates that the NoConnectionException is not found
(NoClassDefFoundError). This class is in officebean.jar. Therefore make
sure the officebean is on the class path, then the error should be gone.

Joachim

Erik Zuehlke wrote:

> (Dear mailinglist, sorry for my last big posting...)
> -----------------------
>
> Quoting Stephan Bergmann <stephan.bergmann@...>:
>
>>
>> <OOo-installation>\program\classes\officebean.jar must be in the
>> CLASSPATH.
>>
>> -Stephan
>>
>> [...]
>>
>
> Hello Stephan,
>
> thank you for your references, thus I looked for again for the  
> differences between Eclipse and mine ?java? call.
>
> Under Eclipse I merged the OOo libraries directly out  
> [installdir\program\classes], but i use in my MANIFEST.MF copies from  
> there in the [application]\libs dir.
>
> After the following call get ahead I then also a ?small? piece:
>
>>> java -verbose -cp C:\programme\OpenOffice2\program\classes -jar
>>> Starter.jar
>
>
> But a new error was displaying, if I had not already despaired, comes  
> then now became I this to. The Error...a conection Error.
>
>>> [Loaded de.zuehlke_it.sgv.view.bbv.BausteineWG$4 from  
>>> file:/C:/sgv/Starter.jar]
>>> [Loaded de.zuehlke_it.sgv.view.bbv.BausteineWG$5 from  
>>> file:/C:/sgv/Starter.jar]
>>> [Loaded de.zuehlke_it.sgv.view.bbv.BausteineWG$6 from  
>>> file:/C:/sgv/Starter.jar]
>>> [Loaded de.zuehlke_it.sgv.view.bbv.BausteineWG$7 from  
>>> file:/C:/sgv/Starter.jar]
>>> [Loaded de.zuehlke_it.sgv.view.bbv.EditorWG from
>>> file:/C:/sgv/Starter.jar]
>>> [Loaded de.zuehlke_it.sgv.view.bbv.EditorWG$1 from
>>> file:/C:/sgv/Starter.jar]
>>> [Loaded de.zuehlke_it.sgv.view.bbv.EditorWG$2 from
>>> file:/C:/sgv/Starter.jar]
>>> [Loaded de.zuehlke_it.sgv.view.ooo.ControllerOOo from  
>>> file:/C:/sgv/Starter.jar]
>>> Exception in thread "main" java.lang.NoClassDefFoundError:  
>>> >>com/sun/star/comp/beans/NoConnectionException
>>>        at de.zuehlke_it.sgv.view.StackView.init(StackView.java:43)
>>>        at de.zuehlke_it.sgv.view.MainComp.<init>(MainComp.java:31)
>>>        at de.zuehlke_it.sgv.SGV.main(SGV.java:171)
>
>
> regards...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Parent Message unknown Re: [api-dev] OOeBean error in a swt / standalone application

by Steffen Grund :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

if your set your classpath like this:

> java -verbose -cp C:\programme\OpenOffice2\program\classes -jar Starter.jar

you should have a look at
http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html

(or have a look at the Java examples in the SDK,
http://api.openoffice.org/SDK/)

Each jar file must be referenced explicitly in the classpath.

Regards, Steffen

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...