Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef DBAUI_RTABLECONNECTIONDATA_HXX
20 : #define DBAUI_RTABLECONNECTIONDATA_HXX
21 :
22 : #include "TableConnectionData.hxx"
23 : #include <com/sun/star/beans/XPropertySet.hpp>
24 : #include <com/sun/star/container/XNameAccess.hpp>
25 : #include "QEnumTypes.hxx"
26 :
27 : namespace dbaui
28 : {
29 : const sal_uInt16 CARDINAL_UNDEFINED = 0x0000;
30 : const sal_uInt16 CARDINAL_ONE_MANY = 0x0001;
31 : const sal_uInt16 CARDINAL_MANY_ONE = 0x0002;
32 : const sal_uInt16 CARDINAL_ONE_ONE = 0x0004;
33 :
34 : class OConnectionLineData;
35 : //==================================================================
36 : class ORelationTableConnectionData : public OTableConnectionData
37 : {
38 : friend bool operator==(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs);
39 : friend bool operator!=(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs) { return !(lhs == rhs); }
40 :
41 : ::osl::Mutex m_aMutex;
42 :
43 : // @see com.sun.star.sdbc.KeyRule
44 : sal_Int32 m_nUpdateRules;
45 : sal_Int32 m_nDeleteRules;
46 : sal_Int32 m_nCardinality;
47 :
48 : sal_Bool checkPrimaryKey(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const;
49 0 : sal_Bool IsSourcePrimKey() const { return checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM); }
50 0 : sal_Bool IsDestPrimKey() const { return checkPrimaryKey(getReferencedTable()->getTable(),JTCS_TO); }
51 :
52 : protected:
53 : virtual OConnectionLineDataRef CreateLineDataObj();
54 : virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData );
55 :
56 : ORelationTableConnectionData& operator=( const ORelationTableConnectionData& rConnData );
57 : public:
58 : ORelationTableConnectionData();
59 : ORelationTableConnectionData( const ORelationTableConnectionData& rConnData );
60 : ORelationTableConnectionData( const TTableWindowData::value_type& _pReferencingTable,
61 : const TTableWindowData::value_type& _pReferencedTable,
62 : const ::rtl::OUString& rConnName = ::rtl::OUString() );
63 : virtual ~ORelationTableConnectionData();
64 :
65 : virtual void CopyFrom(const OTableConnectionData& rSource);
66 0 : virtual OTableConnectionData* NewInstance() const { return new ORelationTableConnectionData(); }
67 :
68 : /** Update create a new relation
69 :
70 : @return true if successful
71 : */
72 : virtual sal_Bool Update();
73 :
74 :
75 : void SetCardinality();
76 0 : inline void SetUpdateRules( sal_Int32 nAttr ){ m_nUpdateRules = nAttr; }
77 0 : inline void SetDeleteRules( sal_Int32 nAttr ){ m_nDeleteRules = nAttr; }
78 :
79 0 : inline sal_Int32 GetUpdateRules() const { return m_nUpdateRules; }
80 0 : inline sal_Int32 GetDeleteRules() const { return m_nDeleteRules; }
81 0 : inline sal_Int32 GetCardinality() const { return m_nCardinality; }
82 :
83 : sal_Bool IsConnectionPossible();
84 : void ChangeOrientation();
85 : sal_Bool DropRelation();
86 : };
87 : }
88 :
89 : #endif // DBAUI_RTABLECONNECTIONDATA_HXX
90 :
91 :
92 :
93 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|