xref: /AOO41X/main/svx/inc/svx/dataaccessdescriptor.hxx (revision 3334a7e6acdae9820fa1a6f556bb10129a8de6b2)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
25 #define _SVX_DATACCESSDESCRIPTOR_HXX_
26 
27 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include "svx/svxdllapi.h"
30 
31 //........................................................................
32 namespace svx
33 {
34 //........................................................................
35 
36     class ODADescriptorImpl;
37 
38     //====================================================================
39     //= DataAccessDescriptorProperty
40     //====================================================================
41     enum DataAccessDescriptorProperty
42     {
43         daDataSource,           /// data source name            (string)
44         daDatabaseLocation,     /// database file URL           (string)
45         daConnectionResource,   /// database driver URL         (string)
46         daConnection,           /// connection                  (XConnection)
47 
48         daCommand,              /// command                     (string)
49         daCommandType,          /// command type                (long)
50         daEscapeProcessing,     /// escape processing           (boolean)
51         daFilter,               /// additional filter           (string)
52         daCursor,               /// the cursor                  (XResultSet)
53 
54         daColumnName,           /// column name                 (string)
55         daColumnObject,         /// column object               (XPropertySet)
56 
57         daSelection,            /// selection                   (sequence< any >)
58         daBookmarkSelection,    /// selection are bookmarks?    (boolean)
59 
60         daComponent             /// component name              (XContent)
61     };
62 
63     //====================================================================
64     //= ODataAccessDescriptor
65     //====================================================================
66     /** class encapsulating the <type scope="com::sun::star::sdb">DataAccessDescriptor</type> service.
67     */
68     class SVX_DLLPUBLIC ODataAccessDescriptor
69     {
70     protected:
71         ODADescriptorImpl*      m_pImpl;
72 
73     public:
74         ODataAccessDescriptor();
75         ODataAccessDescriptor( const ODataAccessDescriptor& _rSource );
76         ODataAccessDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rValues );
77         ODataAccessDescriptor( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rValues );
78 
79         // allows to construct a descriptor from an Any containing either an XPropertySet or a property value sequence
80         ODataAccessDescriptor( const ::com::sun::star::uno::Any& _rValues );
81 
82         const ODataAccessDescriptor& operator=(const ODataAccessDescriptor& _rSource);
83 
84         ~ODataAccessDescriptor();
85 
86         /** returns the descriptor as property set
87             <p>If you call this method more than once, without writing any values between both calls, the same object
88             is returned. If you wrote values, a new object is returned.</p>
89         */
90         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
91                     createPropertySet();
92         /** returns the descriptor as property value sequence
93             <p>If you call this method more than once, without writing any values between both calls, the same object
94             is returned. If you wrote values, a new object is returned.</p>
95         */
96         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
97                     createPropertyValueSequence();
98 
99         /** returns the descriptor as Any sequence
100             <p>If you call this method more than once, without writing any values between both calls, the same object
101             is returned. If you wrote values, a new object is returned.</p>
102         */
103         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
104                     createAnySequence();
105 
106         /** initialized the descriptor from the property set given
107             <p>If <arg>_bClear</arg> is <TRUE/>, the descriptor will clear all it's current settings before
108             initializing with the new ones.</p>
109         */
110         void        initializeFrom(
111                         const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxValues,
112                         sal_Bool _bClear = sal_True);
113 
114         /** initialized the descriptor from the property values given
115             <p>If <arg>_bClear</arg> is <TRUE/>, the descriptor will clear all it's current settings before
116             initializing with the new ones.</p>
117         */
118         void        initializeFrom(
119                         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rValues,
120                         sal_Bool _bClear = sal_True);
121 
122         /// checks whether or not a given property is present in the descriptor
123         sal_Bool    has(DataAccessDescriptorProperty _eWhich) const;
124 
125         /** erases the given property from the descriptor
126         */
127         void        erase(DataAccessDescriptorProperty _eWhich);
128 
129         /** empties the descriptor
130         */
131         void        clear();
132 
133         /// return the value of a given property
134         const   ::com::sun::star::uno::Any& operator [] ( DataAccessDescriptorProperty _eWhich ) const;
135 
136         /** return the (modifiable) value of a given property
137             <p>This operator is not allowed to be called if the descriptor is readonly.</p>
138         */
139                 ::com::sun::star::uno::Any& operator [] ( DataAccessDescriptorProperty _eWhich );
140 
141 
142         /** returns either the data source name if given or the database location
143         */
144         ::rtl::OUString getDataSource() const;
145 
146 
147         /** set the data source name, if it is not file URL
148             @param  _sDataSourceNameOrLocation
149                 the data source name or database location
150         */
151         void setDataSource(const ::rtl::OUString& _sDataSourceNameOrLocation);
152     };
153 
154 //........................................................................
155 }   // namespace svx
156 //........................................................................
157 
158 #endif // _SVX_DATACCESSDESCRIPTOR_HXX_
159 
160 
161