update dev300-m58
[ooovba.git] / dbaccess / source / ui / inc / indexdialog.hxx
blobc79b24ba1b0fa98bc234f7b1f28e8796bdd94c34
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: indexdialog.hxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DBAUI_INDEXDIALOG_HXX_
32 #define _DBAUI_INDEXDIALOG_HXX_
34 #ifndef _SV_DIALOG_HXX
35 #include <vcl/dialog.hxx>
36 #endif
37 #ifndef _SV_FIXED_HXX
38 #include <vcl/fixed.hxx>
39 #endif
40 #ifndef _SV_LSTBOX_HXX
41 #include <vcl/lstbox.hxx>
42 #endif
43 #ifndef _SV_BUTTON_HXX
44 #include <vcl/button.hxx>
45 #endif
46 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
47 #include <com/sun/star/container/XNameAccess.hpp>
48 #endif
49 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
50 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 #endif
52 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
53 #include <com/sun/star/sdbc/XConnection.hpp>
54 #endif
55 #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
56 #include <com/sun/star/uno/Sequence.hxx>
57 #endif
58 #ifndef _SV_TOOLBOX_HXX
59 #include <vcl/toolbox.hxx>
60 #endif
61 #ifndef _SVTREEBOX_HXX
62 #include <svtools/svtreebx.hxx>
63 #endif
64 #ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX
65 #include <svtools/viewoptions.hxx>
66 #endif
67 #ifndef _DBAUI_INDEXES_HXX_
68 #include "indexes.hxx"
69 #endif
70 #ifndef DBAUI_TOOLBOXHELPER_HXX
71 #include "ToolBoxHelper.hxx"
72 #endif
74 //......................................................................
75 namespace dbaui
77 //......................................................................
79 //==================================================================
80 //= DbaIndexList
81 //==================================================================
82 class DbaIndexList : public SvTreeListBox
84 protected:
85 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
86 Link m_aSelectHdl;
87 Link m_aEndEditHdl;
88 sal_Bool m_bSuspendSelectHdl;
90 public:
91 DbaIndexList(Window* _pParent, const ResId& _rId);
93 void SetSelectHdl(const Link& _rHdl) { m_aSelectHdl = _rHdl; }
94 Link GetSelectHdl() const { return m_aSelectHdl; }
96 void SetEndEditHdl(const Link& _rHdl) { m_aEndEditHdl = _rHdl; }
97 Link GetEndEditHdl() const { return m_aEndEditHdl; }
99 virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect );
101 void enableSelectHandler();
102 void disableSelectHandler();
104 void SelectNoHandlerCall( SvLBoxEntry* pEntry );
106 inline void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection)
108 m_xConnection = _rxConnection;
111 protected:
112 virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
114 private:
115 using SvTreeListBox::Select;
118 //==================================================================
119 //= DbaIndexDialog
120 //==================================================================
121 class IndexFieldsControl;
122 class OIndexCollection;
123 class DbaIndexDialog : public ModalDialog,
124 public OToolBoxHelper
126 protected:
127 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
128 SvtViewOptions m_aGeometrySettings;
130 ToolBox m_aActions;
131 DbaIndexList m_aIndexes;
132 FixedLine m_aIndexDetails;
133 FixedText m_aDescriptionLabel;
134 FixedText m_aDescription;
135 CheckBox m_aUnique;
136 FixedText m_aFieldsLabel;
137 IndexFieldsControl* m_pFields;
138 PushButton m_aClose;
139 HelpButton m_aHelp;
141 OIndexCollection* m_pIndexes;
142 SvLBoxEntry* m_pPreviousSelection;
143 sal_Bool m_bEditAgain;
145 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
146 m_xORB;
147 public:
148 DbaIndexDialog(
149 Window* _pParent,
150 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rFieldNames,
151 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes,
152 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
153 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
154 sal_Int32 _nMaxColumnsInIndex
156 virtual ~DbaIndexDialog();
158 virtual void StateChanged( StateChangedType nStateChange );
159 virtual void DataChanged( const DataChangedEvent& rDCEvt );
161 /** will be called whenthe id of the image list is needed.
162 @param _eBitmapSet
163 <svtools/imgdef.hxx>
164 @param _bHiContast
165 <TRUE/> when in high contrast mode.
167 virtual ImageList getImageList(sal_Int16 _eBitmapSet,sal_Bool _bHiContast) const;
169 /** will be called when the controls need to be resized.
171 virtual void resizeControls(const Size& _rDiff);
173 protected:
174 void fillIndexList();
175 void updateToolbox();
176 void updateControls(const SvLBoxEntry* _pEntry);
178 protected:
179 DECL_LINK( OnIndexSelected, DbaIndexList* );
180 DECL_LINK( OnIndexAction, ToolBox* );
181 DECL_LINK( OnEntryEdited, SvLBoxEntry* );
182 DECL_LINK( OnModified, void* );
183 DECL_LINK( OnCloseDialog, void* );
185 DECL_LINK( OnEditIndexAgain, SvLBoxEntry* );
187 private:
188 void OnNewIndex();
189 void OnDropIndex(sal_Bool _bConfirm = sal_True);
190 void OnRenameIndex();
191 void OnSaveIndex();
192 void OnResetIndex();
194 sal_Bool implCommit(SvLBoxEntry* _pEntry);
195 sal_Bool implSaveModified(sal_Bool _bPlausibility = sal_True);
196 sal_Bool implCommitPreviouslySelected();
198 sal_Bool implDropIndex(SvLBoxEntry* _pEntry, sal_Bool _bRemoveFromCollection);
200 sal_Bool implCheckPlausibility(const ConstIndexesIterator& _rPos);
202 /** checks if the controls have to be replaced and moved.
204 void checkControls();
207 //......................................................................
208 } // namespace dbaui
209 //......................................................................
211 #endif // _DBAUI_INDEXDIALOG_HXX_