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