LibreOffice Module connectivity (master) 1
pq_xcontainer.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * Effective License of whole file:
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software Foundation.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
19 *
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
21 *
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
24 *
25 * Copyright: 2000 by Sun Microsystems, Inc.
26 *
27 * Contributor(s): Joerg Budischewski
28 *
29 * All parts contributed on or after August 2011:
30 *
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
34 *
35 ************************************************************************/
36
37#pragma once
38#include <com/sun/star/container/XNameAccess.hpp>
39#include <com/sun/star/container/XIndexAccess.hpp>
40#include <com/sun/star/container/XEnumerationAccess.hpp>
41#include <com/sun/star/container/XContainer.hpp>
42
43#include <com/sun/star/sdbc/XConnection.hpp>
44#include <com/sun/star/sdbcx/XAppend.hpp>
45#include <com/sun/star/sdbcx/XDrop.hpp>
46#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
47
48#include <com/sun/star/util/XRefreshable.hpp>
49
52#include <rtl/ref.hxx>
53
54#include <unordered_map>
55
56namespace pq_sdbc_driver
57{
58
59struct ConnectionSettings;
60
62{
63public:
64 virtual void fire(css::lang::XEventListener * listener) const = 0;
65 virtual css::uno::Type getType() const = 0;
67};
68
70{
71 css::lang::EventObject m_event;
72public:
73 explicit RefreshedBroadcaster(const css::uno::Reference< css::uno::XInterface > & source ) :
74 m_event( source )
75 {}
76
77 virtual void fire( css::lang::XEventListener * listener ) const override
78 {
79 static_cast<css::util::XRefreshListener*>(listener)->refreshed( m_event );
80 }
81
82 virtual css::uno::Type getType() const override
83 {
84 return cppu::UnoType<
85 css::util::XRefreshListener>::get();
86 }
87};
88
89typedef std::unordered_map
90<
91 OUString,
92 sal_Int32
94
95typedef ::cppu::WeakComponentImplHelper
96<
97 css::container::XNameAccess,
98 css::container::XIndexAccess,
99 css::container::XEnumerationAccess,
100 css::sdbcx::XAppend,
101 css::sdbcx::XDrop,
102 css::util::XRefreshable,
103 css::sdbcx::XDataDescriptorFactory,
104 css::container::XContainer
106
107class /* abstract */ Container : public ContainerBase
108{
109protected:
112 css::uno::Reference< css::sdbc::XConnection > m_origin;
113 String2IntMap m_name2index; // maps the element name to an index
114 std::vector< css::uno::Any > m_values; // contains the real values
115 OUString m_type;
116
117public:
118 Container(
119 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
120 css::uno::Reference< css::sdbc::XConnection > origin,
121 ConnectionSettings *pSettings,
122 OUString type // for exception messages
123 );
124
125public: // XIndexAccess
126 virtual sal_Int32 SAL_CALL getCount( ) override;
127 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
128
129public: // XEnumerationAccess
130 virtual css::uno::Reference< css::container::XEnumeration >
131 SAL_CALL createEnumeration( ) override;
132
133public: // XNameAccess
134 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
135 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
136 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
137 // Methods
138 virtual css::uno::Type SAL_CALL getElementType( ) override;
139 virtual sal_Bool SAL_CALL hasElements( ) override;
140
141
142public: // XAppend
143 // Must be overridden in Non-Descriptors. May be overridden in descriptors, when
144 // PropertySet.NAME != container name
145 virtual void SAL_CALL appendByDescriptor(
146 const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override;
147
148 // helper method !
150 void append(
151 const OUString & str,
152 const css::uno::Reference< css::beans::XPropertySet >& descriptor );
153
154
155public: // XDrop
156 virtual void SAL_CALL dropByName( const OUString& elementName ) override;
157 virtual void SAL_CALL dropByIndex( sal_Int32 index ) override;
158
159public: // XDataDescriptorFactory
160 virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor( ) override = 0;
161
162public: // XRefreshable
163 virtual void SAL_CALL refresh( ) override {}
164 virtual void SAL_CALL addRefreshListener(
165 const css::uno::Reference< css::util::XRefreshListener >& l ) override;
166 virtual void SAL_CALL removeRefreshListener(
167 const css::uno::Reference< css::util::XRefreshListener >& l ) override;
168
169public:
170 // Methods
171 virtual void SAL_CALL addContainerListener(
172 const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
173 virtual void SAL_CALL removeContainerListener(
174 const css::uno::Reference< css::container::XContainerListener >& xListener ) override;
175
176public:
177 virtual void SAL_CALL disposing() override;
178
179public:
180 void rename( const OUString & oldName, const OUString &newName );
181
182protected:
183 void fire( const EventBroadcastHelper & helper );
184};
185
186}
187
188/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ConnectionSettings * m_pSettings
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
void append(const OUString &str, const css::uno::Reference< css::beans::XPropertySet > &descriptor)
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Container(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, css::uno::Reference< css::sdbc::XConnection > origin, ConnectionSettings *pSettings, OUString type)
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
void fire(const EventBroadcastHelper &helper)
void rename(const OUString &oldName, const OUString &newName)
virtual sal_Bool SAL_CALL hasElements() override
virtual sal_Int32 SAL_CALL getCount() override
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor() override=0
virtual void SAL_CALL dropByName(const OUString &elementName) override
css::uno::Reference< css::sdbc::XConnection > m_origin
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
::rtl::Reference< comphelper::RefCountedMutex > m_xMutex
virtual void SAL_CALL appendByDescriptor(const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
virtual void SAL_CALL refresh() override
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
virtual void SAL_CALL dropByIndex(sal_Int32 index) override
std::vector< css::uno::Any > m_values
virtual css::uno::Type getType() const =0
virtual void fire(css::lang::XEventListener *listener) const =0
virtual void fire(css::lang::XEventListener *listener) const override
virtual css::uno::Type getType() const override
RefreshedBroadcaster(const css::uno::Reference< css::uno::XInterface > &source)
::cppu::WeakComponentImplHelper< css::container::XNameAccess, css::container::XIndexAccess, css::container::XEnumerationAccess, css::sdbcx::XAppend, css::sdbcx::XDrop, css::util::XRefreshable, css::sdbcx::XDataDescriptorFactory, css::container::XContainer > ContainerBase
std::unordered_map< OUString, sal_Int32 > String2IntMap
sal_Int32 type
Definition: pq_statics.cxx:60
unsigned char sal_Bool