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