1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RTableConnectionData.hxx,v $
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 ************************************************************************/
30 #ifndef DBAUI_RTABLECONNECTIONDATA_HXX
31 #define DBAUI_RTABLECONNECTIONDATA_HXX
33 #ifndef DBAUI_TABLECONNECTIONDATA_HXX
34 #include "TableConnectionData.hxx"
36 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
37 #include <com/sun/star/beans/XPropertySet.hpp>
39 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
40 #include <com/sun/star/container/XNameAccess.hpp>
42 #ifndef DBAUI_ENUMTYPES_HXX
43 #include "QEnumTypes.hxx"
48 const UINT16 CARDINAL_UNDEFINED
= 0x0000;
49 const UINT16 CARDINAL_ONE_MANY
= 0x0001;
50 const UINT16 CARDINAL_MANY_ONE
= 0x0002;
51 const UINT16 CARDINAL_ONE_ONE
= 0x0004;
53 class OConnectionLineData
;
54 //==================================================================
55 class ORelationTableConnectionData
: public OTableConnectionData
57 friend bool operator==(const ORelationTableConnectionData
& lhs
, const ORelationTableConnectionData
& rhs
);
58 friend bool operator!=(const ORelationTableConnectionData
& lhs
, const ORelationTableConnectionData
& rhs
) { return !(lhs
== rhs
); }
60 ::osl::Mutex m_aMutex
;
62 // @see com.sun.star.sdbc.KeyRule
63 sal_Int32 m_nUpdateRules
;
64 sal_Int32 m_nDeleteRules
;
65 sal_Int32 m_nCardinality
;
67 BOOL
checkPrimaryKey(const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& _xKeys
,EConnectionSide _eEConnectionSide
) const;
68 BOOL
IsSourcePrimKey() const { return checkPrimaryKey(getReferencingTable()->getKeys(),JTCS_FROM
); }
69 BOOL
IsDestPrimKey() const { return checkPrimaryKey(getReferencedTable()->getKeys(),JTCS_TO
); }
72 virtual OConnectionLineDataRef
CreateLineDataObj();
73 virtual OConnectionLineDataRef
CreateLineDataObj( const OConnectionLineData
& rConnLineData
);
75 ORelationTableConnectionData
& operator=( const ORelationTableConnectionData
& rConnData
);
77 ORelationTableConnectionData();
78 ORelationTableConnectionData( const ORelationTableConnectionData
& rConnData
);
79 ORelationTableConnectionData( const TTableWindowData::value_type
& _pReferencingTable
,
80 const TTableWindowData::value_type
& _pReferencedTable
,
81 const ::rtl::OUString
& rConnName
= ::rtl::OUString() );
82 virtual ~ORelationTableConnectionData();
84 virtual void CopyFrom(const OTableConnectionData
& rSource
);
85 virtual OTableConnectionData
* NewInstance() const { return new ORelationTableConnectionData(); }
87 /** Update create a new relation
89 @return true if successful
91 virtual BOOL
Update();
94 void SetCardinality();
95 inline void SetUpdateRules( sal_Int32 nAttr
){ m_nUpdateRules
= nAttr
; }
96 inline void SetDeleteRules( sal_Int32 nAttr
){ m_nDeleteRules
= nAttr
; }
98 inline sal_Int32
GetUpdateRules() const { return m_nUpdateRules
; }
99 inline sal_Int32
GetDeleteRules() const { return m_nDeleteRules
; }
100 inline sal_Int32
GetCardinality() const { return m_nCardinality
; }
102 BOOL
IsConnectionPossible();
103 void ChangeOrientation();
108 #endif // DBAUI_RTABLECONNECTIONDATA_HXX