| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <sal/config.h> |
| 21 |
|
| 22 |
#include <memory> |
| 23 |
|
| 24 |
#include <AccessibleTextHelper.hxx> |
| 25 |
#include <DrawViewWrapper.hxx> |
| 26 |
|
| 27 |
#include <vcl/svapp.hxx> |
| 28 |
|
| 29 |
#include <svx/AccessibleTextHelper.hxx> |
| 30 |
#include <svx/unoshtxt.hxx> |
| 31 |
#include <vcl/window.hxx> |
| 32 |
|
| 33 |
#include <com/sun/star/accessibility/AccessibleRole.hpp> |
| 34 |
#include <osl/diagnose.h> |
| 35 |
|
| 36 |
using namespace ::com::sun::star; |
| 37 |
using namespace ::com::sun::star::accessibility; |
| 38 |
|
| 39 |
using ::com::sun::star::uno::Reference; |
| 40 |
|
| 41 |
namespace chart |
| 42 |
{ |
| 43 |
|
| 44 |
AccessibleTextHelper::AccessibleTextHelper( |
| 45 |
DrawViewWrapper * pDrawViewWrapper ) : |
| 46 |
m_pDrawViewWrapper( pDrawViewWrapper ) |
| 47 |
{} |
| 48 |
|
| 49 |
AccessibleTextHelper::~AccessibleTextHelper() |
| 50 |
{ |
| 51 |
} |
| 52 |
|
| 53 |
void AccessibleTextHelper::initialize(const OUString& aCID, |
| 54 |
const rtl::Reference<comphelper::OAccessible>& rEventSource, |
| 55 |
vcl::Window* pWindow) |
| 56 |
{ |
| 57 |
OSL_ENSURE( !aCID.isEmpty(), "Empty CID" ); |
| 58 |
assert(rEventSource.is() && "Empty Event Source"); |
| 59 |
if (aCID.isEmpty()) |
| 60 |
return; |
| 61 |
|
| 62 |
SolarMutexGuard aSolarGuard; |
| 63 |
|
| 64 |
m_oTextHelper.reset(); |
| 65 |
|
| 66 |
if( pWindow ) |
| 67 |
{ |
| 68 |
if (m_pDrawViewWrapper) |
| 69 |
{ |
| 70 |
SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID ); |
| 71 |
if( pTextObj ) |
| 72 |
{ |
| 73 |
m_oTextHelper.emplace(std::make_unique<SvxTextEditSource>(*pTextObj, nullptr, *m_pDrawViewWrapper, *pWindow->GetOutDev())); |
| 74 |
m_oTextHelper->SetEventSource(rEventSource); |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
OSL_ENSURE( m_oTextHelper, "Couldn't create text helper" ); |
| 80 |
} |
| 81 |
|
| 82 |
// ____ XAccessibleContext ____ |
| 83 |
sal_Int64 SAL_CALL AccessibleTextHelper::getAccessibleChildCount() |
| 84 |
{ |
| 85 |
if( m_oTextHelper ) |
| 86 |
{ |
| 87 |
SolarMutexGuard aSolarGuard; |
| 88 |
return m_oTextHelper->GetChildCount(); |
| 89 |
} |
| 90 |
return 0; |
| 91 |
} |
| 92 |
|
| 93 |
Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( sal_Int64 i ) |
| 94 |
{ |
| 95 |
if( m_oTextHelper ) |
| 96 |
{ |
| 97 |
SolarMutexGuard aSolarGuard; |
| 98 |
return m_oTextHelper->GetChild( i ); |
| 99 |
} |
| 100 |
return Reference< XAccessible >(); |
| 101 |
} |
| 102 |
|
| 103 |
Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleParent() |
| 104 |
{ |
| 105 |
OSL_FAIL( "Not implemented in this helper" ); |
| 106 |
return Reference< XAccessible >(); |
| 107 |
} |
| 108 |
|
| 109 |
sal_Int64 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent() |
| 110 |
{ |
| 111 |
OSL_FAIL( "Not implemented in this helper" ); |
| 112 |
return -1; |
| 113 |
} |
| 114 |
|
| 115 |
::sal_Int16 SAL_CALL AccessibleTextHelper::getAccessibleRole() |
| 116 |
{ |
| 117 |
OSL_FAIL( "Not implemented in this helper" ); |
| 118 |
return AccessibleRole::UNKNOWN; |
| 119 |
} |
| 120 |
|
| 121 |
OUString SAL_CALL AccessibleTextHelper::getAccessibleDescription() |
| 122 |
{ |
| 123 |
OSL_FAIL( "Not implemented in this helper" ); |
| 124 |
return OUString(); |
| 125 |
} |
| 126 |
|
| 127 |
OUString SAL_CALL AccessibleTextHelper::getAccessibleName() |
| 128 |
{ |
| 129 |
OSL_FAIL( "Not implemented in this helper" ); |
| 130 |
return OUString(); |
| 131 |
} |
| 132 |
|
| 133 |
Reference< XAccessibleRelationSet > SAL_CALL AccessibleTextHelper::getAccessibleRelationSet() |
| 134 |
{ |
| 135 |
OSL_FAIL( "Not implemented in this helper" ); |
| 136 |
return Reference< XAccessibleRelationSet >(); |
| 137 |
} |
| 138 |
|
| 139 |
sal_Int64 SAL_CALL AccessibleTextHelper::getAccessibleStateSet() |
| 140 |
{ |
| 141 |
OSL_FAIL( "Not implemented in this helper" ); |
| 142 |
return 0; |
| 143 |
} |
| 144 |
|
| 145 |
lang::Locale SAL_CALL AccessibleTextHelper::getLocale() |
| 146 |
{ |
| 147 |
OSL_FAIL( "Not implemented in this helper" ); |
| 148 |
return lang::Locale(); |
| 149 |
} |
| 150 |
|
| 151 |
} // namespace chart |
| 152 |
|
| 153 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |