xref: /trunk/main/dbaccess/source/ui/querydesign/QTableConnection.cxx (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 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dbaccess.hxx"
30 #ifndef DBAUI_QUERYTABLECONNECTION_HXX
31 #include "QTableConnection.hxx"
32 #endif
33 #ifndef _TOOLS_DEBUG_HXX
34 #include <tools/debug.hxx>
35 #endif
36 #ifndef DBAUI_QUERYTABLEVIEW_HXX
37 #include "QueryTableView.hxx"
38 #endif
39 #ifndef DBAUI_CONNECTIONLINE_HXX
40 #include "ConnectionLine.hxx"
41 #endif
42 using namespace dbaui;
43 //========================================================================
44 // class OQueryTableConnection
45 //========================================================================
46 DBG_NAME(OQueryTableConnection)
47 
48 //------------------------------------------------------------------------
49 OQueryTableConnection::OQueryTableConnection(OQueryTableView* pContainer, const TTableConnectionData::value_type& pTabConnData)
50     :OTableConnection(pContainer, pTabConnData)
51     ,m_bVisited(sal_False)
52 {
53     DBG_CTOR(OQueryTableConnection,NULL);
54 }
55 
56 
57 //------------------------------------------------------------------------
58 OQueryTableConnection::OQueryTableConnection(const OQueryTableConnection& rConn)
59     :OTableConnection( rConn )
60 {
61     DBG_CTOR(OQueryTableConnection,NULL);
62     // keine eigenen Members, also reicht die Basisklassenfunktionalitaet
63 }
64 //------------------------------------------------------------------------
65 OQueryTableConnection::~OQueryTableConnection()
66 {
67     DBG_DTOR(OQueryTableConnection,NULL);
68 }
69 
70 //------------------------------------------------------------------------
71 OQueryTableConnection& OQueryTableConnection::operator=(const OQueryTableConnection& rConn)
72 {
73     if (&rConn == this)
74         return *this;
75 
76     OTableConnection::operator=(rConn);
77     // keine eigenen Members ...
78     return *this;
79 }
80 
81 //------------------------------------------------------------------------
82 sal_Bool OQueryTableConnection::operator==(const OQueryTableConnection& rCompare)
83 {
84     DBG_ASSERT(GetData() && rCompare.GetData(), "OQueryTableConnection::operator== : einer der beiden Teilnehmer hat keine Daten !");
85 
86     // allzuviel brauche ich nicht vergleichen (schon gar nicht alle Member) : lediglich die Fenster, an denen wir haengen, und
87     // die Indizies in der entsprechenden Tabelle muessen uebereinstimmen
88     OQueryTableConnectionData* pMyData = static_cast<OQueryTableConnectionData*>(GetData().get());
89     OQueryTableConnectionData* pCompData = static_cast<OQueryTableConnectionData*>(rCompare.GetData().get());
90 
91     // Connections werden als gleich angesehen, wenn sie in Source-/Dest-Fenstername und Source-/Dest-FieldIndex uebereinstimmen ...
92     return  (   (   (pMyData->getReferencedTable() == pCompData->getReferencedTable()) &&
93                     (pMyData->getReferencingTable() == pCompData->getReferencingTable()) &&
94                     (pMyData->GetFieldIndex(JTCS_TO) == pCompData->GetFieldIndex(JTCS_TO)) &&
95                     (pMyData->GetFieldIndex(JTCS_FROM) == pCompData->GetFieldIndex(JTCS_FROM))
96                 )
97                 ||  // ... oder diese Uebereinstimmung ueber Kreuz besteht
98                 (   (pMyData->getReferencingTable() == pCompData->getReferencedTable()) &&
99                     (pMyData->getReferencedTable() == pCompData->getReferencingTable()) &&
100                     (pMyData->GetFieldIndex(JTCS_TO) == pCompData->GetFieldIndex(JTCS_FROM)) &&
101                     (pMyData->GetFieldIndex(JTCS_FROM) == pCompData->GetFieldIndex(JTCS_TO))
102                 )
103             );
104 }
105 // -----------------------------------------------------------------------------
106 
107 
108 
109 
110 
111 
112