/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
OUString OAddressBookSourcePilot::getStateDisplayName( WizardState _nState ) const
{
TranslateId pResId; switch ( _nState )
{ case STATE_SELECT_ABTYPE: pResId = RID_STR_SELECT_ABTYPE; break; case STATE_INVOKE_ADMIN_DIALOG: pResId = RID_STR_INVOKE_ADMIN_DIALOG; break; case STATE_TABLE_SELECTION: pResId = RID_STR_TABLE_SELECTION; break; case STATE_MANUAL_FIELD_MAPPING: pResId = RID_STR_MANUAL_FIELD_MAPPING; break; case STATE_FINAL_CONFIRM: pResId = RID_STR_FINAL_CONFIRM; break;
}
DBG_ASSERT( pResId, "OAddressBookSourcePilot::getStateDisplayName: don't know this state!" );
OUString sDisplayName; if (pResId)
{
sDisplayName = compmodule::ModuleRes(pResId);
}
return sDisplayName;
}
void OAddressBookSourcePilot::implCommitAll()
{ // in real, the data source already exists in the data source context // Thus, if the user changed the name, we have to rename the data source if ( m_aSettings.sDataSourceName != m_aNewDataSource.getName() )
m_aNewDataSource.rename( m_aSettings.sDataSourceName );
// 1. the data source
m_aNewDataSource.store(m_aSettings);
// 2. check if we need to register the data source if ( m_aSettings.bRegisterDataSource )
m_aNewDataSource.registerDataSource(m_aSettings.sRegisteredDataSourceName);
// 3. write the data source / table names into the configuration
addressconfig::writeTemplateAddressSource( getORB(), m_aSettings.bRegisterDataSource ? m_aSettings.sRegisteredDataSourceName : m_aSettings.sDataSourceName, m_aSettings.sSelectedTable );
// 4. write the field mapping
fieldmapping::writeTemplateAddressFieldMapping( getORB(), std::map(m_aSettings.aFieldMapping) );
}
void OAddressBookSourcePilot::implCleanup()
{ if ( m_aNewDataSource.isValid() )
m_aNewDataSource.remove();
}
short OAddressBookSourcePilot::run()
{ short nRet = vcl::RoadmapWizardMachine::run();
implCleanup();
return nRet;
}
bool OAddressBookSourcePilot::onFinish()
{ if (!vcl::RoadmapWizardMachine::onFinish()) returnfalse;
case STATE_FINAL_CONFIRM: if ( !needManualFieldMapping( ) )
implDoAutoFieldMapping(); break;
case STATE_TABLE_SELECTION:
implDefaultTableName(); break;
}
vcl::RoadmapWizardMachine::enterState(_nState);
}
bool OAddressBookSourcePilot::prepareLeaveCurrentState( CommitPageReason _eReason )
{ if (!vcl::RoadmapWizardMachine::prepareLeaveCurrentState(_eReason)) returnfalse;
if ( _eReason == vcl::WizardTypes::eTravelBackward ) returntrue;
bool bAllow = true;
switch ( getCurrentState() )
{ case STATE_SELECT_ABTYPE:
implCreateDataSource(); if ( needAdminInvokationPage() ) break;
[[fallthrough]];
case STATE_INVOKE_ADMIN_DIALOG: if ( !connectToDataSource( false ) )
{ // connecting did not succeed -> do not allow proceeding
bAllow = false; break;
}
// now that we connected to the data source, check whether we need the "table selection" page const StringBag& aTables = m_aNewDataSource.getTableNames();
void OAddressBookSourcePilot::implCreateDataSource()
{ if (m_aNewDataSource.isValid())
{ // we already have a data source object if ( m_aSettings.eType == m_eNewDataSourceType ) // and it already has the correct type return;
// it has a wrong type -> remove it
m_aNewDataSource.remove();
}
enableState( STATE_TABLE_SELECTION,
bTablesPage && ( bConnected ? !bCanSkipTables : !bSettingsPage ) // if we do not need a settings page, we connect upon "Next" on the first page
);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.