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