File: | home/maarten/src/libreoffice/core/dbaccess/source/ui/browser/dsbrowserDnD.cxx |
Warning: | line 246, column 21 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
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/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
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 . | |||
18 | */ | |||
19 | ||||
20 | #include <dbexchange.hxx> | |||
21 | #include <dbtreelistbox.hxx> | |||
22 | #include "dbtreemodel.hxx" | |||
23 | #include <UITools.hxx> | |||
24 | #include <unodatbr.hxx> | |||
25 | ||||
26 | #include <com/sun/star/frame/XStorable.hpp> | |||
27 | #include <com/sun/star/sdb/CommandType.hpp> | |||
28 | #include <com/sun/star/sdbc/SQLException.hpp> | |||
29 | ||||
30 | #include <connectivity/dbexception.hxx> | |||
31 | #include <connectivity/dbtools.hxx> | |||
32 | #include <cppuhelper/exc_hlp.hxx> | |||
33 | #include <svx/dataaccessdescriptor.hxx> | |||
34 | #include <tools/diagnose_ex.h> | |||
35 | #include <osl/diagnose.h> | |||
36 | #include <vcl/svapp.hxx> | |||
37 | ||||
38 | #include <algorithm> | |||
39 | ||||
40 | namespace dbaui | |||
41 | { | |||
42 | ||||
43 | using namespace ::com::sun::star::uno; | |||
44 | using namespace ::com::sun::star::sdb; | |||
45 | using namespace ::com::sun::star::sdbc; | |||
46 | using namespace ::com::sun::star::sdbcx; | |||
47 | using namespace ::com::sun::star::beans; | |||
48 | using namespace ::com::sun::star::util; | |||
49 | using namespace ::com::sun::star::frame; | |||
50 | using namespace ::com::sun::star::container; | |||
51 | using namespace ::com::sun::star::lang; | |||
52 | using namespace ::com::sun::star::form; | |||
53 | using namespace ::com::sun::star::io; | |||
54 | using namespace ::com::sun::star::i18n; | |||
55 | using namespace ::com::sun::star::task; | |||
56 | using namespace ::com::sun::star::datatransfer; | |||
57 | using namespace ::dbtools; | |||
58 | using namespace ::svx; | |||
59 | ||||
60 | bool SbaTableQueryBrowser::implCopyObject(ODataClipboard& rExchange, const weld::TreeIter& rApplyTo, sal_Int32 nCommandType) | |||
61 | { | |||
62 | try | |||
63 | { | |||
64 | OUString aName = GetEntryText(rApplyTo); | |||
65 | std::unique_ptr<weld::TreeIter> xRootEntry(m_pTreeView->GetRootLevelParent(&rApplyTo)); | |||
66 | OUString aDSName = getDataSourceAccessor(*xRootEntry); | |||
67 | ||||
68 | SharedConnection xConnection; | |||
69 | if ( CommandType::QUERY != nCommandType ) | |||
70 | { | |||
71 | if (!ensureConnection(&rApplyTo, xConnection)) | |||
72 | return false; | |||
73 | rExchange.Update(aDSName, nCommandType, aName, xConnection, getNumberFormatter(), getORB()); | |||
74 | } | |||
75 | else | |||
76 | rExchange.Update(aDSName, nCommandType, aName, getNumberFormatter(), getORB()); | |||
77 | ||||
78 | // the ownership goes to ODataClipboards | |||
79 | return true; | |||
80 | } | |||
81 | catch(const SQLException& ) | |||
82 | { | |||
83 | showError( SQLExceptionInfo( ::cppu::getCaughtException() ) ); | |||
84 | } | |||
85 | catch( const Exception& ) | |||
86 | { | |||
87 | DBG_UNHANDLED_EXCEPTION("dbaccess")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/dbaccess/source/ui/browser/dsbrowserDnD.cxx" ":" "87" ": ", "dbaccess" );; | |||
88 | } | |||
89 | return false; | |||
90 | } | |||
91 | ||||
92 | sal_Int8 SbaTableQueryBrowser::queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors ) | |||
93 | { | |||
94 | // check if we're a table or query container | |||
95 | weld::TreeView& rTreeView = m_pTreeView->GetWidget(); | |||
96 | std::unique_ptr<weld::TreeIter> xHitEntry(rTreeView.make_iterator()); | |||
97 | // get_dest_row_at_pos with false cause no drop if no entry was hit exactly | |||
98 | if (rTreeView.get_dest_row_at_pos(_rEvt.maPosPixel, xHitEntry.get(), false)) | |||
99 | { | |||
100 | // it must be a container | |||
101 | EntryType eEntryType = getEntryType(*xHitEntry); | |||
102 | SharedConnection xConnection; | |||
103 | if ( eEntryType == etTableContainer && ensureConnection(xHitEntry.get(), xConnection ) && xConnection.is()) | |||
104 | { | |||
105 | Reference<XChild> xChild(xConnection,UNO_QUERY); | |||
106 | Reference<XStorable> xStore; | |||
107 | if ( xChild.is() ) | |||
108 | xStore.set( getDataSourceOrModel(xChild->getParent()), UNO_QUERY ); | |||
109 | // check for the concrete type | |||
110 | if ( xStore.is() && !xStore->isReadonly() && std::any_of(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(E_TABLE)) ) | |||
111 | return DND_ACTION_COPYcss::datatransfer::dnd::DNDConstants::ACTION_COPY; | |||
112 | } | |||
113 | } | |||
114 | ||||
115 | return DND_ACTION_NONEcss::datatransfer::dnd::DNDConstants::ACTION_NONE; | |||
116 | } | |||
117 | sal_Int8 SbaTableQueryBrowser::executeDrop( const ExecuteDropEvent& _rEvt ) | |||
118 | { | |||
119 | weld::TreeView& rTreeView = m_pTreeView->GetWidget(); | |||
120 | std::unique_ptr<weld::TreeIter> xHitEntry(rTreeView.make_iterator()); | |||
121 | // get_dest_row_at_pos with false cause no drop if no entry was hit exactly | |||
122 | if (!rTreeView.get_dest_row_at_pos(_rEvt.maPosPixel, xHitEntry.get(), false)) | |||
123 | return DND_ACTION_NONEcss::datatransfer::dnd::DNDConstants::ACTION_NONE; | |||
124 | EntryType eEntryType = getEntryType(*xHitEntry); | |||
125 | if (!isContainer(eEntryType)) | |||
126 | { | |||
127 | OSL_FAIL("SbaTableQueryBrowser::executeDrop: what the hell did queryDrop do?")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/dbaccess/source/ui/browser/dsbrowserDnD.cxx" ":" "127" ": "), "%s", "SbaTableQueryBrowser::executeDrop: what the hell did queryDrop do?" ); } } while (false); | |||
128 | // queryDrop should not have allowed us to reach this situation... | |||
129 | return DND_ACTION_NONEcss::datatransfer::dnd::DNDConstants::ACTION_NONE; | |||
130 | } | |||
131 | // a TransferableDataHelper for accessing the dropped data | |||
132 | TransferableDataHelper aDroppedData(_rEvt.maDropEvent.Transferable); | |||
133 | ||||
134 | // reset the data of the previous async drop (if any) | |||
135 | if ( m_nAsyncDrop ) | |||
136 | Application::RemoveUserEvent(m_nAsyncDrop); | |||
137 | ||||
138 | m_nAsyncDrop = nullptr; | |||
139 | m_aAsyncDrop.aDroppedData.clear(); | |||
140 | m_aAsyncDrop.nType = E_TABLE; | |||
141 | m_aAsyncDrop.nAction = _rEvt.mnAction; | |||
142 | m_aAsyncDrop.bError = false; | |||
143 | m_aAsyncDrop.bHtml = false; | |||
144 | m_aAsyncDrop.xDroppedAt.reset(); | |||
145 | m_aAsyncDrop.aUrl.clear(); | |||
146 | ||||
147 | // loop through the available formats and see what we can do ... | |||
148 | // first we have to check if it is our own format, if not we have to copy the stream :-( | |||
149 | if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(aDroppedData.GetDataFlavorExVector()) ) | |||
150 | { | |||
151 | m_aAsyncDrop.aDroppedData = ODataAccessObjectTransferable::extractObjectDescriptor(aDroppedData); | |||
152 | m_aAsyncDrop.xDroppedAt = std::move(xHitEntry); | |||
153 | ||||
154 | // asynchron because we some dialogs and we aren't allowed to show them while in D&D | |||
155 | m_nAsyncDrop = Application::PostUserEvent(LINK(this, SbaTableQueryBrowser, OnAsyncDrop)::tools::detail::makeLink( ::tools::detail::castTo<SbaTableQueryBrowser *>(this), &SbaTableQueryBrowser::LinkStubOnAsyncDrop)); | |||
156 | return DND_ACTION_COPYcss::datatransfer::dnd::DNDConstants::ACTION_COPY; | |||
157 | } | |||
158 | else | |||
159 | { | |||
160 | SharedConnection xDestConnection; | |||
161 | if ( ensureConnection( xHitEntry.get(), xDestConnection ) | |||
162 | && xDestConnection.is() | |||
163 | && m_aTableCopyHelper.copyTagTable( aDroppedData, m_aAsyncDrop, xDestConnection ) | |||
164 | ) | |||
165 | { | |||
166 | m_aAsyncDrop.xDroppedAt = std::move(xHitEntry); | |||
167 | ||||
168 | // asynchron because we some dialogs and we aren't allowed to show them while in D&D | |||
169 | m_nAsyncDrop = Application::PostUserEvent(LINK(this, SbaTableQueryBrowser, OnAsyncDrop)::tools::detail::makeLink( ::tools::detail::castTo<SbaTableQueryBrowser *>(this), &SbaTableQueryBrowser::LinkStubOnAsyncDrop)); | |||
170 | return DND_ACTION_COPYcss::datatransfer::dnd::DNDConstants::ACTION_COPY; | |||
171 | } | |||
172 | } | |||
173 | ||||
174 | return DND_ACTION_NONEcss::datatransfer::dnd::DNDConstants::ACTION_NONE; | |||
175 | } | |||
176 | ||||
177 | bool SbaTableQueryBrowser::requestDrag(const weld::TreeIter& rEntry) | |||
178 | { | |||
179 | // it must be a query/table | |||
180 | EntryType eEntryType = getEntryType(rEntry); | |||
181 | if (!isObject(eEntryType)) | |||
182 | return false; | |||
183 | ||||
184 | ODataClipboard& rExchange = static_cast<ODataClipboard&>(m_pTreeView->GetDataTransfer()); | |||
185 | return implCopyObject(rExchange, rEntry, (etTableOrView == eEntryType) ? CommandType::TABLE : CommandType::QUERY); | |||
186 | } | |||
187 | ||||
188 | IMPL_LINK_NOARG(SbaTableQueryBrowser, OnCopyEntry, LinkParamNone*, void)void SbaTableQueryBrowser::LinkStubOnCopyEntry(void * instance , LinkParamNone* data) { return static_cast<SbaTableQueryBrowser *>(instance)->OnCopyEntry(data); } void SbaTableQueryBrowser ::OnCopyEntry(__attribute__ ((unused)) LinkParamNone*) | |||
189 | { | |||
190 | weld::TreeView& rTreeView = m_pTreeView->GetWidget(); | |||
191 | std::unique_ptr<weld::TreeIter> xSelected = rTreeView.make_iterator(); | |||
192 | if (rTreeView.get_selected(xSelected.get()) && isEntryCopyAllowed(*xSelected)) | |||
193 | copyEntry(*xSelected); | |||
194 | } | |||
195 | ||||
196 | bool SbaTableQueryBrowser::isEntryCopyAllowed(const weld::TreeIter& rEntry) const | |||
197 | { | |||
198 | EntryType eType = getEntryType(rEntry); | |||
199 | return ( eType == etTableOrView || eType == etQuery ); | |||
200 | } | |||
201 | ||||
202 | void SbaTableQueryBrowser::copyEntry(const weld::TreeIter& rEntry) | |||
203 | { | |||
204 | EntryType eType = getEntryType(rEntry); | |||
205 | rtl::Reference<ODataClipboard> xTransfer(new ODataClipboard); | |||
206 | if (implCopyObject(*xTransfer, rEntry, eType == etQuery ? CommandType::QUERY : CommandType::TABLE)) | |||
207 | xTransfer->CopyToClipboard(getView()); | |||
208 | } | |||
209 | ||||
210 | IMPL_LINK_NOARG( SbaTableQueryBrowser, OnAsyncDrop, void*, void )void SbaTableQueryBrowser::LinkStubOnAsyncDrop(void * instance , void* data) { return static_cast<SbaTableQueryBrowser *> (instance)->OnAsyncDrop(data); } void SbaTableQueryBrowser ::OnAsyncDrop(__attribute__ ((unused)) void*) | |||
211 | { | |||
212 | m_nAsyncDrop = nullptr; | |||
213 | SolarMutexGuard aSolarGuard; | |||
214 | ::osl::MutexGuard aGuard( getMutex() ); | |||
215 | ||||
216 | if ( m_aAsyncDrop.nType == E_TABLE ) | |||
217 | { | |||
218 | SharedConnection xDestConnection; | |||
219 | if ( ensureConnection(m_aAsyncDrop.xDroppedAt.get(), xDestConnection) && xDestConnection.is()) | |||
220 | { | |||
221 | std::unique_ptr<weld::TreeIter> xDataSourceEntry = | |||
222 | m_pTreeView->GetRootLevelParent(m_aAsyncDrop.xDroppedAt.get()); | |||
223 | m_aTableCopyHelper.asyncCopyTagTable(m_aAsyncDrop, getDataSourceAccessor(*xDataSourceEntry), xDestConnection); | |||
224 | } | |||
225 | } | |||
226 | ||||
227 | m_aAsyncDrop.aDroppedData.clear(); | |||
228 | } | |||
229 | ||||
230 | void SbaTableQueryBrowser::clearTreeModel() | |||
231 | { | |||
232 | weld::TreeView& rTreeView = m_pTreeView->GetWidget(); | |||
233 | rTreeView.all_foreach([this, &rTreeView](weld::TreeIter& rEntryLoop){ | |||
234 | // clear the user data of the tree model | |||
235 | DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rEntryLoop).toUInt64()); | |||
236 | if (pData) | |||
| ||||
237 | { | |||
238 | rTreeView.set_id(rEntryLoop, OUString()); | |||
239 | Reference<XContainer> xContainer(pData->xContainer, UNO_QUERY); | |||
240 | if (xContainer.is()) | |||
241 | xContainer->removeContainerListener(this); | |||
242 | ||||
243 | if (pData->xConnection.is()) | |||
244 | { | |||
245 | // connections are to be stored *only* at the data source entries | |||
246 | impl_releaseConnection(pData->xConnection); | |||
| ||||
247 | } | |||
248 | ||||
249 | delete pData; | |||
250 | } | |||
251 | return false; | |||
252 | }); | |||
253 | ||||
254 | m_xCurrentlyDisplayed.reset(); | |||
255 | } | |||
256 | } // namespace dbaui | |||
257 | ||||
258 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
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/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
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 . |
18 | */ |
19 | |
20 | #ifndef INCLUDED_UNOTOOLS_SHAREDUNOCOMPONENT_HXX |
21 | #define INCLUDED_UNOTOOLS_SHAREDUNOCOMPONENT_HXX |
22 | |
23 | #include <unotools/unotoolsdllapi.h> |
24 | #include <com/sun/star/uno/Reference.hxx> |
25 | #include <rtl/ref.hxx> |
26 | #include <memory> |
27 | |
28 | namespace com::sun::star { |
29 | namespace lang { |
30 | class XComponent; |
31 | } |
32 | } |
33 | |
34 | namespace utl |
35 | { |
36 | |
37 | //= DisposableComponent |
38 | |
39 | /** is a class which controls lifetime of a UNO component via ->XComponent::dispose |
40 | |
41 | You'll usually never use this class directly, but only as parameter for a |
42 | ->SharedUNOComponent class. |
43 | */ |
44 | class UNOTOOLS_DLLPUBLIC__attribute__ ((visibility("default"))) DisposableComponent |
45 | { |
46 | css::uno::Reference< css::lang::XComponent > m_xComponent; |
47 | |
48 | public: |
49 | /** constructs a ->DisposableComponent instance |
50 | |
51 | @param _rxComponent |
52 | the component whose life time should be controlled by the instance. Must not be <NULL/>. |
53 | */ |
54 | DisposableComponent( const css::uno::Reference< css::uno::XInterface >& _rxComponent ); |
55 | |
56 | /** disposes the component represented by the instance |
57 | |
58 | The component is queried for ->XComponent(which <em>must</em> be supported), |
59 | and ->XComponent::dispose is invoked. A failure of this invocation (e.g. a thrown |
60 | exception) is silenced in release builds, and reported in debug builds. |
61 | */ |
62 | ~DisposableComponent(); |
63 | |
64 | private: |
65 | DisposableComponent( const DisposableComponent& ) = delete; |
66 | DisposableComponent& operator=( const DisposableComponent& ) = delete; |
67 | }; |
68 | |
69 | //= CloseableComponent |
70 | |
71 | class CloseableComponentImpl; |
72 | /** is a class which controls lifetime of a UNO component via ->XCloseable::close |
73 | |
74 | You'll usually never use this class directly, but only as parameter for a |
75 | ->SharedUNOComponent class. |
76 | */ |
77 | class UNOTOOLS_DLLPUBLIC__attribute__ ((visibility("default"))) CloseableComponent |
78 | { |
79 | private: |
80 | /** Our IMPL class. |
81 | */ |
82 | ::rtl::Reference< CloseableComponentImpl > m_pImpl; |
83 | |
84 | public: |
85 | /** constructs a ->CloseableComponent instance |
86 | |
87 | @param _rxComponent |
88 | the component whose life time should be controlled by the instance. Must not be <NULL/>. |
89 | */ |
90 | CloseableComponent( const css::uno::Reference< css::uno::XInterface >& _rxComponent ); |
91 | |
92 | /** destroys resources associated with this instance, and disposes the component |
93 | |
94 | The component is queried for ->XCloseable (which <em>must</em> be supported), |
95 | and ->XCloseable::close is invoked, with delivering the ownership. |
96 | If the invocation fails with a ->CloseVetoException, this is ignored, since in |
97 | this case the vetoing instance took the ownership. |
98 | |
99 | Any other failure will be reported in a debug version via assertion mechanisms, |
100 | and silenced in release builds. |
101 | */ |
102 | ~CloseableComponent(); |
103 | |
104 | private: |
105 | CloseableComponent( const CloseableComponent& ) = delete; |
106 | CloseableComponent& operator=( const CloseableComponent& ) = delete; |
107 | }; |
108 | |
109 | //= SharedUNOComponent |
110 | |
111 | /** is a helper class for sharing ownership of a UNO component |
112 | |
113 | If you need to share a UNO component, which normally needs a dedicated owner, |
114 | and is lifetime controlled by an explicit disposal action (not necessarily ->XComponent::dispose, |
115 | but <em>any</em> explicit method call, after which the object is considered |
116 | to be disposed), between different classes, ->SharedUNOComponent is what you need. |
117 | |
118 | Instead of passing around a <code>Reference< XFoo ></code>, and bothering |
119 | with ownership and disposal, you just use a <code>SharedUNOComponent< XFoo ></code>. |
120 | This instance can be passed around, including copying, and in nearly all respects behaves |
121 | like the original <code>Reference< XFoo ></code>. However, when the last |
122 | ->SharedUNOComponent referencing a certain <code>Reference< XFoo ></code> dies, it |
123 | will automatically get rid of the object held by this reference. |
124 | |
125 | @param INTERFACE |
126 | the UNO interface type as which the component should be held |
127 | |
128 | @param COMPONENT_HOLDER |
129 | a class which can be used to represent and dispose a UNO component. |
130 | The class must support (maybe explicit only) construction from a |
131 | <code>Reference< INTERFACE ></code>, and destruction. Upon destruction, |
132 | the class must dispose (by any suitable means) the component instance it was |
133 | constructed with. |
134 | */ |
135 | template < class INTERFACE, class COMPONENT = DisposableComponent > |
136 | class SharedUNOComponent |
137 | { |
138 | private: |
139 | typedef COMPONENT Component; |
140 | |
141 | private: |
142 | std::shared_ptr<Component> m_xComponent; |
143 | css::uno::Reference< INTERFACE > m_xTypedComponent; |
144 | |
145 | public: |
146 | enum AssignmentMode |
147 | { |
148 | TakeOwnership, |
149 | NoTakeOwnership |
150 | }; |
151 | |
152 | public: |
153 | SharedUNOComponent() |
154 | { |
155 | } |
156 | |
157 | explicit SharedUNOComponent( const css::uno::Reference< INTERFACE >& _rxComponent, AssignmentMode eMode = TakeOwnership ) |
158 | { |
159 | reset( _rxComponent, eMode ); |
160 | } |
161 | |
162 | SharedUNOComponent( const css::uno::BaseReference & _rRef, css::uno::UnoReference_QueryThrow _queryThrow ) |
163 | { |
164 | set( _rRef, _queryThrow ); |
165 | } |
166 | |
167 | // SharedUNOComponent& operator=( const css::uno::Reference< INTERFACE >& _rxComponent ); |
168 | // This operator is intentionally not implemented. There is no canonic ownership after this operator |
169 | // would have been applied: Should the SharedUNOComponent have the ownership of the component, |
170 | // or shouldn't it? Hard to guess, and probably wrong in 50 percent of all cases, anyway. So, |
171 | // instead of tempting clients of this class to use such a dangerous operator, we do |
172 | // not offer it at all. If you need to assign a Reference< INTERFACE > to your SharedUNOComponent, |
173 | // use the ->reset method. |
174 | |
175 | /** assigns a new component, and releases the old one |
176 | */ |
177 | void reset( const css::uno::Reference< INTERFACE >& _rxComponent, AssignmentMode _eMode = TakeOwnership ); |
178 | |
179 | inline bool set( const css::uno::BaseReference& _rRef, css::uno::UnoReference_Query _query ); |
180 | |
181 | inline void set( const css::uno::BaseReference & _rRef, css::uno::UnoReference_QueryThrow _queryThrow ); |
182 | |
183 | inline void set( const css::uno::Reference< INTERFACE >& _rRef, css::uno::UnoReference_SetThrow _setThrow ); |
184 | inline void set( const SharedUNOComponent& _rComp, css::uno::UnoReference_SetThrow _setThrow ); |
185 | |
186 | INTERFACE* SAL_CALL operator->() const; |
187 | |
188 | operator const css::uno::Reference< INTERFACE >&() const |
189 | { |
190 | return m_xTypedComponent; |
191 | } |
192 | |
193 | const css::uno::Reference< INTERFACE >& getTyped() const |
194 | { |
195 | return m_xTypedComponent; |
196 | } |
197 | |
198 | bool is() const |
199 | { |
200 | return m_xTypedComponent.is(); |
201 | } |
202 | |
203 | void clear() |
204 | { |
205 | m_xComponent.reset(); |
206 | m_xTypedComponent.clear(); |
207 | } |
208 | }; |
209 | |
210 | template < class INTERFACE, class COMPONENT > |
211 | INTERFACE* SAL_CALL SharedUNOComponent< INTERFACE, COMPONENT >::operator->() const |
212 | { |
213 | return m_xTypedComponent.operator->(); |
214 | } |
215 | |
216 | // assignments |
217 | template < class INTERFACE, class COMPONENT > |
218 | void SharedUNOComponent< INTERFACE, COMPONENT >::reset( const css::uno::Reference< INTERFACE >& _rxComponent, AssignmentMode _eMode ) |
219 | { |
220 | m_xComponent.reset(_eMode == TakeOwnership ? new COMPONENT( _rxComponent ) : nullptr); |
221 | m_xTypedComponent = _rxComponent; |
222 | } |
223 | |
224 | // comparison operators |
225 | |
226 | template < class INTERFACE, class COMPONENT > |
227 | bool operator==( const SharedUNOComponent< INTERFACE, COMPONENT >& _rLHS, const css::uno::Reference< INTERFACE >& _rRHS ) |
228 | { |
229 | return _rLHS.getTyped() == _rRHS; |
230 | } |
231 | |
232 | template < class INTERFACE, class COMPONENT > |
233 | inline css::uno::Any SAL_CALL makeAny( const SharedUNOComponent< INTERFACE, COMPONENT >& value ) |
234 | { |
235 | return makeAny( value.getTyped() ); |
236 | } |
237 | |
238 | template < class INTERFACE, class COMPONENT > |
239 | void SharedUNOComponent< INTERFACE, COMPONENT >::set( const css::uno::BaseReference & _rRef, css::uno::UnoReference_QueryThrow _queryThrow ) |
240 | { |
241 | reset( css::uno::Reference< INTERFACE >( _rRef, _queryThrow ), TakeOwnership ); |
242 | } |
243 | |
244 | template < class INTERFACE, class COMPONENT > |
245 | void SharedUNOComponent< INTERFACE, COMPONENT >::set( const css::uno::Reference< INTERFACE >& _rRef, css::uno::UnoReference_SetThrow _setThrow ) |
246 | { |
247 | reset( css::uno::Reference< INTERFACE >( _rRef, _setThrow ), TakeOwnership ); |
248 | } |
249 | |
250 | template < class INTERFACE, class COMPONENT > |
251 | void SharedUNOComponent< INTERFACE, COMPONENT >::set( const SharedUNOComponent& _rComp, css::uno::UnoReference_SetThrow _setThrow ) |
252 | { |
253 | *this = _rComp; |
254 | // provoke an exception in case the component is NULL |
255 | m_xTypedComponent.set( m_xTypedComponent, _setThrow ); |
256 | } |
257 | |
258 | template < class INTERFACE, class COMPONENT > |
259 | bool SharedUNOComponent< INTERFACE, COMPONENT >::set( const css::uno::BaseReference& _rRef, css::uno::UnoReference_Query _query ) |
260 | { |
261 | reset( css::uno::Reference< INTERFACE >( _rRef, _query ) ); |
262 | return is(); |
263 | } |
264 | |
265 | } // namespace utl |
266 | |
267 | #endif // INCLUDED_UNOTOOLS_SHAREDUNOCOMPONENT_HXX |
268 | |
269 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
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/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
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 . |
18 | */ |
19 | #ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H |
20 | #define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H |
21 | |
22 | #include "sal/config.h" |
23 | |
24 | #include <cassert> |
25 | #include <cstddef> |
26 | |
27 | #if defined LIBO_INTERNAL_ONLY1 |
28 | #include <type_traits> |
29 | #endif |
30 | |
31 | #include "rtl/alloc.h" |
32 | |
33 | namespace com |
34 | { |
35 | namespace sun |
36 | { |
37 | namespace star |
38 | { |
39 | namespace uno |
40 | { |
41 | |
42 | class RuntimeException; |
43 | class XInterface; |
44 | class Type; |
45 | class Any; |
46 | |
47 | /** Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface. |
48 | Deprecated, please use SAL_NO_ACQUIRE. |
49 | @deprecated |
50 | */ |
51 | enum UnoReference_NoAcquire |
52 | { |
53 | /** This enum value can be used for creating a reference granting a given interface, |
54 | i.e. transferring ownership to it. |
55 | */ |
56 | UNO_REF_NO_ACQUIRE |
57 | }; |
58 | |
59 | /** This base class serves as a base class for all template reference classes and |
60 | has been introduced due to compiler problems with templated operators ==, =!. |
61 | */ |
62 | class BaseReference |
63 | { |
64 | protected: |
65 | /** the interface pointer |
66 | */ |
67 | XInterface * _pInterface; |
68 | |
69 | /** Queries given interface for type rType. |
70 | |
71 | @param pInterface interface pointer |
72 | @param rType interface type |
73 | @return interface of demanded type (may be null) |
74 | */ |
75 | inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType ); |
76 | /** Queries given interface for type rType. |
77 | Throws a RuntimeException if the demanded interface cannot be queried. |
78 | |
79 | @param pInterface interface pointer |
80 | @param rType interface type |
81 | @return interface of demanded type |
82 | */ |
83 | inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType ); |
84 | |
85 | public: |
86 | /** Gets interface pointer. This call does not acquire the interface. |
87 | |
88 | @return UNacquired interface pointer |
89 | */ |
90 | XInterface * SAL_CALL get() const |
91 | { return _pInterface; } |
92 | |
93 | /** Checks if reference is null. |
94 | |
95 | @return true if reference acquires an interface, i.e. true if it is not null |
96 | */ |
97 | bool SAL_CALL is() const |
98 | { return (NULL__null != _pInterface); } |
99 | |
100 | #if defined LIBO_INTERNAL_ONLY1 |
101 | /** Checks if reference is null. |
102 | |
103 | @return true if reference acquires an interface, i.e. true if it is not null |
104 | */ |
105 | explicit operator bool() const |
106 | { return is(); } |
107 | #endif |
108 | |
109 | /** Equality operator: compares two interfaces |
110 | Checks if both references are null or refer to the same object. |
111 | |
112 | @param pInterface another interface |
113 | @return true if both references are null or refer to the same object, false otherwise |
114 | */ |
115 | inline bool SAL_CALL operator == ( XInterface * pInterface ) const; |
116 | /** Inequality operator: compares two interfaces |
117 | Checks if both references are null or refer to the same object. |
118 | |
119 | @param pInterface another interface |
120 | @return false if both references are null or refer to the same object, true otherwise |
121 | */ |
122 | inline bool SAL_CALL operator != ( XInterface * pInterface ) const; |
123 | |
124 | /** Equality operator: compares two interfaces |
125 | Checks if both references are null or refer to the same object. |
126 | |
127 | @param rRef another reference |
128 | @return true if both references are null or refer to the same object, false otherwise |
129 | */ |
130 | inline bool SAL_CALL operator == ( const BaseReference & rRef ) const; |
131 | /** Inequality operator: compares two interfaces |
132 | Checks if both references are null or refer to the same object. |
133 | |
134 | @param rRef another reference |
135 | @return false if both references are null or refer to the same object, true otherwise |
136 | */ |
137 | inline bool SAL_CALL operator != ( const BaseReference & rRef ) const; |
138 | |
139 | /** Needed by some STL containers. |
140 | |
141 | @param rRef another reference |
142 | @return true, if this reference is less than rRef |
143 | */ |
144 | inline bool SAL_CALL operator < ( const BaseReference & rRef ) const; |
145 | }; |
146 | |
147 | /** Enum defining UNO_QUERY for implicit interface query. |
148 | */ |
149 | enum UnoReference_Query |
150 | { |
151 | /** This enum value can be used for implicit interface query. |
152 | */ |
153 | UNO_QUERY |
154 | }; |
155 | /** Enum defining UNO_QUERY_THROW for implicit interface query. |
156 | If the demanded interface is unavailable, then a RuntimeException is thrown. |
157 | */ |
158 | enum UnoReference_QueryThrow |
159 | { |
160 | /** This enum value can be used for implicit interface query. |
161 | */ |
162 | UNO_QUERY_THROW |
163 | }; |
164 | /** Enum defining UNO_SET_THROW for throwing if attempts are made to assign a null |
165 | interface |
166 | |
167 | @since UDK 3.2.8 |
168 | */ |
169 | enum UnoReference_SetThrow |
170 | { |
171 | UNO_SET_THROW |
172 | }; |
173 | |
174 | /** Template reference class for interface type derived from BaseReference. |
175 | A special constructor given the UNO_QUERY identifier queries interfaces |
176 | for reference type. |
177 | */ |
178 | template< class interface_type > |
179 | class SAL_DLLPUBLIC_RTTI__attribute__ ((type_visibility("default"))) Reference : public BaseReference |
180 | { |
181 | /** Queries given interface for type interface_type. |
182 | |
183 | @param pInterface interface pointer |
184 | @return interface of demanded type (may be null) |
185 | */ |
186 | inline static XInterface * SAL_CALL iquery( XInterface * pInterface ); |
187 | /** Queries given interface for type interface_type. |
188 | Throws a RuntimeException if the demanded interface cannot be queried. |
189 | |
190 | @param pInterface interface pointer |
191 | @return interface of demanded type |
192 | */ |
193 | inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface ); |
194 | /** Returns the given interface if it is not <NULL/>, throws a RuntimeException otherwise. |
195 | |
196 | @param pInterface interface pointer |
197 | @return pInterface |
198 | */ |
199 | inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface ); |
200 | |
201 | /** Cast from an "interface pointer" (e.g., BaseReference::_pInterface) to a |
202 | pointer to this interface_type. |
203 | |
204 | To work around ambiguities in the case of multiple-inheritance interface |
205 | types (which inherit XInterface more than once), use reinterpret_cast |
206 | (resp. a sequence of two static_casts, to avoid warnings about |
207 | reinterpret_cast used between related classes) to switch from a pointer |
208 | to XInterface to a pointer to this derived interface_type. In |
209 | principle, this is not guaranteed to work. In practice, it seems to |
210 | work on all supported platforms. |
211 | */ |
212 | static interface_type * castFromXInterface(XInterface * p) { |
213 | return static_cast< interface_type * >(static_cast< void * >(p)); |
214 | } |
215 | |
216 | /** Cast from a pointer to this interface_type to an "interface pointer" |
217 | (e.g., BaseReference::_pInterface). |
218 | |
219 | To work around ambiguities in the case of multiple-inheritance interface |
220 | types (which inherit XInterface more than once), use reinterpret_cast |
221 | (resp. a sequence of two static_casts, to avoid warnings about |
222 | reinterpret_cast used between related classes) to switch from a pointer |
223 | to this derived interface_type to a pointer to XInterface. In |
224 | principle, this is not guaranteed to work. In practice, it seems to |
225 | work on all supported platforms. |
226 | */ |
227 | static XInterface * castToXInterface(interface_type * p) { |
228 | return static_cast< XInterface * >(static_cast< void * >(p)); |
229 | } |
230 | |
231 | public: |
232 | /// @cond INTERNAL |
233 | // these are here to force memory de/allocation to sal lib. |
234 | static void * SAL_CALL operator new ( ::size_t nSize ) |
235 | { return ::rtl_allocateMemory( nSize ); } |
236 | static void SAL_CALL operator delete ( void * pMem ) |
237 | { ::rtl_freeMemory( pMem ); } |
238 | static void * SAL_CALL operator new ( ::size_t, void * pMem ) |
239 | { return pMem; } |
240 | static void SAL_CALL operator delete ( void *, void * ) |
241 | {} |
242 | /// @endcond |
243 | |
244 | /** Destructor: Releases interface if set. |
245 | */ |
246 | inline ~Reference() COVERITY_NOEXCEPT_FALSE; |
247 | |
248 | /** Default Constructor: Sets null reference. |
249 | */ |
250 | inline Reference(); |
251 | |
252 | /** Copy constructor: Copies interface reference. |
253 | |
254 | @param rRef another reference |
255 | */ |
256 | inline Reference( const Reference< interface_type > & rRef ); |
257 | |
258 | #if defined LIBO_INTERNAL_ONLY1 |
259 | /** Move constructor |
260 | |
261 | @param rRef another reference |
262 | */ |
263 | inline Reference( Reference< interface_type > && rRef ) noexcept; |
264 | |
265 | /** Up-casting conversion constructor: Copies interface reference. |
266 | |
267 | Does not work for up-casts to ambiguous bases. For the special case of |
268 | up-casting to Reference< XInterface >, see the corresponding conversion |
269 | operator. |
270 | |
271 | @param rRef another reference |
272 | */ |
273 | template< class derived_type > |
274 | inline Reference( |
275 | const Reference< derived_type > & rRef, |
276 | std::enable_if_t< |
277 | std::is_base_of_v<interface_type, derived_type> |
278 | && !std::is_same_v<interface_type, XInterface>, void *> = nullptr); |
279 | #endif |
280 | |
281 | /** Constructor: Sets given interface pointer. |
282 | |
283 | @param pInterface an interface pointer |
284 | */ |
285 | inline Reference( interface_type * pInterface ); |
286 | |
287 | /** Constructor: Sets given interface pointer without acquiring it. |
288 | |
289 | @param pInterface another reference |
290 | @param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors |
291 | */ |
292 | inline Reference( interface_type * pInterface, __sal_NoAcquire dummy); |
293 | /** Constructor: Sets given interface pointer without acquiring it. |
294 | Deprecated, please use SAL_NO_ACQUIRE version. |
295 | |
296 | @deprecated |
297 | @param pInterface another reference |
298 | @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors |
299 | */ |
300 | inline SAL_DEPRECATED("use SAL_NO_ACQUIRE version")__attribute__((deprecated("use SAL_NO_ACQUIRE version"))) Reference( interface_type * pInterface, UnoReference_NoAcquire dummy ); |
301 | |
302 | /** Constructor: Queries given interface for reference interface type (interface_type). |
303 | |
304 | @param rRef another reference |
305 | @param dummy UNO_QUERY to force obvious distinction to other constructors |
306 | */ |
307 | inline Reference( const BaseReference & rRef, UnoReference_Query dummy ); |
308 | /** Constructor: Queries given interface for reference interface type (interface_type). |
309 | |
310 | @param pInterface an interface pointer |
311 | @param dummy UNO_QUERY to force obvious distinction to other constructors |
312 | */ |
313 | inline Reference( XInterface * pInterface, UnoReference_Query dummy); |
314 | /** Constructor: Queries given any for reference interface type (interface_type). |
315 | |
316 | @param rAny an any |
317 | @param dummy UNO_QUERY to force obvious distinction to other constructors |
318 | */ |
319 | inline Reference( const Any & rAny, UnoReference_Query dummy); |
320 | /** Constructor: Queries given interface for reference interface type (interface_type). |
321 | Throws a RuntimeException if the demanded interface cannot be queried. |
322 | |
323 | @param rRef another reference |
324 | @param dummy UNO_QUERY_THROW to force obvious distinction |
325 | to other constructors |
326 | */ |
327 | inline Reference( const BaseReference & rRef, UnoReference_QueryThrow dummy ); |
328 | #ifdef LIBO_INTERNAL_ONLY1 |
329 | /** |
330 | Prevent code from calling the QUERY_THROW constructor, when they meant to use the SET_THROW constructor. |
331 | */ |
332 | Reference( const Reference< interface_type > & rRef, UnoReference_QueryThrow dummy ) = delete; |
333 | #endif |
334 | /** Constructor: Queries given interface for reference interface type (interface_type). |
335 | Throws a RuntimeException if the demanded interface cannot be queried. |
336 | |
337 | @param pInterface an interface pointer |
338 | @param dummy UNO_QUERY_THROW to force obvious distinction |
339 | to other constructors |
340 | */ |
341 | inline Reference( XInterface * pInterface, UnoReference_QueryThrow dummy ); |
342 | /** Constructor: Queries given any for reference interface type (interface_type). |
343 | Throws a RuntimeException if the demanded interface cannot be queried. |
344 | |
345 | @param rAny an any |
346 | @param dummy UNO_QUERY_THROW to force obvious distinction |
347 | to other constructors |
348 | */ |
349 | inline Reference( const Any & rAny, UnoReference_QueryThrow dummy ); |
350 | /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException |
351 | if the source interface is NULL. |
352 | |
353 | @param rRef another interface reference of the same type |
354 | @param dummy UNO_SET_THROW to distinguish from default copy constructor |
355 | |
356 | @since UDK 3.2.8 |
357 | */ |
358 | inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy ); |
359 | /** Constructor: assigns from the given interface of the same type. Throws a RuntimeException |
360 | if the source interface is NULL. |
361 | |
362 | @param pInterface an interface pointer |
363 | @param dummy UNO_SET_THROW to distinguish from default assignment constructor |
364 | |
365 | @since UDK 3.2.8 |
366 | */ |
367 | inline Reference( interface_type * pInterface, UnoReference_SetThrow dummy ); |
368 | |
369 | /** Cast operator to Reference< XInterface >: Reference objects are binary compatible and |
370 | any interface must be derived from com.sun.star.uno.XInterface. |
371 | This a useful direct cast possibility. |
372 | */ |
373 | SAL_CALL operator const Reference< XInterface > & () const |
374 | { return * reinterpret_cast< const Reference< XInterface > * >( this ); } |
375 | |
376 | /** Dereference operator: Used to call interface methods. |
377 | |
378 | @return UNacquired interface pointer |
379 | */ |
380 | interface_type * SAL_CALL operator -> () const { |
381 | assert(_pInterface != NULL)(static_cast <bool> (_pInterface != __null) ? void (0) : __assert_fail ("_pInterface != NULL", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Reference.h" , 381, __extension__ __PRETTY_FUNCTION__)); |
382 | return castFromXInterface(_pInterface); |
383 | } |
384 | |
385 | /** Indirection operator. |
386 | |
387 | @since LibreOffice 6.3 |
388 | @return UNacquired interface reference |
389 | */ |
390 | interface_type & SAL_CALL operator * () const { |
391 | assert(_pInterface != NULL)(static_cast <bool> (_pInterface != __null) ? void (0) : __assert_fail ("_pInterface != NULL", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Reference.h" , 391, __extension__ __PRETTY_FUNCTION__)); |
392 | return *castFromXInterface(_pInterface); |
393 | } |
394 | |
395 | /** Gets interface pointer. This call does not acquire the interface. |
396 | |
397 | @return UNacquired interface pointer |
398 | */ |
399 | interface_type * SAL_CALL get() const |
400 | { return castFromXInterface(_pInterface); } |
401 | |
402 | /** Clears reference, i.e. releases interface. Reference is null after clear() call. |
403 | */ |
404 | inline void SAL_CALL clear(); |
405 | |
406 | /** Sets the given interface. An interface already set will be released. |
407 | |
408 | @param rRef another reference |
409 | @return true, if non-null interface was set |
410 | */ |
411 | inline bool SAL_CALL set( const Reference< interface_type > & rRef ); |
412 | /** Sets the given interface. An interface already set will be released. |
413 | |
414 | @param pInterface another interface |
415 | @return true, if non-null interface was set |
416 | */ |
417 | inline bool SAL_CALL set( interface_type * pInterface ); |
418 | |
419 | /** Sets interface pointer without acquiring it. An interface already set will be released. |
420 | |
421 | @param pInterface an interface pointer |
422 | @param dummy SAL_NO_ACQUIRE to force obvious distinction to set methods |
423 | @return true, if non-null interface was set |
424 | */ |
425 | inline bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire dummy); |
426 | /** Sets interface pointer without acquiring it. An interface already set will be released. |
427 | Deprecated, please use SAL_NO_ACQUIRE version. |
428 | |
429 | @deprecated |
430 | @param pInterface an interface pointer |
431 | @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to set methods |
432 | @return true, if non-null interface was set |
433 | */ |
434 | inline SAL_DEPRECATED("use SAL_NO_ACQUIRE version")__attribute__((deprecated("use SAL_NO_ACQUIRE version"))) bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire dummy); |
435 | |
436 | /** Queries given interface for reference interface type (interface_type) and sets it. |
437 | An interface already set will be released. |
438 | |
439 | @param pInterface an interface pointer |
440 | @param dummy UNO_QUERY to force obvious distinction to set methods |
441 | @return true, if non-null interface was set |
442 | */ |
443 | inline bool SAL_CALL set( XInterface * pInterface, UnoReference_Query dummy ); |
444 | /** Queries given interface for reference interface type (interface_type) and sets it. |
445 | An interface already set will be released. |
446 | |
447 | @param rRef another reference |
448 | @param dummy UNO_QUERY to force obvious distinction to set methods |
449 | @return true, if non-null interface was set |
450 | */ |
451 | inline bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query dummy); |
452 | |
453 | /** Queries given any for reference interface type (interface_type) |
454 | and sets it. An interface already set will be released. |
455 | |
456 | @param rAny |
457 | an Any containing an interface |
458 | @param dummy |
459 | UNO_QUERY to force obvious distinction |
460 | to set methods |
461 | @return |
462 | true, if non-null interface was set |
463 | */ |
464 | inline bool set( Any const & rAny, UnoReference_Query dummy ); |
465 | |
466 | /** Queries given interface for reference interface type (interface_type) and sets it. |
467 | An interface already set will be released. |
468 | Throws a RuntimeException if the demanded interface cannot be set. |
469 | |
470 | @param pInterface an interface pointer |
471 | @param dummy UNO_QUERY_THROW to force obvious distinction |
472 | to set methods |
473 | */ |
474 | inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow dummy ); |
475 | /** Queries given interface for reference interface type (interface_type) and sets it. |
476 | An interface already set will be released. |
477 | Throws a RuntimeException if the demanded interface cannot be set. |
478 | |
479 | @param rRef another reference |
480 | @param dummy UNO_QUERY_THROW to force obvious distinction |
481 | to set methods |
482 | */ |
483 | inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow dummy ); |
484 | #ifdef LIBO_INTERNAL_ONLY1 |
485 | /** |
486 | Prevent code from calling the QUERY_THROW version, when they meant to use the SET_THROW version. |
487 | */ |
488 | void set( const Reference< interface_type > & rRef, UnoReference_QueryThrow dummy ) = delete; |
489 | #endif |
490 | |
491 | /** Queries given any for reference interface type (interface_type) and |
492 | sets it. An interface already set will be released. |
493 | Throws a RuntimeException if the demanded interface cannot be set. |
494 | |
495 | @param rAny |
496 | an Any containing an interface |
497 | @param dummy |
498 | UNO_QUERY_THROW to force obvious distinction to set methods |
499 | */ |
500 | inline void set( Any const & rAny, UnoReference_QueryThrow dummy); |
501 | /** sets the given interface |
502 | An interface already set will be released. |
503 | Throws a RuntimeException if the source interface is @b NULL. |
504 | |
505 | @param pInterface an interface pointer |
506 | @param dummy UNO_SET_THROW to force obvious distinction to other set methods |
507 | |
508 | @since UDK 3.2.8 |
509 | */ |
510 | inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow dummy); |
511 | /** sets the given interface |
512 | An interface already set will be released. |
513 | Throws a RuntimeException if the source interface is @b NULL. |
514 | |
515 | @param rRef an interface reference |
516 | @param dummy UNO_SET_THROW to force obvious distinction to other set methods |
517 | |
518 | @since UDK 3.2.8 |
519 | */ |
520 | inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy); |
521 | |
522 | |
523 | /** Assignment operator: Acquires given interface pointer and sets reference. |
524 | An interface already set will be released. |
525 | |
526 | @param pInterface an interface pointer |
527 | @return this reference |
528 | */ |
529 | inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ); |
530 | /** Assignment operator: Acquires given interface reference and sets reference. |
531 | An interface already set will be released. |
532 | |
533 | @param rRef an interface reference |
534 | @return this reference |
535 | */ |
536 | inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ); |
537 | #if defined LIBO_INTERNAL_ONLY1 |
538 | /** Assignment move operator: Acquires given interface reference and sets reference. |
539 | An interface already set will be released. |
540 | |
541 | @param rRef an interface reference |
542 | @return this reference |
543 | */ |
544 | inline Reference< interface_type > & SAL_CALL operator = ( Reference< interface_type > && rRef ) noexcept; |
545 | #endif |
546 | /** Queries given interface reference for type interface_type. |
547 | |
548 | @param rRef interface reference |
549 | @return interface reference of demanded type (may be null) |
550 | */ |
551 | SAL_WARN_UNUSED_RESULT[[nodiscard]] inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ); |
552 | /** Queries given interface for type interface_type. |
553 | |
554 | @param pInterface interface pointer |
555 | @return interface reference of demanded type (may be null) |
556 | */ |
557 | SAL_WARN_UNUSED_RESULT[[nodiscard]] inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ); |
558 | }; |
559 | |
560 | } |
561 | } |
562 | } |
563 | } |
564 | |
565 | #endif |
566 | |
567 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |