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 com
.sun
.star
.lang
.XMultiServiceFactory
;
22 import com
.sun
.star
.uno
.UnoRuntime
;
23 import com
.sun
.star
.uno
.XInterface
;
24 import com
.sun
.star
.text
.XTextTablesSupplier
;
25 import com
.sun
.star
.text
.XTextFramesSupplier
;
26 import com
.sun
.star
.text
.XTextSectionsSupplier
;
27 import com
.sun
.star
.text
.XFootnotesSupplier
;
28 import com
.sun
.star
.text
.XBookmarksSupplier
;
29 import com
.sun
.star
.container
.XNameAccess
;
30 import com
.sun
.star
.container
.XIndexAccess
;
33 public class InstCreator
implements XInstCreator
{
34 private final XInterface xParent
;
35 private final XMultiServiceFactory xMSF
;
36 private final XInterface xInstance
;
37 private final XIndexAccess xIA
;
38 private final InstDescr iDsc
;
40 public InstCreator( XInterface xParent
, InstDescr iDsc
) {
41 this.xParent
= xParent
;
44 xMSF
= UnoRuntime
.queryInterface(
45 XMultiServiceFactory
.class, xParent
);
47 xInstance
= createInstance();
48 xIA
= createCollection();
50 public XInterface
getInstance() {
54 public XInterface
createInstance() {
55 XInterface xIfc
= null;
56 xIfc
= iDsc
.createInstance( xMSF
);
61 public XIndexAccess
getCollection() {
65 private XIndexAccess
createCollection() {
66 XNameAccess oNA
= null;
68 if ( iDsc
instanceof TableDsc
) {
69 XTextTablesSupplier oTTS
= UnoRuntime
.queryInterface(
70 XTextTablesSupplier
.class, xParent
);
72 oNA
= oTTS
.getTextTables();
74 if ( iDsc
instanceof FrameDsc
) {
75 XTextFramesSupplier oTTS
= UnoRuntime
.queryInterface(
76 XTextFramesSupplier
.class, xParent
);
78 oNA
= oTTS
.getTextFrames();
80 if ( iDsc
instanceof BookmarkDsc
) {
81 XBookmarksSupplier oTTS
= UnoRuntime
.queryInterface(
82 XBookmarksSupplier
.class, xParent
);
84 oNA
= oTTS
.getBookmarks();
87 if ( iDsc
instanceof FootnoteDsc
) {
88 XFootnotesSupplier oTTS
= UnoRuntime
.queryInterface(
89 XFootnotesSupplier
.class, xParent
);
91 return oTTS
.getFootnotes();
94 if ( iDsc
instanceof TextSectionDsc
) {
95 XTextSectionsSupplier oTSS
= UnoRuntime
.queryInterface(
96 XTextSectionsSupplier
.class, xParent
);
98 oNA
= oTSS
.getTextSections();
101 return UnoRuntime
.queryInterface(
102 XIndexAccess
.class, oNA
);