fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / relationdesign / RTableConnection.cxx
blob35cc2e16d8f73207ae7150b1d0c6d7de35dee368
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 <tools/debug.hxx>
22 #include "RelationTableView.hxx"
23 #include <vcl/svapp.hxx>
24 #include <vcl/settings.hxx>
25 #include "ConnectionLine.hxx"
27 using namespace dbaui;
28 // class ORelationTableConnection
29 ORelationTableConnection::ORelationTableConnection( ORelationTableView* pContainer,
30 const TTableConnectionData::value_type& pTabConnData )
31 :OTableConnection( pContainer, pTabConnData )
35 ORelationTableConnection::ORelationTableConnection( const ORelationTableConnection& rConn )
36 : OTableConnection( rConn )
38 // no own members, thus the base class functionality is enough
41 ORelationTableConnection& ORelationTableConnection::operator=( const ORelationTableConnection& rConn )
43 // this doesn't change anything, since the base class tests this, too and I don't have my own members to copy
44 if (&rConn == this)
45 return *this;
47 OTableConnection::operator=( rConn );
48 return *this;
51 void ORelationTableConnection::Draw(vcl::RenderContext& rRenderContext, const Rectangle& rRect )
53 OTableConnection::Draw(rRenderContext, rRect);
54 ORelationTableConnectionData* pData = static_cast< ORelationTableConnectionData* >(GetData().get());
55 if (pData && (pData->GetCardinality() == CARDINAL_UNDEFINED))
56 return;
58 // search lines for top line
59 Rectangle aBoundingRect;
60 long nTop = GetBoundingRect().Bottom();
61 long nTemp;
63 const OConnectionLine* pTopLine = NULL;
64 const ::std::vector<OConnectionLine*>& rConnLineList = GetConnLineList();
65 std::vector<OConnectionLine*>::const_iterator aIter = rConnLineList.begin();
66 std::vector<OConnectionLine*>::const_iterator aEnd = rConnLineList.end();
68 for(;aIter != aEnd;++aIter)
70 if( (*aIter)->IsValid() )
72 aBoundingRect = (*aIter)->GetBoundingRect();
73 nTemp = aBoundingRect.Top();
74 if(nTemp < nTop)
76 nTop = nTemp;
77 pTopLine = (*aIter);
82 // cardinality
83 if (!pTopLine)
84 return;
86 Rectangle aSourcePos = pTopLine->GetSourceTextPos();
87 Rectangle aDestPos = pTopLine->GetDestTextPos();
89 OUString aSourceText;
90 OUString aDestText;
92 switch (pData->GetCardinality())
94 case CARDINAL_ONE_MANY:
95 aSourceText = "1";
96 aDestText = "n";
97 break;
99 case CARDINAL_MANY_ONE:
100 aSourceText = "n";
101 aDestText = "1";
102 break;
104 case CARDINAL_ONE_ONE:
105 aSourceText = "1";
106 aDestText = "1";
107 break;
110 if (IsSelected())
111 rRenderContext.SetTextColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
112 else
113 rRenderContext.SetTextColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor());
115 rRenderContext.DrawText(aSourcePos, aSourceText, DrawTextFlags::Clip | DrawTextFlags::Center | DrawTextFlags::Bottom);
116 rRenderContext.DrawText(aDestPos, aDestText, DrawTextFlags::Clip | DrawTextFlags::Center | DrawTextFlags::Bottom);
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */