mit Java Tabulator in writer setzen

Programmierung unter AOO/LO (StarBasic, Python, Java, ...)

Moderator: Moderatoren

alda
Beiträge: 2
Registriert: Sa, 16.10.2010 15:09

mit Java Tabulator in writer setzen

Beitrag 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!
Zuletzt geändert von alda am Sa, 16.10.2010 19:36, insgesamt 2-mal geändert.
Karolus
********
Beiträge: 7532
Registriert: Mo, 02.01.2006 19:48

Re: mit Java Tabulator in writer setzen

Beitrag von Karolus »

Hallo
Dein Basic-code ist zumindest sehr unvollständig ...

Gruß Karo
LO7.4.7.2 debian 12(bookworm) auf Raspberry5 8GB (ARM64)
LO25.2.3.2 flatpak debian 12(bookworm) auf Raspberry5 8GB (ARM64)
Antworten