1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
25cdf0e10cSrcweir #define DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _DBA_CORE_COMMANDBASE_HXX_
28cdf0e10cSrcweir #include "commandbase.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_
31cdf0e10cSrcweir #include <comphelper/propertycontainer.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
34cdf0e10cSrcweir #include <com/sun/star/sdbcx/XRename.hpp>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE1_HXX_
37cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
40cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _DBA_CORE_DATASETTINGS_HXX_
43cdf0e10cSrcweir #include "datasettings.hxx"
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
46cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
49cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
52cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
55cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir #ifndef DBA_CONTENTHELPER_HXX
58cdf0e10cSrcweir #include "ContentHelper.hxx"
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir #ifndef _DBASHARED_APITOOLS_HXX_
61cdf0e10cSrcweir #include "apitools.hxx"
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #ifndef _DBA_COREAPI_COLUMN_HXX_
64cdf0e10cSrcweir #include <column.hxx>
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir #include <comphelper/implementationreference.hxx>
67cdf0e10cSrcweir 
68cdf0e10cSrcweir #include <memory>
69cdf0e10cSrcweir //........................................................................
70cdf0e10cSrcweir namespace dbaccess
71cdf0e10cSrcweir {
72cdf0e10cSrcweir //........................................................................
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XColumnsSupplier > OComponentDefinition_BASE;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	class OComponentDefinition_Impl : public OContentHelper_Impl
77cdf0e10cSrcweir 									 ,public ODataSettings_Base
78cdf0e10cSrcweir 	{
79cdf0e10cSrcweir 	public:
80cdf0e10cSrcweir         typedef ::std::map  <   ::rtl::OUString
81cdf0e10cSrcweir                             ,   ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
82cdf0e10cSrcweir                             >   Columns;
83cdf0e10cSrcweir     typedef Columns::iterator           iterator;
84cdf0e10cSrcweir     typedef Columns::const_iterator     const_iterator;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     private:
87cdf0e10cSrcweir 		Columns             m_aColumns;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     public:
90cdf0e10cSrcweir 		::rtl::OUString		m_sSchemaName;
91cdf0e10cSrcweir 		::rtl::OUString		m_sCatalogName;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     public:
94cdf0e10cSrcweir         OComponentDefinition_Impl();
95cdf0e10cSrcweir         virtual ~OComponentDefinition_Impl();
96cdf0e10cSrcweir 
size() const97cdf0e10cSrcweir         inline size_t size() const { return m_aColumns.size(); }
98cdf0e10cSrcweir 
begin() const99cdf0e10cSrcweir         inline const_iterator begin() const   { return m_aColumns.begin(); }
end() const100cdf0e10cSrcweir         inline const_iterator end() const     { return m_aColumns.end(); }
101cdf0e10cSrcweir 
find(const::rtl::OUString & _rName) const102cdf0e10cSrcweir         inline const_iterator find( const ::rtl::OUString& _rName ) const { return m_aColumns.find( _rName ); }
103cdf0e10cSrcweir 
erase(const::rtl::OUString & _rName)104cdf0e10cSrcweir         inline void erase( const ::rtl::OUString& _rName ) { m_aColumns.erase( _rName ); }
105cdf0e10cSrcweir 
insert(const::rtl::OUString & _rName,const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> & _rxColumn)106cdf0e10cSrcweir         inline void insert( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn )
107cdf0e10cSrcweir         {
108cdf0e10cSrcweir             OSL_PRECOND( m_aColumns.find( _rName ) == m_aColumns.end(), "OComponentDefinition_Impl::insert: there's already an element with this name!" );
109cdf0e10cSrcweir             m_aColumns.insert( Columns::value_type( _rName, _rxColumn ) );
110cdf0e10cSrcweir         }
111cdf0e10cSrcweir 	};
112cdf0e10cSrcweir 
113cdf0e10cSrcweir class OColumnPropertyListener;
114cdf0e10cSrcweir //=========================================================================
115cdf0e10cSrcweir //= OComponentDefinition - a database "document" which describes a query
116cdf0e10cSrcweir //=========================================================================
117cdf0e10cSrcweir class OComponentDefinition	:public OContentHelper
118cdf0e10cSrcweir 							,public ODataSettings
119cdf0e10cSrcweir 							,public IColumnFactory
120cdf0e10cSrcweir 							,public OComponentDefinition_BASE
121cdf0e10cSrcweir 							,public ::comphelper::OPropertyArrayUsageHelper< OComponentDefinition >
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	OComponentDefinition();
124cdf0e10cSrcweir 
125cdf0e10cSrcweir protected:
126cdf0e10cSrcweir     ::std::auto_ptr< OColumns >     m_pColumns;
127cdf0e10cSrcweir     ::comphelper::ImplementationReference< OColumnPropertyListener,::com::sun::star::beans::XPropertyChangeListener>
128cdf0e10cSrcweir                                     m_xColumnPropertyListener;
129cdf0e10cSrcweir 	sal_Bool	                    m_bTable;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	virtual ~OComponentDefinition();
132cdf0e10cSrcweir 	virtual void SAL_CALL disposing();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 
135cdf0e10cSrcweir protected:
136cdf0e10cSrcweir 	OComponentDefinition(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
137cdf0e10cSrcweir 		,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >&	_xParentContainer
138cdf0e10cSrcweir 		,const TContentPtr& _pImpl
139cdf0e10cSrcweir 		,sal_Bool _bTable = sal_True);
140cdf0e10cSrcweir 
getDefinition() const141cdf0e10cSrcweir     const   OComponentDefinition_Impl& getDefinition() const { return dynamic_cast< const OComponentDefinition_Impl& >( *m_pImpl.get() ); }
getDefinition()142cdf0e10cSrcweir             OComponentDefinition_Impl& getDefinition()       { return dynamic_cast<       OComponentDefinition_Impl& >( *m_pImpl.get() ); }
143cdf0e10cSrcweir public:
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	OComponentDefinition(
146cdf0e10cSrcweir 			 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContainer
147cdf0e10cSrcweir 			,const ::rtl::OUString& _rElementName
148cdf0e10cSrcweir 			,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
149cdf0e10cSrcweir 			,const TContentPtr& _pImpl
150cdf0e10cSrcweir 			,sal_Bool _bTable = sal_True
151cdf0e10cSrcweir 		);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir // com::sun::star::lang::XTypeProvider
154cdf0e10cSrcweir 	DECLARE_TYPEPROVIDER( );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
157cdf0e10cSrcweir 	DECLARE_XINTERFACE( )
158cdf0e10cSrcweir 
159cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
160cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
161cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
164cdf0e10cSrcweir 	static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
165cdf0e10cSrcweir 	static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
166cdf0e10cSrcweir 		Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
167cdf0e10cSrcweir 
168cdf0e10cSrcweir // ::com::sun::star::beans::XPropertySet
169cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	// XColumnsSupplier
172cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns(  ) throw (::com::sun::star::uno::RuntimeException);
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	// OPropertySetHelper
175cdf0e10cSrcweir 	virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	// IColumnFactory
178cdf0e10cSrcweir 	virtual OColumn*	createColumn(const ::rtl::OUString& _rName) const;
179cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
180cdf0e10cSrcweir     virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
181cdf0e10cSrcweir 	virtual void columnDropped(const ::rtl::OUString& _sName);
notifyDataSourceModified()182cdf0e10cSrcweir     virtual void notifyDataSourceModified() { OContentHelper::notifyDataSourceModified(); }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir protected:
185cdf0e10cSrcweir // OPropertyArrayUsageHelper
186cdf0e10cSrcweir 	virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
189cdf0e10cSrcweir 									sal_Int32 nHandle,
190cdf0e10cSrcweir 									const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     // OContentHelper overridables
193cdf0e10cSrcweir     virtual ::rtl::OUString determineContentType() const;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir private:
196cdf0e10cSrcweir 	void registerProperties();
197cdf0e10cSrcweir };
198cdf0e10cSrcweir 
199cdf0e10cSrcweir //........................................................................
200cdf0e10cSrcweir }	// namespace dbaccess
201cdf0e10cSrcweir //........................................................................
202cdf0e10cSrcweir 
203cdf0e10cSrcweir #endif // DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
204