LibreOffice Module connectivity (master) 1
VCollection.hxx
Go to the documentation of this file.
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_CONNECTIVITY_SDBCX_VCOLLECTION_HXX
21#define INCLUDED_CONNECTIVITY_SDBCX_VCOLLECTION_HXX
22
23#include <config_options.h>
25#include <com/sun/star/container/XNameAccess.hpp>
26#include <com/sun/star/container/XIndexAccess.hpp>
27#include <com/sun/star/container/XEnumerationAccess.hpp>
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/util/XRefreshable.hpp>
30#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
31#include <com/sun/star/sdbcx/XAppend.hpp>
32#include <com/sun/star/sdbcx/XDrop.hpp>
33#include <com/sun/star/sdbc/XColumnLocate.hpp>
35#include <com/sun/star/lang/XServiceInfo.hpp>
37#include <com/sun/star/container/XContainer.hpp>
39#include <memory>
40
41namespace com::sun::star::container { class XEnumeration; }
42
43
44namespace connectivity::sdbcx
45 {
46
47 // the class OCollection is base class for collections :-)
48 typedef ::cppu::ImplHelper10< css::container::XNameAccess,
49 css::container::XIndexAccess,
50 css::container::XEnumerationAccess,
51 css::container::XContainer,
52 css::sdbc::XColumnLocate,
53 css::util::XRefreshable,
54 css::sdbcx::XDataDescriptorFactory,
55 css::sdbcx::XAppend,
56 css::sdbcx::XDrop,
57 css::lang::XServiceInfo> OCollectionBase;
58
59 typedef css::uno::Reference< css::beans::XPropertySet > ObjectType;
60
62 {
63 public:
64 virtual ~IObjectCollection();
65 virtual bool exists(const OUString& _sName ) = 0;
66 virtual bool empty() = 0;
67 virtual void swapAll() = 0;
68 virtual void swap() = 0;
69 virtual void clear() = 0;
70 virtual void reFill(const ::std::vector< OUString> &_rVector) = 0;
71 virtual void insert(const OUString& _sName, const ObjectType& _xObject) = 0;
72 virtual bool rename(const OUString& _sOldName, const OUString& _sNewName) = 0;
73 virtual sal_Int32 size() = 0;
74 virtual css::uno::Sequence< OUString > getElementNames() = 0;
75 virtual OUString getName(sal_Int32 _nIndex) = 0;
76 virtual void disposeAndErase(sal_Int32 _nIndex) = 0;
77 virtual void disposeElements() = 0;
78 virtual sal_Int32 findColumn( const OUString& columnName ) = 0;
79 virtual ObjectType getObject(sal_Int32 _nIndex) = 0;
80 virtual ObjectType getObject(const OUString& columnName) = 0;
81 virtual void setObject(sal_Int32 _nIndex,const ObjectType& _xObject) = 0;
82 virtual bool isCaseSensitive() const = 0;
83 };
84
85 // OCollection
86
88 public OCollectionBase
89 {
90 protected:
91 ::std::unique_ptr<IObjectCollection> m_pElements;
92
95
96 protected:
97 ::cppu::OWeakObject& m_rParent; // parent of the collection
98 ::osl::Mutex& m_rMutex; // mutex of the parent
99 bool m_bUseIndexOnly; // is only TRUE when only an indexaccess is needed
100
101 // the implementing class should refresh their elements
103 virtual void impl_refresh() = 0;
104
105 // will be called when an object was requested by one of the accessing methods like getByIndex
106 virtual ObjectType createObject(const OUString& _rName) = 0;
107
108 // will be called when a new object should be generated by a call of createDataDescriptor
109 // the returned object is empty will be filled outside and added to the collection
110 virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor();
111
123 virtual ObjectType appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor );
124
125 // called when XDrop was called
126 virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName);
127
132 virtual OUString getNameForObject(const ObjectType& _xObject);
133
143 ObjectType cloneDescriptor( const ObjectType& _descriptor );
144
146 bool _bCase,
147 ::osl::Mutex& _rMutex,
148 const ::std::vector< OUString> &_rVector,
149 bool _bUseIndexOnly = false,
150 bool _bUseHardRef = true);
151
155 void clear_NoDispose();
156
159 void insertElement(const OUString& _sElementName,const ObjectType& _xElement);
160
166 ObjectType getObject(sal_Int32 _nIndex);
167
168 public:
169 virtual ~OCollection();
171
172 void reFill(const ::std::vector< OUString> &_rVector);
173 bool isCaseSensitive() const { return m_pElements->isCaseSensitive(); }
174 void renameObject(const OUString& _sOldName, const OUString& _sNewName);
175
176 // only the name is identical to ::cppu::OComponentHelper
177 virtual void disposing();
178 // dispatch the refcounting to the parent
179 virtual void SAL_CALL acquire() noexcept override;
180 virtual void SAL_CALL release() noexcept override;
181
182 // XInterface
183 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
184 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
185
186 // css::container::XElementAccess
187 virtual css::uno::Type SAL_CALL getElementType( ) override;
188 virtual sal_Bool SAL_CALL hasElements( ) override;
189 // css::container::XIndexAccess
190 virtual sal_Int32 SAL_CALL getCount( ) override;
191 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
192
193 // css::container::XNameAccess
194 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
195 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
196 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
197 // XEnumerationAccess
198 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override;
199 // css::util::XRefreshable
200 virtual void SAL_CALL refresh( ) override;
201 virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override;
202 virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override;
203 // XDataDescriptorFactory
204 virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor( ) override;
205 // XAppend
206 virtual void SAL_CALL appendByDescriptor( const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override;
207 // XDrop
208 virtual void SAL_CALL dropByName( const OUString& elementName ) override;
209 virtual void SAL_CALL dropByIndex( sal_Int32 index ) override;
210 // XColumnLocate
211 virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) override;
212 // css::container::XContainer
213 virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
214 virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
215 private:
216 void notifyElementRemoved(const OUString& _sName);
217 void disposeElements();
218 void dropImpl(sal_Int32 _nIndex, bool _bReallyDrop = true);
219 };
220
221}
222#endif // INCLUDED_CONNECTIVITY_SDBCX_VCOLLECTION_HXX
223
224
225/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
Definition: Awrapadox.hxx:45
virtual bool rename(const OUString &_sOldName, const OUString &_sNewName)=0
virtual void setObject(sal_Int32 _nIndex, const ObjectType &_xObject)=0
virtual ObjectType getObject(sal_Int32 _nIndex)=0
virtual OUString getName(sal_Int32 _nIndex)=0
virtual ObjectType getObject(const OUString &columnName)=0
virtual bool isCaseSensitive() const =0
virtual bool exists(const OUString &_sName)=0
virtual void insert(const OUString &_sName, const ObjectType &_xObject)=0
virtual void disposeAndErase(sal_Int32 _nIndex)=0
virtual sal_Int32 findColumn(const OUString &columnName)=0
virtual css::uno::Sequence< OUString > getElementNames()=0
virtual void reFill(const ::std::vector< OUString > &_rVector)=0
virtual ObjectType createObject(const OUString &_rName)=0
::cppu::OWeakObject & m_rParent
Definition: VCollection.hxx:97
::std::unique_ptr< IObjectCollection > m_pElements
Definition: VCollection.hxx:91
::comphelper::OInterfaceContainerHelper3< css::util::XRefreshListener > m_aRefreshListeners
Definition: VCollection.hxx:94
::comphelper::OInterfaceContainerHelper3< css::container::XContainerListener > m_aContainerListeners
Definition: VCollection.hxx:93
#define OOO_DLLPUBLIC_DBTOOLS
Type
::cppu::ImplHelper10< css::container::XNameAccess, css::container::XIndexAccess, css::container::XEnumerationAccess, css::container::XContainer, css::sdbc::XColumnLocate, css::util::XRefreshable, css::sdbcx::XDataDescriptorFactory, css::sdbcx::XAppend, css::sdbcx::XDrop, css::lang::XServiceInfo > OCollectionBase
Definition: VCollection.hxx:57
css::uno::Reference< css::beans::XPropertySet > ObjectType
Definition: VCollection.hxx:59
const char * columnName
Definition: pq_statics.cxx:56
#define SAL_NO_VTABLE
unsigned char sal_Bool