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 INCLUDED_DBACCESS_SOURCE_UI_INC_RTABLECONNECTIONDATA_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_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 : class ORelationTableConnectionData : public OTableConnectionData
36 : {
37 : friend bool operator==(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs);
38 : friend bool operator!=(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs) { return !(lhs == rhs); }
39 :
40 : ::osl::Mutex m_aMutex;
41 :
42 : // @see com.sun.star.sdbc.KeyRule
43 : sal_Int32 m_nUpdateRules;
44 : sal_Int32 m_nDeleteRules;
45 : sal_Int32 m_nCardinality;
46 :
47 : sal_Bool checkPrimaryKey(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const;
48 0 : sal_Bool IsSourcePrimKey() const { return checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM); }
49 0 : sal_Bool IsDestPrimKey() const { return checkPrimaryKey(getReferencedTable()->getTable(),JTCS_TO); }
50 :
51 : protected:
52 : virtual OConnectionLineDataRef CreateLineDataObj() SAL_OVERRIDE;
53 : virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData ) SAL_OVERRIDE;
54 :
55 : ORelationTableConnectionData& operator=( const ORelationTableConnectionData& rConnData );
56 : public:
57 : ORelationTableConnectionData();
58 : ORelationTableConnectionData( const ORelationTableConnectionData& rConnData );
59 : ORelationTableConnectionData( const TTableWindowData::value_type& _pReferencingTable,
60 : const TTableWindowData::value_type& _pReferencedTable,
61 : const OUString& rConnName = OUString() );
62 : virtual ~ORelationTableConnectionData();
63 :
64 : virtual void CopyFrom(const OTableConnectionData& rSource) SAL_OVERRIDE;
65 0 : virtual OTableConnectionData* NewInstance() const SAL_OVERRIDE { return new ORelationTableConnectionData(); }
66 :
67 : /** Update create a new relation
68 :
69 : @return true if successful
70 : */
71 : virtual sal_Bool Update() SAL_OVERRIDE;
72 :
73 : void SetCardinality();
74 0 : inline void SetUpdateRules( sal_Int32 nAttr ){ m_nUpdateRules = nAttr; }
75 0 : inline void SetDeleteRules( sal_Int32 nAttr ){ m_nDeleteRules = nAttr; }
76 :
77 0 : inline sal_Int32 GetUpdateRules() const { return m_nUpdateRules; }
78 0 : inline sal_Int32 GetDeleteRules() const { return m_nDeleteRules; }
79 0 : inline sal_Int32 GetCardinality() const { return m_nCardinality; }
80 :
81 : sal_Bool IsConnectionPossible();
82 : void ChangeOrientation();
83 : sal_Bool DropRelation();
84 : };
85 : }
86 :
87 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_RTABLECONNECTIONDATA_HXX
88 :
89 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|