update dev300-m58
[ooovba.git] / dbaccess / source / ui / relationdesign / RTableConnection.cxx
blobd94e511d368af16a24e108ad23a0ce680f3548f8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RTableConnection.cxx,v $
10 * $Revision: 1.10.68.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBAUI_RTABLECONNECTION_HXX
34 #include "RTableConnection.hxx"
35 #endif
36 #ifndef _TOOLS_DEBUG_HXX
37 #include <tools/debug.hxx>
38 #endif
39 #ifndef DBAUI_RELATION_TABLEVIEW_HXX
40 #include "RelationTableView.hxx"
41 #endif
42 #ifndef _SV_SVAPP_HXX
43 #include <vcl/svapp.hxx>
44 #endif
45 #ifndef DBAUI_CONNECTIONLINE_HXX
46 #include "ConnectionLine.hxx"
47 #endif
49 using namespace dbaui;
50 //========================================================================
51 // class ORelationTableConnection
52 //========================================================================
53 DBG_NAME(ORelationTableConnection)
54 //------------------------------------------------------------------------
55 ORelationTableConnection::ORelationTableConnection( ORelationTableView* pContainer,
56 const TTableConnectionData::value_type& pTabConnData )
57 :OTableConnection( pContainer, pTabConnData )
59 DBG_CTOR(ORelationTableConnection,NULL);
62 //------------------------------------------------------------------------
63 ORelationTableConnection::ORelationTableConnection( const ORelationTableConnection& rConn )
64 : OTableConnection( rConn )
66 DBG_CTOR(ORelationTableConnection,NULL);
67 // keine eigenen Members, also reicht die Basisklassenfunktionalitaet
70 //------------------------------------------------------------------------
71 ORelationTableConnection::~ORelationTableConnection()
73 DBG_DTOR(ORelationTableConnection,NULL);
76 //------------------------------------------------------------------------
77 ORelationTableConnection& ORelationTableConnection::operator=( const ORelationTableConnection& rConn )
79 DBG_CHKTHIS(ORelationTableConnection,NULL);
80 // nicht dass es was aendern wuerde, da die Basisklasse das auch testet und ich keine eigenen Members zu kopieren habe
81 if (&rConn == this)
82 return *this;
84 OTableConnection::operator=( rConn );
85 return *this;
89 //------------------------------------------------------------------------
90 void ORelationTableConnection::Draw( const Rectangle& rRect )
92 DBG_CHKTHIS(ORelationTableConnection,NULL);
93 OTableConnection::Draw( rRect );
94 ORelationTableConnectionData* pData = static_cast< ORelationTableConnectionData* >(GetData().get());
95 if ( pData && (pData->GetCardinality() == CARDINAL_UNDEFINED) )
96 return;
98 //////////////////////////////////////////////////////////////////////
99 // Linien nach oberster Linie durchsuchen
100 Rectangle aBoundingRect;
101 long nTop = GetBoundingRect().Bottom();
102 long nTemp;
104 const OConnectionLine* pTopLine = NULL;
105 const ::std::vector<OConnectionLine*>* pConnLineList = GetConnLineList();
106 ::std::vector<OConnectionLine*>::const_iterator aIter = pConnLineList->begin();
107 ::std::vector<OConnectionLine*>::const_iterator aEnd = pConnLineList->end();
108 for(;aIter != aEnd;++aIter)
110 if( (*aIter)->IsValid() )
112 aBoundingRect = (*aIter)->GetBoundingRect();
113 nTemp = aBoundingRect.Top();
114 if( nTemp<nTop )
116 nTop = nTemp;
117 pTopLine = (*aIter);
122 //////////////////////////////////////////////////////////////////////
123 // Kardinalitaet antragen
124 if( !pTopLine )
125 return;
127 Rectangle aSourcePos = pTopLine->GetSourceTextPos();
128 Rectangle aDestPos = pTopLine->GetDestTextPos();
130 String aSourceText;
131 String aDestText;
133 switch( pData->GetCardinality() )
135 case CARDINAL_ONE_MANY:
136 aSourceText ='1';
137 aDestText ='n';
138 break;
140 case CARDINAL_MANY_ONE:
141 aSourceText ='n';
142 aDestText ='1';
143 break;
145 case CARDINAL_ONE_ONE:
146 aSourceText ='1';
147 aDestText ='1';
148 break;
151 if (IsSelected())
152 GetParent()->SetTextColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
153 else
154 GetParent()->SetTextColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor());
157 GetParent()->DrawText( aSourcePos, aSourceText, TEXT_DRAW_CLIP | TEXT_DRAW_CENTER | TEXT_DRAW_BOTTOM);
158 GetParent()->DrawText( aDestPos, aDestText, TEXT_DRAW_CLIP | TEXT_DRAW_CENTER | TEXT_DRAW_BOTTOM);
160 // -----------------------------------------------------------------------------