Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / ucbhelper / propertyvalueset.hxx
blobdcc48170e8a458a61638d8541cf4f760b2667971
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/weak.hxx>
29 #include <osl/mutex.hxx>
30 #include <ucbhelper/macros.hxx>
31 #include <ucbhelper/ucbhelperdllapi.h>
32 #include <memory>
34 namespace com { namespace sun { namespace star { namespace script {
35 class XTypeConverter;
36 } } } }
38 namespace com { namespace sun { namespace star { namespace beans {
39 struct PropertyValue;
40 class XPropertySet;
41 } } } }
43 namespace ucbhelper {
45 class PropertyValues;
48 /**
49 * This class implements the interface XRow. After construction of a valueset
50 * the user can append properties ( incl. its values ) to the set. This class
51 * is useful when implementing the command "getPropertyValues", because the
52 * values to return can easily appended to a valueset object. That object can
53 * directly be returned by the implementation of the command.
55 class UCBHELPER_DLLPUBLIC PropertyValueSet :
56 public cppu::OWeakObject,
57 public css::lang::XTypeProvider,
58 public css::sdbc::XRow,
59 public css::sdbc::XColumnLocate
61 css::uno::Reference< css::uno::XComponentContext > m_xContext;
62 css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter;
63 osl::Mutex m_aMutex;
64 std::unique_ptr<PropertyValues> m_pValues;
65 bool m_bWasNull;
66 bool m_bTriedToGetTypeConverter;
68 private:
69 UCBHELPER_DLLPRIVATE const css::uno::Reference< css::script::XTypeConverter >&
70 getTypeConverter();
72 public:
73 PropertyValueSet(
74 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
75 virtual ~PropertyValueSet() override;
77 // XInterface
78 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
79 virtual void SAL_CALL acquire()
80 throw() override;
81 virtual void SAL_CALL release()
82 throw() override;
84 // XTypeProvider
85 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
86 getImplementationId() override;
87 virtual css::uno::Sequence< css::uno::Type > SAL_CALL
88 getTypes() override;
90 // XRow
91 virtual sal_Bool SAL_CALL
92 wasNull() override;
93 virtual OUString SAL_CALL
94 getString( sal_Int32 columnIndex ) override;
95 virtual sal_Bool SAL_CALL
96 getBoolean( sal_Int32 columnIndex ) override;
97 virtual sal_Int8 SAL_CALL
98 getByte( sal_Int32 columnIndex ) override;
99 virtual sal_Int16 SAL_CALL
100 getShort( sal_Int32 columnIndex ) override;
101 virtual sal_Int32 SAL_CALL
102 getInt( sal_Int32 columnIndex ) override;
103 virtual sal_Int64 SAL_CALL
104 getLong( sal_Int32 columnIndex ) override;
105 virtual float SAL_CALL
106 getFloat( sal_Int32 columnIndex ) override;
107 virtual double SAL_CALL
108 getDouble( sal_Int32 columnIndex ) override;
109 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
110 getBytes( sal_Int32 columnIndex ) override;
111 virtual css::util::Date SAL_CALL
112 getDate( sal_Int32 columnIndex ) override;
113 virtual css::util::Time SAL_CALL
114 getTime( sal_Int32 columnIndex ) override;
115 virtual css::util::DateTime SAL_CALL
116 getTimestamp( sal_Int32 columnIndex ) override;
117 virtual css::uno::Reference<
118 css::io::XInputStream > SAL_CALL
119 getBinaryStream( sal_Int32 columnIndex ) override;
120 virtual css::uno::Reference<
121 css::io::XInputStream > SAL_CALL
122 getCharacterStream( sal_Int32 columnIndex ) override;
123 virtual css::uno::Any SAL_CALL
124 getObject( sal_Int32 columnIndex,
125 const css::uno::Reference<
126 css::container::XNameAccess >& typeMap ) override;
127 virtual css::uno::Reference<
128 css::sdbc::XRef > SAL_CALL
129 getRef( sal_Int32 columnIndex ) override;
130 virtual css::uno::Reference<
131 css::sdbc::XBlob > SAL_CALL
132 getBlob( sal_Int32 columnIndex ) override;
133 virtual css::uno::Reference<
134 css::sdbc::XClob > SAL_CALL
135 getClob( sal_Int32 columnIndex ) override;
136 virtual css::uno::Reference<
137 css::sdbc::XArray > SAL_CALL
138 getArray( sal_Int32 columnIndex ) override;
140 // XColumnLocate
141 virtual sal_Int32 SAL_CALL
142 findColumn( const OUString& columnName ) override;
145 // Non-interface methods
147 void appendString( const OUString& rPropName, const OUString& rValue );
148 void appendString( const css::beans::Property& rProp, const OUString& rValue )
150 appendString( rProp.Name, rValue );
153 void appendBoolean( const OUString& rPropName, bool bValue );
154 void appendBoolean( const css::beans::Property& rProp, bool bValue )
156 appendBoolean( rProp.Name, bValue );
159 void appendLong( const OUString& rPropName, sal_Int64 nValue );
160 void appendLong( const css::beans::Property& rProp, sal_Int64 nValue )
162 appendLong( rProp.Name, nValue );
165 void appendTimestamp( const OUString& rPropName, const css::util::DateTime& rValue );
166 void appendTimestamp( const css::beans::Property& rProp, const css::util::DateTime& rValue )
168 appendTimestamp( rProp.Name, rValue );
171 void appendObject( const OUString& rPropName, const css::uno::Any& rValue );
172 void appendObject( const css::beans::Property& rProp, const css::uno::Any& rValue )
174 appendObject( rProp.Name, rValue );
177 void appendVoid( const OUString& rPropName );
178 void appendVoid( const css::beans::Property& rProp )
180 appendVoid( rProp.Name );
184 * This method tries to append all property values contained in a
185 * property set to the value set.
187 * @param rSet is a property set containing the property values.
189 void appendPropertySet( const css::uno::Reference< css::beans::XPropertySet >& rSet );
191 /** This method tries to append a single property value contained in a
192 * property set to the value set.
194 * @param rSet is a property set containing the property values.
195 * @param rProperty is the property for that the value shall be obtained
196 * from the given property set.
197 * @return False, if the property value cannot be obtained from the
198 * given property pet. True, otherwise.
200 bool appendPropertySetValue(
201 const css::uno::Reference< css::beans::XPropertySet >& rSet,
202 const css::beans::Property& rProperty );
207 #endif /* ! INCLUDED_UCBHELPER_PROPERTYVALUESET_HXX */
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */