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 "QTableWindow.hxx"
23 #include <osl/diagnose.h>
25 using namespace dbaui
;
27 OQueryTableConnectionData::OQueryTableConnectionData()
28 : m_nFromEntryIndex(0)
29 , m_nDestEntryIndex(0)
30 , m_eJoinType (INNER_JOIN
)
35 OQueryTableConnectionData::OQueryTableConnectionData( const OQueryTableConnectionData
& rConnData
)
36 : OTableConnectionData( rConnData
)
37 , m_nFromEntryIndex(rConnData
.m_nFromEntryIndex
)
38 , m_nDestEntryIndex(rConnData
.m_nDestEntryIndex
)
39 , m_eJoinType(rConnData
.m_eJoinType
)
40 , m_bNatural(rConnData
.m_bNatural
)
44 OQueryTableConnectionData::OQueryTableConnectionData(const TTableWindowData::value_type
& _pReferencingTable
,
45 const TTableWindowData::value_type
& _pReferencedTable
)
46 : OTableConnectionData( _pReferencingTable
,_pReferencedTable
)
47 , m_nFromEntryIndex(0)
48 , m_nDestEntryIndex(0)
49 , m_eJoinType (INNER_JOIN
)
54 OQueryTableConnectionData::~OQueryTableConnectionData()
58 void OQueryTableConnectionData::CopyFrom(const OTableConnectionData
& rSource
)
60 // same as in base class, use of (non-virtual) operator=
61 *this = static_cast<const OQueryTableConnectionData
&>(rSource
);
64 OQueryTableConnectionData
& OQueryTableConnectionData::operator=(const OQueryTableConnectionData
& rConnData
)
66 if (&rConnData
== this)
69 OTableConnectionData::operator=(rConnData
);
71 m_nFromEntryIndex
= rConnData
.m_nFromEntryIndex
;
72 m_nDestEntryIndex
= rConnData
.m_nDestEntryIndex
;
74 m_eJoinType
= rConnData
.m_eJoinType
;
75 m_bNatural
= rConnData
.m_bNatural
;
80 OUString
const & OQueryTableConnectionData::GetAliasName(EConnectionSide nWhich
) const
82 return nWhich
== JTCS_FROM
? m_pReferencingTable
->GetWinName() : m_pReferencedTable
->GetWinName();
85 void OQueryTableConnectionData::InitFromDrag(const OTableFieldDescRef
& rDragLeft
, const OTableFieldDescRef
& rDragRight
)
87 // convert Information in rDrag into parameters for the base class init
88 OQueryTableWindow
* pSourceWin
= static_cast<OQueryTableWindow
*>(rDragLeft
->GetTabWindow());
89 OQueryTableWindow
* pDestWin
= static_cast<OQueryTableWindow
*>(rDragRight
->GetTabWindow());
90 assert(pSourceWin
&& "NO Source window found!");
91 assert(pDestWin
&& "NO Dest window found!");
92 m_pReferencingTable
= pSourceWin
->GetData();
93 m_pReferencedTable
= pDestWin
->GetData();
96 SetFieldIndex(JTCS_FROM
, rDragLeft
->GetFieldIndex());
97 SetFieldIndex(JTCS_TO
, rDragRight
->GetFieldIndex());
99 AppendConnLine(rDragLeft
->GetField(), rDragRight
->GetField());
102 std::shared_ptr
<OTableConnectionData
> OQueryTableConnectionData::NewInstance() const
104 return std::make_shared
<OQueryTableConnectionData
>();
107 bool OQueryTableConnectionData::Update()
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */