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