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 : // -----------------------------------------------------------------------------
46 0 : void SAL_CALL OConnectionLineAccess::disposing()
47 : {
48 0 : m_pLine = NULL;
49 0 : VCLXAccessibleComponent::disposing();
50 0 : }
51 : // -----------------------------------------------------------------------------
52 0 : Any SAL_CALL OConnectionLineAccess::queryInterface( const Type& aType ) throw (RuntimeException)
53 : {
54 0 : Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
55 0 : return aRet.hasValue() ? aRet : OConnectionLineAccess_BASE::queryInterface( aType );
56 : }
57 : // -----------------------------------------------------------------------------
58 0 : Sequence< Type > SAL_CALL OConnectionLineAccess::getTypes( ) throw (RuntimeException)
59 : {
60 0 : return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OConnectionLineAccess_BASE::getTypes());
61 : }
62 : // -----------------------------------------------------------------------------
63 0 : ::rtl::OUString SAL_CALL OConnectionLineAccess::getImplementationName() throw(RuntimeException)
64 : {
65 0 : return getImplementationName_Static();
66 : }
67 : // -----------------------------------------------------------------------------
68 : // XServiceInfo - static methods
69 : // -----------------------------------------------------------------------------
70 0 : ::rtl::OUString OConnectionLineAccess::getImplementationName_Static(void) throw( RuntimeException )
71 : {
72 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ConnectionLineAccessibility"));
73 : }
74 : // -----------------------------------------------------------------------------
75 : // XAccessibleContext
76 0 : sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleChildCount( ) throw (RuntimeException)
77 : {
78 0 : return 0;
79 : }
80 : // -----------------------------------------------------------------------------
81 0 : Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleChild( sal_Int32 /*i*/ ) throw (RuntimeException)
82 : {
83 0 : return Reference< XAccessible >();
84 : }
85 : // -----------------------------------------------------------------------------
86 0 : sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleIndexInParent( ) throw (RuntimeException)
87 : {
88 0 : ::osl::MutexGuard aGuard( m_aMutex );
89 0 : sal_Int32 nIndex = -1;
90 0 : if( m_pLine )
91 : {
92 : // search the postion of our table window in the table window map
93 0 : nIndex = m_pLine->GetParent()->GetTabWinMap()->size();
94 0 : const ::std::vector<OTableConnection*>* pVec = m_pLine->GetParent()->getTableConnections();
95 0 : ::std::vector<OTableConnection*>::const_iterator aIter = pVec->begin();
96 0 : ::std::vector<OTableConnection*>::const_iterator aEnd = pVec->end();
97 0 : for (; aIter != aEnd && (*aIter) != m_pLine; ++nIndex,++aIter)
98 : ;
99 0 : nIndex = ( aIter != aEnd ) ? nIndex : -1;
100 : }
101 0 : return nIndex;
102 : }
103 : // -----------------------------------------------------------------------------
104 0 : sal_Int16 SAL_CALL OConnectionLineAccess::getAccessibleRole( ) throw (RuntimeException)
105 : {
106 0 : return AccessibleRole::UNKNOWN; // ? or may be an AccessibleRole::WINDOW
107 : }
108 : // -----------------------------------------------------------------------------
109 0 : ::rtl::OUString SAL_CALL OConnectionLineAccess::getAccessibleDescription( ) throw (RuntimeException)
110 : {
111 0 : static ::rtl::OUString sDescription(RTL_CONSTASCII_USTRINGPARAM("Relation"));
112 0 : return sDescription;
113 : }
114 : // -----------------------------------------------------------------------------
115 0 : Reference< XAccessibleRelationSet > SAL_CALL OConnectionLineAccess::getAccessibleRelationSet( ) throw (RuntimeException)
116 : {
117 0 : ::osl::MutexGuard aGuard( m_aMutex );
118 0 : return this;
119 : }
120 : // -----------------------------------------------------------------------------
121 : // XAccessibleComponent
122 0 : sal_Bool SAL_CALL OConnectionLineAccess::contains( const awt::Point& _aPoint ) throw (RuntimeException)
123 : {
124 0 : ::osl::MutexGuard aGuard( m_aMutex );
125 0 : Point aPoint(_aPoint.X,_aPoint.Y);
126 0 : return m_pLine ? m_pLine->CheckHit(aPoint) : sal_False;
127 : }
128 : // -----------------------------------------------------------------------------
129 0 : Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleAtPoint( const awt::Point& /*_aPoint*/ ) throw (RuntimeException)
130 : {
131 0 : return Reference< XAccessible >();
132 : }
133 : // -----------------------------------------------------------------------------
134 0 : awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds( ) throw (RuntimeException)
135 : {
136 0 : ::osl::MutexGuard aGuard( m_aMutex );
137 0 : Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : Rectangle());
138 0 : return awt::Rectangle(aRect.getX(),aRect.getY(),aRect.getWidth(),aRect.getHeight());
139 : }
140 : // -----------------------------------------------------------------------------
141 0 : awt::Point SAL_CALL OConnectionLineAccess::getLocation( ) throw (RuntimeException)
142 : {
143 0 : ::osl::MutexGuard aGuard( m_aMutex );
144 0 : Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point());
145 0 : return awt::Point(aPoint.X(),aPoint.Y());
146 : }
147 : // -----------------------------------------------------------------------------
148 0 : awt::Point SAL_CALL OConnectionLineAccess::getLocationOnScreen( ) throw (RuntimeException)
149 : {
150 0 : ::osl::MutexGuard aGuard( m_aMutex );
151 0 : Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point());
152 0 : return awt::Point(aPoint.X(),aPoint.Y());
153 : }
154 : // -----------------------------------------------------------------------------
155 0 : awt::Size SAL_CALL OConnectionLineAccess::getSize( ) throw (RuntimeException)
156 : {
157 0 : ::osl::MutexGuard aGuard( m_aMutex );
158 0 : Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size());
159 0 : return awt::Size(aSize.Width(),aSize.Height());
160 : }
161 : // -----------------------------------------------------------------------------
162 0 : sal_Bool SAL_CALL OConnectionLineAccess::isShowing( ) throw (RuntimeException)
163 : {
164 0 : ::osl::MutexGuard aGuard( m_aMutex );
165 0 : return m_pLine ? m_pLine->GetParent()->GetWindowRegionPixel().IsInside(m_pLine->GetBoundingRect()) : sal_False;
166 : }
167 : // -----------------------------------------------------------------------------
168 0 : sal_Bool SAL_CALL OConnectionLineAccess::isVisible( ) throw (RuntimeException)
169 : {
170 0 : return sal_True;
171 : }
172 : // -----------------------------------------------------------------------------
173 0 : sal_Bool SAL_CALL OConnectionLineAccess::isFocusTraversable( ) throw (RuntimeException)
174 : {
175 0 : return sal_True;
176 : }
177 : // -----------------------------------------------------------------------------
178 : // XAccessibleRelationSet
179 : // -----------------------------------------------------------------------------
180 0 : sal_Int32 SAL_CALL OConnectionLineAccess::getRelationCount( ) throw (RuntimeException)
181 : {
182 0 : return 1;
183 : }
184 : // -----------------------------------------------------------------------------
185 0 : AccessibleRelation SAL_CALL OConnectionLineAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
186 : {
187 0 : ::osl::MutexGuard aGuard( m_aMutex );
188 0 : if( nIndex < 0 || nIndex >= getRelationCount() )
189 0 : throw IndexOutOfBoundsException();
190 :
191 0 : Sequence< Reference<XInterface> > aSeq(m_pLine ? 2 : 0);
192 0 : if( m_pLine )
193 : {
194 0 : aSeq[0] = m_pLine->GetSourceWin()->GetAccessible();
195 0 : aSeq[1] = m_pLine->GetDestWin()->GetAccessible();
196 : }
197 :
198 0 : return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY,aSeq);
199 : }
200 : // -----------------------------------------------------------------------------
201 0 : sal_Bool SAL_CALL OConnectionLineAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException)
202 : {
203 0 : return AccessibleRelationType::CONTROLLED_BY == aRelationType;
204 : }
205 : // -----------------------------------------------------------------------------
206 0 : AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException)
207 : {
208 0 : if( AccessibleRelationType::CONTROLLED_BY == aRelationType )
209 0 : return getRelation(0);
210 0 : return AccessibleRelation();
211 : }
212 : // -----------------------------------------------------------------------------
213 0 : Reference< XAccessible > OTableConnection::CreateAccessible()
214 : {
215 0 : return new OConnectionLineAccess(this);
216 : }
217 : // -----------------------------------------------------------------------------
218 0 : OTableConnection::~OTableConnection()
219 : {
220 : DBG_DTOR(OTableConnection,NULL);
221 : //////////////////////////////////////////////////////////////////////
222 : // clear vector
223 0 : clearLineData();
224 0 : }
225 : // -----------------------------------------------------------------------------
226 0 : sal_Bool OConnectionLineAccess::isEditable() const
227 : {
228 :
229 0 : return m_pLine ? !m_pLine->GetParent()->getDesignView()->getController().isReadOnly() : sal_False;
230 : }
231 : // -----------------------------------------------------------------------------
232 0 : Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException)
233 : {
234 0 : return this;
235 : }
236 : // -----------------------------------------------------------------------------
237 : }
238 : // -----------------------------------------------------------------------------
239 :
240 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|