Bump version to 6.4-15
[LibreOffice.git] / sc / inc / global.hxx
blob0fef008448d585de1748a5cb7a42de04e2882c94
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>
32 #include <atomic>
33 // HACK: <atomic> includes <stdbool.h>, which in some Clang versions does '#define bool bool',
34 // which confuses clang plugins.
35 #undef bool
36 #include <map>
37 #include <memory>
39 namespace com { namespace sun { namespace star { namespace uno { template <typename > class Reference; } } } }
41 class SfxItemSet;
42 class SfxViewShell;
43 struct ScCalcConfig;
44 enum class SvtScriptType;
45 enum class FormulaError : sal_uInt16;
46 enum class SvNumFormatType : sal_Int16;
48 #define SC_COLLATOR_IGNORES css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE
50 // Calc has lots of names...
51 // Clipboard names are in so3/soapp.hxx now
52 // STRING_SCAPP was "scalc3", "scalc4", now just "scalc"
54 #define STRING_SCAPP "scalc"
56 #define STRING_STANDARD "Standard"
58 // Have the dreaded programmatic filter name defined in one place.
59 #define SC_TEXT_CSV_FILTER_NAME "Text - txt - csv (StarCalc)"
61 // characters
63 const sal_Unicode CHAR_NBSP = 0x00A0;
64 const sal_Unicode CHAR_SHY = 0x00AD;
65 const sal_Unicode CHAR_ZWSP = 0x200B;
66 const sal_Unicode CHAR_LRM = 0x200E;
67 const sal_Unicode CHAR_RLM = 0x200F;
68 const sal_Unicode CHAR_NBHY = 0x2011;
69 const sal_Unicode CHAR_ZWNBSP = 0x2060;
70 const sal_Unicode CHAR_NNBSP = 0x202F; //NARROW NO-BREAK SPACE
72 #define MINDOUBLE 1.7e-307
73 #define MAXDOUBLE 1.7e307
75 #define MINZOOM 20
76 #define MAXZOOM 400
78 const SCSIZE MAXSUBTOTAL = 3;
80 #define PIXEL_PER_INCH 96.0
81 #define CM_PER_INCH 2.54
82 #define POINTS_PER_INCH 72.0 /**< PostScript points per inch */
83 #define PIXEL_PER_POINT (PIXEL_PER_INCH / POINTS_PER_INCH)
84 #define TWIPS_PER_POINT 20.0
85 #define TWIPS_PER_INCH (TWIPS_PER_POINT * POINTS_PER_INCH)
86 #define TWIPS_PER_CM (TWIPS_PER_INCH / CM_PER_INCH)
87 #define CM_PER_TWIPS (CM_PER_INCH / TWIPS_PER_INCH)
88 #define TWIPS_PER_PIXEL (TWIPS_PER_INCH / PIXEL_PER_INCH)
89 #define TWIPS_PER_CHAR (TWIPS_PER_INCH / 13.6)
90 #define PIXEL_PER_TWIPS (PIXEL_PER_INCH / TWIPS_PER_INCH)
91 #define HMM_PER_TWIPS (CM_PER_TWIPS * 1000.0)
93 #define STD_COL_WIDTH 1280 /* 2.2577cm, 64.00pt PS */
94 #define STD_EXTRA_WIDTH 113 /* 2mm extra for optimal width,
95 * 0.1986cm with TeX points,
96 * 0.1993cm with PS points. */
98 #define MAX_EXTRA_WIDTH 23811 /* 42cm in TWIPS, 41.8430cm TeX, 41.9999cm PS */
99 #define MAX_EXTRA_HEIGHT 23811
100 #define MAX_COL_WIDTH 56693 /* 1m in TWIPS, 99.6266cm TeX, 100.0001cm PS */
101 #define MAX_ROW_HEIGHT 56693
103 /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
104 #define STD_ROWHEIGHT_DIFF 23
106 namespace sc
108 inline long TwipsToHMM( long nTwips ) { return (nTwips * 127 + 36) / 72; }
109 inline long HMMToTwips( long nHMM ) { return (nHMM * 72 + 63) / 127; }
110 inline long TwipsToEvenHMM( long nTwips ) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
113 // standard size as OLE server (cells)
114 #define OLE_STD_CELLS_X 4
115 #define OLE_STD_CELLS_Y 5
118 // repaint flags (for messages)
119 enum class PaintPartFlags {
120 NONE = 0x00,
121 Grid = 0x01,
122 Top = 0x02,
123 Left = 0x04,
124 Extras = 0x08,
125 Marks = 0x10,
126 Objects = 0x20,
127 Size = 0x40,
128 All = Grid | Top | Left | Extras | Objects | Size,
130 namespace o3tl {
131 template<> struct typed_flags<PaintPartFlags> : is_typed_flags<PaintPartFlags, 0x07f> {};
134 // flags for columns / rows
135 enum class CRFlags : sal_uInt8 {
136 // Filtered always together with Hidden
137 // Filtered and ManualSize only valid for rows
138 NONE = 0x00,
139 Hidden = 0x01,
140 ManualBreak = 0x02,
141 Filtered = 0x04,
142 ManualSize = 0x08,
143 All = Hidden | ManualBreak | Filtered | ManualSize
145 namespace o3tl {
146 template<> struct typed_flags<CRFlags> : is_typed_flags<CRFlags, 0x0f> {};
149 enum class ScBreakType {
150 NONE = 0x00,
151 Page = 0x01,
152 Manual = 0x02
154 namespace o3tl {
155 template<> struct typed_flags<ScBreakType> : is_typed_flags<ScBreakType, 0x03> {};
158 enum class InsertDeleteFlags : sal_uInt16
160 NONE = 0x0000,
161 VALUE = 0x0001, /// Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
162 DATETIME = 0x0002, /// Dates, times, datetime values.
163 STRING = 0x0004, /// Strings (and string results if InsertDeleteFlags::FORMULA is not set).
164 NOTE = 0x0008, /// Cell notes.
165 FORMULA = 0x0010, /// Formula cells.
166 HARDATTR = 0x0020, /// Hard cell attributes.
167 STYLES = 0x0040, /// Cell styles.
168 OBJECTS = 0x0080, /// Drawing objects.
169 EDITATTR = 0x0100, /// Rich-text attributes.
170 OUTLINE = 0x0800, /// Sheet / outlining (grouping) information
171 NOCAPTIONS = 0x0200, /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
172 ADDNOTES = 0x0400, /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
173 SPECIAL_BOOLEAN = 0x1000,
174 FORGETCAPTIONS = 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes.
175 ATTRIB = HARDATTR | STYLES,
176 CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE,
177 ALL = CONTENTS | ATTRIB | OBJECTS,
178 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
179 AUTOFILL = ALL & ~(NOTE | OBJECTS)
181 namespace o3tl
183 template<> struct typed_flags<InsertDeleteFlags> : is_typed_flags<InsertDeleteFlags, 0x3fff> {};
185 // This doesn't work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work.
186 //static_assert((InsertDeleteFlags::ATTRIB & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE, "these must match");
189 enum class ScPasteFunc {
190 NONE, ADD, SUB, MUL, DIV
192 // bits for HasAttr
193 enum class HasAttrFlags {
194 NONE = 0x0000,
195 Lines = 0x0001,
196 Merged = 0x0002,
197 Overlapped = 0x0004,
198 Protected = 0x0008,
199 Shadow = 0x0010,
200 NeedHeight = 0x0020,
201 ShadowRight = 0x0040,
202 ShadowDown = 0x0080,
203 AutoFilter = 0x0100,
204 Conditional = 0x0200,
205 Rotate = 0x0400,
206 NotOverlapped = 0x0800,
207 RightOrCenter = 0x1000, // right or centered logical alignment
209 namespace o3tl {
210 template<> struct typed_flags<HasAttrFlags> : is_typed_flags<HasAttrFlags, 0x1fff> {};
214 #define EMPTY_OUSTRING ScGlobal::GetEmptyOUString()
216 // Layer id's for drawing.
217 // These are both id's and positions.
218 constexpr SdrLayerID SC_LAYER_FRONT (0);
219 constexpr SdrLayerID SC_LAYER_BACK (1);
220 constexpr SdrLayerID SC_LAYER_INTERN (2);
221 constexpr SdrLayerID SC_LAYER_CONTROLS(3);
222 constexpr SdrLayerID SC_LAYER_HIDDEN (4);
224 // link tables
225 enum class ScLinkMode {
226 NONE, NORMAL, VALUE
228 // input
229 enum class ScEnterMode {
230 NORMAL, BLOCK, MATRIX
233 // step = 10pt, max. indention = 100 steps
234 #define SC_INDENT_STEP 200
236 enum class ScScenarioFlags{ // scenario flags
237 NONE = 0,
238 CopyAll = 1,
239 ShowFrame = 2,
240 PrintFrame = 4,
241 TwoWay = 8,
242 Attrib = 16,
243 Value = 32,
244 Protected = 64
246 namespace o3tl {
247 template<> struct typed_flags<ScScenarioFlags> : is_typed_flags<ScScenarioFlags, 127> {};
250 enum class SubtotalFlags {
251 NONE = 0x00,
252 IgnoreNestedStAg = 0x08,
253 IgnoreErrVal = 0x04,
254 IgnoreHidden = 0x02,
255 IgnoreFiltered = 0x01
257 namespace o3tl {
258 template<> struct typed_flags<SubtotalFlags> : is_typed_flags<SubtotalFlags, 0x0f> {};
261 enum class ScCloneFlags{
262 /** Default cell clone flags: do not start listening, do not adjust 3D refs to
263 old position, clone note captions of cell notes. */
264 Default = 0x0000,
266 /** If set, cloned formula cells will start to listen to the document. */
267 StartListening = 0x0001,
269 /** If set, absolute refs will not transformed to external references */
270 NoMakeAbsExternal = 0x0002,
272 /** If set, global named expressions will be converted to sheet-local named
273 expressions. */
274 NamesToLocal = 0x0004
276 namespace o3tl
278 template<> struct typed_flags<ScCloneFlags> : is_typed_flags<ScCloneFlags, 0x0007> {};
281 enum CellType
283 CELLTYPE_NONE,
284 CELLTYPE_VALUE,
285 CELLTYPE_STRING,
286 CELLTYPE_FORMULA,
287 CELLTYPE_EDIT,
290 enum class DelCellCmd
292 CellsUp,
293 CellsLeft,
294 Rows,
295 Cols,
296 NONE
299 enum InsCellCmd
301 INS_CELLSDOWN,
302 INS_CELLSRIGHT,
303 INS_INSROWS_BEFORE,
304 INS_INSCOLS_BEFORE,
305 INS_NONE,
306 INS_INSROWS_AFTER,
307 INS_INSCOLS_AFTER
310 enum UpdateRefMode
312 URM_INSDEL,
313 URM_COPY,
314 URM_MOVE,
315 URM_REORDER
318 enum FillDir
320 FILL_TO_BOTTOM,
321 FILL_TO_RIGHT,
322 FILL_TO_TOP,
323 FILL_TO_LEFT
326 enum FillCmd
328 FILL_SIMPLE,
329 FILL_LINEAR,
330 FILL_GROWTH,
331 FILL_DATE,
332 FILL_AUTO
335 enum ScMoveDirection
337 SC_MOVE_RIGHT,
338 SC_MOVE_LEFT,
339 SC_MOVE_UP,
340 SC_MOVE_DOWN
343 enum FillDateCmd
345 FILL_DAY,
346 FILL_WEEKDAY,
347 FILL_MONTH,
348 FILL_YEAR
351 enum ScDirection
353 DIR_BOTTOM,
354 DIR_RIGHT,
355 DIR_TOP,
356 DIR_LEFT
359 enum ScSizeMode
361 SC_SIZE_DIRECT, // set size or hide if value is 0
362 SC_SIZE_OPTIMAL, // set optimal size for everything
363 SC_SIZE_SHOW, // show with original size
364 SC_SIZE_VISOPT, // set optimal size only if visible
365 SC_SIZE_ORIGINAL // only set size, don't change visible flag
368 enum ScInputMode
370 SC_INPUT_NONE,
371 SC_INPUT_TYPE, // input, while not in inplace mode
372 SC_INPUT_TABLE, // text cursor in the table
373 SC_INPUT_TOP // text cursor in the input line
376 enum ScVObjMode // output modes of objects on a page
378 VOBJ_MODE_SHOW,
379 VOBJ_MODE_HIDE
382 enum ScAnchorType // anchor of a character object
384 SCA_CELL, // anchor to cell, move with cell
385 SCA_CELL_RESIZE, // anchor to cell, move and resize with cell
386 SCA_PAGE, // anchor to page, independent of any cells
387 SCA_DONTKNOW // for multi selection
390 enum ScGetDBMode
392 SC_DB_MAKE, ///< create "untitled" (if necessary)
393 SC_DB_AUTOFILTER, ///< force use of sheet-local instead of document global anonymous range
394 SC_DB_IMPORT, ///< create "Importx" (if necessary)
395 SC_DB_OLD ///< don't create
398 /// For ScDBFunc::GetDBData()
399 enum class ScGetDBSelection
401 /** Keep selection as is, expand to used data area if no selection. */
402 Keep,
404 /** Shrink selection to actually used data area within the selection. */
405 ShrinkToUsedData,
407 /** If only one row or portion thereof is selected, shrink row to used data
408 columns and select further rows down until end of data. If an area is
409 selected, shrink rows to actually used columns. Else, no selection,
410 expand to used data area. */
411 RowDown,
413 /** Behave as if the range corresponding to a ScDBData area was selected,
414 for API use. */
415 ForceMark
418 enum ScLkUpdMode // modes for updating links
420 LM_ALWAYS,
421 LM_NEVER,
422 LM_ON_DEMAND,
423 LM_UNKNOWN
426 // enum with values equal to old DBObject enum from sdb
427 enum ScDBObject
429 ScDbTable,
430 ScDbQuery
433 namespace sc {
435 enum class ColRowEditAction
437 Unknown,
438 InsertColumnsBefore,
439 InsertColumnsAfter,
440 InsertRowsBefore,
441 InsertRowsAfter,
442 DeleteColumns,
443 DeleteRows
448 struct ScImportParam
450 SCCOL nCol1;
451 SCROW nRow1;
452 SCCOL nCol2;
453 SCROW nRow2;
454 bool bImport;
455 OUString aDBName; // alias of data base
456 OUString aStatement;
457 bool bNative;
458 bool bSql; // statement or name?
459 sal_uInt8 nType; // enum DBObject
461 ScImportParam();
462 ScImportParam( const ScImportParam& r );
463 ~ScImportParam();
465 ScImportParam& operator= ( const ScImportParam& r );
466 bool operator== ( const ScImportParam& r ) const;
469 class ScDocShell;
470 class SvxSearchItem;
471 class ScAutoFormat;
472 class LegacyFuncCollection;
473 class ScUnoAddInCollection;
474 class ScUserList;
475 class SvxBrushItem;
476 class ScFunctionList;
477 class ScFunctionMgr;
478 class SfxItemPool;
479 class EditTextObject;
480 class SfxObjectShell;
481 class SvNumberFormatter;
482 class ScUnitConverter;
483 class CharClass;
484 class LocaleDataWrapper;
485 class SvtSysLocale;
486 class CalendarWrapper;
487 class CollatorWrapper;
488 class IntlWrapper;
489 class ScFieldEditEngine;
491 namespace com { namespace sun { namespace star {
492 namespace lang {
493 struct Locale;
495 namespace i18n {
496 class XOrdinalSuffix;
499 namespace utl {
500 class TransliterationWrapper;
503 class ScGlobal
505 static SvxSearchItem* pSearchItem;
506 static ScAutoFormat* pAutoFormat;
507 static std::atomic<LegacyFuncCollection*> pLegacyFuncCollection;
508 static std::atomic<ScUnoAddInCollection*> pAddInCollection;
509 static ScUserList* pUserList;
510 static std::map<const char*, OUString>* pRscString;
511 static OUString* pStrScDoc;
512 static SC_DLLPUBLIC const OUString aEmptyOUString;
513 static OUString* pStrClipDocName;
514 static SvxBrushItem* pEmptyBrushItem;
515 static SvxBrushItem* pButtonBrushItem;
516 static SvxBrushItem* pEmbeddedBrushItem;
518 static ScFunctionList* pStarCalcFunctionList;
519 static ScFunctionMgr* pStarCalcFunctionMgr;
521 static std::atomic<ScUnitConverter*> pUnitConverter;
523 static SvNumberFormatter* pEnglishFormatter; // for UNO / XML export
525 static css::uno::Reference< css::i18n::XOrdinalSuffix> xOrdinalSuffix;
526 static CalendarWrapper* pCalendar;
527 static std::atomic<CollatorWrapper*> pCaseCollator;
528 static std::atomic<CollatorWrapper*> pCollator;
529 static std::atomic<::utl::TransliterationWrapper*> pTransliteration;
530 static std::atomic<::utl::TransliterationWrapper*> pCaseTransliteration;
531 static IntlWrapper* pScIntlWrapper;
532 static std::atomic<css::lang::Locale*> pLocale;
534 static ScFieldEditEngine* pFieldEditEngine;
536 static void InitPPT();
538 public:
539 static SvtSysLocale* pSysLocale;
540 // for faster access a pointer to the single instance provided by SvtSysLocale
541 SC_DLLPUBLIC static const CharClass* pCharClass;
542 // for faster access a pointer to the single instance provided by SvtSysLocale
543 SC_DLLPUBLIC static const LocaleDataWrapper* pLocaleData;
544 SC_DLLPUBLIC static const LocaleDataWrapper* GetpLocaleData();
546 static CalendarWrapper* GetCalendar();
547 SC_DLLPUBLIC static CollatorWrapper* GetCollator();
548 static CollatorWrapper* GetCaseCollator();
549 static css::lang::Locale* GetLocale();
551 SC_DLLPUBLIC static ::utl::TransliterationWrapper* GetpTransliteration();
552 static ::utl::TransliterationWrapper* GetCaseTransliteration();
554 SC_DLLPUBLIC static LanguageType eLnge;
555 static constexpr sal_Unicode cListDelimiter = ',';
557 static const OUString& GetClipDocName();
558 static void SetClipDocName( const OUString& rNew );
559 SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem();
560 SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew );
561 SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat();
562 SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat();
563 static void ClearAutoFormat(); //BugId 54209
564 static LegacyFuncCollection* GetLegacyFuncCollection();
565 SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
566 SC_DLLPUBLIC static ScUserList* GetUserList();
567 static void SetUserList( const ScUserList* pNewList );
569 * Open the specified URL.
570 * @param bIgnoreSettings - If true, ignore security settings (Ctrl-Click) and just open the URL.
572 static void OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgnoreSettings = false);
573 /// Whether the URL can be opened according to current security options (Click/Ctrl-Click)
574 static bool ShouldOpenURL();
575 SC_DLLPUBLIC static OUString GetAbsDocName( const OUString& rFileName,
576 const SfxObjectShell* pShell );
577 SC_DLLPUBLIC static OUString GetDocTabName( const OUString& rFileName,
578 const OUString& rTabName );
579 SC_DLLPUBLIC static sal_uInt32 GetStandardFormat( SvNumberFormatter&, sal_uInt32 nFormat, SvNumFormatType nType );
581 SC_DLLPUBLIC static sal_uInt16 GetStandardRowHeight();
582 /// Horizontal pixel per twips factor.
583 SC_DLLPUBLIC static double nScreenPPTX;
584 /// Vertical pixel per twips factor.
585 SC_DLLPUBLIC static double nScreenPPTY;
587 static tools::SvRef<ScDocShell> xDrawClipDocShellRef;
589 static sal_uInt16 nDefFontHeight;
590 SC_DLLPUBLIC static sal_uInt16 nStdRowHeight;
592 SC_DLLPUBLIC static long nLastRowHeightExtra;
593 static long nLastColWidthExtra;
595 SC_DLLPUBLIC static void Init(); // during start up
596 static void InitAddIns();
597 static void Clear(); // at the end of the program
599 static void InitTextHeight(const SfxItemPool* pPool);
600 static SvxBrushItem* GetEmptyBrushItem() { return pEmptyBrushItem; }
601 static SvxBrushItem* GetButtonBrushItem();
602 static const OUString& GetEmptyOUString() { return aEmptyOUString; }
604 static bool HasStarCalcFunctionList();
605 static ScFunctionList* GetStarCalcFunctionList();
606 static ScFunctionMgr* GetStarCalcFunctionMgr();
607 static void ResetFunctionList();
609 static OUString GetErrorString(FormulaError nErrNumber);
610 static OUString GetLongErrorString(FormulaError nErrNumber);
611 static bool EETextObjEqual( const EditTextObject* pObj1,
612 const EditTextObject* pObj2 );
613 static bool CheckWidthInvalidate( bool& bNumFormatChanged,
614 const SfxItemSet& rNewAttrs,
615 const SfxItemSet& rOldAttrs );
616 static bool HasAttrChanged( const SfxItemSet& rNewAttrs,
617 const SfxItemSet& rOldAttrs,
618 const sal_uInt16 nWhich );
620 static ScUnitConverter* GetUnitConverter();
622 /// strchr() functionality on unicode, as long as we need it for FormulaToken etc.
623 static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
625 static sal_Unicode ToUpperAlpha( sal_Unicode c )
626 { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
628 /** Adds the string rToken to rTokenList, using a list separator character.
629 @param rTokenList The string list where the token will be appended to.
630 @param rToken The token string to append to the token list.
631 @param cSep The character to separate the tokens.
632 @param nSepCount Specifies how often cSep is inserted between two tokens.
633 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
634 SC_DLLPUBLIC static OUString addToken(
635 const OUString& rTokenList, const OUString& rToken,
636 sal_Unicode cSep, sal_Int32 nSepCount = 1,
637 bool bForceSep = false );
639 /** Returns true, if the first and last character of the string is cQuote. */
640 SC_DLLPUBLIC static bool IsQuoted( const OUString& rString, sal_Unicode cQuote );
642 /** Inserts the character cQuote at beginning and end of rString.
643 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
644 escaped by doubling them.
646 SC_DLLPUBLIC static void AddQuotes( OUString& rString, sal_Unicode cQuote, bool bEscapeEmbedded = true );
648 /** Erases the character cQuote from rString, if it exists at beginning AND end.
649 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
650 are unescaped by replacing them with a
651 single instance.
653 SC_DLLPUBLIC static void EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescapeEmbedded = true );
655 /** Finds an unquoted instance of cChar in rString, starting at
656 offset nStart. Unquoted instances may occur when concatenating two
657 quoted strings with a separator, for example, 's1':'s2'. Embedded
658 quotes have to be escaped by being doubled. Caller must ensure that
659 nStart points into an unquoted range or the opening quote. Specialty:
660 if cChar==cQuote the first cQuote character from nStart on is found.
661 @returns offset if found, else -1
663 SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar);
665 /** Finds an unquoted instance of cChar in null-terminated pString. Same
666 semantics as FindUnquoted( const String&, ...)
667 @returns: pointer to cChar if found, else NULL
669 SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar );
671 static rtl_TextEncoding GetCharsetValue( const OUString& rCharSet );
672 static OUString GetCharsetString( rtl_TextEncoding eVal );
674 /// a "ReadOnly" formatter for UNO/XML export
675 static SvNumberFormatter* GetEnglishFormatter();
677 static bool IsSystemRTL(); // depending on system language
678 static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
679 SC_DLLPUBLIC static SvtScriptType GetDefaultScriptType(); // for all WEAK characters
680 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
681 If more than one SvtScriptType::... values are or'ed together, prefers
682 first COMPLEX, then ASIAN */
683 SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( SvtScriptType nScriptType, sal_uInt16 nWhich );
685 /** Adds a language item to the item set, if the number format item contains
686 a language that differs from its parent's language. */
687 SC_DLLPUBLIC static void AddLanguage( SfxItemSet& rSet, const SvNumberFormatter& rFormatter );
689 /** Obtain the ordinal suffix for a number according to the system locale */
690 static OUString GetOrdinalSuffix( sal_Int32 nNumber);
692 /** A static instance of ScFieldEditEngine not capable of resolving
693 document specific fields, to be used only by ScEditUtil::GetString(). */
694 static ScFieldEditEngine& GetStaticFieldEditEngine();
696 /** Replaces the first occurrence of rPlaceholder in rString with
697 rReplacement, or if rPlaceholder is not found appends one space if
698 rString does not end in a space and appends rReplacement.
700 Meant to be used with resource strings ala "Column %1" where a
701 translation may have omitted the %1 placeholder and a simple
702 replacement would end up with nothing replaced so no column indicator
703 in the result string.
705 SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString,
706 const OUString& rPlaceholder,
707 const OUString& rReplacement );
710 /** Convert string content to numeric value.
712 In any case, if rError is set 0.0 is returned.
714 If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally
715 assigned to rError and 0.0 is returned. The caller is expected to
716 handle this situation. Used by the interpreter.
718 Usually FormulaError::NoValue is passed as nStringNoValueError.
720 Otherwise, depending on the string conversion configuration different
721 approaches are taken:
724 For ScCalcConfig::StringConversion::ILLEGAL
725 The error value passed in nStringNoValueError is assigned to rError
726 (and 0.0 returned).
729 For ScCalcConfig::StringConversion::ZERO
730 A zero value is returned and no error assigned.
733 For ScCalcConfig::StringConversion::LOCALE
735 If the string is empty or consists only of spaces, if "treat empty
736 string as zero" is set 0.0 is returned, else nStringNoValueError
737 assigned to rError (and 0.0 returned).
739 Else a non-empty string is passed to the number formatter's scanner to
740 be parsed locale dependent. If that does not detect a numeric value
741 nStringNoValueError is assigned to rError (and 0.0 returned).
743 If no number formatter was passed, the conversion falls back to
744 UNAMBIGUOUS.
747 For ScCalcConfig::StringConversion::UNAMBIGUOUS
749 If the string is empty or consists only of spaces, if "treat empty
750 string as zero" is set 0.0 is returned, else nStringNoValueError
751 assigned to rError (and 0.0 returned).
753 If the string is not empty the following conversion rules are applied:
755 Converted are only integer numbers including exponent, and ISO 8601 dates
756 and times in their extended formats with separators. Anything else,
757 especially fractional numeric values with decimal separators or dates other
758 than ISO 8601 would be locale dependent and is a no-no. Leading and
759 trailing blanks are ignored.
761 The following ISO 8601 formats are converted:
763 CCYY-MM-DD
764 CCYY-MM-DDThh:mm
765 CCYY-MM-DDThh:mm:ss
766 CCYY-MM-DDThh:mm:ss,s
767 CCYY-MM-DDThh:mm:ss.s
768 hh:mm
769 hh:mm:ss
770 hh:mm:ss,s
771 hh:mm:ss.s
773 The century CC may not be omitted and the two-digit year setting is not
774 taken into account. Instead of the T date and time separator exactly one
775 blank may be used.
777 If a date is given, it must be a valid Gregorian calendar date. In this
778 case the optional time must be in the range 00:00 to 23:59:59.99999...
779 If only time is given, it may have any value for hours, taking elapsed time
780 into account; minutes and seconds are limited to the value 59 as well.
782 If the string can not be converted to a numeric value, the error value
783 passed in nStringNoValueError is assigned to rError.
786 @param rStr
787 The string to be converted.
789 @param rConfig
790 The calculation configuration.
792 @param rError
793 Contains the error on return, if any. If an error was set before
794 and the conversion did not result in an error, still 0.0 is
795 returned.
797 @param nStringNoValueError
798 The error value to be assigned to rError if string could not be
799 converted to number.
801 @param pFormatter
802 The number formatter to use in case of
803 ScCalcConfig::StringConversion::LOCALE. Can but should not be
804 nullptr in which case conversion falls back to
805 ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is
806 detected the null date is assumed to be the standard 1899-12-30
807 instead of the configured null date.
809 @param rCurFmtType
810 Can be assigned a format type in case a date or time or date+time
811 string was converted, e.g. SvNumFormatType::DATE or
812 SvNumFormatType::TIME or a combination thereof.
815 static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig,
816 FormulaError & rError, FormulaError nStringNoValueError,
817 SvNumberFormatter* pFormatter, SvNumFormatType & rCurFmtType );
819 /// Calc's threaded group calculation is in progress.
820 SC_DLLPUBLIC static bool bThreadedGroupCalcInProgress;
823 // maybe move to dbdata.hxx (?):
825 enum ScQueryOp
827 SC_EQUAL,
828 SC_LESS,
829 SC_GREATER,
830 SC_LESS_EQUAL,
831 SC_GREATER_EQUAL,
832 SC_NOT_EQUAL,
833 SC_TOPVAL,
834 SC_BOTVAL,
835 SC_TOPPERC,
836 SC_BOTPERC,
837 SC_CONTAINS,
838 SC_DOES_NOT_CONTAIN,
839 SC_BEGINS_WITH,
840 SC_DOES_NOT_BEGIN_WITH,
841 SC_ENDS_WITH,
842 SC_DOES_NOT_END_WITH
845 enum ScQueryConnect
847 SC_AND,
848 SC_OR
851 enum ScSubTotalFunc
853 SUBTOTAL_FUNC_NONE = 0,
854 SUBTOTAL_FUNC_AVE = 1,
855 SUBTOTAL_FUNC_CNT = 2,
856 SUBTOTAL_FUNC_CNT2 = 3,
857 SUBTOTAL_FUNC_MAX = 4,
858 SUBTOTAL_FUNC_MIN = 5,
859 SUBTOTAL_FUNC_PROD = 6,
860 SUBTOTAL_FUNC_STD = 7,
861 SUBTOTAL_FUNC_STDP = 8,
862 SUBTOTAL_FUNC_SUM = 9,
863 SUBTOTAL_FUNC_VAR = 10,
864 SUBTOTAL_FUNC_VARP = 11,
865 SUBTOTAL_FUNC_MED = 12,
866 SUBTOTAL_FUNC_SELECTION_COUNT = 13
869 enum ScAggregateFunc
871 AGGREGATE_FUNC_AVE = 1,
872 AGGREGATE_FUNC_CNT = 2,
873 AGGREGATE_FUNC_CNT2 = 3,
874 AGGREGATE_FUNC_MAX = 4,
875 AGGREGATE_FUNC_MIN = 5,
876 AGGREGATE_FUNC_PROD = 6,
877 AGGREGATE_FUNC_STD = 7,
878 AGGREGATE_FUNC_STDP = 8,
879 AGGREGATE_FUNC_SUM = 9,
880 AGGREGATE_FUNC_VAR = 10,
881 AGGREGATE_FUNC_VARP = 11,
882 AGGREGATE_FUNC_MEDIAN = 12,
883 AGGREGATE_FUNC_MODSNGL = 13,
884 AGGREGATE_FUNC_LARGE = 14,
885 AGGREGATE_FUNC_SMALL = 15,
886 AGGREGATE_FUNC_PERCINC = 16,
887 AGGREGATE_FUNC_QRTINC = 17,
888 AGGREGATE_FUNC_PERCEXC = 18,
889 AGGREGATE_FUNC_QRTEXC = 19
892 class ScArea;
894 struct ScConsolidateParam
896 SCCOL nCol; // cursor position /
897 SCROW nRow; // or start of destination area respectively
898 SCTAB nTab;
899 ScSubTotalFunc eFunction;
900 sal_uInt16 nDataAreaCount; // number of data areas
901 std::unique_ptr<ScArea[]> pDataAreas; // array of pointers into data areas
902 bool bByCol;
903 bool bByRow;
904 bool bReferenceData; // reference source data
906 ScConsolidateParam();
907 ScConsolidateParam( const ScConsolidateParam& r );
908 ~ScConsolidateParam();
910 ScConsolidateParam& operator= ( const ScConsolidateParam& r );
911 bool operator== ( const ScConsolidateParam& r ) const;
912 void Clear (); // = ClearDataAreas()+Members
913 void ClearDataAreas ();
914 void SetAreas ( std::unique_ptr<ScArea[]> pAreas, sal_uInt16 nCount );
917 extern SfxViewShell* pScActiveViewShell;
918 extern sal_uInt16 nScClickMouseModifier;
919 extern sal_uInt16 nScFillModeMouseModifier;
921 #endif
923 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */