1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ComponentDefinition.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
32 #define DBA_COREDATAACESS_COMPONENTDEFINITION_HXX
34 #ifndef _DBA_CORE_COMMANDBASE_HXX_
35 #include "commandbase.hxx"
37 #ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_
38 #include <comphelper/propertycontainer.hxx>
40 #ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
41 #include <com/sun/star/sdbcx/XRename.hpp>
43 #ifndef _CPPUHELPER_IMPLBASE1_HXX_
44 #include <cppuhelper/implbase1.hxx>
46 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
47 #include <comphelper/proparrhlp.hxx>
49 #ifndef _DBA_CORE_DATASETTINGS_HXX_
50 #include "datasettings.hxx"
52 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
53 #include <com/sun/star/container/XNameAccess.hpp>
55 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
56 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
58 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
59 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
61 #ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
62 #include <com/sun/star/uno/XComponentContext.hpp>
64 #ifndef DBA_CONTENTHELPER_HXX
65 #include "ContentHelper.hxx"
67 #ifndef _DBASHARED_APITOOLS_HXX_
68 #include "apitools.hxx"
70 #ifndef _DBA_COREAPI_COLUMN_HXX_
73 #include <comphelper/implementationreference.hxx>
76 //........................................................................
79 //........................................................................
81 typedef ::cppu::ImplHelper1
< ::com::sun::star::sdbcx::XColumnsSupplier
> OComponentDefinition_BASE
;
83 class OComponentDefinition_Impl
: public OContentHelper_Impl
84 ,public ODataSettings_Base
87 typedef ::std::map
< ::rtl::OUString
88 , ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
90 typedef Columns::iterator iterator
;
91 typedef Columns::const_iterator const_iterator
;
97 ::rtl::OUString m_sSchemaName
;
98 ::rtl::OUString m_sCatalogName
;
101 OComponentDefinition_Impl();
102 virtual ~OComponentDefinition_Impl();
104 inline size_t size() const { return m_aColumns
.size(); }
106 inline const_iterator
begin() const { return m_aColumns
.begin(); }
107 inline const_iterator
end() const { return m_aColumns
.end(); }
109 inline const_iterator
find( const ::rtl::OUString
& _rName
) const { return m_aColumns
.find( _rName
); }
111 inline void erase( const ::rtl::OUString
& _rName
) { m_aColumns
.erase( _rName
); }
113 inline void insert( const ::rtl::OUString
& _rName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxColumn
)
115 OSL_PRECOND( m_aColumns
.find( _rName
) == m_aColumns
.end(), "OComponentDefinition_Impl::insert: there's already an element with this name!" );
116 m_aColumns
.insert( Columns::value_type( _rName
, _rxColumn
) );
120 class OColumnPropertyListener
;
121 //=========================================================================
122 //= OComponentDefinition - a database "document" which describes a query
123 //=========================================================================
124 class OComponentDefinition
:public OContentHelper
125 ,public ODataSettings
126 ,public IColumnFactory
127 ,public OComponentDefinition_BASE
128 ,public ::comphelper::OPropertyArrayUsageHelper
< OComponentDefinition
>
130 OComponentDefinition();
133 ::std::auto_ptr
< OColumns
> m_pColumns
;
134 ::comphelper::ImplementationReference
< OColumnPropertyListener
,::com::sun::star::beans::XPropertyChangeListener
>
135 m_xColumnPropertyListener
;
138 virtual ~OComponentDefinition();
139 virtual void SAL_CALL
disposing();
143 OComponentDefinition(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>&
144 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _xParentContainer
145 ,const TContentPtr
& _pImpl
146 ,sal_Bool _bTable
= sal_True
);
148 const OComponentDefinition_Impl
& getDefinition() const { return dynamic_cast< const OComponentDefinition_Impl
& >( *m_pImpl
.get() ); }
149 OComponentDefinition_Impl
& getDefinition() { return dynamic_cast< OComponentDefinition_Impl
& >( *m_pImpl
.get() ); }
152 OComponentDefinition(
153 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxContainer
154 ,const ::rtl::OUString
& _rElementName
155 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>&
156 ,const TContentPtr
& _pImpl
157 ,sal_Bool _bTable
= sal_True
160 // com::sun::star::lang::XTypeProvider
161 DECLARE_TYPEPROVIDER( );
163 // ::com::sun::star::uno::XInterface
164 DECLARE_XINTERFACE( )
166 // ::com::sun::star::lang::XServiceInfo
167 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
168 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
170 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException
);
171 static ::rtl::OUString
getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException
);
172 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
173 Create(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&);
175 // ::com::sun::star::beans::XPropertySet
176 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
179 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getColumns( ) throw (::com::sun::star::uno::RuntimeException
);
181 // OPropertySetHelper
182 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
185 virtual OColumn
* createColumn(const ::rtl::OUString
& _rName
) const;
186 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> createColumnDescriptor();
187 virtual void columnAppended( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxSourceDescriptor
);
188 virtual void columnDropped(const ::rtl::OUString
& _sName
);
189 virtual void notifyDataSourceModified() { OContentHelper::notifyDataSourceModified(); }
192 // OPropertyArrayUsageHelper
193 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const;
195 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
197 const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
);
199 // OContentHelper overridables
200 virtual ::rtl::OUString
determineContentType() const;
203 void registerProperties();
206 //........................................................................
207 } // namespace dbaccess
208 //........................................................................
210 #endif // DBA_COREDATAACESS_COMPONENTDEFINITION_HXX