Bump version to 6.4-15
[LibreOffice.git] / include / ucbhelper / propertyvalueset.hxx
blobed3cd4671d125d781df275c0cfc0d7b780b61032
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_UCBHELPER_PROPERTYVALUESET_HXX
21 #define INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX
23 #include <com/sun/star/lang/XTypeProvider.hpp>
24 #include <com/sun/star/sdbc/XColumnLocate.hpp>
25 #include <com/sun/star/sdbc/XRow.hpp>
26 #include <com/sun/star/beans/Property.hpp>
27 #include <cppuhelper/implbase.hxx>
29 #include <osl/mutex.hxx>
30 #include <ucbhelper/ucbhelperdllapi.h>
31 #include <memory>
33 namespace com { namespace sun { namespace star { namespace script {
34 class XTypeConverter;
35 } } } }
37 namespace com { namespace sun { namespace star { namespace beans {
38 class XPropertySet;
39 } } } }
41 namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } }
43 enum class PropsSet;
44 namespace ucbhelper_impl { struct PropertyValue; }
46 namespace ucbhelper {
48 class PropertyValues;
51 /**
52 * This class implements the interface XRow. After construction of a valueset
53 * the user can append properties ( incl. its values ) to the set. This class
54 * is useful when implementing the command "getPropertyValues", because the
55 * values to return can easily appended to a valueset object. That object can
56 * directly be returned by the implementation of the command.
58 class UCBHELPER_DLLPUBLIC PropertyValueSet final :
59 public cppu::WeakImplHelper<
60 css::sdbc::XRow,
61 css::sdbc::XColumnLocate>
63 css::uno::Reference< css::uno::XComponentContext > m_xContext;
64 css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter;
65 osl::Mutex m_aMutex;
66 std::unique_ptr<PropertyValues> m_pValues;
67 bool m_bWasNull;
68 bool m_bTriedToGetTypeConverter;
70 private:
71 UCBHELPER_DLLPRIVATE const css::uno::Reference< css::script::XTypeConverter >&
72 getTypeConverter();
74 template <class T, T ucbhelper_impl::PropertyValue::*_member_name_>
75 T getValue(PropsSet nTypeName, sal_Int32 columnIndex);
77 template <class T, T ucbhelper_impl::PropertyValue::*_member_name_>
78 void appendValue(const OUString& rPropName, PropsSet nTypeName, const T& rValue);
80 public:
81 PropertyValueSet(
82 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
83 virtual ~PropertyValueSet() override;
85 // XRow
86 virtual sal_Bool SAL_CALL
87 wasNull() override;
88 virtual OUString SAL_CALL
89 getString( sal_Int32 columnIndex ) override;
90 virtual sal_Bool SAL_CALL
91 getBoolean( sal_Int32 columnIndex ) override;
92 virtual sal_Int8 SAL_CALL
93 getByte( sal_Int32 columnIndex ) override;
94 virtual sal_Int16 SAL_CALL
95 getShort( sal_Int32 columnIndex ) override;
96 virtual sal_Int32 SAL_CALL
97 getInt( sal_Int32 columnIndex ) override;
98 virtual sal_Int64 SAL_CALL
99 getLong( sal_Int32 columnIndex ) override;
100 virtual float SAL_CALL
101 getFloat( sal_Int32 columnIndex ) override;
102 virtual double SAL_CALL
103 getDouble( sal_Int32 columnIndex ) override;
104 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
105 getBytes( sal_Int32 columnIndex ) override;
106 virtual css::util::Date SAL_CALL
107 getDate( sal_Int32 columnIndex ) override;
108 virtual css::util::Time SAL_CALL
109 getTime( sal_Int32 columnIndex ) override;
110 virtual css::util::DateTime SAL_CALL
111 getTimestamp( sal_Int32 columnIndex ) override;
112 virtual css::uno::Reference<
113 css::io::XInputStream > SAL_CALL
114 getBinaryStream( sal_Int32 columnIndex ) override;
115 virtual css::uno::Reference<
116 css::io::XInputStream > SAL_CALL
117 getCharacterStream( sal_Int32 columnIndex ) override;
118 virtual css::uno::Any SAL_CALL
119 getObject( sal_Int32 columnIndex,
120 const css::uno::Reference<
121 css::container::XNameAccess >& typeMap ) override;
122 virtual css::uno::Reference<
123 css::sdbc::XRef > SAL_CALL
124 getRef( sal_Int32 columnIndex ) override;
125 virtual css::uno::Reference<
126 css::sdbc::XBlob > SAL_CALL
127 getBlob( sal_Int32 columnIndex ) override;
128 virtual css::uno::Reference<
129 css::sdbc::XClob > SAL_CALL
130 getClob( sal_Int32 columnIndex ) override;
131 virtual css::uno::Reference<
132 css::sdbc::XArray > SAL_CALL
133 getArray( sal_Int32 columnIndex ) override;
135 // XColumnLocate
136 virtual sal_Int32 SAL_CALL
137 findColumn( const OUString& columnName ) override;
140 // Non-interface methods
142 void appendString( const OUString& rPropName, const OUString& rValue );
143 void appendString( const css::beans::Property& rProp, const OUString& rValue )
145 appendString( rProp.Name, rValue );
148 void appendBoolean( const OUString& rPropName, bool bValue );
149 void appendBoolean( const css::beans::Property& rProp, bool bValue )
151 appendBoolean( rProp.Name, bValue );
154 void appendLong( const OUString& rPropName, sal_Int64 nValue );
155 void appendLong( const css::beans::Property& rProp, sal_Int64 nValue )
157 appendLong( rProp.Name, nValue );
160 void appendTimestamp( const OUString& rPropName, const css::util::DateTime& rValue );
161 void appendTimestamp( const css::beans::Property& rProp, const css::util::DateTime& rValue )
163 appendTimestamp( rProp.Name, rValue );
166 void appendObject( const OUString& rPropName, const css::uno::Any& rValue );
167 void appendObject( const css::beans::Property& rProp, const css::uno::Any& rValue )
169 appendObject( rProp.Name, rValue );
172 void appendVoid( const OUString& rPropName );
173 void appendVoid( const css::beans::Property& rProp )
175 appendVoid( rProp.Name );
179 * This method tries to append all property values contained in a
180 * property set to the value set.
182 * @param rSet is a property set containing the property values.
184 void appendPropertySet( const css::uno::Reference< css::beans::XPropertySet >& rSet );
186 /** This method tries to append a single property value contained in a
187 * property set to the value set.
189 * @param rSet is a property set containing the property values.
190 * @param rProperty is the property for that the value shall be obtained
191 * from the given property set.
192 * @return False, if the property value cannot be obtained from the
193 * given property pet. True, otherwise.
195 bool appendPropertySetValue(
196 const css::uno::Reference< css::beans::XPropertySet >& rSet,
197 const css::beans::Property& rProperty );
202 #endif /* ! INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX */
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */