xref: /trunk/main/dbaccess/source/ui/inc/indexes.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_INDEXES_HXX_
29 #define _DBAUI_INDEXES_HXX_
30 
31 #ifndef _STRING_HXX
32 #include <tools/string.hxx>
33 #endif
34 #ifndef _COMPHELPER_STLTYPES_HXX_
35 #include <comphelper/stl_types.hxx>
36 #endif
37 
38 //......................................................................
39 namespace dbaui
40 {
41 //......................................................................
42     //==================================================================
43     //= OIndexField
44     //==================================================================
45     struct OIndexField
46     {
47         String              sFieldName;
48         sal_Bool            bSortAscending;
49 
50         OIndexField() : bSortAscending(sal_True) { }
51     };
52 
53     DECLARE_STL_VECTOR( OIndexField, IndexFields );
54 
55     //==================================================================
56     //= OIndex
57     //==================================================================
58     struct GrantIndexAccess
59     {
60         friend class OIndexCollection;
61     private:
62         GrantIndexAccess() { }
63     };
64 
65     //..................................................................
66     struct OIndex
67     {
68     protected:
69         ::rtl::OUString     sOriginalName;
70         sal_Bool            bModified;
71 
72     public:
73         ::rtl::OUString     sName;
74         ::rtl::OUString     sDescription;
75         sal_Bool            bPrimaryKey;
76         sal_Bool            bUnique;
77         IndexFields         aFields;
78 
79     public:
80         OIndex(const ::rtl::OUString& _rOriginalName)
81             : sOriginalName(_rOriginalName), bModified(sal_False), sName(_rOriginalName), bPrimaryKey(sal_False), bUnique(sal_False)
82         {
83         }
84 
85         const ::rtl::OUString& getOriginalName() const { return sOriginalName; }
86 
87         sal_Bool    isModified() const { return bModified; }
88         void        setModified(sal_Bool _bModified) { bModified = _bModified; }
89         void        clearModified() { setModified(sal_False); }
90 
91         sal_Bool    isNew() const { return 0 == getOriginalName().getLength(); }
92         void        flagAsNew(const GrantIndexAccess&) { sOriginalName = ::rtl::OUString(); }
93         void        flagAsCommitted(const GrantIndexAccess&) { sOriginalName = sName; }
94 
95 
96     private:
97         OIndex();   // not implemented
98     };
99 
100     DECLARE_STL_VECTOR( OIndex, Indexes );
101 
102 //......................................................................
103 }   // namespace dbaui
104 //......................................................................
105 
106 #endif // _DBAUI_INDEXES_HXX_
107 
108