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 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
{
37 XMultiServiceFactory xMSF
;
42 public InstCreator( XInterface xParent
, InstDescr iDsc
) {
43 this.xParent
= xParent
;
46 xMSF
= UnoRuntime
.queryInterface(
47 XMultiServiceFactory
.class, xParent
);
49 xInstance
= createInstance();
50 xIA
= createCollection();
52 public XInterface
getInstance() {
56 public XInterface
createInstance() {
57 XInterface xIfc
= null;
58 xIfc
= iDsc
.createInstance( xMSF
);
63 public XIndexAccess
getCollection() {
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
);