LibreOffice Module dbaccess (master) 1
QTableConnectionData.cxx
Go to the documentation of this file.
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
21#include "QTableWindow.hxx"
22
23#include <osl/diagnose.h>
24
25using namespace dbaui;
26
27OQueryTableConnectionData::OQueryTableConnectionData()
28 : m_nFromEntryIndex(0)
29 , m_nDestEntryIndex(0)
30 , m_eJoinType (INNER_JOIN)
31 , m_bNatural(false)
32{
33}
34
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)
41{
42}
43
44OQueryTableConnectionData::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)
50 , m_bNatural(false)
51{
52}
53
55{
56}
57
59{
60 // same as in base class, use of (non-virtual) operator=
61 *this = static_cast<const OQueryTableConnectionData&>(rSource);
62}
63
65{
66 if (&rConnData == this)
67 return *this;
68
70
73
74 m_eJoinType = rConnData.m_eJoinType;
75 m_bNatural = rConnData.m_bNatural;
76
77 return *this;
78}
79
81{
82 return nWhich == JTCS_FROM ? m_pReferencingTable->GetWinName() : m_pReferencedTable->GetWinName();
83}
84
86{
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 OSL_ENSURE(pSourceWin,"NO Source window found!");
91 OSL_ENSURE(pDestWin,"NO Dest window found!");
92 m_pReferencingTable = pSourceWin->GetData();
93 m_pReferencedTable = pDestWin->GetData();
94
95 // set members
96 SetFieldIndex(JTCS_FROM, rDragLeft->GetFieldIndex());
97 SetFieldIndex(JTCS_TO, rDragRight->GetFieldIndex());
98
99 AppendConnLine(rDragLeft->GetField(), rDragRight->GetField());
100}
101
102std::shared_ptr<OTableConnectionData> OQueryTableConnectionData::NewInstance() const
103{
104 return std::make_shared<OQueryTableConnectionData>();
105}
106
108{
109 return true;
110}
111
112/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFieldIndex(EConnectionSide nWhich, sal_Int32 nVal)
OQueryTableConnectionData & operator=(const OQueryTableConnectionData &rConnData)
virtual void CopyFrom(const OTableConnectionData &rSource) override
initialise from a source (more comfortable than a virtual assignment operator)
virtual std::shared_ptr< OTableConnectionData > NewInstance() const override
deliver a new instance of my own type
virtual bool Update() override
Update create a new connection.
OUString const & GetAliasName(EConnectionSide nWhich) const
void InitFromDrag(const OTableFieldDescRef &rDragLeft, const OTableFieldDescRef &rDragRight)
Contains all connection data which exists between two windows.
TTableWindowData::value_type m_pReferencedTable
TTableWindowData::value_type m_pReferencingTable
bool AppendConnLine(const OUString &rSourceFieldName, const OUString &rDestFieldName)
OTableConnectionData & operator=(const OTableConnectionData &rConnData)
const TTableWindowData::value_type & GetData() const
EConnectionSide
Definition: QEnumTypes.hxx:42
@ JTCS_TO
Definition: QEnumTypes.hxx:44
@ JTCS_FROM
Definition: QEnumTypes.hxx:43
@ INNER_JOIN
Definition: QEnumTypes.hxx:59