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 .
23 #include "MAccessible.h"
25 #include <vcl/svapp.hxx>
27 #include <com/sun/star/accessibility/XAccessible.hpp>
28 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
30 using namespace com::sun::star::accessibility
;
31 using namespace com::sun::star::uno
;
35 * @param currentValue Variant that accepts current value.
39 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::get_currentValue(VARIANT
* currentValue
)
45 if (currentValue
== nullptr)
50 // Get Any type value from UNO.
51 css::uno::Any anyVal
= GetXInterface()->getCurrentValue();
52 // Convert Any to VARIANT.
53 CMAccessible::ConvertAnyToVariant(anyVal
, currentValue
);
65 * @param Value New value should be set.
66 * @param success If the method is successfully called.
69 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::setCurrentValue(VARIANT value
)
81 // Set value according to value type.
86 anyVal
<<= sal_Unicode(value
.bVal
);
92 css::uno::Type
typeInfo(TypeClass_BOOLEAN
, "bool");
93 anyVal
.setValue(&value
.boolVal
, typeInfo
);
99 css::uno::Type
typeInfo(TypeClass_SHORT
, "short");
100 anyVal
.setValue(&value
.iVal
, typeInfo
);
106 css::uno::Type
typeInfo(TypeClass_LONG
, "long");
107 anyVal
.setValue(&value
.lVal
, typeInfo
);
113 css::uno::Type
typeInfo(TypeClass_FLOAT
, "float");
114 anyVal
.setValue(&value
.fltVal
, typeInfo
);
120 css::uno::Type
typeInfo(TypeClass_DOUBLE
, "double");
121 anyVal
.setValue(&value
.dblVal
, typeInfo
);
127 // Unsupported type conversion.
135 hRet
= pRXVal
->setCurrentValue(anyVal
) ? S_OK
: E_FAIL
;
148 * @param maximumValue Variant that accepts maximum value.
151 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::get_maximumValue(VARIANT
* maximumValue
)
157 if (maximumValue
== nullptr)
162 // Get Any type value from UNO.
163 css::uno::Any anyVal
= GetXInterface()->getMaximumValue();
164 // Convert Any to VARIANT.
165 CMAccessible::ConvertAnyToVariant(anyVal
, maximumValue
);
177 * @param minimumValue Variant that accepts minimum value.
180 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::get_minimumValue(VARIANT
* minimumValue
)
186 if (minimumValue
== nullptr)
191 // Get Any type value from UNO.
192 css::uno::Any anyVal
= GetXInterface()->getMinimumValue();
193 // Convert Any to VARIANT.
194 CMAccessible::ConvertAnyToVariant(anyVal
, minimumValue
);
205 * Put valid UNO interface into com class.
206 * @param pXInterface UNO interface.
209 COM_DECLSPEC_NOTHROW STDMETHODIMP
CAccValue::put_XInterface(hyper pXInterface
)
211 // internal IUNOXWrapper - no mutex meeded
215 CUNOXWrapper::put_XInterface(pXInterface
);
217 if (pUNOInterface
== nullptr)
219 Reference
<XAccessibleContext
> pRContext
= pUNOInterface
->getAccessibleContext();
224 Reference
<XAccessibleValue
> pRXI(pRContext
, UNO_QUERY
);
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */