1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "QTableConnectionData.hxx"
21 #include <tools/debug.hxx>
22 #include "QTableWindow.hxx"
24 using namespace dbaui
;
26 // class OQueryTableConnectionData
27 OQueryTableConnectionData::OQueryTableConnectionData()
28 : OTableConnectionData()
29 , m_nFromEntryIndex(0)
30 , m_nDestEntryIndex(0)
31 , m_eJoinType (INNER_JOIN
)
33 , m_eFromType(TAB_NORMAL_FIELD
)
34 , m_eDestType(TAB_NORMAL_FIELD
)
38 OQueryTableConnectionData::OQueryTableConnectionData( const OQueryTableConnectionData
& rConnData
)
39 : OTableConnectionData( rConnData
)
40 , m_nFromEntryIndex(rConnData
.m_nFromEntryIndex
)
41 , m_nDestEntryIndex(rConnData
.m_nDestEntryIndex
)
42 , m_eJoinType(rConnData
.m_eJoinType
)
43 , m_bNatural(rConnData
.m_bNatural
)
44 , m_eFromType(rConnData
.m_eFromType
)
45 , m_eDestType(rConnData
.m_eDestType
)
50 OQueryTableConnectionData::OQueryTableConnectionData(const TTableWindowData::value_type
& _pReferencingTable
,
51 const TTableWindowData::value_type
& _pReferencedTable
,
52 const OUString
& rConnName
)
53 : OTableConnectionData( _pReferencingTable
,_pReferencedTable
, rConnName
)
54 , m_nFromEntryIndex(0)
55 , m_nDestEntryIndex(0)
56 , m_eJoinType (INNER_JOIN
)
58 , m_eFromType(TAB_NORMAL_FIELD
)
59 , m_eDestType(TAB_NORMAL_FIELD
)
63 OQueryTableConnectionData::~OQueryTableConnectionData()
67 OConnectionLineDataRef
OQueryTableConnectionData::CreateLineDataObj()
69 // no specializing of LineDatas, so it is an instance of standard class
70 return new OConnectionLineData();
73 OConnectionLineDataRef
OQueryTableConnectionData::CreateLineDataObj( const OConnectionLineData
& rConnLineData
)
75 return new OConnectionLineData( rConnLineData
);
78 void OQueryTableConnectionData::CopyFrom(const OTableConnectionData
& rSource
)
80 // same as in base class, use of (non-virtual) operator=
81 *this = static_cast<const OQueryTableConnectionData
&>(rSource
);
84 OQueryTableConnectionData
& OQueryTableConnectionData::operator=(const OQueryTableConnectionData
& rConnData
)
86 if (&rConnData
== this)
89 OTableConnectionData::operator=(rConnData
);
91 m_nFromEntryIndex
= rConnData
.m_nFromEntryIndex
;
92 m_nDestEntryIndex
= rConnData
.m_nDestEntryIndex
;
94 m_eFromType
= rConnData
.m_eFromType
;
95 m_eDestType
= rConnData
.m_eDestType
;
96 m_eJoinType
= rConnData
.m_eJoinType
;
97 m_bNatural
= rConnData
.m_bNatural
;
102 OUString
OQueryTableConnectionData::GetAliasName(EConnectionSide nWhich
) const
104 return nWhich
== JTCS_FROM
? m_pReferencingTable
->GetWinName() : m_pReferencedTable
->GetWinName();
107 void OQueryTableConnectionData::InitFromDrag(const OTableFieldDescRef
& rDragLeft
, const OTableFieldDescRef
& rDragRight
)
109 // convert Information in rDrag into parameters for the base class init
110 OQueryTableWindow
* pSourceWin
= static_cast<OQueryTableWindow
*>(rDragLeft
->GetTabWindow());
111 OQueryTableWindow
* pDestWin
= static_cast<OQueryTableWindow
*>(rDragRight
->GetTabWindow());
112 OSL_ENSURE(pSourceWin
,"NO Source window found!");
113 OSL_ENSURE(pDestWin
,"NO Dest window found!");
114 m_pReferencingTable
= pSourceWin
->GetData();
115 m_pReferencedTable
= pDestWin
->GetData();
118 SetFieldIndex(JTCS_FROM
, rDragLeft
->GetFieldIndex());
119 SetFieldIndex(JTCS_TO
, rDragRight
->GetFieldIndex());
121 SetFieldType(JTCS_FROM
, rDragLeft
->GetFieldType());
122 SetFieldType(JTCS_TO
, rDragRight
->GetFieldType());
124 AppendConnLine(rDragLeft
->GetField(), rDragRight
->GetField());
127 OTableConnectionData
* OQueryTableConnectionData::NewInstance() const
129 return new OQueryTableConnectionData();
132 bool OQueryTableConnectionData::Update()
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */