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_UCBHELPER_PROPERTYVALUESET_HXX
21 #define INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX
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>
29 #include <ucbhelper/ucbhelperdllapi.h>
32 namespace com::sun::star::script
{
36 namespace com::sun::star::beans
{
40 namespace com::sun::star::uno
{ class XComponentContext
; }
43 namespace ucbhelper_impl
{ struct PropertyValue
; }
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.
57 class SAL_DLLPUBLIC_RTTI PropertyValueSet final
:
58 public cppu::WeakImplHelper
<
60 css::sdbc::XColumnLocate
>
62 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
63 css::uno::Reference
< css::script::XTypeConverter
> m_xTypeConverter
;
65 std::unique_ptr
<PropertyValues
> m_pValues
;
67 bool m_bTriedToGetTypeConverter
;
70 const css::uno::Reference
< css::script::XTypeConverter
>&
71 getTypeConverter(const std::unique_lock
<std::mutex
>& rGuard
);
73 template <class T
, T
ucbhelper_impl::PropertyValue::*_member_name_
>
74 T
getValue(PropsSet nTypeName
, sal_Int32 columnIndex
);
76 template <class T
, T
ucbhelper_impl::PropertyValue::*_member_name_
>
77 void appendValue(const OUString
& rPropName
, PropsSet nTypeName
, const T
& rValue
);
79 css::uno::Any
getObjectImpl(const std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 columnIndex
);
82 UCBHELPER_DLLPUBLIC
PropertyValueSet(
83 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
84 virtual ~PropertyValueSet() override
;
87 virtual sal_Bool SAL_CALL
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
;
137 virtual sal_Int32 SAL_CALL
138 findColumn( const OUString
& columnName
) override
;
141 // Non-interface methods
143 UCBHELPER_DLLPUBLIC
void appendString( const OUString
& rPropName
, const OUString
& rValue
);
144 void appendString( const css::beans::Property
& rProp
, const OUString
& rValue
)
146 appendString( rProp
.Name
, rValue
);
149 UCBHELPER_DLLPUBLIC
void appendBoolean( const OUString
& rPropName
, bool bValue
);
150 void appendBoolean( const css::beans::Property
& rProp
, bool bValue
)
152 appendBoolean( rProp
.Name
, bValue
);
155 UCBHELPER_DLLPUBLIC
void appendLong( const OUString
& rPropName
, sal_Int64 nValue
);
156 void appendLong( const css::beans::Property
& rProp
, sal_Int64 nValue
)
158 appendLong( rProp
.Name
, nValue
);
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
)
164 appendTimestamp( rProp
.Name
, rValue
);
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
)
170 appendObject( rProp
.Name
, rValue
);
173 UCBHELPER_DLLPUBLIC
void appendVoid( const OUString
& rPropName
);
174 void appendVoid( const css::beans::Property
& rProp
)
176 appendVoid( rProp
.Name
);
180 * This method tries to append all property values contained in a
181 * property set to the value set.
183 * @param rSet is a property set containing the property values.
185 UCBHELPER_DLLPUBLIC
void appendPropertySet( const css::uno::Reference
< css::beans::XPropertySet
>& rSet
);
187 /** This method tries to append a single property value contained in a
188 * property set to the value set.
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.
196 UCBHELPER_DLLPUBLIC
bool appendPropertySetValue(
197 const css::uno::Reference
< css::beans::XPropertySet
>& rSet
,
198 const css::beans::Property
& rProperty
);
203 #endif /* ! INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX */
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */