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