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(void) 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 ::std::vector<OTableConnection*>& rVec = m_pLine->GetParent()->getTableConnections();
86 0 : ::std::vector<OTableConnection*>::const_iterator aIter = rVec.begin();
87 0 : ::std::vector<OTableConnection*>::const_iterator aEnd = rVec.end();
88 0 : for (; aIter != aEnd && (*aIter) != 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 : static OUString sDescription("Relation");
101 0 : return sDescription;
102 : }
103 0 : Reference< XAccessibleRelationSet > SAL_CALL OConnectionLineAccess::getAccessibleRelationSet( ) throw (RuntimeException, std::exception)
104 : {
105 0 : ::osl::MutexGuard aGuard( m_aMutex );
106 0 : return this;
107 : }
108 : // XAccessibleComponent
109 0 : bool SAL_CALL OConnectionLineAccess::contains( const awt::Point& _aPoint ) throw (RuntimeException)
110 : {
111 0 : ::osl::MutexGuard aGuard( m_aMutex );
112 0 : Point aPoint(_aPoint.X,_aPoint.Y);
113 0 : return m_pLine ? m_pLine->CheckHit(aPoint) : sal_False;
114 : }
115 0 : Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleAtPoint( const awt::Point& /*_aPoint*/ ) throw (RuntimeException, std::exception)
116 : {
117 0 : return Reference< XAccessible >();
118 : }
119 0 : awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds( ) throw (RuntimeException, std::exception)
120 : {
121 0 : ::osl::MutexGuard aGuard( m_aMutex );
122 0 : Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : Rectangle());
123 0 : return awt::Rectangle(aRect.getX(),aRect.getY(),aRect.getWidth(),aRect.getHeight());
124 : }
125 0 : awt::Point SAL_CALL OConnectionLineAccess::getLocation( ) throw (RuntimeException, std::exception)
126 : {
127 0 : ::osl::MutexGuard aGuard( m_aMutex );
128 0 : Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point());
129 0 : return awt::Point(aPoint.X(),aPoint.Y());
130 : }
131 0 : awt::Point SAL_CALL OConnectionLineAccess::getLocationOnScreen( ) throw (RuntimeException, std::exception)
132 : {
133 0 : ::osl::MutexGuard aGuard( m_aMutex );
134 0 : Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point());
135 0 : return awt::Point(aPoint.X(),aPoint.Y());
136 : }
137 0 : awt::Size SAL_CALL OConnectionLineAccess::getSize( ) throw (RuntimeException, std::exception)
138 : {
139 0 : ::osl::MutexGuard aGuard( m_aMutex );
140 0 : Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size());
141 0 : return awt::Size(aSize.Width(),aSize.Height());
142 : }
143 0 : bool SAL_CALL OConnectionLineAccess::isShowing( ) throw (RuntimeException)
144 : {
145 0 : ::osl::MutexGuard aGuard( m_aMutex );
146 0 : return m_pLine ? m_pLine->GetParent()->GetWindowRegionPixel().IsInside(m_pLine->GetBoundingRect()) : sal_False;
147 : }
148 0 : bool SAL_CALL OConnectionLineAccess::isVisible( ) throw (RuntimeException)
149 : {
150 0 : return true;
151 : }
152 0 : bool SAL_CALL OConnectionLineAccess::isFocusTraversable( ) throw (RuntimeException)
153 : {
154 0 : return true;
155 : }
156 : // XAccessibleRelationSet
157 0 : sal_Int32 SAL_CALL OConnectionLineAccess::getRelationCount( ) throw (RuntimeException, std::exception)
158 : {
159 0 : return 1;
160 : }
161 0 : AccessibleRelation SAL_CALL OConnectionLineAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
162 : {
163 0 : ::osl::MutexGuard aGuard( m_aMutex );
164 0 : if( nIndex < 0 || nIndex >= getRelationCount() )
165 0 : throw IndexOutOfBoundsException();
166 :
167 0 : Sequence< Reference<XInterface> > aSeq(m_pLine ? 2 : 0);
168 0 : if( m_pLine )
169 : {
170 0 : aSeq[0] = m_pLine->GetSourceWin()->GetAccessible();
171 0 : aSeq[1] = m_pLine->GetDestWin()->GetAccessible();
172 : }
173 :
174 0 : return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY,aSeq);
175 : }
176 0 : sal_Bool SAL_CALL OConnectionLineAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
177 : {
178 0 : return AccessibleRelationType::CONTROLLED_BY == aRelationType;
179 : }
180 0 : AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
181 : {
182 0 : if( AccessibleRelationType::CONTROLLED_BY == aRelationType )
183 0 : return getRelation(0);
184 0 : return AccessibleRelation();
185 : }
186 0 : Reference< XAccessible > OTableConnection::CreateAccessible()
187 : {
188 0 : return new OConnectionLineAccess(this);
189 : }
190 0 : OTableConnection::~OTableConnection()
191 : {
192 : // clear vector
193 0 : clearLineData();
194 0 : }
195 0 : bool OConnectionLineAccess::isEditable() const
196 : {
197 :
198 0 : return m_pLine ? !m_pLine->GetParent()->getDesignView()->getController().isReadOnly() : sal_False;
199 : }
200 0 : Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
201 : {
202 0 : return this;
203 : }
204 72 : }
205 :
206 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|