1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef DBAUI_TABLECONNECTIONDATA_HXX 24 #define DBAUI_TABLECONNECTIONDATA_HXX 25 26 #ifndef DBAUI_CONNECTIONLINEDATA_HXX 27 #include "ConnectionLineData.hxx" 28 #endif 29 #include "TableWindowData.hxx" 30 #include <vector> 31 #ifndef _RTTI_HXX 32 #include <tools/rtti.hxx> 33 #endif 34 #ifndef _STRING_HXX 35 #include <tools/string.hxx> 36 #endif 37 #include <boost/shared_ptr.hpp> 38 39 namespace dbaui 40 { 41 #define MAX_CONN_COUNT 2 42 //================================================================== 43 // ConnData ---------->* ConnLineData 44 // ^1 ^1 45 // | | 46 // Conn ---------->* ConnLine 47 //================================================================== 48 49 50 //================================================================== 51 /* 52 the class OTableConnectionData contains all connection data which exists between two windows 53 **/ 54 class OTableConnectionData 55 { 56 57 protected: 58 TTableWindowData::value_type m_pReferencingTable; 59 TTableWindowData::value_type m_pReferencedTable; 60 String m_aConnName; 61 62 OConnectionLineDataVec m_vConnLineData; 63 64 void Init(); 65 66 virtual OConnectionLineDataRef CreateLineDataObj(); 67 virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData ); 68 69 OTableConnectionData& operator=( const OTableConnectionData& rConnData ); 70 public: 71 OTableConnectionData(); 72 OTableConnectionData(const TTableWindowData::value_type& _pReferencingTable,const TTableWindowData::value_type& _pReferencedTable, const String& rConnName = String() ); 73 OTableConnectionData( const OTableConnectionData& rConnData ); 74 virtual ~OTableConnectionData(); 75 76 // sich aus einer Quelle initialisieren (das ist mir irgendwie angenehmer als ein virtueller Zuweisungsoperator) 77 virtual void CopyFrom(const OTableConnectionData& rSource); 78 79 // eine neue Instanz meines eigenen Typs liefern (braucht NICHT initialisiert sein) 80 virtual OTableConnectionData* NewInstance() const; 81 // (von OTableConnectionData abgeleitete Klasse muessen entsprechend eine Instanz ihrer Klasse liefern) 82 83 sal_Bool SetConnLine( sal_uInt16 nIndex, const String& rSourceFieldName, const String& rDestFieldName ); 84 sal_Bool AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName ); 85 void ResetConnLines( sal_Bool bUseDefaults = sal_True ); 86 87 /** normalizeLines moves the empty lines to the back 88 */ 89 void normalizeLines(); 90 // loescht die Liste der ConnLines, bei bUseDefaults == sal_True werden danach MAX_CONN_COUNT neue Dummy-Linien eingefuegt 91 GetConnLineDataList()92 OConnectionLineDataVec* GetConnLineDataList(){ return &m_vConnLineData; } 93 getReferencingTable() const94 inline TTableWindowData::value_type getReferencingTable() const { return m_pReferencingTable; } getReferencedTable() const95 inline TTableWindowData::value_type getReferencedTable() const { return m_pReferencedTable; } 96 setReferencingTable(const TTableWindowData::value_type & _pTable)97 inline void setReferencingTable(const TTableWindowData::value_type& _pTable) { m_pReferencingTable = _pTable; } setReferencedTable(const TTableWindowData::value_type & _pTable)98 inline void setReferencedTable(const TTableWindowData::value_type& _pTable) { m_pReferencedTable = _pTable; } 99 GetConnName() const100 String GetConnName() const { return m_aConnName; } 101 SetConnName(const String & rConnName)102 virtual void SetConnName( const String& rConnName ){ m_aConnName = rConnName; } 103 /** Update create a new connection 104 105 @return true if successful 106 */ Update()107 virtual sal_Bool Update(){ return sal_True; } 108 }; 109 110 typedef ::std::vector< ::boost::shared_ptr<OTableConnectionData> > TTableConnectionData; 111 112 } 113 #endif // DBAUI_TABLECONNECTIONDATA_HXX 114 115 116