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 28 #ifndef _DBAUI_DBFINDEX_HXX_ 29 #define _DBAUI_DBFINDEX_HXX_ 30 31 #ifndef _DIALOG_HXX //autogen 32 #include <vcl/dialog.hxx> 33 #endif 34 #ifndef _BUTTON_HXX //autogen 35 #include <vcl/button.hxx> 36 #endif 37 #ifndef _COMBOBOX_HXX //autogen 38 #include <vcl/combobox.hxx> 39 #endif 40 #ifndef _LSTBOX_HXX //autogen 41 #include <vcl/lstbox.hxx> 42 #endif 43 #ifndef _SV_FIXED_HXX 44 #include <vcl/fixed.hxx> 45 #endif 46 #ifndef __SGI_STL_LIST 47 #include <list> 48 #endif 49 #ifndef _COMPHELPER_STLTYPES_HXX_ 50 #include <comphelper/stl_types.hxx> 51 #endif 52 53 //......................................................................... 54 namespace dbaui 55 { 56 //......................................................................... 57 58 //========================================================================= 59 //= OTableIndex 60 //========================================================================= 61 /// represents a single dbf index 62 class OTableIndex 63 { 64 private: 65 String aIndexFileName; 66 67 public: 68 OTableIndex() { } 69 OTableIndex( const OTableIndex& _rSource) : aIndexFileName(_rSource.aIndexFileName) { } 70 OTableIndex( const String& rFileName ) : aIndexFileName( rFileName ) { } 71 72 void SetIndexFileName( const String& rFileName ) { aIndexFileName = rFileName; } 73 String GetIndexFileName() const { return aIndexFileName; } 74 }; 75 76 //------------------------------------------------------------------------- 77 typedef ::std::list< OTableIndex > TableIndexList; 78 DECLARE_STL_ITERATORS(TableIndexList); 79 80 //========================================================================= 81 //= OTableInfo 82 //========================================================================= 83 class ODbaseIndexDialog; 84 /** holds the INF file of a table 85 */ 86 class OTableInfo 87 { 88 friend class ODbaseIndexDialog; 89 private: 90 String aTableName; 91 TableIndexList aIndexList; 92 93 public: 94 OTableInfo() { } 95 OTableInfo( const String& rName ) : aTableName(rName) { } 96 97 void WriteInfFile( const String& rDSN ) const; 98 }; 99 100 //------------------------------------------------------------------------- 101 typedef ::std::list< OTableInfo > TableInfoList; 102 DECLARE_STL_ITERATORS(TableInfoList); 103 104 ////////////////////////////////////////////////////////////////////////// 105 // IndexDialog 106 class ODbaseIndexDialog : public ModalDialog 107 { 108 protected: 109 OKButton aPB_OK; 110 CancelButton aPB_CANCEL; 111 HelpButton aPB_HELP; 112 113 FixedText m_FT_Tables; 114 ComboBox aCB_Tables; 115 116 FixedLine m_FL_Indexes; 117 118 FixedText m_FT_TableIndexes; 119 ListBox aLB_TableIndexes; 120 121 FixedText m_FT_AllIndexes; 122 ListBox aLB_FreeIndexes; 123 124 ImageButton aIB_Add; 125 ImageButton aIB_Remove; 126 ImageButton aIB_AddAll; 127 ImageButton aIB_RemoveAll; 128 129 DECL_LINK( TableSelectHdl, ComboBox* ); 130 DECL_LINK( AddClickHdl, PushButton* ); 131 DECL_LINK( RemoveClickHdl, PushButton* ); 132 DECL_LINK( AddAllClickHdl, PushButton* ); 133 DECL_LINK( RemoveAllClickHdl, PushButton* ); 134 DECL_LINK( OKClickHdl, PushButton* ); 135 DECL_LINK( OnListEntrySelected, ListBox* ); 136 137 String m_aDSN; 138 TableInfoList m_aTableInfoList; 139 TableIndexList m_aFreeIndexList; 140 sal_Bool m_bCaseSensitiv; 141 142 void Init(); 143 void SetCtrls(); 144 sal_Bool GetTable(const String& rName, TableInfoListIterator& _rPosition); 145 146 OTableIndex implRemoveIndex(const String& _rName, TableIndexList& _rList, ListBox& _rDisplay, sal_Bool _bMustExist); 147 void implInsertIndex(const OTableIndex& _rIndex, TableIndexList& _rList, ListBox& _rDisplay); 148 149 OTableIndex RemoveFreeIndex( const String& _rName, sal_Bool _bMustExist ) { return implRemoveIndex(_rName, m_aFreeIndexList, aLB_FreeIndexes, _bMustExist); } 150 void InsertFreeIndex( const OTableIndex& _rIndex ) { implInsertIndex(_rIndex, m_aFreeIndexList, aLB_FreeIndexes); } 151 OTableIndex RemoveTableIndex( const String& _rTableName, const String& _rIndexName, sal_Bool _bMustExist ); 152 void InsertTableIndex( const String& _rTableName, const OTableIndex& _rIndex ); 153 154 void checkButtons(); 155 156 public: 157 ODbaseIndexDialog( Window * pParent, String aDataSrcName ); 158 virtual ~ODbaseIndexDialog(); 159 }; 160 161 //......................................................................... 162 } // namespace dbaui 163 //......................................................................... 164 165 #endif // _DBAUI_DBFINDEX_HXX_ 166 167