Line data Source code
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 DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
21 : #define DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
22 :
23 : #include "commandbase.hxx"
24 : #include <comphelper/propertycontainer.hxx>
25 : #include <com/sun/star/sdbcx/XRename.hpp>
26 : #include <cppuhelper/implbase1.hxx>
27 : #include <comphelper/proparrhlp.hxx>
28 : #include "datasettings.hxx"
29 : #include <com/sun/star/container/XNameAccess.hpp>
30 : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
31 : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
32 : #include <com/sun/star/uno/XComponentContext.hpp>
33 : #include "ContentHelper.hxx"
34 : #include "apitools.hxx"
35 : #include <column.hxx>
36 : #include <comphelper/implementationreference.hxx>
37 :
38 : #include <memory>
39 : //........................................................................
40 : namespace dbaccess
41 : {
42 : //........................................................................
43 :
44 : typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XColumnsSupplier > OComponentDefinition_BASE;
45 :
46 : class OComponentDefinition_Impl : public OContentHelper_Impl
47 : ,public ODataSettings_Base
48 : {
49 : public:
50 : typedef ::std::map < ::rtl::OUString
51 : , ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
52 : > Columns;
53 : typedef Columns::iterator iterator;
54 : typedef Columns::const_iterator const_iterator;
55 :
56 : private:
57 : Columns m_aColumns;
58 :
59 : public:
60 : ::rtl::OUString m_sSchemaName;
61 : ::rtl::OUString m_sCatalogName;
62 :
63 : public:
64 : OComponentDefinition_Impl();
65 : virtual ~OComponentDefinition_Impl();
66 :
67 0 : inline size_t size() const { return m_aColumns.size(); }
68 :
69 0 : inline const_iterator begin() const { return m_aColumns.begin(); }
70 0 : inline const_iterator end() const { return m_aColumns.end(); }
71 :
72 0 : inline const_iterator find( const ::rtl::OUString& _rName ) const { return m_aColumns.find( _rName ); }
73 :
74 0 : inline void erase( const ::rtl::OUString& _rName ) { m_aColumns.erase( _rName ); }
75 :
76 0 : inline void insert( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn )
77 : {
78 : OSL_PRECOND( m_aColumns.find( _rName ) == m_aColumns.end(), "OComponentDefinition_Impl::insert: there's already an element with this name!" );
79 0 : m_aColumns.insert( Columns::value_type( _rName, _rxColumn ) );
80 0 : }
81 : };
82 :
83 : class OColumnPropertyListener;
84 : //=========================================================================
85 : //= OComponentDefinition - a database "document" which describes a query
86 : //=========================================================================
87 : class OComponentDefinition :public OContentHelper
88 : ,public ODataSettings
89 : ,public IColumnFactory
90 : ,public OComponentDefinition_BASE
91 : ,public ::comphelper::OPropertyArrayUsageHelper< OComponentDefinition >
92 : {
93 : OComponentDefinition();
94 :
95 : protected:
96 : ::std::auto_ptr< OColumns > m_pColumns;
97 : ::comphelper::ImplementationReference< OColumnPropertyListener,::com::sun::star::beans::XPropertyChangeListener>
98 : m_xColumnPropertyListener;
99 : sal_Bool m_bTable;
100 :
101 : virtual ~OComponentDefinition();
102 : virtual void SAL_CALL disposing();
103 :
104 :
105 : protected:
106 : OComponentDefinition(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
107 : ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer
108 : ,const TContentPtr& _pImpl
109 : ,sal_Bool _bTable = sal_True);
110 :
111 0 : const OComponentDefinition_Impl& getDefinition() const { return dynamic_cast< const OComponentDefinition_Impl& >( *m_pImpl.get() ); }
112 0 : OComponentDefinition_Impl& getDefinition() { return dynamic_cast< OComponentDefinition_Impl& >( *m_pImpl.get() ); }
113 : public:
114 :
115 : OComponentDefinition(
116 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContainer
117 : ,const ::rtl::OUString& _rElementName
118 : ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
119 : ,const TContentPtr& _pImpl
120 : ,sal_Bool _bTable = sal_True
121 : );
122 :
123 : // com::sun::star::lang::XTypeProvider
124 : DECLARE_TYPEPROVIDER( );
125 :
126 : // ::com::sun::star::uno::XInterface
127 : DECLARE_XINTERFACE( )
128 :
129 : // ::com::sun::star::lang::XServiceInfo
130 : virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
131 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
132 :
133 : static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
134 : static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
135 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
136 : Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
137 :
138 : // ::com::sun::star::beans::XPropertySet
139 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
140 :
141 : // XColumnsSupplier
142 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw (::com::sun::star::uno::RuntimeException);
143 :
144 : // OPropertySetHelper
145 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
146 :
147 : // IColumnFactory
148 : virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
149 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
150 : virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
151 : virtual void columnDropped(const ::rtl::OUString& _sName);
152 0 : virtual void notifyDataSourceModified() { OContentHelper::notifyDataSourceModified(); }
153 :
154 : protected:
155 : // OPropertyArrayUsageHelper
156 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
157 :
158 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
159 : sal_Int32 nHandle,
160 : const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
161 :
162 : // OContentHelper overridables
163 : virtual ::rtl::OUString determineContentType() const;
164 :
165 : private:
166 : void registerProperties();
167 : };
168 :
169 : //........................................................................
170 : } // namespace dbaccess
171 : //........................................................................
172 :
173 : #endif // DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
174 :
175 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|