Examples of XSpreadsheet


Examples of com.sun.star.sheet.XSpreadsheet

    * Has <b> OK </b> status if cell's values in source range are equal to
    * cell's values in destination range and no exceptions were thrown. <p>
    */
    public void _copyRange(){
        log.println("Prepare cells before test methods.");
        XSpreadsheet oSheet = (XSpreadsheet)
            UnoRuntime.queryInterface(XSpreadsheet.class, oObj);
        try {
            oSheet.getCellByPosition(1,1).setValue(100);
            oSheet.getCellByPosition(1,2).setValue(200);
            oSheet.getCellByPosition(2,1).setValue(300);
            oSheet.getCellByPosition(2,2).setValue(400);
        } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
            e.printStackTrace(log);
            tRes.tested("copyRange()", false);
        }

        XCellRangeAddressable oAddr =
            (XCellRangeAddressable)
                 UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj);
        short iSheet = oAddr.getRangeAddress().Sheet;
        CellAddress sDest;
        CellRangeAddress sSrc;

        sSrc = new CellRangeAddress(iSheet, 1, 1, 2, 2);
        sDest = new CellAddress(iSheet, 1, 10);
        boolean result = true;
        boolean loc_result = true;

        oObj.copyRange(sDest, sSrc);
        try {
            loc_result  = (oSheet.getCellByPosition(1, 10).getValue() == 100);
            loc_result &= (oSheet.getCellByPosition(1, 11).getValue() == 200);
            loc_result &= (oSheet.getCellByPosition(2, 10).getValue() == 300);
            loc_result &= (oSheet.getCellByPosition(2, 11).getValue() == 400);
        } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
            e.printStackTrace(log);
            tRes.tested("copyRange()", false);
        }

View Full Code Here

Examples of com.sun.star.sheet.XSpreadsheet

    * and no exceptions were thrown. <p>
    */
    public void _insertCells(){
        boolean result = false;

        XSpreadsheet oSheet = (XSpreadsheet)
            UnoRuntime.queryInterface(XSpreadsheet.class, oObj);
        XCellRangeAddressable oAddr = (XCellRangeAddressable)
            UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj);
        short iSheet = oAddr.getRangeAddress().Sheet;
        try {
            oSheet.getCellByPosition(0,20).setValue(100);
            oSheet.getCellByPosition(1,20).setValue(100);
            oSheet.getCellByPosition(2,20).setValue(100);
            oSheet.getCellByPosition(3,20).setValue(100);
            oSheet.getCellByPosition(0,21).setValue(200);
            oSheet.getCellByPosition(1,21).setValue(200);
            oSheet.getCellByPosition(2,21).setValue(200);
            oSheet.getCellByPosition(3,21).setValue(200);

            // catch some sleight of hand threads
            if (oSheet.getCellByPosition(1,21).getValue() == 200){
                //log.println("Rows closed.");
            }
            else{
                log.println("Cells were already inserted. "+
                    "Delete old cells now");
                XColumnRowRange oColumnRowRange = (XColumnRowRange)
                    UnoRuntime.queryInterface(XColumnRowRange.class, oSheet);

                XTableRows oRows = (XTableRows) oColumnRowRange.getRows();
                oRows.removeByIndex(21,1);
            }
            CellRangeAddress sSrc = new CellRangeAddress(iSheet, 0, 21, 5, 21);
            oObj.insertCells (sSrc, CellInsertMode.DOWN) ;

            // check the result
            double res = oSheet.getCellByPosition(1, 21).getValue();
            if (res == 0.0) {
                result = true;
            }
        } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
            e.printStackTrace(log);
View Full Code Here

Examples of com.sun.star.sheet.XSpreadsheet

    * of values in destination range and no exceptions were thrown. <p>
    */
    public void _moveRange(){
        boolean result = false;

        XSpreadsheet oSheet = (XSpreadsheet)
            UnoRuntime.queryInterface(XSpreadsheet.class, oObj);

        XCellRangeAddressable oAddr = (XCellRangeAddressable)
            UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj);

        short iSheet = oAddr.getRangeAddress().Sheet;
        //prepare source range
        try {
            oSheet.getCellByPosition(4,0).setValue(111);
            oSheet.getCellByPosition(4,1).setValue(222);

            CellRangeAddress sSrc = new CellRangeAddress(iSheet, 4, 0, 4, 1);
            CellAddress sDest = new CellAddress(iSheet, 4, 4);
            oObj.moveRange(sDest, sSrc);

            double cntA = 0;
            double cntB = 0;
            cntA = oSheet.getCellByPosition(4, 4).getValue();
            cntB = oSheet.getCellByPosition(4, 5).getValue();
            if (cntA + cntB == 333.0){ result = true; }
            //clean up
            oSheet.getCellByPosition(4,4).setValue(0);
            oSheet.getCellByPosition(4,5).setValue(0);
        } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
            e.printStackTrace(log);
            result = false;
        }

View Full Code Here

