Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef EXTENSIONS_ABSPILOT_HXX
21 : #define EXTENSIONS_ABSPILOT_HXX
22 :
23 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 : #include <svtools/roadmapwizard.hxx>
25 : #include "addresssettings.hxx"
26 : #include <vcl/fixed.hxx>
27 : #include "datasourcehandling.hxx"
28 :
29 : //.........................................................................
30 : namespace abp
31 : {
32 : //.........................................................................
33 :
34 : //=====================================================================
35 : //= OAddessBookSourcePilot
36 : //=====================================================================
37 : typedef ::svt::RoadmapWizard OAddessBookSourcePilot_Base;
38 : class OAddessBookSourcePilot : public OAddessBookSourcePilot_Base
39 : {
40 : protected:
41 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
42 : m_xORB;
43 : AddressSettings m_aSettings;
44 :
45 : ODataSource m_aNewDataSource;
46 : AddressSourceType m_eNewDataSourceType;
47 :
48 : public:
49 : /// ctor
50 : OAddessBookSourcePilot(
51 : Window* _pParent,
52 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
53 : /// dtor
54 : ~OAddessBookSourcePilot();
55 :
56 : /// get the service factory which was used to create the dialog
57 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
58 0 : getORB() { return m_xORB; }
59 0 : AddressSettings& getSettings() { return m_aSettings; }
60 0 : const AddressSettings& getSettings() const { return m_aSettings; }
61 :
62 0 : const ODataSource& getDataSource() const { return m_aNewDataSource; }
63 :
64 : sal_Bool connectToDataSource( sal_Bool _bForceReConnect );
65 :
66 0 : void travelNext( ) { OAddessBookSourcePilot_Base::travelNext(); }
67 :
68 : /// to be called when the selected type changed
69 : void typeSelectionChanged( AddressSourceType _eType );
70 :
71 : protected:
72 : // OWizardMachine overridables
73 : virtual ::svt::OWizardPage* createPage( WizardState _nState );
74 : virtual void enterState( WizardState _nState );
75 : virtual sal_Bool prepareLeaveCurrentState( CommitPageReason _eReason );
76 : virtual sal_Bool onFinish();
77 :
78 : // RoadmapWizard
79 : virtual String getStateDisplayName( WizardState _nState ) const;
80 :
81 : virtual sal_Bool Close();
82 :
83 : private:
84 : DECL_LINK( OnCancelClicked, void* );
85 :
86 : /** creates a new data source of the type indicated by m_aSettings
87 : <p>If another data source has been created before, this one is deleted.</p>
88 : */
89 : void implCreateDataSource();
90 :
91 : /// does an automatic field mapping (possible for all types except AST_OTHER)
92 : void implDoAutoFieldMapping();
93 :
94 : /// guesses a default for the table name, if no valid table is selected
95 : void implDefaultTableName();
96 :
97 0 : inline sal_Bool needAdminInvokationPage( AddressSourceType _eType ) const
98 : {
99 : return ( ( AST_LDAP == _eType )
100 : || ( AST_OTHER == _eType )
101 0 : );
102 : }
103 : /// check if with the current settings, we would need to invoke he administration dialog for more details about the data source
104 0 : inline sal_Bool needAdminInvokationPage() const
105 : {
106 0 : return needAdminInvokationPage( m_aSettings.eType );
107 : }
108 :
109 0 : inline sal_Bool needManualFieldMapping( AddressSourceType _eType ) const
110 : {
111 : return ( AST_OTHER == _eType ) || ( AST_KAB == _eType ) ||
112 : ( AST_EVOLUTION == _eType ) || ( AST_EVOLUTION_GROUPWISE == _eType ) ||
113 0 : ( AST_EVOLUTION_LDAP == _eType );
114 : }
115 : /// checks if we need a manual (user-guided) field mapping
116 0 : inline sal_Bool needManualFieldMapping() const
117 : {
118 0 : return needManualFieldMapping( m_aSettings.eType );
119 : }
120 :
121 : /// determines whether the given address book type does provide one table only
122 0 : inline bool needTableSelection( AddressSourceType _eType ) const
123 : {
124 0 : return ( AST_LDAP != _eType ) && ( AST_KAB != _eType );
125 : }
126 :
127 : inline bool needTableSelection() const
128 : {
129 : return needTableSelection( m_aSettings.eType );
130 : }
131 :
132 : void implCleanup();
133 : void implCommitAll();
134 :
135 : void impl_updateRoadmap( AddressSourceType _eType );
136 : };
137 :
138 : //.........................................................................
139 : } // namespace abp
140 : //.........................................................................
141 :
142 : #endif // EXTENSIONS_ABSPILOT_HXX
143 :
144 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|