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 .
22 #include "MAccessible.h"
25 #pragma clang diagnostic push
26 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
30 #pragma clang diagnostic pop
33 #include <vcl/svapp.hxx>
35 #include <com/sun/star/accessibility/XAccessible.hpp>
36 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
38 using namespace com::sun::star::accessibility
;
39 using namespace com::sun::star::uno
;
43 * @param currentValue Variant that accepts current value.
47 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::get_currentValue(VARIANT
* currentValue
)
53 if (currentValue
== nullptr)
58 // Get Any type value from UNO.
59 css::uno::Any anyVal
= GetXInterface()->getCurrentValue();
60 // Convert Any to VARIANT.
61 CMAccessible::ConvertAnyToVariant(anyVal
, currentValue
);
70 * @param Value New value should be set.
71 * @param success If the method is successfully called.
74 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::setCurrentValue(VARIANT value
)
86 // Set value according to value type.
91 anyVal
<<= sal_Unicode(value
.bVal
);
97 css::uno::Type
typeInfo(TypeClass_BOOLEAN
, "bool");
98 anyVal
.setValue(&value
.boolVal
, typeInfo
);
104 css::uno::Type
typeInfo(TypeClass_SHORT
, "short");
105 anyVal
.setValue(&value
.iVal
, typeInfo
);
111 css::uno::Type
typeInfo(TypeClass_LONG
, "long");
112 anyVal
.setValue(&value
.lVal
, typeInfo
);
118 css::uno::Type
typeInfo(TypeClass_FLOAT
, "float");
119 anyVal
.setValue(&value
.fltVal
, typeInfo
);
125 css::uno::Type
typeInfo(TypeClass_DOUBLE
, "double");
126 anyVal
.setValue(&value
.dblVal
, typeInfo
);
132 // Unsupported type conversion.
140 hRet
= pRXVal
->setCurrentValue(anyVal
) ? S_OK
: E_FAIL
;
145 LEAVE_PROTECTED_BLOCK
150 * @param maximumValue Variant that accepts maximum value.
153 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::get_maximumValue(VARIANT
*maximumValue
)
157 ENTER_PROTECTED_BLOCK
159 if (maximumValue
== nullptr)
164 // Get Any type value from UNO.
165 css::uno::Any anyVal
= GetXInterface()->getMaximumValue();
166 // Convert Any to VARIANT.
167 CMAccessible::ConvertAnyToVariant(anyVal
, maximumValue
);
171 LEAVE_PROTECTED_BLOCK
176 * @param mininumValue Variant that accepts minimum value.
179 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::get_minimumValue(VARIANT
*mininumValue
)
183 ENTER_PROTECTED_BLOCK
185 if (mininumValue
== nullptr)
190 // Get Any type value from UNO.
191 css::uno::Any anyVal
= GetXInterface()->getMinimumValue();
192 // Convert Any to VARIANT.
193 CMAccessible::ConvertAnyToVariant(anyVal
, mininumValue
);
197 LEAVE_PROTECTED_BLOCK
201 * Put valid UNO interface into com class.
202 * @param pXInterface UNO interface.
205 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::put_XInterface(hyper pXInterface
)
207 // internal IUNOXWrapper - no mutex meeded
209 ENTER_PROTECTED_BLOCK
211 CUNOXWrapper::put_XInterface(pXInterface
);
213 if(pUNOInterface
== nullptr)
215 Reference
<XAccessibleContext
> pRContext
= pUNOInterface
->getAccessibleContext();
216 if( !pRContext
.is() )
220 Reference
<XAccessibleValue
> pRXI(pRContext
,UNO_QUERY
);
227 LEAVE_PROTECTED_BLOCK
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */