Coverage Report

Created: 2026-02-14 09:37

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
6.92M
#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
62.5k
#define OLE_STD_CELLS_X     4
125
62.5k
#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
namespace o3tl
287
{
288
    template<> struct typed_flags<ScCloneFlags> : is_typed_flags<ScCloneFlags, 0x0007> {};
289
}
290
291
enum CellType
292
    {
293
        CELLTYPE_NONE,
294
        CELLTYPE_VALUE,
295
        CELLTYPE_STRING,
296
        CELLTYPE_FORMULA,
297
        CELLTYPE_EDIT,
298
    };
299
300
enum class DelCellCmd
301
    {
302
        CellsUp,
303
        CellsLeft,
304
        Rows,
305
        Cols,
306
        NONE
307
    };
308
309
enum InsCellCmd
310
    {
311
        INS_CELLSDOWN,
312
        INS_CELLSRIGHT,
313
        INS_INSROWS_BEFORE,
314
        INS_INSCOLS_BEFORE,
315
        INS_NONE,
316
        INS_INSROWS_AFTER,
317
        INS_INSCOLS_AFTER
318
    };
319
320
enum UpdateRefMode
321
    {
322
        URM_INSDEL,
323
        URM_COPY,
324
        URM_MOVE,
325
        URM_REORDER
326
    };
327
328
enum FillDir
329
    {
330
        FILL_TO_BOTTOM,
331
        FILL_TO_RIGHT,
332
        FILL_TO_TOP,
333
        FILL_TO_LEFT
334
    };
335
336
enum FillCmd
337
    {
338
        FILL_SIMPLE,
339
        FILL_LINEAR,
340
        FILL_GROWTH,
341
        FILL_DATE,
342
        FILL_AUTO
343
    };
344
345
enum ScMoveDirection
346
{
347
    SC_MOVE_RIGHT,
348
    SC_MOVE_LEFT,
349
    SC_MOVE_UP,
350
    SC_MOVE_DOWN
351
};
352
353
enum FillDateCmd
354
    {
355
        FILL_DAY,
356
        FILL_WEEKDAY,
357
        FILL_MONTH,
358
        FILL_END_OF_MONTH,
359
        FILL_YEAR
360
    };
361
362
enum ScDirection
363
    {
364
        DIR_BOTTOM,
365
        DIR_RIGHT,
366
        DIR_TOP,
367
        DIR_LEFT
368
    };
369
370
enum ScSizeMode
371
    {
372
        SC_SIZE_DIRECT,             // set size or hide if value is 0
373
        SC_SIZE_OPTIMAL,            // set optimal size for everything
374
        SC_SIZE_SHOW,               // show with original size
375
        SC_SIZE_VISOPT,             // set optimal size only if visible
376
        SC_SIZE_ORIGINAL            // only set size, don't change visible flag
377
    };
378
379
enum ScInputMode
380
    {
381
        SC_INPUT_NONE,
382
        SC_INPUT_TYPE,              // input, while not in inplace mode
383
        SC_INPUT_TABLE,             // text cursor in the table
384
        SC_INPUT_TOP                // text cursor in the input line
385
    };