Examples of com.sun.star.sheet.XSpreadsheet

    * range is equal to zero and no exceptions were thrown. <p>
    */
    public void _removeRange(){
        boolean result = false;

        XSpreadsheet oSheet = (XSpreadsheet)
            UnoRuntime.queryInterface(XSpreadsheet.class, oObj);
        XCellRangeAddressable oAddr = (XCellRangeAddressable)
            UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj);
        short iSheet = oAddr.getRangeAddress().Sheet;
        try {
            //prepare source range
            oSheet.getCellByPosition(5, 0).setValue(333);
            oSheet.getCellByPosition(5, 1).setValue(444);

            CellRangeAddress sSrc = new CellRangeAddress(iSheet, 5, 0, 5, 1);
            oObj.removeRange(sSrc, CellDeleteMode.UP);

            double cntA = 0;
            double cntB = 0;
            cntA = oSheet.getCellByPosition(5, 0).getValue();
            cntB = oSheet.getCellByPosition(5, 1).getValue();
            if (cntA + cntB == 0.0){ result = true; }

            //clean up
            oSheet.getCellByPosition(5, 0).setValue(0);
            oSheet.getCellByPosition(5, 1).setValue(0);
        } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
            e.printStackTrace(log);
            result = false;
        }

View Full Code Here

Examples of com.sun.star.sheet.XSpreadsheet

        if (xDrawPage.hasElements()) {
            elementCount = xDrawPage.getCount();
        }
       
        // get a sheet for changing the cells
        XSpreadsheet xSheet = (XSpreadsheet)tEnv.getObjRelation("XSheetAuditing.Spreadsheet");
        if (xSheet == null) // query on ther object
            xSheet = (XSpreadsheet)UnoRuntime.queryInterface(XSpreadsheet.class, oObj);
        if (xSheet == null)
            throw new StatusException(Status.failed("'XSheetAuditing.Spreadsheet' object relation not found."));
        try {
            xAddress = xSheet.getCellByPosition(address.Column, address.Row);
            xDependentAddress = xSheet.getCellByPosition(dependentAddress.Column, dependentAddress.Row);
            xPrecedentAddress = xSheet.getCellByPosition(precedentAddress.Column, precedentAddress.Row);
        }
        catch(com.sun.star.lang.IndexOutOfBoundsException e) {
            throw new StatusException(Status.failed("Invalid cell addresses in object relations."));
        }
    }
View Full Code Here

Examples of com.sun.star.sheet.XSpreadsheet

     */
    public static void fillCalcSheetWithContent(XComponent xSheetDoc, int sheetNumber,
                        int startCellX, int startCellY, int rangeLengthX, int rangeLengthY)
                  throws java.lang.Exception {
        try{
            XSpreadsheet xSheet = getSpreadSheetFromSheetDoc(xSheetDoc, sheetNumber);

            fillCalcSheetWithContent(xSheet, startCellX, startCellY, rangeLengthX, rangeLengthY);

        } catch (Exception e){
                throw new Exception(
View Full Code Here

Examples of com.sun.star.sheet.XSpreadsheet

     * @see com.sun.star.sheet.XSpreadsheet
     */
    public static XSpreadsheet getSpreadSheetFromSheetDoc(XComponent xSheetDoc, int sheetNumber)
                  throws java.lang.Exception {
       
        XSpreadsheet xSheet = null;

        try{
            XSpreadsheetDocument xSpreadsheetDoc = (XSpreadsheetDocument)
                    UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc);

View Full Code Here

Examples of com.sun.star.sheet.XSpreadsheet

            XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)
                    UnoRuntime.queryInterface(XSpreadsheetDocument.class, oObj);
            XSpreadsheets oSheets = xSpreadsheetDocument.getSheets();
            XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface(
                                                XIndexAccess.class, oSheets);
            XSpreadsheet oSheet = (XSpreadsheet) UnoRuntime.queryInterface(
                                      XSpreadsheet.class, oIndexSheets.getByIndex(0));
            xSheet[0] = oSheet;
            oSheet = (XSpreadsheet) UnoRuntime.queryInterface(
                                      XSpreadsheet.class, oIndexSheets.getByIndex(1));
            xSheet[1] = oSheet;
View Full Code Here

Examples of com.sun.star.sheet.XSpreadsheet

            SOF.createInstance(oComp, "com.sun.star.sheet.SheetCellRanges");

        XSpreadsheets oSheets = xSheetDoc.getSheets() ;
        XIndexAccess oIndSheets = (XIndexAccess)
            UnoRuntime.queryInterface (XIndexAccess.class, oSheets);
        XSpreadsheet oSheet = null;
        try {
            oSheet = (XSpreadsheet) AnyConverter.toObject(
                    new Type(XSpreadsheet.class),oIndSheets.getByIndex(0));
            XNameContainer oRanges = (XNameContainer)
                UnoRuntime.queryInterface(XNameContainer.class, oObj);

            oRange = oSheet.getCellRangeByName("C1:D4");
            oRanges.insertByName("Range1", oRange);
            oRange = oSheet.getCellRangeByName("E2:F5");
            oRanges.insertByName("Range2", oRange);
            oRange = oSheet.getCellRangeByName("G2:H3");
            oRanges.insertByName("Range3", oRange);
            oRange = oSheet.getCellRangeByName("I7:J8");
            oRanges.insertByName("Range4", oRange);
        } catch(com.sun.star.lang.WrappedTargetException e) {
            e.printStackTrace(log);
            throw new StatusException("Couldn't create test object", e);
        } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
            e.printStackTrace(log);
            throw new StatusException("Couldn't create test object", e);
        } catch(com.sun.star.container.ElementExistException e) {
            e.printStackTrace(log);
            throw new StatusException("Couldn't create test object", e);
        } catch(com.sun.star.lang.IllegalArgumentException e) {
            e.printStackTrace(log);
            throw new StatusException("Couldn't create test object", e);
        }

        log.println("filling some cells");
        try {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 5; j++) {
                    oSheet.getCellByPosition(i, j).setFormula("a");
                }
            }
            for (int i = 0; i < 10; i++) {
                for (int j = 5; j < 10; j++) {
                    oSheet.getCellByPosition(i, j).setValue(i + j);
                }
            }
        } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
            e.printStackTrace(log);
            throw new StatusException (
View Full Code Here

Examples of com.sun.star.sheet.XSpreadsheet

        XSpreadsheets xSpreadsheets = (XSpreadsheets) xSheetDoc.getSheets();

        log.println("getting a sheet");

        XSpreadsheet oSheet = null;
        XIndexAccess oIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
                                            XIndexAccess.class, xSpreadsheets);

        try {
            oSheet = (XSpreadsheet) AnyConverter.toObject(
                             new Type(XSpreadsheet.class),
                             oIndexAccess.getByIndex(0));
        } catch (com.sun.star.lang.WrappedTargetException e) {
            e.printStackTrace(log);
            throw new StatusException("Couldn't get a spreadsheet", e);
        } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
            e.printStackTrace(log);
            throw new StatusException("Couldn't get a spreadsheet", e);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            e.printStackTrace(log);
            throw new StatusException("Couldn't get a spreadsheet", e);
        }

        log.println("filling some cells");

        try {
            oSheet.getCellByPosition(5, 5).setValue(15);
            oSheet.getCellByPosition(1, 4).setValue(10);
            oSheet.getCellByPosition(2, 0).setValue(-5.15);
            oSheet.getCellByPosition(8, 8).setFormula("= B5 + C1");
            // fill cells for XSheetOtline::autoutline
            oSheet.getCellByPosition(6, 6).setValue(3);
            oSheet.getCellByPosition(7, 6).setValue(3);
            oSheet.getCellByPosition(8, 6).setFormula("= SUM(G7:H7)");
            oSheet.getCellByPosition(9, 6).setFormula("= G7*I7");
        } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
            e.printStackTrace(log);
            throw new StatusException("Exception occurred while filling cells", e);
        }

        oObj = (XInterface) UnoRuntime.queryInterface(XInterface.class, oSheet);

        log.println("creating a new environment for object");

        TestEnvironment tEnv = new TestEnvironment(oObj);
       
        // do not execute com::sun::star::sheets::XCellSeries::fillAuto()
        tEnv.addObjRelation("XCELLSERIES_FILLAUTO", new Boolean(false));

        // set the adress ranges of the cells (see values set above): for e.g. XSheetOutline test
        tEnv.addObjRelation("CellRangeAddress",
            new CellRangeAddress((short)0, 6, 6, 8, 8));
        tEnv.addObjRelation("CellRangeSubAddress",
            new CellRangeAddress((short)0, 6, 6, 7, 8));
        // pick a cell with a formula for XSheetAuditing, a dependent cell and a precedent cell
        tEnv.addObjRelation("XSheetAuditing.CellAddress", new CellAddress((short)0, 8, 6));
        tEnv.addObjRelation("XSheetAuditing.PrecedentCellAddress", new CellAddress((short)0, 7, 6));
        tEnv.addObjRelation("XSheetAuditing.DependentCellAddress", new CellAddress((short)0, 9, 6));
       
        // add an existing sheet for linking
        tEnv.addObjRelation("XSheetLinkable.LinkSheet", "ScSheetLinksObj.sdc");
       
        //adding Scenario and with that a ScenarioSheet-Relation for Scenario and XScenarioEnhanced
        XScenariosSupplier scene = (XScenariosSupplier) UnoRuntime.queryInterface(
                                           XScenariosSupplier.class,
                                           tEnv.getTestObject());
        scene.getScenarios()
             .addNewByName("Scenario",
                           new CellRangeAddress[] {
            new CellRangeAddress((short) 0, 0, 0, 10, 10)
        }, "Comment");

        XSpreadsheet sSheet = null;
       
        try {
            sSheet = (XSpreadsheet) UnoRuntime.queryInterface(
                             XSpreadsheet.class,
                             xSpreadsheets.getByName("Scenario"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.