LibreOffice Module dbaccess (master) 1
ComponentDefinition.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#pragma once
21
22#include <commandbase.hxx>
23#include <com/sun/star/sdbcx/XRename.hpp>
26#include <rtl/ref.hxx>
27#include <datasettings.hxx>
28#include <com/sun/star/container/XNameAccess.hpp>
29#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
30#include <com/sun/star/beans/XPropertyChangeListener.hpp>
31#include <com/sun/star/uno/XComponentContext.hpp>
32#include <ContentHelper.hxx>
33#include <apitools.hxx>
34#include <column.hxx>
35
36#include <memory>
37namespace dbaccess
38{
39
40 typedef ::cppu::ImplHelper1< css::sdbcx::XColumnsSupplier > OComponentDefinition_BASE;
41
43 ,public ODataSettings_Base
44 {
45 public:
46 typedef std::map < OUString
47 , css::uno::Reference< css::beans::XPropertySet >
49 typedef Columns::iterator iterator;
50 typedef Columns::const_iterator const_iterator;
51
52 private:
54
55 public:
56 OUString m_sSchemaName;
58
59 public:
61 virtual ~OComponentDefinition_Impl() override;
62
63 size_t size() const { return m_aColumns.size(); }
64
65 const_iterator begin() const { return m_aColumns.begin(); }
66 const_iterator end() const { return m_aColumns.end(); }
67
68 const_iterator find( const OUString& _rName ) const { return m_aColumns.find( _rName ); }
69
70 void erase( const OUString& _rName ) { m_aColumns.erase( _rName ); }
71
72 void insert( const OUString& _rName, const css::uno::Reference< css::beans::XPropertySet >& _rxColumn )
73 {
74 OSL_PRECOND( m_aColumns.find( _rName ) == m_aColumns.end(), "OComponentDefinition_Impl::insert: there's already an element with this name!" );
75 m_aColumns.emplace( _rName, _rxColumn );
76 }
77 };
78
79class OColumnPropertyListener;
80// OComponentDefinition - a database "document" which describes a query
82 ,public ODataSettings
83 ,public IColumnFactory
85 ,public ::comphelper::OPropertyArrayUsageHelper< OComponentDefinition >
86{
87 // no Reference! see OCollection::acquire
88 std::unique_ptr<OColumns> m_pColumns;
91
92protected:
93 virtual ~OComponentDefinition() override;
94 virtual void SAL_CALL disposing() override;
95
96 const OComponentDefinition_Impl& getDefinition() const { return dynamic_cast< const OComponentDefinition_Impl& >( *m_pImpl ); }
97 OComponentDefinition_Impl& getDefinition() { return dynamic_cast< OComponentDefinition_Impl& >( *m_pImpl ); }
98public:
100 const css::uno::Reference< css::uno::XComponentContext >&,
101 const css::uno::Reference< css::uno::XInterface >& _xParentContainer,
102 const TContentPtr& _pImpl,
103 bool _bTable = true);
104
106 const css::uno::Reference< css::uno::XInterface >& _rxContainer
107 ,const OUString& _rElementName
108 ,const css::uno::Reference< css::uno::XComponentContext >&
109 ,const TContentPtr& _pImpl
110 ,bool _bTable = true
111 );
112
113 virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
114 virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override;
115
116// css::uno::XInterface
118
119 // css::lang::XServiceInfo
120 virtual OUString SAL_CALL getImplementationName( ) override;
121 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
122
123 // XInitialization
124 virtual void SAL_CALL initialize( css::uno::Sequence< css::uno::Any > const & rArguments) override;
125
126 // css::beans::XPropertySet
127 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
128
129 // XColumnsSupplier
130 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override;
131
132 // OPropertySetHelper
133 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
134
135 // IColumnFactory
136 virtual rtl::Reference<OColumn> createColumn(const OUString& _rName) const override;
137 virtual css::uno::Reference< css::beans::XPropertySet > createColumnDescriptor() override;
138 virtual void columnAppended( const css::uno::Reference< css::beans::XPropertySet >& _rxSourceDescriptor ) override;
139 virtual void columnDropped(const OUString& _sName) override;
141
142protected:
143// OPropertyArrayUsageHelper
144 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
145
146 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
147 sal_Int32 nHandle,
148 const css::uno::Any& rValue) override;
149
150 // OContentHelper overridables
151 virtual OUString determineContentType() const override;
152
153private:
154 void registerProperties();
155};
156
157} // namespace dbaccess
158
159/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void insert(const OUString &_rName, const css::uno::Reference< css::beans::XPropertySet > &_rxColumn)
const_iterator find(const OUString &_rName) const
void erase(const OUString &_rName)
std::map< OUString, css::uno::Reference< css::beans::XPropertySet > > Columns
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
std::unique_ptr< OColumns > m_pColumns
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL initialize(css::uno::Sequence< css::uno::Any > const &rArguments) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual OUString determineContentType() const override
virtual void columnAppended(const css::uno::Reference< css::beans::XPropertySet > &_rxSourceDescriptor) override
notifies that a column, created from a column descriptor, has been appended
const OComponentDefinition_Impl & getDefinition() const
OComponentDefinition_Impl & getDefinition()
virtual void SAL_CALL disposing() override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
OComponentDefinition(const css::uno::Reference< css::uno::XInterface > &_rxContainer, const OUString &_rElementName, const css::uno::Reference< css::uno::XComponentContext > &, const TContentPtr &_pImpl, bool _bTable=true)
virtual OUString SAL_CALL getImplementationName() override
virtual void columnDropped(const OUString &_sName) override
notifies that a column with a given name has been dropped
OComponentDefinition(const css::uno::Reference< css::uno::XComponentContext > &, const css::uno::Reference< css::uno::XInterface > &_xParentContainer, const TContentPtr &_pImpl, bool _bTable=true)
virtual rtl::Reference< OColumn > createColumn(const OUString &_rName) const override
creates an OColumn object which should represent the column with a given name
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::beans::XPropertySet > createColumnDescriptor() override
creates a column descriptor object.
rtl::Reference< OColumnPropertyListener > m_xColumnPropertyListener
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns() override
std::shared_ptr< OContentHelper_Impl > TContentPtr
::cppu::ImplHelper1< css::sdbcx::XColumnsSupplier > OComponentDefinition_BASE
#define DECLARE_XINTERFACE()