386
387
enum ScVObjMode                     // output modes of objects on a page
388
{
389
    VOBJ_MODE_SHOW,
390
    VOBJ_MODE_HIDE
391
};
392
393
enum ScAnchorType                   // anchor of a character object
394
{
395
    SCA_CELL,                       // anchor to cell, move with cell
396
    SCA_CELL_RESIZE,                // anchor to cell, move and resize with cell
397
    SCA_PAGE,                       // anchor to page, independent of any cells
398
    SCA_DONTKNOW                    // for multi selection
399
};
400
401
enum ScGetDBMode
402
{
403
    SC_DB_MAKE,         ///< create "untitled" (if necessary)
404
    SC_DB_AUTOFILTER,   ///< force use of sheet-local instead of document global anonymous range
405
    SC_DB_IMPORT,       ///< create "Importx" (if necessary)
406
    SC_DB_OLD           ///< don't create
407
};
408
409
/// For ScDBFunc::GetDBData()
410
enum class ScGetDBSelection
411
{
412
    /** Keep selection as is, expand to used data area if no selection. */
413
    Keep,
414
415
    /** Shrink selection to actually used data area within the selection. */
416
    ShrinkToUsedData,
417
418
    /** If only one row or portion thereof is selected, shrink row to used data
419
        columns and select further rows down until end of data. If an area is
420
        selected, shrink rows to actually used columns. Else, no selection,
421
        expand to used data area. */
422
    RowDown,
423
424
    /** Behave as if the range corresponding to a ScDBData area was selected,
425
        for API use. */
426
    ForceMark
427
};
428
429
enum ScLkUpdMode    // modes for updating links
430
{
431
    LM_ALWAYS,
432
    LM_NEVER,
433
    LM_ON_DEMAND,
434
    LM_UNKNOWN
435
};
436
437
// enum with values equal to old DBObject enum from sdb
438
enum ScDBObject
439
{
440
    ScDbTable,
441
    ScDbQuery
442
};
443
444
namespace sc {
445
446
enum class EditAction
447
{
448
    Unknown,
449
    InsertColumnsBefore,
450
    InsertColumnsAfter,
451
    InsertRowsBefore,
452
    InsertRowsAfter,
453
    DeleteColumns,
454
    DeleteRows,
455
    UpdatePivotTable
456
};
457
458
}
459
460
struct ScImportParam
461
{
462
    SCCOL           nCol1;
463
    SCROW           nRow1;
464
    SCCOL           nCol2;
465
    SCROW           nRow2;
466
    bool            bImport;
467
    OUString aDBName;                    // alias of data base
468
    OUString aStatement;
469
    bool            bNative;
470
    bool            bSql;                       // statement or name?
471
    sal_uInt8       nType;                      // enum DBObject
472
473
    ScImportParam();
474
    ScImportParam( const ScImportParam& r );
475
    ~ScImportParam();
476
477
    ScImportParam&  operator=   ( const ScImportParam& r );
478
    bool            operator==  ( const ScImportParam& r ) const;
479
};
480
481
// Formula data replacement character for a pair of parentheses at end of
482
// function name, to force sorting parentheses before all other characters.
483
// Collation may treat parentheses differently.
484
inline constexpr sal_Unicode cParenthesesReplacement = 0x0001;
485
struct InputHandlerFunctionNames
486
{
487
    ScTypedCaseStrSet       maFunctionData;
488
    ScTypedCaseStrSet       maFunctionDataPara;
489
    std::set<sal_Unicode>   maFunctionChar;
490
};
491
492
class ScDocShell;
493
class SvxSearchItem;
494
class ScAutoFormat;
495
class LegacyFuncCollection;
496
class ScUnoAddInCollection;
497
class ScUserList;
498
class SvxBrushItem;
499
class ScFunctionList;
500
class ScFunctionMgr;
501
class SfxItemPool;
502
class EditTextObject;
503
class SfxObjectShell;
504
class SvNumberFormatter;
505
struct ScInterpreterContext;
506
class ScUnitConverter;
507
class CharClass;
508
class LocaleDataWrapper;
509
class SvtSysLocale;
510
class CalendarWrapper;
511
class CollatorWrapper;
512
class ScFieldEditEngine;
513
514
namespace com::sun::star {
515
    namespace lang {
516
        struct Locale;
517
    }
518
    namespace i18n {
519
        class XOrdinalSuffix;
520
    }
521
}
522
namespace utl {
523
    class TransliterationWrapper;
524
}
525
526
namespace sc {
527
    class SharedStringPoolPurge;
528
}
529
530
class ScGlobal
531
{
532
    static std::unique_ptr<SvxSearchItem> xSearchItem;
533
    static std::unique_ptr<ScAutoFormat> xAutoFormat;
534
    static std::atomic<LegacyFuncCollection*> pLegacyFuncCollection;
535
    static std::atomic<ScUnoAddInCollection*> pAddInCollection;
536
    static std::unique_ptr<ScUserList> xUserList;
537
    static OUString         aStrClipDocName;
538
    static std::unique_ptr<SvxBrushItem> xEmptyBrushItem;
539
    static std::unique_ptr<SvxBrushItem> xButtonBrushItem;
540
541
    static std::unordered_map<OUString, std::unique_ptr<ScFunctionList>> xStarCalcFunctionList;
542
    static std::unordered_map<OUString, std::unique_ptr<ScFunctionMgr>> xStarCalcFunctionMgr;
543
544
    static std::atomic<ScUnitConverter*> pUnitConverter;
545
546
    static std::unique_ptr<SvNumberFormatter> xEnglishFormatter;          // for UNO / XML export
547
548
    static css::uno::Reference< css::i18n::XOrdinalSuffix> xOrdinalSuffix;
549
    static std::optional<CalendarWrapper>    oCalendar;
550
    static std::atomic<CollatorWrapper*>     pCaseCollator;
551
    static std::atomic<CollatorWrapper*>     pCollator;
552
    static std::atomic<::utl::TransliterationWrapper*> pTransliteration;
553
    static std::atomic<::utl::TransliterationWrapper*> pCaseTransliteration;
554
    static std::atomic<css::lang::Locale*>   pLocale;
555
556
    static std::unique_ptr<ScFieldEditEngine> xFieldEditEngine;
557
558
    static std::atomic<sc::SharedStringPoolPurge*> pSharedStringPoolPurge;
559
560
    static std::unordered_map<OUString, InputHandlerFunctionNames> maInputHandlerFunctionNames;
561
562
    static void                 InitPPT();
563
564
public:
565
    static std::optional<SvtSysLocale> oSysLocale;
566
    SC_DLLPUBLIC static const LocaleDataWrapper& getLocaleData();
567
    SC_DLLPUBLIC static const CharClass& getCharClass();
568
569
    static CalendarWrapper&     GetCalendar();
570
    /// case-insensitive collator
571
    SC_DLLPUBLIC static CollatorWrapper& GetCollator();
572
    /// case-sensitive collator
573
    static CollatorWrapper&     GetCaseCollator();
574
    static CollatorWrapper&     GetCollator(bool bCaseSensitive);
575
    static css::lang::Locale&   GetLocale();
576
577
    SC_DLLPUBLIC static ::utl::TransliterationWrapper& GetTransliteration();
578
    static ::utl::TransliterationWrapper& GetCaseTransliteration();
579
    static ::utl::TransliterationWrapper& GetTransliteration(bool bCaseSensitive);
580
581
    SC_DLLPUBLIC static LanguageType            eLnge;
582
    static constexpr sal_Unicode cListDelimiter = ',';
583
584
    static const OUString&      GetClipDocName();
585
    static void                 SetClipDocName( const OUString& rNew );
586
    SC_DLLPUBLIC static const SvxSearchItem&    GetSearchItem();
587
    SC_DLLPUBLIC static void                    SetSearchItem( const SvxSearchItem& rNew );
588
    SC_DLLPUBLIC static ScAutoFormat*       GetAutoFormat();
589
    SC_DLLPUBLIC static ScAutoFormat*       GetOrCreateAutoFormat();
590
    SC_DLLPUBLIC static void                ResetAutoFormat();
591
    static void                 ClearAutoFormat(); //BugId 54209
592
    static LegacyFuncCollection*      GetLegacyFuncCollection();
593
    SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
594
    SC_DLLPUBLIC static ScUserList&         GetUserList();
595
    static void                 SetUserList( const ScUserList* pNewList );
596
    /**
597
     * Open the specified URL.
598
     * @param bIgnoreSettings - If true, ignore security settings (Ctrl-Click) and just open the URL.
599
     */
600
    SC_DLLPUBLIC static void OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgnoreSettings = false);
601
    /// Whether the URL can be opened according to current security options (Click/Ctrl-Click)
602
    static bool                 ShouldOpenURL();
603
    SC_DLLPUBLIC static OUString            GetAbsDocName( const OUString& rFileName,
604
                                                const SfxObjectShell* pShell );
605
    SC_DLLPUBLIC static OUString            GetDocTabName( std::u16string_view rFileName,
606
                                                std::u16string_view rTabName );
607
    SC_DLLPUBLIC static sal_uInt32 GetStandardFormat( ScInterpreterContext&, sal_uInt32 nFormat, SvNumFormatType nType );
608
609
    /// Horizontal pixel per twips factor.
610
    SC_DLLPUBLIC static double              nScreenPPTX;
611
    /// Vertical pixel per twips factor.
612
    SC_DLLPUBLIC static double              nScreenPPTY;
613
614
    static rtl::Reference<ScDocShell> xDrawClipDocShellRef;
615
616
    static sal_uInt16           nDefFontHeight;
617
    SC_DLLPUBLIC static sal_uInt16           nStdRowHeight;
618
619
    SC_DLLPUBLIC static ::tools::Long                nLastRowHeightExtra;
620
    static ::tools::Long             nLastColWidthExtra;
621
622
    SC_DLLPUBLIC static void Init();                     // during start up
623
    static void             InitAddIns();
624
    SC_DLLPUBLIC static void Clear();                    // at the end of the program
625
626
    static void             InitTextHeight(SfxItemPool& rPool);
627
157k
    static const SvxBrushItem* GetEmptyBrushItem() { return xEmptyBrushItem.get(); }
628
    static SvxBrushItem*    GetButtonBrushItem();
629
630
    static bool             HasStarCalcFunctionList();
631
    static ScFunctionList*  GetStarCalcFunctionList();
632
    static ScFunctionMgr*   GetStarCalcFunctionMgr();
633
    static void             ResetFunctionList();
634
    static const InputHandlerFunctionNames& GetInputHandlerFunctionNames();
635
636
    static OUString         GetErrorString(FormulaError nErrNumber);
637
    static OUString         GetLongErrorString(FormulaError nErrNumber);
638
    static bool             EETextObjEqual( const EditTextObject* pObj1,
639
                                            const EditTextObject* pObj2 );
640
    static bool             CheckWidthInvalidate( bool& bNumFormatChanged,
641
                                                  const SfxItemSet& rNewAttrs,
642
                                                  const SfxItemSet& rOldAttrs );
643
    static bool             HasAttrChanged( const SfxItemSet& rNewAttrs,
644
                                            const SfxItemSet& rOldAttrs,
645
                                            const sal_uInt16      nWhich );
646
647
    static ScUnitConverter* GetUnitConverter();
648
649
    /// strchr() functionality on unicode, as long as we need it for FormulaToken etc.
650
    static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
651
652
    static sal_Unicode ToUpperAlpha( sal_Unicode c )
653
3.92M
        { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
654
655
    /** Adds the string rToken to rTokenList, using a list separator character.
656
        @param rTokenList  The string list where the token will be appended to.
657
        @param rToken  The token string to append to the token list.
658
        @param cSep  The character to separate the tokens.
659
        @param nSepCount  Specifies how often cSep is inserted between two tokens.
660
        @param bForceSep  true = Always insert separator; false = Only, if not at begin or end. */
661
    SC_DLLPUBLIC static OUString addToken(
662
                                std::u16string_view rTokenList, std::u16string_view rToken,
663
                                sal_Unicode cSep, sal_Int32 nSepCount = 1,
664
                                bool bForceSep = false );
665
666
    /** Returns true, if the first and last character of the string is cQuote. */
667
    SC_DLLPUBLIC static bool             IsQuoted( std::u16string_view rString, sal_Unicode cQuote );
668
669
    /** Inserts the character cQuote at beginning and end of rString.
670
        @param bEscapeEmbedded      If <TRUE/>, embedded quote characters are
671
                                    escaped by doubling them.
672
     */
673
    SC_DLLPUBLIC static void             AddQuotes( OUString& rString, sal_Unicode cQuote, bool bEscapeEmbedded = true );
674
675
    /** Erases the character cQuote from rString, if it exists at beginning AND end.
676
        @param bUnescapeEmbedded    If <TRUE/>, embedded doubled quote characters
677
                                    are unescaped by replacing them with a
678
                                    single instance.
679
     */
680
    SC_DLLPUBLIC static void             EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescapeEmbedded = true );
681
682
    /** Finds an unquoted instance of cChar in rString, starting at
683
        offset nStart. Unquoted instances may occur when concatenating two
684
        quoted strings with a separator, for example, 's1':'s2'. Embedded
685
        quotes have to be escaped by being doubled. Caller must ensure that
686
        nStart points into an unquoted range or the opening quote. Specialty:
687
        if cChar=='\'' the first quote character from nStart on is found.
688
        @returns offset if found, else -1
689
     */
690
    SC_DLLPUBLIC static sal_Int32   FindUnquoted( const OUString& rString, sal_Unicode cChar, sal_Int32 nStart = 0 );
691
692
    /** Finds an unquoted instance of cChar in null-terminated pString. Same
693
        semantics as FindUnquoted( const String&, ...)
694
        @returns: pointer to cChar if found, else NULL
695
     */
696
    SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar );
697
698
    static  rtl_TextEncoding GetCharsetValue( std::u16string_view rCharSet );
699
    static  OUString        GetCharsetString( rtl_TextEncoding eVal );
700
701
    /// a "ReadOnly" formatter for UNO/XML export
702
    static  SvNumberFormatter*  GetEnglishFormatter();
703
704
    static bool IsSystemRTL();                      // depending on system language
705
    static LanguageType GetEditDefaultLanguage();   // for EditEngine::SetDefaultLanguage
706
    SC_DLLPUBLIC static SvtScriptType GetDefaultScriptType();             // for all WEAK characters
707
    /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
708
        If more than one SvtScriptType::... values are or'ed together, prefers
709
        first COMPLEX, then ASIAN */
710
    SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( SvtScriptType nScriptType, sal_uInt16 nWhich );
711
712
    /** Adds a language item to the item set, if the number format item contains
713
        a language that differs from its parent's language. */
714
    SC_DLLPUBLIC static void             AddLanguage( SfxItemSet& rSet, const SvNumberFormatter& rFormatter );
715
716
    /** Obtain the ordinal suffix for a number according to the system locale */
717
    static OUString         GetOrdinalSuffix( sal_Int32 nNumber);
718
719
    static sc::SharedStringPoolPurge& GetSharedStringPoolPurge();
720
721
    /** Replaces the first occurrence of rPlaceholder in rString with
722
        rReplacement, or if rPlaceholder is not found appends one space if
723
        rString does not end in a space and appends rReplacement.
724
725
        Meant to be used with resource strings ala "Column %1" where a
726
        translation may have omitted the %1 placeholder and a simple
727
        replacement would end up with nothing replaced so no column indicator
728
        in the result string.
729
     */
730
    SC_DLLPUBLIC static OUString    ReplaceOrAppend( const OUString& rString,
731
                                                     std::u16string_view rPlaceholder,
732
                                                     const OUString& rReplacement );
733
734
735
    /** Convert string content to numeric value.
736
737
        In any case, if rError is set 0.0 is returned.
738
739
        If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally
740
        assigned to rError and 0.0 is returned. The caller is expected to
741
        handle this situation. Used by the interpreter.
742
743
        Usually FormulaError::NoValue is passed as nStringNoValueError.
744
745
        Otherwise, depending on the string conversion configuration different
746
        approaches are taken:
747
748
749
        For ScCalcConfig::StringConversion::ILLEGAL
750
        The error value passed in nStringNoValueError is assigned to rError
751
        (and 0.0 returned).
752
753
754
        For ScCalcConfig::StringConversion::ZERO
755
        A zero value is returned and no error assigned.
756
757
758
        For ScCalcConfig::StringConversion::LOCALE
759
760
        If the string is empty or consists only of spaces, if "treat empty
761
        string as zero" is set 0.0 is returned, else nStringNoValueError
762
        assigned to rError (and 0.0 returned).
763
764
        Else a non-empty string is passed to the number formatter's scanner to
765
        be parsed locale dependent. If that does not detect a numeric value
766
        nStringNoValueError is assigned to rError (and 0.0 returned).
767
768
        If no number formatter was passed, the conversion falls back to
769
        UNAMBIGUOUS.
770
771
772
        For ScCalcConfig::StringConversion::UNAMBIGUOUS
773
774
        If the string is empty or consists only of spaces, if "treat empty
775
        string as zero" is set 0.0 is returned, else nStringNoValueError
776
        assigned to rError (and 0.0 returned).
777
778
        If the string is not empty the following conversion rules are applied:
779
780
        Converted are only integer numbers including exponent, and ISO 8601 dates
781
        and times in their extended formats with separators. Anything else,
782
        especially fractional numeric values with decimal separators or dates other
783
        than ISO 8601 would be locale dependent and is a no-no. Leading and
784
        trailing blanks are ignored.
785
786
        The following ISO 8601 formats are converted:
787
788
        CCYY-MM-DD
789
        CCYY-MM-DDThh:mm
790
        CCYY-MM-DDThh:mm:ss
791
        CCYY-MM-DDThh:mm:ss,s
792
        CCYY-MM-DDThh:mm:ss.s
793
        hh:mm
794
        hh:mm:ss
795
        hh:mm:ss,s
796
        hh:mm:ss.s
797
798
        The century CC may not be omitted and the two-digit year setting is not
799
        taken into account. Instead of the T date and time separator exactly one
800
        blank may be used.
801
802
        If a date is given, it must be a valid Gregorian calendar date. In this
803
        case the optional time must be in the range 00:00 to 23:59:59.99999...
804
        If only time is given, it may have any value for hours, taking elapsed time
805
        into account; minutes and seconds are limited to the value 59 as well.
806
807
        If the string can not be converted to a numeric value, the error value
808
        passed in nStringNoValueError is assigned to rError.
809
810
811
        @param rStr
812
            The string to be converted.
813
814
        @param rConfig
815
            The calculation configuration.
816
817
        @param rError
818
            Contains the error on return, if any. If an error was set before
819
            and the conversion did not result in an error, still 0.0 is
820
            returned.
821
822
        @param nStringNoValueError
823
            The error value to be assigned to rError if string could not be
824
            converted to number.
825
826
        @param pFormatter
827
            The number formatter to use in case of
828
            ScCalcConfig::StringConversion::LOCALE. Can but should not be
829
            nullptr in which case conversion falls back to
830
            ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is
831
            detected the null date is assumed to be the standard 1899-12-30
832
            instead of the configured null date.
833
834
        @param rCurFmtType
835
            Can be assigned a format type in case a date or time or date+time
836
            string was converted, e.g. SvNumFormatType::DATE or
837
            SvNumFormatType::TIME or a combination thereof.
838
839
     */
840
    static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig,
841
            FormulaError & rError, FormulaError nStringNoValueError,
842
            ScInterpreterContext& rContext, SvNumFormatType & rCurFmtType );
843
844
    /// Calc's threaded group calculation is in progress.
845
    SC_DLLPUBLIC static bool bThreadedGroupCalcInProgress;
846
};
847
848
// maybe move to dbdata.hxx (?):
849
850
enum ScQueryOp
851
    {
852
        SC_EQUAL,
853
        SC_LESS,
854
        SC_GREATER,
855
        SC_LESS_EQUAL,
856
        SC_GREATER_EQUAL,
857
        SC_NOT_EQUAL,
858
        SC_TOPVAL,
859
        SC_BOTVAL,
860
        SC_TOPPERC,
861
        SC_BOTPERC,
862
        SC_CONTAINS,
863
        SC_DOES_NOT_CONTAIN,
864
        SC_BEGINS_WITH,
865
        SC_DOES_NOT_BEGIN_WITH,
866
        SC_ENDS_WITH,
867
        SC_DOES_NOT_END_WITH
868
    };
869
870
enum ScQueryConnect
871
    {
872
        SC_AND,
873
        SC_OR
874
    };
875
876
enum ScSubTotalFunc : sal_Int16
877
    {
878
        SUBTOTAL_FUNC_NONE  = 0,
879
        SUBTOTAL_FUNC_AVE   = 1,
880
        SUBTOTAL_FUNC_CNT   = 2,
881
        SUBTOTAL_FUNC_CNT2  = 3,
882
        SUBTOTAL_FUNC_MAX   = 4,
883
        SUBTOTAL_FUNC_MIN   = 5,
884
        SUBTOTAL_FUNC_PROD  = 6,
885
        SUBTOTAL_FUNC_STD   = 7,
886
        SUBTOTAL_FUNC_STDP  = 8,
887
        SUBTOTAL_FUNC_SUM   = 9,
888
        SUBTOTAL_FUNC_VAR   = 10,
889
        SUBTOTAL_FUNC_VARP  = 11,
890
        SUBTOTAL_FUNC_MED   = 12,
891
        SUBTOTAL_FUNC_SELECTION_COUNT = 13
892
    };
893
894
enum ScAggregateFunc
895
    {
896
        AGGREGATE_FUNC_AVE     = 1,
897
        AGGREGATE_FUNC_CNT     = 2,
898
        AGGREGATE_FUNC_CNT2    = 3,
899
        AGGREGATE_FUNC_MAX     = 4,
900
        AGGREGATE_FUNC_MIN     = 5,
901
        AGGREGATE_FUNC_PROD    = 6,
902
        AGGREGATE_FUNC_STD     = 7,
903
        AGGREGATE_FUNC_STDP    = 8,
904
        AGGREGATE_FUNC_SUM     = 9,
905
        AGGREGATE_FUNC_VAR     = 10,
906
        AGGREGATE_FUNC_VARP    = 11,
907
        AGGREGATE_FUNC_MEDIAN  = 12,
908
        AGGREGATE_FUNC_MODSNGL = 13,
909
        AGGREGATE_FUNC_LARGE   = 14,
910
        AGGREGATE_FUNC_SMALL   = 15,
911
        AGGREGATE_FUNC_PERCINC = 16,
912
        AGGREGATE_FUNC_QRTINC  = 17,
913
        AGGREGATE_FUNC_PERCEXC = 18,
914
        AGGREGATE_FUNC_QRTEXC  = 19
915
    };
916
917
class ScArea;
918
919
struct ScConsolidateParam
920
{
921
    SCCOL           nCol;                   // cursor position /
922
    SCROW           nRow;                   // or start of destination area respectively
923
    SCTAB           nTab;
924
    ScSubTotalFunc  eFunction;
925
    sal_uInt16      nDataAreaCount;         // number of data areas
926
    std::unique_ptr<ScArea[]> pDataAreas; // array of pointers into data areas
927
    bool            bByCol;
928
    bool            bByRow;
929
    bool            bReferenceData;         // reference source data
930
931
    ScConsolidateParam();
932
    ScConsolidateParam( const ScConsolidateParam& r );
933
    ~ScConsolidateParam();
934
935
    ScConsolidateParam& operator=       ( const ScConsolidateParam& r );
936
    bool                operator==      ( const ScConsolidateParam& r ) const;
937
    void                Clear           (); // = ClearDataAreas()+Members
938
    void                ClearDataAreas  ();
939
    void                SetAreas        ( std::unique_ptr<ScArea[]> pAreas, sal_uInt16 nCount );
940
};
941
942
extern SfxViewShell* pScActiveViewShell;
943
extern sal_uInt16 nScClickMouseModifier;
944
extern sal_uInt16 nScFillModeMouseModifier;
945
946
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */