xref: /trunk/main/dbaccess/source/ui/inc/TableConnection.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBAUI_TABLECONNECTION_HXX
28 #define DBAUI_TABLECONNECTION_HXX
29 
30 //#ifndef _SV_GEN_HXX
31 //#include <tools/gen.hxx>
32 //#endif
33 //#ifndef DBAUI_CONNECTIONLINE_HXX
34 //#include "ConnectionLine.hxx"
35 //#endif
36 #include <vector>
37 #ifndef _TOOLS_DEBUG_HXX
38 #include <tools/debug.hxx>
39 #endif
40 #ifndef _SV_WINDOW_HXX
41 #include <vcl/window.hxx>
42 #endif
43 #ifndef _RTTI_HXX
44 #include <tools/rtti.hxx>
45 #endif
46 #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
47 #include <com/sun/star/uno/Reference.h>
48 #endif
49 #include "TableConnectionData.hxx"
50 
51 class Point;
52 class Rectangle;
53 
54 namespace dbaui
55 {
56     class OTableConnectionData;
57     class OTableWindow;
58     class OJoinTableView;
59     class OConnectionLine;
60 
61     DBG_NAMEEX(OTableConnection)
62     class OTableConnection : public Window
63     {
64         ::std::vector<OConnectionLine*> m_vConnLine;
65         TTableConnectionData::value_type
66                                         m_pData;
67         OJoinTableView*                 m_pParent;
68 
69         sal_Bool                            m_bSelected;
70 
71         void Init();
72         /** clearLineData loops through the vector and deletes all lines
73         */
74         void clearLineData();
75 
76     protected:
77         OConnectionLine* CreateConnLine( const OConnectionLine& rConnLine );
78 
79     public:
80         OTableConnection( OJoinTableView* pContainer, const TTableConnectionData::value_type& pTabConnData );
81         OTableConnection( const OTableConnection& rConn );
82             // WICHTIG : normalerweise bekomme ich von aussen einen Zeiger auf OTableConnectionData mitgegeben, hier aber muss ich
83             // mir (ueber OTableConnectionData::NewInstance) selber eine INstanz anlegen, die ich aber - wie in allen anderen Faellen auch -
84             // NIE loesche. Der Aufrufer ist also bei Benutzung dieses Constructors dafuer verantwortlich, meine Daten abzufragen und
85             // sich irgendwo zu merken, um sie dann irgendwann zu loeschen.
86         virtual ~OTableConnection();
87 
88         OTableConnection& operator=( const OTableConnection& rConn );
89 
90 
91         void        Select();
92         void        Deselect();
93         sal_Bool        IsSelected() const { return m_bSelected; }
94         sal_Bool        CheckHit( const Point& rMousePos ) const;
95         bool        InvalidateConnection();
96         void        UpdateLineList();
97 
98         OTableWindow* GetSourceWin() const;
99         OTableWindow* GetDestWin() const;
100 
101         bool RecalcLines();
102         /** isTableConnection
103             @param  _pTable the table where we should check if we belongs to it
104 
105             @return true when the source or the destination window are equal
106         */
107         bool isTableConnection(const OTableWindow* _pTable)
108         {
109             return (_pTable == GetSourceWin() || _pTable == GetDestWin());
110         }
111 
112         Rectangle   GetBoundingRect() const;
113 
114         inline TTableConnectionData::value_type GetData() const { return m_pData; }
115         const ::std::vector<OConnectionLine*>*  GetConnLineList() const { return &m_vConnLine; }
116         inline OJoinTableView*                  GetParent() const { return m_pParent; }
117         virtual void                    Draw( const Rectangle& rRect );
118         using Window::Draw;
119         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
120     };
121 }
122 #endif // DBAUI_TABLECONNECTION_HXX
123 
124