LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / global.hxx
blobdcc24c0d042fcfb918ef4c9b45ac647936960105
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include "address.hxx"
23 #include <i18nlangtag/lang.h>
24 #include <svx/svdtypes.hxx>
25 #include <tools/ref.hxx>
26 #include <sal/types.h>
27 #include <com/sun/star/i18n/CollatorOptions.hpp>
28 #include "scdllapi.h"
29 #include <rtl/ustring.hxx>
30 #include <tools/long.hxx>
31 #include <o3tl/unit_conversion.hxx>
33 #include <atomic>
34 // HACK: <atomic> includes <stdbool.h>, which in some Clang versions does '#define bool bool',
35 // which confuses clang plugins.
36 #undef bool
38 #include <memory>
39 #include <optional>
40 #include <string_view>
42 namespace com::sun::star::uno { template <typename > class Reference; }
44 class SfxItemSet;
45 class SfxViewShell;
46 struct ScCalcConfig;
47 enum class SvtScriptType;
48 enum class FormulaError : sal_uInt16;
49 enum class SvNumFormatType : sal_Int16;
51 #define SC_COLLATOR_IGNORES css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE
53 // Calc has lots of names...
54 // Clipboard names are in so3/soapp.hxx now
55 // STRING_SCAPP was "scalc3", "scalc4", now just "scalc"
57 #define STRING_SCAPP "scalc"
59 #define STRING_STANDARD "Standard"
61 // Have the dreaded programmatic filter name defined in one place.
62 #define SC_TEXT_CSV_FILTER_NAME "Text - txt - csv (StarCalc)"
64 // characters
66 const sal_Unicode CHAR_NBSP = 0x00A0;
67 const sal_Unicode CHAR_SHY = 0x00AD;
68 const sal_Unicode CHAR_ZWSP = 0x200B;
69 const sal_Unicode CHAR_LRM = 0x200E;
70 const sal_Unicode CHAR_RLM = 0x200F;
71 const sal_Unicode CHAR_NBHY = 0x2011;
72 const sal_Unicode CHAR_WJ = 0x2060;
73 const sal_Unicode CHAR_NNBSP = 0x202F; //NARROW NO-BREAK SPACE
75 #define MINDOUBLE 1.7e-307
76 #define MAXDOUBLE 1.7e307
78 #define MINZOOM 20
79 #define MAXZOOM 400
81 const SCSIZE MAXSUBTOTAL = 3;
83 // ~105.88 twip, i.e. about 2 times narrower than o3tl::Length::ch, which is 210 twip
84 constexpr auto TWIPS_PER_CHAR = o3tl::toTwips(1 / 13.6, o3tl::Length::in);
86 constexpr sal_Int32 STD_COL_WIDTH = o3tl::convert(64, o3tl::Length::pt, o3tl::Length::twip);
87 constexpr sal_Int32 STD_EXTRA_WIDTH = o3tl::convert(2, o3tl::Length::mm, o3tl::Length::twip);
89 constexpr sal_Int32 MAX_EXTRA_WIDTH = o3tl::convert(42, o3tl::Length::cm, o3tl::Length::twip);
90 constexpr sal_Int32 MAX_EXTRA_HEIGHT = o3tl::convert(42, o3tl::Length::cm, o3tl::Length::twip);
91 constexpr sal_Int32 MAX_COL_WIDTH = o3tl::convert(1, o3tl::Length::m, o3tl::Length::twip);
92 constexpr sal_Int32 MAX_ROW_HEIGHT = o3tl::convert(1, o3tl::Length::m, o3tl::Length::twip);
94 /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
95 #define STD_ROWHEIGHT_DIFF 23
97 namespace sc
99 constexpr ::tools::Long TwipsToEvenHMM( ::tools::Long nTwips ) { return o3tl::convert(nTwips, 127, 144) * 2; }
102 // standard size as OLE server (cells)
103 #define OLE_STD_CELLS_X 4
104 #define OLE_STD_CELLS_Y 5
107 // repaint flags (for messages)
108 enum class PaintPartFlags {
109 NONE = 0x00,
110 Grid = 0x01,
111 Top = 0x02,
112 Left = 0x04,
113 Extras = 0x08,
114 Marks = 0x10,
115 Objects = 0x20,
116 Size = 0x40,
117 All = Grid | Top | Left | Extras | Objects | Size,
119 namespace o3tl {
120 template<> struct typed_flags<PaintPartFlags> : is_typed_flags<PaintPartFlags, 0x07f> {};
123 // flags for columns / rows
124 enum class CRFlags : sal_uInt8 {
125 // Filtered always together with Hidden
126 // Filtered and ManualSize only valid for rows
127 NONE = 0x00,
128 Hidden = 0x01,
129 ManualBreak = 0x02,
130 Filtered = 0x04,
131 ManualSize = 0x08,
132 All = Hidden | ManualBreak | Filtered | ManualSize
134 namespace o3tl {
135 template<> struct typed_flags<CRFlags> : is_typed_flags<CRFlags, 0x0f> {};
138 enum class ScBreakType {
139 NONE = 0x00,
140 Page = 0x01,
141 Manual = 0x02
143 namespace o3tl {
144 template<> struct typed_flags<ScBreakType> : is_typed_flags<ScBreakType, 0x03> {};
147 enum class InsertDeleteFlags : sal_uInt16
149 NONE = 0x0000,
150 VALUE = 0x0001, /// Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
151 DATETIME = 0x0002, /// Dates, times, datetime values.
152 STRING = 0x0004, /// Strings (and string results if InsertDeleteFlags::FORMULA is not set).
153 NOTE = 0x0008, /// Cell notes.
154 FORMULA = 0x0010, /// Formula cells.
155 HARDATTR = 0x0020, /// Hard cell attributes.
156 STYLES = 0x0040, /// Cell styles.
157 OBJECTS = 0x0080, /// Drawing objects.
158 EDITATTR = 0x0100, /// Rich-text attributes.
159 OUTLINE = 0x0800, /// Sheet / outlining (grouping) information
160 SPARKLINES = 0x4000, /// Sparklines in a cell.
161 NOCAPTIONS = 0x0200, /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
162 ADDNOTES = 0x0400, /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
163 SPECIAL_BOOLEAN = 0x1000,
164 FORGETCAPTIONS = 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes.
165 ATTRIB = HARDATTR | STYLES,
166 CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE | SPARKLINES,
167 ALL = CONTENTS | ATTRIB | OBJECTS | SPARKLINES,
168 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
169 AUTOFILL = ALL & ~(NOTE | OBJECTS)
171 namespace o3tl
173 template<> struct typed_flags<InsertDeleteFlags> : is_typed_flags<InsertDeleteFlags, 0x7fff> {};
175 // This doesn't work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work.
176 //static_assert((InsertDeleteFlags::ATTRIB & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE, "these must match");
179 enum class ScPasteFunc {
180 NONE, ADD, SUB, MUL, DIV
182 // bits for HasAttr
183 enum class HasAttrFlags {
184 NONE = 0x0000,
185 Lines = 0x0001,
186 Merged = 0x0002,
187 Overlapped = 0x0004,
188 Protected = 0x0008,
189 Shadow = 0x0010,
190 NeedHeight = 0x0020,
191 ShadowRight = 0x0040,
192 ShadowDown = 0x0080,
193 AutoFilter = 0x0100,
194 Conditional = 0x0200,
195 Rotate = 0x0400,
196 NotOverlapped = 0x0800,
197 RightOrCenter = 0x1000, // right or centered logical alignment
199 namespace o3tl {
200 template<> struct typed_flags<HasAttrFlags> : is_typed_flags<HasAttrFlags, 0x1fff> {};
204 // Layer id's for drawing.
205 // These are both id's and positions.
206 constexpr SdrLayerID SC_LAYER_FRONT (0);
207 constexpr SdrLayerID SC_LAYER_BACK (1);
208 constexpr SdrLayerID SC_LAYER_INTERN (2);
209 constexpr SdrLayerID SC_LAYER_CONTROLS(3);
210 constexpr SdrLayerID SC_LAYER_HIDDEN (4);
212 // link tables
213 enum class ScLinkMode {
214 NONE, NORMAL, VALUE
216 // input
217 enum class ScEnterMode {
218 NORMAL, BLOCK, MATRIX
221 // step = 10pt, max. indention = 100 steps
222 #define SC_INDENT_STEP 200
224 enum class ScScenarioFlags{ // scenario flags
225 NONE = 0,
226 CopyAll = 1,
227 ShowFrame = 2,
228 PrintFrame = 4,
229 TwoWay = 8,
230 Attrib = 16,
231 Value = 32,
232 Protected = 64
234 namespace o3tl {
235 template<> struct typed_flags<ScScenarioFlags> : is_typed_flags<ScScenarioFlags, 127> {};
238 enum class SubtotalFlags {
239 NONE = 0x00,
240 IgnoreNestedStAg = 0x08,
241 IgnoreErrVal = 0x04,
242 IgnoreHidden = 0x02,
243 IgnoreFiltered = 0x01
245 namespace o3tl {
246 template<> struct typed_flags<SubtotalFlags> : is_typed_flags<SubtotalFlags, 0x0f> {};
249 enum class ScCloneFlags{
250 /** Default cell clone flags: do not start listening, do not adjust 3D refs to
251 old position, clone note captions of cell notes. */
252 Default = 0x0000,
254 /** If set, cloned formula cells will start to listen to the document. */
255 StartListening = 0x0001,
257 /** If set, absolute refs will not transformed to external references */
258 NoMakeAbsExternal = 0x0002,
260 /** If set, global named expressions will be converted to sheet-local named
261 expressions. */
262 NamesToLocal = 0x0004
264 namespace o3tl
266 template<> struct typed_flags<ScCloneFlags> : is_typed_flags<ScCloneFlags, 0x0007> {};
269 enum CellType
271 CELLTYPE_NONE,
272 CELLTYPE_VALUE,
273 CELLTYPE_STRING,
274 CELLTYPE_FORMULA,
275 CELLTYPE_EDIT,
278 enum class DelCellCmd
280 CellsUp,
281 CellsLeft,
282 Rows,
283 Cols,
284 NONE
287 enum InsCellCmd
289 INS_CELLSDOWN,
290 INS_CELLSRIGHT,
291 INS_INSROWS_BEFORE,
292 INS_INSCOLS_BEFORE,
293 INS_NONE,
294 INS_INSROWS_AFTER,
295 INS_INSCOLS_AFTER
298 enum UpdateRefMode
300 URM_INSDEL,
301 URM_COPY,
302 URM_MOVE,
303 URM_REORDER
306 enum FillDir
308 FILL_TO_BOTTOM,
309 FILL_TO_RIGHT,
310 FILL_TO_TOP,
311 FILL_TO_LEFT
314 enum FillCmd
316 FILL_SIMPLE,
317 FILL_LINEAR,
318 FILL_GROWTH,
319 FILL_DATE,
320 FILL_AUTO
323 enum ScMoveDirection
325 SC_MOVE_RIGHT,
326 SC_MOVE_LEFT,
327 SC_MOVE_UP,
328 SC_MOVE_DOWN
331 enum FillDateCmd
333 FILL_DAY,
334 FILL_WEEKDAY,
335 FILL_MONTH,
336 FILL_END_OF_MONTH,
337 FILL_YEAR
340 enum ScDirection
342 DIR_BOTTOM,
343 DIR_RIGHT,
344 DIR_TOP,
345 DIR_LEFT
348 enum ScSizeMode
350 SC_SIZE_DIRECT, // set size or hide if value is 0
351 SC_SIZE_OPTIMAL, // set optimal size for everything
352 SC_SIZE_SHOW, // show with original size
353 SC_SIZE_VISOPT, // set optimal size only if visible
354 SC_SIZE_ORIGINAL // only set size, don't change visible flag
357 enum ScInputMode
359 SC_INPUT_NONE,
360 SC_INPUT_TYPE, // input, while not in inplace mode
361 SC_INPUT_TABLE, // text cursor in the table
362 SC_INPUT_TOP // text cursor in the input line
365 enum ScVObjMode // output modes of objects on a page
367 VOBJ_MODE_SHOW,
368 VOBJ_MODE_HIDE
371 enum ScAnchorType // anchor of a character object
373 SCA_CELL, // anchor to cell, move with cell
374 SCA_CELL_RESIZE, // anchor to cell, move and resize with cell
375 SCA_PAGE, // anchor to page, independent of any cells
376 SCA_DONTKNOW // for multi selection
379 enum ScGetDBMode
381 SC_DB_MAKE, ///< create "untitled" (if necessary)
382 SC_DB_AUTOFILTER, ///< force use of sheet-local instead of document global anonymous range
383 SC_DB_IMPORT, ///< create "Importx" (if necessary)
384 SC_DB_OLD ///< don't create
387 /// For ScDBFunc::GetDBData()
388 enum class ScGetDBSelection
390 /** Keep selection as is, expand to used data area if no selection. */
391 Keep,
393 /** Shrink selection to actually used data area within the selection. */
394 ShrinkToUsedData,
396 /** If only one row or portion thereof is selected, shrink row to used data
397 columns and select further rows down until end of data. If an area is
398 selected, shrink rows to actually used columns. Else, no selection,
399 expand to used data area. */
400 RowDown,
402 /** Behave as if the range corresponding to a ScDBData area was selected,
403 for API use. */
404 ForceMark
407 enum ScLkUpdMode // modes for updating links
409 LM_ALWAYS,
410 LM_NEVER,
411 LM_ON_DEMAND,
412 LM_UNKNOWN
415 // enum with values equal to old DBObject enum from sdb
416 enum ScDBObject
418 ScDbTable,
419 ScDbQuery
422 namespace sc {
424 enum class ColRowEditAction
426 Unknown,
427 InsertColumnsBefore,
428 InsertColumnsAfter,
429 InsertRowsBefore,
430 InsertRowsAfter,
431 DeleteColumns,
432 DeleteRows
437 struct ScImportParam
439 SCCOL nCol1;
440 SCROW nRow1;
441 SCCOL nCol2;
442 SCROW nRow2;
443 bool bImport;
444 OUString aDBName; // alias of data base
445 OUString aStatement;
446 bool bNative;
447 bool bSql; // statement or name?
448 sal_uInt8 nType; // enum DBObject
450 ScImportParam();
451 ScImportParam( const ScImportParam& r );
452 ~ScImportParam();
454 ScImportParam& operator= ( const ScImportParam& r );
455 bool operator== ( const ScImportParam& r ) const;
458 class ScDocShell;
459 class SvxSearchItem;
460 class ScAutoFormat;
461 class LegacyFuncCollection;
462 class ScUnoAddInCollection;
463 class ScUserList;
464 class SvxBrushItem;
465 class ScFunctionList;
466 class ScFunctionMgr;
467 class SfxItemPool;
468 class EditTextObject;
469 class SfxObjectShell;
470 class SvNumberFormatter;
471 class ScUnitConverter;
472 class CharClass;
473 class LocaleDataWrapper;
474 class SvtSysLocale;
475 class CalendarWrapper;
476 class CollatorWrapper;
477 class IntlWrapper;
478 class ScFieldEditEngine;
480 namespace com::sun::star {
481 namespace lang {
482 struct Locale;
484 namespace i18n {
485 class XOrdinalSuffix;
488 namespace utl {
489 class TransliterationWrapper;
492 class ScGlobal
494 static std::unique_ptr<SvxSearchItem> xSearchItem;
495 static std::unique_ptr<ScAutoFormat> xAutoFormat;
496 static std::atomic<LegacyFuncCollection*> pLegacyFuncCollection;
497 static std::atomic<ScUnoAddInCollection*> pAddInCollection;
498 static std::unique_ptr<ScUserList> xUserList;
499 static OUString aStrClipDocName;
500 static std::unique_ptr<SvxBrushItem> xEmptyBrushItem;
501 static std::unique_ptr<SvxBrushItem> xButtonBrushItem;
503 static std::unique_ptr<ScFunctionList> xStarCalcFunctionList;
504 static std::unique_ptr<ScFunctionMgr> xStarCalcFunctionMgr;
506 static std::atomic<ScUnitConverter*> pUnitConverter;
508 static std::unique_ptr<SvNumberFormatter> xEnglishFormatter; // for UNO / XML export
510 static css::uno::Reference< css::i18n::XOrdinalSuffix> xOrdinalSuffix;
511 static std::optional<CalendarWrapper> oCalendar;
512 static std::atomic<CollatorWrapper*> pCaseCollator;
513 static std::atomic<CollatorWrapper*> pCollator;
514 static std::atomic<::utl::TransliterationWrapper*> pTransliteration;
515 static std::atomic<::utl::TransliterationWrapper*> pCaseTransliteration;
516 static std::atomic<css::lang::Locale*> pLocale;
518 static std::unique_ptr<ScFieldEditEngine> xFieldEditEngine;
520 static void InitPPT();
522 public:
523 static std::optional<SvtSysLocale> oSysLocale;
524 SC_DLLPUBLIC static const LocaleDataWrapper& getLocaleData();
525 SC_DLLPUBLIC static const CharClass& getCharClass();
527 static CalendarWrapper& GetCalendar();
528 /// case-insensitive collator
529 SC_DLLPUBLIC static CollatorWrapper& GetCollator();
530 /// case-sensitive collator
531 static CollatorWrapper& GetCaseCollator();
532 static CollatorWrapper& GetCollator(bool bCaseSensitive);
533 static css::lang::Locale& GetLocale();
535 SC_DLLPUBLIC static ::utl::TransliterationWrapper& GetTransliteration();
536 static ::utl::TransliterationWrapper& GetCaseTransliteration();
537 static ::utl::TransliterationWrapper& GetTransliteration(bool bCaseSensitive);
539 SC_DLLPUBLIC static LanguageType eLnge;
540 static constexpr sal_Unicode cListDelimiter = ',';
542 static const OUString& GetClipDocName();
543 static void SetClipDocName( const OUString& rNew );
544 SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem();
545 SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew );
546 SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat();
547 SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat();
548 static void ClearAutoFormat(); //BugId 54209
549 static LegacyFuncCollection* GetLegacyFuncCollection();
550 SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
551 SC_DLLPUBLIC static ScUserList* GetUserList();
552 static void SetUserList( const ScUserList* pNewList );
554 * Open the specified URL.
555 * @param bIgnoreSettings - If true, ignore security settings (Ctrl-Click) and just open the URL.
557 static void OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgnoreSettings = false);
558 /// Whether the URL can be opened according to current security options (Click/Ctrl-Click)
559 static bool ShouldOpenURL();
560 SC_DLLPUBLIC static OUString GetAbsDocName( const OUString& rFileName,
561 const SfxObjectShell* pShell );
562 SC_DLLPUBLIC static OUString GetDocTabName( std::u16string_view rFileName,
563 std::u16string_view rTabName );
564 SC_DLLPUBLIC static sal_uInt32 GetStandardFormat( SvNumberFormatter&, sal_uInt32 nFormat, SvNumFormatType nType );
566 SC_DLLPUBLIC static sal_uInt16 GetStandardRowHeight();
567 /// Horizontal pixel per twips factor.
568 SC_DLLPUBLIC static double nScreenPPTX;
569 /// Vertical pixel per twips factor.
570 SC_DLLPUBLIC static double nScreenPPTY;
572 static tools::SvRef<ScDocShell> xDrawClipDocShellRef;
574 static sal_uInt16 nDefFontHeight;
575 SC_DLLPUBLIC static sal_uInt16 nStdRowHeight;
577 SC_DLLPUBLIC static ::tools::Long nLastRowHeightExtra;
578 static ::tools::Long nLastColWidthExtra;
580 SC_DLLPUBLIC static void Init(); // during start up
581 static void InitAddIns();
582 SC_DLLPUBLIC static void Clear(); // at the end of the program
584 static void InitTextHeight(const SfxItemPool* pPool);
585 static SvxBrushItem* GetEmptyBrushItem() { return xEmptyBrushItem.get(); }
586 static SvxBrushItem* GetButtonBrushItem();
588 static bool HasStarCalcFunctionList();
589 static ScFunctionList* GetStarCalcFunctionList();
590 static ScFunctionMgr* GetStarCalcFunctionMgr();
591 static void ResetFunctionList();
593 static OUString GetErrorString(FormulaError nErrNumber);
594 static OUString GetLongErrorString(FormulaError nErrNumber);
595 static bool EETextObjEqual( const EditTextObject* pObj1,
596 const EditTextObject* pObj2 );
597 static bool CheckWidthInvalidate( bool& bNumFormatChanged,
598 const SfxItemSet& rNewAttrs,
599 const SfxItemSet& rOldAttrs );
600 static bool HasAttrChanged( const SfxItemSet& rNewAttrs,
601 const SfxItemSet& rOldAttrs,
602 const sal_uInt16 nWhich );
604 static ScUnitConverter* GetUnitConverter();
606 /// strchr() functionality on unicode, as long as we need it for FormulaToken etc.
607 static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
609 static sal_Unicode ToUpperAlpha( sal_Unicode c )
610 { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
612 /** Adds the string rToken to rTokenList, using a list separator character.
613 @param rTokenList The string list where the token will be appended to.
614 @param rToken The token string to append to the token list.
615 @param cSep The character to separate the tokens.
616 @param nSepCount Specifies how often cSep is inserted between two tokens.
617 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
618 SC_DLLPUBLIC static OUString addToken(
619 std::u16string_view rTokenList, std::u16string_view rToken,
620 sal_Unicode cSep, sal_Int32 nSepCount = 1,
621 bool bForceSep = false );
623 /** Returns true, if the first and last character of the string is cQuote. */
624 SC_DLLPUBLIC static bool IsQuoted( const OUString& rString, sal_Unicode cQuote );
626 /** Inserts the character cQuote at beginning and end of rString.
627 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
628 escaped by doubling them.
630 SC_DLLPUBLIC static void AddQuotes( OUString& rString, sal_Unicode cQuote, bool bEscapeEmbedded = true );
632 /** Erases the character cQuote from rString, if it exists at beginning AND end.
633 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
634 are unescaped by replacing them with a
635 single instance.
637 SC_DLLPUBLIC static void EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescapeEmbedded = true );
639 /** Finds an unquoted instance of cChar in rString, starting at
640 offset nStart. Unquoted instances may occur when concatenating two
641 quoted strings with a separator, for example, 's1':'s2'. Embedded
642 quotes have to be escaped by being doubled. Caller must ensure that
643 nStart points into an unquoted range or the opening quote. Specialty:
644 if cChar=='\'' the first quote character from nStart on is found.
645 @returns offset if found, else -1
647 SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar, sal_Int32 nStart = 0 );
649 /** Finds an unquoted instance of cChar in null-terminated pString. Same
650 semantics as FindUnquoted( const String&, ...)
651 @returns: pointer to cChar if found, else NULL
653 SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar );
655 static rtl_TextEncoding GetCharsetValue( const OUString& rCharSet );
656 static OUString GetCharsetString( rtl_TextEncoding eVal );
658 /// a "ReadOnly" formatter for UNO/XML export
659 static SvNumberFormatter* GetEnglishFormatter();
661 static bool IsSystemRTL(); // depending on system language
662 static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
663 SC_DLLPUBLIC static SvtScriptType GetDefaultScriptType(); // for all WEAK characters
664 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
665 If more than one SvtScriptType::... values are or'ed together, prefers
666 first COMPLEX, then ASIAN */
667 SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( SvtScriptType nScriptType, sal_uInt16 nWhich );
669 /** Adds a language item to the item set, if the number format item contains
670 a language that differs from its parent's language. */
671 SC_DLLPUBLIC static void AddLanguage( SfxItemSet& rSet, const SvNumberFormatter& rFormatter );
673 /** Obtain the ordinal suffix for a number according to the system locale */
674 static OUString GetOrdinalSuffix( sal_Int32 nNumber);
676 /** A static instance of ScFieldEditEngine not capable of resolving
677 document specific fields, to be used only by ScEditUtil::GetString(). */
678 static ScFieldEditEngine& GetStaticFieldEditEngine();
680 /** Replaces the first occurrence of rPlaceholder in rString with
681 rReplacement, or if rPlaceholder is not found appends one space if
682 rString does not end in a space and appends rReplacement.
684 Meant to be used with resource strings ala "Column %1" where a
685 translation may have omitted the %1 placeholder and a simple
686 replacement would end up with nothing replaced so no column indicator
687 in the result string.
689 SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString,
690 std::u16string_view rPlaceholder,
691 const OUString& rReplacement );
694 /** Convert string content to numeric value.
696 In any case, if rError is set 0.0 is returned.
698 If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally
699 assigned to rError and 0.0 is returned. The caller is expected to
700 handle this situation. Used by the interpreter.
702 Usually FormulaError::NoValue is passed as nStringNoValueError.
704 Otherwise, depending on the string conversion configuration different
705 approaches are taken:
708 For ScCalcConfig::StringConversion::ILLEGAL
709 The error value passed in nStringNoValueError is assigned to rError
710 (and 0.0 returned).
713 For ScCalcConfig::StringConversion::ZERO
714 A zero value is returned and no error assigned.
717 For ScCalcConfig::StringConversion::LOCALE
719 If the string is empty or consists only of spaces, if "treat empty
720 string as zero" is set 0.0 is returned, else nStringNoValueError
721 assigned to rError (and 0.0 returned).
723 Else a non-empty string is passed to the number formatter's scanner to
724 be parsed locale dependent. If that does not detect a numeric value
725 nStringNoValueError is assigned to rError (and 0.0 returned).
727 If no number formatter was passed, the conversion falls back to
728 UNAMBIGUOUS.
731 For ScCalcConfig::StringConversion::UNAMBIGUOUS
733 If the string is empty or consists only of spaces, if "treat empty
734 string as zero" is set 0.0 is returned, else nStringNoValueError
735 assigned to rError (and 0.0 returned).
737 If the string is not empty the following conversion rules are applied:
739 Converted are only integer numbers including exponent, and ISO 8601 dates
740 and times in their extended formats with separators. Anything else,
741 especially fractional numeric values with decimal separators or dates other
742 than ISO 8601 would be locale dependent and is a no-no. Leading and
743 trailing blanks are ignored.
745 The following ISO 8601 formats are converted:
747 CCYY-MM-DD
748 CCYY-MM-DDThh:mm
749 CCYY-MM-DDThh:mm:ss
750 CCYY-MM-DDThh:mm:ss,s
751 CCYY-MM-DDThh:mm:ss.s
752 hh:mm
753 hh:mm:ss
754 hh:mm:ss,s
755 hh:mm:ss.s
757 The century CC may not be omitted and the two-digit year setting is not
758 taken into account. Instead of the T date and time separator exactly one
759 blank may be used.
761 If a date is given, it must be a valid Gregorian calendar date. In this
762 case the optional time must be in the range 00:00 to 23:59:59.99999...
763 If only time is given, it may have any value for hours, taking elapsed time
764 into account; minutes and seconds are limited to the value 59 as well.
766 If the string can not be converted to a numeric value, the error value
767 passed in nStringNoValueError is assigned to rError.
770 @param rStr
771 The string to be converted.
773 @param rConfig
774 The calculation configuration.
776 @param rError
777 Contains the error on return, if any. If an error was set before
778 and the conversion did not result in an error, still 0.0 is
779 returned.
781 @param nStringNoValueError
782 The error value to be assigned to rError if string could not be
783 converted to number.
785 @param pFormatter
786 The number formatter to use in case of
787 ScCalcConfig::StringConversion::LOCALE. Can but should not be
788 nullptr in which case conversion falls back to
789 ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is
790 detected the null date is assumed to be the standard 1899-12-30
791 instead of the configured null date.
793 @param rCurFmtType
794 Can be assigned a format type in case a date or time or date+time
795 string was converted, e.g. SvNumFormatType::DATE or
796 SvNumFormatType::TIME or a combination thereof.
799 static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig,
800 FormulaError & rError, FormulaError nStringNoValueError,
801 SvNumberFormatter* pFormatter, SvNumFormatType & rCurFmtType );
803 /// Calc's threaded group calculation is in progress.
804 SC_DLLPUBLIC static bool bThreadedGroupCalcInProgress;
807 // maybe move to dbdata.hxx (?):
809 enum ScQueryOp
811 SC_EQUAL,
812 SC_LESS,
813 SC_GREATER,
814 SC_LESS_EQUAL,
815 SC_GREATER_EQUAL,
816 SC_NOT_EQUAL,
817 SC_TOPVAL,
818 SC_BOTVAL,
819 SC_TOPPERC,
820 SC_BOTPERC,
821 SC_CONTAINS,
822 SC_DOES_NOT_CONTAIN,
823 SC_BEGINS_WITH,
824 SC_DOES_NOT_BEGIN_WITH,
825 SC_ENDS_WITH,
826 SC_DOES_NOT_END_WITH
829 enum ScQueryConnect
831 SC_AND,
832 SC_OR
835 enum ScSubTotalFunc
837 SUBTOTAL_FUNC_NONE = 0,
838 SUBTOTAL_FUNC_AVE = 1,
839 SUBTOTAL_FUNC_CNT = 2,
840 SUBTOTAL_FUNC_CNT2 = 3,
841 SUBTOTAL_FUNC_MAX = 4,
842 SUBTOTAL_FUNC_MIN = 5,
843 SUBTOTAL_FUNC_PROD = 6,
844 SUBTOTAL_FUNC_STD = 7,
845 SUBTOTAL_FUNC_STDP = 8,
846 SUBTOTAL_FUNC_SUM = 9,
847 SUBTOTAL_FUNC_VAR = 10,
848 SUBTOTAL_FUNC_VARP = 11,
849 SUBTOTAL_FUNC_MED = 12,
850 SUBTOTAL_FUNC_SELECTION_COUNT = 13
853 enum ScAggregateFunc
855 AGGREGATE_FUNC_AVE = 1,
856 AGGREGATE_FUNC_CNT = 2,
857 AGGREGATE_FUNC_CNT2 = 3,
858 AGGREGATE_FUNC_MAX = 4,
859 AGGREGATE_FUNC_MIN = 5,
860 AGGREGATE_FUNC_PROD = 6,
861 AGGREGATE_FUNC_STD = 7,
862 AGGREGATE_FUNC_STDP = 8,
863 AGGREGATE_FUNC_SUM = 9,
864 AGGREGATE_FUNC_VAR = 10,
865 AGGREGATE_FUNC_VARP = 11,
866 AGGREGATE_FUNC_MEDIAN = 12,
867 AGGREGATE_FUNC_MODSNGL = 13,
868 AGGREGATE_FUNC_LARGE = 14,
869 AGGREGATE_FUNC_SMALL = 15,
870 AGGREGATE_FUNC_PERCINC = 16,
871 AGGREGATE_FUNC_QRTINC = 17,
872 AGGREGATE_FUNC_PERCEXC = 18,
873 AGGREGATE_FUNC_QRTEXC = 19
876 class ScArea;
878 struct ScConsolidateParam
880 SCCOL nCol; // cursor position /
881 SCROW nRow; // or start of destination area respectively
882 SCTAB nTab;
883 ScSubTotalFunc eFunction;
884 sal_uInt16 nDataAreaCount; // number of data areas
885 std::unique_ptr<ScArea[]> pDataAreas; // array of pointers into data areas
886 bool bByCol;
887 bool bByRow;
888 bool bReferenceData; // reference source data
890 ScConsolidateParam();
891 ScConsolidateParam( const ScConsolidateParam& r );
892 ~ScConsolidateParam();
894 ScConsolidateParam& operator= ( const ScConsolidateParam& r );
895 bool operator== ( const ScConsolidateParam& r ) const;
896 void Clear (); // = ClearDataAreas()+Members
897 void ClearDataAreas ();
898 void SetAreas ( std::unique_ptr<ScArea[]> pAreas, sal_uInt16 nCount );
901 extern SfxViewShell* pScActiveViewShell;
902 extern sal_uInt16 nScClickMouseModifier;
903 extern sal_uInt16 nScFillModeMouseModifier;
905 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */