Bump version to 6.4-15
[LibreOffice.git] / include / basic / basicmanagerrepository.hxx
blobe9e906685ed6071e1e27da33c1c0b2fd0f8e1fbe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_BASIC_BASICMANAGERREPOSITORY_HXX
21 #define INCLUDED_BASIC_BASICMANAGERREPOSITORY_HXX
23 #include <basic/basicdllapi.h>
25 namespace com::sun::star::frame { class XModel; }
26 namespace com::sun::star::uno { template <typename > class Reference; }
28 class BasicManager;
31 namespace basic
35 //= BasicManagerRepository
37 /** specifies a callback for instances which are interested in BasicManagers
38 created by the BasicManagerRepository.
40 class BASIC_DLLPUBLIC SAL_NO_VTABLE BasicManagerCreationListener
42 public:
43 /** is called when a BasicManager has been created
45 @param _rxForDocument
46 denotes the document for which the BasicManager has been created. If this is <NULL/>,
47 then the BasicManager is the application-wide BasicManager.
49 @param _pBasicManager
50 denotes the BasicManager which has been created. The listener might for instance
51 decide to add global variables to it, or otherwise initialize it.
53 virtual void onBasicManagerCreated(
54 const css::uno::Reference< css::frame::XModel >& _rxForDocument,
55 BasicManager& _rBasicManager
56 ) = 0;
58 protected:
59 ~BasicManagerCreationListener() {}
63 //= BasicManagerRepository
65 class BASIC_DLLPUBLIC BasicManagerRepository
67 public:
68 /** returns the BasicManager belonging to the given document
70 If the BasicManager does not yet exist, it is created. In this case, if the application's
71 BasicManager does not yet exist, it is also created. This is necessary since
72 the application's BasicManager acts as parent for all document's BasicManagers.
74 If you're interested in this case - the implicit creation of the application's BasicManager -,
75 then you need to register as BasicManagerCreationListener.
77 @param _rxDocumentModel
78 denotes the document model whose BasicManager is to be retrieved. Must not be <NULL/>.
79 The document should support the XDocumentPropertiesSupplier
80 interface, for retrieving
81 its title, which is needed in some error conditions.
82 Also it <em>must</em> support the XStorageBasedDocument interface, since we
83 must be able to retrieve the document's storage. If this interface is <em>not</em>
84 supported, creating a new BasicManager will certainly fail.
86 @return
87 the BasicManager for this model.
89 @attention
90 The returned BasicManager instances is owned by the repository. In particular,
91 you are not allowed to delete it. Instead, the given model is observed: As soon
92 as it's closed, the associated BasicManager is deleted.
94 static BasicManager* getDocumentBasicManager(
95 const css::uno::Reference< css::frame::XModel >& _rxDocumentModel
98 /** returns the application-wide BasicManager
100 @attention
101 If the BasicManager is newly created, then it is still owned by the repository.
102 In particular, you are not allowed to delete it. Instead, call resetApplicationBasicManager
103 to release the BasicManager.
105 static BasicManager* getApplicationBasicManager();
107 /** resets the application-wide BasicManager to <NULL/>
109 static void resetApplicationBasicManager();
111 /** registers a BasicManagerCreationListener instance which is notified whenever
112 the repository creates a BasicManager instance.
114 Note that this listener is <em>not</em> called when somebody else
115 creates BasicManager instances.
117 If the same listener is registered multiple times, it is also notified
118 multiple times, and needs to be revoked once for each registration.
120 static void registerCreationListener(
121 BasicManagerCreationListener& _rListener
124 /** revokes a BasicManagerCreationListener instance which has previously
125 been registered to be notified about created BasicManager instances.
127 static void revokeCreationListener(
128 BasicManagerCreationListener& _rListener
133 } // namespace basic
136 #endif // INCLUDED_BASIC_BASICMANAGERREPOSITORY_HXX
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */