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_QUERY_HXX_ 29 #define _DBA_COREAPI_QUERY_HXX_ 30 31 #ifndef _DBA_COREAPI_QUERYDESCRIPTOR_HXX_ 32 #include "querydescriptor.hxx" 33 #endif 34 #ifndef _CPPUHELPER_IMPLBASE3_HXX_ 35 #include <cppuhelper/implbase3.hxx> 36 #endif 37 #ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ 38 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> 39 #endif 40 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_ 41 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 42 #endif 43 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 44 #include <com/sun/star/sdbc/XConnection.hpp> 45 #endif 46 #ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_ 47 #include <com/sun/star/sdbcx/XRename.hpp> 48 #endif 49 #ifndef DBA_CONTENTHELPER_HXX 50 #include "ContentHelper.hxx" 51 #endif 52 53 #include <map> 54 55 namespace dbtools 56 { 57 class IWarningsContainer; 58 } 59 60 //........................................................................ 61 namespace dbaccess 62 { 63 //........................................................................ 64 65 //========================================================================== 66 //= OQuery - an object implementing the sdb.Query service 67 //========================================================================== 68 typedef ::cppu::ImplHelper3 < ::com::sun::star::sdbcx::XDataDescriptorFactory, 69 ::com::sun::star::beans::XPropertyChangeListener, 70 ::com::sun::star::sdbcx::XRename 71 > OQuery_Base; 72 class OQuery; 73 class OColumn; 74 typedef ::comphelper::OPropertyArrayUsageHelper< OQuery > OQuery_ArrayHelperBase; 75 76 77 class OQuery :public OContentHelper 78 ,public OQueryDescriptor_Base 79 ,public OQuery_Base 80 ,public OQuery_ArrayHelperBase 81 ,public ODataSettings 82 { 83 friend struct TRelease; 84 85 public: 86 typedef ::std::map< ::rtl::OUString,OColumn*,::comphelper::UStringMixLess> TNameColumnMap; 87 88 protected: 89 // TNameColumnMap m_aColumnMap; // contains all columnnames to columns 90 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xCommandDefinition; 91 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection; 92 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xCommandPropInfo; 93 ::rtl::Reference< OContainerMediator > m_pColumnMediator; 94 ::dbtools::IWarningsContainer* m_pWarnings; 95 sal_Bool m_bCaseSensitiv : 1; // assume case sensitivity of the column names ? 96 97 // possible actions on our "aggregate" 98 enum AGGREGATE_ACTION { NONE, SETTING_PROPERTIES, FLUSHING }; 99 AGGREGATE_ACTION m_eDoingCurrently; 100 101 // ------------------------------------------------------------------------ 102 /** a class which automatically resets m_eDoingCurrently in it's destructor 103 */ 104 class OAutoActionReset; // just for the following friend declaration 105 friend class OAutoActionReset; 106 class OAutoActionReset 107 { 108 OQuery* m_pActor; 109 public: 110 OAutoActionReset(OQuery* _pActor) : m_pActor(_pActor) { } 111 ~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; } 112 }; 113 114 protected: 115 virtual ~OQuery(); 116 117 // OPropertyArrayUsageHelper 118 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 119 ::cppu::IPropertyArrayHelper* getArrayHelper() { return OQuery_ArrayHelperBase::getArrayHelper(); } 120 121 public: 122 OQuery( 123 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxCommandDefinition, 124 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, 125 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB 126 ); 127 128 // com::sun::star::lang::XTypeProvider 129 DECLARE_TYPEPROVIDER( ); 130 131 // ::com::sun::star::uno::XInterface 132 DECLARE_XINTERFACE( ) 133 134 // ::com::sun::star::beans::XPropertySet 135 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 136 137 // OPropertySetHelper 138 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 139 140 // ::com::sun::star::lang::XServiceInfo 141 DECLARE_SERVICE_INFO(); 142 143 // ::com::sun::star::sdbcx::XDataDescriptorFactory 144 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException); 145 146 // ::com::sun::star::beans::XPropertyChangeListener 147 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException); 148 149 // ::com::sun::star::lang::XEventListener 150 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); 151 152 // OPropertySetHelper 153 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 154 sal_Int32 nHandle, 155 const ::com::sun::star::uno::Any& rValue ) 156 throw (::com::sun::star::uno::Exception); 157 158 public: 159 // the caller is responsible for the lifetime! 160 void setWarningsContainer( ::dbtools::IWarningsContainer* _pWarnings ) { m_pWarnings = _pWarnings; } 161 ::dbtools::IWarningsContainer* getWarningsContainer( ) const { return m_pWarnings; } 162 163 // XRename 164 virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); 165 166 protected: 167 virtual void SAL_CALL disposing(); 168 169 virtual OColumn* createColumn(const ::rtl::OUString& _rName) const; 170 171 virtual void rebuildColumns( ); 172 173 // OContentHelper overridables 174 virtual ::rtl::OUString determineContentType() const; 175 176 private: 177 void registerProperties(); 178 }; 179 180 //........................................................................ 181 } // namespace dbaccess 182 //........................................................................ 183 184 #endif // _DBA_COREAPI_QUERY_HXX_ 185 186 187