bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScAnnotationTextCursor.java
blob91224f3802486ab8655eabd1cc6530a52b910f04
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod._sc;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
29 import com.sun.star.container.XIndexAccess;
30 import com.sun.star.lang.XComponent;
31 import com.sun.star.lang.XMultiServiceFactory;
32 import com.sun.star.sheet.XSheetAnnotation;
33 import com.sun.star.sheet.XSheetAnnotationAnchor;
34 import com.sun.star.sheet.XSpreadsheet;
35 import com.sun.star.sheet.XSpreadsheetDocument;
36 import com.sun.star.sheet.XSpreadsheets;
37 import com.sun.star.table.CellAddress;
38 import com.sun.star.table.XCell;
39 import com.sun.star.table.XCellRange;
40 import com.sun.star.text.XSimpleText;
41 import com.sun.star.uno.UnoRuntime;
42 import com.sun.star.uno.XInterface;
45 /**
47 * initial description
48 * @see com.sun.star.beans.XPropertySet
49 * @see com.sun.star.beans.XPropertyState
50 * @see com.sun.star.document.XDocumentInsertable
51 * @see com.sun.star.style.CharacterProperties
52 * @see com.sun.star.style.ParagraphProperties
53 * @see com.sun.star.text.XParagraphCursor
54 * @see com.sun.star.text.XSentenceCursor
55 * @see com.sun.star.text.XTextCursor
56 * @see com.sun.star.text.XTextRange
57 * @see com.sun.star.text.XWordCursor
58 * @see com.sun.star.util.XSortable
61 public class ScAnnotationTextCursor extends TestCase {
63 private XSpreadsheetDocument xSheetDoc = null;
65 protected void initialize( TestParameters tParam, PrintWriter log ) {
66 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) tParam.getMSF() );
68 try {
69 log.println( "creating a Spreadsheet document" );
70 xSheetDoc = SOF.createCalcDoc(null);
71 } catch ( com.sun.star.uno.Exception e ) {
72 // Some exception occurs.FAILED
73 e.printStackTrace( log );
74 throw new StatusException( "Couldn't create document", e );
79 protected void cleanup( TestParameters tParam, PrintWriter log ) {
80 log.println( " disposing xSheetDoc " );
81 XComponent oComp = UnoRuntime.queryInterface
82 (XComponent.class, xSheetDoc) ;
83 util.DesktopTools.closeDoc(oComp);
87 /**
88 * creating a Testenvironment for the interfaces to be tested
90 public synchronized TestEnvironment createTestEnvironment
91 ( TestParameters Param, PrintWriter log )
92 throws StatusException {
94 XInterface oObj = null;
96 // creation of testobject here
97 // first we write what we are intend to do to log file
98 log.println( "Creating a test environment" );
100 CellAddress cellPos = new CellAddress((short)0, 1, 2);
102 try {
103 log.println("Getting test object ") ;
105 XSpreadsheetDocument xArea = UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc);
107 XSpreadsheets oSheets = xArea.getSheets();
109 XIndexAccess XAccess = UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
111 XSpreadsheet oSheet = (XSpreadsheet)XAccess.getByIndex(cellPos.Sheet);
113 XCellRange oCRange = UnoRuntime.queryInterface(XCellRange.class, oSheet);
115 XCell oCell = oCRange.getCellByPosition(cellPos.Column, cellPos.Row);
117 XSheetAnnotationAnchor oAnnoA = UnoRuntime.queryInterface(XSheetAnnotationAnchor.class, oCell);
119 XSheetAnnotation oAnno = oAnnoA.getAnnotation();
120 XSimpleText aText = UnoRuntime.queryInterface(XSimpleText.class,oAnno);
121 aText.setString("A nice little Test");
122 oObj = aText.createTextCursor();
124 } catch (Exception e) {
125 e.printStackTrace(log) ;
126 throw new StatusException(
127 "Error getting test object from spreadsheet document",e) ;
130 TestEnvironment tEnv = new TestEnvironment( oObj );
132 // Other parameters required for interface tests
134 return tEnv;
137 } // finish class ScAnnotationTextCursor