xref: /AOO41X/main/extensions/source/abpilot/abspilot.hxx (revision 46dbaceef8c12a09e4905feda473ecab36e10d03)
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 EXTENSIONS_ABSPILOT_HXX
25 #define EXTENSIONS_ABSPILOT_HXX
26 
27 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <svtools/roadmapwizard.hxx>
29 #include "addresssettings.hxx"
30 #include <vcl/fixed.hxx>
31 #include "datasourcehandling.hxx"
32 
33 //.........................................................................
34 namespace abp
35 {
36 //.........................................................................
37 
38     //=====================================================================
39     //= OAddessBookSourcePilot
40     //=====================================================================
41     typedef ::svt::RoadmapWizard OAddessBookSourcePilot_Base;
42     class OAddessBookSourcePilot : public OAddessBookSourcePilot_Base
43     {
44     protected:
45         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
46                                 m_xORB;
47         AddressSettings         m_aSettings;
48 
49         ODataSource             m_aNewDataSource;
50         AddressSourceType       m_eNewDataSourceType;
51 
52     public:
53         /// ctor
54         OAddessBookSourcePilot(
55             Window* _pParent,
56             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
57 
58         /// get the service factory which was used to create the dialog
59         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
getORB()60                                 getORB() { return m_xORB; }
getSettings()61         AddressSettings&        getSettings() { return m_aSettings; }
getSettings() const62         const AddressSettings&  getSettings() const { return m_aSettings; }
63 
getDataSource() const64         const ODataSource&      getDataSource() const { return m_aNewDataSource; }
65 
66         sal_Bool                connectToDataSource( sal_Bool _bForceReConnect );
67 
travelNext()68         void                    travelNext( ) { OAddessBookSourcePilot_Base::travelNext(); }
69 
70         /// to be called when the selected type changed
71         void                    typeSelectionChanged( AddressSourceType _eType );
72 
73     protected:
74         // OWizardMachine overridables
75         virtual ::svt::OWizardPage* createPage( WizardState _nState );
76         virtual void                enterState( WizardState _nState );
77         virtual sal_Bool            prepareLeaveCurrentState( CommitPageReason _eReason );
78         virtual sal_Bool            onFinish();
79 
80         // RoadmapWizard
81         virtual String              getStateDisplayName( WizardState _nState ) const;
82 
83         virtual sal_Bool    Close();
84 
85     private:
86         DECL_LINK( OnCancelClicked, void* );
87 
88         /** creates a new data source of the type indicated by m_aSettings
89             <p>If another data source has been created before, this one is deleted.</p>
90         */
91         void implCreateDataSource();
92 
93         /// does an automatic field mapping (possible for all types except AST_OTHER)
94         void implDoAutoFieldMapping();
95 
96         /// guesses a default for the table name, if no valid table is selected
97         void implDefaultTableName();
98 
needAdminInvokationPage(AddressSourceType _eType) const99         inline sal_Bool needAdminInvokationPage( AddressSourceType _eType ) const
100         {
101             return  (   ( AST_LDAP == _eType )
102                     ||  ( AST_OTHER == _eType )
103                     );
104         }
105         /// check if with the current settings, we would need to invoke he administration dialog for more details about the data source
needAdminInvokationPage() const106         inline sal_Bool needAdminInvokationPage() const
107         {
108             return  needAdminInvokationPage( m_aSettings.eType );
109         }
110 
needManualFieldMapping(AddressSourceType _eType) const111         inline sal_Bool needManualFieldMapping( AddressSourceType _eType ) const
112         {
113             return  ( AST_OTHER == _eType ) || ( AST_KAB == _eType ) ||
114                     ( AST_EVOLUTION == _eType ) || ( AST_EVOLUTION_GROUPWISE == _eType ) ||
115                     ( AST_EVOLUTION_LDAP == _eType );
116         }
117         /// checks if we need a manual (user-guided) field mapping
needManualFieldMapping() const118         inline sal_Bool needManualFieldMapping() const
119         {
120             return needManualFieldMapping( m_aSettings.eType );
121         }
122 
123         /// determines whether the given address book type does provide one table only
needTableSelection(AddressSourceType _eType) const124         inline bool needTableSelection( AddressSourceType _eType ) const
125         {
126             return  ( AST_LDAP != _eType ) && ( AST_KAB != _eType );
127         }
128 
needTableSelection() const129         inline bool needTableSelection() const
130         {
131             return needTableSelection( m_aSettings.eType );
132         }
133 
134         void implCleanup();
135         void implCommitAll();
136 
137         void impl_updateRoadmap( AddressSourceType _eType );
138     };
139 
140 //.........................................................................
141 }   // namespace abp
142 //.........................................................................
143 
144 #endif // EXTENSIONS_ABSPILOT_HXX
145 
146