xref: /trunk/main/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx (revision 07a3d7f126518b23ae382088cf657ec498e294b1)
196de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
396de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
496de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
596de5490SAndrew Rist  * distributed with this work for additional information
696de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
796de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
896de5490SAndrew Rist  * "License"); you may not use this file except in compliance
996de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
1196de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
1396de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1496de5490SAndrew Rist  * software distributed under the License is distributed on an
1596de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1696de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
1796de5490SAndrew Rist  * specific language governing permissions and limitations
1896de5490SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
2096de5490SAndrew Rist  *************************************************************/
2196de5490SAndrew Rist 
2296de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBACCESS_CONNECTIONLINEACCESS_HXX
27cdf0e10cSrcweir #include "ConnectionLineAccess.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef DBAUI_JOINTABLEVIEW_HXX
30cdf0e10cSrcweir #include "JoinTableView.hxx"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
33cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_
36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
39cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef DBAUI_TABLECONNECTION_HXX
42cdf0e10cSrcweir #include "TableConnection.hxx"
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOW_HXX
45cdf0e10cSrcweir #include "TableWindow.hxx"
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _COMPHELPER_UNO3_HXX_
48cdf0e10cSrcweir #include <comphelper/uno3.hxx>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef DBAUI_JOINDESIGNVIEW_HXX
51cdf0e10cSrcweir #include "JoinDesignView.hxx"
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef DBAUI_JOINCONTROLLER_HXX
54cdf0e10cSrcweir #include "JoinController.hxx"
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_
57cdf0e10cSrcweir #include <comphelper/sequence.hxx>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace dbaui
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     using namespace ::com::sun::star::accessibility;
63cdf0e10cSrcweir     using namespace ::com::sun::star::uno;
64cdf0e10cSrcweir     using namespace ::com::sun::star::beans;
65cdf0e10cSrcweir     using namespace ::com::sun::star::lang;
66cdf0e10cSrcweir     //  using namespace ::com::sun::star::awt;
67cdf0e10cSrcweir     using namespace ::com::sun::star;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     OConnectionLineAccess::OConnectionLineAccess(OTableConnection* _pLine)
70cdf0e10cSrcweir         : VCLXAccessibleComponent(_pLine->GetComponentInterface().is() ? _pLine->GetWindowPeer() : NULL)
71cdf0e10cSrcweir         ,m_pLine(_pLine)
72cdf0e10cSrcweir     {
73cdf0e10cSrcweir     }
74cdf0e10cSrcweir     // -----------------------------------------------------------------------------
75cdf0e10cSrcweir     void SAL_CALL OConnectionLineAccess::disposing()
76cdf0e10cSrcweir     {
77cdf0e10cSrcweir         m_pLine = NULL;
78cdf0e10cSrcweir         VCLXAccessibleComponent::disposing();
79cdf0e10cSrcweir     }
80cdf0e10cSrcweir     // -----------------------------------------------------------------------------
81cdf0e10cSrcweir     Any SAL_CALL OConnectionLineAccess::queryInterface( const Type& aType ) throw (RuntimeException)
82cdf0e10cSrcweir     {
83cdf0e10cSrcweir         Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
84cdf0e10cSrcweir         return aRet.hasValue() ? aRet : OConnectionLineAccess_BASE::queryInterface( aType );
85cdf0e10cSrcweir     }
86cdf0e10cSrcweir     // -----------------------------------------------------------------------------
87cdf0e10cSrcweir     Sequence< Type > SAL_CALL OConnectionLineAccess::getTypes(  ) throw (RuntimeException)
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir         return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OConnectionLineAccess_BASE::getTypes());
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir     // -----------------------------------------------------------------------------
92cdf0e10cSrcweir     ::rtl::OUString SAL_CALL OConnectionLineAccess::getImplementationName() throw(RuntimeException)
93cdf0e10cSrcweir     {
94cdf0e10cSrcweir         return getImplementationName_Static();
95cdf0e10cSrcweir     }
96cdf0e10cSrcweir     // -----------------------------------------------------------------------------
97cdf0e10cSrcweir     // XServiceInfo - static methods
98cdf0e10cSrcweir     // -----------------------------------------------------------------------------
99cdf0e10cSrcweir     ::rtl::OUString OConnectionLineAccess::getImplementationName_Static(void) throw( RuntimeException )
100cdf0e10cSrcweir     {
101cdf0e10cSrcweir         return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ConnectionLineAccessibility");
102cdf0e10cSrcweir     }
103cdf0e10cSrcweir     // -----------------------------------------------------------------------------
104cdf0e10cSrcweir     // XAccessibleContext
105cdf0e10cSrcweir     sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleChildCount(  ) throw (RuntimeException)
106cdf0e10cSrcweir     {
107cdf0e10cSrcweir         return 0;
108cdf0e10cSrcweir     }
109cdf0e10cSrcweir     // -----------------------------------------------------------------------------
110cdf0e10cSrcweir     Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleChild( sal_Int32 /*i*/ ) throw (RuntimeException)
111cdf0e10cSrcweir     {
112cdf0e10cSrcweir         return Reference< XAccessible >();
113cdf0e10cSrcweir     }
114cdf0e10cSrcweir     // -----------------------------------------------------------------------------
115cdf0e10cSrcweir     sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleIndexInParent(  ) throw (RuntimeException)
116cdf0e10cSrcweir     {
117cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex  );
118cdf0e10cSrcweir         sal_Int32 nIndex = -1;
119cdf0e10cSrcweir         if( m_pLine )
120cdf0e10cSrcweir         {
121*07a3d7f1SPedro Giffuni             // search the position of our table window in the table window map
122cdf0e10cSrcweir             nIndex = m_pLine->GetParent()->GetTabWinMap()->size();
123cdf0e10cSrcweir             const ::std::vector<OTableConnection*>* pVec = m_pLine->GetParent()->getTableConnections();
124cdf0e10cSrcweir             ::std::vector<OTableConnection*>::const_iterator aIter = pVec->begin();
125cdf0e10cSrcweir             ::std::vector<OTableConnection*>::const_iterator aEnd = pVec->end();
126cdf0e10cSrcweir             for (; aIter != aEnd && (*aIter) != m_pLine; ++nIndex,++aIter)
127cdf0e10cSrcweir                 ;
128cdf0e10cSrcweir             nIndex = ( aIter != aEnd ) ? nIndex : -1;
129cdf0e10cSrcweir         }
130cdf0e10cSrcweir         return nIndex;
131cdf0e10cSrcweir     }
132cdf0e10cSrcweir     // -----------------------------------------------------------------------------
133cdf0e10cSrcweir     sal_Int16 SAL_CALL OConnectionLineAccess::getAccessibleRole(  ) throw (RuntimeException)
134cdf0e10cSrcweir     {
135cdf0e10cSrcweir         return AccessibleRole::UNKNOWN; // ? or may be an AccessibleRole::WINDOW
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir     // -----------------------------------------------------------------------------
138cdf0e10cSrcweir     ::rtl::OUString SAL_CALL OConnectionLineAccess::getAccessibleDescription(  ) throw (RuntimeException)
139cdf0e10cSrcweir     {
140cdf0e10cSrcweir         static ::rtl::OUString sDescription(RTL_CONSTASCII_USTRINGPARAM("Relation"));
141cdf0e10cSrcweir         return sDescription;
142cdf0e10cSrcweir     }
143cdf0e10cSrcweir     // -----------------------------------------------------------------------------
144cdf0e10cSrcweir     Reference< XAccessibleRelationSet > SAL_CALL OConnectionLineAccess::getAccessibleRelationSet(  ) throw (RuntimeException)
145cdf0e10cSrcweir     {
146cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex  );
147cdf0e10cSrcweir         return this;
148cdf0e10cSrcweir     }
149cdf0e10cSrcweir     // -----------------------------------------------------------------------------
150cdf0e10cSrcweir     // XAccessibleComponent
151cdf0e10cSrcweir     sal_Bool SAL_CALL OConnectionLineAccess::contains( const awt::Point& _aPoint ) throw (RuntimeException)
152cdf0e10cSrcweir     {
153cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex  );
154cdf0e10cSrcweir         Point aPoint(_aPoint.X,_aPoint.Y);
155cdf0e10cSrcweir         return m_pLine ? m_pLine->CheckHit(aPoint) : sal_False;
156cdf0e10cSrcweir     }
157cdf0e10cSrcweir     // -----------------------------------------------------------------------------
158cdf0e10cSrcweir     Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleAtPoint( const awt::Point& /*_aPoint*/ ) throw (RuntimeException)
159cdf0e10cSrcweir     {
160cdf0e10cSrcweir         return Reference< XAccessible >();
161cdf0e10cSrcweir     }
162cdf0e10cSrcweir     // -----------------------------------------------------------------------------
163cdf0e10cSrcweir     awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds(  ) throw (RuntimeException)
164cdf0e10cSrcweir     {
165cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex  );
166cdf0e10cSrcweir         Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : Rectangle());
167cdf0e10cSrcweir         return awt::Rectangle(aRect.getX(),aRect.getY(),aRect.getWidth(),aRect.getHeight());
168cdf0e10cSrcweir     }
169cdf0e10cSrcweir     // -----------------------------------------------------------------------------
170cdf0e10cSrcweir     awt::Point SAL_CALL OConnectionLineAccess::getLocation(  ) throw (RuntimeException)
171cdf0e10cSrcweir     {
172cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex  );
173cdf0e10cSrcweir         Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point());
174cdf0e10cSrcweir         return awt::Point(aPoint.X(),aPoint.Y());
175cdf0e10cSrcweir     }
176cdf0e10cSrcweir     // -----------------------------------------------------------------------------
177cdf0e10cSrcweir     awt::Point SAL_CALL OConnectionLineAccess::getLocationOnScreen(  ) throw (RuntimeException)
178cdf0e10cSrcweir     {
179cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex  );
180cdf0e10cSrcweir         Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point());
181cdf0e10cSrcweir         return awt::Point(aPoint.X(),aPoint.Y());
182cdf0e10cSrcweir     }
183cdf0e10cSrcweir     // -----------------------------------------------------------------------------
184cdf0e10cSrcweir     awt::Size SAL_CALL OConnectionLineAccess::getSize(  ) throw (RuntimeException)
185cdf0e10cSrcweir     {
186cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex  );
187cdf0e10cSrcweir         Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size());
188cdf0e10cSrcweir         return awt::Size(aSize.Width(),aSize.Height());
189cdf0e10cSrcweir     }
190cdf0e10cSrcweir     // -----------------------------------------------------------------------------
191cdf0e10cSrcweir     sal_Bool SAL_CALL OConnectionLineAccess::isShowing(  ) throw (RuntimeException)
192cdf0e10cSrcweir     {
193cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex  );
194cdf0e10cSrcweir         return m_pLine ? m_pLine->GetParent()->GetWindowRegionPixel().IsInside(m_pLine->GetBoundingRect()) : sal_False;
195cdf0e10cSrcweir     }
196cdf0e10cSrcweir     // -----------------------------------------------------------------------------
197cdf0e10cSrcweir     sal_Bool SAL_CALL OConnectionLineAccess::isVisible(  ) throw (RuntimeException)
198cdf0e10cSrcweir     {
199cdf0e10cSrcweir         return sal_True;
200cdf0e10cSrcweir     }
201cdf0e10cSrcweir     // -----------------------------------------------------------------------------
202cdf0e10cSrcweir     sal_Bool SAL_CALL OConnectionLineAccess::isFocusTraversable(  ) throw (RuntimeException)
203cdf0e10cSrcweir     {
204cdf0e10cSrcweir         return sal_True;
205cdf0e10cSrcweir     }
206cdf0e10cSrcweir     // -----------------------------------------------------------------------------
207cdf0e10cSrcweir     // XAccessibleRelationSet
208cdf0e10cSrcweir     // -----------------------------------------------------------------------------
209cdf0e10cSrcweir     sal_Int32 SAL_CALL OConnectionLineAccess::getRelationCount(  ) throw (RuntimeException)
210cdf0e10cSrcweir     {
211cdf0e10cSrcweir         return 1;
212cdf0e10cSrcweir     }
213cdf0e10cSrcweir     // -----------------------------------------------------------------------------
214cdf0e10cSrcweir     AccessibleRelation SAL_CALL OConnectionLineAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
215cdf0e10cSrcweir     {
216cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex  );
217cdf0e10cSrcweir         if( nIndex < 0 || nIndex >= getRelationCount() )
218cdf0e10cSrcweir             throw IndexOutOfBoundsException();
219cdf0e10cSrcweir 
220cdf0e10cSrcweir         Sequence< Reference<XInterface> > aSeq(m_pLine ? 2 : 0);
221cdf0e10cSrcweir         if( m_pLine )
222cdf0e10cSrcweir         {
223cdf0e10cSrcweir             aSeq[0] = m_pLine->GetSourceWin()->GetAccessible();
224cdf0e10cSrcweir             aSeq[1] = m_pLine->GetDestWin()->GetAccessible();
225cdf0e10cSrcweir         }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir         return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY,aSeq);
228cdf0e10cSrcweir     }
229cdf0e10cSrcweir     // -----------------------------------------------------------------------------
230cdf0e10cSrcweir     sal_Bool SAL_CALL OConnectionLineAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException)
231cdf0e10cSrcweir     {
232cdf0e10cSrcweir         return AccessibleRelationType::CONTROLLED_BY == aRelationType;
233cdf0e10cSrcweir     }
234cdf0e10cSrcweir     // -----------------------------------------------------------------------------
235cdf0e10cSrcweir     AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException)
236cdf0e10cSrcweir     {
237cdf0e10cSrcweir         if( AccessibleRelationType::CONTROLLED_BY == aRelationType )
238cdf0e10cSrcweir             return getRelation(0);
239cdf0e10cSrcweir         return AccessibleRelation();
240cdf0e10cSrcweir     }
241cdf0e10cSrcweir     // -----------------------------------------------------------------------------
242cdf0e10cSrcweir     Reference< XAccessible > OTableConnection::CreateAccessible()
243cdf0e10cSrcweir     {
244cdf0e10cSrcweir         return new OConnectionLineAccess(this);
245cdf0e10cSrcweir     }
246cdf0e10cSrcweir     // -----------------------------------------------------------------------------
247cdf0e10cSrcweir     OTableConnection::~OTableConnection()
248cdf0e10cSrcweir     {
249cdf0e10cSrcweir         DBG_DTOR(OTableConnection,NULL);
250cdf0e10cSrcweir         //////////////////////////////////////////////////////////////////////
251cdf0e10cSrcweir         // clear vector
252cdf0e10cSrcweir         clearLineData();
253cdf0e10cSrcweir     }
254cdf0e10cSrcweir     // -----------------------------------------------------------------------------
255cdf0e10cSrcweir     sal_Bool OConnectionLineAccess::isEditable() const
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir 
258cdf0e10cSrcweir         return m_pLine ? !m_pLine->GetParent()->getDesignView()->getController().isReadOnly() : sal_False;
259cdf0e10cSrcweir     }
260cdf0e10cSrcweir     // -----------------------------------------------------------------------------
261cdf0e10cSrcweir     Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException)
262cdf0e10cSrcweir     {
263cdf0e10cSrcweir         return this;
264cdf0e10cSrcweir     }
265cdf0e10cSrcweir     // -----------------------------------------------------------------------------
266cdf0e10cSrcweir }
267cdf0e10cSrcweir // -----------------------------------------------------------------------------
268cdf0e10cSrcweir 
269