Branch data Line data Source code
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"
21 : : #include <tools/debug.hxx>
22 : : #include "RelationTableView.hxx"
23 : : #include <vcl/svapp.hxx>
24 : : #include "ConnectionLine.hxx"
25 : :
26 : : using namespace dbaui;
27 : : //========================================================================
28 : : // class ORelationTableConnection
29 : : //========================================================================
30 : : DBG_NAME(ORelationTableConnection)
31 : : //------------------------------------------------------------------------
32 : 0 : ORelationTableConnection::ORelationTableConnection( ORelationTableView* pContainer,
33 : : const TTableConnectionData::value_type& pTabConnData )
34 : 0 : :OTableConnection( pContainer, pTabConnData )
35 : : {
36 : : DBG_CTOR(ORelationTableConnection,NULL);
37 : 0 : }
38 : :
39 : : //------------------------------------------------------------------------
40 : 0 : ORelationTableConnection::ORelationTableConnection( const ORelationTableConnection& rConn )
41 : 0 : : OTableConnection( rConn )
42 : : {
43 : : DBG_CTOR(ORelationTableConnection,NULL);
44 : : // keine eigenen Members, also reicht die Basisklassenfunktionalitaet
45 : 0 : }
46 : :
47 : : //------------------------------------------------------------------------
48 : 0 : ORelationTableConnection::~ORelationTableConnection()
49 : : {
50 : : DBG_DTOR(ORelationTableConnection,NULL);
51 [ # # ]: 0 : }
52 : :
53 : : //------------------------------------------------------------------------
54 : 0 : ORelationTableConnection& ORelationTableConnection::operator=( const ORelationTableConnection& rConn )
55 : : {
56 : : DBG_CHKTHIS(ORelationTableConnection,NULL);
57 : : // nicht dass es was aendern wuerde, da die Basisklasse das auch testet und ich keine eigenen Members zu kopieren habe
58 [ # # ]: 0 : if (&rConn == this)
59 : 0 : return *this;
60 : :
61 : 0 : OTableConnection::operator=( rConn );
62 : 0 : return *this;
63 : : }
64 : :
65 : :
66 : : //------------------------------------------------------------------------
67 : 0 : void ORelationTableConnection::Draw( const Rectangle& rRect )
68 : : {
69 : : DBG_CHKTHIS(ORelationTableConnection,NULL);
70 [ # # ]: 0 : OTableConnection::Draw( rRect );
71 [ # # ][ # # ]: 0 : ORelationTableConnectionData* pData = static_cast< ORelationTableConnectionData* >(GetData().get());
72 [ # # ][ # # ]: 0 : if ( pData && (pData->GetCardinality() == CARDINAL_UNDEFINED) )
[ # # ]
73 : : return;
74 : :
75 : : //////////////////////////////////////////////////////////////////////
76 : : // Linien nach oberster Linie durchsuchen
77 [ # # ]: 0 : Rectangle aBoundingRect;
78 [ # # ]: 0 : long nTop = GetBoundingRect().Bottom();
79 : : long nTemp;
80 : :
81 : 0 : const OConnectionLine* pTopLine = NULL;
82 : 0 : const ::std::vector<OConnectionLine*>* pConnLineList = GetConnLineList();
83 : 0 : ::std::vector<OConnectionLine*>::const_iterator aIter = pConnLineList->begin();
84 : 0 : ::std::vector<OConnectionLine*>::const_iterator aEnd = pConnLineList->end();
85 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
86 : : {
87 [ # # ][ # # ]: 0 : if( (*aIter)->IsValid() )
88 : : {
89 [ # # ]: 0 : aBoundingRect = (*aIter)->GetBoundingRect();
90 : 0 : nTemp = aBoundingRect.Top();
91 [ # # ]: 0 : if( nTemp<nTop )
92 : : {
93 : 0 : nTop = nTemp;
94 : 0 : pTopLine = (*aIter);
95 : : }
96 : : }
97 : : }
98 : :
99 : : //////////////////////////////////////////////////////////////////////
100 : : // Kardinalitaet antragen
101 [ # # ]: 0 : if( !pTopLine )
102 : : return;
103 : :
104 [ # # ]: 0 : Rectangle aSourcePos = pTopLine->GetSourceTextPos();
105 [ # # ]: 0 : Rectangle aDestPos = pTopLine->GetDestTextPos();
106 : :
107 [ # # ]: 0 : String aSourceText;
108 [ # # ]: 0 : String aDestText;
109 : :
110 [ # # # # ]: 0 : switch( pData->GetCardinality() )
111 : : {
112 : : case CARDINAL_ONE_MANY:
113 [ # # ]: 0 : aSourceText ='1';
114 [ # # ]: 0 : aDestText ='n';
115 : 0 : break;
116 : :
117 : : case CARDINAL_MANY_ONE:
118 [ # # ]: 0 : aSourceText ='n';
119 [ # # ]: 0 : aDestText ='1';
120 : 0 : break;
121 : :
122 : : case CARDINAL_ONE_ONE:
123 [ # # ]: 0 : aSourceText ='1';
124 [ # # ]: 0 : aDestText ='1';
125 : 0 : break;
126 : : }
127 : :
128 [ # # ]: 0 : if (IsSelected())
129 [ # # ][ # # ]: 0 : GetParent()->SetTextColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
130 : : else
131 [ # # ][ # # ]: 0 : GetParent()->SetTextColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor());
132 : :
133 : :
134 [ # # ]: 0 : GetParent()->DrawText( aSourcePos, aSourceText, TEXT_DRAW_CLIP | TEXT_DRAW_CENTER | TEXT_DRAW_BOTTOM);
135 [ # # ][ # # ]: 0 : GetParent()->DrawText( aDestPos, aDestText, TEXT_DRAW_CLIP | TEXT_DRAW_CENTER | TEXT_DRAW_BOTTOM);
[ # # ]
136 : : }
137 : : // -----------------------------------------------------------------------------
138 : :
139 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|