Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _DBA_COREAPI_QUERY_HXX_
21 : #define _DBA_COREAPI_QUERY_HXX_
22 :
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"
30 :
31 : #include <map>
32 :
33 : namespace dbtools
34 : {
35 : class IWarningsContainer;
36 : }
37 :
38 : //........................................................................
39 : namespace dbaccess
40 : {
41 : //........................................................................
42 :
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;
53 :
54 :
55 : class OQuery :public OContentHelper
56 : ,public OQueryDescriptor_Base
57 : ,public OQuery_Base
58 : ,public OQuery_ArrayHelperBase
59 : ,public ODataSettings
60 : {
61 : friend struct TRelease;
62 :
63 : public:
64 : typedef ::std::map< ::rtl::OUString,OColumn*,::comphelper::UStringMixLess> TNameColumnMap;
65 :
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 ?
74 :
75 : // possible actions on our "aggregate"
76 : enum AGGREGATE_ACTION { NONE, SETTING_PROPERTIES, FLUSHING };
77 : AGGREGATE_ACTION m_eDoingCurrently;
78 :
79 : // ------------------------------------------------------------------------
80 : /** a class which automatically resets m_eDoingCurrently in it's destructor
81 : */
82 : class OAutoActionReset; // just for the following friend declaration
83 : friend class OAutoActionReset;
84 : class OAutoActionReset
85 : {
86 : OQuery* m_pActor;
87 : public:
88 0 : OAutoActionReset(OQuery* _pActor) : m_pActor(_pActor) { }
89 0 : ~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; }
90 : };
91 :
92 : protected:
93 : virtual ~OQuery();
94 :
95 : // OPropertyArrayUsageHelper
96 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
97 0 : ::cppu::IPropertyArrayHelper* getArrayHelper() { return OQuery_ArrayHelperBase::getArrayHelper(); }
98 :
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
104 : );
105 :
106 : // com::sun::star::lang::XTypeProvider
107 : DECLARE_TYPEPROVIDER( );
108 :
109 : // ::com::sun::star::uno::XInterface
110 : DECLARE_XINTERFACE( )
111 :
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);
114 :
115 : // OPropertySetHelper
116 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
117 :
118 : // ::com::sun::star::lang::XServiceInfo
119 : DECLARE_SERVICE_INFO();
120 :
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);
123 :
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);
126 :
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);
129 :
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);
135 :
136 : public:
137 : // the caller is responsible for the lifetime!
138 0 : void setWarningsContainer( ::dbtools::IWarningsContainer* _pWarnings ) { m_pWarnings = _pWarnings; }
139 : ::dbtools::IWarningsContainer* getWarningsContainer( ) const { return m_pWarnings; }
140 :
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);
143 :
144 : protected:
145 : virtual void SAL_CALL disposing();
146 :
147 : virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
148 :
149 : virtual void rebuildColumns( );
150 :
151 : // OContentHelper overridables
152 : virtual ::rtl::OUString determineContentType() const;
153 :
154 : private:
155 : void registerProperties();
156 : };
157 :
158 : //........................................................................
159 : } // namespace dbaccess
160 : //........................................................................
161 :
162 : #endif // _DBA_COREAPI_QUERY_HXX_
163 :
164 :
165 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|