xref: /trunk/main/dbaccess/source/ui/inc/RTableConnectionData.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef DBAUI_RTABLECONNECTIONDATA_HXX
24cdf0e10cSrcweir #define DBAUI_RTABLECONNECTIONDATA_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef DBAUI_TABLECONNECTIONDATA_HXX
27cdf0e10cSrcweir #include "TableConnectionData.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
30cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
33cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef DBAUI_ENUMTYPES_HXX
36cdf0e10cSrcweir #include "QEnumTypes.hxx"
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace dbaui
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     const sal_uInt16 CARDINAL_UNDEFINED = 0x0000;
42cdf0e10cSrcweir     const sal_uInt16 CARDINAL_ONE_MANY  = 0x0001;
43cdf0e10cSrcweir     const sal_uInt16 CARDINAL_MANY_ONE  = 0x0002;
44cdf0e10cSrcweir     const sal_uInt16 CARDINAL_ONE_ONE   = 0x0004;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir     class OConnectionLineData;
47cdf0e10cSrcweir     //==================================================================
48cdf0e10cSrcweir     class ORelationTableConnectionData :    public OTableConnectionData
49cdf0e10cSrcweir     {
50cdf0e10cSrcweir         friend bool operator==(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs);
operator !=(const ORelationTableConnectionData & lhs,const ORelationTableConnectionData & rhs)51cdf0e10cSrcweir         friend bool operator!=(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs) { return !(lhs == rhs); }
52cdf0e10cSrcweir 
53cdf0e10cSrcweir         ::osl::Mutex    m_aMutex;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir         // @see com.sun.star.sdbc.KeyRule
56cdf0e10cSrcweir         sal_Int32 m_nUpdateRules;
57cdf0e10cSrcweir         sal_Int32 m_nDeleteRules;
58cdf0e10cSrcweir         sal_Int32 m_nCardinality;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir         sal_Bool checkPrimaryKey(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const;
IsSourcePrimKey() const61cdf0e10cSrcweir         sal_Bool IsSourcePrimKey()  const { return checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM);    }
IsDestPrimKey() const62cdf0e10cSrcweir         sal_Bool IsDestPrimKey()    const { return checkPrimaryKey(getReferencedTable()->getTable(),JTCS_TO);       }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     protected:
65cdf0e10cSrcweir         virtual OConnectionLineDataRef CreateLineDataObj();
66cdf0e10cSrcweir         virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         ORelationTableConnectionData& operator=( const ORelationTableConnectionData& rConnData );
69cdf0e10cSrcweir     public:
70cdf0e10cSrcweir         ORelationTableConnectionData();
71cdf0e10cSrcweir         ORelationTableConnectionData( const ORelationTableConnectionData& rConnData );
72cdf0e10cSrcweir         ORelationTableConnectionData( const TTableWindowData::value_type& _pReferencingTable,
73cdf0e10cSrcweir                                       const TTableWindowData::value_type& _pReferencedTable,
74cdf0e10cSrcweir                                       const ::rtl::OUString& rConnName = ::rtl::OUString() );
75cdf0e10cSrcweir         virtual ~ORelationTableConnectionData();
76cdf0e10cSrcweir 
77cdf0e10cSrcweir         virtual void CopyFrom(const OTableConnectionData& rSource);
NewInstance() const78cdf0e10cSrcweir         virtual OTableConnectionData* NewInstance() const { return new ORelationTableConnectionData(); }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir         /** Update create a new relation
81cdf0e10cSrcweir 
82cdf0e10cSrcweir             @return true if successful
83cdf0e10cSrcweir         */
84cdf0e10cSrcweir         virtual sal_Bool Update();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 
87cdf0e10cSrcweir         void        SetCardinality();
SetUpdateRules(sal_Int32 nAttr)88cdf0e10cSrcweir         inline void SetUpdateRules( sal_Int32 nAttr ){ m_nUpdateRules = nAttr; }
SetDeleteRules(sal_Int32 nAttr)89cdf0e10cSrcweir         inline void SetDeleteRules( sal_Int32 nAttr ){ m_nDeleteRules = nAttr; }
90cdf0e10cSrcweir 
GetUpdateRules() const91cdf0e10cSrcweir         inline sal_Int32    GetUpdateRules() const { return m_nUpdateRules; }
GetDeleteRules() const92cdf0e10cSrcweir         inline sal_Int32    GetDeleteRules() const { return m_nDeleteRules; }
GetCardinality() const93cdf0e10cSrcweir         inline sal_Int32    GetCardinality() const { return m_nCardinality; }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir         sal_Bool        IsConnectionPossible();
96cdf0e10cSrcweir         void        ChangeOrientation();
97cdf0e10cSrcweir         sal_Bool        DropRelation();
98cdf0e10cSrcweir     };
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir #endif // DBAUI_RTABLECONNECTIONDATA_HXX
102