Package com.sun.star.table

Examples of com.sun.star.table.XCellRange


        Helper.setUnoPropertyValue(xTextSection, "LinkRegion", sLinkRegion);
        if (CurDBColumn != null){
            boolean bIsGroupTable = (sLinkRegion.equals(RECORDSECTION) != true);
            if (bIsGroupTable == true){
                XTextTable xTextTable = CurReportDocument.oTextTableHandler.getlastTextTable();
                XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(XCellRange.class, xTextTable);
                CurDBColumn.modifyCellContent(xCellRange, CurGroupValue);
            }
        }
    } catch (Exception exception) {
        exception.printStackTrace(System.out);
View Full Code Here


        maSheetDoc = aHelper.createSpreadsheetDocument();
        maDrawDoc  = aHelper.createDrawingDocument();
        CalcHelper aCalcHelper   = new CalcHelpermaSheetDoc );
        ChartHelper aChartHelper = new ChartHelper( maDrawDoc );

        XCellRange aRange = aCalcHelper.insertFormulaRange( 3, 30 );

        // the unit for measures is 1/100th of a millimeter
        // position at (1cm, 1cm)
        Point aPos    = new Point( 1000, 1000 );
View Full Code Here

        maSheetDoc = aHelper.createSpreadsheetDocument();
        maDrawDoc  = aHelper.createDrawingDocument();
        CalcHelper aCalcHelper   = new CalcHelpermaSheetDoc );
        ChartHelper aChartHelper = new ChartHelper( maDrawDoc );

        XCellRange aRange = aCalcHelper.insertFormulaRange( 3, 30 );

        // the unit for measures is 1/100th of a millimeter
        // position at (1cm, 1cm)
        Point aPos    = new Point( 1000, 1000 );
View Full Code Here

        Helper aHelper = new Helper( args );

        CalcHelper aCalcHelper = new CalcHelper( aHelper.createSpreadsheetDocument() );

        // insert a cell range with 4 columns and 24 rows filled with random numbers
        XCellRange aRange = aCalcHelper.insertRandomRange( 4, 24 );
        CellRangeAddress aRangeAddress = ((XCellRangeAddressable) UnoRuntime.queryInterface(
            XCellRangeAddressable.class, aRange)).getRangeAddress();

        // change view to sheet containing the chart
        aCalcHelper.raiseChartSheet();
View Full Code Here

            XTextContent xTextContentTable = (XTextContent)UnoRuntime.queryInterface(
                XTextContent.class, table);

            xText.insertTextContent(xText.getEnd(), xTextContentTable, false);

            XCellRange xCellRange = (XCellRange)UnoRuntime.queryInterface(
                XCellRange.class, table);
            XCell xCell = xCellRange.getCellByPosition(0, 1);
            XText xCellText = (XText)UnoRuntime.queryInterface(XText.class, xCell);

            manipulateText(xCellText);
            manipulateTable(xCellRange);
View Full Code Here

            XIndexAccess xIndexedSheets = (XIndexAccess)UnoRuntime.queryInterface(
                XIndexAccess.class, sheets);
            Object sheet =  xIndexedSheets.getByIndex(0);

            //get cell A2 in first sheet
            XCellRange xSpreadsheetCells = (XCellRange)UnoRuntime.queryInterface(
                XCellRange.class, sheet);
            XCell xCell = xSpreadsheetCells.getCellByPosition(0,1);
            XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(
                XPropertySet.class, xCell);
            xCellProps.setPropertyValue("IsTextWrapped", new Boolean(true));

            XText xCellText = (XText)UnoRuntime.queryInterface(XText.class, xCell);
View Full Code Here

        xCell = xCellRange.getCellByPosition(1,0);
        xCellText = (XText)UnoRuntime.queryInterface(XText.class, xCell);
        xCellText.setString("Year");
        xCell = xCellRange.getCellByPosition(1,1);
        xCell.setValue(1940);
        XCellRange xSelectedCells = xCellRange.getCellRangeByName("A1:B1");
        XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(
            XPropertySet.class, xSelectedCells);

        // format table headers and table borders
        // we need to distinguish text and sheet tables:
