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 :
20 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_DLG_DBFINDEX_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_UI_DLG_DBFINDEX_HXX
22 :
23 : #include <vcl/dialog.hxx>
24 : #include <vcl/button.hxx>
25 : #include <vcl/combobox.hxx>
26 : #include <vcl/layout.hxx>
27 : #include <vcl/lstbox.hxx>
28 : #include <vcl/fixed.hxx>
29 : #include <list>
30 :
31 : namespace dbaui
32 : {
33 :
34 : // OTableIndex
35 : /// represents a single dbf index
36 0 : class OTableIndex
37 : {
38 : private:
39 : OUString aIndexFileName;
40 :
41 : public:
42 0 : OTableIndex() { }
43 0 : OTableIndex( const OTableIndex& _rSource) : aIndexFileName(_rSource.aIndexFileName) { }
44 0 : OTableIndex( const OUString& rFileName ) : aIndexFileName( rFileName ) { }
45 :
46 : void SetIndexFileName( const OUString& rFileName ) { aIndexFileName = rFileName; }
47 0 : OUString GetIndexFileName() const { return aIndexFileName; }
48 : };
49 :
50 : typedef ::std::list< OTableIndex > TableIndexList;
51 :
52 : // OTableInfo
53 : class ODbaseIndexDialog;
54 : /** holds the INF file of a table
55 : */
56 0 : class OTableInfo
57 : {
58 : friend class ODbaseIndexDialog;
59 : private:
60 : OUString aTableName;
61 : TableIndexList aIndexList;
62 :
63 : public:
64 : OTableInfo() { }
65 0 : OTableInfo( const OUString& rName ) : aTableName(rName) { }
66 :
67 : void WriteInfFile( const OUString& rDSN ) const;
68 : };
69 :
70 : typedef ::std::list< OTableInfo > TableInfoList;
71 :
72 : // IndexDialog
73 : class ODbaseIndexDialog : public ModalDialog
74 : {
75 : protected:
76 : VclPtr<OKButton> m_pPB_OK;
77 : VclPtr<ComboBox> m_pCB_Tables;
78 : VclPtr<VclContainer> m_pIndexes;
79 : VclPtr<ListBox> m_pLB_TableIndexes;
80 : VclPtr<ListBox> m_pLB_FreeIndexes;
81 :
82 : VclPtr<PushButton> m_pAdd;
83 : VclPtr<PushButton> m_pRemove;
84 : VclPtr<PushButton> m_pAddAll;
85 : VclPtr<PushButton> m_pRemoveAll;
86 :
87 : DECL_LINK( TableSelectHdl, ComboBox* );
88 : DECL_LINK( AddClickHdl, PushButton* );
89 : DECL_LINK( RemoveClickHdl, PushButton* );
90 : DECL_LINK( AddAllClickHdl, PushButton* );
91 : DECL_LINK( RemoveAllClickHdl, PushButton* );
92 : DECL_LINK( OKClickHdl, PushButton* );
93 : DECL_LINK( OnListEntrySelected, ListBox* );
94 :
95 : OUString m_aDSN;
96 : TableInfoList m_aTableInfoList;
97 : TableIndexList m_aFreeIndexList;
98 : bool m_bCaseSensitiv;
99 :
100 : void Init();
101 : void SetCtrls();
102 : bool GetTable(const OUString& rName, TableInfoList::iterator& _rPosition);
103 :
104 : OTableIndex implRemoveIndex(const OUString& _rName, TableIndexList& _rList, ListBox& _rDisplay, bool _bMustExist);
105 : static void implInsertIndex(const OTableIndex& _rIndex, TableIndexList& _rList, ListBox& _rDisplay);
106 :
107 0 : OTableIndex RemoveFreeIndex( const OUString& _rName, bool _bMustExist ) { return implRemoveIndex(_rName, m_aFreeIndexList, *m_pLB_FreeIndexes, _bMustExist); }
108 0 : void InsertFreeIndex( const OTableIndex& _rIndex ) { implInsertIndex(_rIndex, m_aFreeIndexList, *m_pLB_FreeIndexes); }
109 : OTableIndex RemoveTableIndex( const OUString& _rTableName, const OUString& _rIndexName, bool _bMustExist );
110 : void InsertTableIndex( const OUString& _rTableName, const OTableIndex& _rIndex );
111 :
112 : void checkButtons();
113 :
114 : public:
115 : ODbaseIndexDialog( vcl::Window * pParent, const OUString& aDataSrcName );
116 : virtual ~ODbaseIndexDialog();
117 : virtual void dispose() SAL_OVERRIDE;
118 : };
119 :
120 : } // namespace dbaui
121 :
122 : #endif // INCLUDED_DBACCESS_SOURCE_UI_DLG_DBFINDEX_HXX
123 :
124 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|