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