I'm using Java to operate on my file. I want to customize headers on each page or cutsomize style of each page. For example for page one set style first page, for page two,for, five set style default. It's possible or not ?
here is sample of my code
Code: Select all
Object oDesktop = xOfficeFactory.createInstanceWithContext(
"com.sun.star.frame.Desktop", xOfficeComponentContext);
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
XDesktop.class, oDesktop);
XComponent xCurrentComponent = xDesktop.getCurrentComponent();
XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xCurrentComponent);
XController xController = xModel.getCurrentController();
XTextViewCursorSupplier xViewCursorSupplier =
(XTextViewCursorSupplier) UnoRuntime.queryInterface(
XTextViewCursorSupplier.class, xController);
XTextViewCursor xViewCursor = xViewCursorSupplier.getViewCursor();
XPropertySet xCursorPropertySet = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xViewCursor);
XPageCursor xPageCursor = (XPageCursor) UnoRuntime.queryInterface(
XPageCursor.class, xViewCursor);
XText xDocumentText = xViewCursor.getText();
com.sun.star.text.XTextCursor xTCursor = xDocumentText.createTextCursor();
xPageCursor.jumpToFirstPage();
XTextCursor xModelCursor = xDocumentText.createTextCursorByRange(xViewCursor.getStart());
XParagraphCursor xParagraphCursor = (XParagraphCursor) UnoRuntime.queryInterface(
XParagraphCursor.class, xModelCursor);
xParagraphCursor.gotoEndOfParagraph(false);
xParagraphCursor.setString("Hello");
XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xCurrentComponent);
PropertyValue[] storeProps = new PropertyValue[1];
storeProps[0] = new PropertyValue();
storeProps[0].Name = "FilterName";
storeProps[0].Value = "MS Word 97";
XStyleFamiliesSupplier xStyleFamiliesSupplier = UnoRuntime.queryInterface(
XStyleFamiliesSupplier.class, xModel);
XNameAccess xNameAccess = xStyleFamiliesSupplier.getStyleFamilies();
XNameContainer xNameContainer = UnoRuntime.queryInterface(
XNameContainer.class, xNameAccess.getByName("PageStyles"));
XNameAccess xNameAccess2 = UnoRuntime.queryInterface(
XNameAccess.class, xNameContainer);
XStyle xStyle = UnoRuntime.queryInterface(
XStyle.class, xNameAccess2.getByName("Standard"));
XPropertySet xPageStyleProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xStyle );
xPageStyleProps.setPropertyValue("LeftMargin", new Short((short) 5000));
xPageStyleProps.setPropertyValue("RightMargin", new Short((short) 5000));
xPageStyleProps.setPropertyValue("TopMargin", new Short((short) 5000));
xPageStyleProps.setPropertyValue("FooterIsOn", true);
xPageStyleProps.setPropertyValue("HeaderIsOn", true);
//