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 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
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
.sheet
.XSheetAnnotation
;
32 import com
.sun
.star
.sheet
.XSheetAnnotationAnchor
;
33 import com
.sun
.star
.sheet
.XSpreadsheet
;
34 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
35 import com
.sun
.star
.sheet
.XSpreadsheets
;
36 import com
.sun
.star
.table
.CellAddress
;
37 import com
.sun
.star
.table
.XCell
;
38 import com
.sun
.star
.table
.XCellRange
;
39 import com
.sun
.star
.text
.XSimpleText
;
40 import com
.sun
.star
.uno
.UnoRuntime
;
41 import com
.sun
.star
.uno
.XInterface
;
47 * @see com.sun.star.beans.XPropertySet
48 * @see com.sun.star.beans.XPropertyState
49 * @see com.sun.star.document.XDocumentInsertable
50 * @see com.sun.star.style.CharacterProperties
51 * @see com.sun.star.style.ParagraphProperties
52 * @see com.sun.star.text.XParagraphCursor
53 * @see com.sun.star.text.XSentenceCursor
54 * @see com.sun.star.text.XTextCursor
55 * @see com.sun.star.text.XTextRange
56 * @see com.sun.star.text.XWordCursor
57 * @see com.sun.star.util.XSortable
60 public class ScAnnotationTextCursor
extends TestCase
{
62 private XSpreadsheetDocument xSheetDoc
= null;
65 protected void initialize( TestParameters tParam
, PrintWriter log
) {
66 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
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
);
80 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
81 log
.println( " disposing xSheetDoc " );
82 XComponent oComp
= UnoRuntime
.queryInterface
83 (XComponent
.class, xSheetDoc
) ;
84 util
.DesktopTools
.closeDoc(oComp
);
89 * creating a Testenvironment for the interfaces to be tested
92 public synchronized TestEnvironment createTestEnvironment
93 ( TestParameters Param
, PrintWriter log
)
94 throws StatusException
{
96 XInterface oObj
= null;
98 // creation of testobject here
99 // first we write what we are intend to do to log file
100 log
.println( "Creating a test environment" );
102 CellAddress cellPos
= new CellAddress((short)0, 1, 2);
105 log
.println("Getting test object ") ;
107 XSpreadsheetDocument xArea
= UnoRuntime
.queryInterface(XSpreadsheetDocument
.class, xSheetDoc
);
109 XSpreadsheets oSheets
= xArea
.getSheets();
111 XIndexAccess XAccess
= UnoRuntime
.queryInterface(XIndexAccess
.class, oSheets
);
113 XSpreadsheet oSheet
= (XSpreadsheet
)XAccess
.getByIndex(cellPos
.Sheet
);
115 XCellRange oCRange
= UnoRuntime
.queryInterface(XCellRange
.class, oSheet
);
117 XCell oCell
= oCRange
.getCellByPosition(cellPos
.Column
, cellPos
.Row
);
119 XSheetAnnotationAnchor oAnnoA
= UnoRuntime
.queryInterface(XSheetAnnotationAnchor
.class, oCell
);
121 XSheetAnnotation oAnno
= oAnnoA
.getAnnotation();
122 XSimpleText aText
= UnoRuntime
.queryInterface(XSimpleText
.class,oAnno
);
123 aText
.setString("A nice little Test");
124 oObj
= aText
.createTextCursor();
126 } catch (Exception e
) {
127 e
.printStackTrace(log
) ;
128 throw new StatusException(
129 "Error getting test object from spreadsheet document",e
) ;
132 TestEnvironment tEnv
= new TestEnvironment( oObj
);
134 // Other parameters required for interface tests
139 } // finish class ScAnnotationTextCursor