/* -*- 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 .
*/
staticbool IsFormulaText(const CharClass& rCharClass, const OUString& rStr, sal_Int32 nPos)
{ if( rCharClass.isLetterNumeric( rStr, nPos ) ) returntrue; else
{ // In internationalized versions function names may contain a dot // and in every version also an underscore... ;-)
sal_Unicode c = rStr[nPos]; return c == '.' || c == '_';
}
short nParCount = 0; short nTableRefCount = 0; bool bInArray = false; bool bFound = false; bool bTickEscaped = false;
while ( !bFound && (nStart < nStrLen) )
{
sal_Unicode c = rStr[nStart];
if (nTableRefCount > 0)
{ // Column names may contain anything, skip. Also skip separator // between item specifier and column name or whatever in a // TableRef [[...]; [...]] // But keep track of apostrophe ' tick escaped brackets. if (c == '\'')
bTickEscaped = !bTickEscaped; else
{ if (c == tableRefOpen && !bTickEscaped)
++nTableRefCount; elseif (c == tableRefClose && !bTickEscaped)
--nTableRefCount;
bTickEscaped = false;
}
} elseif (c == tableRefOpen)
{
++nTableRefCount;
} elseif ( c == '"' )
{
nStart++; while ( (nStart < nStrLen) && rStr[nStart] != '"' )
nStart++;
} elseif ( c == open )
nParCount++; elseif ( c == close )
{
nParCount--; if ( nParCount == 0 )
bFound = true; elseif ( nParCount < 0 )
{
bFound = true;
nStart--; // read one too far
}
} elseif ( c == arrayOpen )
{
bInArray = true;
} elseif ( c == arrayClose )
{
bInArray = false;
} elseif ( c == sep )
{ if ( !bInArray && nParCount == 0 )
{
bFound = true;
nStart--; // read one too far
}
}
nStart++; // Set behind found position
}
// nStart > nStrLen can happen if there was an unclosed quote; instead of // checking that in every loop iteration check it once here. return std::min(nStart, nStrLen);
}
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.