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 "RTableConnection.hxx"
21 #include <RTableConnectionData.hxx>
22 #include <RelationTableView.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/settings.hxx>
25 #include <ConnectionLine.hxx>
27 using namespace dbaui
;
28 ORelationTableConnection::ORelationTableConnection( ORelationTableView
* pContainer
,
29 const TTableConnectionData::value_type
& pTabConnData
)
30 :OTableConnection( pContainer
, pTabConnData
)
34 ORelationTableConnection::ORelationTableConnection( const ORelationTableConnection
& rConn
)
35 : VclReferenceBase(), OTableConnection( rConn
)
37 // no own members, thus the base class functionality is enough
40 ORelationTableConnection
& ORelationTableConnection::operator=( const ORelationTableConnection
& rConn
)
42 // this doesn't change anything, since the base class tests this, too and I don't have my own members to copy
46 OTableConnection::operator=( rConn
);
50 void ORelationTableConnection::Draw(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
)
52 OTableConnection::Draw(rRenderContext
, rRect
);
53 ORelationTableConnectionData
* pData
= static_cast< ORelationTableConnectionData
* >(GetData().get());
54 if (pData
&& (pData
->GetCardinality() == Cardinality::Undefined
))
57 // search lines for top line
58 tools::Rectangle aBoundingRect
;
59 tools::Long nTop
= GetBoundingRect().Bottom();
62 const OConnectionLine
* pTopLine
= nullptr;
63 const std::vector
<std::unique_ptr
<OConnectionLine
>>& rConnLineList
= GetConnLineList();
65 for (auto const& elem
: rConnLineList
)
69 aBoundingRect
= elem
->GetBoundingRect();
70 nTemp
= aBoundingRect
.Top();
74 pTopLine
= elem
.get();
83 tools::Rectangle aSourcePos
= pTopLine
->GetSourceTextPos();
84 tools::Rectangle aDestPos
= pTopLine
->GetDestTextPos();
89 switch (pData
->GetCardinality())
91 case Cardinality::OneMany
:
96 case Cardinality::ManyOne
:
101 case Cardinality::OneOne
:
109 rRenderContext
.SetTextColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
111 rRenderContext
.SetTextColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor());
113 rRenderContext
.DrawText(aSourcePos
, aSourceText
, DrawTextFlags::Clip
| DrawTextFlags::Center
| DrawTextFlags::Bottom
);
114 rRenderContext
.DrawText(aDestPos
, aDestText
, DrawTextFlags::Clip
| DrawTextFlags::Center
| DrawTextFlags::Bottom
);
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */