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 UCBHELPER_DLLPUBLIC 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 UCBHELPER_DLLPRIVATE
const css::uno::Reference
< css::script::XTypeConverter
>&
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
);
81 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
82 virtual ~PropertyValueSet() override
;
85 virtual sal_Bool SAL_CALL
87 virtual OUString SAL_CALL
88 getString( sal_Int32 columnIndex
) override
;
89 virtual sal_Bool SAL_CALL
90 getBoolean( sal_Int32 columnIndex
) override
;
91 virtual sal_Int8 SAL_CALL
92 getByte( sal_Int32 columnIndex
) override
;
93 virtual sal_Int16 SAL_CALL
94 getShort( sal_Int32 columnIndex
) override
;
95 virtual sal_Int32 SAL_CALL
96 getInt( sal_Int32 columnIndex
) override
;
97 virtual sal_Int64 SAL_CALL
98 getLong( sal_Int32 columnIndex
) override
;
99 virtual float SAL_CALL
100 getFloat( sal_Int32 columnIndex
) override
;
101 virtual double SAL_CALL
102 getDouble( sal_Int32 columnIndex
) override
;
103 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
104 getBytes( sal_Int32 columnIndex
) override
;
105 virtual css::util::Date SAL_CALL
106 getDate( sal_Int32 columnIndex
) override
;
107 virtual css::util::Time SAL_CALL
108 getTime( sal_Int32 columnIndex
) override
;
109 virtual css::util::DateTime SAL_CALL
110 getTimestamp( sal_Int32 columnIndex
) override
;
111 virtual css::uno::Reference
<
112 css::io::XInputStream
> SAL_CALL
113 getBinaryStream( sal_Int32 columnIndex
) override
;
114 virtual css::uno::Reference
<
115 css::io::XInputStream
> SAL_CALL
116 getCharacterStream( sal_Int32 columnIndex
) override
;
117 virtual css::uno::Any SAL_CALL
118 getObject( sal_Int32 columnIndex
,
119 const css::uno::Reference
<
120 css::container::XNameAccess
>& typeMap
) override
;
121 virtual css::uno::Reference
<
122 css::sdbc::XRef
> SAL_CALL
123 getRef( sal_Int32 columnIndex
) override
;
124 virtual css::uno::Reference
<
125 css::sdbc::XBlob
> SAL_CALL
126 getBlob( sal_Int32 columnIndex
) override
;
127 virtual css::uno::Reference
<
128 css::sdbc::XClob
> SAL_CALL
129 getClob( sal_Int32 columnIndex
) override
;
130 virtual css::uno::Reference
<
131 css::sdbc::XArray
> SAL_CALL
132 getArray( sal_Int32 columnIndex
) override
;
135 virtual sal_Int32 SAL_CALL
136 findColumn( const OUString
& columnName
) override
;
139 // Non-interface methods
141 void appendString( const OUString
& rPropName
, const OUString
& rValue
);
142 void appendString( const css::beans::Property
& rProp
, const OUString
& rValue
)
144 appendString( rProp
.Name
, rValue
);
147 void appendBoolean( const OUString
& rPropName
, bool bValue
);
148 void appendBoolean( const css::beans::Property
& rProp
, bool bValue
)
150 appendBoolean( rProp
.Name
, bValue
);
153 void appendLong( const OUString
& rPropName
, sal_Int64 nValue
);
154 void appendLong( const css::beans::Property
& rProp
, sal_Int64 nValue
)
156 appendLong( rProp
.Name
, nValue
);
159 void appendTimestamp( const OUString
& rPropName
, const css::util::DateTime
& rValue
);
160 void appendTimestamp( const css::beans::Property
& rProp
, const css::util::DateTime
& rValue
)
162 appendTimestamp( rProp
.Name
, rValue
);
165 void appendObject( const OUString
& rPropName
, const css::uno::Any
& rValue
);
166 void appendObject( const css::beans::Property
& rProp
, const css::uno::Any
& rValue
)
168 appendObject( rProp
.Name
, rValue
);
171 void appendVoid( const OUString
& rPropName
);
172 void appendVoid( const css::beans::Property
& rProp
)
174 appendVoid( rProp
.Name
);
178 * This method tries to append all property values contained in a
179 * property set to the value set.
181 * @param rSet is a property set containing the property values.
183 void appendPropertySet( const css::uno::Reference
< css::beans::XPropertySet
>& rSet
);
185 /** This method tries to append a single property value contained in a
186 * property set to the value set.
188 * @param rSet is a property set containing the property values.
189 * @param rProperty is the property for that the value shall be obtained
190 * from the given property set.
191 * @return False, if the property value cannot be obtained from the
192 * given property pet. True, otherwise.
194 bool appendPropertySetValue(
195 const css::uno::Reference
< css::beans::XPropertySet
>& rSet
,
196 const css::beans::Property
& rProperty
);
201 #endif /* ! INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX */
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */