1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _DBA_COREAPI_QUERYDESCRIPTOR_HXX_ 25 #define _DBA_COREAPI_QUERYDESCRIPTOR_HXX_ 26 27 #ifndef _CPPUHELPER_IMPLBASE3_HXX_ 28 #include <cppuhelper/implbase3.hxx> 29 #endif 30 #ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ 31 #include <comphelper/proparrhlp.hxx> 32 #endif 33 #ifndef _OSL_MUTEX_HXX_ 34 #include <osl/mutex.hxx> 35 #endif 36 37 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ 38 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 39 #endif 40 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ 41 #include <com/sun/star/lang/XServiceInfo.hpp> 42 #endif 43 #ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ 44 #include <com/sun/star/lang/XUnoTunnel.hpp> 45 #endif 46 47 #ifndef _DBASHARED_APITOOLS_HXX_ 48 #include "apitools.hxx" 49 #endif 50 #ifndef _DBA_COREAPI_COLUMN_HXX_ 51 #include "column.hxx" 52 #endif 53 #ifndef _DBA_CORE_DATASETTINGS_HXX_ 54 #include "datasettings.hxx" 55 #endif 56 #ifndef _DBA_CORE_COMMANDBASE_HXX_ 57 #include "commandbase.hxx" 58 #endif 59 #ifndef _COMPHELPER_BROADCASTHELPER_HXX_ 60 #include <comphelper/broadcasthelper.hxx> 61 #endif 62 #ifndef _COMPHELPER_UNO3_HXX_ 63 #include <comphelper/uno3.hxx> 64 #endif 65 66 //........................................................................ 67 namespace dbaccess 68 { 69 //........................................................................ 70 71 //========================================================================== 72 //= OQueryDescriptor_Base - a query descriptor (as the name suggests :) 73 //========================================================================== 74 typedef ::cppu::ImplHelper3< 75 ::com::sun::star::sdbcx::XColumnsSupplier, 76 ::com::sun::star::lang::XUnoTunnel, 77 ::com::sun::star::lang::XServiceInfo > OQueryDescriptor_BASE; 78 79 class OQueryDescriptor_Base 80 :public OQueryDescriptor_BASE 81 ,public OCommandBase 82 ,public IColumnFactory 83 ,public ::connectivity::sdbcx::IRefreshableColumns 84 { 85 private: 86 sal_Bool m_bColumnsOutOfDate : 1; // the columns have to be rebuild on the next getColumns ? 87 ::osl::Mutex& m_rMutex; 88 89 protected: 90 OColumns* m_pColumns; // our column descriptions 91 ::rtl::OUString m_sElementName; 92 virtual ~OQueryDescriptor_Base(); 93 94 void setColumnsOutOfDate( sal_Bool _bOutOfDate = sal_True ); isColumnsOutOfDate() const95 sal_Bool isColumnsOutOfDate() const { return m_bColumnsOutOfDate; } 96 getColumnCount() const97 sal_Int32 getColumnCount() const { return m_pColumns ? m_pColumns->getCount() : 0; } 98 void clearColumns( ); 99 100 void implAppendColumn( const ::rtl::OUString& _rName, OColumn* _pColumn ); 101 102 public: 103 OQueryDescriptor_Base(::osl::Mutex& _rMutex,::cppu::OWeakObject& _rMySelf); 104 /** constructs the object with a UNO QueryDescriptor. If you use this ctor, the resulting object 105 won't have any column informations (the column container will be empty) 106 */ 107 OQueryDescriptor_Base(const OQueryDescriptor_Base& _rSource,::cppu::OWeakObject& _rMySelf); 108 109 // ::com::sun::star::sdbcx::XColumnsSupplier 110 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException); 111 112 // ::com::sun::star::lang::XUnoTunnel 113 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); 114 DECLARE_IMPLEMENTATION_ID( ); 115 116 // ::com::sun::star::lang::XServiceInfo 117 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); 118 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); 119 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); 120 121 protected: 122 123 // IColumnFactory 124 virtual OColumn* createColumn(const ::rtl::OUString& _rName) const; 125 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor(); 126 virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ); 127 virtual void columnDropped(const ::rtl::OUString& _sName); 128 129 /** rebuild our columns set 130 131 clearColumns has already been called before, do <em>NOT</em> call it, again 132 */ 133 virtual void rebuildColumns( ); 134 135 virtual void disposeColumns(); 136 137 // IRefreshableColumns overridables 138 virtual void refreshColumns(); 139 }; 140 141 class OQueryDescriptor : public comphelper::OMutexAndBroadcastHelper 142 ,public ::cppu::OWeakObject 143 ,public OQueryDescriptor_Base 144 ,public ::comphelper::OPropertyArrayUsageHelper< OQueryDescriptor_Base > 145 ,public ODataSettings 146 { 147 OQueryDescriptor(const OQueryDescriptor&); 148 void operator =(const OQueryDescriptor&); 149 // helper 150 void registerProperties(); 151 protected: 152 // OPropertyArrayUsageHelper 153 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 154 155 // OPropertySetHelper 156 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 157 158 virtual ~OQueryDescriptor(); 159 public: 160 OQueryDescriptor(); 161 OQueryDescriptor(const OQueryDescriptor_Base& _rSource); 162 163 // com::sun::star::lang::XTypeProvider 164 DECLARE_TYPEPROVIDER( ); 165 166 // ::com::sun::star::uno::XInterface 167 DECLARE_XINTERFACE( ) 168 169 // ::com::sun::star::beans::XPropertySet 170 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 171 172 }; 173 //........................................................................ 174 } // namespace dbaccess 175 //........................................................................ 176 177 #endif // _DBA_COREAPI_QUERYDESCRIPTOR_HXX_ 178 179 180