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