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