xref: /trunk/main/dbaccess/source/ui/inc/RTableConnectionData.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 #ifndef DBAUI_RTABLECONNECTIONDATA_HXX
28 #define DBAUI_RTABLECONNECTIONDATA_HXX
29 
30 #ifndef DBAUI_TABLECONNECTIONDATA_HXX
31 #include "TableConnectionData.hxx"
32 #endif
33 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
37 #include <com/sun/star/container/XNameAccess.hpp>
38 #endif
39 #ifndef DBAUI_ENUMTYPES_HXX
40 #include "QEnumTypes.hxx"
41 #endif
42 
43 namespace dbaui
44 {
45     const sal_uInt16 CARDINAL_UNDEFINED = 0x0000;
46     const sal_uInt16 CARDINAL_ONE_MANY  = 0x0001;
47     const sal_uInt16 CARDINAL_MANY_ONE  = 0x0002;
48     const sal_uInt16 CARDINAL_ONE_ONE   = 0x0004;
49 
50     class OConnectionLineData;
51     //==================================================================
52     class ORelationTableConnectionData :    public OTableConnectionData
53     {
54         friend bool operator==(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs);
55         friend bool operator!=(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs) { return !(lhs == rhs); }
56 
57         ::osl::Mutex    m_aMutex;
58 
59         // @see com.sun.star.sdbc.KeyRule
60         sal_Int32 m_nUpdateRules;
61         sal_Int32 m_nDeleteRules;
62         sal_Int32 m_nCardinality;
63 
64         sal_Bool checkPrimaryKey(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const;
65         sal_Bool IsSourcePrimKey()  const { return checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM);    }
66         sal_Bool IsDestPrimKey()    const { return checkPrimaryKey(getReferencedTable()->getTable(),JTCS_TO);       }
67 
68     protected:
69         virtual OConnectionLineDataRef CreateLineDataObj();
70         virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData );
71 
72         ORelationTableConnectionData& operator=( const ORelationTableConnectionData& rConnData );
73     public:
74         ORelationTableConnectionData();
75         ORelationTableConnectionData( const ORelationTableConnectionData& rConnData );
76         ORelationTableConnectionData( const TTableWindowData::value_type& _pReferencingTable,
77                                       const TTableWindowData::value_type& _pReferencedTable,
78                                       const ::rtl::OUString& rConnName = ::rtl::OUString() );
79         virtual ~ORelationTableConnectionData();
80 
81         virtual void CopyFrom(const OTableConnectionData& rSource);
82         virtual OTableConnectionData* NewInstance() const { return new ORelationTableConnectionData(); }
83 
84         /** Update create a new relation
85 
86             @return true if successful
87         */
88         virtual sal_Bool Update();
89 
90 
91         void        SetCardinality();
92         inline void SetUpdateRules( sal_Int32 nAttr ){ m_nUpdateRules = nAttr; }
93         inline void SetDeleteRules( sal_Int32 nAttr ){ m_nDeleteRules = nAttr; }
94 
95         inline sal_Int32    GetUpdateRules() const { return m_nUpdateRules; }
96         inline sal_Int32    GetDeleteRules() const { return m_nDeleteRules; }
97         inline sal_Int32    GetCardinality() const { return m_nCardinality; }
98 
99         sal_Bool        IsConnectionPossible();
100         void        ChangeOrientation();
101         sal_Bool        DropRelation();
102     };
103 }
104 
105 #endif // DBAUI_RTABLECONNECTIONDATA_HXX
106 
107 
108 
109