/* -*- 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 .
*/
if (getFinalState() == _nState)
defaultButton(WizardButtonFlags::FINISH);
}
bool OListComboWizard::leaveState(WizardState _nState)
{ if (!OControlWizard::leaveState(_nState)) returnfalse;
if (getFinalState() == _nState)
defaultButton(WizardButtonFlags::NEXT);
returntrue;
}
void OListComboWizard::implApplySettings()
{ try
{ // for quoting identifiers, we need the connection meta data
Reference< XConnection > xConn = getFormConnection();
DBG_ASSERT(xConn.is(), "OListComboWizard::implApplySettings: no connection, unable to quote!");
Reference< XDatabaseMetaData > xMetaData; if (xConn.is())
xMetaData = xConn->getMetaData();
// do some quotings if (xMetaData.is())
{
OUString sQuoteString = xMetaData->getIdentifierQuoteString(); if (isListBox()) // only when we have a listbox this should be not empty
getSettings().sLinkedListField = quoteName(sQuoteString, getSettings().sLinkedListField);
if (isListBox())
{ // BoundColumn: 1
getContext().xObjectModel->setPropertyValue(u"BoundColumn"_ustr, Any(sal_Int16(1)));
Sequence< OUString > aListSource { // build the statement to set as list source
OUString("SELECT " +
getSettings().sListContentField + ", " + getSettings().sLinkedListField + " FROM " + getSettings().sListContentTable)
};
getContext().xObjectModel->setPropertyValue(u"ListSource"_ustr, Any(aListSource));
} else
{ // build the statement to set as list source
OUString sStatement = "SELECT DISTINCT " +
getSettings().sListContentField + " FROM " + getSettings().sListContentTable;
getContext().xObjectModel->setPropertyValue( u"ListSource"_ustr, Any(sStatement));
}
// the bound field
getContext().xObjectModel->setPropertyValue(u"DataField"_ustr, Any(getSettings().sLinkedFormField));
} catch(const Exception&)
{
OSL_FAIL("OListComboWizard::implApplySettings: could not set the property values for the listbox!");
}
}
bool OListComboWizard::onFinish()
{ if ( !OControlWizard::onFinish() ) returnfalse;
implApplySettings(); returntrue;
}
Reference< XNameAccess > OLCPage::getTables() const
{
Reference< XConnection > xConn = getFormConnection();
DBG_ASSERT(xConn.is(), "OLCPage::getTables: should have an active connection when reaching this page!");
// fill the list with the table name
m_xSelectTable->clear(); try
{
Reference< XNameAccess > xTables = getTables();
Sequence< OUString > aTableNames; if (xTables.is())
aTableNames = xTables->getElementNames();
fillListBox(*m_xSelectTable, aTableNames);
} catch(const Exception&)
{
OSL_FAIL("OContentTableSelection::initializePage: could not retrieve the table names!");
}
bool OContentTableSelection::commitPage( ::vcl::WizardTypes::CommitPageReason _eReason )
{ if (!OLCPage::commitPage(_eReason)) returnfalse;
OListComboSettings& rSettings = getSettings();
rSettings.sListContentTable = m_xSelectTable->get_selected_text(); if (rSettings.sListContentTable.isEmpty() && (::vcl::WizardTypes::eTravelBackward != _eReason)) // need to select a table returnfalse;
// fill the value list
fillListBox(*m_xValueListField, getContext().aFieldNames); // fill the table field list
fillListBox(*m_xTableField, getTableFields());
// the initial selections
m_xValueListField->set_entry_text(getSettings().sLinkedFormField);
m_xTableField->set_entry_text(getSettings().sLinkedListField);
implCheckFinish();
}
bool OLinkFieldsPage::canAdvance() const
{ // we're on the last page here, no travelNext allowed ... returnfalse;
}
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.