summaryrefslogtreecommitdiff
path: root/include/svx/dataaccessdescriptor.hxx
blob: 9449d8fbd051eea46b1fce0acfd6b9fbc332f6b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_SVX_DATAACCESSDESCRIPTOR_HXX
#define INCLUDED_SVX_DATAACCESSDESCRIPTOR_HXX

#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <svx/svxdllapi.h>
#include <memory>

namespace svx
{
    class ODADescriptorImpl;

    //= DataAccessDescriptorProperty
    enum class DataAccessDescriptorProperty
    {
        DataSource,           /// data source name            (string)
        DatabaseLocation,     /// database file URL           (string)
        ConnectionResource,   /// database driver URL         (string)
        Connection,           /// connection                  (XConnection)

        Command,              /// command                     (string)
        CommandType,          /// command type                (long)
        EscapeProcessing,     /// escape processing           (boolean)
        Filter,               /// additional filter           (string)
        Cursor,               /// the cursor                  (XResultSet)

        ColumnName,           /// column name                 (string)
        ColumnObject,         /// column object               (XPropertySet)

        Selection,            /// selection                   (sequence< any >)
        BookmarkSelection,    /// selection are bookmarks?    (boolean)

        Component             /// component name              (XContent)
    };

    //= ODataAccessDescriptor

    /** class encapsulating the css::sdb::DataAccessDescriptor service.
    */
    class SAL_WARN_UNUSED SVX_DLLPUBLIC ODataAccessDescriptor
    {
    protected:
        std::unique_ptr<ODADescriptorImpl>      m_pImpl;

    public:
        ODataAccessDescriptor();
        ODataAccessDescriptor( const ODataAccessDescriptor& _rSource );
        ODataAccessDescriptor( ODataAccessDescriptor&& _rSource );
        ODataAccessDescriptor( const css::uno::Reference< css::beans::XPropertySet >& _rValues );
        ODataAccessDescriptor( const css::uno::Sequence< css::beans::PropertyValue >& _rValues );

        // allows to construct a descriptor from an Any containing either an XPropertySet or a property value sequence
        ODataAccessDescriptor( const css::uno::Any& _rValues );

        ODataAccessDescriptor& operator=(const ODataAccessDescriptor& _rSource);
        ODataAccessDescriptor& operator=(ODataAccessDescriptor&& _rSource);

        ~ODataAccessDescriptor();

        /** returns the descriptor as property value sequence
            <p>If you call this method more than once, without writing any values between both calls, the same object
            is returned. If you wrote values, a new object is returned.</p>
        */
        css::uno::Sequence< css::beans::PropertyValue >
                    createPropertyValueSequence();

        /** initialized the descriptor from the property values given
            The descriptor will clear all its current settings before
            initializing with the new ones.
        */
        void        initializeFrom(
                        const css::uno::Sequence< css::beans::PropertyValue >& _rValues);

        /// checks whether or not a given property is present in the descriptor
        bool        has(DataAccessDescriptorProperty _eWhich) const;

        /** erases the given property from the descriptor
        */
        void        erase(DataAccessDescriptorProperty _eWhich);

        /** empties the descriptor
        */
        void        clear();

        /// return the value of a given property
        const   css::uno::Any& operator [] ( DataAccessDescriptorProperty _eWhich ) const;

        /** return the (modifiable) value of a given property
            <p>This operator is not allowed to be called if the descriptor is readonly.</p>
        */
                css::uno::Any& operator [] ( DataAccessDescriptorProperty _eWhich );

        /** returns either the data source name if given or the database location
        */
        OUString getDataSource() const;

        /** set the data source name, if it is not file URL
            @param  _sDataSourceNameOrLocation
                the data source name or database location
        */
        void setDataSource(const OUString& _sDataSourceNameOrLocation);
    };

}

#endif // INCLUDED_SVX_DATAACCESSDESCRIPTOR_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */