1 /************************************************************** 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 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 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. 19 * 20 *************************************************************/ 21 22 23 package com.sun.star.wizards.report; 24 25 import com.sun.star.container.XIndexAccess; 26 import com.sun.star.container.XNameAccess; 27 import com.sun.star.container.XNamed; 28 import com.sun.star.lang.XMultiServiceFactory; 29 import com.sun.star.table.XCellRange; 30 import com.sun.star.table.XTableColumns; 31 import com.sun.star.table.XTableRows; 32 import com.sun.star.text.XTextTable; 33 import com.sun.star.uno.Exception; 34 import com.sun.star.uno.UnoRuntime; 35 import com.sun.star.wizards.text.TextTableHandler; 36 import com.sun.star.wizards.text.ViewHandler; 37 38 public class RecordTable 39 { 40 41 String CurFieldName; 42 String LabelDescription; 43 public XNamed xTableName; 44 public XCellRange xCellRange; 45 public XTextTable xTextTable; 46 private TextTableHandler oTextTableHandler; 47 public XTableColumns xTableColumns; 48 public XTableRows xTableRows; 49 RecordTable(TextTableHandler _oTextTableHandler)50 public RecordTable(TextTableHandler _oTextTableHandler) 51 { 52 try 53 { 54 this.oTextTableHandler = _oTextTableHandler; 55 String[] TableNames = oTextTableHandler.xTextTablesSupplier.getTextTables().getElementNames(); 56 XNameAccess xAllTextTables = oTextTableHandler.xTextTablesSupplier.getTextTables(); 57 if ((xAllTextTables.hasByName(ReportTextDocument.TBLRECORDSECTION)) || (xAllTextTables.hasByName(ReportTextDocument.COPYOFTBLRECORDSECTION))) 58 { 59 Object oTable; 60 if (xAllTextTables.hasByName(ReportTextDocument.COPYOFTBLRECORDSECTION)) 61 { 62 oTable = xAllTextTables.getByName(ReportTextDocument.COPYOFTBLRECORDSECTION); 63 } 64 else 65 { 66 oTable = xAllTextTables.getByName(ReportTextDocument.TBLRECORDSECTION); 67 } 68 xTextTable = UnoRuntime.queryInterface(XTextTable.class, oTable); 69 xTableName = UnoRuntime.queryInterface(XNamed.class, xTextTable); 70 } 71 else 72 { 73 XIndexAccess xTableIndex = UnoRuntime.queryInterface(XIndexAccess.class, xAllTextTables); 74 int n = xTableIndex.getCount() - 1; 75 Object x = xTableIndex.getByIndex(n); 76 xTextTable = UnoRuntime.queryInterface(XTextTable.class, x); 77 xTableName = UnoRuntime.queryInterface(XNamed.class, xTextTable); 78 xTableName.setName(ReportTextDocument.TBLRECORDSECTION); 79 } 80 xTableRows = xTextTable.getRows(); 81 xTableColumns = xTextTable.getColumns(); 82 xCellRange = UnoRuntime.queryInterface(XCellRange.class, xTextTable); 83 } 84 catch (Exception exception) 85 { 86 exception.printStackTrace(System.out); 87 } 88 } 89 adjustOptimalTableWidths(XMultiServiceFactory _xMSF, ViewHandler oViewHandler)90 public void adjustOptimalTableWidths(XMultiServiceFactory _xMSF, ViewHandler oViewHandler) 91 { // setTableColumnSeparators(){ 92 oTextTableHandler.adjustOptimalTableWidths(_xMSF, xTextTable); 93 oViewHandler.collapseViewCursorToStart(); 94 } 95 } 96