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