Seite 1 von 1

mit Java Tabulator in writer setzen

Verfasst: Sa, 16.10.2010 15:21
von alda
Hallo zusammen,

ich möchte von Java aus Tabulatoren in einem Writer-Dokument setzen. Mit basic habe ich das ganz einfach so gemacht:
  • dim newstops(2) as object
    dim tabStop As New com.sun.star.style.TabStop

    sUrl = "staroffice.factory:swriter"
    oDocument = oDesktop.LoadComponentFromUrl(sUrl,"_blank",0,mNoArgs)

    oStyleFamilies = oDocument.StyleFamilies
    oParagraphStyles = oStyleFamilies.getByName("ParagraphStyles")
    oStdPage = oParagraphStyles.getByName("Standard")

    tabStop.position = 7000
    tabStop.alignment = com.sun.star.style.TabAlign.LEFT
    newstops(0) = tabStop
    tabStop.position = 8000
    tabStop.alignment = com.sun.star.style.TabAlign.LEFT
    newstops(1) = tabStop
    oStdPage.ParaTabstops=newstops()
Doch wie funktioniert das mit Java?
  • XNameContainer xParagraphStyles = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xStyleFamilies.getByName("ParagraphStyles"));
    Object oStandard = xParagraphStyles.getByName("Standard");
    TabStop[] newTabStop = new TabStop[2];
    newTabStop[0] = new TabStop(); ;
    newTabStop[0].Position = 7000;
    newTabStop[0].Alignment = com.sun.star.style.TabAlign.LEFT;

    newTabStop[1] = new TabStop(); ;
    newTabStop[1].Position = 8000;
    newTabStop[1].Alignment = com.sun.star.style.TabAlign.LEFT;

    dDocument = xComponentLoader.loadComponentFromURL(sUrl, "_blank", 0, mFileProperties);
    XTextDocument xTextDocument = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, dDocument);
    XText oText = xTextDocument.getText();
    oCursor = oText.createTextCursor();
    XPropertySet xTextCursorProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, oCursor);
    xTextCursorProps.setPropertyValue("ParaTabStops", newTabStop);
Fehlt die Zuordnung von newTabStop zu oStandard, ansonsten wird mit dem setPropertyValue der Tab zwar gesetzt, aber nicht in der Formatvorlage, sondern nur local direkt im Text. Wäre nett, wenn mir jemand einen Tipp geben könnte, möglichst mit Beispiel.

Vielen Dank schon mal!

Re: mit Java Tabulator in writer setzen

Verfasst: Sa, 16.10.2010 17:32
von Karolus
Hallo
Dein Basic-code ist zumindest sehr unvollständig ...

Gruß Karo