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
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.SOfficeFactory
;
28 import com
.sun
.star
.beans
.XPropertySet
;
29 import com
.sun
.star
.container
.XNameAccess
;
30 import com
.sun
.star
.lang
.XComponent
;
31 import com
.sun
.star
.sheet
.XHeaderFooterContent
;
32 import com
.sun
.star
.sheet
.XSpreadsheetDocument
;
33 import com
.sun
.star
.style
.XStyle
;
34 import com
.sun
.star
.style
.XStyleFamiliesSupplier
;
35 import com
.sun
.star
.text
.XText
;
36 import com
.sun
.star
.uno
.AnyConverter
;
37 import com
.sun
.star
.uno
.Type
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
42 * Test for object which is represented by service
43 * <code>com.sun.star.text.TextCursor</code>. <p>
44 * Object implements the following interfaces :
46 * <li> <code>com::sun::star::text::XTextCursor</code></li>
47 * <li> <code>com::sun::star::text::XWordCursor</code></li>
48 * <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li>
49 * <li> <code>com::sun::star::text::XTextRange</code></li>
50 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
51 * <li> <code>com::sun::star::container::XContentEnumerationAccess</code></li>
52 * <li> <code>com::sun::star::beans::XPropertyState</code></li>
53 * <li> <code>com::sun::star::style::CharacterProperties</code></li>
54 * <li> <code>com::sun::star::text::XSentenceCursor</code></li>
55 * <li> <code>com::sun::star::style::ParagraphProperties</code></li>
56 * <li> <code>com::sun::star::text::XParagraphCursor</code></li>
57 * <li> <code>com::sun::star::document::XDocumentInsertable</code></li>
58 * <li> <code>com::sun::star::util::XSortable</code></li>
59 * <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li>
61 * @see com.sun.star.text.TextCursor
62 * @see com.sun.star.text.XTextCursor
63 * @see com.sun.star.text.XWordCursor
64 * @see com.sun.star.style.CharacterPropertiesComplex
65 * @see com.sun.star.text.XTextRange
66 * @see com.sun.star.beans.XPropertySet
67 * @see com.sun.star.container.XContentEnumerationAccess
68 * @see com.sun.star.beans.XPropertyState
69 * @see com.sun.star.style.CharacterProperties
70 * @see com.sun.star.text.XSentenceCursor
71 * @see com.sun.star.style.ParagraphProperties
72 * @see com.sun.star.text.XParagraphCursor
73 * @see com.sun.star.document.XDocumentInsertable
74 * @see com.sun.star.util.XSortable
75 * @see com.sun.star.style.CharacterPropertiesAsian
76 * @see ifc.text._XTextCursor
77 * @see ifc.text._XWordCursor
78 * @see ifc.style._CharacterPropertiesComplex
79 * @see ifc.text._XTextRange
80 * @see ifc.beans._XPropertySet
81 * @see ifc.container._XContentEnumerationAccess
82 * @see ifc.beans._XPropertyState
83 * @see ifc.style._CharacterProperties
84 * @see ifc.text._XSentenceCursor
85 * @see ifc.style._ParagraphProperties
86 * @see ifc.text._XParagraphCursor
87 * @see ifc.document._XDocumentInsertable
88 * @see ifc.util._XSortable
89 * @see ifc.style._CharacterPropertiesAsian
91 public class ScHeaderFooterTextCursor
extends TestCase
{
92 private XSpreadsheetDocument xSpreadsheetDoc
;
95 * Creates Spreadsheet document.
98 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
99 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
100 log
.println( "creating a Spreadsheet document" );
101 xSpreadsheetDoc
= SOF
.createCalcDoc(null);
105 * Disposes Spreadsheet document.
108 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
109 log
.println( " disposing xSheetDoc " );
110 XComponent oComp
= UnoRuntime
.queryInterface (XComponent
.class, xSpreadsheetDoc
) ;
111 util
.DesktopTools
.closeDoc(oComp
);
115 * Creating a TestEnvironment for the interfaces to be tested.
116 * Retrieves the collection of style families available in the document
117 * using the interface <code>XStyleFamiliesSupplier</code>.
118 * Obtains default style from the style family <code>'PageStyles'</code>.
119 * Retrieves value of the property <code>'RightPageHeaderContent'</code>.
120 * Sets some string for the text which is printed in the center part of the
121 * header or footer using the interface <code>XHeaderFooterContent</code>
122 * and sets new value of the property <code>'RightPageHeaderContent'</code>.
123 * Creates text cursor for the text which is printed in the center part of
124 * the header or footer. This text cursor is the instance of the service
125 * <code>com.sun.star.text.TextCursor</code>.
129 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) throws Exception
{
131 XInterface oObj
= null;
132 XPropertySet PropSet
;
133 XNameAccess PageStyles
= null;
134 XStyle StdStyle
= null;
136 XStyleFamiliesSupplier StyleFam
= UnoRuntime
.queryInterface(
137 XStyleFamiliesSupplier
.class,
140 XNameAccess StyleFamNames
= StyleFam
.getStyleFamilies();
141 PageStyles
= (XNameAccess
) AnyConverter
.toObject(
142 new Type(XNameAccess
.class),StyleFamNames
.getByName("PageStyles"));
143 StdStyle
= (XStyle
) AnyConverter
.toObject(
144 new Type(XStyle
.class),PageStyles
.getByName("Default"));
146 //get the property-set
147 PropSet
= UnoRuntime
.queryInterface(XPropertySet
.class, StdStyle
);
149 XHeaderFooterContent RPHC
= null;
150 // creation of testobject here
151 // first we write what we are intend to do to log file
152 log
.println( "creating a test environment" );
153 RPHC
= (XHeaderFooterContent
) AnyConverter
.toObject(
154 new Type(XHeaderFooterContent
.class),
155 PropSet
.getPropertyValue("RightPageHeaderContent"));
157 XText center
= RPHC
.getCenterText();
158 center
.setString("CENTER");
160 PropSet
.setPropertyValue("RightPageHeaderContent",RPHC
);
162 // create testobject here
163 oObj
= center
.createTextCursor();
164 TestEnvironment tEnv
= new TestEnvironment(oObj
);
166 // add relation for XTextRange
167 tEnv
.addObjRelation("XTEXT",
168 UnoRuntime
.queryInterface(XText
.class,center
));
172 } // finish method getTestEnvironment
174 } // finish class ScHeaderFooterTextCursor