tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScAnnotationTextCursor.java
blobcaa2e2a911fe49fa70dcc9c453ff949d8726da5c
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.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.SOfficeFactory;
28 import com.sun.star.container.XIndexAccess;
29 import com.sun.star.lang.XComponent;
30 import com.sun.star.sheet.XSheetAnnotation;
31 import com.sun.star.sheet.XSheetAnnotationAnchor;
32 import com.sun.star.sheet.XSpreadsheet;
33 import com.sun.star.sheet.XSpreadsheetDocument;
34 import com.sun.star.sheet.XSpreadsheets;
35 import com.sun.star.table.CellAddress;
36 import com.sun.star.table.XCell;
37 import com.sun.star.table.XCellRange;
38 import com.sun.star.text.XSimpleText;
39 import com.sun.star.uno.UnoRuntime;
40 import com.sun.star.uno.XInterface;
43 /**
45 * initial description
46 * @see com.sun.star.beans.XPropertySet
47 * @see com.sun.star.beans.XPropertyState
48 * @see com.sun.star.document.XDocumentInsertable
49 * @see com.sun.star.style.CharacterProperties
50 * @see com.sun.star.style.ParagraphProperties
51 * @see com.sun.star.text.XParagraphCursor
52 * @see com.sun.star.text.XSentenceCursor
53 * @see com.sun.star.text.XTextCursor
54 * @see com.sun.star.text.XTextRange
55 * @see com.sun.star.text.XWordCursor
56 * @see com.sun.star.util.XSortable
59 public class ScAnnotationTextCursor extends TestCase {
61 private XSpreadsheetDocument xSheetDoc = null;
63 @Override
64 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
65 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
66 log.println( "creating a Spreadsheet document" );
67 xSheetDoc = SOF.createCalcDoc(null);
70 @Override
71 protected void cleanup( TestParameters tParam, PrintWriter log ) {
72 log.println( " disposing xSheetDoc " );
73 XComponent oComp = UnoRuntime.queryInterface
74 (XComponent.class, xSheetDoc) ;
75 util.DesktopTools.closeDoc(oComp);
79 /**
80 * creating a TestEnvironment for the interfaces to be tested
82 @Override
83 public TestEnvironment createTestEnvironment
84 ( TestParameters Param, PrintWriter log )
85 throws Exception {
87 XInterface oObj = null;
89 // creation of testobject here
90 // first we write what we are intend to do to log file
91 log.println( "Creating a test environment" );
93 CellAddress cellPos = new CellAddress((short)0, 1, 2);
95 log.println("Getting test object ") ;
97 XSpreadsheetDocument xArea = UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc);
99 XSpreadsheets oSheets = xArea.getSheets();
101 XIndexAccess XAccess = UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
103 XSpreadsheet oSheet = (XSpreadsheet)XAccess.getByIndex(cellPos.Sheet);
105 XCellRange oCRange = UnoRuntime.queryInterface(XCellRange.class, oSheet);
107 XCell oCell = oCRange.getCellByPosition(cellPos.Column, cellPos.Row);
109 XSheetAnnotationAnchor oAnnoA = UnoRuntime.queryInterface(XSheetAnnotationAnchor.class, oCell);
111 XSheetAnnotation oAnno = oAnnoA.getAnnotation();
112 XSimpleText aText = UnoRuntime.queryInterface(XSimpleText.class,oAnno);
113 aText.setString("A nice little Test");
114 oObj = aText.createTextCursor();
116 TestEnvironment tEnv = new TestEnvironment( oObj );
118 // Other parameters required for interface tests
120 return tEnv;
123 } // finish class ScAnnotationTextCursor