1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DBAUI_INDEXDIALOG_HXX_
25cdf0e10cSrcweir #define _DBAUI_INDEXDIALOG_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _SV_DIALOG_HXX
28cdf0e10cSrcweir #include <vcl/dialog.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _SV_FIXED_HXX
31cdf0e10cSrcweir #include <vcl/fixed.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _SV_LSTBOX_HXX
34cdf0e10cSrcweir #include <vcl/lstbox.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX
37cdf0e10cSrcweir #include <vcl/button.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
40cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
43cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
46cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
49cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir #ifndef _SV_TOOLBOX_HXX
52cdf0e10cSrcweir #include <vcl/toolbox.hxx>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #ifndef _SVTREEBOX_HXX
55cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX
58cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir #ifndef _DBAUI_INDEXES_HXX_
61cdf0e10cSrcweir #include "indexes.hxx"
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #ifndef DBAUI_TOOLBOXHELPER_HXX
64cdf0e10cSrcweir #include "ToolBoxHelper.hxx"
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir 
67cdf0e10cSrcweir //......................................................................
68cdf0e10cSrcweir namespace dbaui
69cdf0e10cSrcweir {
70cdf0e10cSrcweir //......................................................................
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	//==================================================================
73cdf0e10cSrcweir 	//= DbaIndexList
74cdf0e10cSrcweir 	//==================================================================
75cdf0e10cSrcweir 	class DbaIndexList : public SvTreeListBox
76cdf0e10cSrcweir 	{
77cdf0e10cSrcweir 	protected:
78cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
79cdf0e10cSrcweir 		Link		m_aSelectHdl;
80cdf0e10cSrcweir 		Link		m_aEndEditHdl;
81cdf0e10cSrcweir 		sal_Bool	m_bSuspendSelectHdl;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	public:
84cdf0e10cSrcweir 		DbaIndexList(Window* _pParent, const ResId& _rId);
85cdf0e10cSrcweir 
SetSelectHdl(const Link & _rHdl)86cdf0e10cSrcweir 		void SetSelectHdl(const Link& _rHdl) { m_aSelectHdl = _rHdl; }
GetSelectHdl() const87cdf0e10cSrcweir 		Link GetSelectHdl() const { return m_aSelectHdl; }
88cdf0e10cSrcweir 
SetEndEditHdl(const Link & _rHdl)89cdf0e10cSrcweir 		void SetEndEditHdl(const Link& _rHdl) { m_aEndEditHdl = _rHdl; }
GetEndEditHdl() const90cdf0e10cSrcweir 		Link GetEndEditHdl() const { return m_aEndEditHdl; }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 		virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 		void enableSelectHandler();
95cdf0e10cSrcweir 		void disableSelectHandler();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 		void SelectNoHandlerCall( SvLBoxEntry* pEntry );
98cdf0e10cSrcweir 
setConnection(const::com::sun::star::uno::Reference<::com::sun::star::sdbc::XConnection> & _rxConnection)99cdf0e10cSrcweir 		inline void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection)
100cdf0e10cSrcweir 		{
101cdf0e10cSrcweir 			 m_xConnection = _rxConnection;
102cdf0e10cSrcweir 		}
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	protected:
105cdf0e10cSrcweir 		virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     private:
108cdf0e10cSrcweir         using SvTreeListBox::Select;
109cdf0e10cSrcweir 	};
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	//==================================================================
112cdf0e10cSrcweir 	//= DbaIndexDialog
113cdf0e10cSrcweir 	//==================================================================
114cdf0e10cSrcweir 	class IndexFieldsControl;
115cdf0e10cSrcweir 	class OIndexCollection;
116cdf0e10cSrcweir 	class DbaIndexDialog :	public ModalDialog,
117cdf0e10cSrcweir 							public OToolBoxHelper
118cdf0e10cSrcweir 	{
119cdf0e10cSrcweir 	protected:
120cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
121cdf0e10cSrcweir 		SvtViewOptions			m_aGeometrySettings;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 		ToolBox					m_aActions;
124cdf0e10cSrcweir 		DbaIndexList			m_aIndexes;
125cdf0e10cSrcweir 		FixedLine				m_aIndexDetails;
126cdf0e10cSrcweir 		FixedText				m_aDescriptionLabel;
127cdf0e10cSrcweir 		FixedText				m_aDescription;
128cdf0e10cSrcweir 		CheckBox				m_aUnique;
129cdf0e10cSrcweir 		FixedText				m_aFieldsLabel;
130cdf0e10cSrcweir 		IndexFieldsControl*		m_pFields;
131cdf0e10cSrcweir 		PushButton				m_aClose;
132cdf0e10cSrcweir 		HelpButton				m_aHelp;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 		OIndexCollection*		m_pIndexes;
135cdf0e10cSrcweir 		SvLBoxEntry*			m_pPreviousSelection;
136cdf0e10cSrcweir 		sal_Bool				m_bEditAgain;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
139cdf0e10cSrcweir 								m_xORB;
140cdf0e10cSrcweir 	public:
141cdf0e10cSrcweir 		DbaIndexDialog(
142cdf0e10cSrcweir 			Window* _pParent,
143cdf0e10cSrcweir 			const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rFieldNames,
144cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes,
145cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
146cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
147cdf0e10cSrcweir 			sal_Int32 _nMaxColumnsInIndex
148cdf0e10cSrcweir 			);
149cdf0e10cSrcweir 		virtual ~DbaIndexDialog();
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 		virtual void StateChanged( StateChangedType nStateChange );
152cdf0e10cSrcweir 		virtual void DataChanged( const DataChangedEvent& rDCEvt );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 		/** will be called whenthe id of the image list is needed.
155cdf0e10cSrcweir 			@param	_eBitmapSet
156cdf0e10cSrcweir 				<svtools/imgdef.hxx>
157cdf0e10cSrcweir 			@param	_bHiContast
158cdf0e10cSrcweir 				<TRUE/> when in high contrast mode.
159cdf0e10cSrcweir 		*/
160cdf0e10cSrcweir 		virtual ImageList getImageList(sal_Int16 _eBitmapSet,sal_Bool _bHiContast) const;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 		/** will be called when the controls need to be resized.
163cdf0e10cSrcweir 		*/
164cdf0e10cSrcweir 		virtual void resizeControls(const Size& _rDiff);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	protected:
167cdf0e10cSrcweir 		void fillIndexList();
168cdf0e10cSrcweir 		void updateToolbox();
169cdf0e10cSrcweir 		void updateControls(const SvLBoxEntry* _pEntry);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	protected:
172cdf0e10cSrcweir 		DECL_LINK( OnIndexSelected, DbaIndexList* );
173cdf0e10cSrcweir 		DECL_LINK( OnIndexAction, ToolBox* );
174cdf0e10cSrcweir 		DECL_LINK( OnEntryEdited, SvLBoxEntry* );
175cdf0e10cSrcweir 		DECL_LINK( OnModified, void* );
176cdf0e10cSrcweir 		DECL_LINK( OnCloseDialog, void* );
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 		DECL_LINK( OnEditIndexAgain, SvLBoxEntry* );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	private:
181cdf0e10cSrcweir 		void OnNewIndex();
182cdf0e10cSrcweir 		void OnDropIndex(sal_Bool _bConfirm = sal_True);
183cdf0e10cSrcweir 		void OnRenameIndex();
184cdf0e10cSrcweir 		void OnSaveIndex();
185cdf0e10cSrcweir 		void OnResetIndex();
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 		sal_Bool implCommit(SvLBoxEntry* _pEntry);
188cdf0e10cSrcweir 		sal_Bool implSaveModified(sal_Bool _bPlausibility = sal_True);
189cdf0e10cSrcweir 		sal_Bool implCommitPreviouslySelected();
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 		sal_Bool implDropIndex(SvLBoxEntry* _pEntry, sal_Bool _bRemoveFromCollection);
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 		sal_Bool implCheckPlausibility(const ConstIndexesIterator& _rPos);
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 		/** checks if the controls have to be replaced and moved.
196cdf0e10cSrcweir 		*/
197cdf0e10cSrcweir 		void checkControls();
198cdf0e10cSrcweir 	};
199cdf0e10cSrcweir 
200cdf0e10cSrcweir //......................................................................
201cdf0e10cSrcweir }	// namespace dbaui
202cdf0e10cSrcweir //......................................................................
203cdf0e10cSrcweir 
204cdf0e10cSrcweir #endif // _DBAUI_INDEXDIALOG_HXX_
205cdf0e10cSrcweir 
206