merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / querydesign / ConnectionLineAccess.cxx
blob95031ec067f097ae94764b2068995e97c173d146
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ConnectionLineAccess.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBACCESS_CONNECTIONLINEACCESS_HXX
34 #include "ConnectionLineAccess.hxx"
35 #endif
36 #ifndef DBAUI_JOINTABLEVIEW_HXX
37 #include "JoinTableView.hxx"
38 #endif
39 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
40 #include <com/sun/star/accessibility/AccessibleRole.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_
43 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
44 #endif
45 #ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
46 #include <toolkit/awt/vclxwindow.hxx>
47 #endif
48 #ifndef DBAUI_TABLECONNECTION_HXX
49 #include "TableConnection.hxx"
50 #endif
51 #ifndef DBAUI_TABLEWINDOW_HXX
52 #include "TableWindow.hxx"
53 #endif
54 #ifndef _COMPHELPER_UNO3_HXX_
55 #include <comphelper/uno3.hxx>
56 #endif
57 #ifndef DBAUI_JOINDESIGNVIEW_HXX
58 #include "JoinDesignView.hxx"
59 #endif
60 #ifndef DBAUI_JOINCONTROLLER_HXX
61 #include "JoinController.hxx"
62 #endif
63 #ifndef _COMPHELPER_SEQUENCE_HXX_
64 #include <comphelper/sequence.hxx>
65 #endif
67 namespace dbaui
69 using namespace ::com::sun::star::accessibility;
70 using namespace ::com::sun::star::uno;
71 using namespace ::com::sun::star::beans;
72 using namespace ::com::sun::star::lang;
73 // using namespace ::com::sun::star::awt;
74 using namespace ::com::sun::star;
76 OConnectionLineAccess::OConnectionLineAccess(OTableConnection* _pLine)
77 : VCLXAccessibleComponent(_pLine->GetComponentInterface().is() ? _pLine->GetWindowPeer() : NULL)
78 ,m_pLine(_pLine)
81 // -----------------------------------------------------------------------------
82 void SAL_CALL OConnectionLineAccess::disposing()
84 m_pLine = NULL;
85 VCLXAccessibleComponent::disposing();
87 // -----------------------------------------------------------------------------
88 Any SAL_CALL OConnectionLineAccess::queryInterface( const Type& aType ) throw (RuntimeException)
90 Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
91 return aRet.hasValue() ? aRet : OConnectionLineAccess_BASE::queryInterface( aType );
93 // -----------------------------------------------------------------------------
94 Sequence< Type > SAL_CALL OConnectionLineAccess::getTypes( ) throw (RuntimeException)
96 return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OConnectionLineAccess_BASE::getTypes());
98 // -----------------------------------------------------------------------------
99 ::rtl::OUString SAL_CALL OConnectionLineAccess::getImplementationName() throw(RuntimeException)
101 return getImplementationName_Static();
103 // -----------------------------------------------------------------------------
104 // XServiceInfo - static methods
105 // -----------------------------------------------------------------------------
106 ::rtl::OUString OConnectionLineAccess::getImplementationName_Static(void) throw( RuntimeException )
108 return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ConnectionLineAccessibility");
110 // -----------------------------------------------------------------------------
111 // XAccessibleContext
112 sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleChildCount( ) throw (RuntimeException)
114 return 0;
116 // -----------------------------------------------------------------------------
117 Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleChild( sal_Int32 /*i*/ ) throw (RuntimeException)
119 return Reference< XAccessible >();
121 // -----------------------------------------------------------------------------
122 sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleIndexInParent( ) throw (RuntimeException)
124 ::osl::MutexGuard aGuard( m_aMutex );
125 sal_Int32 nIndex = -1;
126 if( m_pLine )
128 // search the postion of our table window in the table window map
129 nIndex = m_pLine->GetParent()->GetTabWinMap()->size();
130 const ::std::vector<OTableConnection*>* pVec = m_pLine->GetParent()->getTableConnections();
131 ::std::vector<OTableConnection*>::const_iterator aIter = pVec->begin();
132 ::std::vector<OTableConnection*>::const_iterator aEnd = pVec->end();
133 for (; aIter != aEnd && (*aIter) != m_pLine; ++nIndex,++aIter)
135 nIndex = ( aIter != aEnd ) ? nIndex : -1;
137 return nIndex;
139 // -----------------------------------------------------------------------------
140 sal_Int16 SAL_CALL OConnectionLineAccess::getAccessibleRole( ) throw (RuntimeException)
142 return AccessibleRole::UNKNOWN; // ? or may be an AccessibleRole::WINDOW
144 // -----------------------------------------------------------------------------
145 ::rtl::OUString SAL_CALL OConnectionLineAccess::getAccessibleDescription( ) throw (RuntimeException)
147 static ::rtl::OUString sDescription(RTL_CONSTASCII_USTRINGPARAM("Relation"));
148 return sDescription;
150 // -----------------------------------------------------------------------------
151 Reference< XAccessibleRelationSet > SAL_CALL OConnectionLineAccess::getAccessibleRelationSet( ) throw (RuntimeException)
153 ::osl::MutexGuard aGuard( m_aMutex );
154 return this;
156 // -----------------------------------------------------------------------------
157 // XAccessibleComponent
158 sal_Bool SAL_CALL OConnectionLineAccess::contains( const awt::Point& _aPoint ) throw (RuntimeException)
160 ::osl::MutexGuard aGuard( m_aMutex );
161 Point aPoint(_aPoint.X,_aPoint.Y);
162 return m_pLine ? m_pLine->CheckHit(aPoint) : sal_False;
164 // -----------------------------------------------------------------------------
165 Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleAtPoint( const awt::Point& /*_aPoint*/ ) throw (RuntimeException)
167 return Reference< XAccessible >();
169 // -----------------------------------------------------------------------------
170 awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds( ) throw (RuntimeException)
172 ::osl::MutexGuard aGuard( m_aMutex );
173 Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : Rectangle());
174 return awt::Rectangle(aRect.getX(),aRect.getY(),aRect.getWidth(),aRect.getHeight());
176 // -----------------------------------------------------------------------------
177 awt::Point SAL_CALL OConnectionLineAccess::getLocation( ) throw (RuntimeException)
179 ::osl::MutexGuard aGuard( m_aMutex );
180 Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point());
181 return awt::Point(aPoint.X(),aPoint.Y());
183 // -----------------------------------------------------------------------------
184 awt::Point SAL_CALL OConnectionLineAccess::getLocationOnScreen( ) throw (RuntimeException)
186 ::osl::MutexGuard aGuard( m_aMutex );
187 Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point());
188 return awt::Point(aPoint.X(),aPoint.Y());
190 // -----------------------------------------------------------------------------
191 awt::Size SAL_CALL OConnectionLineAccess::getSize( ) throw (RuntimeException)
193 ::osl::MutexGuard aGuard( m_aMutex );
194 Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size());
195 return awt::Size(aSize.Width(),aSize.Height());
197 // -----------------------------------------------------------------------------
198 sal_Bool SAL_CALL OConnectionLineAccess::isShowing( ) throw (RuntimeException)
200 ::osl::MutexGuard aGuard( m_aMutex );
201 return m_pLine ? m_pLine->GetParent()->GetWindowRegionPixel().IsInside(m_pLine->GetBoundingRect()) : sal_False;
203 // -----------------------------------------------------------------------------
204 sal_Bool SAL_CALL OConnectionLineAccess::isVisible( ) throw (RuntimeException)
206 return sal_True;
208 // -----------------------------------------------------------------------------
209 sal_Bool SAL_CALL OConnectionLineAccess::isFocusTraversable( ) throw (RuntimeException)
211 return sal_True;
213 // -----------------------------------------------------------------------------
214 // XAccessibleRelationSet
215 // -----------------------------------------------------------------------------
216 sal_Int32 SAL_CALL OConnectionLineAccess::getRelationCount( ) throw (RuntimeException)
218 return 1;
220 // -----------------------------------------------------------------------------
221 AccessibleRelation SAL_CALL OConnectionLineAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
223 ::osl::MutexGuard aGuard( m_aMutex );
224 if( nIndex < 0 || nIndex >= getRelationCount() )
225 throw IndexOutOfBoundsException();
227 Sequence< Reference<XInterface> > aSeq(m_pLine ? 2 : 0);
228 if( m_pLine )
230 aSeq[0] = m_pLine->GetSourceWin()->GetAccessible();
231 aSeq[1] = m_pLine->GetDestWin()->GetAccessible();
234 return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY,aSeq);
236 // -----------------------------------------------------------------------------
237 sal_Bool SAL_CALL OConnectionLineAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException)
239 return AccessibleRelationType::CONTROLLED_BY == aRelationType;
241 // -----------------------------------------------------------------------------
242 AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException)
244 if( AccessibleRelationType::CONTROLLED_BY == aRelationType )
245 return getRelation(0);
246 return AccessibleRelation();
248 // -----------------------------------------------------------------------------
249 Reference< XAccessible > OTableConnection::CreateAccessible()
251 return new OConnectionLineAccess(this);
253 // -----------------------------------------------------------------------------
254 OTableConnection::~OTableConnection()
256 DBG_DTOR(OTableConnection,NULL);
257 //////////////////////////////////////////////////////////////////////
258 // clear vector
259 clearLineData();
261 // -----------------------------------------------------------------------------
262 sal_Bool OConnectionLineAccess::isEditable() const
265 return m_pLine ? !m_pLine->GetParent()->getDesignView()->getController().isReadOnly() : sal_False;
267 // -----------------------------------------------------------------------------
268 Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException)
270 return this;
272 // -----------------------------------------------------------------------------
274 // -----------------------------------------------------------------------------