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 INCLUDED_DBACCESS_SOURCE_CORE_API_QUERY_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_CORE_API_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 : namespace dbaccess
39 : {
40 :
41 : // OQuery - an object implementing the sdb.Query service
42 : typedef ::cppu::ImplHelper3 < ::com::sun::star::sdbcx::XDataDescriptorFactory,
43 : ::com::sun::star::beans::XPropertyChangeListener,
44 : ::com::sun::star::sdbcx::XRename
45 : > OQuery_Base;
46 : class OQuery;
47 : class OColumn;
48 : typedef ::comphelper::OPropertyArrayUsageHelper< OQuery > OQuery_ArrayHelperBase;
49 :
50 : class OQuery :public OContentHelper
51 : ,public OQueryDescriptor_Base
52 : ,public OQuery_Base
53 : ,public OQuery_ArrayHelperBase
54 : ,public ODataSettings
55 : {
56 : friend struct TRelease;
57 :
58 : public:
59 : typedef ::std::map< OUString,OColumn*,::comphelper::UStringMixLess> TNameColumnMap;
60 :
61 : protected:
62 : // TNameColumnMap m_aColumnMap; // contains all columnnames to columns
63 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xCommandDefinition;
64 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
65 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xCommandPropInfo;
66 : ::rtl::Reference< OContainerMediator > m_pColumnMediator;
67 : ::dbtools::IWarningsContainer* m_pWarnings;
68 : sal_Bool m_bCaseSensitiv : 1; // assume case sensitivity of the column names ?
69 :
70 : // possible actions on our "aggregate"
71 : enum AGGREGATE_ACTION { NONE, SETTING_PROPERTIES, FLUSHING };
72 : AGGREGATE_ACTION m_eDoingCurrently;
73 :
74 : /** a class which automatically resets m_eDoingCurrently in its destructor
75 : */
76 : class OAutoActionReset; // just for the following friend declaration
77 : friend class OAutoActionReset;
78 : class OAutoActionReset
79 : {
80 : OQuery* m_pActor;
81 : public:
82 0 : OAutoActionReset(OQuery* _pActor) : m_pActor(_pActor) { }
83 0 : ~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; }
84 : };
85 :
86 : protected:
87 : virtual ~OQuery();
88 :
89 : // OPropertyArrayUsageHelper
90 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
91 0 : ::cppu::IPropertyArrayHelper* getArrayHelper() { return OQuery_ArrayHelperBase::getArrayHelper(); }
92 :
93 : public:
94 : OQuery(
95 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxCommandDefinition,
96 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn,
97 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _xORB
98 : );
99 :
100 : virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes()
101 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 : virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
103 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 :
105 : // ::com::sun::star::uno::XInterface
106 : DECLARE_XINTERFACE( )
107 :
108 : // ::com::sun::star::beans::XPropertySet
109 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 :
111 : // OPropertySetHelper
112 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
113 :
114 : // ::com::sun::star::lang::XServiceInfo
115 : DECLARE_SERVICE_INFO();
116 :
117 : // ::com::sun::star::sdbcx::XDataDescriptorFactory
118 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 :
120 : // ::com::sun::star::beans::XPropertyChangeListener
121 : virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 :
123 : // ::com::sun::star::lang::XEventListener
124 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
125 :
126 : // OPropertySetHelper
127 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
128 : sal_Int32 nHandle,
129 : const ::com::sun::star::uno::Any& rValue )
130 : throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
131 :
132 : public:
133 : // the caller is responsible for the lifetime!
134 0 : void setWarningsContainer( ::dbtools::IWarningsContainer* _pWarnings ) { m_pWarnings = _pWarnings; }
135 : ::dbtools::IWarningsContainer* getWarningsContainer( ) const { return m_pWarnings; }
136 :
137 : // XRename
138 : virtual void SAL_CALL rename( const OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 :
140 : protected:
141 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
142 :
143 : virtual OColumn* createColumn(const OUString& _rName) const SAL_OVERRIDE;
144 :
145 : virtual void rebuildColumns( ) SAL_OVERRIDE;
146 :
147 : // OContentHelper overridables
148 : virtual OUString determineContentType() const SAL_OVERRIDE;
149 :
150 : private:
151 : void registerProperties();
152 : };
153 :
154 : } // namespace dbaccess
155 :
156 : #endif // INCLUDED_DBACCESS_SOURCE_CORE_API_QUERY_HXX
157 :
158 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|