tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / dbaccess / source / ui / querydesign / ConnectionLineAccess.cxx
blob2bff88cf3ecf27b01f3712b56fada316ec859e1b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
29 namespace dbaui
31 using namespace ::com::sun::star::accessibility;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::lang;
34 using namespace ::com::sun::star;
36 OConnectionLineAccess::OConnectionLineAccess(OTableConnection* _pLine)
37 : ImplInheritanceHelper(_pLine)
38 ,m_pLine(_pLine)
41 void SAL_CALL OConnectionLineAccess::disposing()
43 m_pLine = nullptr;
44 VCLXAccessibleComponent::disposing();
46 OUString SAL_CALL OConnectionLineAccess::getImplementationName()
48 return u"org.openoffice.comp.dbu.ConnectionLineAccessibility"_ustr;
50 // XAccessibleContext
51 sal_Int64 SAL_CALL OConnectionLineAccess::getAccessibleChildCount( )
53 return 0;
55 Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleChild( sal_Int64 /*i*/ )
57 return Reference< XAccessible >();
59 sal_Int64 SAL_CALL OConnectionLineAccess::getAccessibleIndexInParent( )
61 ::osl::MutexGuard aGuard( m_aMutex );
62 sal_Int64 nIndex = -1;
63 if( m_pLine )
65 // search the position of our table window in the table window map
66 // TODO JNA Shouldn't nIndex begin at 0?
67 nIndex = m_pLine->GetParent()->GetTabWinMap().size();
68 const auto& rVec = m_pLine->GetParent()->getTableConnections();
69 bool bFound = false;
70 for (auto const& elem : rVec)
72 if (elem.get() == m_pLine)
74 bFound = true;
75 break;
77 ++nIndex;
79 nIndex = bFound ? nIndex : -1;
81 return nIndex;
83 sal_Int16 SAL_CALL OConnectionLineAccess::getAccessibleRole( )
85 return AccessibleRole::UNKNOWN; // ? or may be an AccessibleRole::WINDOW
87 OUString SAL_CALL OConnectionLineAccess::getAccessibleDescription( )
89 return u"Relation"_ustr;
91 Reference< XAccessibleRelationSet > SAL_CALL OConnectionLineAccess::getAccessibleRelationSet( )
93 ::osl::MutexGuard aGuard( m_aMutex );
94 return this;
96 // XAccessibleComponent
97 Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleAtPoint( const awt::Point& /*_aPoint*/ )
99 return Reference< XAccessible >();
101 awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds( )
103 ::osl::MutexGuard aGuard( m_aMutex );
104 tools::Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : tools::Rectangle());
105 return awt::Rectangle(aRect.Left(),aRect.Top(),aRect.getOpenWidth(),aRect.getOpenHeight());
107 awt::Point SAL_CALL OConnectionLineAccess::getLocation( )
109 ::osl::MutexGuard aGuard( m_aMutex );
110 Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point());
111 return awt::Point(aPoint.X(),aPoint.Y());
113 awt::Point SAL_CALL OConnectionLineAccess::getLocationOnScreen( )
115 ::osl::MutexGuard aGuard( m_aMutex );
116 Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point());
117 return awt::Point(aPoint.X(),aPoint.Y());
119 awt::Size SAL_CALL OConnectionLineAccess::getSize( )
121 ::osl::MutexGuard aGuard( m_aMutex );
122 Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size());
123 return awt::Size(aSize.Width(),aSize.Height());
125 // XAccessibleRelationSet
126 sal_Int32 SAL_CALL OConnectionLineAccess::getRelationCount( )
128 return 1;
130 AccessibleRelation SAL_CALL OConnectionLineAccess::getRelation( sal_Int32 nIndex )
132 ::osl::MutexGuard aGuard( m_aMutex );
133 if( nIndex < 0 || nIndex >= getRelationCount() )
134 throw IndexOutOfBoundsException();
136 Sequence<Reference<XAccessible>> aSeq;
137 if( m_pLine )
139 aSeq = { m_pLine->GetSourceWin()->GetAccessible(),
140 m_pLine->GetDestWin()->GetAccessible() };
143 return AccessibleRelation(AccessibleRelationType_CONTROLLED_BY,aSeq);
145 sal_Bool SAL_CALL OConnectionLineAccess::containsRelation(AccessibleRelationType eRelationType)
147 return AccessibleRelationType_CONTROLLED_BY == eRelationType;
149 AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType(AccessibleRelationType eRelationType)
151 if (AccessibleRelationType_CONTROLLED_BY == eRelationType)
152 return getRelation(0);
153 return AccessibleRelation();
155 Reference< XAccessible > OTableConnection::CreateAccessible()
157 return new OConnectionLineAccess(this);
159 OTableConnection::~OTableConnection()
161 disposeOnce();
163 void OTableConnection::dispose()
165 // clear vector
166 clearLineData();
167 m_pParent.clear();
168 vcl::Window::dispose();
170 Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext( )
172 return this;
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */