Coverage Report

Created: 2026-09-28 10:59

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