neue Seite in Writer-Dokument einfügen

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

Moderator: Moderatoren

Matrixx
Beiträge: 2
Registriert: Mo, 05.07.2004 13:19
Wohnort: Lengenfeld

neue Seite in Writer-Dokument einfügen

Beitrag von Matrixx »

Hallo,

ich versuche mit Java OpenOffice zu steuern. Das funktioniert eigentlich auch ganz gut, nur kann ich keine neue Seite in ein vorhandenes Dokument einfügen.

Habe es mit einem Beispiel aus dem DevGuide probiert, aber es tut sich nichts:

Code: Alles auswählen

oeffneTextDokument("file:///C:/PAGE_NEU.sxw");     // returns a document
    if (oDesktop == null) {
       oInterface = (XInterface) xMSF.createInstance("com.sun.star.frame.Desktop");
       oDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, oInterface);
    }

          XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class, aDoc);
          XController xController = xModel.getCurrentController();
          // the controller gives us the TextViewCursor
          XTextViewCursorSupplier xViewCursorSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController);
          XTextViewCursor xViewCursor = xViewCursorSupplier.getViewCursor();
         
          XPageCursor xPageCursor = (XPageCursor)UnoRuntime.queryInterface(
              XPageCursor.class, xViewCursor);
          System.out.println("The current page number is " + xPageCursor.getPage());
         
         
          // query its XPropertySet interface, we want to set character and paragraph properties
          //XPropertySet xCursorPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xViewCursor);
   
          XMultiServiceFactory xDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(
              XMultiServiceFactory.class, document );

          // use the service 'com.sun.star.style.ParagraphStyle'
          XInterface xInterface = (XInterface) xDocMSF.createInstance( "com.sun.star.style.ParagraphStyle" );

          // create a supplier to get the Style family collection
          XStyleFamiliesSupplier xSupplier = ( XStyleFamiliesSupplier ) UnoRuntime.queryInterface(
              XStyleFamiliesSupplier.class, document );

          // get the NameAccess interface from the Style family collection
          XNameAccess xNameAccess = xSupplier.getStyleFamilies();

          // select the Paragraph styles, you get the Paragraph style collection
          XNameContainer xParaStyleCollection = (XNameContainer) UnoRuntime.queryInterface(
              XNameContainer.class, xNameAccess.getByName( "ParagraphStyles" ));

          // create a PropertySet to set the properties for the new Paragraphstyle
          XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(
              XPropertySet.class, xInterface );
          System.out.println( "create a PropertySet to set the properties for the new Paragraphstyle" );

          xPropertySet.setPropertyValue("BreakType", com.sun.star.style.BreakType.PAGE_BEFORE );
          System.out.println( "set the paragraph attribute Breaktype to PageAfter" );
     // --> nichts passiert
Kann mir jemand helfen?

Gruß Matrixx