landscape style Tom Schindl How do I switch the orientation

Switching the orientation involves 2 steps you first have to switch the orientation

and afterwards you have to switch the size (or the other way round)

// Create a new empty spreadsheet PropertyValue[] loadProps = new PropertyValue[0]; XComponent xCalcComponent = xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, loadProps); XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, xCalcComponent); // Get the page style XStyleFamiliesSupplier xSupplier = ( XStyleFamiliesSupplier ) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xSpreadsheetDocument ); XNameAccess xNameAccess = xSupplier.getStyleFamilies(); XNameContainer xPageStyleCollection = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName( "PageStyles" )); XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPageStyleCollection.getByName("Default") ); // Flip the size Size size = (Size)xPropertySet.getPropertyValue("Size"); int height = size.Height; size.Height=size.Width; size.Width=height; xPropertySet.setPropertyValue("Size",size); // Switch the orientation xPropertySet.setPropertyValue("IsLandscape",new Boolean(true) );
Fixed name of style-collection used Initial version