Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
21 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
22 :
23 : #include <vcl/dialog.hxx>
24 : #include <vcl/fixed.hxx>
25 : #include <vcl/lstbox.hxx>
26 : #include <vcl/button.hxx>
27 : #include <com/sun/star/container/XNameAccess.hpp>
28 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 : #include <com/sun/star/sdbc/XConnection.hpp>
30 : #include <com/sun/star/uno/Sequence.hxx>
31 : #include <com/sun/star/uno/XComponentContext.hpp>
32 : #include <vcl/toolbox.hxx>
33 : #include <svtools/treelistbox.hxx>
34 : #include <unotools/viewoptions.hxx>
35 : #include "indexes.hxx"
36 : #include <dbaccess/ToolBoxHelper.hxx>
37 :
38 : namespace dbaui
39 : {
40 :
41 : // DbaIndexList
42 0 : class DbaIndexList : public SvTreeListBox
43 : {
44 : protected:
45 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
46 : Link m_aSelectHdl;
47 : Link m_aEndEditHdl;
48 : sal_Bool m_bSuspendSelectHdl;
49 :
50 : public:
51 : DbaIndexList(Window* _pParent, const ResId& _rId);
52 :
53 0 : void SetSelectHdl(const Link& _rHdl) { m_aSelectHdl = _rHdl; }
54 : Link GetSelectHdl() const { return m_aSelectHdl; }
55 :
56 0 : void SetEndEditHdl(const Link& _rHdl) { m_aEndEditHdl = _rHdl; }
57 : Link GetEndEditHdl() const { return m_aEndEditHdl; }
58 :
59 : virtual sal_Bool Select( SvTreeListEntry* pEntry, sal_Bool bSelect );
60 :
61 : void enableSelectHandler();
62 : void disableSelectHandler();
63 :
64 : void SelectNoHandlerCall( SvTreeListEntry* pEntry );
65 :
66 0 : inline void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection)
67 : {
68 0 : m_xConnection = _rxConnection;
69 0 : }
70 :
71 : protected:
72 : virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) SAL_OVERRIDE;
73 :
74 : private:
75 : using SvTreeListBox::Select;
76 : };
77 :
78 : // DbaIndexDialog
79 : class IndexFieldsControl;
80 : class OIndexCollection;
81 : class DbaIndexDialog : public ModalDialog,
82 : public OToolBoxHelper
83 : {
84 : protected:
85 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
86 : SvtViewOptions m_aGeometrySettings;
87 :
88 : ToolBox m_aActions;
89 : DbaIndexList m_aIndexes;
90 : FixedLine m_aIndexDetails;
91 : FixedText m_aDescriptionLabel;
92 : FixedText m_aDescription;
93 : CheckBox m_aUnique;
94 : FixedText m_aFieldsLabel;
95 : IndexFieldsControl* m_pFields;
96 : PushButton m_aClose;
97 : HelpButton m_aHelp;
98 :
99 : OIndexCollection* m_pIndexes;
100 : SvTreeListEntry* m_pPreviousSelection;
101 : sal_Bool m_bEditAgain;
102 :
103 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
104 : m_xContext;
105 : public:
106 : DbaIndexDialog(
107 : Window* _pParent,
108 : const ::com::sun::star::uno::Sequence< OUString >& _rFieldNames,
109 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes,
110 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
111 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
112 : sal_Int32 _nMaxColumnsInIndex
113 : );
114 : virtual ~DbaIndexDialog();
115 :
116 : virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
117 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
118 :
119 : /** will be called whenthe id of the image list is needed.
120 : @param _eBitmapSet
121 : <svtools/imgdef.hxx>
122 : @param _bHiContast
123 : <TRUE/> when in high contrast mode.
124 : */
125 : virtual ImageList getImageList(sal_Int16 _eBitmapSet) const SAL_OVERRIDE;
126 :
127 : /** will be called when the controls need to be resized.
128 : */
129 : virtual void resizeControls(const Size& _rDiff) SAL_OVERRIDE;
130 :
131 : protected:
132 : void fillIndexList();
133 : void updateToolbox();
134 : void updateControls(const SvTreeListEntry* _pEntry);
135 :
136 : protected:
137 : DECL_LINK( OnIndexSelected, DbaIndexList* );
138 : DECL_LINK( OnIndexAction, ToolBox* );
139 : DECL_LINK( OnEntryEdited, SvTreeListEntry* );
140 : DECL_LINK( OnModified, void* );
141 : DECL_LINK( OnCloseDialog, void* );
142 :
143 : DECL_LINK( OnEditIndexAgain, SvTreeListEntry* );
144 :
145 : private:
146 : void OnNewIndex();
147 : void OnDropIndex(sal_Bool _bConfirm = sal_True);
148 : void OnRenameIndex();
149 : void OnSaveIndex();
150 : void OnResetIndex();
151 :
152 : sal_Bool implCommit(SvTreeListEntry* _pEntry);
153 : sal_Bool implSaveModified(sal_Bool _bPlausibility = sal_True);
154 : sal_Bool implCommitPreviouslySelected();
155 :
156 : sal_Bool implDropIndex(SvTreeListEntry* _pEntry, sal_Bool _bRemoveFromCollection);
157 :
158 : sal_Bool implCheckPlausibility(const Indexes::const_iterator& _rPos);
159 :
160 : /** checks if the controls have to be replaced and moved.
161 : */
162 : void checkControls();
163 : };
164 :
165 : } // namespace dbaui
166 :
167 : #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
168 :
169 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|