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