View Full Code Here

                // Getting the first XSpreadsheet
                XSpreadsheet xspreadsheet = (XSpreadsheet)UnoRuntime.queryInterface(
                    XSpreadsheet.class, xindexaccess.getByIndex( 0 ));
               
                // Querying for the interface XCellRange on the XSpeadsheet
                XCellRange xcellrange = ( XCellRange )
                UnoRuntime.queryInterface( XCellRange.class, xspreadsheet );
               
                /* Getting the gregorian calendar with the date on which to start the
                   calculation */
                GregorianCalendar gregoriancalendarAbsoluteStartDate =
                    this.getGregorianCalendarFromString(this.getStringFromCell( xcellrange, 5, 2 ) );
                gregoriancalendarAbsoluteStartDate.add( Calendar.DATE, -1 );
               
                // Set the start date with the absolute start date
                GregorianCalendar gregoriancalendarStartDate =
                (GregorianCalendar) gregoriancalendarAbsoluteStartDate.clone();
               
                /* Creating the service FunctionAccess, which allows generic access to
                   all spreadsheet functions */
                Object objectFunctionAccess =
                    xmultiservicefactory.createInstance("com.sun.star.sheet.FunctionAccess" );
               
                // Querying for the interface XFunctionAccess on service
                // FunctionAccess
                XFunctionAccess xfunctionaccess = (XFunctionAccess)
                    UnoRuntime.queryInterface(XFunctionAccess.class,
                                              objectFunctionAccess );
               
                // Creating vector for holidays
                Vector vectorHolidays = new Vector();
               
                // Get the Official Holidays
                this.getOfficialHolidays( vectorHolidays, xcellrange,
                                          xfunctionaccess,
                                          gregoriancalendarStartDate.get( Calendar.YEAR ) );
               
                // Get the private holidays
                this.getPrivateHolidays( vectorHolidays, xcellrange, xfunctionaccess );
               
                // Getting the object array of holidays
                Object[] objectSortedHolidays = vectorHolidays.toArray();
               
                // Sorting the holidays
                Arrays.sort( objectSortedHolidays );
               
                // Collect the Official Holidays and the private holidays
                Object [][]objectHolidays =
                new Object[][] { objectSortedHolidays };
               
                // Row index
                int intRowTo = this.INT_ROW_FROM - 1;
               
                // Getting the feature of the first cell
                String stringFeature = this.getStringFromCell( xcellrange,
                                                               intRowTo + 1, this.INT_COLUMN_FEATURE );
               
                // Determine the last row with an entry in the first column
                while ( ( stringFeature != null ) &&
                        ( !stringFeature.equals( "" ) ) ) {
                    intRowTo++;
                    stringFeature = this.getStringFromCell( xcellrange,
                    intRowTo + 1, this.INT_COLUMN_FEATURE );
                }
               
                // Setting the last row to be calculated
                final int INT_ROW_TO = intRowTo + 1;
               
                // Deleting cells which will be recalculated
                for ( int intRow = this.INT_ROW_FROM; intRow < INT_ROW_TO + 5; intRow++ ) {
                    for ( int intColumn = this.INT_COLUMN_STARTDATE;
                          intColumn <= this.INT_COLUMN_END_DAY_OF_WEEK;
                          intColumn++ ) {
                        this.setStringToCell( xcellrange, intRow, intColumn,
                        "" );
                    }
                }
               
                /* Clearing the background color of the due date cells and setting the
                   the hyperlink to the bugtracker */
                for ( int intRow = this.INT_ROW_FROM; intRow < INT_ROW_TO; intRow++ ) {
                   
                    // Querying for the interface XPropertySet for the cell providing the due date
                    XPropertySet xpropertyset = ( XPropertySet )
                        UnoRuntime.queryInterface( XPropertySet.class,
                                                   xcellrange.getCellByPosition( this.INT_COLUMN_DUEDATE,
                                                                                 intRow ) );
                   
                    // Changing the background color of the cell to white
                    xpropertyset.setPropertyValue( "CellBackColor",
                    new Integer( 16777215 ) );
                   
                    // Getting the cell of the bug id
                    XCell xcell = xcellrange.getCellByPosition(
                    this.INT_COLUMN_FEATURE, intRow );
                   
                    // Querying for the interface XSimpleText
                    XSimpleText xsimpletext = ( XSimpleText )
                    UnoRuntime.queryInterface( XSimpleText.class, xcell );
                   
                    // Getting the text cursor
                    XTextCursor xtextcursor = xsimpletext.createTextCursor();
                   
                    // Querying for the interface XTextRange
                    XTextRange xtextrange = ( XTextRange )
                    UnoRuntime.queryInterface( XTextRange.class, xtextcursor );
                   
                    // Getting the bug ID from the cell
                    String stringBugID = xtextrange.getString();                   
                    if ( !stringBugID.startsWith( "http://so-web1.germany.sun.com/bis/servlet/" +
                                                  "intray.ControlPanel?system=1&update=true&id=" ) ) {
                        String stringBugIDLink = "http://so-web1.germany.sun.com/bis/servlet/" +
                            "intray.ControlPanel?system=1&update=true&id=" + stringBugID +
                            "&showframeset=true";
                       
                        // Querying for the interface XMultiServiceFactory
                        XMultiServiceFactory xmultiservicefactoryTextField =
                            (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class,
                                                                            aInstance );
                       
                        // Creating an instance of the text field URL
                        Object objectTextField =
                            xmultiservicefactoryTextField.createInstance(
                                "com.sun.star.text.TextField.URL" );
                       
                        // Querying for the interface XTextField
                        XTextField xtextfield = ( XTextField )
                            UnoRuntime.queryInterface( XTextField.class,
                                                       objectTextField );
                       
                        // Querying for the interface XPropertySet
                        XPropertySet xpropertysetTextField = ( XPropertySet )
                            UnoRuntime.queryInterface( XPropertySet.class,
                                                       xtextfield );
                       
                        // Setting the URL
                        xpropertysetTextField.setPropertyValue( "URL", stringBugIDLink );
                       
                        // Setting the representation of the URL
                        xpropertysetTextField.setPropertyValue( "Representation", stringBugID );
                       
                        // Querying for the interface XText
                        XText xtext = ( XText )UnoRuntime.queryInterface( XText.class, xcell );
                       
                        // Delete cell content
                        xtextrange.setString( "" );
                       
                        // Inserting the text field URL to the cell
                        xtext.insertTextContent( xtextrange, xtextfield, false );
                    }
                }
               
                // Processing all features/bugs in the table
                for ( int intRow = this.INT_ROW_FROM; intRow < INT_ROW_TO; intRow++ ) {
                    // Getting the cell of the column "Needed Days" in the current row
                    XCell xcell = xcellrange.getCellByPosition( INT_COLUMN_NEEDEDDAYS, intRow );

                    // Getting the number of needed days to perform the feature
                    int intNeededDays = (int) Math.round( xcell.getValue() );
                   
                    // Getting the content of a specified cell
                    String stringStatus = this.getStringFromCell( xcellrange,
                    intRow, this.INT_COLUMN_STATUS );
                   
                    /* Testing if the number of needed days is greater than zero and if
                       the status is not "done" */
                    if ( ( intNeededDays > 0 )
                         && !( stringStatus.toLowerCase().trim().equals( "done" ) ) ) {
                        // Getting the start date after a specified number of workdays
                        gregoriancalendarStartDate = this.getWorkday(
                            gregoriancalendarStartDate, 1, objectHolidays,
                            xfunctionaccess );
                       
                        // Getting a string with the date format jjjj-mm-dd from the gregorian calendar
                        String stringDate = this.getStringFromGregorianCalendar(
                            gregoriancalendarStartDate );
                       
                        // Set the start date in the specified cell of the table
                        this.setStringToCell( xcellrange, intRow,
                                              this.INT_COLUMN_STARTDATE, stringDate );
                       
                        // For the start day set the day of week in the specified cell of the table
                        this.setDayOfWeek( gregoriancalendarStartDate,
                                           xcellrange, intRow, this.INT_COLUMN_START_DAY_OF_WEEK );
                       
                        // Getting the end date after a specified number of workdays
                        GregorianCalendar gregoriancalendarEndDate =
                            this.getWorkday( gregoriancalendarStartDate,
                                             intNeededDays - 1,
                                             objectHolidays, xfunctionaccess );
                       
                        // Creating a string with the date format jjjj-mm-dd
                        stringDate = this.getStringFromGregorianCalendar(
                            gregoriancalendarEndDate );
                       
                        // Set the end date in the specified cell of the table
                        this.setStringToCell( xcellrange, intRow,
                                              this.INT_COLUMN_ENDDATE, stringDate );
                       
                        // For the end day set the day of week in the specified cell of the table
                        this.setDayOfWeek( gregoriancalendarEndDate, xcellrange,
                                           intRow, this.INT_COLUMN_END_DAY_OF_WEEK );
                       
                        // Set the initial date for the next loop
                        gregoriancalendarStartDate = ( GregorianCalendar )
                            gregoriancalendarEndDate.clone();
                       
                        // Get the due date from the table
                        String stringDueDate = this.getStringFromCell(
                            xcellrange, intRow, this.INT_COLUMN_DUEDATE );
                       
                        // Testing if the due date is not empty
                        if ( !stringDueDate.equals( "" ) ) {
                            GregorianCalendar gregoriancalendarDueDate =
                                this.getGregorianCalendarFromString( stringDueDate );
                           
                            // Testing if the due date is before the calculated end date
                            if ( gregoriancalendarDueDate.before( gregoriancalendarEndDate ) ) {
                                /* Getting the date when the processing of the feature/bug should
                                   be started at the latest */
                                GregorianCalendar gregoriancalendarLatestDateToStart =
                                    this.getWorkday( gregoriancalendarDueDate,
                                                     -( intNeededDays - 1 ),
                                                     objectHolidays, xfunctionaccess );
                               
                                // Begin with the current row
                                int intRowToInsert = intRow;
                               
                                // Get the start date for the feature/bug in the current row
                                GregorianCalendar gregoriancalendarPreviousStartDate =
                                    this.getGregorianCalendarFromString(
                                        this.getStringFromCell(
                                            xcellrange, intRowToInsert,
                                            this.INT_COLUMN_STARTDATE ) );
                               
                                // Testing if we have to search for an earlier date to begin
                                while ( ( gregoriancalendarLatestDateToStart.before(
                                              gregoriancalendarPreviousStartDate ) ) &&
                                        ( INT_ROW_FROM != intRowToInsert ) ) {
                                    // Decrease the row
                                    intRowToInsert--;
                                   
                                    // Get the start date for the feature/bug in the current row
                                    String stringStartDate = this.getStringFromCell(
                                        xcellrange, intRowToInsert, this.INT_COLUMN_STARTDATE );
                                   
                                    // Search until a valid start date is found
                                    while ( stringStartDate.equals( "" ) ) {
                                        // Decrease the row
                                        intRowToInsert--;
                                       
                                        // Get the start date for the feature/bug in the current row
                                        stringStartDate = this.getStringFromCell(
                                            xcellrange, intRowToInsert, this.INT_COLUMN_STARTDATE );
                                    }
                                   
                                    // Get the GregorianCalender format for the start date
                                    gregoriancalendarPreviousStartDate =
                                        this.getGregorianCalendarFromString( stringStartDate );
                                }
                               
                                // Getting the cell of the column "Needed Days" in the row where to insert
                                XCell xcellNeededDaysWhereToInsert =
                                    xcellrange.getCellByPosition( INT_COLUMN_NEEDEDDAYS, intRowToInsert );
                                // Getting the number of needed days to perform the feature
                                int intNeededDaysWhereToInsert = (int)
                                    Math.round( xcellNeededDaysWhereToInsert.getValue() );
                               
                                GregorianCalendar gregoriancalendarPreviousNewEndDate =
                                    this.getWorkday( gregoriancalendarPreviousStartDate,
                                                     intNeededDays - 1 + intNeededDaysWhereToInsert,
                                                     objectHolidays, xfunctionaccess );                              
                                String stringPreviousDueDate = this.getStringFromCell(
                                    xcellrange, intRowToInsert, this.INT_COLUMN_DUEDATE );
                               
                                GregorianCalendar
                                gregoriancalendarPreviousDueDate = null;
                               
                                if ( !stringPreviousDueDate.equals( "" ) ) {
                                    gregoriancalendarPreviousDueDate =
                                        this.getGregorianCalendarFromString( stringPreviousDueDate );
                                }
                               
                                if ( ( intRowToInsert == intRow ) ||
                                     ( gregoriancalendarPreviousNewEndDate.after(
                                         gregoriancalendarPreviousDueDate ) ) ) {
                                    // Querying for the interface XPropertySet for the cell providing
                                    // the due date
                                    XPropertySet xpropertyset = ( XPropertySet )
                                        UnoRuntime.queryInterface( XPropertySet.class,
                                                                   xcellrange.getCellByPosition(
                                                                       this.INT_COLUMN_DUEDATE,
                                                                       intRow ) );
                                   
                                    // Changing the background color of the cell to red
                                    xpropertyset.setPropertyValue(
View Full Code Here

                                           xCellFormatSupplier.getCellFormatRanges() );
            XEnumeration xRanges = xEnumerationAccess.createEnumeration();
           
            while( xRanges.hasMoreElements() ) {
                // the enumeration returns a cellrange
                XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(
                    XCellRange.class, xRanges.nextElement());
               
                // the PropertySet the get and set the properties from the cellrange
                XPropertySet xCellProp = ( XPropertySet ) UnoRuntime.queryInterface(
                    XPropertySet.class, xCellRange );
View Full Code Here

   
    public static void createExampleData( XSpreadsheet xSheet, XNumberFormats xNumberFormat ) {
       
        // enter in a cellrange numbers and change the numberformat to DM
        XCell xCell = null;
        XCellRange xCellRange = null;
       
        try {
            Locale xLanguage = new Locale();
            xLanguage.Country = "de";    // Germany -> DM
            xLanguage.Language = "de";   // German
View Full Code Here

TOP

Related Classes of com.sun.star.table.XCellRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.