Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / dbaccess / source / core / api / query.hxx
blob456454b5656b9eb6f3909936ce37f08f6e6d1574
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _DBA_COREAPI_QUERY_HXX_
21 #define _DBA_COREAPI_QUERY_HXX_
23 #include "querydescriptor.hxx"
24 #include <cppuhelper/implbase3.hxx>
25 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
26 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
27 #include <com/sun/star/sdbc/XConnection.hpp>
28 #include <com/sun/star/sdbcx/XRename.hpp>
29 #include "ContentHelper.hxx"
31 #include <map>
33 namespace dbtools
35 class IWarningsContainer;
38 //........................................................................
39 namespace dbaccess
41 //........................................................................
43 //==========================================================================
44 //= OQuery - an object implementing the sdb.Query service
45 //==========================================================================
46 typedef ::cppu::ImplHelper3 < ::com::sun::star::sdbcx::XDataDescriptorFactory,
47 ::com::sun::star::beans::XPropertyChangeListener,
48 ::com::sun::star::sdbcx::XRename
49 > OQuery_Base;
50 class OQuery;
51 class OColumn;
52 typedef ::comphelper::OPropertyArrayUsageHelper< OQuery > OQuery_ArrayHelperBase;
55 class OQuery :public OContentHelper
56 ,public OQueryDescriptor_Base
57 ,public OQuery_Base
58 ,public OQuery_ArrayHelperBase
59 ,public ODataSettings
61 friend struct TRelease;
63 public:
64 typedef ::std::map< ::rtl::OUString,OColumn*,::comphelper::UStringMixLess> TNameColumnMap;
66 protected:
67 // TNameColumnMap m_aColumnMap; // contains all columnnames to columns
68 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xCommandDefinition;
69 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
70 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xCommandPropInfo;
71 ::rtl::Reference< OContainerMediator > m_pColumnMediator;
72 ::dbtools::IWarningsContainer* m_pWarnings;
73 sal_Bool m_bCaseSensitiv : 1; // assume case sensitivity of the column names ?
75 // possible actions on our "aggregate"
76 enum AGGREGATE_ACTION { NONE, SETTING_PROPERTIES, FLUSHING };
77 AGGREGATE_ACTION m_eDoingCurrently;
79 // ------------------------------------------------------------------------
80 /** a class which automatically resets m_eDoingCurrently in it's destructor
82 class OAutoActionReset; // just for the following friend declaration
83 friend class OAutoActionReset;
84 class OAutoActionReset
86 OQuery* m_pActor;
87 public:
88 OAutoActionReset(OQuery* _pActor) : m_pActor(_pActor) { }
89 ~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; }
92 protected:
93 virtual ~OQuery();
95 // OPropertyArrayUsageHelper
96 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
97 ::cppu::IPropertyArrayHelper* getArrayHelper() { return OQuery_ArrayHelperBase::getArrayHelper(); }
99 public:
100 OQuery(
101 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxCommandDefinition,
102 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn,
103 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
106 // com::sun::star::lang::XTypeProvider
107 DECLARE_TYPEPROVIDER( );
109 // ::com::sun::star::uno::XInterface
110 DECLARE_XINTERFACE( )
112 // ::com::sun::star::beans::XPropertySet
113 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
115 // OPropertySetHelper
116 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
118 // ::com::sun::star::lang::XServiceInfo
119 DECLARE_SERVICE_INFO();
121 // ::com::sun::star::sdbcx::XDataDescriptorFactory
122 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException);
124 // ::com::sun::star::beans::XPropertyChangeListener
125 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
127 // ::com::sun::star::lang::XEventListener
128 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
130 // OPropertySetHelper
131 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
132 sal_Int32 nHandle,
133 const ::com::sun::star::uno::Any& rValue )
134 throw (::com::sun::star::uno::Exception);
136 public:
137 // the caller is responsible for the lifetime!
138 void setWarningsContainer( ::dbtools::IWarningsContainer* _pWarnings ) { m_pWarnings = _pWarnings; }
139 ::dbtools::IWarningsContainer* getWarningsContainer( ) const { return m_pWarnings; }
141 // XRename
142 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);
144 protected:
145 virtual void SAL_CALL disposing();
147 virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
149 virtual void rebuildColumns( );
151 // OContentHelper overridables
152 virtual ::rtl::OUString determineContentType() const;
154 private:
155 void registerProperties();
158 //........................................................................
159 } // namespace dbaccess
160 //........................................................................
162 #endif // _DBA_COREAPI_QUERY_HXX_
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */