xref: /trunk/main/dbaccess/source/core/api/querydescriptor.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
29 #define _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
30 
31 #ifndef _CPPUHELPER_IMPLBASE3_HXX_
32 #include <cppuhelper/implbase3.hxx>
33 #endif
34 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
35 #include <comphelper/proparrhlp.hxx>
36 #endif
37 #ifndef _OSL_MUTEX_HXX_
38 #include <osl/mutex.hxx>
39 #endif
40 
41 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
42 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
43 #endif
44 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
45 #include <com/sun/star/lang/XServiceInfo.hpp>
46 #endif
47 #ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
48 #include <com/sun/star/lang/XUnoTunnel.hpp>
49 #endif
50 
51 #ifndef _DBASHARED_APITOOLS_HXX_
52 #include "apitools.hxx"
53 #endif
54 #ifndef _DBA_COREAPI_COLUMN_HXX_
55 #include "column.hxx"
56 #endif
57 #ifndef _DBA_CORE_DATASETTINGS_HXX_
58 #include "datasettings.hxx"
59 #endif
60 #ifndef _DBA_CORE_COMMANDBASE_HXX_
61 #include "commandbase.hxx"
62 #endif
63 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_
64 #include <comphelper/broadcasthelper.hxx>
65 #endif
66 #ifndef _COMPHELPER_UNO3_HXX_
67 #include <comphelper/uno3.hxx>
68 #endif
69 
70 //........................................................................
71 namespace dbaccess
72 {
73 //........................................................................
74 
75 //==========================================================================
76 //= OQueryDescriptor_Base - a query descriptor (as the name suggests :)
77 //==========================================================================
78 typedef ::cppu::ImplHelper3<
79         ::com::sun::star::sdbcx::XColumnsSupplier,
80         ::com::sun::star::lang::XUnoTunnel,
81         ::com::sun::star::lang::XServiceInfo >  OQueryDescriptor_BASE;
82 
83 class OQueryDescriptor_Base
84         :public OQueryDescriptor_BASE
85         ,public OCommandBase
86         ,public IColumnFactory
87         ,public ::connectivity::sdbcx::IRefreshableColumns
88 {
89 private:
90     sal_Bool        m_bColumnsOutOfDate : 1;    // the columns have to be rebuild on the next getColumns ?
91     ::osl::Mutex&   m_rMutex;
92 
93 protected:
94     OColumns*       m_pColumns;                 // our column descriptions
95     ::rtl::OUString m_sElementName;
96     virtual ~OQueryDescriptor_Base();
97 
98     void        setColumnsOutOfDate( sal_Bool _bOutOfDate = sal_True );
99     sal_Bool    isColumnsOutOfDate() const { return m_bColumnsOutOfDate; }
100 
101     sal_Int32   getColumnCount() const { return m_pColumns ? m_pColumns->getCount() : 0; }
102     void        clearColumns( );
103 
104     void        implAppendColumn( const ::rtl::OUString& _rName, OColumn* _pColumn );
105 
106 public:
107     OQueryDescriptor_Base(::osl::Mutex& _rMutex,::cppu::OWeakObject& _rMySelf);
108     /** constructs the object with a UNO QueryDescriptor. If you use this ctor, the resulting object
109         won't have any column informations (the column container will be empty)
110     */
111     OQueryDescriptor_Base(const OQueryDescriptor_Base& _rSource,::cppu::OWeakObject& _rMySelf);
112 
113 // ::com::sun::star::sdbcx::XColumnsSupplier
114     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns(  ) throw(::com::sun::star::uno::RuntimeException);
115 
116 // ::com::sun::star::lang::XUnoTunnel
117     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
118     DECLARE_IMPLEMENTATION_ID( );
119 
120 // ::com::sun::star::lang::XServiceInfo
121     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
122     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
123     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
124 
125 protected:
126 
127 // IColumnFactory
128     virtual OColumn*    createColumn(const ::rtl::OUString& _rName) const;
129     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor();
130     virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor );
131     virtual void columnDropped(const ::rtl::OUString& _sName);
132 
133     /** rebuild our columns set
134 
135         clearColumns has already been called before, do <em>NOT</em> call it, again
136     */
137     virtual void rebuildColumns( );
138 
139     virtual void disposeColumns();
140 
141     // IRefreshableColumns overridables
142     virtual void refreshColumns();
143 };
144 
145 class OQueryDescriptor : public comphelper::OMutexAndBroadcastHelper
146                         ,public ::cppu::OWeakObject
147                         ,public OQueryDescriptor_Base
148                         ,public ::comphelper::OPropertyArrayUsageHelper< OQueryDescriptor_Base >
149                         ,public ODataSettings
150 {
151     OQueryDescriptor(const OQueryDescriptor&);
152     void operator =(const OQueryDescriptor&);
153     // helper
154     void registerProperties();
155 protected:
156     // OPropertyArrayUsageHelper
157     virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
158 
159     // OPropertySetHelper
160     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
161 
162     virtual ~OQueryDescriptor();
163 public:
164     OQueryDescriptor();
165     OQueryDescriptor(const OQueryDescriptor_Base& _rSource);
166 
167     // com::sun::star::lang::XTypeProvider
168     DECLARE_TYPEPROVIDER( );
169 
170 // ::com::sun::star::uno::XInterface
171     DECLARE_XINTERFACE( )
172 
173     // ::com::sun::star::beans::XPropertySet
174     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
175 
176 };
177 //........................................................................
178 }   // namespace dbaccess
179 //........................................................................
180 
181 #endif // _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
182 
183 
184