1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <ConnectionLineAccess.hxx>
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>
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
;
37 OConnectionLineAccess::OConnectionLineAccess(OTableConnection
* _pLine
)
38 : ImplInheritanceHelper(_pLine
->GetComponentInterface().is() ? _pLine
->GetWindowPeer() : nullptr)
42 void SAL_CALL
OConnectionLineAccess::disposing()
45 VCLXAccessibleComponent::disposing();
47 OUString SAL_CALL
OConnectionLineAccess::getImplementationName()
49 return "org.openoffice.comp.dbu.ConnectionLineAccessibility";
52 sal_Int64 SAL_CALL
OConnectionLineAccess::getAccessibleChildCount( )
56 Reference
< XAccessible
> SAL_CALL
OConnectionLineAccess::getAccessibleChild( sal_Int64
/*i*/ )
58 return Reference
< XAccessible
>();
60 sal_Int64 SAL_CALL
OConnectionLineAccess::getAccessibleIndexInParent( )
62 ::osl::MutexGuard
aGuard( m_aMutex
);
63 sal_Int64 nIndex
= -1;
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();
71 for (auto const& elem
: rVec
)
73 if (elem
.get() == m_pLine
)
80 nIndex
= bFound
? nIndex
: -1;
84 sal_Int16 SAL_CALL
OConnectionLineAccess::getAccessibleRole( )
86 return AccessibleRole::UNKNOWN
; // ? or may be an AccessibleRole::WINDOW
88 OUString SAL_CALL
OConnectionLineAccess::getAccessibleDescription( )
92 Reference
< XAccessibleRelationSet
> SAL_CALL
OConnectionLineAccess::getAccessibleRelationSet( )
94 ::osl::MutexGuard
aGuard( m_aMutex
);
97 // XAccessibleComponent
98 Reference
< XAccessible
> SAL_CALL
OConnectionLineAccess::getAccessibleAtPoint( const awt::Point
& /*_aPoint*/ )
100 return Reference
< XAccessible
>();
102 awt::Rectangle SAL_CALL
OConnectionLineAccess::getBounds( )
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());
108 awt::Point SAL_CALL
OConnectionLineAccess::getLocation( )
110 ::osl::MutexGuard
aGuard( m_aMutex
);
111 Point
aPoint(m_pLine
? m_pLine
->GetBoundingRect().TopLeft() : Point());
112 return awt::Point(aPoint
.X(),aPoint
.Y());
114 awt::Point SAL_CALL
OConnectionLineAccess::getLocationOnScreen( )
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());
120 awt::Size SAL_CALL
OConnectionLineAccess::getSize( )
122 ::osl::MutexGuard
aGuard( m_aMutex
);
123 Size
aSize(m_pLine
? m_pLine
->GetBoundingRect().GetSize() : Size());
124 return awt::Size(aSize
.Width(),aSize
.Height());
126 // XAccessibleRelationSet
127 sal_Int32 SAL_CALL
OConnectionLineAccess::getRelationCount( )
131 AccessibleRelation SAL_CALL
OConnectionLineAccess::getRelation( sal_Int32 nIndex
)
133 ::osl::MutexGuard
aGuard( m_aMutex
);
134 if( nIndex
< 0 || nIndex
>= getRelationCount() )
135 throw IndexOutOfBoundsException();
137 Sequence
< Reference
<XInterface
> > aSeq
;
140 aSeq
= { m_pLine
->GetSourceWin()->GetAccessible(),
141 m_pLine
->GetDestWin()->GetAccessible() };
144 return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY
,aSeq
);
146 sal_Bool SAL_CALL
OConnectionLineAccess::containsRelation( sal_Int16 aRelationType
)
148 return AccessibleRelationType::CONTROLLED_BY
== aRelationType
;
150 AccessibleRelation SAL_CALL
OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType
)
152 if( AccessibleRelationType::CONTROLLED_BY
== aRelationType
)
153 return getRelation(0);
154 return AccessibleRelation();
156 Reference
< XAccessible
> OTableConnection::CreateAccessible()
158 return new OConnectionLineAccess(this);
160 OTableConnection::~OTableConnection()
164 void OTableConnection::dispose()
169 vcl::Window::dispose();
171 Reference
< XAccessibleContext
> SAL_CALL
OConnectionLineAccess::getAccessibleContext( )
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */