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_QTABLECONNECTIONDATA_HXX
31 #include "QTableConnectionData.hxx"
32 #endif
33 #ifndef _TOOLS_DEBUG_HXX
34 #include <tools/debug.hxx>
35 #endif
36 #ifndef DBAUI_QTABLECONNECTIONDATA_HXX
37 #include "QTableConnectionData.hxx"
38 #endif
39 #ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
40 #include "QTableWindow.hxx"
41 #endif
42 
43 using namespace dbaui;
44 
45 //========================================================================
46 // class OQueryTableConnectionData
47 //========================================================================
48 DBG_NAME(OQueryTableConnectionData)
49 //------------------------------------------------------------------------
50 OQueryTableConnectionData::OQueryTableConnectionData()
51 	:OTableConnectionData()
52 	,m_eJoinType (INNER_JOIN)
53     ,m_bNatural(false)
54 {
55 	DBG_CTOR(OQueryTableConnectionData,NULL);
56 }
57 
58 //------------------------------------------------------------------------
59 OQueryTableConnectionData::OQueryTableConnectionData( const OQueryTableConnectionData& rConnData )
60 	:OTableConnectionData( rConnData )
61 {
62 	DBG_CTOR(OQueryTableConnectionData,NULL);
63 	m_nFromEntryIndex = rConnData.m_nFromEntryIndex;
64 	m_nDestEntryIndex = rConnData.m_nDestEntryIndex;
65 
66 	m_eFromType = rConnData.m_eFromType;
67 	m_eDestType = rConnData.m_eDestType;
68 	m_eJoinType = rConnData.m_eJoinType;
69     m_bNatural  = rConnData.m_bNatural;
70 }
71 
72 //------------------------------------------------------------------------
73 OQueryTableConnectionData::OQueryTableConnectionData(const TTableWindowData::value_type& _pReferencingTable
74                                                     ,const TTableWindowData::value_type& _pReferencedTable
75                                                     ,const ::rtl::OUString& rConnName)
76 	:OTableConnectionData( _pReferencingTable,_pReferencedTable, rConnName )
77 	,m_nFromEntryIndex(0)
78 	,m_nDestEntryIndex(0)
79 	,m_eJoinType (INNER_JOIN)
80     ,m_bNatural(false)
81 	,m_eFromType(TAB_NORMAL_FIELD)
82 	,m_eDestType(TAB_NORMAL_FIELD)
83 {
84 	DBG_CTOR(OQueryTableConnectionData,NULL);
85 }
86 
87 //------------------------------------------------------------------------
88 OQueryTableConnectionData::~OQueryTableConnectionData()
89 {
90 	DBG_DTOR(OQueryTableConnectionData,NULL);
91 }
92 
93 //------------------------------------------------------------------------
94 OConnectionLineDataRef OQueryTableConnectionData::CreateLineDataObj()
95 {
96 	DBG_CHKTHIS(OQueryTableConnectionData,NULL);
97 	// keine Spezialisierung bei den LineDatas, also eine Instanz der Standard-Klasse
98 	return new OConnectionLineData();
99 }
100 
101 //------------------------------------------------------------------------
102 OConnectionLineDataRef OQueryTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData )
103 {
104 	DBG_CHKTHIS(OQueryTableConnectionData,NULL);
105 	return new OConnectionLineData( rConnLineData );
106 }
107 
108 //------------------------------------------------------------------------
109 void OQueryTableConnectionData::CopyFrom(const OTableConnectionData& rSource)
110 {
111 	DBG_CHKTHIS(OQueryTableConnectionData,NULL);
112 	// wie in der Basisklasse zurueckziehen auf das (nicht-virtuelle) operator=
113 	*this = (const OQueryTableConnectionData&)rSource;
114 }
115 
116 //------------------------------------------------------------------------
117 OQueryTableConnectionData& OQueryTableConnectionData::operator=(const OQueryTableConnectionData& rConnData)
118 {
119 	DBG_CHKTHIS(OQueryTableConnectionData,NULL);
120 	if (&rConnData == this)
121 		return *this;
122 
123 	OTableConnectionData::operator=(rConnData);
124 
125 	m_nFromEntryIndex = rConnData.m_nFromEntryIndex;
126 	m_nDestEntryIndex = rConnData.m_nDestEntryIndex;
127 
128 	m_eFromType = rConnData.m_eFromType;
129 	m_eDestType = rConnData.m_eDestType;
130 	m_eJoinType = rConnData.m_eJoinType;
131     m_bNatural  = rConnData.m_bNatural;
132 
133 	return *this;
134 }
135 
136 //------------------------------------------------------------------------------
137 ::rtl::OUString OQueryTableConnectionData::GetAliasName(EConnectionSide nWhich) const
138 {
139 	DBG_CHKTHIS(OQueryTableConnectionData,NULL);
140 	return nWhich == JTCS_FROM ? m_pReferencingTable->GetWinName() : m_pReferencedTable->GetWinName();
141 }
142 
143 //------------------------------------------------------------------------------
144 void OQueryTableConnectionData::InitFromDrag(const OTableFieldDescRef& rDragLeft, const OTableFieldDescRef& rDragRight)
145 {
146 	DBG_CHKTHIS(OQueryTableConnectionData,NULL);
147 	// die Infos in rDrag in Parameter fuer das Basisklassen-Init umsetzen ...
148 	OQueryTableWindow* pSourceWin = static_cast<OQueryTableWindow*>(rDragLeft->GetTabWindow());
149 	OQueryTableWindow* pDestWin = static_cast<OQueryTableWindow*>(rDragRight->GetTabWindow());
150 	OSL_ENSURE(pSourceWin,"NO Source window found!");
151 	OSL_ENSURE(pDestWin,"NO Dest window found!");
152     m_pReferencingTable = pSourceWin->GetData();
153     m_pReferencedTable  = pDestWin->GetData();
154 
155 	// und dann meine Members setzen
156 	SetFieldIndex(JTCS_FROM, rDragLeft->GetFieldIndex());
157 	SetFieldIndex(JTCS_TO, rDragRight->GetFieldIndex());
158 
159 	SetFieldType(JTCS_FROM, rDragLeft->GetFieldType());
160 	SetFieldType(JTCS_TO, rDragRight->GetFieldType());
161 
162 	AppendConnLine((::rtl::OUString)rDragLeft->GetField(),(::rtl::OUString)rDragRight->GetField());
163 }
164 // -----------------------------------------------------------------------------
165 OTableConnectionData* OQueryTableConnectionData::NewInstance() const
166 {
167 	return new OQueryTableConnectionData();
168 }
169 // -----------------------------------------------------------------------------
170 sal_Bool OQueryTableConnectionData::Update()
171 {
172 	return sal_True;
173 }
174 // -----------------------------------------------------------------------------
175 
176 
177 
178 
179