xref: /trunk/main/extensions/source/abpilot/abspilot.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef EXTENSIONS_ABSPILOT_HXX
29 #define EXTENSIONS_ABSPILOT_HXX
30 
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <svtools/roadmapwizard.hxx>
33 #include "addresssettings.hxx"
34 #include <vcl/fixed.hxx>
35 #include "datasourcehandling.hxx"
36 
37 //.........................................................................
38 namespace abp
39 {
40 //.........................................................................
41 
42     //=====================================================================
43     //= OAddessBookSourcePilot
44     //=====================================================================
45     typedef ::svt::RoadmapWizard OAddessBookSourcePilot_Base;
46     class OAddessBookSourcePilot : public OAddessBookSourcePilot_Base
47     {
48     protected:
49         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
50                                 m_xORB;
51         AddressSettings         m_aSettings;
52 
53         ODataSource             m_aNewDataSource;
54         AddressSourceType       m_eNewDataSourceType;
55 
56     public:
57         /// ctor
58         OAddessBookSourcePilot(
59             Window* _pParent,
60             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
61 
62         /// get the service factory which was used to create the dialog
63         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
64                                 getORB() { return m_xORB; }
65         AddressSettings&        getSettings() { return m_aSettings; }
66         const AddressSettings&  getSettings() const { return m_aSettings; }
67 
68         const ODataSource&      getDataSource() const { return m_aNewDataSource; }
69 
70         sal_Bool                connectToDataSource( sal_Bool _bForceReConnect );
71 
72         void                    travelNext( ) { OAddessBookSourcePilot_Base::travelNext(); }
73 
74         /// to be called when the selected type changed
75         void                    typeSelectionChanged( AddressSourceType _eType );
76 
77     protected:
78         // OWizardMachine overridables
79         virtual ::svt::OWizardPage* createPage( WizardState _nState );
80         virtual void                enterState( WizardState _nState );
81         virtual sal_Bool            prepareLeaveCurrentState( CommitPageReason _eReason );
82         virtual sal_Bool            onFinish();
83 
84         // RoadmapWizard
85         virtual String              getStateDisplayName( WizardState _nState ) const;
86 
87         virtual sal_Bool    Close();
88 
89     private:
90         DECL_LINK( OnCancelClicked, void* );
91 
92         /** creates a new data source of the type indicated by m_aSettings
93             <p>If another data source has been created before, this one is deleted.</p>
94         */
95         void implCreateDataSource();
96 
97         /// does an automatic field mapping (possible for all types except AST_OTHER)
98         void implDoAutoFieldMapping();
99 
100         /// guesses a default for the table name, if no valid table is selected
101         void implDefaultTableName();
102 
103         inline sal_Bool needAdminInvokationPage( AddressSourceType _eType ) const
104         {
105             return  (   ( AST_LDAP == _eType )
106                     ||  ( AST_OTHER == _eType )
107                     );
108         }
109         /// check if with the current settings, we would need to invoke he administration dialog for more details about the data source
110         inline sal_Bool needAdminInvokationPage() const
111         {
112             return  needAdminInvokationPage( m_aSettings.eType );
113         }
114 
115         inline sal_Bool needManualFieldMapping( AddressSourceType _eType ) const
116         {
117             return  ( AST_OTHER == _eType ) || ( AST_KAB == _eType ) ||
118                     ( AST_EVOLUTION == _eType ) || ( AST_EVOLUTION_GROUPWISE == _eType ) ||
119                     ( AST_EVOLUTION_LDAP == _eType );
120         }
121         /// checks if we need a manual (user-guided) field mapping
122         inline sal_Bool needManualFieldMapping() const
123         {
124             return needManualFieldMapping( m_aSettings.eType );
125         }
126 
127         /// determines whether the given address book type does provide one table only
128         inline bool needTableSelection( AddressSourceType _eType ) const
129         {
130             return  ( AST_LDAP != _eType ) && ( AST_KAB != _eType );
131         }
132 
133         inline bool needTableSelection() const
134         {
135             return needTableSelection( m_aSettings.eType );
136         }
137 
138         void implCleanup();
139         void implCommitAll();
140 
141         void impl_updateRoadmap( AddressSourceType _eType );
142     };
143 
144 //.........................................................................
145 }   // namespace abp
146 //.........................................................................
147 
148 #endif // EXTENSIONS_ABSPILOT_HXX
149 
150