1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_COMPONENTDEFINITION_HXX
21 #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_COMPONENTDEFINITION_HXX
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"
41 typedef ::cppu::ImplHelper1
< ::com::sun::star::sdbcx::XColumnsSupplier
> OComponentDefinition_BASE
;
43 class OComponentDefinition_Impl
: public OContentHelper_Impl
44 ,public ODataSettings_Base
47 typedef ::std::map
< OUString
48 , ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
50 typedef Columns::iterator iterator
;
51 typedef Columns::const_iterator const_iterator
;
57 OUString m_sSchemaName
;
58 OUString m_sCatalogName
;
61 OComponentDefinition_Impl();
62 virtual ~OComponentDefinition_Impl();
64 inline size_t size() const { return m_aColumns
.size(); }
66 inline const_iterator
begin() const { return m_aColumns
.begin(); }
67 inline const_iterator
end() const { return m_aColumns
.end(); }
69 inline const_iterator
find( const OUString
& _rName
) const { return m_aColumns
.find( _rName
); }
71 inline void erase( const OUString
& _rName
) { m_aColumns
.erase( _rName
); }
73 inline void insert( const OUString
& _rName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxColumn
)
75 OSL_PRECOND( m_aColumns
.find( _rName
) == m_aColumns
.end(), "OComponentDefinition_Impl::insert: there's already an element with this name!" );
76 m_aColumns
.insert( Columns::value_type( _rName
, _rxColumn
) );
80 class OColumnPropertyListener
;
81 // OComponentDefinition - a database "document" which describes a query
82 class OComponentDefinition
:public OContentHelper
84 ,public IColumnFactory
85 ,public OComponentDefinition_BASE
86 ,public ::comphelper::OPropertyArrayUsageHelper
< OComponentDefinition
>
88 OComponentDefinition();
91 ::std::unique_ptr
< OColumns
> m_pColumns
;
92 rtl::Reference
<OColumnPropertyListener
> m_xColumnPropertyListener
;
95 virtual ~OComponentDefinition();
96 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
99 OComponentDefinition(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&
100 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _xParentContainer
101 ,const TContentPtr
& _pImpl
102 ,bool _bTable
= true);
104 const OComponentDefinition_Impl
& getDefinition() const { return dynamic_cast< const OComponentDefinition_Impl
& >( *m_pImpl
.get() ); }
105 OComponentDefinition_Impl
& getDefinition() { return dynamic_cast< OComponentDefinition_Impl
& >( *m_pImpl
.get() ); }
108 OComponentDefinition(
109 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxContainer
110 ,const OUString
& _rElementName
111 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&
112 ,const TContentPtr
& _pImpl
116 virtual css::uno::Sequence
<css::uno::Type
> SAL_CALL
getTypes()
117 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
118 virtual css::uno::Sequence
<sal_Int8
> SAL_CALL
getImplementationId()
119 throw (css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
121 // ::com::sun::star::uno::XInterface
122 DECLARE_XINTERFACE( )
124 // ::com::sun::star::lang::XServiceInfo
125 virtual OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
126 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
128 static ::com::sun::star::uno::Sequence
< OUString
> getSupportedServiceNames_static() throw( ::com::sun::star::uno::RuntimeException
);
129 static OUString
getImplementationName_static() throw( ::com::sun::star::uno::RuntimeException
);
130 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
131 Create(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&);
134 virtual void SAL_CALL
initialize( com::sun::star::uno::Sequence
< com::sun::star::uno::Any
> const & rArguments
) throw (com::sun::star::uno::Exception
, std::exception
) SAL_OVERRIDE
;
136 // ::com::sun::star::beans::XPropertySet
137 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
140 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
getColumns( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
142 // OPropertySetHelper
143 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
146 virtual OColumn
* createColumn(const OUString
& _rName
) const SAL_OVERRIDE
;
147 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> createColumnDescriptor() SAL_OVERRIDE
;
148 virtual void columnAppended( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxSourceDescriptor
) SAL_OVERRIDE
;
149 virtual void columnDropped(const OUString
& _sName
) SAL_OVERRIDE
;
150 virtual void notifyDataSourceModified() SAL_OVERRIDE
{ OContentHelper::notifyDataSourceModified(); }
153 // OPropertyArrayUsageHelper
154 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const SAL_OVERRIDE
;
156 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
158 const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
, std::exception
) SAL_OVERRIDE
;
160 // OContentHelper overridables
161 virtual OUString
determineContentType() const SAL_OVERRIDE
;
164 void registerProperties();
167 } // namespace dbaccess
169 #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_COMPONENTDEFINITION_HXX
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */