void OIndexCollection::commitNewIndex(const Indexes::iterator& _rPos)
{
OSL_ENSURE(_rPos->isNew(), "OIndexCollection::commitNewIndex: index must be new!");
try
{
Reference< XDataDescriptorFactory > xIndexFactory(m_xIndexes, UNO_QUERY);
Reference< XAppend > xAppendIndex(xIndexFactory, UNO_QUERY); if (!xAppendIndex.is())
{
OSL_FAIL("OIndexCollection::commitNewIndex: missing an interface of the index container!"); return;
}
Reference< XDataDescriptorFactory > xColumnFactory(xCols, UNO_QUERY);
Reference< XAppend > xAppendCols(xColumnFactory, UNO_QUERY); if (!xAppendCols.is())
{
OSL_FAIL("OIndexCollection::commitNewIndex: invalid index descriptor returned!"); return;
}
// set the properties static constexpr OUString s_sNamePropertyName = u"Name"_ustr; // the index' own props
xIndexDescriptor->setPropertyValue(u"IsUnique"_ustr, css::uno::Any(_rPos->bUnique));
xIndexDescriptor->setPropertyValue(s_sNamePropertyName, Any(_rPos->sName));
// the fields for (autoconst& field : _rPos->aFields)
{
OSL_ENSURE(!xCols->hasByName(field.sFieldName), "OIndexCollection::commitNewIndex: double column name (need to prevent this outside)!");
// adjust the OIndex structure
Indexes::iterator aDropped = findOriginal(_rPos->getOriginalName());
OSL_ENSURE(aDropped != m_aIndexes.end(), "OIndexCollection::drop: invalid original name, but successful commit?!");
aDropped->flagAsNew(GrantIndexAccess());
returntrue;
}
bool OIndexCollection::drop(const Indexes::iterator& _rPos)
{
OSL_ENSURE((_rPos >= m_aIndexes.begin()) && (_rPos < m_aIndexes.end()), "OIndexCollection::drop: invalid position (fasten your seatbelt... this will crash)!");
if (!_rPos->isNew()) if (!dropNoRemove(_rPos)) returnfalse;
// adjust the index array
m_aIndexes.erase(_rPos); returntrue;
}
void OIndexCollection::implFillIndexInfo(OIndex& _rIndex)
{ // get the UNO descriptor for the index
Reference< XPropertySet > xIndex;
m_xIndexes->getByName(_rIndex.getOriginalName()) >>= xIndex; if (!xIndex.is())
{
OSL_FAIL("OIndexCollection::implFillIndexInfo: got an invalid index object!");
} else
implFillIndexInfo(_rIndex, xIndex);
}
// the columns
Reference< XColumnsSupplier > xSuppCols(_rxDescriptor, UNO_QUERY);
Reference< XNameAccess > xCols; if (xSuppCols.is())
xCols = xSuppCols->getColumns();
OSL_ENSURE(xCols.is(), "OIndexCollection::implFillIndexInfo: the index does not have columns!"); if (!xCols.is()) return;
Indexes::iterator OIndexCollection::insert(const OUString& _rName)
{
OSL_ENSURE(end() == find(_rName), "OIndexCollection::insert: invalid new name!");
OIndex aNewIndex((OUString())); // the empty string indicates the index is a new one
aNewIndex.sName = _rName;
m_aIndexes.push_back(aNewIndex); return m_aIndexes.end() - 1; // the last element is the new one ...
}
m_xIndexes = _rxIndexes; if (!m_xIndexes.is()) return;
// loop through all the indexes for (auto& name : m_xIndexes->getElementNames())
{ // extract the index object
Reference< XPropertySet > xIndex;
m_xIndexes->getByName(name) >>= xIndex; if (!xIndex.is())
{
OSL_FAIL("OIndexCollection::implConstructFrom: got an invalid index object ... ignoring!"); continue;
}
// fill the OIndex structure
OIndex aCurrentIndex(name);
implFillIndexInfo(aCurrentIndex, xIndex);
m_aIndexes.push_back(aCurrentIndex);
}
}
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.