1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/windows/ia2/ia2AccessibleHypertext.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:expandtab:shiftwidth=2:tabstop=2: 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#include "ia2AccessibleHypertext.h" 1.12 + 1.13 +#include "AccessibleHypertext_i.c" 1.14 + 1.15 +#include "HyperTextAccessibleWrap.h" 1.16 +#include "IUnknownImpl.h" 1.17 + 1.18 +using namespace mozilla::a11y; 1.19 + 1.20 +// IAccessibleHypertext 1.21 + 1.22 +STDMETHODIMP 1.23 +ia2AccessibleHypertext::get_nHyperlinks(long* aHyperlinkCount) 1.24 +{ 1.25 + A11Y_TRYBLOCK_BEGIN 1.26 + 1.27 + if (!aHyperlinkCount) 1.28 + return E_INVALIDARG; 1.29 + 1.30 + *aHyperlinkCount = 0; 1.31 + 1.32 + HyperTextAccessibleWrap* hyperText = static_cast<HyperTextAccessibleWrap*>(this); 1.33 + if (hyperText->IsDefunct()) 1.34 + return CO_E_OBJNOTCONNECTED; 1.35 + 1.36 + *aHyperlinkCount = hyperText->LinkCount(); 1.37 + return S_OK; 1.38 + 1.39 + A11Y_TRYBLOCK_END 1.40 +} 1.41 + 1.42 +STDMETHODIMP 1.43 +ia2AccessibleHypertext::get_hyperlink(long aLinkIndex, 1.44 + IAccessibleHyperlink** aHyperlink) 1.45 +{ 1.46 + A11Y_TRYBLOCK_BEGIN 1.47 + 1.48 + if (!aHyperlink) 1.49 + return E_INVALIDARG; 1.50 + 1.51 + *aHyperlink = nullptr; 1.52 + 1.53 + HyperTextAccessibleWrap* hyperText = static_cast<HyperTextAccessibleWrap*>(this); 1.54 + if (hyperText->IsDefunct()) 1.55 + return CO_E_OBJNOTCONNECTED; 1.56 + 1.57 + Accessible* hyperLink = hyperText->LinkAt(aLinkIndex); 1.58 + if (!hyperLink) 1.59 + return E_FAIL; 1.60 + 1.61 + *aHyperlink = 1.62 + static_cast<IAccessibleHyperlink*>(static_cast<AccessibleWrap*>(hyperLink)); 1.63 + (*aHyperlink)->AddRef(); 1.64 + return S_OK; 1.65 + 1.66 + A11Y_TRYBLOCK_END 1.67 +} 1.68 + 1.69 +STDMETHODIMP 1.70 +ia2AccessibleHypertext::get_hyperlinkIndex(long aCharIndex, long* aHyperlinkIndex) 1.71 +{ 1.72 + A11Y_TRYBLOCK_BEGIN 1.73 + 1.74 + if (!aHyperlinkIndex) 1.75 + return E_INVALIDARG; 1.76 + 1.77 + *aHyperlinkIndex = 0; 1.78 + 1.79 + HyperTextAccessibleWrap* hyperAcc = static_cast<HyperTextAccessibleWrap*>(this); 1.80 + if (hyperAcc->IsDefunct()) 1.81 + return CO_E_OBJNOTCONNECTED; 1.82 + 1.83 + *aHyperlinkIndex = hyperAcc->LinkIndexAtOffset(aCharIndex); 1.84 + return S_OK; 1.85 + 1.86 + A11Y_TRYBLOCK_END 1.87 +} 1.88 +