1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef DBAUI_TABLECONNECTION_HXX
24 #define DBAUI_TABLECONNECTION_HXX
25 
26 //#ifndef _SV_GEN_HXX
27 //#include <tools/gen.hxx>
28 //#endif
29 //#ifndef DBAUI_CONNECTIONLINE_HXX
30 //#include "ConnectionLine.hxx"
31 //#endif
32 #include <vector>
33 #ifndef _TOOLS_DEBUG_HXX
34 #include <tools/debug.hxx>
35 #endif
36 #ifndef _SV_WINDOW_HXX
37 #include <vcl/window.hxx>
38 #endif
39 #ifndef _RTTI_HXX
40 #include <tools/rtti.hxx>
41 #endif
42 #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
43 #include <com/sun/star/uno/Reference.h>
44 #endif
45 #include "TableConnectionData.hxx"
46 
47 class Point;
48 class Rectangle;
49 
50 namespace dbaui
51 {
52 	class OTableConnectionData;
53 	class OTableWindow;
54 	class OJoinTableView;
55 	class OConnectionLine;
56 
57 	DBG_NAMEEX(OTableConnection)
58 	class OTableConnection : public Window
59 	{
60 		::std::vector<OConnectionLine*>	m_vConnLine;
61         TTableConnectionData::value_type
62                                         m_pData;
63 		OJoinTableView*					m_pParent;
64 
65 		sal_Bool							m_bSelected;
66 
67 		void Init();
68 		/** clearLineData loops through the vector and deletes all lines
69 		*/
70 		void clearLineData();
71 
72 	protected:
73 		OConnectionLine* CreateConnLine( const OConnectionLine& rConnLine );
74 
75 	public:
76         OTableConnection( OJoinTableView* pContainer, const TTableConnectionData::value_type& pTabConnData );
77 		OTableConnection( const OTableConnection& rConn );
78 			// WICHTIG : normalerweise bekomme ich von aussen einen Zeiger auf OTableConnectionData mitgegeben, hier aber muss ich
79 			// mir (ueber OTableConnectionData::NewInstance) selber eine INstanz anlegen, die ich aber - wie in allen anderen Faellen auch -
80 			// NIE loesche. Der Aufrufer ist also bei Benutzung dieses Constructors dafuer verantwortlich, meine Daten abzufragen und
81 			// sich irgendwo zu merken, um sie dann irgendwann zu loeschen.
82 		virtual ~OTableConnection();
83 
84 		OTableConnection& operator=( const OTableConnection& rConn );
85 
86 
87 		void		Select();
88 		void		Deselect();
IsSelected() const89 		sal_Bool		IsSelected() const { return m_bSelected; }
90 		sal_Bool		CheckHit( const Point& rMousePos ) const;
91 		bool		InvalidateConnection();
92 		void		UpdateLineList();
93 
94 		OTableWindow* GetSourceWin() const;
95 		OTableWindow* GetDestWin() const;
96 
97 		bool RecalcLines();
98 		/** isTableConnection
99 			@param	_pTable	the table where we should check if we belongs to it
100 
101 			@return	true when the source or the destination window are equal
102 		*/
isTableConnection(const OTableWindow * _pTable)103 		bool isTableConnection(const OTableWindow* _pTable)
104 		{
105 			return (_pTable == GetSourceWin() || _pTable == GetDestWin());
106 		}
107 
108 		Rectangle	GetBoundingRect() const;
109 
GetData() const110 		inline TTableConnectionData::value_type	GetData() const { return m_pData; }
GetConnLineList() const111 		const ::std::vector<OConnectionLine*>*  GetConnLineList() const { return &m_vConnLine; }
GetParent() const112 		inline OJoinTableView*					GetParent() const { return m_pParent; }
113 		virtual void					Draw( const Rectangle& rRect );
114         using Window::Draw;
115 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
116 	};
117 }
118 #endif // DBAUI_TABLECONNECTION_HXX
119 
120