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