xref: /trunk/main/extensions/source/dbpilots/controlwizard.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*46dbaceeSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*46dbaceeSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*46dbaceeSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*46dbaceeSAndrew Rist  * distributed with this work for additional information
6*46dbaceeSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*46dbaceeSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*46dbaceeSAndrew Rist  * "License"); you may not use this file except in compliance
9*46dbaceeSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*46dbaceeSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*46dbaceeSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*46dbaceeSAndrew Rist  * software distributed under the License is distributed on an
15*46dbaceeSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*46dbaceeSAndrew Rist  * KIND, either express or implied.  See the License for the
17*46dbaceeSAndrew Rist  * specific language governing permissions and limitations
18*46dbaceeSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*46dbaceeSAndrew Rist  *************************************************************/
21*46dbaceeSAndrew Rist 
22*46dbaceeSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _EXTENSIONS_DBP_CONTROLWIZARD_HXX
25cdf0e10cSrcweir #define _EXTENSIONS_DBP_CONTROLWIZARD_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svtools/wizardmachine.hxx>
28cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
31cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp>
32cdf0e10cSrcweir #include <vcl/fixed.hxx>
33cdf0e10cSrcweir #include <vcl/edit.hxx>
34cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX
35cdf0e10cSrcweir #include <vcl/button.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include <vcl/lstbox.hxx>
38cdf0e10cSrcweir #include <vcl/combobox.hxx>
39cdf0e10cSrcweir #include "dbptypes.hxx"
40cdf0e10cSrcweir #ifndef _EXTENSIONS_DBP_DBPRESID_HRC_
41cdf0e10cSrcweir #include "dbpresid.hrc"
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir #include "componentmodule.hxx"
44cdf0e10cSrcweir #include "wizardcontext.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir class ResId;
47cdf0e10cSrcweir //.........................................................................
48cdf0e10cSrcweir namespace dbp
49cdf0e10cSrcweir {
50cdf0e10cSrcweir //.........................................................................
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     //=====================================================================
53cdf0e10cSrcweir     //= OControlWizardSettings
54cdf0e10cSrcweir     //=====================================================================
55cdf0e10cSrcweir     struct OControlWizardSettings
56cdf0e10cSrcweir     {
57cdf0e10cSrcweir         String      sControlLabel;
58cdf0e10cSrcweir     };
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     //=====================================================================
61cdf0e10cSrcweir     //= OControlWizardPage
62cdf0e10cSrcweir     //=====================================================================
63cdf0e10cSrcweir     class OControlWizard;
64cdf0e10cSrcweir     typedef ::svt::OWizardPage OControlWizardPage_Base;
65cdf0e10cSrcweir     class OControlWizardPage : public OControlWizardPage_Base
66cdf0e10cSrcweir     {
67cdf0e10cSrcweir     protected:
68cdf0e10cSrcweir         FixedLine*      m_pFormSettingsSeparator;
69cdf0e10cSrcweir         FixedText*      m_pFormDatasourceLabel;
70cdf0e10cSrcweir         FixedText*      m_pFormDatasource;
71cdf0e10cSrcweir         FixedText*      m_pFormContentTypeLabel;
72cdf0e10cSrcweir         FixedText*      m_pFormContentType;
73cdf0e10cSrcweir         FixedText*      m_pFormTableLabel;
74cdf0e10cSrcweir         FixedText*      m_pFormTable;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     protected:
77cdf0e10cSrcweir         OControlWizard*                 getDialog();
78cdf0e10cSrcweir         const OControlWizard*           getDialog() const;
79cdf0e10cSrcweir         const OControlWizardContext&    getContext();
80cdf0e10cSrcweir         sal_Bool                        updateContext();
81cdf0e10cSrcweir         void                            setFormConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, sal_Bool _bAutoDispose = sal_True );
82cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
83cdf0e10cSrcweir                                         getFormConnection() const;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     public:
86cdf0e10cSrcweir         OControlWizardPage( OControlWizard* _pParent, const ResId& _rResId );
87cdf0e10cSrcweir         ~OControlWizardPage();
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     protected:
90cdf0e10cSrcweir         void fillListBox(
91cdf0e10cSrcweir             ListBox& _rList,
92cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rItems,
93cdf0e10cSrcweir             sal_Bool _bClear = sal_True);
94cdf0e10cSrcweir         void fillListBox(
95cdf0e10cSrcweir             ComboBox& _rList,
96cdf0e10cSrcweir             const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rItems,
97cdf0e10cSrcweir             sal_Bool _bClear = sal_True);
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     protected:
100cdf0e10cSrcweir         void enableFormDatasourceDisplay();
101cdf0e10cSrcweir         void adjustControlForNoDSDisplay(Control* _pControl, sal_Bool bConstLowerDistance = sal_False);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     protected:
104cdf0e10cSrcweir         // OWizardPage overridables
105cdf0e10cSrcweir         virtual void        initializePage();
106cdf0e10cSrcweir     };
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     struct OAccessRegulator;
109cdf0e10cSrcweir     //=====================================================================
110cdf0e10cSrcweir     //= OControlWizard
111cdf0e10cSrcweir     //=====================================================================
112cdf0e10cSrcweir     typedef ::svt::OWizardMachine OControlWizard_Base;
113cdf0e10cSrcweir     class OControlWizard : public OControlWizard_Base
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir     private:
116cdf0e10cSrcweir         OControlWizardContext   m_aContext;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     protected:
119cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
120cdf0e10cSrcweir                     m_xORB;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     public:
123cdf0e10cSrcweir         OControlWizard(
124cdf0e10cSrcweir             Window* _pParent,
125cdf0e10cSrcweir             const ResId& _rId,
126cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
127cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
128cdf0e10cSrcweir         );
129cdf0e10cSrcweir         ~OControlWizard();
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         // make the some base class methods public
travelNext()132cdf0e10cSrcweir         sal_Bool    travelNext() { return OControlWizard_Base::travelNext(); }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     public:
135cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
getServiceFactory() const136cdf0e10cSrcweir             getServiceFactory() const { return m_xORB; }
137cdf0e10cSrcweir 
getContext() const138cdf0e10cSrcweir         const OControlWizardContext&    getContext() const { return m_aContext; }
139cdf0e10cSrcweir         sal_Bool                        updateContext(const OAccessRegulator&);
140cdf0e10cSrcweir         void                            setFormConnection(const OAccessRegulator&, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, sal_Bool _bAutoDispose = sal_True );
141cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
142cdf0e10cSrcweir                                         getFormConnection(const OAccessRegulator&) const;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         /** returns the com.sun.star.task.InteractionHandler
145cdf0e10cSrcweir             @param  _pWindow    The window will be used when an error message has to be shown.
146cdf0e10cSrcweir         */
147cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > getInteractionHandler(Window* _pWindow) const;
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     protected:
150cdf0e10cSrcweir         // initialize the derivees settings (which have to be derived from OControlWizardSettings)
151cdf0e10cSrcweir         // with some common data extracted from the control model
152cdf0e10cSrcweir         void initControlSettings(OControlWizardSettings* _pSettings);
153cdf0e10cSrcweir         // commit the control-relevant settings
154cdf0e10cSrcweir         void commitControlSettings(OControlWizardSettings* _pSettings);
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         sal_Bool needDatasourceSelection();
157cdf0e10cSrcweir 
158cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
159cdf0e10cSrcweir                                         getFormConnection() const;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir         virtual sal_Bool approveControl(sal_Int16 _nClassId) = 0;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir         // ModalDialog overridables
164cdf0e10cSrcweir         virtual short   Execute();
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     private:
167cdf0e10cSrcweir         sal_Bool initContext();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir         void implGetDSContext();
170cdf0e10cSrcweir         void implDetermineForm();
171cdf0e10cSrcweir         void implDeterminePage();
172cdf0e10cSrcweir         void implDetermineShape();
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         // made private. Not to be used by derived (or external) classes
175cdf0e10cSrcweir         virtual void ActivatePage();
176cdf0e10cSrcweir     };
177cdf0e10cSrcweir 
178cdf0e10cSrcweir //.........................................................................
179cdf0e10cSrcweir }   // namespace dbp
180cdf0e10cSrcweir //.........................................................................
181cdf0e10cSrcweir 
182cdf0e10cSrcweir #endif // _EXTENSIONS_DBP_CONTROLWIZARD_HXX
183