Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/ucbhelper/propertyvalueset.hxx
Line
Count
Source
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_UCBHELPER_PROPERTYVALUESET_HXX
21
#define INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX
22
23
#include <com/sun/star/sdbc/XColumnLocate.hpp>
24
#include <com/sun/star/sdbc/XRow.hpp>
25
#include <com/sun/star/beans/Property.hpp>
26
#include <cppuhelper/implbase.hxx>
27
28
#include <mutex>
29
#include <ucbhelper/ucbhelperdllapi.h>
30
#include <memory>
31
32
namespace com::sun::star::script {
33
    class XTypeConverter;
34
}
35
36
namespace com::sun::star::beans {
37
    class XPropertySet;
38
}
39
40
namespace com::sun::star::uno { class XComponentContext; }
41
42
enum class PropsSet;
43
namespace ucbhelper_impl { struct PropertyValue; }
44
45
namespace ucbhelper {
46
47
class PropertyValues;
48
49
50
/**
51
  * This class implements the interface XRow. After construction of a valueset
52
  * the user can append properties ( incl. its values ) to the set. This class
53
  * is useful when implementing the command "getPropertyValues", because the
54
  * values to return can easily appended to a valueset object. That object can
55
  * directly be returned by the implementation of the command.
56
  */
57
class SAL_DLLPUBLIC_RTTI PropertyValueSet final :
58
                public cppu::WeakImplHelper<
59
                    css::sdbc::XRow,
60
                    css::sdbc::XColumnLocate>
61
{
62
    css::uno::Reference< css::uno::XComponentContext >   m_xContext;
63
    css::uno::Reference< css::script::XTypeConverter >   m_xTypeConverter;
64
    std::mutex      m_aMutex;
65
    std::unique_ptr<PropertyValues>                      m_pValues;
66
    bool        m_bWasNull;
67
    bool        m_bTriedToGetTypeConverter;
68
69
private:
70
    const css::uno::Reference< css::script::XTypeConverter >&
71
    getTypeConverter(const std::unique_lock<std::mutex>& rGuard);
72
73
    template <class T, T ucbhelper_impl::PropertyValue::*_member_name_>
74
    T getValue(PropsSet nTypeName, sal_Int32 columnIndex);
75
76
    template <class T, T ucbhelper_impl::PropertyValue::*_member_name_>
77
    void appendValue(const OUString& rPropName, PropsSet nTypeName, const T& rValue);
78
79
    css::uno::Any getObjectImpl(const std::unique_lock<std::mutex>& rGuard, sal_Int32 columnIndex);
80
81
public:
82
    UCBHELPER_DLLPUBLIC PropertyValueSet(
83
            const css::uno::Reference< css::uno::XComponentContext >& rxContext );
84
    virtual ~PropertyValueSet() override;
85
86
    // XRow
87
    virtual sal_Bool SAL_CALL
88
    wasNull() override;
89
    virtual OUString SAL_CALL
90
    getString( sal_Int32 columnIndex ) override;
91
    virtual sal_Bool SAL_CALL
92
    getBoolean( sal_Int32 columnIndex ) override;
93
    virtual sal_Int8 SAL_CALL
94
    getByte( sal_Int32 columnIndex ) override;
95
    virtual sal_Int16 SAL_CALL
96
    getShort( sal_Int32 columnIndex ) override;
97
    virtual sal_Int32 SAL_CALL
98
    getInt( sal_Int32 columnIndex ) override;
99
    virtual sal_Int64 SAL_CALL
100
    getLong( sal_Int32 columnIndex ) override;
101
    virtual float SAL_CALL
102
    getFloat( sal_Int32 columnIndex ) override;
103
    virtual double SAL_CALL
104
    getDouble( sal_Int32 columnIndex ) override;
105
    virtual css::uno::Sequence< sal_Int8 > SAL_CALL
106
    getBytes( sal_Int32 columnIndex ) override;
107
    virtual css::util::Date SAL_CALL
108
    getDate( sal_Int32 columnIndex ) override;
109
    virtual css::util::Time SAL_CALL
110
    getTime( sal_Int32 columnIndex ) override;
111
    virtual css::util::DateTime SAL_CALL
112
    getTimestamp( sal_Int32 columnIndex ) override;
113
    virtual css::uno::Reference<
114
                css::io::XInputStream > SAL_CALL
115
    getBinaryStream( sal_Int32 columnIndex ) override;
116
    virtual css::uno::Reference<
117
                css::io::XInputStream > SAL_CALL
118
    getCharacterStream( sal_Int32 columnIndex ) override;
119
    virtual css::uno::Any SAL_CALL
120
    getObject( sal_Int32 columnIndex,
121
               const css::uno::Reference<
122
                   css::container::XNameAccess >& typeMap ) override;
123
    virtual css::uno::Reference<
124
                css::sdbc::XRef > SAL_CALL
125
    getRef( sal_Int32 columnIndex ) override;
126
    virtual css::uno::Reference<
127
                css::sdbc::XBlob > SAL_CALL
128
    getBlob( sal_Int32 columnIndex ) override;
129
    virtual css::uno::Reference<
130
                css::sdbc::XClob > SAL_CALL
131
    getClob( sal_Int32 columnIndex ) override;
132
    virtual css::uno::Reference<
133
                css::sdbc::XArray > SAL_CALL
134
    getArray( sal_Int32 columnIndex ) override;
135
136
    // XColumnLocate
137
    virtual sal_Int32 SAL_CALL
138
    findColumn( const OUString& columnName ) override;
139
140
141
    // Non-interface methods
142
143
    UCBHELPER_DLLPUBLIC void appendString( const OUString& rPropName, const OUString& rValue );
144
    void appendString( const css::beans::Property& rProp, const OUString& rValue )
145
0
    {
146
0
        appendString( rProp.Name, rValue );
147
0
    }
148
149
    UCBHELPER_DLLPUBLIC void appendBoolean( const OUString& rPropName, bool bValue );
150
    void appendBoolean( const css::beans::Property& rProp, bool bValue )
151
0
    {
152
0
        appendBoolean( rProp.Name, bValue );
153
0
    }
154
155
    UCBHELPER_DLLPUBLIC void appendLong( const OUString& rPropName, sal_Int64 nValue );
156
    void appendLong( const css::beans::Property& rProp, sal_Int64 nValue )
157
0
    {
158
0
        appendLong( rProp.Name, nValue );
159
0
    }
160
161
    UCBHELPER_DLLPUBLIC void appendTimestamp( const OUString& rPropName, const css::util::DateTime& rValue );
162
    void appendTimestamp( const css::beans::Property& rProp, const css::util::DateTime& rValue )
163
0
    {
164
0
        appendTimestamp( rProp.Name, rValue );
165
0
    }
166
167
    UCBHELPER_DLLPUBLIC void appendObject( const OUString& rPropName, const css::uno::Any& rValue );
168
    void appendObject( const css::beans::Property& rProp, const css::uno::Any& rValue )
169
0
    {
170
0
        appendObject( rProp.Name, rValue );
171
0
    }
172
173
    UCBHELPER_DLLPUBLIC void appendVoid( const OUString& rPropName );
174
    void appendVoid( const css::beans::Property& rProp )
175
0
    {
176
0
        appendVoid( rProp.Name );
177
0
    }
178
179
    /**
180
      * This method tries to append all property values contained in a
181
      * property set to the value set.
182
      *
183
       *    @param  rSet is a property set containing the property values.
184
      */
185
    UCBHELPER_DLLPUBLIC void appendPropertySet( const css::uno::Reference< css::beans::XPropertySet >& rSet );
186
187
    /** This method tries to append a single property value contained in a
188
      * property set to the value set.
189
      *
190
       *    @param  rSet is a property set containing the property values.
191
       *    @param  rProperty is the property for that the value shall be obtained
192
      *         from the given property set.
193
       *    @return False, if the property value cannot be obtained from the
194
      *         given property pet. True, otherwise.
195
       */
196
    UCBHELPER_DLLPUBLIC bool appendPropertySetValue(
197
                        const css::uno::Reference< css::beans::XPropertySet >& rSet,
198
                        const css::beans::Property& rProperty );
199
};
200
201
}
202
203
#endif /* ! INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX */
204
205
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */