LibreOffice Module dbaccess (master) 1
RTableConnection.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
20#include "RTableConnection.hxx"
22#include <RelationTableView.hxx>
23#include <vcl/svapp.hxx>
24#include <vcl/settings.hxx>
25#include <ConnectionLine.hxx>
26
27using namespace dbaui;
28ORelationTableConnection::ORelationTableConnection( ORelationTableView* pContainer,
29 const TTableConnectionData::value_type& pTabConnData )
30 :OTableConnection( pContainer, pTabConnData )
31{
32}
33
36{
37 // no own members, thus the base class functionality is enough
38}
39
41{
42 // this doesn't change anything, since the base class tests this, too and I don't have my own members to copy
43 if (&rConn == this)
44 return *this;
45
47 return *this;
48}
49
51{
52 OTableConnection::Draw(rRenderContext, rRect);
54 if (pData && (pData->GetCardinality() == Cardinality::Undefined))
55 return;
56
57 // search lines for top line
58 tools::Rectangle aBoundingRect;
60 tools::Long nTemp;
61
62 const OConnectionLine* pTopLine = nullptr;
63 const std::vector<std::unique_ptr<OConnectionLine>>& rConnLineList = GetConnLineList();
64
65 for (auto const& elem : rConnLineList)
66 {
67 if( elem->IsValid() )
68 {
69 aBoundingRect = elem->GetBoundingRect();
70 nTemp = aBoundingRect.Top();
71 if(nTemp < nTop)
72 {
73 nTop = nTemp;
74 pTopLine = elem.get();
75 }
76 }
77 }
78
79 // cardinality
80 if (!pTopLine)
81 return;
82
83 tools::Rectangle aSourcePos = pTopLine->GetSourceTextPos();
84 tools::Rectangle aDestPos = pTopLine->GetDestTextPos();
85
86 OUString aSourceText;
87 OUString aDestText;
88
89 switch (pData->GetCardinality())
90 {
92 aSourceText = "1";
93 aDestText = "n";
94 break;
95
97 aSourceText = "n";
98 aDestText = "1";
99 break;
100
102 aSourceText = "1";
103 aDestText = "1";
104 break;
105 default: break;
106 }
107
108 if (IsSelected())
109 rRenderContext.SetTextColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
110 else
111 rRenderContext.SetTextColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor());
112
113 rRenderContext.DrawText(aSourcePos, aSourceText, DrawTextFlags::Clip | DrawTextFlags::Center | DrawTextFlags::Bottom);
114 rRenderContext.DrawText(aDestPos, aDestText, DrawTextFlags::Clip | DrawTextFlags::Center | DrawTextFlags::Bottom);
115}
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static const AllSettings & GetSettings()
void SetTextColor(const Color &rColor)
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
tools::Rectangle GetDestTextPos() const
tools::Rectangle GetSourceTextPos() const
virtual void Draw(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
ORelationTableConnection & operator=(const ORelationTableConnection &rConn)
ORelationTableConnection(ORelationTableView *pContainer, const TTableConnectionData::value_type &pTabConnData)
const TTableConnectionData::value_type & GetData() const
OTableConnection & operator=(const OTableConnection &rConn)
tools::Rectangle GetBoundingRect() const
const std::vector< std::unique_ptr< OConnectionLine > > & GetConnLineList() const
virtual void Draw(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
constexpr tools::Long Top() const
constexpr tools::Long Bottom() const
std::unique_ptr< sal_Int32[]> pData
long Long