LibreOffice Module framework (master) 1
actiontriggerseparatorpropertyset.cxx
Go to the documentation of this file.
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
21#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <vcl/svapp.hxx>
27
28using namespace cppu;
29using namespace com::sun::star::uno;
30using namespace com::sun::star::beans;
31using namespace com::sun::star::lang;
32using namespace com::sun::star::awt;
33
34namespace {
35
36// Handles for properties
37// (PLEASE SORT THIS FIELD, IF YOU ADD NEW PROPERTIES!)
38// We use an enum to define these handles, to use all numbers from 0 to nn and
39// if you add someone, you don't must control this!
40// But don't forget to change values of follow defines, if you do something with this enum!
41enum EPROPERTIES
42{
43 HANDLE_TYPE,
45};
46
47}
48
49namespace framework
50{
51
54 , OPropertySetHelper ( *static_cast< OBroadcastHelper * >(this) )
55 , m_nSeparatorType( 0 )
56{
57}
58
60{
61}
62
63// XInterface
65{
66 Any a = ::cppu::queryInterface(
67 aType,
68 static_cast< XServiceInfo* >(this),
69 static_cast< XTypeProvider* >(this));
70
71 if( a.hasValue() )
72 return a;
73 else
74 {
75 a = OPropertySetHelper::queryInterface( aType );
76
77 if( a.hasValue() )
78 return a;
79 }
80
81 return OWeakObject::queryInterface( aType );
82}
83
85{
86 OWeakObject::acquire();
87}
88
90{
91 OWeakObject::release();
92}
93
94// XServiceInfo
96{
98}
99
101{
103}
104
106{
108 return seqServiceNames;
109}
110
111// XTypeProvider
113{
114 // Create a static typecollection ...
115 static ::cppu::OTypeCollection ourTypeCollection(
121
122 return ourTypeCollection.getTypes();
123}
124
126{
127 return css::uno::Sequence<sal_Int8>();
128}
129
131 Any& aConvertedValue,
132 Any& aOldValue,
133 sal_Int32 nHandle,
134 const Any& aValue )
135{
136 // Check, if value of property will changed in method "setFastPropertyValue_NoBroadcast()".
137 // Return sal_True, if changed - else return sal_False.
138 // Attention: Method "impl_tryToChangeProperty()" can throw the IllegalArgumentException !!!
139 // Initialize return value with sal_False !!!
140 // (Handle can be invalid)
141 bool bReturn = false;
142
143 switch( nHandle )
144 {
145 case HANDLE_TYPE:
146 bReturn = impl_tryToChangeProperty( m_nSeparatorType, aValue, aOldValue, aConvertedValue );
147 break;
148 }
149
150 // Return state of operation.
151 return bReturn;
152}
153
155 sal_Int32 nHandle, const Any& aValue )
156{
157 SolarMutexGuard aGuard;
158
159 // Search for right handle ... and try to set property value.
160 switch( nHandle )
161 {
162 case HANDLE_TYPE:
163 aValue >>= m_nSeparatorType;
164 break;
165 }
166}
167
169 Any& aValue, sal_Int32 nHandle ) const
170{
171 SolarMutexGuard aGuard;
172
173 // Search for right handle ... and try to get property value.
174 switch( nHandle )
175 {
176 case HANDLE_TYPE:
177 aValue <<= m_nSeparatorType;
178 break;
179 }
180}
181
183{
184 // Define static member to give structure of properties to baseclass "OPropertySetHelper".
185 // "impl_getStaticPropertyDescriptor" is a non exported and static function, who will define a static propertytable.
186 // "true" indicates: Table is sorted by name.
187 static OPropertyArrayHelper ourInfoHelper( impl_getStaticPropertyDescriptor(), true );
188
189 return ourInfoHelper;
190}
191
193{
194 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
195 // (Use method "getInfoHelper()".)
197
198 return xInfo;
199}
200
202{
203 return
204 {
205 Property( "SeparatorType", HANDLE_TYPE, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::TRANSIENT )
206 };
207}
208
210 sal_Int16 aCurrentValue ,
211 const Any& aNewValue ,
212 Any& aOldValue ,
213 Any& aConvertedValue )
214{
215 // Set default return value if method failed.
216 bool bReturn = false;
217 // Get new value from any.
218 // IllegalArgumentException() can be thrown!
219 sal_Int16 aValue = 0;
220 convertPropertyValue( aValue, aNewValue );
221
222 // If value change ...
223 if( aValue != aCurrentValue )
224 {
225 // ... set information of change.
226 aOldValue <<= aCurrentValue;
227 aConvertedValue <<= aValue;
228 // Return OK - "value will be change ..."
229 bReturn = true;
230 }
231 else
232 {
233 // ... clear information of return parameter!
234 aOldValue.clear ();
235 aConvertedValue.clear ();
236 // Return NOTHING - "value will not be change ..."
237 bReturn = false;
238 }
239
240 return bReturn;
241}
242
243}
244
245/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral IMPLEMENTATIONNAME_ACTIONTRIGGERSEPARATOR
constexpr OUStringLiteral SERVICENAME_ACTIONTRIGGERSEPARATOR
static css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL createPropertySetInfo(IPropertyArrayHelper &rProperties)
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &aValue, sal_Int32 nHandle) const override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor()
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
bool impl_tryToChangeProperty(sal_Int16 aCurrentValue, const css::uno::Any &aNewValue, css::uno::Any &aOldValue, css::uno::Any &aConvertedValue)
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &aConvertedValue, css::uno::Any &aOldValue, sal_Int32 nHandle, const css::uno::Any &aValue) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &aValue) override
#define PROPERTYCOUNT
uno_Any a
Type
void SAL_CALL convertPropertyValue(target &value, const css::uno::Any &a)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_Int32 nHandle
unsigned char sal_Bool
std::mutex m_aMutex