nss: upgrade to release 3.73
[LibreOffice.git] / sc / inc / global.hxx
blob21d33ccc35e9b60402f6039af3a47496d8b8d0fc
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 #ifndef INCLUDED_SC_INC_GLOBAL_HXX
21 #define INCLUDED_SC_INC_GLOBAL_HXX
23 #include "address.hxx"
24 #include <i18nlangtag/lang.h>
25 #include <svx/svdtypes.hxx>
26 #include <tools/ref.hxx>
27 #include <sal/types.h>
28 #include <com/sun/star/i18n/CollatorOptions.hpp>
29 #include "scdllapi.h"
30 #include <rtl/ustring.hxx>
31 #include <tools/long.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
37 #include <map>
38 #include <memory>
40 namespace com::sun::star::uno { template <typename > class Reference; }
42 class SfxItemSet;
43 class SfxViewShell;
44 struct ScCalcConfig;
45 enum class SvtScriptType;
46 enum class FormulaError : sal_uInt16;
47 enum class SvNumFormatType : sal_Int16;
49 #define SC_COLLATOR_IGNORES css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE
51 // Calc has lots of names...
52 // Clipboard names are in so3/soapp.hxx now
53 // STRING_SCAPP was "scalc3", "scalc4", now just "scalc"
55 #define STRING_SCAPP "scalc"
57 #define STRING_STANDARD "Standard"
59 // Have the dreaded programmatic filter name defined in one place.
60 #define SC_TEXT_CSV_FILTER_NAME "Text - txt - csv (StarCalc)"
62 // characters
64 const sal_Unicode CHAR_NBSP = 0x00A0;
65 const sal_Unicode CHAR_SHY = 0x00AD;
66 const sal_Unicode CHAR_ZWSP = 0x200B;
67 const sal_Unicode CHAR_LRM = 0x200E;
68 const sal_Unicode CHAR_RLM = 0x200F;
69 const sal_Unicode CHAR_NBHY = 0x2011;
70 const sal_Unicode CHAR_ZWNBSP = 0x2060;
71 const sal_Unicode CHAR_NNBSP = 0x202F; //NARROW NO-BREAK SPACE
73 #define MINDOUBLE 1.7e-307
74 #define MAXDOUBLE 1.7e307
76 #define MINZOOM 20
77 #define MAXZOOM 400
79 const SCSIZE MAXSUBTOTAL = 3;
81 #define PIXEL_PER_INCH 96.0
82 #define CM_PER_INCH 2.54
83 #define POINTS_PER_INCH 72.0 /**< PostScript points per inch */
84 #define PIXEL_PER_POINT (PIXEL_PER_INCH / POINTS_PER_INCH)
85 #define TWIPS_PER_POINT 20.0
86 #define TWIPS_PER_INCH (TWIPS_PER_POINT * POINTS_PER_INCH)
87 #define TWIPS_PER_CM (TWIPS_PER_INCH / CM_PER_INCH)
88 #define CM_PER_TWIPS (CM_PER_INCH / TWIPS_PER_INCH)
89 #define TWIPS_PER_PIXEL (TWIPS_PER_INCH / PIXEL_PER_INCH)
90 #define TWIPS_PER_CHAR (TWIPS_PER_INCH / 13.6)
91 #define PIXEL_PER_TWIPS (PIXEL_PER_INCH / TWIPS_PER_INCH)
92 #define HMM_PER_TWIPS (CM_PER_TWIPS * 1000.0)
94 #define STD_COL_WIDTH 1280 /* 2.2577cm, 64.00pt PS */
95 #define STD_EXTRA_WIDTH 113 /* 2mm extra for optimal width,
96 * 0.1986cm with TeX points,
97 * 0.1993cm with PS points. */
99 #define MAX_EXTRA_WIDTH 23811 /* 42cm in TWIPS, 41.8430cm TeX, 41.9999cm PS */
100 #define MAX_EXTRA_HEIGHT 23811
101 #define MAX_COL_WIDTH 56693 /* 1m in TWIPS, 99.6266cm TeX, 100.0001cm PS */
102 #define MAX_ROW_HEIGHT 56693
104 /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
105 #define STD_ROWHEIGHT_DIFF 23
107 namespace sc
109 inline ::tools::Long TwipsToHMM( ::tools::Long nTwips ) { return (nTwips * 127 + 36) / 72; }
110 inline ::tools::Long HMMToTwips( ::tools::Long nHMM ) { return (nHMM * 72 + 63) / 127; }
111 inline ::tools::Long TwipsToEvenHMM( ::tools::Long nTwips ) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
114 // standard size as OLE server (cells)
115 #define OLE_STD_CELLS_X 4
116 #define OLE_STD_CELLS_Y 5
119 // repaint flags (for messages)
120 enum class PaintPartFlags {
121 NONE = 0x00,
122 Grid = 0x01,
123 Top = 0x02,
124 Left = 0x04,
125 Extras = 0x08,
126 Marks = 0x10,
127 Objects = 0x20,
128 Size = 0x40,
129 All = Grid | Top | Left | Extras | Objects | Size,
131 namespace o3tl {
132 template<> struct typed_flags<PaintPartFlags> : is_typed_flags<PaintPartFlags, 0x07f> {};
135 // flags for columns / rows
136 enum class CRFlags : sal_uInt8 {
137 // Filtered always together with Hidden
138 // Filtered and ManualSize only valid for rows
139 NONE = 0x00,
140 Hidden = 0x01,
141 ManualBreak = 0x02,
142 Filtered = 0x04,
143 ManualSize = 0x08,
144 All = Hidden | ManualBreak | Filtered | ManualSize
146 namespace o3tl {
147 template<> struct typed_flags<CRFlags> : is_typed_flags<CRFlags, 0x0f> {};
150 enum class ScBreakType {
151 NONE = 0x00,
152 Page = 0x01,
153 Manual = 0x02
155 namespace o3tl {
156 template<> struct typed_flags<ScBreakType> : is_typed_flags<ScBreakType, 0x03> {};
159 enum class InsertDeleteFlags : sal_uInt16
161 NONE = 0x0000,
162 VALUE = 0x0001, /// Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
163 DATETIME = 0x0002, /// Dates, times, datetime values.
164 STRING = 0x0004, /// Strings (and string results if InsertDeleteFlags::FORMULA is not set).
165 NOTE = 0x0008, /// Cell notes.
166 FORMULA = 0x0010, /// Formula cells.
167 HARDATTR = 0x0020, /// Hard cell attributes.
168 STYLES = 0x0040, /// Cell styles.
169 OBJECTS = 0x0080, /// Drawing objects.
170 EDITATTR = 0x0100, /// Rich-text attributes.
171 OUTLINE = 0x0800, /// Sheet / outlining (grouping) information
172 NOCAPTIONS = 0x0200, /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
173 ADDNOTES = 0x0400, /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
174 SPECIAL_BOOLEAN = 0x1000,
175 FORGETCAPTIONS = 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes.
176 ATTRIB = HARDATTR | STYLES,
177 CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE,
178 ALL = CONTENTS | ATTRIB | OBJECTS,
179 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
180 AUTOFILL = ALL & ~(NOTE | OBJECTS)
182 namespace o3tl
184 template<> struct typed_flags<InsertDeleteFlags> : is_typed_flags<InsertDeleteFlags, 0x3fff> {};
186 // This doesn't work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work.
187 //static_assert((InsertDeleteFlags::ATTRIB & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE, "these must match");
190 enum class ScPasteFunc {
191 NONE, ADD, SUB, MUL, DIV
193 // bits for HasAttr
194 enum class HasAttrFlags {
195 NONE = 0x0000,
196 Lines = 0x0001,
197 Merged = 0x0002,
198 Overlapped = 0x0004,
199 Protected = 0x0008,
200 Shadow = 0x0010,
201 NeedHeight = 0x0020,
202 ShadowRight = 0x0040,
203 ShadowDown = 0x0080,
204 AutoFilter = 0x0100,
205 Conditional = 0x0200,
206 Rotate = 0x0400,
207 NotOverlapped = 0x0800,
208 RightOrCenter = 0x1000, // right or centered logical alignment
210 namespace o3tl {
211 template<> struct typed_flags<HasAttrFlags> : is_typed_flags<HasAttrFlags, 0x1fff> {};
215 #define EMPTY_OUSTRING ScGlobal::GetEmptyOUString()
217 // Layer id's for drawing.
218 // These are both id's and positions.
219 constexpr SdrLayerID SC_LAYER_FRONT (0);
220 constexpr SdrLayerID SC_LAYER_BACK (1);
221 constexpr SdrLayerID SC_LAYER_INTERN (2);
222 constexpr SdrLayerID SC_LAYER_CONTROLS(3);
223 constexpr SdrLayerID SC_LAYER_HIDDEN (4);
225 // link tables
226 enum class ScLinkMode {
227 NONE, NORMAL, VALUE
229 // input
230 enum class ScEnterMode {
231 NORMAL, BLOCK, MATRIX
234 // step = 10pt, max. indention = 100 steps
235 #define SC_INDENT_STEP 200
237 enum class ScScenarioFlags{ // scenario flags
238 NONE = 0,
239 CopyAll = 1,
240 ShowFrame = 2,
241 PrintFrame = 4,
242 TwoWay = 8,
243 Attrib = 16,
244 Value = 32,
245 Protected = 64
247 namespace o3tl {
248 template<> struct typed_flags<ScScenarioFlags> : is_typed_flags<ScScenarioFlags, 127> {};
251 enum class SubtotalFlags {
252 NONE = 0x00,
253 IgnoreNestedStAg = 0x08,
254 IgnoreErrVal = 0x04,
255 IgnoreHidden = 0x02,
256 IgnoreFiltered = 0x01
258 namespace o3tl {
259 template<> struct typed_flags<SubtotalFlags> : is_typed_flags<SubtotalFlags, 0x0f> {};
262 enum class ScCloneFlags{
263 /** Default cell clone flags: do not start listening, do not adjust 3D refs to
264 old position, clone note captions of cell notes. */
265 Default = 0x0000,
267 /** If set, cloned formula cells will start to listen to the document. */
268 StartListening = 0x0001,
270 /** If set, absolute refs will not transformed to external references */
271 NoMakeAbsExternal = 0x0002,
273 /** If set, global named expressions will be converted to sheet-local named
274 expressions. */
275 NamesToLocal = 0x0004
277 namespace o3tl
279 template<> struct typed_flags<ScCloneFlags> : is_typed_flags<ScCloneFlags, 0x0007> {};
282 enum CellType
284 CELLTYPE_NONE,
285 CELLTYPE_VALUE,
286 CELLTYPE_STRING,
287 CELLTYPE_FORMULA,
288 CELLTYPE_EDIT,
291 enum class DelCellCmd
293 CellsUp,
294 CellsLeft,
295 Rows,
296 Cols,
297 NONE
300 enum InsCellCmd
302 INS_CELLSDOWN,
303 INS_CELLSRIGHT,
304 INS_INSROWS_BEFORE,
305 INS_INSCOLS_BEFORE,
306 INS_NONE,
307 INS_INSROWS_AFTER,
308 INS_INSCOLS_AFTER
311 enum UpdateRefMode
313 URM_INSDEL,
314 URM_COPY,
315 URM_MOVE,
316 URM_REORDER
319 enum FillDir
321 FILL_TO_BOTTOM,
322 FILL_TO_RIGHT,
323 FILL_TO_TOP,
324 FILL_TO_LEFT
327 enum FillCmd
329 FILL_SIMPLE,
330 FILL_LINEAR,
331 FILL_GROWTH,
332 FILL_DATE,
333 FILL_AUTO
336 enum ScMoveDirection
338 SC_MOVE_RIGHT,
339 SC_MOVE_LEFT,
340 SC_MOVE_UP,
341 SC_MOVE_DOWN
344 enum FillDateCmd
346 FILL_DAY,
347 FILL_WEEKDAY,
348 FILL_MONTH,
349 FILL_END_OF_MONTH,
350 FILL_YEAR
353 enum ScDirection
355 DIR_BOTTOM,
356 DIR_RIGHT,
357 DIR_TOP,
358 DIR_LEFT
361 enum ScSizeMode
363 SC_SIZE_DIRECT, // set size or hide if value is 0
364 SC_SIZE_OPTIMAL, // set optimal size for everything
365 SC_SIZE_SHOW, // show with original size
366 SC_SIZE_VISOPT, // set optimal size only if visible
367 SC_SIZE_ORIGINAL // only set size, don't change visible flag
370 enum ScInputMode
372 SC_INPUT_NONE,
373 SC_INPUT_TYPE, // input, while not in inplace mode
374 SC_INPUT_TABLE, // text cursor in the table
375 SC_INPUT_TOP // text cursor in the input line
378 enum ScVObjMode // output modes of objects on a page
380 VOBJ_MODE_SHOW,
381 VOBJ_MODE_HIDE
384 enum ScAnchorType // anchor of a character object
386 SCA_CELL, // anchor to cell, move with cell
387 SCA_CELL_RESIZE, // anchor to cell, move and resize with cell
388 SCA_PAGE, // anchor to page, independent of any cells
389 SCA_DONTKNOW // for multi selection
392 enum ScGetDBMode
394 SC_DB_MAKE, ///< create "untitled" (if necessary)
395 SC_DB_AUTOFILTER, ///< force use of sheet-local instead of document global anonymous range
396 SC_DB_IMPORT, ///< create "Importx" (if necessary)
397 SC_DB_OLD ///< don't create
400 /// For ScDBFunc::GetDBData()
401 enum class ScGetDBSelection
403 /** Keep selection as is, expand to used data area if no selection. */
404 Keep,
406 /** Shrink selection to actually used data area within the selection. */
407 ShrinkToUsedData,
409 /** If only one row or portion thereof is selected, shrink row to used data
410 columns and select further rows down until end of data. If an area is
411 selected, shrink rows to actually used columns. Else, no selection,
412 expand to used data area. */
413 RowDown,
415 /** Behave as if the range corresponding to a ScDBData area was selected,
416 for API use. */
417 ForceMark
420 enum ScLkUpdMode // modes for updating links
422 LM_ALWAYS,
423 LM_NEVER,
424 LM_ON_DEMAND,
425 LM_UNKNOWN
428 // enum with values equal to old DBObject enum from sdb
429 enum ScDBObject
431 ScDbTable,
432 ScDbQuery
435 namespace sc {
437 enum class ColRowEditAction
439 Unknown,
440 InsertColumnsBefore,
441 InsertColumnsAfter,
442 InsertRowsBefore,
443 InsertRowsAfter,
444 DeleteColumns,
445 DeleteRows
450 struct ScImportParam
452 SCCOL nCol1;
453 SCROW nRow1;
454 SCCOL nCol2;
455 SCROW nRow2;
456 bool bImport;
457 OUString aDBName; // alias of data base
458 OUString aStatement;
459 bool bNative;
460 bool bSql; // statement or name?
461 sal_uInt8 nType; // enum DBObject
463 ScImportParam();
464 ScImportParam( const ScImportParam& r );
465 ~ScImportParam();
467 ScImportParam& operator= ( const ScImportParam& r );
468 bool operator== ( const ScImportParam& r ) const;
471 class ScDocShell;
472 class SvxSearchItem;
473 class ScAutoFormat;
474 class LegacyFuncCollection;
475 class ScUnoAddInCollection;
476 class ScUserList;
477 class SvxBrushItem;
478 class ScFunctionList;
479 class ScFunctionMgr;
480 class SfxItemPool;
481 class EditTextObject;
482 class SfxObjectShell;
483 class SvNumberFormatter;
484 class ScUnitConverter;
485 class CharClass;
486 class LocaleDataWrapper;
487 class SvtSysLocale;
488 class CalendarWrapper;
489 class CollatorWrapper;
490 class IntlWrapper;
491 class ScFieldEditEngine;
493 namespace com::sun::star {
494 namespace lang {
495 struct Locale;
497 namespace i18n {
498 class XOrdinalSuffix;
501 namespace utl {
502 class TransliterationWrapper;
505 class ScGlobal
507 static std::unique_ptr<SvxSearchItem> xSearchItem;
508 static std::unique_ptr<ScAutoFormat> xAutoFormat;
509 static std::atomic<LegacyFuncCollection*> pLegacyFuncCollection;
510 static std::atomic<ScUnoAddInCollection*> pAddInCollection;
511 static std::unique_ptr<ScUserList> xUserList;
512 static SC_DLLPUBLIC const OUString aEmptyOUString;
513 static OUString aStrClipDocName;
514 static std::unique_ptr<SvxBrushItem> xEmptyBrushItem;
515 static std::unique_ptr<SvxBrushItem> xButtonBrushItem;
517 static std::unique_ptr<ScFunctionList> xStarCalcFunctionList;
518 static std::unique_ptr<ScFunctionMgr> xStarCalcFunctionMgr;
520 static std::atomic<ScUnitConverter*> pUnitConverter;
522 static std::unique_ptr<SvNumberFormatter> xEnglishFormatter; // for UNO / XML export
524 static css::uno::Reference< css::i18n::XOrdinalSuffix> xOrdinalSuffix;
525 static std::unique_ptr<CalendarWrapper> xCalendar;
526 static std::atomic<CollatorWrapper*> pCaseCollator;
527 static std::atomic<CollatorWrapper*> pCollator;
528 static std::atomic<::utl::TransliterationWrapper*> pTransliteration;
529 static std::atomic<::utl::TransliterationWrapper*> pCaseTransliteration;
530 static std::atomic<css::lang::Locale*> pLocale;
532 static std::unique_ptr<ScFieldEditEngine> xFieldEditEngine;
534 static void InitPPT();
536 public:
537 static std::unique_ptr<SvtSysLocale> xSysLocale;
538 SC_DLLPUBLIC static const LocaleDataWrapper* getLocaleDataPtr();
539 SC_DLLPUBLIC static const CharClass* getCharClassPtr();
541 static CalendarWrapper* GetCalendar();
542 SC_DLLPUBLIC static CollatorWrapper* GetCollator();
543 static CollatorWrapper* GetCaseCollator();
544 static css::lang::Locale* GetLocale();
546 SC_DLLPUBLIC static ::utl::TransliterationWrapper* GetpTransliteration();
547 static ::utl::TransliterationWrapper* GetCaseTransliteration();
549 SC_DLLPUBLIC static LanguageType eLnge;
550 static constexpr sal_Unicode cListDelimiter = ',';
552 static const OUString& GetClipDocName();
553 static void SetClipDocName( const OUString& rNew );
554 SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem();
555 SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew );
556 SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat();
557 SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat();
558 static void ClearAutoFormat(); //BugId 54209
559 static LegacyFuncCollection* GetLegacyFuncCollection();
560 SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
561 SC_DLLPUBLIC static ScUserList* GetUserList();
562 static void SetUserList( const ScUserList* pNewList );
564 * Open the specified URL.
565 * @param bIgnoreSettings - If true, ignore security settings (Ctrl-Click) and just open the URL.
567 static void OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgnoreSettings = false);
568 /// Whether the URL can be opened according to current security options (Click/Ctrl-Click)
569 static bool ShouldOpenURL();
570 SC_DLLPUBLIC static OUString GetAbsDocName( const OUString& rFileName,
571 const SfxObjectShell* pShell );
572 SC_DLLPUBLIC static OUString GetDocTabName( const OUString& rFileName,
573 const OUString& rTabName );
574 SC_DLLPUBLIC static sal_uInt32 GetStandardFormat( SvNumberFormatter&, sal_uInt32 nFormat, SvNumFormatType nType );
576 SC_DLLPUBLIC static sal_uInt16 GetStandardRowHeight();
577 /// Horizontal pixel per twips factor.
578 SC_DLLPUBLIC static double nScreenPPTX;
579 /// Vertical pixel per twips factor.
580 SC_DLLPUBLIC static double nScreenPPTY;
582 static tools::SvRef<ScDocShell> xDrawClipDocShellRef;
584 static sal_uInt16 nDefFontHeight;
585 SC_DLLPUBLIC static sal_uInt16 nStdRowHeight;
587 SC_DLLPUBLIC static ::tools::Long nLastRowHeightExtra;
588 static ::tools::Long nLastColWidthExtra;
590 SC_DLLPUBLIC static void Init(); // during start up
591 static void InitAddIns();
592 SC_DLLPUBLIC static void Clear(); // at the end of the program
594 static void InitTextHeight(const SfxItemPool* pPool);
595 static SvxBrushItem* GetEmptyBrushItem() { return xEmptyBrushItem.get(); }
596 static SvxBrushItem* GetButtonBrushItem();
597 static const OUString& GetEmptyOUString() { return aEmptyOUString; }
599 static bool HasStarCalcFunctionList();
600 static ScFunctionList* GetStarCalcFunctionList();
601 static ScFunctionMgr* GetStarCalcFunctionMgr();
602 static void ResetFunctionList();
604 static OUString GetErrorString(FormulaError nErrNumber);
605 static OUString GetLongErrorString(FormulaError nErrNumber);
606 static bool EETextObjEqual( const EditTextObject* pObj1,
607 const EditTextObject* pObj2 );
608 static bool CheckWidthInvalidate( bool& bNumFormatChanged,
609 const SfxItemSet& rNewAttrs,
610 const SfxItemSet& rOldAttrs );
611 static bool HasAttrChanged( const SfxItemSet& rNewAttrs,
612 const SfxItemSet& rOldAttrs,
613 const sal_uInt16 nWhich );
615 static ScUnitConverter* GetUnitConverter();
617 /// strchr() functionality on unicode, as long as we need it for FormulaToken etc.
618 static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
620 static sal_Unicode ToUpperAlpha( sal_Unicode c )
621 { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
623 /** Adds the string rToken to rTokenList, using a list separator character.
624 @param rTokenList The string list where the token will be appended to.
625 @param rToken The token string to append to the token list.
626 @param cSep The character to separate the tokens.
627 @param nSepCount Specifies how often cSep is inserted between two tokens.
628 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
629 SC_DLLPUBLIC static OUString addToken(
630 const OUString& rTokenList, const OUString& rToken,
631 sal_Unicode cSep, sal_Int32 nSepCount = 1,
632 bool bForceSep = false );
634 /** Returns true, if the first and last character of the string is cQuote. */
635 SC_DLLPUBLIC static bool IsQuoted( const OUString& rString, sal_Unicode cQuote );
637 /** Inserts the character cQuote at beginning and end of rString.
638 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
639 escaped by doubling them.
641 SC_DLLPUBLIC static void AddQuotes( OUString& rString, sal_Unicode cQuote, bool bEscapeEmbedded = true );
643 /** Erases the character cQuote from rString, if it exists at beginning AND end.
644 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
645 are unescaped by replacing them with a
646 single instance.
648 SC_DLLPUBLIC static void EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescapeEmbedded = true );
650 /** Finds an unquoted instance of cChar in rString, starting at
651 offset nStart. Unquoted instances may occur when concatenating two
652 quoted strings with a separator, for example, 's1':'s2'. Embedded
653 quotes have to be escaped by being doubled. Caller must ensure that
654 nStart points into an unquoted range or the opening quote. Specialty:
655 if cChar=='\'' the first quote character from nStart on is found.
656 @returns offset if found, else -1
658 SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar, sal_Int32 nStart = 0 );
660 /** Finds an unquoted instance of cChar in null-terminated pString. Same
661 semantics as FindUnquoted( const String&, ...)
662 @returns: pointer to cChar if found, else NULL
664 SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar );
666 static rtl_TextEncoding GetCharsetValue( const OUString& rCharSet );
667 static OUString GetCharsetString( rtl_TextEncoding eVal );
669 /// a "ReadOnly" formatter for UNO/XML export
670 static SvNumberFormatter* GetEnglishFormatter();
672 static bool IsSystemRTL(); // depending on system language
673 static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
674 SC_DLLPUBLIC static SvtScriptType GetDefaultScriptType(); // for all WEAK characters
675 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
676 If more than one SvtScriptType::... values are or'ed together, prefers
677 first COMPLEX, then ASIAN */
678 SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( SvtScriptType nScriptType, sal_uInt16 nWhich );
680 /** Adds a language item to the item set, if the number format item contains
681 a language that differs from its parent's language. */
682 SC_DLLPUBLIC static void AddLanguage( SfxItemSet& rSet, const SvNumberFormatter& rFormatter );
684 /** Obtain the ordinal suffix for a number according to the system locale */
685 static OUString GetOrdinalSuffix( sal_Int32 nNumber);
687 /** A static instance of ScFieldEditEngine not capable of resolving
688 document specific fields, to be used only by ScEditUtil::GetString(). */
689 static ScFieldEditEngine& GetStaticFieldEditEngine();
691 /** Replaces the first occurrence of rPlaceholder in rString with
692 rReplacement, or if rPlaceholder is not found appends one space if
693 rString does not end in a space and appends rReplacement.
695 Meant to be used with resource strings ala "Column %1" where a
696 translation may have omitted the %1 placeholder and a simple
697 replacement would end up with nothing replaced so no column indicator
698 in the result string.
700 SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString,
701 std::u16string_view rPlaceholder,
702 const OUString& rReplacement );
705 /** Convert string content to numeric value.
707 In any case, if rError is set 0.0 is returned.
709 If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally
710 assigned to rError and 0.0 is returned. The caller is expected to
711 handle this situation. Used by the interpreter.
713 Usually FormulaError::NoValue is passed as nStringNoValueError.
715 Otherwise, depending on the string conversion configuration different
716 approaches are taken:
719 For ScCalcConfig::StringConversion::ILLEGAL
720 The error value passed in nStringNoValueError is assigned to rError
721 (and 0.0 returned).
724 For ScCalcConfig::StringConversion::ZERO
725 A zero value is returned and no error assigned.
728 For ScCalcConfig::StringConversion::LOCALE
730 If the string is empty or consists only of spaces, if "treat empty
731 string as zero" is set 0.0 is returned, else nStringNoValueError
732 assigned to rError (and 0.0 returned).
734 Else a non-empty string is passed to the number formatter's scanner to
735 be parsed locale dependent. If that does not detect a numeric value
736 nStringNoValueError is assigned to rError (and 0.0 returned).
738 If no number formatter was passed, the conversion falls back to
739 UNAMBIGUOUS.
742 For ScCalcConfig::StringConversion::UNAMBIGUOUS
744 If the string is empty or consists only of spaces, if "treat empty
745 string as zero" is set 0.0 is returned, else nStringNoValueError
746 assigned to rError (and 0.0 returned).
748 If the string is not empty the following conversion rules are applied:
750 Converted are only integer numbers including exponent, and ISO 8601 dates
751 and times in their extended formats with separators. Anything else,
752 especially fractional numeric values with decimal separators or dates other
753 than ISO 8601 would be locale dependent and is a no-no. Leading and
754 trailing blanks are ignored.
756 The following ISO 8601 formats are converted:
758 CCYY-MM-DD
759 CCYY-MM-DDThh:mm
760 CCYY-MM-DDThh:mm:ss
761 CCYY-MM-DDThh:mm:ss,s
762 CCYY-MM-DDThh:mm:ss.s
763 hh:mm
764 hh:mm:ss
765 hh:mm:ss,s
766 hh:mm:ss.s
768 The century CC may not be omitted and the two-digit year setting is not
769 taken into account. Instead of the T date and time separator exactly one
770 blank may be used.
772 If a date is given, it must be a valid Gregorian calendar date. In this
773 case the optional time must be in the range 00:00 to 23:59:59.99999...
774 If only time is given, it may have any value for hours, taking elapsed time
775 into account; minutes and seconds are limited to the value 59 as well.
777 If the string can not be converted to a numeric value, the error value
778 passed in nStringNoValueError is assigned to rError.
781 @param rStr
782 The string to be converted.
784 @param rConfig
785 The calculation configuration.
787 @param rError
788 Contains the error on return, if any. If an error was set before
789 and the conversion did not result in an error, still 0.0 is
790 returned.
792 @param nStringNoValueError
793 The error value to be assigned to rError if string could not be
794 converted to number.
796 @param pFormatter
797 The number formatter to use in case of
798 ScCalcConfig::StringConversion::LOCALE. Can but should not be
799 nullptr in which case conversion falls back to
800 ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is
801 detected the null date is assumed to be the standard 1899-12-30
802 instead of the configured null date.
804 @param rCurFmtType
805 Can be assigned a format type in case a date or time or date+time
806 string was converted, e.g. SvNumFormatType::DATE or
807 SvNumFormatType::TIME or a combination thereof.
810 static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig,
811 FormulaError & rError, FormulaError nStringNoValueError,
812 SvNumberFormatter* pFormatter, SvNumFormatType & rCurFmtType );
814 /// Calc's threaded group calculation is in progress.
815 SC_DLLPUBLIC static bool bThreadedGroupCalcInProgress;
818 // maybe move to dbdata.hxx (?):
820 enum ScQueryOp
822 SC_EQUAL,
823 SC_LESS,
824 SC_GREATER,
825 SC_LESS_EQUAL,
826 SC_GREATER_EQUAL,
827 SC_NOT_EQUAL,
828 SC_TOPVAL,
829 SC_BOTVAL,
830 SC_TOPPERC,
831 SC_BOTPERC,
832 SC_CONTAINS,
833 SC_DOES_NOT_CONTAIN,
834 SC_BEGINS_WITH,
835 SC_DOES_NOT_BEGIN_WITH,
836 SC_ENDS_WITH,
837 SC_DOES_NOT_END_WITH
840 enum ScQueryConnect
842 SC_AND,
843 SC_OR
846 enum ScSubTotalFunc
848 SUBTOTAL_FUNC_NONE = 0,
849 SUBTOTAL_FUNC_AVE = 1,
850 SUBTOTAL_FUNC_CNT = 2,
851 SUBTOTAL_FUNC_CNT2 = 3,
852 SUBTOTAL_FUNC_MAX = 4,
853 SUBTOTAL_FUNC_MIN = 5,
854 SUBTOTAL_FUNC_PROD = 6,
855 SUBTOTAL_FUNC_STD = 7,
856 SUBTOTAL_FUNC_STDP = 8,
857 SUBTOTAL_FUNC_SUM = 9,
858 SUBTOTAL_FUNC_VAR = 10,
859 SUBTOTAL_FUNC_VARP = 11,
860 SUBTOTAL_FUNC_MED = 12,
861 SUBTOTAL_FUNC_SELECTION_COUNT = 13
864 enum ScAggregateFunc
866 AGGREGATE_FUNC_AVE = 1,
867 AGGREGATE_FUNC_CNT = 2,
868 AGGREGATE_FUNC_CNT2 = 3,
869 AGGREGATE_FUNC_MAX = 4,
870 AGGREGATE_FUNC_MIN = 5,
871 AGGREGATE_FUNC_PROD = 6,
872 AGGREGATE_FUNC_STD = 7,
873 AGGREGATE_FUNC_STDP = 8,
874 AGGREGATE_FUNC_SUM = 9,
875 AGGREGATE_FUNC_VAR = 10,
876 AGGREGATE_FUNC_VARP = 11,
877 AGGREGATE_FUNC_MEDIAN = 12,
878 AGGREGATE_FUNC_MODSNGL = 13,
879 AGGREGATE_FUNC_LARGE = 14,
880 AGGREGATE_FUNC_SMALL = 15,
881 AGGREGATE_FUNC_PERCINC = 16,
882 AGGREGATE_FUNC_QRTINC = 17,
883 AGGREGATE_FUNC_PERCEXC = 18,
884 AGGREGATE_FUNC_QRTEXC = 19
887 class ScArea;
889 struct ScConsolidateParam
891 SCCOL nCol; // cursor position /
892 SCROW nRow; // or start of destination area respectively
893 SCTAB nTab;
894 ScSubTotalFunc eFunction;
895 sal_uInt16 nDataAreaCount; // number of data areas
896 std::unique_ptr<ScArea[]> pDataAreas; // array of pointers into data areas
897 bool bByCol;
898 bool bByRow;
899 bool bReferenceData; // reference source data
901 ScConsolidateParam();
902 ScConsolidateParam( const ScConsolidateParam& r );
903 ~ScConsolidateParam();
905 ScConsolidateParam& operator= ( const ScConsolidateParam& r );
906 bool operator== ( const ScConsolidateParam& r ) const;
907 void Clear (); // = ClearDataAreas()+Members
908 void ClearDataAreas ();
909 void SetAreas ( std::unique_ptr<ScArea[]> pAreas, sal_uInt16 nCount );
912 extern SfxViewShell* pScActiveViewShell;
913 extern sal_uInt16 nScClickMouseModifier;
914 extern sal_uInt16 nScFillModeMouseModifier;
916 #endif
918 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */