Kaydet (Commit) 37acd3c0 authored tarafından Noel Grandin's avatar Noel Grandin

convert CARDINALITY constants to scoped enum

Change-Id: I35cc98086850e62a2ea8703fc4b086ed2adff66a
üst 394b8e39
...@@ -26,10 +26,9 @@ ...@@ -26,10 +26,9 @@
namespace dbaui namespace dbaui
{ {
const sal_uInt16 CARDINAL_UNDEFINED = 0x0000; enum class Cardinality {
const sal_uInt16 CARDINAL_ONE_MANY = 0x0001; Undefined, OneMany, ManyOne, OneOne
const sal_uInt16 CARDINAL_MANY_ONE = 0x0002; };
const sal_uInt16 CARDINAL_ONE_ONE = 0x0004;
class OConnectionLineData; class OConnectionLineData;
class ORelationTableConnectionData : public OTableConnectionData class ORelationTableConnectionData : public OTableConnectionData
...@@ -41,7 +40,7 @@ namespace dbaui ...@@ -41,7 +40,7 @@ namespace dbaui
// @see com.sun.star.sdbc.KeyRule // @see com.sun.star.sdbc.KeyRule
sal_Int32 m_nUpdateRules; sal_Int32 m_nUpdateRules;
sal_Int32 m_nDeleteRules; sal_Int32 m_nDeleteRules;
sal_Int32 m_nCardinality; Cardinality m_nCardinality;
bool checkPrimaryKey(const css::uno::Reference< css::beans::XPropertySet>& i_xTable, EConnectionSide _eEConnectionSide) const; bool checkPrimaryKey(const css::uno::Reference< css::beans::XPropertySet>& i_xTable, EConnectionSide _eEConnectionSide) const;
bool IsSourcePrimKey() const { return checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM); } bool IsSourcePrimKey() const { return checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM); }
...@@ -74,7 +73,7 @@ namespace dbaui ...@@ -74,7 +73,7 @@ namespace dbaui
inline sal_Int32 GetUpdateRules() const { return m_nUpdateRules; } inline sal_Int32 GetUpdateRules() const { return m_nUpdateRules; }
inline sal_Int32 GetDeleteRules() const { return m_nDeleteRules; } inline sal_Int32 GetDeleteRules() const { return m_nDeleteRules; }
inline sal_Int32 GetCardinality() const { return m_nCardinality; } inline Cardinality GetCardinality() const { return m_nCardinality; }
bool IsConnectionPossible(); bool IsConnectionPossible();
void ChangeOrientation(); void ChangeOrientation();
......
...@@ -52,7 +52,7 @@ void ORelationTableConnection::Draw(vcl::RenderContext& rRenderContext, const Re ...@@ -52,7 +52,7 @@ void ORelationTableConnection::Draw(vcl::RenderContext& rRenderContext, const Re
{ {
OTableConnection::Draw(rRenderContext, rRect); OTableConnection::Draw(rRenderContext, rRect);
ORelationTableConnectionData* pData = static_cast< ORelationTableConnectionData* >(GetData().get()); ORelationTableConnectionData* pData = static_cast< ORelationTableConnectionData* >(GetData().get());
if (pData && (pData->GetCardinality() == CARDINAL_UNDEFINED)) if (pData && (pData->GetCardinality() == Cardinality::Undefined))
return; return;
// search lines for top line // search lines for top line
...@@ -91,20 +91,21 @@ void ORelationTableConnection::Draw(vcl::RenderContext& rRenderContext, const Re ...@@ -91,20 +91,21 @@ void ORelationTableConnection::Draw(vcl::RenderContext& rRenderContext, const Re
switch (pData->GetCardinality()) switch (pData->GetCardinality())
{ {
case CARDINAL_ONE_MANY: case Cardinality::OneMany:
aSourceText = "1"; aSourceText = "1";
aDestText = "n"; aDestText = "n";
break; break;
case CARDINAL_MANY_ONE: case Cardinality::ManyOne:
aSourceText = "n"; aSourceText = "n";
aDestText = "1"; aDestText = "1";
break; break;
case CARDINAL_ONE_ONE: case Cardinality::OneOne:
aSourceText = "1"; aSourceText = "1";
aDestText = "1"; aDestText = "1";
break; break;
default: break;
} }
if (IsSelected()) if (IsSelected())
......
...@@ -47,7 +47,7 @@ ORelationTableConnectionData::ORelationTableConnectionData() ...@@ -47,7 +47,7 @@ ORelationTableConnectionData::ORelationTableConnectionData()
:OTableConnectionData() :OTableConnectionData()
,m_nUpdateRules(KeyRule::NO_ACTION) ,m_nUpdateRules(KeyRule::NO_ACTION)
,m_nDeleteRules(KeyRule::NO_ACTION) ,m_nDeleteRules(KeyRule::NO_ACTION)
,m_nCardinality(CARDINAL_UNDEFINED) ,m_nCardinality(Cardinality::Undefined)
{ {
} }
...@@ -57,7 +57,7 @@ ORelationTableConnectionData::ORelationTableConnectionData( const TTableWindowDa ...@@ -57,7 +57,7 @@ ORelationTableConnectionData::ORelationTableConnectionData( const TTableWindowDa
:OTableConnectionData( _pReferencingTable, _pReferencedTable ) :OTableConnectionData( _pReferencingTable, _pReferencedTable )
,m_nUpdateRules(KeyRule::NO_ACTION) ,m_nUpdateRules(KeyRule::NO_ACTION)
,m_nDeleteRules(KeyRule::NO_ACTION) ,m_nDeleteRules(KeyRule::NO_ACTION)
,m_nCardinality(CARDINAL_UNDEFINED) ,m_nCardinality(Cardinality::Undefined)
{ {
m_aConnName = rConnName; m_aConnName = rConnName;
...@@ -127,20 +127,20 @@ void ORelationTableConnectionData::ChangeOrientation() ...@@ -127,20 +127,20 @@ void ORelationTableConnectionData::ChangeOrientation()
void ORelationTableConnectionData::SetCardinality() void ORelationTableConnectionData::SetCardinality()
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
m_nCardinality = CARDINAL_UNDEFINED; m_nCardinality = Cardinality::Undefined;
if( IsSourcePrimKey() ) if( IsSourcePrimKey() )
{ {
if( IsDestPrimKey() ) if( IsDestPrimKey() )
m_nCardinality = CARDINAL_ONE_ONE; m_nCardinality = Cardinality::OneOne;
else else
m_nCardinality = CARDINAL_ONE_MANY; m_nCardinality = Cardinality::OneMany;
} }
if( IsDestPrimKey() ) if( IsDestPrimKey() )
{ {
if( !IsSourcePrimKey() ) if( !IsSourcePrimKey() )
m_nCardinality = CARDINAL_MANY_ONE; m_nCardinality = Cardinality::ManyOne;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment