calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / dbaccess / source / ui / relationdesign / RTableConnection.cxx
blobba60ae54661b5ef30cfb4cd06f5ca01f073d97c1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
43 if (&rConn == this)
44 return *this;
46 OTableConnection::operator=( rConn );
47 return *this;
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))
55 return;
57 // search lines for top line
58 tools::Rectangle aBoundingRect;
59 tools::Long nTop = GetBoundingRect().Bottom();
60 tools::Long nTemp;
62 const OConnectionLine* pTopLine = nullptr;
63 const std::vector<std::unique_ptr<OConnectionLine>>& rConnLineList = GetConnLineList();
65 for (auto const& elem : rConnLineList)
67 if( elem->IsValid() )
69 aBoundingRect = elem->GetBoundingRect();
70 nTemp = aBoundingRect.Top();
71 if(nTemp < nTop)
73 nTop = nTemp;
74 pTopLine = elem.get();
79 // cardinality
80 if (!pTopLine)
81 return;
83 tools::Rectangle aSourcePos = pTopLine->GetSourceTextPos();
84 tools::Rectangle aDestPos = pTopLine->GetDestTextPos();
86 OUString aSourceText;
87 OUString aDestText;
89 switch (pData->GetCardinality())
91 case Cardinality::OneMany:
92 aSourceText = "1";
93 aDestText = "n";
94 break;
96 case Cardinality::ManyOne:
97 aSourceText = "n";
98 aDestText = "1";
99 break;
101 case Cardinality::OneOne:
102 aSourceText = "1";
103 aDestText = "1";
104 break;
105 default: break;
108 if (IsSelected())
109 rRenderContext.SetTextColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
110 else
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: */