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_TABLECONNECTIONDATA_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_TABLECONNECTIONDATA_HXX
21 :
22 : #include "ConnectionLineData.hxx"
23 : #include "TableWindowData.hxx"
24 : #include <vector>
25 : #include <tools/rtti.hxx>
26 : #include <boost/shared_ptr.hpp>
27 :
28 : namespace dbaui
29 : {
30 : //===========================================//
31 : // ConnData ---------->* ConnLineData //
32 : // ^1 ^1 //
33 : // | | //
34 : // Conn ---------->* ConnLine //
35 : //===========================================//
36 :
37 : /** Contains all connection data which exists between two windows */
38 : class OTableConnectionData
39 : {
40 : protected:
41 : TTableWindowData::value_type m_pReferencingTable;
42 : TTableWindowData::value_type m_pReferencedTable;
43 : OUString m_aConnName;
44 :
45 : OConnectionLineDataVec m_vConnLineData;
46 :
47 : void Init();
48 :
49 : virtual OConnectionLineDataRef CreateLineDataObj();
50 : virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData );
51 :
52 : OTableConnectionData& operator=( const OTableConnectionData& rConnData );
53 : public:
54 : OTableConnectionData();
55 : OTableConnectionData( const TTableWindowData::value_type& _pReferencingTable,
56 : const TTableWindowData::value_type& _pReferencedTable,
57 : const OUString& rConnName = OUString() );
58 : OTableConnectionData( const OTableConnectionData& rConnData );
59 : virtual ~OTableConnectionData();
60 :
61 : /// initialise from a source (more comfortable than a virtual assignment operator)
62 : virtual void CopyFrom(const OTableConnectionData& rSource);
63 :
64 : /** deliver a new instance of my own type
65 :
66 : derived classes have to deliver an instance of their own type
67 :
68 : @note does NOT have to be initialised
69 : */
70 : virtual OTableConnectionData* NewInstance() const;
71 :
72 : bool SetConnLine( sal_uInt16 nIndex, const OUString& rSourceFieldName, const OUString& rDestFieldName );
73 : bool AppendConnLine( const OUString& rSourceFieldName, const OUString& rDestFieldName );
74 : /** Deletes list of ConnLines
75 : */
76 : void ResetConnLines();
77 :
78 : /** moves the empty lines to the back
79 : removes duplicated empty lines
80 :
81 : caller is responsible for repainting them
82 :
83 : @return infex of first changed line, or one-past-the-end if no change
84 : */
85 : OConnectionLineDataVec::size_type normalizeLines();
86 :
87 0 : const OConnectionLineDataVec& GetConnLineDataList() const { return m_vConnLineData; }
88 0 : OConnectionLineDataVec& GetConnLineDataList() { return m_vConnLineData; }
89 :
90 0 : inline TTableWindowData::value_type getReferencingTable() const { return m_pReferencingTable; }
91 0 : inline TTableWindowData::value_type getReferencedTable() const { return m_pReferencedTable; }
92 :
93 0 : inline void setReferencingTable(const TTableWindowData::value_type& _pTable) { m_pReferencingTable = _pTable; }
94 0 : inline void setReferencedTable(const TTableWindowData::value_type& _pTable) { m_pReferencedTable = _pTable; }
95 :
96 0 : OUString GetConnName() const { return m_aConnName; }
97 :
98 0 : virtual void SetConnName( const OUString& rConnName ){ m_aConnName = rConnName; }
99 : /** Update create a new connection
100 :
101 : @return true if successful
102 : */
103 0 : virtual bool Update(){ return true; }
104 : };
105 :
106 : typedef ::std::vector< ::boost::shared_ptr<OTableConnectionData> > TTableConnectionData;
107 :
108 : }
109 : #endif
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|