/* -*- 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 .
*/
case GBW_STATE_DEFAULTOPTION: return GBW_STATE_OPTIONVALUES;
case GBW_STATE_OPTIONVALUES: if (getContext().aFieldNames.hasElements()) return GBW_STATE_DBFIELD; else return GBW_STATE_FINALIZE;
case GBW_STATE_DBFIELD: return GBW_STATE_FINALIZE;
}
return WZS_INVALID_STATE;
}
void OGroupBoxWizard::enterState(::vcl::WizardTypes::WizardState _nState)
{ // some stuff to do before calling the base class (modifying our settings) switch (_nState)
{ case GBW_STATE_DEFAULTOPTION: if (!m_bVisitedDefault)
{ // assume that the first of the radio buttons should be selected
DBG_ASSERT(m_aSettings.aLabels.size(), "OGroupBoxWizard::enterState: should never have reached this state!");
m_aSettings.sDefaultField = m_aSettings.aLabels[0];
}
m_bVisitedDefault = true; break;
case GBW_STATE_DBFIELD: if (!m_bVisitedDB)
{ // try to generate a default for the DB field // (simply use the first field in the DB names collection) if (getContext().aFieldNames.hasElements())
m_aSettings.sDBField = getContext().aFieldNames[0];
}
m_bVisitedDB = true; break;
}
// setting the def button... to be done before the base class is called, too, 'cause the base class // calls the pages, which are allowed to override our def button behaviour
defaultButton(GBW_STATE_FINALIZE == _nState ? WizardButtonFlags::FINISH : WizardButtonFlags::NEXT);
// allow "finish" on the last page only
enableButtons(WizardButtonFlags::FINISH, GBW_STATE_FINALIZE == _nState); // allow previous on all pages but the first one
enableButtons(WizardButtonFlags::PREVIOUS, GBW_STATE_OPTIONLIST != _nState); // allow next on all pages but the last one
enableButtons(WizardButtonFlags::NEXT, GBW_STATE_FINALIZE != _nState);
OControlWizard::enterState(_nState);
}
bool OGroupBoxWizard::onFinish()
{ // commit the basic control settings
commitControlSettings(&m_aSettings);
// create the radio buttons try
{
OOptionGroupLayouter aLayouter( getComponentContext() );
aLayouter.doLayout(getContext(), getSettings());
} catch(const Exception&)
{
TOOLS_WARN_EXCEPTION("extensions.dbpilots", "caught an exception while creating the radio shapes!");
}
// no need to initialize the list of radios here // (we're the only one affecting this special setting, so it will be in the same state as last time this // page was committed)
implCheckMoveButtons();
}
bool ORadioSelectionPage::commitPage( ::vcl::WizardTypes::CommitPageReason _eReason )
{ if (!OGBWPage::commitPage(_eReason)) returnfalse;
// copy the names of the radio buttons to be inserted // and initialize the values
OOptionGroupSettings& rSettings = getSettings();
rSettings.aLabels.clear();
rSettings.aValues.clear();
rSettings.aLabels.reserve(m_xExistingRadios->n_children());
rSettings.aValues.reserve(m_xExistingRadios->n_children()); for (sal_Int32 i=0; i<m_xExistingRadios->n_children(); ++i)
{
rSettings.aLabels.push_back(m_xExistingRadios->get_text(i));
rSettings.aValues.push_back(OUString::number(i + 1));
}
if (bUnfinishedInput)
{ if (!pDialog->is_default_widget(m_xMoveRight.get()))
pDialogController->defaultButton(m_xMoveRight.get());
} else
{ if (pDialog->is_default_widget(m_xMoveRight.get()))
pDialogController->defaultButton(WizardButtonFlags::NEXT);
}
}
void OOptionValuesPage::implTraveledOptions()
{ if (::vcl::WizardTypes::WizardState(-1) != m_nLastSelection)
{ // save the value for the last option
DBG_ASSERT(o3tl::make_unsigned(m_nLastSelection) < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid previous selection index!");
m_aUncommittedValues[m_nLastSelection] = m_xValue->get_text();
}
// fill the list with all available options
m_xOptions->clear();
m_nLastSelection = -1; for (autoconst& label : rSettings.aLabels)
m_xOptions->append_text(label);
// remember the values ... can't set them directly in the settings without the explicit commit call // so we need have a copy of the values
m_aUncommittedValues = rSettings.aValues;
// select the first entry
m_xOptions->select(0);
implTraveledOptions();
}
bool OOptionValuesPage::commitPage( ::vcl::WizardTypes::CommitPageReason _eReason )
{ if (!OGBWPage::commitPage(_eReason)) returnfalse;
OOptionGroupSettings& rSettings = getSettings();
// commit the current value
implTraveledOptions(); // copy the uncommitted values
rSettings.aValues = m_aUncommittedValues;
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.