/* -*- 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 #include 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 xContext = pUNOInterface->getAccessibleContext(); if (!xContext.is()) return E_FAIL; // retrieve reference to table (parent of the cell) Reference xParentContext = xContext->getAccessibleParent()->getAccessibleContext(); Reference 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: */