2007-05-09 12:19:01 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=2:tabstop=2:
|
|
|
|
*/
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-05-09 12:19:01 +04:00
|
|
|
|
2012-10-05 17:04:59 +04:00
|
|
|
#include "ia2AccessibleValue.h"
|
2007-05-09 12:19:01 +04:00
|
|
|
|
|
|
|
#include "AccessibleValue_i.c"
|
|
|
|
|
2012-10-05 17:04:59 +04:00
|
|
|
#include "AccessibleWrap.h"
|
2012-11-28 14:28:02 +04:00
|
|
|
#include "Accessible-inl.h"
|
2013-05-05 09:38:14 +04:00
|
|
|
#include "IUnknownImpl.h"
|
2008-02-12 18:48:51 +03:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
#include "mozilla/FloatingPoint.h"
|
|
|
|
|
2012-11-18 06:01:44 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2007-05-09 12:19:01 +04:00
|
|
|
// IUnknown
|
|
|
|
|
|
|
|
STDMETHODIMP
|
2012-10-05 17:04:59 +04:00
|
|
|
ia2AccessibleValue::QueryInterface(REFIID iid, void** ppv)
|
2007-05-09 12:19:01 +04:00
|
|
|
{
|
2013-06-27 23:02:00 +04:00
|
|
|
if (!ppv)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2013-04-03 04:33:43 +04:00
|
|
|
*ppv = nullptr;
|
2007-05-09 12:19:01 +04:00
|
|
|
|
|
|
|
if (IID_IAccessibleValue == iid) {
|
2012-10-05 17:04:59 +04:00
|
|
|
AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
|
|
|
|
if (valueAcc->HasNumericValue()) {
|
|
|
|
*ppv = static_cast<IAccessibleValue*>(this);
|
|
|
|
valueAcc->AddRef();
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
2007-05-09 12:19:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IAccessibleValue
|
|
|
|
|
|
|
|
STDMETHODIMP
|
2012-10-05 17:04:59 +04:00
|
|
|
ia2AccessibleValue::get_currentValue(VARIANT* aCurrentValue)
|
2007-05-09 12:19:01 +04:00
|
|
|
{
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_BEGIN
|
|
|
|
|
2013-06-27 23:02:00 +04:00
|
|
|
if (!aCurrentValue)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2007-05-09 12:19:01 +04:00
|
|
|
VariantInit(aCurrentValue);
|
|
|
|
|
2012-10-05 17:04:59 +04:00
|
|
|
AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
|
2015-04-29 21:51:13 +03:00
|
|
|
double currentValue;
|
2016-08-18 10:30:21 +03:00
|
|
|
if (valueAcc->IsProxy()) {
|
|
|
|
currentValue = valueAcc->Proxy()->CurValue();
|
|
|
|
} else {
|
|
|
|
if (valueAcc->IsDefunct())
|
|
|
|
return CO_E_OBJNOTCONNECTED;
|
2016-07-22 23:20:42 +03:00
|
|
|
|
2016-08-18 10:30:21 +03:00
|
|
|
currentValue = valueAcc->CurValue();
|
|
|
|
}
|
2016-07-22 23:20:42 +03:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
if (IsNaN(currentValue))
|
|
|
|
return S_FALSE;
|
2007-05-09 12:19:01 +04:00
|
|
|
|
|
|
|
aCurrentValue->vt = VT_R8;
|
|
|
|
aCurrentValue->dblVal = currentValue;
|
2008-03-30 07:24:02 +04:00
|
|
|
return S_OK;
|
2007-05-09 12:19:01 +04:00
|
|
|
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_END
|
2007-05-09 12:19:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP
|
2012-10-05 17:04:59 +04:00
|
|
|
ia2AccessibleValue::setCurrentValue(VARIANT aValue)
|
2007-05-09 12:19:01 +04:00
|
|
|
{
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_BEGIN
|
|
|
|
|
2015-04-29 21:51:13 +03:00
|
|
|
if (aValue.vt != VT_R8)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2012-10-05 17:04:59 +04:00
|
|
|
AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
|
2016-08-18 10:30:21 +03:00
|
|
|
if (valueAcc->IsProxy())
|
|
|
|
return valueAcc->Proxy()->SetCurValue(aValue.dblVal) ? S_OK : E_FAIL;
|
2015-04-29 21:51:13 +03:00
|
|
|
|
2012-10-05 17:04:59 +04:00
|
|
|
if (valueAcc->IsDefunct())
|
|
|
|
return CO_E_OBJNOTCONNECTED;
|
2007-05-09 12:19:01 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
return valueAcc->SetCurValue(aValue.dblVal) ? S_OK : E_FAIL;
|
2008-02-12 18:48:51 +03:00
|
|
|
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_END
|
2007-05-09 12:19:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP
|
2012-10-05 17:04:59 +04:00
|
|
|
ia2AccessibleValue::get_maximumValue(VARIANT* aMaximumValue)
|
2007-05-09 12:19:01 +04:00
|
|
|
{
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_BEGIN
|
|
|
|
|
2013-06-27 23:02:00 +04:00
|
|
|
if (!aMaximumValue)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2007-05-09 12:19:01 +04:00
|
|
|
VariantInit(aMaximumValue);
|
|
|
|
|
2012-10-05 17:04:59 +04:00
|
|
|
AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
|
2015-04-29 21:51:13 +03:00
|
|
|
double maximumValue;
|
2016-08-18 10:30:21 +03:00
|
|
|
if (valueAcc->IsProxy()) {
|
|
|
|
maximumValue = valueAcc->Proxy()->MaxValue();
|
|
|
|
} else {
|
|
|
|
if (valueAcc->IsDefunct())
|
|
|
|
return CO_E_OBJNOTCONNECTED;
|
2016-07-22 23:20:42 +03:00
|
|
|
|
2016-08-18 10:30:21 +03:00
|
|
|
maximumValue = valueAcc->MaxValue();
|
|
|
|
}
|
2016-07-22 23:20:42 +03:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
if (IsNaN(maximumValue))
|
|
|
|
return S_FALSE;
|
2007-05-09 12:19:01 +04:00
|
|
|
|
|
|
|
aMaximumValue->vt = VT_R8;
|
|
|
|
aMaximumValue->dblVal = maximumValue;
|
2008-03-30 07:24:02 +04:00
|
|
|
return S_OK;
|
2007-05-09 12:19:01 +04:00
|
|
|
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_END
|
2007-05-09 12:19:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP
|
2012-10-05 17:04:59 +04:00
|
|
|
ia2AccessibleValue::get_minimumValue(VARIANT* aMinimumValue)
|
2007-05-09 12:19:01 +04:00
|
|
|
{
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_BEGIN
|
|
|
|
|
2013-06-27 23:02:00 +04:00
|
|
|
if (!aMinimumValue)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2007-05-09 12:19:01 +04:00
|
|
|
VariantInit(aMinimumValue);
|
|
|
|
|
2012-10-05 17:04:59 +04:00
|
|
|
AccessibleWrap* valueAcc = static_cast<AccessibleWrap*>(this);
|
2015-04-29 21:51:13 +03:00
|
|
|
double minimumValue;
|
2016-08-18 10:30:21 +03:00
|
|
|
if (valueAcc->IsProxy()) {
|
|
|
|
minimumValue = valueAcc->Proxy()->MinValue();
|
|
|
|
} else {
|
|
|
|
if (valueAcc->IsDefunct())
|
|
|
|
return CO_E_OBJNOTCONNECTED;
|
2016-07-22 23:20:42 +03:00
|
|
|
|
2016-08-18 10:30:21 +03:00
|
|
|
minimumValue = valueAcc->MinValue();
|
|
|
|
}
|
2016-07-22 23:20:42 +03:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
if (IsNaN(minimumValue))
|
|
|
|
return S_FALSE;
|
2007-05-09 12:19:01 +04:00
|
|
|
|
|
|
|
aMinimumValue->vt = VT_R8;
|
|
|
|
aMinimumValue->dblVal = minimumValue;
|
2008-03-30 07:24:02 +04:00
|
|
|
return S_OK;
|
2007-05-09 12:19:01 +04:00
|
|
|
|
2012-11-28 14:27:20 +04:00
|
|
|
A11Y_TRYBLOCK_END
|
2007-05-09 12:19:01 +04:00
|
|
|
}
|
|
|
|
|