LibreOffice Module dbaccess (master) 1
ConnectionLineAccess.cxx
Go to the documentation of this file.
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
21#include <ConnectionLine.hxx>
22#include <JoinTableView.hxx>
23#include <com/sun/star/accessibility/AccessibleRole.hpp>
24#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
25#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26#include <TableConnection.hxx>
27#include <TableWindow.hxx>
28
29namespace dbaui
30{
31 using namespace ::com::sun::star::accessibility;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star;
36
38 : ImplInheritanceHelper(_pLine->GetComponentInterface().is() ? _pLine->GetWindowPeer() : nullptr)
39 ,m_pLine(_pLine)
40 {
41 }
43 {
44 m_pLine = nullptr;
45 VCLXAccessibleComponent::disposing();
46 }
48 {
49 return "org.openoffice.comp.dbu.ConnectionLineAccessibility";
50 }
51 // XAccessibleContext
53 {
54 return 0;
55 }
57 {
59 }
61 {
62 ::osl::MutexGuard aGuard( m_aMutex );
63 sal_Int64 nIndex = -1;
64 if( m_pLine )
65 {
66 // search the position of our table window in the table window map
67 // TODO JNA Shouldn't nIndex begin at 0?
68 nIndex = m_pLine->GetParent()->GetTabWinMap().size();
69 const auto& rVec = m_pLine->GetParent()->getTableConnections();
70 bool bFound = false;
71 for (auto const& elem : rVec)
72 {
73 if (elem.get() == m_pLine)
74 {
75 bFound = true;
76 break;
77 }
78 ++nIndex;
79 }
80 nIndex = bFound ? nIndex : -1;
81 }
82 return nIndex;
83 }
85 {
86 return AccessibleRole::UNKNOWN; // ? or may be an AccessibleRole::WINDOW
87 }
89 {
90 return "Relation";
91 }
93 {
94 ::osl::MutexGuard aGuard( m_aMutex );
95 return this;
96 }
97 // XAccessibleComponent
99 {
101 }
102 awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds( )
103 {
104 ::osl::MutexGuard aGuard( m_aMutex );
105 tools::Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : tools::Rectangle());
106 return awt::Rectangle(aRect.Left(),aRect.Top(),aRect.getOpenWidth(),aRect.getOpenHeight());
107 }
109 {
110 ::osl::MutexGuard aGuard( m_aMutex );
111 Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point());
112 return awt::Point(aPoint.X(),aPoint.Y());
113 }
115 {
116 ::osl::MutexGuard aGuard( m_aMutex );
117 Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point());
118 return awt::Point(aPoint.X(),aPoint.Y());
119 }
120 awt::Size SAL_CALL OConnectionLineAccess::getSize( )
121 {
122 ::osl::MutexGuard aGuard( m_aMutex );
123 Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size());
124 return awt::Size(aSize.Width(),aSize.Height());
125 }
126 // XAccessibleRelationSet
128 {
129 return 1;
130 }
131 AccessibleRelation SAL_CALL OConnectionLineAccess::getRelation( sal_Int32 nIndex )
132 {
133 ::osl::MutexGuard aGuard( m_aMutex );
134 if( nIndex < 0 || nIndex >= getRelationCount() )
135 throw IndexOutOfBoundsException();
136
138 if( m_pLine )
139 {
140 aSeq = { m_pLine->GetSourceWin()->GetAccessible(),
141 m_pLine->GetDestWin()->GetAccessible() };
142 }
143
144 return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY,aSeq);
145 }
146 sal_Bool SAL_CALL OConnectionLineAccess::containsRelation( sal_Int16 aRelationType )
147 {
148 return AccessibleRelationType::CONTROLLED_BY == aRelationType;
149 }
150 AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType )
151 {
152 if( AccessibleRelationType::CONTROLLED_BY == aRelationType )
153 return getRelation(0);
154 return AccessibleRelation();
155 }
157 {
158 return new OConnectionLineAccess(this);
159 }
161 {
162 disposeOnce();
163 }
165 {
166 // clear vector
168 m_pParent.clear();
170 }
172 {
173 return this;
174 }
175}
176
177/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long Y() const
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
the class OConnectionLineAccess represents the accessible object for the connection between two table...
virtual css::awt::Rectangle SAL_CALL getBounds() override
virtual css::accessibility::AccessibleRelation SAL_CALL getRelation(sal_Int32 nIndex) override
virtual sal_Bool SAL_CALL containsRelation(sal_Int16 aRelationType) override
OConnectionLineAccess(OTableConnection *_pLine)
virtual css::awt::Point SAL_CALL getLocation() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual void SAL_CALL disposing() override
this function is called upon disposing the component
virtual css::awt::Size SAL_CALL getSize() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual sal_Int32 SAL_CALL getRelationCount() override
virtual OUString SAL_CALL getAccessibleDescription() override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
virtual css::accessibility::AccessibleRelation SAL_CALL getRelationByType(sal_Int16 aRelationType) override
virtual OUString SAL_CALL getImplementationName() override
VclPtr< const OTableConnection > m_pLine
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual ~OTableConnection() override
destructor
virtual void dispose() override
void clearLineData()
loops through the vector and deletes all lines
VclPtr< OJoinTableView > m_pParent
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
constexpr tools::Long Top() const
tools::Long getOpenHeight() const
tools::Long getOpenWidth() const
constexpr tools::Long Left() const
virtual void dispose() override
std::mutex m_aMutex
sal_Int32 nIndex
Sequence< sal_Int8 > aSeq
unsigned char sal_Bool