Line data Source code
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 "ConnectionLineAccess.hxx"
21 : #include "JoinTableView.hxx"
22 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
23 : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
24 : #include <toolkit/awt/vclxwindow.hxx>
25 : #include "TableConnection.hxx"
26 : #include "TableWindow.hxx"
27 : #include <comphelper/uno3.hxx>
28 : #include "JoinDesignView.hxx"
29 : #include "JoinController.hxx"
30 : #include <comphelper/sequence.hxx>
31 :
32 : namespace dbaui
33 : {
34 : using namespace ::com::sun::star::accessibility;
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star::beans;
37 : using namespace ::com::sun::star::lang;
38 : using namespace ::com::sun::star;
39 :
40 0 : OConnectionLineAccess::OConnectionLineAccess(OTableConnection* _pLine)
41 0 : : VCLXAccessibleComponent(_pLine->GetComponentInterface().is() ? _pLine->GetWindowPeer() : NULL)
42 0 : ,m_pLine(_pLine)
43 : {
44 0 : }
45 0 : void SAL_CALL OConnectionLineAccess::disposing()
46 : {
47 0 : m_pLine = NULL;
48 0 : VCLXAccessibleComponent::disposing();
49 0 : }
50 0 : Any SAL_CALL OConnectionLineAccess::queryInterface( const Type& aType ) throw (RuntimeException, std::exception)
51 : {
52 0 : Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
53 0 : return aRet.hasValue() ? aRet : OConnectionLineAccess_BASE::queryInterface( aType );
54 : }
55 0 : Sequence< Type > SAL_CALL OConnectionLineAccess::getTypes( ) throw (RuntimeException, std::exception)
56 : {
57 0 : return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OConnectionLineAccess_BASE::getTypes());
58 : }
59 0 : OUString SAL_CALL OConnectionLineAccess::getImplementationName() throw(RuntimeException, std::exception)
60 : {
61 0 : return getImplementationName_Static();
62 : }
63 : // XServiceInfo - static methods
64 0 : OUString OConnectionLineAccess::getImplementationName_Static() throw( RuntimeException )
65 : {
66 0 : return OUString("org.openoffice.comp.dbu.ConnectionLineAccessibility");
67 : }
68 : // XAccessibleContext
69 0 : sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleChildCount( ) throw (RuntimeException, std::exception)
70 : {
71 0 : return 0;
72 : }
73 0 : Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleChild( sal_Int32 /*i*/ ) throw (RuntimeException, std::exception)
74 : {
75 0 : return Reference< XAccessible >();
76 : }
77 0 : sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleIndexInParent( ) throw (RuntimeException, std::exception)
78 : {
79 0 : ::osl::MutexGuard aGuard( m_aMutex );
80 0 : sal_Int32 nIndex = -1;
81 0 : if( m_pLine )
82 : {
83 : // search the position of our table window in the table window map
84 0 : nIndex = m_pLine->GetParent()->GetTabWinMap().size();
85 0 : const auto& rVec = m_pLine->GetParent()->getTableConnections();
86 0 : auto aIter = rVec.begin();
87 0 : auto aEnd = rVec.end();
88 0 : for (; aIter != aEnd && (*aIter).get() != m_pLine; ++nIndex,++aIter)
89 : ;
90 0 : nIndex = ( aIter != aEnd ) ? nIndex : -1;
91 : }
92 0 : return nIndex;
93 : }
94 0 : sal_Int16 SAL_CALL OConnectionLineAccess::getAccessibleRole( ) throw (RuntimeException, std::exception)
95 : {
96 0 : return AccessibleRole::UNKNOWN; // ? or may be an AccessibleRole::WINDOW
97 : }
98 0 : OUString SAL_CALL OConnectionLineAccess::getAccessibleDescription( ) throw (RuntimeException, std::exception)
99 : {
100 0 : return OUString("Relation");
101 : }
102 0 : Reference< XAccessibleRelationSet > SAL_CALL OConnectionLineAccess::getAccessibleRelationSet( ) throw (RuntimeException, std::exception)
103 : {
104 0 : ::osl::MutexGuard aGuard( m_aMutex );
105 0 : return this;
106 : }
107 : // XAccessibleComponent
108 0 : Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleAtPoint( const awt::Point& /*_aPoint*/ ) throw (RuntimeException, std::exception)
109 : {
110 0 : return Reference< XAccessible >();
111 : }
112 0 : awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds( ) throw (RuntimeException, std::exception)
113 : {
114 0 : ::osl::MutexGuard aGuard( m_aMutex );
115 0 : Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : Rectangle());
116 0 : return awt::Rectangle(aRect.getX(),aRect.getY(),aRect.getWidth(),aRect.getHeight());
117 : }
118 0 : awt::Point SAL_CALL OConnectionLineAccess::getLocation( ) throw (RuntimeException, std::exception)
119 : {
120 0 : ::osl::MutexGuard aGuard( m_aMutex );
121 0 : Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point());
122 0 : return awt::Point(aPoint.X(),aPoint.Y());
123 : }
124 0 : awt::Point SAL_CALL OConnectionLineAccess::getLocationOnScreen( ) throw (RuntimeException, std::exception)
125 : {
126 0 : ::osl::MutexGuard aGuard( m_aMutex );
127 0 : Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point());
128 0 : return awt::Point(aPoint.X(),aPoint.Y());
129 : }
130 0 : awt::Size SAL_CALL OConnectionLineAccess::getSize( ) throw (RuntimeException, std::exception)
131 : {
132 0 : ::osl::MutexGuard aGuard( m_aMutex );
133 0 : Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size());
134 0 : return awt::Size(aSize.Width(),aSize.Height());
135 : }
136 : // XAccessibleRelationSet
137 0 : sal_Int32 SAL_CALL OConnectionLineAccess::getRelationCount( ) throw (RuntimeException, std::exception)
138 : {
139 0 : return 1;
140 : }
141 0 : AccessibleRelation SAL_CALL OConnectionLineAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
142 : {
143 0 : ::osl::MutexGuard aGuard( m_aMutex );
144 0 : if( nIndex < 0 || nIndex >= getRelationCount() )
145 0 : throw IndexOutOfBoundsException();
146 :
147 0 : Sequence< Reference<XInterface> > aSeq(m_pLine ? 2 : 0);
148 0 : if( m_pLine )
149 : {
150 0 : aSeq[0] = m_pLine->GetSourceWin()->GetAccessible();
151 0 : aSeq[1] = m_pLine->GetDestWin()->GetAccessible();
152 : }
153 :
154 0 : return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY,aSeq);
155 : }
156 0 : sal_Bool SAL_CALL OConnectionLineAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
157 : {
158 0 : return AccessibleRelationType::CONTROLLED_BY == aRelationType;
159 : }
160 0 : AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
161 : {
162 0 : if( AccessibleRelationType::CONTROLLED_BY == aRelationType )
163 0 : return getRelation(0);
164 0 : return AccessibleRelation();
165 : }
166 0 : Reference< XAccessible > OTableConnection::CreateAccessible()
167 : {
168 0 : return new OConnectionLineAccess(this);
169 : }
170 0 : OTableConnection::~OTableConnection()
171 : {
172 0 : disposeOnce();
173 0 : }
174 0 : void OTableConnection::dispose()
175 : {
176 : // clear vector
177 0 : clearLineData();
178 0 : m_pParent.clear();
179 0 : vcl::Window::dispose();
180 0 : }
181 0 : Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
182 : {
183 0 : return this;
184 : }
185 36 : }
186 :
187 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|