1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScAnnotationTextCursor.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.SOfficeFactory
;
41 import com
.sun
.star
.container
.XIndexAccess
;
42 import com
.sun
.star
.lang
.XComponent
;
43 import com
.sun
.star
.lang
.XMultiServiceFactory
;
44 import com
.sun
.star
.sheet
.XSheetAnnotation
;
45 import com
.sun
.star
.sheet
.XSheetAnnotationAnchor
;
46 import com
.sun
.star
.sheet
.XSpreadsheet
;
47 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
48 import com
.sun
.star
.sheet
.XSpreadsheets
;
49 import com
.sun
.star
.table
.CellAddress
;
50 import com
.sun
.star
.table
.XCell
;
51 import com
.sun
.star
.table
.XCellRange
;
52 import com
.sun
.star
.text
.XSimpleText
;
53 import com
.sun
.star
.uno
.UnoRuntime
;
54 import com
.sun
.star
.uno
.XInterface
;
60 * @see com.sun.star.beans.XPropertySet
61 * @see com.sun.star.beans.XPropertyState
62 * @see com.sun.star.document.XDocumentInsertable
63 * @see com.sun.star.style.CharacterProperties
64 * @see com.sun.star.style.ParagraphProperties
65 * @see com.sun.star.text.XParagraphCursor
66 * @see com.sun.star.text.XSentenceCursor
67 * @see com.sun.star.text.XTextCursor
68 * @see com.sun.star.text.XTextRange
69 * @see com.sun.star.text.XWordCursor
70 * @see com.sun.star.util.XSortable
73 public class ScAnnotationTextCursor
extends TestCase
{
75 static XSpreadsheetDocument xSheetDoc
= null;
77 protected void initialize( TestParameters tParam
, PrintWriter log
) {
78 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
) tParam
.getMSF() );
81 log
.println( "creating a Spreadsheet document" );
82 xSheetDoc
= SOF
.createCalcDoc(null);
83 } catch ( com
.sun
.star
.uno
.Exception e
) {
84 // Some exception occures.FAILED
85 e
.printStackTrace( log
);
86 throw new StatusException( "Couldn't create document", e
);
91 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
92 log
.println( " disposing xSheetDoc " );
93 XComponent oComp
= (XComponent
) UnoRuntime
.queryInterface
94 (XComponent
.class, xSheetDoc
) ;
95 util
.DesktopTools
.closeDoc(oComp
);
100 * creating a Testenvironment for the interfaces to be tested
102 public synchronized TestEnvironment createTestEnvironment
103 ( TestParameters Param
, PrintWriter log
)
104 throws StatusException
{
106 XInterface oObj
= null;
108 // creation of testobject here
109 // first we write what we are intend to do to log file
110 log
.println( "Creating a test environment" );
112 CellAddress cellPos
= new CellAddress((short)0, 1, 2);
115 log
.println("Getting test object ") ;
117 XSpreadsheetDocument xArea
= (XSpreadsheetDocument
)
118 UnoRuntime
.queryInterface(XSpreadsheetDocument
.class, xSheetDoc
);
120 XSpreadsheets oSheets
= (XSpreadsheets
) xArea
.getSheets();
122 XIndexAccess XAccess
= (XIndexAccess
)
123 UnoRuntime
.queryInterface(XIndexAccess
.class, oSheets
);
125 XSpreadsheet oSheet
= (XSpreadsheet
)XAccess
.getByIndex(cellPos
.Sheet
);
127 XCellRange oCRange
= (XCellRange
)
128 UnoRuntime
.queryInterface(XCellRange
.class, oSheet
);
130 XCell oCell
= oCRange
.getCellByPosition(cellPos
.Column
, cellPos
.Row
);
132 XSheetAnnotationAnchor oAnnoA
= (XSheetAnnotationAnchor
)
133 UnoRuntime
.queryInterface(XSheetAnnotationAnchor
.class, oCell
);
135 XSheetAnnotation oAnno
= oAnnoA
.getAnnotation();
136 XSimpleText aText
= (XSimpleText
)
137 UnoRuntime
.queryInterface(XSimpleText
.class,oAnno
);
138 aText
.setString("A nice little Test");
139 oObj
= aText
.createTextCursor();
141 } catch (Exception e
) {
142 e
.printStackTrace(log
) ;
143 throw new StatusException(
144 "Error getting test object from spreadsheet document",e
) ;
147 TestEnvironment tEnv
= new TestEnvironment( oObj
);
149 // Other parameters required for interface tests
154 } // finish class ScAnnotationTextCursor