LOK: tilebench improvements
[LibreOffice.git] / sc / inc / global.hxx
blobfdb05f367094964c9d30dba82cf078e7cedeb2ca
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 <map>
32 #include <vector>
34 class Bitmap;
35 class SfxItemSet;
36 class SfxViewShell;
37 class Color;
38 struct ScCalcConfig;
39 enum class SvtScriptType;
40 enum class FormulaError : sal_uInt16;
41 enum class SvNumFormatType : sal_Int16;
43 #define SC_COLLATOR_IGNORES css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE
45 #define SC_TRANSLITERATION_IGNORECASE TransliterationFlags::IGNORE_CASE
46 #define SC_TRANSLITERATION_CASESENSE TransliterationFlags::NONE
48 // Calc has lots of names...
49 // Clipboard names are in so3/soapp.hxx now
50 // STRING_SCAPP was "scalc3", "scalc4", now just "scalc"
52 #define STRING_SCAPP "scalc"
54 #define STRING_STANDARD "Standard"
56 // characters
58 const sal_Unicode CHAR_NBSP = 0x00A0;
59 const sal_Unicode CHAR_SHY = 0x00AD;
60 const sal_Unicode CHAR_ZWSP = 0x200B;
61 const sal_Unicode CHAR_LRM = 0x200E;
62 const sal_Unicode CHAR_RLM = 0x200F;
63 const sal_Unicode CHAR_NBHY = 0x2011;
64 const sal_Unicode CHAR_ZWNBSP = 0x2060;
66 #define MINDOUBLE 1.7e-307
67 #define MAXDOUBLE 1.7e307
69 #define MINZOOM 20
70 #define MAXZOOM 400
72 const SCSIZE MAXSUBTOTAL = 3;
74 #define PIXEL_PER_INCH 96.0
75 #define CM_PER_INCH 2.54
76 #define POINTS_PER_INCH 72.0 /**< PostScript points per inch */
77 #define PIXEL_PER_POINT (PIXEL_PER_INCH / POINTS_PER_INCH)
78 #define TWIPS_PER_POINT 20.0
79 #define TWIPS_PER_INCH (TWIPS_PER_POINT * POINTS_PER_INCH)
80 #define TWIPS_PER_CM (TWIPS_PER_INCH / CM_PER_INCH)
81 #define CM_PER_TWIPS (CM_PER_INCH / TWIPS_PER_INCH)
82 #define TWIPS_PER_PIXEL (TWIPS_PER_INCH / PIXEL_PER_INCH)
83 #define TWIPS_PER_CHAR (TWIPS_PER_INCH / 13.6)
84 #define PIXEL_PER_TWIPS (PIXEL_PER_INCH / TWIPS_PER_INCH)
85 #define HMM_PER_TWIPS (CM_PER_TWIPS * 1000.0)
87 #define STD_COL_WIDTH 1280 /* 2.2577cm, 64.00pt PS */
88 #define STD_EXTRA_WIDTH 113 /* 2mm extra for optimal width,
89 * 0.1986cm with TeX points,
90 * 0.1993cm with PS points. */
92 #define MAX_EXTRA_WIDTH 23811 /* 42cm in TWIPS, 41.8430cm TeX, 41.9999cm PS */
93 #define MAX_EXTRA_HEIGHT 23811
94 #define MAX_COL_WIDTH 56693 /* 1m in TWIPS, 99.6266cm TeX, 100.0001cm PS */
95 #define MAX_ROW_HEIGHT 56693
97 /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
98 #define STD_ROWHEIGHT_DIFF 23
100 namespace sc
102 inline long TwipsToHMM( long nTwips ) { return (nTwips * 127 + 36) / 72; }
103 inline long HMMToTwips( long nHMM ) { return (nHMM * 72 + 63) / 127; }
104 inline long TwipsToEvenHMM( long nTwips ) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
107 // standard size as OLE server (cells)
108 #define OLE_STD_CELLS_X 4
109 #define OLE_STD_CELLS_Y 5
112 // repaint flags (for messages)
113 enum class PaintPartFlags {
114 NONE = 0x00,
115 Grid = 0x01,
116 Top = 0x02,
117 Left = 0x04,
118 Extras = 0x08,
119 Marks = 0x10,
120 Objects = 0x20,
121 Size = 0x40,
122 All = Grid | Top | Left | Extras | Objects | Size,
124 namespace o3tl {
125 template<> struct typed_flags<PaintPartFlags> : is_typed_flags<PaintPartFlags, 0x07f> {};
128 // flags for columns / rows
129 enum class CRFlags : sal_uInt8 {
130 // Filtered always together with Hidden
131 // Filtered and ManualSize only valid for rows
132 NONE = 0x00,
133 Hidden = 0x01,
134 ManualBreak = 0x02,
135 Filtered = 0x04,
136 ManualSize = 0x08,
137 All = Hidden | ManualBreak | Filtered | ManualSize
139 namespace o3tl {
140 template<> struct typed_flags<CRFlags> : is_typed_flags<CRFlags, 0x0f> {};
143 enum class ScBreakType {
144 NONE = 0x00,
145 Page = 0x01,
146 Manual = 0x02
148 namespace o3tl {
149 template<> struct typed_flags<ScBreakType> : is_typed_flags<ScBreakType, 0x03> {};
152 enum class InsertDeleteFlags : sal_uInt16
154 NONE = 0x0000,
155 VALUE = 0x0001, /// Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
156 DATETIME = 0x0002, /// Dates, times, datetime values.
157 STRING = 0x0004, /// Strings (and string results if InsertDeleteFlags::FORMULA is not set).
158 NOTE = 0x0008, /// Cell notes.
159 FORMULA = 0x0010, /// Formula cells.
160 HARDATTR = 0x0020, /// Hard cell attributes.
161 STYLES = 0x0040, /// Cell styles.
162 OBJECTS = 0x0080, /// Drawing objects.
163 EDITATTR = 0x0100, /// Rich-text attributes.
164 OUTLINE = 0x0800, /// Sheet / outlining (grouping) information
165 NOCAPTIONS = 0x0200, /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
166 ADDNOTES = 0x0400, /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
167 SPECIAL_BOOLEAN = 0x1000,
168 FORGETCAPTIONS = 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes.
169 ATTRIB = HARDATTR | STYLES,
170 CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE,
171 ALL = CONTENTS | ATTRIB | OBJECTS,
172 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
173 AUTOFILL = ALL & ~(NOTE | OBJECTS)
175 namespace o3tl
177 template<> struct typed_flags<InsertDeleteFlags> : is_typed_flags<InsertDeleteFlags, 0x3fff> {};
179 // This doesn't work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work.
180 //static_assert((InsertDeleteFlags::ATTRIB & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE, "these must match");
183 enum class ScPasteFunc {
184 NONE, ADD, SUB, MUL, DIV
186 // bits for HasAttr
187 enum class HasAttrFlags {
188 NONE = 0x0000,
189 Lines = 0x0001,
190 Merged = 0x0002,
191 Overlapped = 0x0004,
192 Protected = 0x0008,
193 Shadow = 0x0010,
194 NeedHeight = 0x0020,
195 ShadowRight = 0x0040,
196 ShadowDown = 0x0080,
197 AutoFilter = 0x0100,
198 Conditional = 0x0200,
199 Rotate = 0x0400,
200 NotOverlapped = 0x0800,
201 RightOrCenter = 0x1000, // right or centered logical alignment
203 namespace o3tl {
204 template<> struct typed_flags<HasAttrFlags> : is_typed_flags<HasAttrFlags, 0x1fff> {};
208 #define EMPTY_OUSTRING ScGlobal::GetEmptyOUString()
210 // Layer id's for drawing.
211 // These are both id's and positions.
212 constexpr SdrLayerID SC_LAYER_FRONT (0);
213 constexpr SdrLayerID SC_LAYER_BACK (1);
214 constexpr SdrLayerID SC_LAYER_INTERN (2);
215 constexpr SdrLayerID SC_LAYER_CONTROLS(3);
216 constexpr SdrLayerID SC_LAYER_HIDDEN (4);
218 // link tables
219 enum class ScLinkMode {
220 NONE, NORMAL, VALUE
222 // input
223 enum class ScEnterMode {
224 NORMAL, BLOCK, MATRIX
227 // step = 10pt, max. indention = 100 steps
228 #define SC_INDENT_STEP 200
230 enum class ScScenarioFlags{ // scenario flags
231 NONE = 0,
232 CopyAll = 1,
233 ShowFrame = 2,
234 PrintFrame = 4,
235 TwoWay = 8,
236 Attrib = 16,
237 Value = 32,
238 Protected = 64
240 namespace o3tl {
241 template<> struct typed_flags<ScScenarioFlags> : is_typed_flags<ScScenarioFlags, 127> {};
244 enum class SubtotalFlags {
245 NONE = 0x00,
246 IgnoreNestedStAg = 0x08,
247 IgnoreErrVal = 0x04,
248 IgnoreHidden = 0x02,
249 IgnoreFiltered = 0x01
251 namespace o3tl {
252 template<> struct typed_flags<SubtotalFlags> : is_typed_flags<SubtotalFlags, 0x0f> {};
255 enum class ScCloneFlags{
256 /** Default cell clone flags: do not start listening, do not adjust 3D refs to
257 old position, clone note captions of cell notes. */
258 Default = 0x0000,
260 /** If set, cloned formula cells will start to listen to the document. */
261 StartListening = 0x0001,
263 /** If set, absolute refs will not transformed to external references */
264 NoMakeAbsExternal = 0x0002,
266 /** If set, global named expressions will be converted to sheet-local named
267 expressions. */
268 NamesToLocal = 0x0004
270 namespace o3tl
272 template<> struct typed_flags<ScCloneFlags> : is_typed_flags<ScCloneFlags, 0x0007> {};
275 #ifndef DELETEZ
276 #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
277 #endif
279 // is bit set in set?
280 #define IS_SET(bit,set)(((set)&(bit))==(bit))
282 enum CellType
284 CELLTYPE_NONE,
285 CELLTYPE_VALUE,
286 CELLTYPE_STRING,
287 CELLTYPE_FORMULA,
288 CELLTYPE_EDIT,
291 enum DelCellCmd
293 DEL_CELLSUP,
294 DEL_CELLSLEFT,
295 DEL_DELROWS,
296 DEL_DELCOLS,
297 DEL_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_YEAR
352 enum ScDirection
354 DIR_BOTTOM,
355 DIR_RIGHT,
356 DIR_TOP,
357 DIR_LEFT
360 enum ScSizeMode
362 SC_SIZE_DIRECT, // set size or hide if value is 0
363 SC_SIZE_OPTIMAL, // set optimal size for everything
364 SC_SIZE_SHOW, // show with original size
365 SC_SIZE_VISOPT, // set optimal size only if visible
366 SC_SIZE_ORIGINAL // only set size, don't change visible flag
369 enum ScInputMode
371 SC_INPUT_NONE,
372 SC_INPUT_TYPE, // input, while not in inplace mode
373 SC_INPUT_TABLE, // text cursor in the table
374 SC_INPUT_TOP // text cursor in the input line
377 enum ScVObjMode // output modes of objects on a page
379 VOBJ_MODE_SHOW,
380 VOBJ_MODE_HIDE
383 enum ScAnchorType // anchor of a character object
385 SCA_CELL,
386 SCA_PAGE,
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 ScDocument;
470 class ScDocShell;
471 class SvxSearchItem;
472 class ScAutoFormat;
473 class LegacyFuncCollection;
474 class ScUnoAddInCollection;
475 class ScUserList;
476 class SvxBrushItem;
477 class ScFunctionList;
478 class ScFunctionMgr;
479 class SfxItemPool;
480 class SdrModel;
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 OutputDevice;
492 class ScFieldEditEngine;
494 namespace com { namespace sun { namespace star {
495 namespace lang {
496 struct Locale;
498 namespace i18n {
499 class XOrdinalSuffix;
502 namespace utl {
503 class TransliterationWrapper;
506 class ScGlobal
508 static SvxSearchItem* pSearchItem;
509 static ScAutoFormat* pAutoFormat;
510 static LegacyFuncCollection* pLegacyFuncCollection;
511 static ScUnoAddInCollection* pAddInCollection;
512 static ScUserList* pUserList;
513 static std::map<const char*, OUString>* pRscString;
514 static OUString* pStrScDoc;
515 static OUString* pEmptyOUString;
516 static OUString* pStrClipDocName;
517 static SvxBrushItem* pEmptyBrushItem;
518 static SvxBrushItem* pButtonBrushItem;
519 static SvxBrushItem* pEmbeddedBrushItem;
520 static SvxBrushItem* pProtectedBrushItem;
522 static ScFunctionList* pStarCalcFunctionList;
523 static ScFunctionMgr* pStarCalcFunctionMgr;
525 static ScUnitConverter* pUnitConverter;
527 static SvNumberFormatter* pEnglishFormatter; // for UNO / XML export
529 static css::uno::Reference< css::i18n::XOrdinalSuffix> xOrdinalSuffix;
530 static CalendarWrapper* pCalendar;
531 static CollatorWrapper* pCaseCollator;
532 static CollatorWrapper* pCollator;
533 static ::utl::TransliterationWrapper* pTransliteration;
534 static ::utl::TransliterationWrapper* pCaseTransliteration;
535 static IntlWrapper* pScIntlWrapper;
536 static css::lang::Locale* pLocale;
538 static ScFieldEditEngine* pFieldEditEngine;
540 static void InitPPT();
542 public:
543 static SvtSysLocale* pSysLocale;
544 // for faster access a pointer to the single instance provided by SvtSysLocale
545 SC_DLLPUBLIC static const CharClass* pCharClass;
546 // for faster access a pointer to the single instance provided by SvtSysLocale
547 SC_DLLPUBLIC static const LocaleDataWrapper* pLocaleData;
548 SC_DLLPUBLIC static const LocaleDataWrapper* GetpLocaleData();
550 static CalendarWrapper* GetCalendar();
551 SC_DLLPUBLIC static CollatorWrapper* GetCollator();
552 static CollatorWrapper* GetCaseCollator();
553 static css::lang::Locale* GetLocale();
555 SC_DLLPUBLIC static ::utl::TransliterationWrapper* GetpTransliteration();
556 static ::utl::TransliterationWrapper* GetCaseTransliteration();
558 SC_DLLPUBLIC static LanguageType eLnge;
559 static sal_Unicode cListDelimiter;
561 static const OUString& GetClipDocName();
562 static void SetClipDocName( const OUString& rNew );
563 SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem();
564 SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew );
565 SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat();
566 SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat();
567 static void ClearAutoFormat(); //BugId 54209
568 static LegacyFuncCollection* GetLegacyFuncCollection();
569 SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
570 SC_DLLPUBLIC static ScUserList* GetUserList();
571 static void SetUserList( const ScUserList* pNewList );
572 SC_DLLPUBLIC static const OUString& GetRscString(const char* pResId);
573 /// Open the specified URL.
574 static void OpenURL(const OUString& rURL, const OUString& rTarget);
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 SC_DLLPUBLIC static double nScreenPPTX;
583 SC_DLLPUBLIC static double nScreenPPTY;
585 static tools::SvRef<ScDocShell> xDrawClipDocShellRef;
587 static sal_uInt16 nDefFontHeight;
588 SC_DLLPUBLIC static sal_uInt16 nStdRowHeight;
590 SC_DLLPUBLIC static long nLastRowHeightExtra;
591 static long nLastColWidthExtra;
593 SC_DLLPUBLIC static void Init(); // during start up
594 static void InitAddIns();
595 static void Clear(); // at the end of the program
597 static void InitTextHeight(const SfxItemPool* pPool);
598 static SvxBrushItem* GetEmptyBrushItem() { return pEmptyBrushItem; }
599 static SvxBrushItem* GetButtonBrushItem();
600 static SvxBrushItem* GetProtectedBrushItem() { return pProtectedBrushItem; }
601 SC_DLLPUBLIC static const OUString& GetEmptyOUString();
603 static bool HasStarCalcFunctionList();
604 static ScFunctionList* GetStarCalcFunctionList();
605 static ScFunctionMgr* GetStarCalcFunctionMgr();
606 static void ResetFunctionList();
608 static OUString GetErrorString(FormulaError nErrNumber);
609 static OUString GetLongErrorString(FormulaError nErrNumber);
610 static bool EETextObjEqual( const EditTextObject* pObj1,
611 const EditTextObject* pObj2 );
612 static bool CheckWidthInvalidate( bool& bNumFormatChanged,
613 const SfxItemSet& rNewAttrs,
614 const SfxItemSet& rOldAttrs );
615 static bool HasAttrChanged( const SfxItemSet& rNewAttrs,
616 const SfxItemSet& rOldAttrs,
617 const sal_uInt16 nWhich );
619 static ScUnitConverter* GetUnitConverter();
621 /// strchr() functionality on unicode, as long as we need it for FormulaToken etc.
622 static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
624 static sal_Unicode ToUpperAlpha( sal_Unicode c )
625 { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
627 /** Adds the string rToken to rTokenList, using a list separator character.
628 @param rTokenList The string list where the token will be appended to.
629 @param rToken The token string to append to the token list.
630 @param cSep The character to separate the tokens.
631 @param nSepCount Specifies how often cSep is inserted between two tokens.
632 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
633 SC_DLLPUBLIC static OUString addToken(
634 const OUString& rTokenList, const OUString& rToken,
635 sal_Unicode cSep, sal_Int32 nSepCount = 1,
636 bool bForceSep = false );
638 /** Returns true, if the first and last character of the string is cQuote. */
639 SC_DLLPUBLIC static bool IsQuoted( const OUString& rString, sal_Unicode cQuote );
641 /** Inserts the character cQuote at beginning and end of rString.
642 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
643 escaped by doubling them.
645 SC_DLLPUBLIC static void AddQuotes( OUString& rString, sal_Unicode cQuote, bool bEscapeEmbedded = true );
647 /** Erases the character cQuote from rString, if it exists at beginning AND end.
648 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
649 are unescaped by replacing them with a
650 single instance.
652 SC_DLLPUBLIC static void EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescapeEmbedded = true );
654 /** Finds an unquoted instance of cChar in rString, starting at
655 offset nStart. Unquoted instances may occur when concatenating two
656 quoted strings with a separator, for example, 's1':'s2'. Embedded
657 quotes have to be escaped by being doubled. Caller must ensure that
658 nStart points into an unquoted range or the opening quote. Specialty:
659 if cChar==cQuote the first cQuote character from nStart on is found.
660 @returns offset if found, else -1
662 SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar);
664 /** Finds an unquoted instance of cChar in null-terminated pString. Same
665 semantics as FindUnquoted( const String&, ...)
666 @returns: pointer to cChar if found, else NULL
668 SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar );
670 static rtl_TextEncoding GetCharsetValue( const OUString& rCharSet );
671 static OUString GetCharsetString( rtl_TextEncoding eVal );
673 /// a "ReadOnly" formatter for UNO/XML export
674 static SvNumberFormatter* GetEnglishFormatter();
676 static bool IsSystemRTL(); // depending on system language
677 static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
678 SC_DLLPUBLIC static SvtScriptType GetDefaultScriptType(); // for all WEAK characters
679 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
680 If more than one SvtScriptType::... values are or'ed together, prefers
681 first COMPLEX, then ASIAN */
682 SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( SvtScriptType nScriptType, sal_uInt16 nWhich );
684 /** Adds a language item to the item set, if the number format item contains
685 a language that differs from its parent's language. */
686 SC_DLLPUBLIC static void AddLanguage( SfxItemSet& rSet, const SvNumberFormatter& rFormatter );
688 /** Obtain the ordinal suffix for a number according to the system locale */
689 static OUString GetOrdinalSuffix( sal_Int32 nNumber);
691 /** A static instance of ScFieldEditEngine not capable of resolving
692 document specific fields, to be used only by ScEditUtil::GetString(). */
693 static ScFieldEditEngine& GetStaticFieldEditEngine();
695 /** Replaces the first occurrence of rPlaceholder in rString with
696 rReplacement, or if rPlaceholder is not found appends one space if
697 rString does not end in a space and appends rReplacement.
699 Meant to be used with resource strings ala "Column %1" where a
700 translation may have omitted the %1 placeholder and a simple
701 replacement would end up with nothing replaced so no column indicator
702 in the result string.
704 SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString,
705 const OUString& rPlaceholder,
706 const OUString& rReplacement );
709 /** Convert string content to numeric value.
711 In any case, if rError is set 0.0 is returned.
713 If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally
714 assigned to rError and 0.0 is returned. The caller is expected to
715 handle this situation. Used by the interpreter.
717 Usually FormulaError::NoValue is passed as nStringNoValueError.
719 Otherwise, depending on the string conversion configuration different
720 approaches are taken:
723 For ScCalcConfig::StringConversion::ILLEGAL
724 The error value passed in nStringNoValueError is assigned to rError
725 (and 0.0 returned).
728 For ScCalcConfig::StringConversion::ZERO
729 A zero value is returned and no error assigned.
732 For ScCalcConfig::StringConversion::LOCALE
734 If the string is empty or consists only of spaces, if "treat empty
735 string as zero" is set 0.0 is returned, else nStringNoValueError
736 assigned to rError (and 0.0 returned).
738 Else a non-empty string is passed to the number formatter's scanner to
739 be parsed locale dependent. If that does not detect a numeric value
740 nStringNoValueError is assigned to rError (and 0.0 returned).
742 If no number formatter was passed, the conversion falls back to
743 UNAMBIGUOUS.
746 For ScCalcConfig::StringConversion::UNAMBIGUOUS
748 If the string is empty or consists only of spaces, if "treat empty
749 string as zero" is set 0.0 is returned, else nStringNoValueError
750 assigned to rError (and 0.0 returned).
752 If the string is not empty the following conversion rules are applied:
754 Converted are only integer numbers including exponent, and ISO 8601 dates
755 and times in their extended formats with separators. Anything else,
756 especially fractional numeric values with decimal separators or dates other
757 than ISO 8601 would be locale dependent and is a no-no. Leading and
758 trailing blanks are ignored.
760 The following ISO 8601 formats are converted:
762 CCYY-MM-DD
763 CCYY-MM-DDThh:mm
764 CCYY-MM-DDThh:mm:ss
765 CCYY-MM-DDThh:mm:ss,s
766 CCYY-MM-DDThh:mm:ss.s
767 hh:mm
768 hh:mm:ss
769 hh:mm:ss,s
770 hh:mm:ss.s
772 The century CC may not be omitted and the two-digit year setting is not
773 taken into account. Instead of the T date and time separator exactly one
774 blank may be used.
776 If a date is given, it must be a valid Gregorian calendar date. In this
777 case the optional time must be in the range 00:00 to 23:59:59.99999...
778 If only time is given, it may have any value for hours, taking elapsed time
779 into account; minutes and seconds are limited to the value 59 as well.
781 If the string can not be converted to a numeric value, the error value
782 passed in nStringNoValueError is assigned to rError.
785 @param rStr
786 The string to be converted.
788 @param rConfig
789 The calculation configuration.
791 @param rError
792 Contains the error on return, if any. If an error was set before
793 and the conversion did not result in an error, still 0.0 is
794 returned.
796 @param nStringNoValueError
797 The error value to be assigned to rError if string could not be
798 converted to number.
800 @param pFormatter
801 The number formatter to use in case of
802 ScCalcConfig::StringConversion::LOCALE. Can but should not be
803 nullptr in which case conversion falls back to
804 ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is
805 detected the null date is assumed to be the standard 1899-12-30
806 instead of the configured null date.
808 @param rCurFmtType
809 Can be assigned a format type in case a date or time or date+time
810 string was converted, e.g. SvNumFormatType::DATE or
811 SvNumFormatType::TIME or a combination thereof.
814 static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig,
815 FormulaError & rError, FormulaError nStringNoValueError,
816 SvNumberFormatter* pFormatter, SvNumFormatType & rCurFmtType );
820 // maybe move to dbdata.hxx (?):
822 enum ScQueryOp
824 SC_EQUAL,
825 SC_LESS,
826 SC_GREATER,
827 SC_LESS_EQUAL,
828 SC_GREATER_EQUAL,
829 SC_NOT_EQUAL,
830 SC_TOPVAL,
831 SC_BOTVAL,
832 SC_TOPPERC,
833 SC_BOTPERC,
834 SC_CONTAINS,
835 SC_DOES_NOT_CONTAIN,
836 SC_BEGINS_WITH,
837 SC_DOES_NOT_BEGIN_WITH,
838 SC_ENDS_WITH,
839 SC_DOES_NOT_END_WITH
842 enum ScQueryConnect
844 SC_AND,
845 SC_OR
848 enum ScSubTotalFunc
850 SUBTOTAL_FUNC_NONE = 0,
851 SUBTOTAL_FUNC_AVE = 1,
852 SUBTOTAL_FUNC_CNT = 2,
853 SUBTOTAL_FUNC_CNT2 = 3,
854 SUBTOTAL_FUNC_MAX = 4,
855 SUBTOTAL_FUNC_MIN = 5,
856 SUBTOTAL_FUNC_PROD = 6,
857 SUBTOTAL_FUNC_STD = 7,
858 SUBTOTAL_FUNC_STDP = 8,
859 SUBTOTAL_FUNC_SUM = 9,
860 SUBTOTAL_FUNC_VAR = 10,
861 SUBTOTAL_FUNC_VARP = 11,
862 SUBTOTAL_FUNC_MED = 12,
863 SUBTOTAL_FUNC_SELECTION_COUNT = 13
866 enum ScAggregateFunc
868 AGGREGATE_FUNC_AVE = 1,
869 AGGREGATE_FUNC_CNT = 2,
870 AGGREGATE_FUNC_CNT2 = 3,
871 AGGREGATE_FUNC_MAX = 4,
872 AGGREGATE_FUNC_MIN = 5,
873 AGGREGATE_FUNC_PROD = 6,
874 AGGREGATE_FUNC_STD = 7,
875 AGGREGATE_FUNC_STDP = 8,
876 AGGREGATE_FUNC_SUM = 9,
877 AGGREGATE_FUNC_VAR = 10,
878 AGGREGATE_FUNC_VARP = 11,
879 AGGREGATE_FUNC_MEDIAN = 12,
880 AGGREGATE_FUNC_MODSNGL = 13,
881 AGGREGATE_FUNC_LARGE = 14,
882 AGGREGATE_FUNC_SMALL = 15,
883 AGGREGATE_FUNC_PERCINC = 16,
884 AGGREGATE_FUNC_QRTINC = 17,
885 AGGREGATE_FUNC_PERCEXC = 18,
886 AGGREGATE_FUNC_QRTEXC = 19
889 class ScArea;
891 struct ScConsolidateParam
893 SCCOL nCol; // cursor position /
894 SCROW nRow; // or start of destination area respectively
895 SCTAB nTab;
896 ScSubTotalFunc eFunction;
897 sal_uInt16 nDataAreaCount; // number of data areas
898 ScArea** ppDataAreas; // array of pointers into data areas
899 bool bByCol;
900 bool bByRow;
901 bool bReferenceData; // reference source data
903 ScConsolidateParam();
904 ScConsolidateParam( const ScConsolidateParam& r );
905 ~ScConsolidateParam();
907 ScConsolidateParam& operator= ( const ScConsolidateParam& r );
908 bool operator== ( const ScConsolidateParam& r ) const;
909 void Clear (); // = ClearDataAreas()+Members
910 void ClearDataAreas ();
911 void SetAreas ( ScArea* const* ppAreas, sal_uInt16 nCount );
914 extern SfxViewShell* pScActiveViewShell;
915 extern sal_uInt16 nScClickMouseModifier;
916 extern sal_uInt16 nScFillModeMouseModifier;
918 #endif
920 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */