Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "QTableConnectionData.hxx"
21 : #include <tools/debug.hxx>
22 : #include "QTableWindow.hxx"
23 :
24 : using namespace dbaui;
25 :
26 : // class OQueryTableConnectionData
27 0 : OQueryTableConnectionData::OQueryTableConnectionData()
28 : : OTableConnectionData()
29 : , m_nFromEntryIndex(0)
30 : , m_nDestEntryIndex(0)
31 : , m_eJoinType (INNER_JOIN)
32 : , m_bNatural(false)
33 : , m_eFromType(TAB_NORMAL_FIELD)
34 0 : , m_eDestType(TAB_NORMAL_FIELD)
35 : {
36 0 : }
37 :
38 0 : 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 0 : , m_eDestType(rConnData.m_eDestType)
46 : {
47 :
48 0 : }
49 :
50 0 : 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)
57 : , m_bNatural(false)
58 : , m_eFromType(TAB_NORMAL_FIELD)
59 0 : , m_eDestType(TAB_NORMAL_FIELD)
60 : {
61 0 : }
62 :
63 0 : OQueryTableConnectionData::~OQueryTableConnectionData()
64 : {
65 0 : }
66 :
67 0 : OConnectionLineDataRef OQueryTableConnectionData::CreateLineDataObj()
68 : {
69 : // no specializing of LineDatas, so it is an instance of standard class
70 0 : return new OConnectionLineData();
71 : }
72 :
73 0 : OConnectionLineDataRef OQueryTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData )
74 : {
75 0 : return new OConnectionLineData( rConnLineData );
76 : }
77 :
78 0 : void OQueryTableConnectionData::CopyFrom(const OTableConnectionData& rSource)
79 : {
80 : // same as in base class, use of (non-virtual) operator=
81 0 : *this = (const OQueryTableConnectionData&)rSource;
82 0 : }
83 :
84 0 : OQueryTableConnectionData& OQueryTableConnectionData::operator=(const OQueryTableConnectionData& rConnData)
85 : {
86 0 : if (&rConnData == this)
87 0 : return *this;
88 :
89 0 : OTableConnectionData::operator=(rConnData);
90 :
91 0 : m_nFromEntryIndex = rConnData.m_nFromEntryIndex;
92 0 : m_nDestEntryIndex = rConnData.m_nDestEntryIndex;
93 :
94 0 : m_eFromType = rConnData.m_eFromType;
95 0 : m_eDestType = rConnData.m_eDestType;
96 0 : m_eJoinType = rConnData.m_eJoinType;
97 0 : m_bNatural = rConnData.m_bNatural;
98 :
99 0 : return *this;
100 : }
101 :
102 0 : OUString OQueryTableConnectionData::GetAliasName(EConnectionSide nWhich) const
103 : {
104 0 : return nWhich == JTCS_FROM ? m_pReferencingTable->GetWinName() : m_pReferencedTable->GetWinName();
105 : }
106 :
107 0 : void OQueryTableConnectionData::InitFromDrag(const OTableFieldDescRef& rDragLeft, const OTableFieldDescRef& rDragRight)
108 : {
109 : // convert Information in rDrag into parameters for the base class init
110 0 : OQueryTableWindow* pSourceWin = static_cast<OQueryTableWindow*>(rDragLeft->GetTabWindow());
111 0 : OQueryTableWindow* pDestWin = static_cast<OQueryTableWindow*>(rDragRight->GetTabWindow());
112 : OSL_ENSURE(pSourceWin,"NO Source window found!");
113 : OSL_ENSURE(pDestWin,"NO Dest window found!");
114 0 : m_pReferencingTable = pSourceWin->GetData();
115 0 : m_pReferencedTable = pDestWin->GetData();
116 :
117 : // set members
118 0 : SetFieldIndex(JTCS_FROM, rDragLeft->GetFieldIndex());
119 0 : SetFieldIndex(JTCS_TO, rDragRight->GetFieldIndex());
120 :
121 0 : SetFieldType(JTCS_FROM, rDragLeft->GetFieldType());
122 0 : SetFieldType(JTCS_TO, rDragRight->GetFieldType());
123 :
124 0 : AppendConnLine((OUString)rDragLeft->GetField(),(OUString)rDragRight->GetField());
125 0 : }
126 :
127 0 : OTableConnectionData* OQueryTableConnectionData::NewInstance() const
128 : {
129 0 : return new OQueryTableConnectionData();
130 : }
131 :
132 0 : sal_Bool OQueryTableConnectionData::Update()
133 : {
134 0 : return sal_True;
135 : }
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|