1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef DBAUI_TABLECONNECTIONDATA_HXX 28 #define DBAUI_TABLECONNECTIONDATA_HXX 29 30 #ifndef DBAUI_CONNECTIONLINEDATA_HXX 31 #include "ConnectionLineData.hxx" 32 #endif 33 #include "TableWindowData.hxx" 34 #include <vector> 35 #ifndef _RTTI_HXX 36 #include <tools/rtti.hxx> 37 #endif 38 #ifndef _STRING_HXX 39 #include <tools/string.hxx> 40 #endif 41 #include <boost/shared_ptr.hpp> 42 43 namespace dbaui 44 { 45 #define MAX_CONN_COUNT 2 46 //================================================================== 47 // ConnData ---------->* ConnLineData 48 // ^1 ^1 49 // | | 50 // Conn ---------->* ConnLine 51 //================================================================== 52 53 54 //================================================================== 55 /* 56 the class OTableConnectionData contains all connection data which exists between two windows 57 **/ 58 class OTableConnectionData 59 { 60 61 protected: 62 TTableWindowData::value_type m_pReferencingTable; 63 TTableWindowData::value_type m_pReferencedTable; 64 String m_aConnName; 65 66 OConnectionLineDataVec m_vConnLineData; 67 68 void Init(); 69 70 virtual OConnectionLineDataRef CreateLineDataObj(); 71 virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData ); 72 73 OTableConnectionData& operator=( const OTableConnectionData& rConnData ); 74 public: 75 OTableConnectionData(); 76 OTableConnectionData(const TTableWindowData::value_type& _pReferencingTable,const TTableWindowData::value_type& _pReferencedTable, const String& rConnName = String() ); 77 OTableConnectionData( const OTableConnectionData& rConnData ); 78 virtual ~OTableConnectionData(); 79 80 // sich aus einer Quelle initialisieren (das ist mir irgendwie angenehmer als ein virtueller Zuweisungsoperator) 81 virtual void CopyFrom(const OTableConnectionData& rSource); 82 83 // eine neue Instanz meines eigenen Typs liefern (braucht NICHT initialisiert sein) 84 virtual OTableConnectionData* NewInstance() const; 85 // (von OTableConnectionData abgeleitete Klasse muessen entsprechend eine Instanz ihrer Klasse liefern) 86 87 sal_Bool SetConnLine( sal_uInt16 nIndex, const String& rSourceFieldName, const String& rDestFieldName ); 88 sal_Bool AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName ); 89 void ResetConnLines( sal_Bool bUseDefaults = sal_True ); 90 91 /** normalizeLines moves the empty lines to the back 92 */ 93 void normalizeLines(); 94 // loescht die Liste der ConnLines, bei bUseDefaults == sal_True werden danach MAX_CONN_COUNT neue Dummy-Linien eingefuegt 95 96 OConnectionLineDataVec* GetConnLineDataList(){ return &m_vConnLineData; } 97 98 inline TTableWindowData::value_type getReferencingTable() const { return m_pReferencingTable; } 99 inline TTableWindowData::value_type getReferencedTable() const { return m_pReferencedTable; } 100 101 inline void setReferencingTable(const TTableWindowData::value_type& _pTable) { m_pReferencingTable = _pTable; } 102 inline void setReferencedTable(const TTableWindowData::value_type& _pTable) { m_pReferencedTable = _pTable; } 103 104 String GetConnName() const { return m_aConnName; } 105 106 virtual void SetConnName( const String& rConnName ){ m_aConnName = rConnName; } 107 /** Update create a new connection 108 109 @return true if successful 110 */ 111 virtual sal_Bool Update(){ return sal_True; } 112 }; 113 114 typedef ::std::vector< ::boost::shared_ptr<OTableConnectionData> > TTableConnectionData; 115 116 } 117 #endif // DBAUI_TABLECONNECTIONDATA_HXX 118 119 120