bump product version to 4.1.6.2
[LibreOffice.git] / qadevOOo / runner / util / InstCreator.java
blob2f131a263fea53f4a1517135f49efbafbce7c7eb
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 util;
21 import util.XInstCreator;
23 import com.sun.star.lang.XMultiServiceFactory;
24 import com.sun.star.uno.UnoRuntime;
25 import com.sun.star.uno.XInterface;
26 import com.sun.star.text.XTextTablesSupplier;
27 import com.sun.star.text.XTextFramesSupplier;
28 import com.sun.star.text.XTextSectionsSupplier;
29 import com.sun.star.text.XFootnotesSupplier;
30 import com.sun.star.text.XBookmarksSupplier;
31 import com.sun.star.container.XNameAccess;
32 import com.sun.star.container.XIndexAccess;
35 public class InstCreator implements XInstCreator {
36 XInterface xParent;
37 XMultiServiceFactory xMSF;
38 XInterface xInstance;
39 XIndexAccess xIA;
40 InstDescr iDsc;
42 public InstCreator( XInterface xParent, InstDescr iDsc ) {
43 this.xParent = xParent;
44 this.iDsc = iDsc;
46 xMSF = UnoRuntime.queryInterface(
47 XMultiServiceFactory.class, xParent );
49 xInstance = createInstance();
50 xIA = createCollection();
52 public XInterface getInstance() {
53 return xInstance;
56 public XInterface createInstance() {
57 XInterface xIfc = null;
58 xIfc = iDsc.createInstance( xMSF );
60 return xIfc;
63 public XIndexAccess getCollection() {
64 return xIA;
67 private XIndexAccess createCollection() {
68 XNameAccess oNA = null;
70 if ( iDsc instanceof TableDsc ) {
71 XTextTablesSupplier oTTS = UnoRuntime.queryInterface(
72 XTextTablesSupplier.class, xParent );
74 oNA = oTTS.getTextTables();
76 if ( iDsc instanceof FrameDsc ) {
77 XTextFramesSupplier oTTS = UnoRuntime.queryInterface(
78 XTextFramesSupplier.class, xParent );
80 oNA = oTTS.getTextFrames();
82 if ( iDsc instanceof BookmarkDsc ) {
83 XBookmarksSupplier oTTS = UnoRuntime.queryInterface(
84 XBookmarksSupplier.class, xParent );
86 oNA = oTTS.getBookmarks();
89 if ( iDsc instanceof FootnoteDsc ) {
90 XFootnotesSupplier oTTS = UnoRuntime.queryInterface(
91 XFootnotesSupplier.class, xParent );
93 return( oTTS.getFootnotes() );
96 if ( iDsc instanceof TextSectionDsc ) {
97 XTextSectionsSupplier oTSS = UnoRuntime.queryInterface(
98 XTextSectionsSupplier.class, xParent );
100 oNA = oTSS.getTextSections();
103 return UnoRuntime.queryInterface(
104 XIndexAccess.class, oNA);