xref: /trunk/main/dbaccess/source/ui/inc/indexfieldscontrol.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_INDEXFIELDSCONTROL_HXX_
29 #define _DBAUI_INDEXFIELDSCONTROL_HXX_
30 
31 #ifndef _DBAUI_MODULE_DBU_HXX_
32 #include "moduledbu.hxx"
33 #endif
34 #ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
35 #include <svtools/editbrowsebox.hxx>
36 #endif
37 #ifndef _DBAUI_INDEXCOLLECTION_HXX_
38 #include "indexcollection.hxx"
39 #endif
40 #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
41 #include <com/sun/star/uno/Sequence.hxx>
42 #endif
43 
44 //......................................................................
45 namespace dbaui
46 {
47 //......................................................................
48 
49     //==================================================================
50     // IndexFieldsControl
51     //==================================================================
52     class IndexFieldsControl : public ::svt::EditBrowseBox
53     {
54         OModuleClient        m_aModuleClient;
55     protected:
56         IndexFields                 m_aSavedValue;
57 
58         IndexFields                 m_aFields;          // !! order matters !!
59         ConstIndexFieldsIterator    m_aSeekRow;         // !!
60 
61         Link                        m_aModifyHdl;
62 
63         ::svt::ListBoxControl*      m_pSortingCell;
64         ::svt::ListBoxControl*      m_pFieldNameCell;
65 
66         String                      m_sAscendingText;
67         String                      m_sDescendingText;
68 
69         sal_Int32                   m_nMaxColumnsInIndex;
70         sal_Bool                    m_bAddIndexAppendix;
71 
72     public:
73         IndexFieldsControl( Window* _pParent, const ResId& _rId ,sal_Int32 _nMaxColumnsInIndex,sal_Bool _bAddIndexAppendix);
74         ~IndexFieldsControl();
75 
76         void Init(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rAvailableFields);
77 
78         void initializeFrom(const IndexFields& _rFields);
79         void commitTo(IndexFields& _rFields);
80 
81         sal_Bool SaveModified();
82         sal_Bool IsModified() const;
83 
84         const IndexFields&  GetSavedValue() const { return m_aSavedValue; }
85         void                SaveValue() { m_aSavedValue = m_aFields; }
86 
87         void SetModifyHdl(const Link& _rHdl) { m_aModifyHdl = _rHdl; }
88         Link GetModifyHdl() const { return m_aModifyHdl; }
89         virtual String GetCellText(long _nRow,sal_uInt16 nColId) const;
90 
91     protected:
92         // EditBrowseBox overridables
93         virtual void PaintCell( OutputDevice& _rDev, const Rectangle& _rRect, sal_uInt16 _nColumnId ) const;
94         virtual sal_Bool SeekRow(long nRow);
95         virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId);
96         virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
97 
98         ::svt::CellController*  GetController(long _nRow, sal_uInt16 _nColumnId);
99         void                InitController(::svt::CellControllerRef&, long _nRow, sal_uInt16 _nColumnId);
100 
101     protected:
102         String GetRowCellText(const ConstIndexFieldsIterator& _rRow,sal_uInt16 nColId) const;
103         sal_Bool implGetFieldDesc(long _nRow, ConstIndexFieldsIterator& _rPos);
104 
105         sal_Bool isNewField() const { return GetCurRow() >= (sal_Int32)m_aFields.size(); }
106 
107         DECL_LINK( OnListEntrySelected, ListBox* );
108 
109     private:
110         using ::svt::EditBrowseBox::Init;
111     };
112 
113 //......................................................................
114 }   // namespace dbaui
115 //......................................................................
116 
117 #endif // _DBAUI_INDEXFIELDSCONTROL_HXX_
118 
119