/* ============================================================================== This file is part of the JUCE 7 technical preview. Copyright (c) 2022 - Raw Material Software Limited You may use this code under the terms of the GPL v3 (see www.gnu.org/licenses). For the technical preview this file cannot be licensed commercially. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE DISCLAIMED. ============================================================================== */ namespace juce { //============================================================================== class UIAGridProvider : public UIAProviderBase, public ComBaseClassHelper { public: using UIAProviderBase::UIAProviderBase; //============================================================================== JUCE_COMRESULT GetItem (int row, int column, IRawElementProviderSimple** pRetVal) override { return withTableInterface (pRetVal, [&] (const AccessibilityTableInterface& tableInterface) { if (! isPositiveAndBelow (row, tableInterface.getNumRows()) || ! isPositiveAndBelow (column, tableInterface.getNumColumns())) return E_INVALIDARG; JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token") if (auto* handler = tableInterface.getCellHandler (row, column)) handler->getNativeImplementation()->QueryInterface (IID_PPV_ARGS (pRetVal)); JUCE_END_IGNORE_WARNINGS_GCC_LIKE return S_OK; }); } JUCE_COMRESULT get_RowCount (int* pRetVal) override { return withTableInterface (pRetVal, [&] (const AccessibilityTableInterface& tableInterface) { *pRetVal = tableInterface.getNumRows(); return S_OK; }); } JUCE_COMRESULT get_ColumnCount (int* pRetVal) override { return withTableInterface (pRetVal, [&] (const AccessibilityTableInterface& tableInterface) { *pRetVal = tableInterface.getNumColumns(); return S_OK; }); } private: template JUCE_COMRESULT withTableInterface (Value* pRetVal, Callback&& callback) const { return withCheckedComArgs (pRetVal, *this, [&]() -> HRESULT { if (auto* tableInterface = getHandler().getTableInterface()) return callback (*tableInterface); return (HRESULT) UIA_E_NOTSUPPORTED; }); } //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIAGridProvider) }; } // namespace juce