/* -*- 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 .
*/
bool lcl_createStarQuery( const ScDocument* pDoc,
svl::SharedStringPool& rPool, ScQueryParamBase* pParam, const ScDBRangeBase* pDBRef, const ScDBRangeBase* pQueryRef)
{ // A valid StarQuery must be at least 4 columns wide. To be precise it // should be exactly 4 columns ... // Additionally, if this wasn't checked, a formula pointing to a valid 1-3 // column Excel style query range immediately left to itself would result // in a circular reference when the field name or operator or value (first // to third query range column) is obtained (#i58354#). Furthermore, if the // range wasn't sufficiently specified data changes wouldn't flag formula // cells for recalculation.
do
{
ScQueryEntry& rEntry = pParam->GetEntry(nIndex);
bValid = false;
if (nIndex > 0)
{ // For all entries after the first one, check the and/or connector in the first column.
aCellStr = pQueryRef->getString(0, nRow);
lcl_uppercase(aCellStr); if ( aCellStr == ScResId(STR_TABLE_AND) )
{
rEntry.eConnect = SC_AND;
bValid = true;
} elseif ( aCellStr == ScResId(STR_TABLE_OR) )
{
rEntry.eConnect = SC_OR;
bValid = true;
}
}
if ((nIndex < 1) || bValid)
{ // field name in the 2nd column.
aCellStr = pQueryRef->getString(1, nRow);
SCCOL nField = pDBRef->findFieldColumn(aCellStr); // TODO: must be case insensitive comparison. if (pDoc->ValidCol(nField))
{
rEntry.nField = nField;
bValid = true;
} else
bValid = false;
}
if (bValid)
{ // equality, non-equality operator in the 3rd column.
aCellStr = pQueryRef->getString(2, nRow);
lcl_uppercase(aCellStr); const sal_Unicode* p = aCellStr.getStr(); if (p[0] == '<')
{ if (p[1] == '>')
rEntry.eOp = SC_NOT_EQUAL; elseif (p[1] == '=')
rEntry.eOp = SC_LESS_EQUAL; else
rEntry.eOp = SC_LESS;
} elseif (p[0] == '>')
{ if (p[1] == '=')
rEntry.eOp = SC_GREATER_EQUAL; else
rEntry.eOp = SC_GREATER;
} elseif (p[0] == '=')
rEntry.eOp = SC_EQUAL;
}
if (bValid)
{ // Finally, the right-hand-side value in the 4th column.
rEntry.GetQueryItem().maString =
rPool.intern(pQueryRef->getString(3, nRow));
rEntry.bDoQuery = true;
}
nIndex++;
nRow++;
} while (bValid && (nRow < nRows) /* && (nIndex < MAXQUERY) */ ); return bValid;
}
if (bValid)
{ // Count the number of visible cells (excluding the header row). Each // visible cell corresponds with a single query.
SCSIZE nVisible = pQueryRef->getVisibleDataCellCount(); if ( nVisible > SCSIZE_MAX / sizeof(void*) )
{
OSL_FAIL("too many filter criteria");
nVisible = 0;
}
nCount = pParam->GetEntryCount(); if (bValid)
{ // bQueryByString must be set for (SCSIZE i = 0; i < nCount; ++i)
pParam->GetEntry(i).GetQueryItem().meType = ScQueryEntry::ByString;
} else
{ // nothing for (SCSIZE i = 0; i < nCount; ++i)
pParam->GetEntry(i).Clear();
} return bValid;
}
OUString ScDBInternalRange::getString(SCCOL nCol, SCROW nRow) const
{ const ScAddress& s = maRange.aStart; // #i109200# this is used in formula calculation, use GetInputString, not GetString // (consistent with ScDBInternalRange::getCellString) // GetStringForFormula is not used here, to allow querying for date values. return getDoc()->GetInputString(s.Col() + nCol, s.Row() + nRow, maRange.aStart.Tab());
}
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.