1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include "address.hxx"
23 #include "typedstrdata.hxx"
24 #include <i18nlangtag/lang.h>
25 #include <svx/svdtypes.hxx>
26 #include <tools/ref.hxx>
27 #include <sal/types.h>
28 #include <com/sun/star/i18n/CollatorOptions.hpp>
30 #include <rtl/ustring.hxx>
31 #include <tools/long.hxx>
32 #include <o3tl/unit_conversion.hxx>
35 // HACK: <atomic> includes <stdbool.h>, which in some Clang versions does '#define bool bool',
36 // which confuses clang plugins.
41 #include <string_view>
43 namespace com::sun::star::uno
{ template <typename
> class Reference
; }
48 enum class SvtScriptType
: sal_uInt8
;
49 enum class FormulaError
: sal_uInt16
;
50 enum class SvNumFormatType
: sal_Int16
;
52 #define SC_COLLATOR_IGNORES css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE
54 // Calc has lots of names...
55 // Clipboard names are in so3/soapp.hxx now
56 // STRING_SCAPP was "scalc3", "scalc4", now just "scalc"
58 inline constexpr OUStringLiteral STRING_SCAPP
= u
"scalc";
60 inline constexpr OUStringLiteral STRING_STANDARD
= u
"Standard";
62 // Have the dreaded programmatic filter name defined in one place.
63 inline constexpr OUStringLiteral SC_TEXT_CSV_FILTER_NAME
= u
"Text - txt - csv (StarCalc)";
67 const sal_Unicode CHAR_NBSP
= 0x00A0;
68 const sal_Unicode CHAR_SHY
= 0x00AD;
69 const sal_Unicode CHAR_ZWSP
= 0x200B;
70 const sal_Unicode CHAR_LRM
= 0x200E;
71 const sal_Unicode CHAR_RLM
= 0x200F;
72 const sal_Unicode CHAR_NBHY
= 0x2011;
73 const sal_Unicode CHAR_WJ
= 0x2060;
74 const sal_Unicode CHAR_NNBSP
= 0x202F; //NARROW NO-BREAK SPACE
76 #define MINDOUBLE 1.7e-307
77 #define MAXDOUBLE 1.7e307
79 const sal_uInt16 MINZOOM
= 20;
80 const sal_uInt16 MAXZOOM
= 400;
82 const SCSIZE MAXSUBTOTAL
= 3;
84 // ~105.88 twip, i.e. about 2 times narrower than o3tl::Length::ch, which is 210 twip
85 constexpr auto TWIPS_PER_CHAR
= o3tl::toTwips(1 / 13.6, o3tl::Length::in
);
87 constexpr sal_Int32 STD_COL_WIDTH
= o3tl::convert(64, o3tl::Length::pt
, o3tl::Length::twip
);
88 constexpr sal_Int32 STD_EXTRA_WIDTH
= o3tl::convert(2, o3tl::Length::mm
, o3tl::Length::twip
);
90 constexpr sal_Int32 MAX_EXTRA_WIDTH
= o3tl::convert(42, o3tl::Length::cm
, o3tl::Length::twip
);
91 constexpr sal_Int32 MAX_EXTRA_HEIGHT
= o3tl::convert(42, o3tl::Length::cm
, o3tl::Length::twip
);
92 constexpr sal_Int32 MAX_COL_WIDTH
= o3tl::convert(1, o3tl::Length::m
, o3tl::Length::twip
);
93 constexpr sal_Int32 MAX_ROW_HEIGHT
= o3tl::convert(1, o3tl::Length::m
, o3tl::Length::twip
);
95 /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
96 #define STD_ROWHEIGHT_DIFF 23
100 constexpr ::tools::Long
TwipsToEvenHMM( ::tools::Long nTwips
) { return o3tl::convert(nTwips
, 127, 144) * 2; }
103 // standard size as OLE server (cells)
104 #define OLE_STD_CELLS_X 4
105 #define OLE_STD_CELLS_Y 5
108 // repaint flags (for messages)
109 enum class PaintPartFlags
{
118 All
= Grid
| Top
| Left
| Extras
| Objects
| Size
,
121 template<> struct typed_flags
<PaintPartFlags
> : is_typed_flags
<PaintPartFlags
, 0x07f> {};
124 // flags for columns / rows
125 enum class CRFlags
: sal_uInt8
{
126 // Filtered always together with Hidden
127 // Filtered and ManualSize only valid for rows
133 All
= Hidden
| ManualBreak
| Filtered
| ManualSize
136 template<> struct typed_flags
<CRFlags
> : is_typed_flags
<CRFlags
, 0x0f> {};
139 enum class ScBreakType
{
145 template<> struct typed_flags
<ScBreakType
> : is_typed_flags
<ScBreakType
, 0x03> {};
148 enum class InsertDeleteFlags
: sal_uInt16
151 VALUE
= 0x0001, /// Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
152 DATETIME
= 0x0002, /// Dates, times, datetime values.
153 STRING
= 0x0004, /// Strings (and string results if InsertDeleteFlags::FORMULA is not set).
154 NOTE
= 0x0008, /// Cell notes.
155 FORMULA
= 0x0010, /// Formula cells.
156 HARDATTR
= 0x0020, /// Hard cell attributes.
157 STYLES
= 0x0040, /// Cell styles.
158 OBJECTS
= 0x0080, /// Drawing objects.
159 EDITATTR
= 0x0100, /// Rich-text attributes.
160 OUTLINE
= 0x0800, /// Sheet / outlining (grouping) information
161 SPARKLINES
= 0x4000, /// Sparklines in a cell.
162 NOCAPTIONS
= 0x0200, /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
163 ADDNOTES
= 0x0400, /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
164 SPECIAL_BOOLEAN
= 0x1000,
165 FORGETCAPTIONS
= 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes.
166 ATTRIB
= HARDATTR
| STYLES
,
167 CONTENTS
= VALUE
| DATETIME
| STRING
| NOTE
| FORMULA
| OUTLINE
| SPARKLINES
,
168 ALL
= CONTENTS
| ATTRIB
| OBJECTS
| SPARKLINES
,
169 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
170 AUTOFILL
= ALL
& ~(NOTE
| OBJECTS
)
174 template<> struct typed_flags
<InsertDeleteFlags
> : is_typed_flags
<InsertDeleteFlags
, 0x7fff> {};
176 // This doesn't work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work.
177 //static_assert((InsertDeleteFlags::ATTRIB & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE, "these must match");
180 enum class ScPasteFunc
{
181 NONE
, ADD
, SUB
, MUL
, DIV
184 enum class HasAttrFlags
{
192 ShadowRight
= 0x0040,
195 Conditional
= 0x0200,
197 NotOverlapped
= 0x0800,
198 RightOrCenter
= 0x1000, // right or centered logical alignment
201 template<> struct typed_flags
<HasAttrFlags
> : is_typed_flags
<HasAttrFlags
, 0x1fff> {};
205 // Layer id's for drawing.
206 // These are both id's and positions.
207 constexpr SdrLayerID
SC_LAYER_FRONT (0);
208 constexpr SdrLayerID
SC_LAYER_BACK (1);
209 constexpr SdrLayerID
SC_LAYER_INTERN (2);
210 constexpr SdrLayerID
SC_LAYER_CONTROLS(3);
211 constexpr SdrLayerID
SC_LAYER_HIDDEN (4);
214 enum class ScLinkMode
{
218 enum class ScEnterMode
{
219 NORMAL
, BLOCK
, MATRIX
222 // step = 10pt, max. indention = 100 steps
223 #define SC_INDENT_STEP 200
225 enum class ScScenarioFlags
{ // scenario flags
236 template<> struct typed_flags
<ScScenarioFlags
> : is_typed_flags
<ScScenarioFlags
, 127> {};
239 enum class SubtotalFlags
{
241 IgnoreNestedStAg
= 0x08,
244 IgnoreFiltered
= 0x01
247 template<> struct typed_flags
<SubtotalFlags
> : is_typed_flags
<SubtotalFlags
, 0x0f> {};
250 enum class ScCloneFlags
{
251 /** Default cell clone flags: do not start listening, do not adjust 3D refs to
252 old position, clone note captions of cell notes. */
255 /** If set, cloned formula cells will start to listen to the document. */
256 StartListening
= 0x0001,
258 /** If set, absolute refs will not transformed to external references */
259 NoMakeAbsExternal
= 0x0002,
261 /** If set, global named expressions will be converted to sheet-local named
263 NamesToLocal
= 0x0004
267 template<> struct typed_flags
<ScCloneFlags
> : is_typed_flags
<ScCloneFlags
, 0x0007> {};
279 enum class DelCellCmd
351 SC_SIZE_DIRECT
, // set size or hide if value is 0
352 SC_SIZE_OPTIMAL
, // set optimal size for everything
353 SC_SIZE_SHOW
, // show with original size
354 SC_SIZE_VISOPT
, // set optimal size only if visible
355 SC_SIZE_ORIGINAL
// only set size, don't change visible flag
361 SC_INPUT_TYPE
, // input, while not in inplace mode
362 SC_INPUT_TABLE
, // text cursor in the table
363 SC_INPUT_TOP
// text cursor in the input line
366 enum ScVObjMode
// output modes of objects on a page
372 enum ScAnchorType
// anchor of a character object
374 SCA_CELL
, // anchor to cell, move with cell
375 SCA_CELL_RESIZE
, // anchor to cell, move and resize with cell
376 SCA_PAGE
, // anchor to page, independent of any cells
377 SCA_DONTKNOW
// for multi selection
382 SC_DB_MAKE
, ///< create "untitled" (if necessary)
383 SC_DB_AUTOFILTER
, ///< force use of sheet-local instead of document global anonymous range
384 SC_DB_IMPORT
, ///< create "Importx" (if necessary)
385 SC_DB_OLD
///< don't create
388 /// For ScDBFunc::GetDBData()
389 enum class ScGetDBSelection
391 /** Keep selection as is, expand to used data area if no selection. */
394 /** Shrink selection to actually used data area within the selection. */
397 /** If only one row or portion thereof is selected, shrink row to used data
398 columns and select further rows down until end of data. If an area is
399 selected, shrink rows to actually used columns. Else, no selection,
400 expand to used data area. */
403 /** Behave as if the range corresponding to a ScDBData area was selected,
408 enum ScLkUpdMode
// modes for updating links
416 // enum with values equal to old DBObject enum from sdb
425 enum class ColRowEditAction
445 OUString aDBName
; // alias of data base
448 bool bSql
; // statement or name?
449 sal_uInt8 nType
; // enum DBObject
452 ScImportParam( const ScImportParam
& r
);
455 ScImportParam
& operator= ( const ScImportParam
& r
);
456 bool operator== ( const ScImportParam
& r
) const;
459 // Formula data replacement character for a pair of parentheses at end of
460 // function name, to force sorting parentheses before all other characters.
461 // Collation may treat parentheses differently.
462 constexpr sal_Unicode cParenthesesReplacement
= 0x0001;
463 struct InputHandlerFunctionNames
465 ScTypedCaseStrSet maFunctionData
;
466 ScTypedCaseStrSet maFunctionDataPara
;
467 std::set
<sal_Unicode
> maFunctionChar
;
473 class LegacyFuncCollection
;
474 class ScUnoAddInCollection
;
477 class ScFunctionList
;
480 class EditTextObject
;
481 class SfxObjectShell
;
482 class SvNumberFormatter
;
483 class ScUnitConverter
;
485 class LocaleDataWrapper
;
487 class CalendarWrapper
;
488 class CollatorWrapper
;
490 class ScFieldEditEngine
;
492 namespace com::sun::star
{
497 class XOrdinalSuffix
;
501 class TransliterationWrapper
;
505 class SharedStringPoolPurge
;
510 static std::unique_ptr
<SvxSearchItem
> xSearchItem
;
511 static std::unique_ptr
<ScAutoFormat
> xAutoFormat
;
512 static std::atomic
<LegacyFuncCollection
*> pLegacyFuncCollection
;
513 static std::atomic
<ScUnoAddInCollection
*> pAddInCollection
;
514 static std::unique_ptr
<ScUserList
> xUserList
;
515 static OUString aStrClipDocName
;
516 static std::unique_ptr
<SvxBrushItem
> xEmptyBrushItem
;
517 static std::unique_ptr
<SvxBrushItem
> xButtonBrushItem
;
519 static std::unique_ptr
<ScFunctionList
> xStarCalcFunctionList
;
520 static std::unique_ptr
<ScFunctionMgr
> xStarCalcFunctionMgr
;
522 static std::atomic
<ScUnitConverter
*> pUnitConverter
;
524 static std::unique_ptr
<SvNumberFormatter
> xEnglishFormatter
; // for UNO / XML export
526 static css::uno::Reference
< css::i18n::XOrdinalSuffix
> xOrdinalSuffix
;
527 static std::optional
<CalendarWrapper
> oCalendar
;
528 static std::atomic
<CollatorWrapper
*> pCaseCollator
;
529 static std::atomic
<CollatorWrapper
*> pCollator
;
530 static std::atomic
<::utl::TransliterationWrapper
*> pTransliteration
;
531 static std::atomic
<::utl::TransliterationWrapper
*> pCaseTransliteration
;
532 static std::atomic
<css::lang::Locale
*> pLocale
;
534 static std::unique_ptr
<ScFieldEditEngine
> xFieldEditEngine
;
536 static std::atomic
<sc::SharedStringPoolPurge
*> pSharedStringPoolPurge
;
538 static InputHandlerFunctionNames maInputHandlerFunctionNames
;
540 static void InitPPT();
543 static std::optional
<SvtSysLocale
> oSysLocale
;
544 SC_DLLPUBLIC
static const LocaleDataWrapper
& getLocaleData();
545 SC_DLLPUBLIC
static const CharClass
& getCharClass();
547 static CalendarWrapper
& GetCalendar();
548 /// case-insensitive collator
549 SC_DLLPUBLIC
static CollatorWrapper
& GetCollator();
550 /// case-sensitive collator
551 static CollatorWrapper
& GetCaseCollator();
552 static CollatorWrapper
& GetCollator(bool bCaseSensitive
);
553 static css::lang::Locale
& GetLocale();
555 SC_DLLPUBLIC
static ::utl::TransliterationWrapper
& GetTransliteration();
556 static ::utl::TransliterationWrapper
& GetCaseTransliteration();
557 static ::utl::TransliterationWrapper
& GetTransliteration(bool bCaseSensitive
);
559 SC_DLLPUBLIC
static LanguageType eLnge
;
560 static constexpr sal_Unicode cListDelimiter
= ',';
562 static const OUString
& GetClipDocName();
563 static void SetClipDocName( const OUString
& rNew
);
564 SC_DLLPUBLIC
static const SvxSearchItem
& GetSearchItem();
565 SC_DLLPUBLIC
static void SetSearchItem( const SvxSearchItem
& rNew
);
566 SC_DLLPUBLIC
static ScAutoFormat
* GetAutoFormat();
567 SC_DLLPUBLIC
static ScAutoFormat
* GetOrCreateAutoFormat();
568 static void ClearAutoFormat(); //BugId 54209
569 static LegacyFuncCollection
* GetLegacyFuncCollection();
570 SC_DLLPUBLIC
static ScUnoAddInCollection
* GetAddInCollection();
571 SC_DLLPUBLIC
static ScUserList
* GetUserList();
572 static void SetUserList( const ScUserList
* pNewList
);
574 * Open the specified URL.
575 * @param bIgnoreSettings - If true, ignore security settings (Ctrl-Click) and just open the URL.
577 static void OpenURL(const OUString
& rURL
, const OUString
& rTarget
, bool bIgnoreSettings
= false);
578 /// Whether the URL can be opened according to current security options (Click/Ctrl-Click)
579 static bool ShouldOpenURL();
580 SC_DLLPUBLIC
static OUString
GetAbsDocName( const OUString
& rFileName
,
581 const SfxObjectShell
* pShell
);
582 SC_DLLPUBLIC
static OUString
GetDocTabName( std::u16string_view rFileName
,
583 std::u16string_view rTabName
);
584 SC_DLLPUBLIC
static sal_uInt32
GetStandardFormat( SvNumberFormatter
&, sal_uInt32 nFormat
, SvNumFormatType nType
);
586 SC_DLLPUBLIC
static sal_uInt16
GetStandardRowHeight();
587 /// Horizontal pixel per twips factor.
588 SC_DLLPUBLIC
static double nScreenPPTX
;
589 /// Vertical pixel per twips factor.
590 SC_DLLPUBLIC
static double nScreenPPTY
;
592 static tools::SvRef
<ScDocShell
> xDrawClipDocShellRef
;
594 static sal_uInt16 nDefFontHeight
;
595 SC_DLLPUBLIC
static sal_uInt16 nStdRowHeight
;
597 SC_DLLPUBLIC
static ::tools::Long nLastRowHeightExtra
;
598 static ::tools::Long nLastColWidthExtra
;
600 SC_DLLPUBLIC
static void Init(); // during start up
601 static void InitAddIns();
602 SC_DLLPUBLIC
static void Clear(); // at the end of the program
604 static void InitTextHeight(const SfxItemPool
* pPool
);
605 static SvxBrushItem
* GetEmptyBrushItem() { return xEmptyBrushItem
.get(); }
606 static SvxBrushItem
* GetButtonBrushItem();
608 static bool HasStarCalcFunctionList();
609 static ScFunctionList
* GetStarCalcFunctionList();
610 static ScFunctionMgr
* GetStarCalcFunctionMgr();
611 static void ResetFunctionList();
612 static const InputHandlerFunctionNames
& GetInputHandlerFunctionNames();
614 static OUString
GetErrorString(FormulaError nErrNumber
);
615 static OUString
GetLongErrorString(FormulaError nErrNumber
);
616 static bool EETextObjEqual( const EditTextObject
* pObj1
,
617 const EditTextObject
* pObj2
);
618 static bool CheckWidthInvalidate( bool& bNumFormatChanged
,
619 const SfxItemSet
& rNewAttrs
,
620 const SfxItemSet
& rOldAttrs
);
621 static bool HasAttrChanged( const SfxItemSet
& rNewAttrs
,
622 const SfxItemSet
& rOldAttrs
,
623 const sal_uInt16 nWhich
);
625 static ScUnitConverter
* GetUnitConverter();
627 /// strchr() functionality on unicode, as long as we need it for FormulaToken etc.
628 static const sal_Unicode
* UnicodeStrChr( const sal_Unicode
* pStr
, sal_Unicode c
);
630 static sal_Unicode
ToUpperAlpha( sal_Unicode c
)
631 { return ( c
>= 'a' && c
<= 'z' ) ? ( c
-'a'+'A' ) : c
; }
633 /** Adds the string rToken to rTokenList, using a list separator character.
634 @param rTokenList The string list where the token will be appended to.
635 @param rToken The token string to append to the token list.
636 @param cSep The character to separate the tokens.
637 @param nSepCount Specifies how often cSep is inserted between two tokens.
638 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
639 SC_DLLPUBLIC
static OUString
addToken(
640 std::u16string_view rTokenList
, std::u16string_view rToken
,
641 sal_Unicode cSep
, sal_Int32 nSepCount
= 1,
642 bool bForceSep
= false );
644 /** Returns true, if the first and last character of the string is cQuote. */
645 SC_DLLPUBLIC
static bool IsQuoted( std::u16string_view rString
, sal_Unicode cQuote
);
647 /** Inserts the character cQuote at beginning and end of rString.
648 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
649 escaped by doubling them.
651 SC_DLLPUBLIC
static void AddQuotes( OUString
& rString
, sal_Unicode cQuote
, bool bEscapeEmbedded
= true );
653 /** Erases the character cQuote from rString, if it exists at beginning AND end.
654 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
655 are unescaped by replacing them with a
658 SC_DLLPUBLIC
static void EraseQuotes( OUString
& rString
, sal_Unicode cQuote
, bool bUnescapeEmbedded
= true );
660 /** Finds an unquoted instance of cChar in rString, starting at
661 offset nStart. Unquoted instances may occur when concatenating two
662 quoted strings with a separator, for example, 's1':'s2'. Embedded
663 quotes have to be escaped by being doubled. Caller must ensure that
664 nStart points into an unquoted range or the opening quote. Specialty:
665 if cChar=='\'' the first quote character from nStart on is found.
666 @returns offset if found, else -1
668 SC_DLLPUBLIC
static sal_Int32
FindUnquoted( const OUString
& rString
, sal_Unicode cChar
, sal_Int32 nStart
= 0 );
670 /** Finds an unquoted instance of cChar in null-terminated pString. Same
671 semantics as FindUnquoted( const String&, ...)
672 @returns: pointer to cChar if found, else NULL
674 SC_DLLPUBLIC
static const sal_Unicode
* FindUnquoted( const sal_Unicode
* pString
, sal_Unicode cChar
);
676 static rtl_TextEncoding
GetCharsetValue( std::u16string_view rCharSet
);
677 static OUString
GetCharsetString( rtl_TextEncoding eVal
);
679 /// a "ReadOnly" formatter for UNO/XML export
680 static SvNumberFormatter
* GetEnglishFormatter();
682 static bool IsSystemRTL(); // depending on system language
683 static LanguageType
GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
684 SC_DLLPUBLIC
static SvtScriptType
GetDefaultScriptType(); // for all WEAK characters
685 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
686 If more than one SvtScriptType::... values are or'ed together, prefers
687 first COMPLEX, then ASIAN */
688 SC_DLLPUBLIC
static sal_uInt16
GetScriptedWhichID( SvtScriptType nScriptType
, sal_uInt16 nWhich
);
690 /** Adds a language item to the item set, if the number format item contains
691 a language that differs from its parent's language. */
692 SC_DLLPUBLIC
static void AddLanguage( SfxItemSet
& rSet
, const SvNumberFormatter
& rFormatter
);
694 /** Obtain the ordinal suffix for a number according to the system locale */
695 static OUString
GetOrdinalSuffix( sal_Int32 nNumber
);
697 /** A static instance of ScFieldEditEngine not capable of resolving
698 document specific fields, to be used only by ScEditUtil::GetString(). */
699 static ScFieldEditEngine
& GetStaticFieldEditEngine();
701 static sc::SharedStringPoolPurge
& GetSharedStringPoolPurge();
703 /** Replaces the first occurrence of rPlaceholder in rString with
704 rReplacement, or if rPlaceholder is not found appends one space if
705 rString does not end in a space and appends rReplacement.
707 Meant to be used with resource strings ala "Column %1" where a
708 translation may have omitted the %1 placeholder and a simple
709 replacement would end up with nothing replaced so no column indicator
710 in the result string.
712 SC_DLLPUBLIC
static OUString
ReplaceOrAppend( const OUString
& rString
,
713 std::u16string_view rPlaceholder
,
714 const OUString
& rReplacement
);
717 /** Convert string content to numeric value.
719 In any case, if rError is set 0.0 is returned.
721 If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally
722 assigned to rError and 0.0 is returned. The caller is expected to
723 handle this situation. Used by the interpreter.
725 Usually FormulaError::NoValue is passed as nStringNoValueError.
727 Otherwise, depending on the string conversion configuration different
728 approaches are taken:
731 For ScCalcConfig::StringConversion::ILLEGAL
732 The error value passed in nStringNoValueError is assigned to rError
736 For ScCalcConfig::StringConversion::ZERO
737 A zero value is returned and no error assigned.
740 For ScCalcConfig::StringConversion::LOCALE
742 If the string is empty or consists only of spaces, if "treat empty
743 string as zero" is set 0.0 is returned, else nStringNoValueError
744 assigned to rError (and 0.0 returned).
746 Else a non-empty string is passed to the number formatter's scanner to
747 be parsed locale dependent. If that does not detect a numeric value
748 nStringNoValueError is assigned to rError (and 0.0 returned).
750 If no number formatter was passed, the conversion falls back to
754 For ScCalcConfig::StringConversion::UNAMBIGUOUS
756 If the string is empty or consists only of spaces, if "treat empty
757 string as zero" is set 0.0 is returned, else nStringNoValueError
758 assigned to rError (and 0.0 returned).
760 If the string is not empty the following conversion rules are applied:
762 Converted are only integer numbers including exponent, and ISO 8601 dates
763 and times in their extended formats with separators. Anything else,
764 especially fractional numeric values with decimal separators or dates other
765 than ISO 8601 would be locale dependent and is a no-no. Leading and
766 trailing blanks are ignored.
768 The following ISO 8601 formats are converted:
773 CCYY-MM-DDThh:mm:ss,s
774 CCYY-MM-DDThh:mm:ss.s
780 The century CC may not be omitted and the two-digit year setting is not
781 taken into account. Instead of the T date and time separator exactly one
784 If a date is given, it must be a valid Gregorian calendar date. In this
785 case the optional time must be in the range 00:00 to 23:59:59.99999...
786 If only time is given, it may have any value for hours, taking elapsed time
787 into account; minutes and seconds are limited to the value 59 as well.
789 If the string can not be converted to a numeric value, the error value
790 passed in nStringNoValueError is assigned to rError.
794 The string to be converted.
797 The calculation configuration.
800 Contains the error on return, if any. If an error was set before
801 and the conversion did not result in an error, still 0.0 is
804 @param nStringNoValueError
805 The error value to be assigned to rError if string could not be
809 The number formatter to use in case of
810 ScCalcConfig::StringConversion::LOCALE. Can but should not be
811 nullptr in which case conversion falls back to
812 ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is
813 detected the null date is assumed to be the standard 1899-12-30
814 instead of the configured null date.
817 Can be assigned a format type in case a date or time or date+time
818 string was converted, e.g. SvNumFormatType::DATE or
819 SvNumFormatType::TIME or a combination thereof.
822 static double ConvertStringToValue( const OUString
& rStr
, const ScCalcConfig
& rConfig
,
823 FormulaError
& rError
, FormulaError nStringNoValueError
,
824 SvNumberFormatter
* pFormatter
, SvNumFormatType
& rCurFmtType
);
826 /// Calc's threaded group calculation is in progress.
827 SC_DLLPUBLIC
static bool bThreadedGroupCalcInProgress
;
830 // maybe move to dbdata.hxx (?):
847 SC_DOES_NOT_BEGIN_WITH
,
860 SUBTOTAL_FUNC_NONE
= 0,
861 SUBTOTAL_FUNC_AVE
= 1,
862 SUBTOTAL_FUNC_CNT
= 2,
863 SUBTOTAL_FUNC_CNT2
= 3,
864 SUBTOTAL_FUNC_MAX
= 4,
865 SUBTOTAL_FUNC_MIN
= 5,
866 SUBTOTAL_FUNC_PROD
= 6,
867 SUBTOTAL_FUNC_STD
= 7,
868 SUBTOTAL_FUNC_STDP
= 8,
869 SUBTOTAL_FUNC_SUM
= 9,
870 SUBTOTAL_FUNC_VAR
= 10,
871 SUBTOTAL_FUNC_VARP
= 11,
872 SUBTOTAL_FUNC_MED
= 12,
873 SUBTOTAL_FUNC_SELECTION_COUNT
= 13
878 AGGREGATE_FUNC_AVE
= 1,
879 AGGREGATE_FUNC_CNT
= 2,
880 AGGREGATE_FUNC_CNT2
= 3,
881 AGGREGATE_FUNC_MAX
= 4,
882 AGGREGATE_FUNC_MIN
= 5,
883 AGGREGATE_FUNC_PROD
= 6,
884 AGGREGATE_FUNC_STD
= 7,
885 AGGREGATE_FUNC_STDP
= 8,
886 AGGREGATE_FUNC_SUM
= 9,
887 AGGREGATE_FUNC_VAR
= 10,
888 AGGREGATE_FUNC_VARP
= 11,
889 AGGREGATE_FUNC_MEDIAN
= 12,
890 AGGREGATE_FUNC_MODSNGL
= 13,
891 AGGREGATE_FUNC_LARGE
= 14,
892 AGGREGATE_FUNC_SMALL
= 15,
893 AGGREGATE_FUNC_PERCINC
= 16,
894 AGGREGATE_FUNC_QRTINC
= 17,
895 AGGREGATE_FUNC_PERCEXC
= 18,
896 AGGREGATE_FUNC_QRTEXC
= 19
901 struct ScConsolidateParam
903 SCCOL nCol
; // cursor position /
904 SCROW nRow
; // or start of destination area respectively
906 ScSubTotalFunc eFunction
;
907 sal_uInt16 nDataAreaCount
; // number of data areas
908 std::unique_ptr
<ScArea
[]> pDataAreas
; // array of pointers into data areas
911 bool bReferenceData
; // reference source data
913 ScConsolidateParam();
914 ScConsolidateParam( const ScConsolidateParam
& r
);
915 ~ScConsolidateParam();
917 ScConsolidateParam
& operator= ( const ScConsolidateParam
& r
);
918 bool operator== ( const ScConsolidateParam
& r
) const;
919 void Clear (); // = ClearDataAreas()+Members
920 void ClearDataAreas ();
921 void SetAreas ( std::unique_ptr
<ScArea
[]> pAreas
, sal_uInt16 nCount
);
924 extern SfxViewShell
* pScActiveViewShell
;
925 extern sal_uInt16 nScClickMouseModifier
;
926 extern sal_uInt16 nScFillModeMouseModifier
;
928 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */