Package com.sun.star.table

Examples of com.sun.star.table.XCell


        String backColorPropertyName = "";
        XPropertySet xTableProps = null;

        // enter column titles and a cell value
        XCell xCell = xCellRange.getCellByPosition(0,0);
        XText xCellText = (XText)UnoRuntime.queryInterface(XText.class, xCell);
        xCellText.setString("Quotation");
        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
View Full Code Here


                    // 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 );                              
View Full Code Here

        public String getStringFromCell( XCellRange xcellrange, int intRow, int intColumn ) {
            XTextRange xtextrangeStartDate = null;
           
            try {
                // Getting the cell holding the information about the start date
                XCell xcellStartDate = xcellrange.getCellByPosition( intColumn, intRow );
                // Querying for the interface XTextRange on the XCell
                xtextrangeStartDate = (XTextRange)
                    UnoRuntime.queryInterface( XTextRange.class, xcellStartDate );
            }
            catch( Exception exception ) {
View Full Code Here

         */
        public void setStringToCell( XCellRange xcellrange, int intRow,
                                     int intColumn, String stringDate ) {
            try {
                // Getting the cell holding the information on the day to start
                XCell xcellStartDate = xcellrange.getCellByPosition( intColumn, intRow );
                // Querying for the interface XTextRange on the XCell
                XTextRange xtextrange = (XTextRange)
                    UnoRuntime.queryInterface( XTextRange.class, xcellStartDate );
                // Setting the new start date
                xtextrange.setString( stringDate );
View Full Code Here

                    if( xSheetCellRanges.getCount() > 0 ) {
                        XEnumerationAccess xCellEnumerationAccess = xSheetCellRanges.getCells();
                        XEnumeration xCellEnumeration = xCellEnumerationAccess.createEnumeration();
                       
                        while( xCellEnumeration.hasMoreElements() ) {
                            XCell xCell = (XCell) UnoRuntime.queryInterface(
                                XCell.class, xCellEnumeration.nextElement());
                            xCell.setValue( (double) xCell.getValue() / fFactor );
                        }
                    }
                }
            }
        }
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
           
            // Numberformat string from DM
            String sSimple = "0 [$DM]";
           
            // get the numberformat key
            int iNumberFormatKey = NumberFormat( xNumberFormat, sSimple, xLanguage );
           
            for( int iCounter=1; iCounter < 10; iCounter++ ) {
                // get one cell and insert a number
                xCell = xSheet.getCellByPosition( 2, 1 + iCounter );
                xCell.setValue( (double) iCounter * 2 );
                xCellRange = xSheet.getCellRangeByPosition( 2, 1 + iCounter, 2, 1 + iCounter );
               
                // get the ProperySet from the cell, to change the numberformat
                XPropertySet xCellProp = ( XPropertySet ) UnoRuntime.queryInterface(
                    XPropertySet.class, xCellRange );
View Full Code Here

     * @param stringFlag If the value of stringFlag is "V", the stringValue will be converted to the
     * float type. Otherwise the stringValue will be written as a formula.
     */
    public static void insertIntoCell( int intX, int intY, String stringValue,
    XSpreadsheet xspreadsheet, String stringFlag ) {
        XCell xcell = null;
       
        try {
            xcell = xspreadsheet.getCellByPosition( intX, intY );
        }
        catch ( com.sun.star.lang.IndexOutOfBoundsException exception ) {
            System.out.println( "Could not get cell." );
        }
        if ( stringFlag.equals( "V" ) ) {
            xcell.setValue( ( new Float( stringValue ) ).floatValue() );
        }
        else {
            xcell.setFormula( stringValue );
        }
    }
View Full Code Here

            XIndexAccess oIndexSheets = (XIndexAccess)
                UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
            XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject(
                        new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));

            XCell oCell = oSheet.getCellByPosition(2,3);
            oText = (XText)UnoRuntime.queryInterface(XText.class, oCell);

            oText.insertTextContent(
                oText.createTextCursor(), oContent, true);
View Full Code Here

     * float type. Otherwise the stringValue will be written as a formula.
     */
    public static void insertIntoCell( int intX, int intY, String stringValue,
                                       XSpreadsheet xspreadsheet, String stringFlag )
    {
        XCell xcell = null;
       
        try {
            xcell = xspreadsheet.getCellByPosition( intX, intY );
        }
        catch ( com.sun.star.lang.IndexOutOfBoundsException exception ) {
            System.out.println( "Could not get cell." );
        }
        if ( stringFlag.equals( "V" ) ) {
            xcell.setValue( ( new Float( stringValue ) ).floatValue() );
        }
        else {
            xcell.setFormula( stringValue );
        }
    }
View Full Code Here

        TestParameters Param, PrintWriter log) {

        XInterface oObj = null;

        // inserting some content to have non-empty page preview
        XCell xCell = null;
        try {
            XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ;
            XIndexAccess oIndexSheets = (XIndexAccess)
                UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
            XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject(
                            new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
            xCell = oSheet.getCellByPosition(0, 0) ;
            xCell.setFormula("ScAccessiblePageHeaderArea");
        } catch(com.sun.star.lang.WrappedTargetException e) {
            log.println("Exception ceating relation :");
            e.printStackTrace(log);
        } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
            log.println("Exception ceating relation :");
View Full Code Here

TOP

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

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.