diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /winaccessibility/source/UAccCOM/AccTableCell.cxx | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream/4%7.4.7.tar.xz libreoffice-upstream/4%7.4.7.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | winaccessibility/source/UAccCOM/AccTableCell.cxx | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/winaccessibility/source/UAccCOM/AccTableCell.cxx b/winaccessibility/source/UAccCOM/AccTableCell.cxx new file mode 100644 index 000000000..90c450735 --- /dev/null +++ b/winaccessibility/source/UAccCOM/AccTableCell.cxx @@ -0,0 +1,186 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "AccTableCell.h" + +#include <vcl/svapp.hxx> +#include <com/sun/star/accessibility/XAccessible.hpp> + +using namespace com::sun::star::accessibility; +using namespace com::sun::star::uno; + +CAccTableCell::CAccTableCell() + : m_nIndexInParent(0) +{ +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::put_XInterface(hyper pXInterface) +{ + // internal IUNOXWrapper - no mutex meeded + + try + { + CUNOXWrapper::put_XInterface(pXInterface); + if (pUNOInterface == nullptr) + return E_INVALIDARG; + + Reference<XAccessibleContext> xContext = pUNOInterface->getAccessibleContext(); + if (!xContext.is()) + return E_FAIL; + + // retrieve reference to table (parent of the cell) + Reference<XAccessibleContext> xParentContext + = xContext->getAccessibleParent()->getAccessibleContext(); + Reference<XAccessibleTable> xTable(xParentContext, UNO_QUERY); + + if (!xTable.is()) + { + m_xTable.clear(); + return E_FAIL; + } + + m_xTable = xTable; + m_nIndexInParent = xContext->getAccessibleIndexInParent(); + return S_OK; + } + catch (...) + { + return E_FAIL; + } +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_columnExtent(long* pColumnsSpanned) +{ + SolarMutexGuard g; + + try + { + if (pColumnsSpanned == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + long nRow = 0, nColumn = 0; + get_rowIndex(&nRow); + get_columnIndex(&nColumn); + + *pColumnsSpanned = m_xTable->getAccessibleColumnExtentAt(nRow, nColumn); + return S_OK; + } + catch (...) + { + return E_FAIL; + } +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_columnIndex(long* pColumnIndex) +{ + SolarMutexGuard g; + + try + { + if (pColumnIndex == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + *pColumnIndex = m_xTable->getAccessibleColumn(m_nIndexInParent); + return S_OK; + } + catch (...) + { + return E_FAIL; + } +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_rowExtent(long* pRowsSpanned) +{ + SolarMutexGuard g; + + try + { + if (pRowsSpanned == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + long nRow = 0, nColumn = 0; + get_rowIndex(&nRow); + get_columnIndex(&nColumn); + + *pRowsSpanned = m_xTable->getAccessibleRowExtentAt(nRow, nColumn); + + return S_OK; + } + catch (...) + { + return E_FAIL; + } +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_rowIndex(long* pRowIndex) +{ + SolarMutexGuard g; + + try + { + if (pRowIndex == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + *pRowIndex = m_xTable->getAccessibleRow(m_nIndexInParent); + return S_OK; + } + catch (...) + { + return E_FAIL; + } +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_isSelected(boolean* pIsSelected) +{ + SolarMutexGuard g; + + try + { + if (pIsSelected == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + long nRow = 0, nColumn = 0; + get_rowIndex(&nRow); + get_columnIndex(&nColumn); + + *pIsSelected = m_xTable->isAccessibleSelected(nRow, nColumn); + return S_OK; + } + catch (...) + { + return E_FAIL; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |