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
.container
.XNameAccess
;
29 import com
.sun
.star
.lang
.XMultiServiceFactory
;
30 import com
.sun
.star
.text
.XText
;
31 import com
.sun
.star
.text
.XTextContent
;
32 import com
.sun
.star
.text
.XTextCursor
;
33 import com
.sun
.star
.text
.XTextDocument
;
34 import com
.sun
.star
.text
.XTextSectionsSupplier
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
41 * @see com.sun.star.text.XText
44 public class SwXTextSections
extends TestCase
{
45 XTextDocument xTextDoc
;
48 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
49 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF() );
50 log
.println( "creating a textdocument" );
51 xTextDoc
= SOF
.createTextDoc( null );
55 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
56 log
.println( " disposing xTextDoc " );
57 util
.DesktopTools
.closeDoc(xTextDoc
);
61 * creating a TestEnvironment for the interfaces to be tested
64 public TestEnvironment createTestEnvironment
65 (TestParameters Param
, PrintWriter log
) throws Exception
{
67 XInterface oObj
= null;
68 XInterface oTS
= null;
69 XNameAccess oTSSuppName
= null;
73 // creation of testobject here
74 // first we write what we are intend to do to log file
75 log
.println( "creating a test environment" );
78 oText
= xTextDoc
.getText();
79 XTextCursor oCursor
= oText
.createTextCursor();
82 log
.println( "inserting TextSections" );
84 XMultiServiceFactory oDocMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class, xTextDoc
);
87 oTS
= (XInterface
) oDocMSF
.createInstance
88 ("com.sun.star.text.TextSection");
89 XTextContent oTSC
= UnoRuntime
.queryInterface(XTextContent
.class, oTS
);
90 oText
.insertTextContent(oCursor
, oTSC
, false);
93 oTS
= (XInterface
) oDocMSF
.createInstance
94 ("com.sun.star.text.TextSection");
95 XTextContent oTSC2
= UnoRuntime
.queryInterface(XTextContent
.class, oTS
);
96 oText
.insertTextContent(oCursor
, oTSC2
, false);
99 log
.println( "try to get a TextSection with the XTextSectionSupplier()" );
102 XTextSectionsSupplier oTSSupp
= UnoRuntime
.queryInterface( XTextSectionsSupplier
.class,
104 oTSSuppName
= oTSSupp
.getTextSections();
107 System
.out
.println("Couldn't get Textsection " + e
);
113 log
.println( "creating a new environment for TextSections object" );
114 TestEnvironment tEnv
= new TestEnvironment( oObj
);
116 log
.println( "adding TextDocument as mod relation to environment" );
117 tEnv
.addObjRelation("TEXTDOC", xTextDoc
);
120 } // finish method getTestEnvironment
122 } // finish class SwXTextSection