1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef BASICMANAGERREPOSITORY_HXX 25 #define BASICMANAGERREPOSITORY_HXX 26 27 #include "basic/basicdllapi.h" 28 29 /** === begin UNO includes === **/ 30 #include <com/sun/star/frame/XModel.hpp> 31 #include <com/sun/star/embed/XStorage.hpp> 32 /** === end UNO includes === **/ 33 34 class BasicManager; 35 36 //........................................................................ 37 namespace basic 38 { 39 //........................................................................ 40 41 //==================================================================== 42 //= BasicManagerRepository 43 //==================================================================== 44 /** specifies a callback for instances which are interested in BasicManagers 45 created by the BasicManagerRepository. 46 */ 47 class BASIC_DLLPUBLIC SAL_NO_VTABLE BasicManagerCreationListener 48 { 49 public: 50 /** is called when a BasicManager has been created 51 52 @param _rxForDocument 53 denotes the document for which the BasicManager has been created. If this is <NULL/>, 54 then the BasicManager is the application-wide BasicManager. 55 56 @param _pBasicManager 57 denotes the BasicManager which has been created. The listener might for instance 58 decide to add global variables to it, or otherwise initialize it. 59 */ 60 virtual void onBasicManagerCreated( 61 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxForDocument, 62 BasicManager& _rBasicManager 63 ) = 0; 64 }; 65 66 //==================================================================== 67 //= BasicManagerRepository 68 //==================================================================== 69 class BASIC_DLLPUBLIC BasicManagerRepository 70 { 71 public: 72 /** returns the BasicManager belonging to the given document 73 74 If the BasicManager does not yet exist, it is created. In this case, if the application's 75 BasicManager does not yet exist, it is also created. This is necessary since 76 the application's BasicManager acts as parent for all document's BasicManagers. 77 78 If you're interested in this case - the implicit creation of the application's BasicManager -, 79 then you need to register as BasicManagerCreationListener. 80 81 @param _rxDocumentModel 82 denotes the document model whose BasicManager is to be retrieved. Must not be <NULL/>. 83 The document should support the XDocumentInfoSupplier interface, for retrieving 84 its title, which is needed in some error conditions. 85 Also it <em>must</em> support the XStorageBasedDocument interface, since we 86 must be able to retrieve the document's storage. If this interface is <em>not</em> 87 supported, creating a new BasicManager will certainly fail. 88 89 @return 90 the BasicManager for this model. 91 92 @attention 93 The returned BasicManager instances is owned by the repository. In particular, 94 you are not allowed to delete it. Instead, the given model is observed: As soon 95 as it's closed, the associated BasicManager is deleted. 96 */ 97 static BasicManager* getDocumentBasicManager( 98 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocumentModel 99 ); 100 101 /** returns the application-wide BasicManager 102 103 @param _bCreate 104 determines whether the BasicManager should be created (<TRUE/>) if it 105 does not yet exist. 106 107 @attention 108 If the BasicManager is newly created, then it is still owned by the repository. 109 In particular, you are not allowed to delete it. Instead, call resetApplicationBasicManager 110 to release the BasicManager. 111 */ 112 static BasicManager* getApplicationBasicManager( bool _bCreate ); 113 114 /** resets the application-wide BasicManager to <NULL/> 115 */ 116 static void resetApplicationBasicManager(); 117 118 /** registers a BasicManagerCreationListener instance which is notified whenever 119 the repository creates a BasicManager instance. 120 121 Note that this listener is <em>not</em> called when somebody else 122 creates BasicManager instances. 123 124 If the same listener is registered multiple times, it is also notified 125 multiple times, and needs to be revoked once for each registration. 126 */ 127 static void registerCreationListener( 128 BasicManagerCreationListener& _rListener 129 ); 130 131 /** reveokes a BasicManagerCreationListener instance which has previously 132 been registered to be notified about created BasicManager instances. 133 */ 134 static void revokeCreationListener( 135 BasicManagerCreationListener& _rListener 136 ); 137 }; 138 139 //........................................................................ 140 } // namespace basic 141 //........................................................................ 142 143 #endif // BASICMANAGERREPOSITORY_HXX 144 145