HelloTextTableShape.java (34dd1e25) | HelloTextTableShape.java (002e2b2b) |
---|---|
1/************************************************************** | 1/************************************************************** |
2 * | 2 * |
3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at | 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at |
10 * | 10 * |
11 * http://www.apache.org/licenses/LICENSE-2.0 | 11 * http://www.apache.org/licenses/LICENSE-2.0 |
12 * | 12 * |
13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. | 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. |
19 * | 19 * |
20 *************************************************************/ 21 22 23 24import com.sun.star.lang.XComponent; 25import com.sun.star.uno.XComponentContext; 26import com.sun.star.uno.UnoRuntime; 27import com.sun.star.uno.AnyConverter; --- 34 unchanged lines hidden (view full) --- 62import com.sun.star.text.XTextTablesSupplier; 63import com.sun.star.container.XNameAccess; 64import com.sun.star.container.XNamed; 65import com.sun.star.text.XBookmarksSupplier; 66import com.sun.star.text.XTextRange; 67 68/** 69 * | 20 *************************************************************/ 21 22 23 24import com.sun.star.lang.XComponent; 25import com.sun.star.uno.XComponentContext; 26import com.sun.star.uno.UnoRuntime; 27import com.sun.star.uno.AnyConverter; --- 34 unchanged lines hidden (view full) --- 62import com.sun.star.text.XTextTablesSupplier; 63import com.sun.star.container.XNameAccess; 64import com.sun.star.container.XNamed; 65import com.sun.star.text.XBookmarksSupplier; 66import com.sun.star.text.XTextRange; 67 68/** 69 * |
70 * @author dschulten | 70 * @author dschulten |
71 */ 72public class HelloTextTableShape { 73 74 private XComponentContext xRemoteContext = null; 75 private XMultiComponentFactory xRemoteServiceManager = null; 76 77 /** Creates a new instance of HelloTextTableShape */ 78 public HelloTextTableShape() { --- 12 unchanged lines hidden (view full) --- 91 e.printStackTrace(); 92 } 93 finally { 94 System.exit(0); 95 } 96 97 } 98 | 71 */ 72public class HelloTextTableShape { 73 74 private XComponentContext xRemoteContext = null; 75 private XMultiComponentFactory xRemoteServiceManager = null; 76 77 /** Creates a new instance of HelloTextTableShape */ 78 public HelloTextTableShape() { --- 12 unchanged lines hidden (view full) --- 91 e.printStackTrace(); 92 } 93 finally { 94 System.exit(0); 95 } 96 97 } 98 |
99 protected void useDocuments() throws java.lang.Exception { | 99 protected void useDocuments() throws java.lang.Exception { |
100 useWriter(); 101 useCalc(); 102 useDraw(); 103 } 104 105 protected void useWriter() throws java.lang.Exception { 106 try { 107 // create new writer document and get text, then manipulate text --- 101 unchanged lines hidden (view full) --- 209 } 210 211 } 212 213 protected void useCalc() throws java.lang.Exception { 214 try { 215 // create new calc document and manipulate cell text 216 XComponent xCalcComponent = newDocComponent("scalc"); | 100 useWriter(); 101 useCalc(); 102 useDraw(); 103 } 104 105 protected void useWriter() throws java.lang.Exception { 106 try { 107 // create new writer document and get text, then manipulate text --- 101 unchanged lines hidden (view full) --- 209 } 210 211 } 212 213 protected void useCalc() throws java.lang.Exception { 214 try { 215 // create new calc document and manipulate cell text 216 XComponent xCalcComponent = newDocComponent("scalc"); |
217 XSpreadsheetDocument xSpreadsheetDocument = | 217 XSpreadsheetDocument xSpreadsheetDocument = |
218 (XSpreadsheetDocument)UnoRuntime.queryInterface( 219 XSpreadsheetDocument .class, xCalcComponent); 220 Object sheets = xSpreadsheetDocument.getSheets(); 221 XIndexAccess xIndexedSheets = (XIndexAccess)UnoRuntime.queryInterface( 222 XIndexAccess.class, sheets); | 218 (XSpreadsheetDocument)UnoRuntime.queryInterface( 219 XSpreadsheetDocument .class, xCalcComponent); 220 Object sheets = xSpreadsheetDocument.getSheets(); 221 XIndexAccess xIndexedSheets = (XIndexAccess)UnoRuntime.queryInterface( 222 XIndexAccess.class, sheets); |
223 Object sheet = xIndexedSheets.getByIndex(0); | 223 Object sheet = xIndexedSheets.getByIndex(0); |
224 225 //get cell A2 in first sheet 226 XCellRange xSpreadsheetCells = (XCellRange)UnoRuntime.queryInterface( 227 XCellRange.class, sheet); 228 XCell xCell = xSpreadsheetCells.getCellByPosition(0,1); 229 XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface( 230 XPropertySet.class, xCell); 231 xCellProps.setPropertyValue("IsTextWrapped", new Boolean(true)); --- 36 unchanged lines hidden (view full) --- 268 xRemoteContext = null; 269 throw e; 270 } 271 272 } 273 274 protected void useDraw() throws java.lang.Exception { 275 try { | 224 225 //get cell A2 in first sheet 226 XCellRange xSpreadsheetCells = (XCellRange)UnoRuntime.queryInterface( 227 XCellRange.class, sheet); 228 XCell xCell = xSpreadsheetCells.getCellByPosition(0,1); 229 XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface( 230 XPropertySet.class, xCell); 231 xCellProps.setPropertyValue("IsTextWrapped", new Boolean(true)); --- 36 unchanged lines hidden (view full) --- 268 xRemoteContext = null; 269 throw e; 270 } 271 272 } 273 274 protected void useDraw() throws java.lang.Exception { 275 try { |
276 //create new draw document and insert ractangle shape | 276 //create new draw document and insert rectangle shape |
277 XComponent xDrawComponent = newDocComponent("sdraw"); 278 XDrawPagesSupplier xDrawPagesSupplier = 279 (XDrawPagesSupplier)UnoRuntime.queryInterface( 280 XDrawPagesSupplier.class, xDrawComponent); 281 282 Object drawPages = xDrawPagesSupplier.getDrawPages(); 283 XIndexAccess xIndexedDrawPages = (XIndexAccess)UnoRuntime.queryInterface( 284 XIndexAccess.class, drawPages); --- 117 unchanged lines hidden (view full) --- 402 403 xTableProps.setPropertyValue("TableBorder", bord); 404 405 bord = (TableBorder)xTableProps.getPropertyValue("TableBorder"); 406 theLine = bord.TopLine; 407 int col = theLine.Color; 408 System.out.println(col); 409 } | 277 XComponent xDrawComponent = newDocComponent("sdraw"); 278 XDrawPagesSupplier xDrawPagesSupplier = 279 (XDrawPagesSupplier)UnoRuntime.queryInterface( 280 XDrawPagesSupplier.class, xDrawComponent); 281 282 Object drawPages = xDrawPagesSupplier.getDrawPages(); 283 XIndexAccess xIndexedDrawPages = (XIndexAccess)UnoRuntime.queryInterface( 284 XIndexAccess.class, drawPages); --- 117 unchanged lines hidden (view full) --- 402 403 xTableProps.setPropertyValue("TableBorder", bord); 404 405 bord = (TableBorder)xTableProps.getPropertyValue("TableBorder"); 406 theLine = bord.TopLine; 407 int col = theLine.Color; 408 System.out.println(col); 409 } |
410 | 410 |
411 protected void manipulateShape(XShape xShape) throws com.sun.star.uno.Exception { 412 XPropertySet xShapeProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xShape); 413 xShapeProps.setPropertyValue("FillColor", new Integer(0x99CCFF)); 414 xShapeProps.setPropertyValue("LineColor", new Integer(0x000099)); 415 xShapeProps.setPropertyValue("RotateAngle", new Integer(3000)); 416 417 xShapeProps.setPropertyValue("TextLeftDistance", new Integer(0)); 418 xShapeProps.setPropertyValue("TextRightDistance", new Integer(0)); 419 xShapeProps.setPropertyValue("TextUpperDistance", new Integer(0)); | 411 protected void manipulateShape(XShape xShape) throws com.sun.star.uno.Exception { 412 XPropertySet xShapeProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xShape); 413 xShapeProps.setPropertyValue("FillColor", new Integer(0x99CCFF)); 414 xShapeProps.setPropertyValue("LineColor", new Integer(0x000099)); 415 xShapeProps.setPropertyValue("RotateAngle", new Integer(3000)); 416 417 xShapeProps.setPropertyValue("TextLeftDistance", new Integer(0)); 418 xShapeProps.setPropertyValue("TextRightDistance", new Integer(0)); 419 xShapeProps.setPropertyValue("TextUpperDistance", new Integer(0)); |
420 xShapeProps.setPropertyValue("TextLowerDistance", new Integer(0)); | 420 xShapeProps.setPropertyValue("TextLowerDistance", new Integer(0)); |
421 } 422 423 424 protected XComponent newDocComponent(String docType) throws java.lang.Exception { 425 String loadUrl = "private:factory/" + docType; 426 xRemoteServiceManager = this.getRemoteServiceManager(); 427 Object desktop = xRemoteServiceManager.createInstanceWithContext( 428 "com.sun.star.frame.Desktop", xRemoteContext); --- 4 unchanged lines hidden (view full) --- 433 } 434 435 protected XMultiComponentFactory getRemoteServiceManager() throws java.lang.Exception { 436 if (xRemoteContext == null && xRemoteServiceManager == null) { 437 try { 438 // First step: get the remote office component context 439 xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); 440 System.out.println("Connected to a running office ..."); | 421 } 422 423 424 protected XComponent newDocComponent(String docType) throws java.lang.Exception { 425 String loadUrl = "private:factory/" + docType; 426 xRemoteServiceManager = this.getRemoteServiceManager(); 427 Object desktop = xRemoteServiceManager.createInstanceWithContext( 428 "com.sun.star.frame.Desktop", xRemoteContext); --- 4 unchanged lines hidden (view full) --- 433 } 434 435 protected XMultiComponentFactory getRemoteServiceManager() throws java.lang.Exception { 436 if (xRemoteContext == null && xRemoteServiceManager == null) { 437 try { 438 // First step: get the remote office component context 439 xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); 440 System.out.println("Connected to a running office ..."); |
441 | 441 |
442 xRemoteServiceManager = xRemoteContext.getServiceManager(); 443 } 444 catch( Exception e) { 445 e.printStackTrace(); 446 System.exit(1); | 442 xRemoteServiceManager = xRemoteContext.getServiceManager(); 443 } 444 catch( Exception e) { 445 e.printStackTrace(); 446 System.exit(1); |
447 } | 447 } |
448 } 449 return xRemoteServiceManager; 450 } 451} | 448 } 449 return xRemoteServiceManager; 450 } 451} |