1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/windows/ia2/ia2AccessibleEditableText.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,143 @@ 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 "ia2AccessibleEditableText.h" 1.12 + 1.13 +#include "AccessibleEditableText_i.c" 1.14 +#include "HyperTextAccessible-inl.h" 1.15 +#include "HyperTextAccessibleWrap.h" 1.16 + 1.17 +#include "nsCOMPtr.h" 1.18 +#include "nsString.h" 1.19 + 1.20 +using namespace mozilla::a11y; 1.21 + 1.22 +// IAccessibleEditableText 1.23 + 1.24 +STDMETHODIMP 1.25 +ia2AccessibleEditableText::copyText(long aStartOffset, long aEndOffset) 1.26 +{ 1.27 + A11Y_TRYBLOCK_BEGIN 1.28 + 1.29 + HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); 1.30 + if (textAcc->IsDefunct()) 1.31 + return CO_E_OBJNOTCONNECTED; 1.32 + 1.33 + if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) 1.34 + return E_INVALIDARG; 1.35 + 1.36 + textAcc->CopyText(aStartOffset, aEndOffset); 1.37 + return S_OK; 1.38 + 1.39 + A11Y_TRYBLOCK_END 1.40 +} 1.41 + 1.42 +STDMETHODIMP 1.43 +ia2AccessibleEditableText::deleteText(long aStartOffset, long aEndOffset) 1.44 +{ 1.45 + A11Y_TRYBLOCK_BEGIN 1.46 + 1.47 + HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); 1.48 + if (textAcc->IsDefunct()) 1.49 + return CO_E_OBJNOTCONNECTED; 1.50 + 1.51 + if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) 1.52 + return E_INVALIDARG; 1.53 + 1.54 + textAcc->DeleteText(aStartOffset, aEndOffset); 1.55 + return S_OK; 1.56 + 1.57 + A11Y_TRYBLOCK_END 1.58 +} 1.59 + 1.60 +STDMETHODIMP 1.61 +ia2AccessibleEditableText::insertText(long aOffset, BSTR *aText) 1.62 +{ 1.63 + A11Y_TRYBLOCK_BEGIN 1.64 + 1.65 + HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); 1.66 + if (textAcc->IsDefunct()) 1.67 + return CO_E_OBJNOTCONNECTED; 1.68 + 1.69 + if (!textAcc->IsValidOffset(aOffset)) 1.70 + return E_INVALIDARG; 1.71 + 1.72 + uint32_t length = ::SysStringLen(*aText); 1.73 + nsAutoString text(*aText, length); 1.74 + 1.75 + textAcc->InsertText(text, aOffset); 1.76 + return S_OK; 1.77 + 1.78 + A11Y_TRYBLOCK_END 1.79 +} 1.80 + 1.81 +STDMETHODIMP 1.82 +ia2AccessibleEditableText::cutText(long aStartOffset, long aEndOffset) 1.83 +{ 1.84 + A11Y_TRYBLOCK_BEGIN 1.85 + 1.86 + HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); 1.87 + if (textAcc->IsDefunct()) 1.88 + return CO_E_OBJNOTCONNECTED; 1.89 + 1.90 + if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) 1.91 + return E_INVALIDARG; 1.92 + 1.93 + textAcc->CutText(aStartOffset, aEndOffset); 1.94 + return S_OK; 1.95 + 1.96 + A11Y_TRYBLOCK_END 1.97 +} 1.98 + 1.99 +STDMETHODIMP 1.100 +ia2AccessibleEditableText::pasteText(long aOffset) 1.101 +{ 1.102 + A11Y_TRYBLOCK_BEGIN 1.103 + 1.104 + HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); 1.105 + if (textAcc->IsDefunct()) 1.106 + return CO_E_OBJNOTCONNECTED; 1.107 + 1.108 + if (!textAcc->IsValidOffset(aOffset)) 1.109 + return E_INVALIDARG; 1.110 + 1.111 + textAcc->PasteText(aOffset); 1.112 + return S_OK; 1.113 + 1.114 + A11Y_TRYBLOCK_END 1.115 +} 1.116 + 1.117 +STDMETHODIMP 1.118 +ia2AccessibleEditableText::replaceText(long aStartOffset, long aEndOffset, 1.119 + BSTR *aText) 1.120 +{ 1.121 + A11Y_TRYBLOCK_BEGIN 1.122 + 1.123 + HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); 1.124 + if (textAcc->IsDefunct()) 1.125 + return CO_E_OBJNOTCONNECTED; 1.126 + 1.127 + if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) 1.128 + return E_INVALIDARG; 1.129 + 1.130 + textAcc->DeleteText(aStartOffset, aEndOffset); 1.131 + 1.132 + uint32_t length = ::SysStringLen(*aText); 1.133 + nsAutoString text(*aText, length); 1.134 + textAcc->InsertText(text, aStartOffset); 1.135 + 1.136 + return S_OK; 1.137 + 1.138 + A11Y_TRYBLOCK_END 1.139 +} 1.140 + 1.141 +STDMETHODIMP 1.142 +ia2AccessibleEditableText::setAttributes(long aStartOffset, long aEndOffset, 1.143 + BSTR *aAttributes) 1.144 +{ 1.145 + return E_NOTIMPL; 1.146 +}