2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-17 06:27:38 +00:00
|
|
|
|
2001-02-28 09:09:17 +00:00
|
|
|
#include "RTableConnection.hxx"
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include "RelationTableView.hxx"
|
|
|
|
#include <vcl/svapp.hxx>
|
2014-01-02 23:52:37 +01:00
|
|
|
#include <vcl/settings.hxx>
|
2002-02-06 07:31:04 +00:00
|
|
|
#include "ConnectionLine.hxx"
|
2001-02-28 09:09:17 +00:00
|
|
|
|
|
|
|
using namespace dbaui;
|
|
|
|
// class ORelationTableConnection
|
|
|
|
ORelationTableConnection::ORelationTableConnection( ORelationTableView* pContainer,
|
2007-11-01 14:36:29 +00:00
|
|
|
const TTableConnectionData::value_type& pTabConnData )
|
2001-02-28 09:09:17 +00:00
|
|
|
:OTableConnection( pContainer, pTabConnData )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ORelationTableConnection::ORelationTableConnection( const ORelationTableConnection& rConn )
|
|
|
|
: OTableConnection( rConn )
|
|
|
|
{
|
2014-02-22 21:20:15 +01:00
|
|
|
// no own members, thus the base class functionality is enough
|
2001-02-28 09:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ORelationTableConnection::~ORelationTableConnection()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ORelationTableConnection& ORelationTableConnection::operator=( const ORelationTableConnection& rConn )
|
|
|
|
{
|
2014-02-22 21:20:15 +01:00
|
|
|
// this doesn't change anything, since the base class tests this, too and I don't have my own members to copy
|
2001-02-28 09:09:17 +00:00
|
|
|
if (&rConn == this)
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
OTableConnection::operator=( rConn );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ORelationTableConnection::Draw( const Rectangle& rRect )
|
|
|
|
{
|
|
|
|
OTableConnection::Draw( rRect );
|
2008-10-01 12:28:29 +00:00
|
|
|
ORelationTableConnectionData* pData = static_cast< ORelationTableConnectionData* >(GetData().get());
|
2006-10-12 12:43:36 +00:00
|
|
|
if ( pData && (pData->GetCardinality() == CARDINAL_UNDEFINED) )
|
2001-02-28 09:09:17 +00:00
|
|
|
return;
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
// search lines for top line
|
2001-02-28 09:09:17 +00:00
|
|
|
Rectangle aBoundingRect;
|
|
|
|
long nTop = GetBoundingRect().Bottom();
|
|
|
|
long nTemp;
|
|
|
|
|
|
|
|
const OConnectionLine* pTopLine = NULL;
|
|
|
|
const ::std::vector<OConnectionLine*>* pConnLineList = GetConnLineList();
|
|
|
|
::std::vector<OConnectionLine*>::const_iterator aIter = pConnLineList->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector<OConnectionLine*>::const_iterator aEnd = pConnLineList->end();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-28 09:09:17 +00:00
|
|
|
{
|
|
|
|
if( (*aIter)->IsValid() )
|
|
|
|
{
|
|
|
|
aBoundingRect = (*aIter)->GetBoundingRect();
|
|
|
|
nTemp = aBoundingRect.Top();
|
|
|
|
if( nTemp<nTop )
|
|
|
|
{
|
|
|
|
nTop = nTemp;
|
|
|
|
pTopLine = (*aIter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
// cardinality
|
2001-02-28 09:09:17 +00:00
|
|
|
if( !pTopLine )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Rectangle aSourcePos = pTopLine->GetSourceTextPos();
|
|
|
|
Rectangle aDestPos = pTopLine->GetDestTextPos();
|
|
|
|
|
2013-09-27 12:04:57 +02:00
|
|
|
OUString aSourceText;
|
|
|
|
OUString aDestText;
|
2001-02-28 09:09:17 +00:00
|
|
|
|
2007-11-01 14:36:29 +00:00
|
|
|
switch( pData->GetCardinality() )
|
2001-02-28 09:09:17 +00:00
|
|
|
{
|
|
|
|
case CARDINAL_ONE_MANY:
|
2013-09-27 12:04:57 +02:00
|
|
|
aSourceText = "1";
|
|
|
|
aDestText = "n";
|
2001-02-28 09:09:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CARDINAL_MANY_ONE:
|
2013-09-27 12:04:57 +02:00
|
|
|
aSourceText = "n";
|
|
|
|
aDestText = "1";
|
2001-02-28 09:09:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CARDINAL_ONE_ONE:
|
2013-09-27 12:04:57 +02:00
|
|
|
aSourceText = "1";
|
|
|
|
aDestText = "1";
|
2001-02-28 09:09:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsSelected())
|
|
|
|
GetParent()->SetTextColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
|
|
|
|
else
|
|
|
|
GetParent()->SetTextColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor());
|
|
|
|
|
|
|
|
GetParent()->DrawText( aSourcePos, aSourceText, TEXT_DRAW_CLIP | TEXT_DRAW_CENTER | TEXT_DRAW_BOTTOM);
|
|
|
|
GetParent()->DrawText( aDestPos, aDestText, TEXT_DRAW_CLIP | TEXT_DRAW_CENTER | TEXT_DRAW_BOTTOM);
|
|
|
|
}
|
2010-10-12 15:59:03 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|