1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_DBACCESS_SOURCE_CORE_API_QUERYDESCRIPTOR_HXX
21 #define INCLUDED_DBACCESS_SOURCE_CORE_API_QUERYDESCRIPTOR_HXX
23 #include <cppuhelper/implbase3.hxx>
24 #include <comphelper/proparrhlp.hxx>
25 #include <osl/mutex.hxx>
27 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include "apitools.hxx"
33 #include "datasettings.hxx"
34 #include "commandbase.hxx"
35 #include <comphelper/broadcasthelper.hxx>
36 #include <comphelper/uno3.hxx>
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
;
47 class OQueryDescriptor_Base
48 :public OQueryDescriptor_BASE
50 ,public IColumnFactory
51 ,public ::connectivity::sdbcx::IRefreshableColumns
54 bool m_bColumnsOutOfDate
: 1; // the columns have to be rebuild on the next getColumns ?
55 ::osl::Mutex
& m_rMutex
;
58 OColumns
* m_pColumns
; // our column descriptions
59 OUString m_sElementName
;
60 virtual ~OQueryDescriptor_Base();
62 void setColumnsOutOfDate( bool _bOutOfDate
= true );
63 bool isColumnsOutOfDate() const { return m_bColumnsOutOfDate
; }
65 sal_Int32
getColumnCount() const { return m_pColumns
? m_pColumns
->getCount() : 0; }
68 void implAppendColumn( const OUString
& _rName
, OColumn
* _pColumn
);
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)
75 OQueryDescriptor_Base(const OQueryDescriptor_Base
& _rSource
,::cppu::OWeakObject
& _rMySelf
);
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
;
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( );
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
;
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
;
97 /** rebuild our columns set
99 clearColumns has already been called before, do <em>NOT</em> call it, again
101 virtual void rebuildColumns( );
103 virtual void disposeColumns();
105 // IRefreshableColumns overridables
106 virtual void refreshColumns() SAL_OVERRIDE
;
109 class OQueryDescriptor
: public comphelper::OMutexAndBroadcastHelper
110 ,public ::cppu::OWeakObject
111 ,public OQueryDescriptor_Base
112 ,public ::comphelper::OPropertyArrayUsageHelper
< OQueryDescriptor_Base
>
113 ,public ODataSettings
115 OQueryDescriptor(const OQueryDescriptor
&) SAL_DELETED_FUNCTION
;
116 void operator =(const OQueryDescriptor
&) SAL_DELETED_FUNCTION
;
118 void registerProperties();
120 // OPropertyArrayUsageHelper
121 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const SAL_OVERRIDE
;
123 // OPropertySetHelper
124 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
126 virtual ~OQueryDescriptor();
129 OQueryDescriptor(const OQueryDescriptor_Base
& _rSource
);
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
;
136 // ::com::sun::star::uno::XInterface
137 DECLARE_XINTERFACE( )
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
;
143 } // namespace dbaccess
145 #endif // INCLUDED_DBACCESS_SOURCE_CORE_API_QUERYDESCRIPTOR_HXX
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */