/* -*- 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 .
*/
#include <atomic> // HACK: <atomic> includes <stdbool.h>, which in some Clang versions does '#define bool bool', // which confuses clang plugins. #undefbool
// Have the dreaded programmatic filter name defined in one place. inline constexpr OUString SC_TEXT_CSV_FILTER_NAME = u"Text - txt - csv (StarCalc)"_ustr;
// ~105.88 twip, i.e. about 2 times narrower than o3tl::Length::ch, which is 210 twip inline constexpr auto TWIPS_PER_CHAR = o3tl::toTwips(1 / 13.6, o3tl::Length::in);
enumclass ScCloneFlags{ /** Default cell clone flags: do not start listening, do not adjust 3D refs to
old position, clone note captions of cell notes. */ Default = 0x0000,
/** If set, cloned formula cells will start to listen to the document. */
StartListening = 0x0001,
/** If set, absolute refs will not transformed to external references */
NoMakeAbsExternal = 0x0002,
/** If set, global named expressions will be converted to sheet-local named
expressions. */
NamesToLocal = 0x0004
}; namespace o3tl
{ template<> struct typed_flags<ScCloneFlags> : is_typed_flags<ScCloneFlags, 0x0007> {};
}
enum ScSizeMode
{
SC_SIZE_DIRECT, // set size or hide if value is 0
SC_SIZE_OPTIMAL, // set optimal size for everything
SC_SIZE_SHOW, // show with original size
SC_SIZE_VISOPT, // set optimal size only if visible
SC_SIZE_ORIGINAL // only set size, don't change visible flag
};
enum ScInputMode
{
SC_INPUT_NONE,
SC_INPUT_TYPE, // input, while not in inplace mode
SC_INPUT_TABLE, // text cursor in the table
SC_INPUT_TOP // text cursor in the input line
};
enum ScVObjMode // output modes of objects on a page
{
VOBJ_MODE_SHOW,
VOBJ_MODE_HIDE
};
enum ScAnchorType // anchor of a character object
{
SCA_CELL, // anchor to cell, move with cell
SCA_CELL_RESIZE, // anchor to cell, move and resize with cell
SCA_PAGE, // anchor to page, independent of any cells
SCA_DONTKNOW // for multi selection
};
enum ScGetDBMode
{
SC_DB_MAKE, ///< create "untitled" (if necessary)
SC_DB_AUTOFILTER, ///< force use of sheet-local instead of document global anonymous range
SC_DB_IMPORT, ///< create "Importx" (if necessary)
SC_DB_OLD ///< don't create
};
/// For ScDBFunc::GetDBData() enumclass ScGetDBSelection
{ /** Keep selection as is, expand to used data area if no selection. */
Keep,
/** Shrink selection to actually used data area within the selection. */
ShrinkToUsedData,
/** If only one row or portion thereof is selected, shrink row to used data columns and select further rows down until end of data. If an area is selected, shrink rows to actually used columns. Else, no selection,
expand to used data area. */
RowDown,
/** Behave as if the range corresponding to a ScDBData area was selected,
for API use. */
ForceMark
};
struct ScImportParam
{
SCCOL nCol1;
SCROW nRow1;
SCCOL nCol2;
SCROW nRow2; bool bImport;
OUString aDBName; // alias of data base
OUString aStatement; bool bNative; bool bSql; // statement or name?
sal_uInt8 nType; // enum DBObject
ScImportParam();
ScImportParam( const ScImportParam& r );
~ScImportParam();
ScImportParam& operator= ( const ScImportParam& r ); booloperator== ( const ScImportParam& r ) const;
};
// Formula data replacement character for a pair of parentheses at end of // function name, to force sorting parentheses before all other characters. // Collation may treat parentheses differently. inline constexpr sal_Unicode cParenthesesReplacement = 0x0001; struct InputHandlerFunctionNames
{
ScTypedCaseStrSet maFunctionData;
ScTypedCaseStrSet maFunctionDataPara;
std::set<sal_Unicode> maFunctionChar;
};
class ScDocShell; class SvxSearchItem; class ScAutoFormat; class LegacyFuncCollection; class ScUnoAddInCollection; class ScUserList; class SvxBrushItem; class ScFunctionList; class ScFunctionMgr; class SfxItemPool; class EditTextObject; class SfxObjectShell; class SvNumberFormatter; struct ScInterpreterContext; class ScUnitConverter; class CharClass; class LocaleDataWrapper; class SvtSysLocale; class CalendarWrapper; class CollatorWrapper; class ScFieldEditEngine;
namespace com::sun::star { namespace lang { struct Locale;
} namespace i18n { class XOrdinalSuffix;
}
} namespace utl { class TransliterationWrapper;
}
/// strchr() functionality on unicode, as long as we need it for FormulaToken etc. staticconst sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
static sal_Unicode ToUpperAlpha( sal_Unicode c )
{ return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
/** Adds the string rToken to rTokenList, using a list separator character. @param rTokenList The string list where the token will be appended to. @param rToken The token string to append to the token list. @param cSep The character to separate the tokens. @param nSepCount Specifies how often cSep is inserted between two tokens.
@param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
SC_DLLPUBLIC static OUString addToken(
std::u16string_view rTokenList, std::u16string_view rToken,
sal_Unicode cSep, sal_Int32 nSepCount = 1, bool bForceSep = false );
/** Returns true, if the first and last character of the string is cQuote. */
SC_DLLPUBLIC staticbool IsQuoted( std::u16string_view rString, sal_Unicode cQuote );
/** Inserts the character cQuote at beginning and end of rString. @param bEscapeEmbedded If <TRUE/>, embedded quote characters are escaped by doubling them.
*/
SC_DLLPUBLIC staticvoid AddQuotes( OUString& rString, sal_Unicode cQuote, bool bEscapeEmbedded = true );
/** Erases the character cQuote from rString, if it exists at beginning AND end. @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters are unescaped by replacing them with a single instance.
*/
SC_DLLPUBLIC staticvoid EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescapeEmbedded = true );
/** Finds an unquoted instance of cChar in rString, starting at offset nStart. Unquoted instances may occur when concatenating two quoted strings with a separator, for example, 's1':'s2'. Embedded quotes have to be escaped by being doubled. Caller must ensure that nStart points into an unquoted range or the opening quote. Specialty: if cChar=='\'' the first quote character from nStart on is found. @returns offset if found, else -1
*/
SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar, sal_Int32 nStart = 0 );
/** Finds an unquoted instance of cChar in null-terminated pString. Same semantics as FindUnquoted( const String&, ...) @returns: pointer to cChar if found, else NULL
*/
SC_DLLPUBLIC staticconst sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar );
/// a "ReadOnly" formatter for UNO/XML export static SvNumberFormatter* GetEnglishFormatter();
staticbool IsSystemRTL(); // depending on system language static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
SC_DLLPUBLIC static SvtScriptType GetDefaultScriptType(); // for all WEAK characters /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs. If more than one SvtScriptType::... values are or'ed together, prefers
first COMPLEX, then ASIAN */
SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( SvtScriptType nScriptType, sal_uInt16 nWhich );
/** Adds a language item to the item set, if the number format item contains
a language that differs from its parent's language. */
SC_DLLPUBLIC staticvoid AddLanguage( SfxItemSet& rSet, const SvNumberFormatter& rFormatter );
/** Obtain the ordinal suffix for a number according to the system locale */ static OUString GetOrdinalSuffix( sal_Int32 nNumber);
/** Replaces the first occurrence of rPlaceholder in rString with rReplacement, or if rPlaceholder is not found appends one space if rString does not end in a space and appends rReplacement.
Meant to be used with resource strings ala "Column %1" where a translation may have omitted the %1 placeholder and a simple replacement would end up with nothing replaced so no column indicator in the result string.
*/
SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString,
std::u16string_view rPlaceholder, const OUString& rReplacement );
/** Convert string content to numeric value.
In any case, if rError is set 0.0 is returned.
If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally assigned to rError and 0.0 is returned. The caller is expected to handle this situation. Used by the interpreter.
Usually FormulaError::NoValue is passed as nStringNoValueError.
Otherwise, depending on the string conversion configuration different approaches are taken:
For ScCalcConfig::StringConversion::ILLEGAL The error value passed in nStringNoValueError is assigned to rError (and 0.0 returned).
For ScCalcConfig::StringConversion::ZERO A zero value is returned and no error assigned.
For ScCalcConfig::StringConversion::LOCALE
If the string is empty or consists only of spaces, if "treat empty string as zero" is set 0.0 is returned, else nStringNoValueError assigned to rError (and 0.0 returned).
Else a non-empty string is passed to the number formatter's scanner to be parsed locale dependent. If that does not detect a numeric value nStringNoValueError is assigned to rError (and 0.0 returned).
If no number formatter was passed, the conversion falls back to UNAMBIGUOUS.
For ScCalcConfig::StringConversion::UNAMBIGUOUS
If the string is empty or consists only of spaces, if "treat empty string as zero" is set 0.0 is returned, else nStringNoValueError assigned to rError (and 0.0 returned).
If the string is not empty the following conversion rules are applied:
Converted are only integer numbers including exponent, and ISO 8601 dates and times in their extended formats with separators. Anything else, especially fractional numeric values with decimal separators or dates other than ISO 8601 would be locale dependent and is a no-no. Leading and trailing blanks are ignored.
The century CC may not be omitted and the two-digit year setting is not taken into account. Instead of the T date and time separator exactly one blank may be used.
If a date is given, it must be a valid Gregorian calendar date. In this case the optional time must be in the range 00:00 to 23:59:59.99999... If only time is given, it may have any value for hours, taking elapsed time into account; minutes and seconds are limited to the value 59 as well.
If the string can not be converted to a numeric value, the error value passed in nStringNoValueError is assigned to rError.
@param rStr The string to be converted.
@param rConfig The calculation configuration.
@param rError Contains the error on return, if any. If an error was set before and the conversion did not result in an error, still 0.0 is returned.
@param nStringNoValueError The error value to be assigned to rError if string could not be converted to number.
@param pFormatter The number formatter to use in case of ScCalcConfig::StringConversion::LOCALE. Can but should not be nullptr in which case conversion falls back to ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is detected the null date is assumed to be the standard 1899-12-30 instead of the configured null date.
@param rCurFmtType Can be assigned a format type in case a date or time or date+time string was converted, e.g. SvNumFormatType::DATE or SvNumFormatType::TIME or a combination thereof.
struct ScConsolidateParam
{
SCCOL nCol; // cursor position /
SCROW nRow; // or start of destination area respectively
SCTAB nTab;
ScSubTotalFunc eFunction;
sal_uInt16 nDataAreaCount; // number of data areas
std::unique_ptr<ScArea[]> pDataAreas; // array of pointers into data areas bool bByCol; bool bByRow; bool bReferenceData; // reference source data
ScConsolidateParam();
ScConsolidateParam( const ScConsolidateParam& r );
~ScConsolidateParam();
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.