Avoid potential negative array index access to cached text.
[LibreOffice.git] / extensions / source / abpilot / abspilot.hxx
blob45c965d2be0de04e104c419ed7415e6ff8c35de0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <vcl/roadmapwizard.hxx>
23 #include "addresssettings.hxx"
24 #include "datasourcehandling.hxx"
26 using vcl::WizardTypes::WizardState;
27 using vcl::WizardTypes::CommitPageReason;
29 namespace abp
31 typedef ::vcl::RoadmapWizardMachine OAddressBookSourcePilot_Base;
32 class OAddressBookSourcePilot final : public OAddressBookSourcePilot_Base
34 css::uno::Reference< css::uno::XComponentContext >
35 m_xORB;
36 AddressSettings m_aSettings;
38 ODataSource m_aNewDataSource;
39 AddressSourceType m_eNewDataSourceType;
41 public:
42 /// ctor
43 OAddressBookSourcePilot(
44 weld::Window* _pParent,
45 const css::uno::Reference< css::uno::XComponentContext >& _rxORB);
47 virtual short run() override;
49 /// get the service factory which was used to create the dialog
50 const css::uno::Reference< css::uno::XComponentContext >&
51 getORB() const { return m_xORB; }
52 AddressSettings& getSettings() { return m_aSettings; }
53 const AddressSettings& getSettings() const { return m_aSettings; }
55 const ODataSource& getDataSource() const { return m_aNewDataSource; }
57 bool connectToDataSource( bool _bForceReConnect );
59 void travelNext( ) { OAddressBookSourcePilot_Base::travelNext(); }
61 /// to be called when the selected type changed
62 void typeSelectionChanged( AddressSourceType _eType );
64 private:
65 // OWizardMachine overridables
66 virtual std::unique_ptr<BuilderPage> createPage( WizardState _nState ) override;
67 virtual void enterState( WizardState _nState ) override;
68 virtual bool prepareLeaveCurrentState( CommitPageReason _eReason ) override;
69 virtual bool onFinish() override;
71 // RoadmapWizard
72 virtual OUString getStateDisplayName( WizardState _nState ) const override;
74 /** creates a new data source of the type indicated by m_aSettings
75 <p>If another data source has been created before, this one is deleted.</p>
77 void implCreateDataSource();
79 /// does an automatic field mapping (possible for all types except AST_OTHER)
80 void implDoAutoFieldMapping();
82 /// guesses a default for the table name, if no valid table is selected
83 void implDefaultTableName();
85 static bool needAdminInvokationPage( AddressSourceType _eType )
87 return ( AST_OTHER == _eType );
89 /// check if with the current settings, we would need to invoke he administration dialog for more details about the data source
90 bool needAdminInvokationPage() const
92 return needAdminInvokationPage( m_aSettings.eType );
95 static bool needManualFieldMapping( AddressSourceType _eType )
97 return ( AST_OTHER == _eType ) || ( AST_KAB == _eType ) ||
98 ( AST_EVOLUTION == _eType ) || ( AST_EVOLUTION_GROUPWISE == _eType ) ||
99 ( AST_EVOLUTION_LDAP == _eType );
101 /// checks if we need a manual (user-guided) field mapping
102 bool needManualFieldMapping() const
104 return needManualFieldMapping( m_aSettings.eType );
107 /// determines whether the given address book type does provide one table only
108 static bool needTableSelection( AddressSourceType _eType )
110 return ( AST_KAB != _eType );
113 void implCleanup();
114 void implCommitAll();
116 void impl_updateRoadmap( AddressSourceType _eType );
118 } // namespace abp
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */