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_QUERYDESCRIPTOR_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_CORE_API_QUERYDESCRIPTOR_HXX
22 :
23 : #include <cppuhelper/implbase3.hxx>
24 : #include <comphelper/proparrhlp.hxx>
25 : #include <osl/mutex.hxx>
26 :
27 : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
28 : #include <com/sun/star/lang/XServiceInfo.hpp>
29 : #include <com/sun/star/lang/XUnoTunnel.hpp>
30 :
31 : #include "apitools.hxx"
32 : #include "column.hxx"
33 : #include "datasettings.hxx"
34 : #include "commandbase.hxx"
35 : #include <comphelper/broadcasthelper.hxx>
36 : #include <comphelper/uno3.hxx>
37 :
38 : namespace dbaccess
39 : {
40 :
41 : // OQueryDescriptor_Base - a query descriptor (as the name suggests :)
42 : typedef ::cppu::ImplHelper3<
43 : ::com::sun::star::sdbcx::XColumnsSupplier,
44 : ::com::sun::star::lang::XUnoTunnel,
45 : ::com::sun::star::lang::XServiceInfo > OQueryDescriptor_BASE;
46 :
47 : class OQueryDescriptor_Base
48 : :public OQueryDescriptor_BASE
49 : ,public OCommandBase
50 : ,public IColumnFactory
51 : ,public ::connectivity::sdbcx::IRefreshableColumns
52 : {
53 : private:
54 : sal_Bool m_bColumnsOutOfDate : 1; // the columns have to be rebuild on the next getColumns ?
55 : ::osl::Mutex& m_rMutex;
56 :
57 : protected:
58 : OColumns* m_pColumns; // our column descriptions
59 : OUString m_sElementName;
60 : virtual ~OQueryDescriptor_Base();
61 :
62 : void setColumnsOutOfDate( sal_Bool _bOutOfDate = sal_True );
63 0 : sal_Bool isColumnsOutOfDate() const { return m_bColumnsOutOfDate; }
64 :
65 : sal_Int32 getColumnCount() const { return m_pColumns ? m_pColumns->getCount() : 0; }
66 : void clearColumns( );
67 :
68 : void implAppendColumn( const OUString& _rName, OColumn* _pColumn );
69 :
70 : public:
71 : OQueryDescriptor_Base(::osl::Mutex& _rMutex,::cppu::OWeakObject& _rMySelf);
72 : /** constructs the object with a UNO QueryDescriptor. If you use this ctor, the resulting object
73 : won't have any column information (the column container will be empty)
74 : */
75 : OQueryDescriptor_Base(const OQueryDescriptor_Base& _rSource,::cppu::OWeakObject& _rMySelf);
76 :
77 : // ::com::sun::star::sdbcx::XColumnsSupplier
78 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 :
80 : // ::com::sun::star::lang::XUnoTunnel
81 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
82 : DECLARE_IMPLEMENTATION_ID( );
83 :
84 : // ::com::sun::star::lang::XServiceInfo
85 : virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 :
89 : protected:
90 :
91 : // IColumnFactory
92 : virtual OColumn* createColumn(const OUString& _rName) const SAL_OVERRIDE;
93 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor() SAL_OVERRIDE;
94 : virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ) SAL_OVERRIDE;
95 : virtual void columnDropped(const OUString& _sName) SAL_OVERRIDE;
96 :
97 : /** rebuild our columns set
98 :
99 : clearColumns has already been called before, do <em>NOT</em> call it, again
100 : */
101 : virtual void rebuildColumns( );
102 :
103 : virtual void disposeColumns();
104 :
105 : // IRefreshableColumns overridables
106 : virtual void refreshColumns() SAL_OVERRIDE;
107 : };
108 :
109 : class OQueryDescriptor : public comphelper::OMutexAndBroadcastHelper
110 : ,public ::cppu::OWeakObject
111 : ,public OQueryDescriptor_Base
112 : ,public ::comphelper::OPropertyArrayUsageHelper< OQueryDescriptor_Base >
113 : ,public ODataSettings
114 : {
115 : OQueryDescriptor(const OQueryDescriptor&);
116 : void operator =(const OQueryDescriptor&);
117 : // helper
118 : void registerProperties();
119 : protected:
120 : // OPropertyArrayUsageHelper
121 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
122 :
123 : // OPropertySetHelper
124 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
125 :
126 : virtual ~OQueryDescriptor();
127 : public:
128 : OQueryDescriptor();
129 : OQueryDescriptor(const OQueryDescriptor_Base& _rSource);
130 :
131 : virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes()
132 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
133 : virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
134 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 :
136 : // ::com::sun::star::uno::XInterface
137 : DECLARE_XINTERFACE( )
138 :
139 : // ::com::sun::star::beans::XPropertySet
140 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 :
142 : };
143 : } // namespace dbaccess
144 :
145 : #endif // INCLUDED_DBACCESS_SOURCE_CORE_API_QUERYDESCRIPTOR_HXX
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|