build fix
[LibreOffice.git] / sc / inc / global.hxx
blob77907e73071325a8fd78600d72ced3edb7099e9d
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 <tools/stream.hxx>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include "scdllapi.h"
28 #include <rtl/ustring.hxx>
30 #include <vector>
32 class ImageList;
33 class Bitmap;
34 class SfxItemSet;
35 class Color;
36 struct ScCalcConfig;
37 enum class SvtScriptType;
38 enum class FormulaError : sal_uInt16;
40 #define SC_COLLATOR_IGNORES ( \
41 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE )
43 #define SC_TRANSLITERATION_IGNORECASE ( \
44 css::i18n::TransliterationModules_IGNORE_CASE )
45 #define SC_TRANSLITERATION_CASESENSE 0
47 // Calc has lots of names...
48 // Clipboard names are in so3/soapp.hxx now
49 // STRING_SCAPP was "scalc3", "scalc4", now just "scalc"
51 #define STRING_SCAPP "scalc"
53 #define STRING_STANDARD "Standard"
55 // characters
57 const sal_Unicode CHAR_NBSP = 0x00A0;
58 const sal_Unicode CHAR_SHY = 0x00AD;
59 const sal_Unicode CHAR_ZWSP = 0x200B;
60 const sal_Unicode CHAR_LRM = 0x200E;
61 const sal_Unicode CHAR_RLM = 0x200F;
62 const sal_Unicode CHAR_NBHY = 0x2011;
63 const sal_Unicode CHAR_ZWNBSP = 0x2060;
65 #define MINDOUBLE 1.7e-307
66 #define MAXDOUBLE 1.7e307
68 #define MINZOOM 20
69 #define MAXZOOM 400
71 const SCSIZE MAXSUBTOTAL = 3;
73 #define PIXEL_PER_INCH 96.0
74 #define CM_PER_INCH 2.54
75 #define POINTS_PER_INCH 72.0 /**< PostScript points per inch */
76 #define PIXEL_PER_POINT (PIXEL_PER_INCH / POINTS_PER_INCH)
77 #define TWIPS_PER_POINT 20.0
78 #define TWIPS_PER_INCH (TWIPS_PER_POINT * POINTS_PER_INCH)
79 #define TWIPS_PER_CM (TWIPS_PER_INCH / CM_PER_INCH)
80 #define CM_PER_TWIPS (CM_PER_INCH / TWIPS_PER_INCH)
81 #define TWIPS_PER_PIXEL (TWIPS_PER_INCH / PIXEL_PER_INCH)
82 #define TWIPS_PER_CHAR (TWIPS_PER_INCH / 13.6)
83 #define PIXEL_PER_TWIPS (PIXEL_PER_INCH / TWIPS_PER_INCH)
84 #define HMM_PER_TWIPS (CM_PER_TWIPS * 1000.0)
86 #define STD_COL_WIDTH 1280 /* 2.2577cm, 64.00pt PS */
87 #define STD_EXTRA_WIDTH 113 /* 2mm extra for optimal width,
88 * 0.1986cm with TeX points,
89 * 0.1993cm with PS points. */
91 #define MAX_EXTRA_WIDTH 23811 /* 42cm in TWIPS, 41.8430cm TeX, 41.9999cm PS */
92 #define MAX_EXTRA_HEIGHT 23811
93 #define MAX_COL_WIDTH 56693 /* 1m in TWIPS, 99.6266cm TeX, 100.0001cm PS */
94 #define MAX_ROW_HEIGHT 56693
96 /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
97 #define STD_ROWHEIGHT_DIFF 23
99 namespace sc
101 inline long TwipsToHMM( long nTwips ) { return (nTwips * 127 + 36) / 72; }
102 inline long HMMToTwips( long nHMM ) { return (nHMM * 72 + 63) / 127; }
103 inline long TwipsToEvenHMM( long nTwips ) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
106 // standard size as OLE server (cells)
107 #define OLE_STD_CELLS_X 4
108 #define OLE_STD_CELLS_Y 5
111 // repaint flags (for messages)
112 enum class PaintPartFlags {
113 NONE = 0x00,
114 Grid = 0x01,
115 Top = 0x02,
116 Left = 0x04,
117 Extras = 0x08,
118 Marks = 0x10,
119 Objects = 0x20,
120 Size = 0x40,
121 All = Grid | Top | Left | Extras | Objects | Size,
123 namespace o3tl {
124 template<> struct typed_flags<PaintPartFlags> : is_typed_flags<PaintPartFlags, 0x07f> {};
127 // flags for columns / rows
128 enum class CRFlags : sal_uInt8 {
129 // Filtered always together with Hidden
130 // Filtered and ManualSize only valid for rows
131 NONE = 0x00,
132 Hidden = 0x01,
133 ManualBreak = 0x02,
134 Filtered = 0x04,
135 ManualSize = 0x08,
136 All = Hidden | ManualBreak | Filtered | ManualSize
138 namespace o3tl {
139 template<> struct typed_flags<CRFlags> : is_typed_flags<CRFlags, 0x0f> {};
142 enum class ScBreakType {
143 NONE = 0x00,
144 Page = 0x01,
145 Manual = 0x02
147 namespace o3tl {
148 template<> struct typed_flags<ScBreakType> : is_typed_flags<ScBreakType, 0x03> {};
151 enum class InsertDeleteFlags : sal_uInt16
153 NONE = 0x0000,
154 VALUE = 0x0001, /// Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
155 DATETIME = 0x0002, /// Dates, times, datetime values.
156 STRING = 0x0004, /// Strings (and string results if InsertDeleteFlags::FORMULA is not set).
157 NOTE = 0x0008, /// Cell notes.
158 FORMULA = 0x0010, /// Formula cells.
159 HARDATTR = 0x0020, /// Hard cell attributes.
160 STYLES = 0x0040, /// Cell styles.
161 OBJECTS = 0x0080, /// Drawing objects.
162 EDITATTR = 0x0100, /// Rich-text attributes.
163 OUTLINE = 0x0800, /// Sheet / outlining (grouping) information
164 NOCAPTIONS = 0x0200, /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
165 ADDNOTES = 0x0400, /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
166 SPECIAL_BOOLEAN = 0x1000,
167 FORGETCAPTIONS = 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes.
168 ATTRIB = HARDATTR | STYLES,
169 CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE,
170 ALL = CONTENTS | ATTRIB | OBJECTS,
171 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
172 AUTOFILL = ALL & ~(NOTE | OBJECTS)
174 namespace o3tl
176 template<> struct typed_flags<InsertDeleteFlags> : is_typed_flags<InsertDeleteFlags, 0x3fff> {};
178 // This doesn't work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work.
179 //static_assert((InsertDeleteFlags::ATTRIB & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE, "these must match");
182 enum class ScPasteFunc {
183 NONE, ADD, SUB, MUL, DIV
185 // bits for HasAttr
186 enum class HasAttrFlags {
187 NONE = 0x0000,
188 Lines = 0x0001,
189 Merged = 0x0002,
190 Overlapped = 0x0004,
191 Protected = 0x0008,
192 Shadow = 0x0010,
193 NeedHeight = 0x0020,
194 ShadowRight = 0x0040,
195 ShadowDown = 0x0080,
196 AutoFilter = 0x0100,
197 Conditional = 0x0200,
198 Rotate = 0x0400,
199 NotOverlapped = 0x0800,
200 RightOrCenter = 0x1000, // right or centered logical alignment
202 namespace o3tl {
203 template<> struct typed_flags<HasAttrFlags> : is_typed_flags<HasAttrFlags, 0x1fff> {};
207 #define EMPTY_OUSTRING ScGlobal::GetEmptyOUString()
209 // layer id's for drawing
210 #define SC_LAYER_FRONT 0
211 #define SC_LAYER_BACK 1
212 #define SC_LAYER_INTERN 2
213 #define SC_LAYER_CONTROLS 3
214 #define SC_LAYER_HIDDEN 4
216 // link tables
217 enum class ScLinkMode {
218 NONE, NORMAL, VALUE
220 // input
221 enum class ScEnterMode {
222 NORMAL, BLOCK, MATRIX
225 // step = 10pt, max. indention = 100 steps
226 #define SC_INDENT_STEP 200
228 enum class ScScenarioFlags{ // scenario flags
229 NONE = 0,
230 CopyAll = 1,
231 ShowFrame = 2,
232 PrintFrame = 4,
233 TwoWay = 8,
234 Attrib = 16,
235 Value = 32,
236 Protected = 64
238 namespace o3tl {
239 template<> struct typed_flags<ScScenarioFlags> : is_typed_flags<ScScenarioFlags, 127> {};
242 enum class SubtotalFlags {
243 NONE = 0x00,
244 IgnoreNestedStAg = 0x08,
245 IgnoreErrVal = 0x04,
246 IgnoreHidden = 0x02,
247 IgnoreFiltered = 0x01
249 namespace o3tl {
250 template<> struct typed_flags<SubtotalFlags> : is_typed_flags<SubtotalFlags, 0x0f> {};
253 enum class ScCloneFlags{
254 /** Default cell clone flags: do not start listening, do not adjust 3D refs to
255 old position, clone note captions of cell notes. */
256 Default = 0x0000,
258 /** If set, cloned formula cells will start to listen to the document. */
259 StartListening = 0x0001,
261 /** If set, absolute refs will not transformed to external references */
262 NoMakeAbsExternal = 0x0002,
264 /** If set, global named expressions will be converted to sheet-local named
265 expressions. */
266 NamesToLocal = 0x0004
268 namespace o3tl
270 template<> struct typed_flags<ScCloneFlags> : is_typed_flags<ScCloneFlags, 0x0007> {};
273 #ifndef DELETEZ
274 #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
275 #endif
277 // is bit set in set?
278 #define IS_SET(bit,set)(((set)&(bit))==(bit))
280 enum CellType
282 CELLTYPE_NONE,
283 CELLTYPE_VALUE,
284 CELLTYPE_STRING,
285 CELLTYPE_FORMULA,
286 CELLTYPE_EDIT,
289 enum DelCellCmd
291 DEL_CELLSUP,
292 DEL_CELLSLEFT,
293 DEL_DELROWS,
294 DEL_DELCOLS,
295 DEL_NONE
298 enum InsCellCmd
300 INS_CELLSDOWN,
301 INS_CELLSRIGHT,
302 INS_INSROWS_BEFORE,
303 INS_INSCOLS_BEFORE,
304 INS_NONE,
305 INS_INSROWS_AFTER,
306 INS_INSCOLS_AFTER
309 enum UpdateRefMode
311 URM_INSDEL,
312 URM_COPY,
313 URM_MOVE,
314 URM_REORDER
317 enum FillDir
319 FILL_TO_BOTTOM,
320 FILL_TO_RIGHT,
321 FILL_TO_TOP,
322 FILL_TO_LEFT
325 enum FillCmd
327 FILL_SIMPLE,
328 FILL_LINEAR,
329 FILL_GROWTH,
330 FILL_DATE,
331 FILL_AUTO
334 enum ScMoveDirection
336 SC_MOVE_RIGHT,
337 SC_MOVE_LEFT,
338 SC_MOVE_UP,
339 SC_MOVE_DOWN
342 enum FillDateCmd
344 FILL_DAY,
345 FILL_WEEKDAY,
346 FILL_MONTH,
347 FILL_YEAR
350 enum ScDirection
352 DIR_BOTTOM,
353 DIR_RIGHT,
354 DIR_TOP,
355 DIR_LEFT
358 enum ScSizeMode
360 SC_SIZE_DIRECT, // set size or hide if value is 0
361 SC_SIZE_OPTIMAL, // set optimal size for everything
362 SC_SIZE_SHOW, // show with original size
363 SC_SIZE_VISOPT, // set optimal size only if visible
364 SC_SIZE_ORIGINAL // only set size, don't change visible flag
367 enum ScInputMode
369 SC_INPUT_NONE,
370 SC_INPUT_TYPE, // input, while not in inplace mode
371 SC_INPUT_TABLE, // text cursor in the table
372 SC_INPUT_TOP // text cursor in the input line
375 enum ScVObjMode // output modes of objects on a page
377 VOBJ_MODE_SHOW,
378 VOBJ_MODE_HIDE
381 enum ScAnchorType // anchor of a character object
383 SCA_CELL,
384 SCA_PAGE,
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 ScGetDBSelection
399 /** Keep selection as is, expand to used data area if no selection. */
400 SC_DBSEL_KEEP,
402 /** Shrink selection to sheet's data area. */
403 SC_DBSEL_SHRINK_TO_SHEET_DATA,
405 /** Shrink selection to actually used data area within the selection. */
406 SC_DBSEL_SHRINK_TO_USED_DATA,
408 /** If only one row or portion thereof is selected, shrink row to used data
409 columns and select further rows down until end of data. If an area is
410 selected, shrink rows to actually used columns. Else, no selection,
411 expand to used data area. */
412 SC_DBSEL_ROW_DOWN,
414 /** Behave as if the range corresponding to a ScDBData area was selected,
415 for API use. */
416 SC_DBSEL_FORCE_MARK
419 enum ScLkUpdMode // modes for updating links
421 LM_ALWAYS,
422 LM_NEVER,
423 LM_ON_DEMAND,
424 LM_UNKNOWN
427 // enum with values equal to old DBObject enum from sdb
428 enum ScDBObject
430 ScDbTable,
431 ScDbQuery
434 namespace sc {
436 enum class ColRowEditAction
438 Unknown,
439 InsertColumnsBefore,
440 InsertColumnsAfter,
441 InsertRowsBefore,
442 InsertRowsAfter,
443 DeleteColumns,
444 DeleteRows
449 struct ScImportParam
451 SCCOL nCol1;
452 SCROW nRow1;
453 SCCOL nCol2;
454 SCROW nRow2;
455 bool bImport;
456 OUString aDBName; // alias of data base
457 OUString aStatement;
458 bool bNative;
459 bool bSql; // statement or name?
460 sal_uInt8 nType; // enum DBObject
462 ScImportParam();
463 ScImportParam( const ScImportParam& r );
464 ~ScImportParam();
466 ScImportParam& operator= ( const ScImportParam& r );
467 bool operator== ( const ScImportParam& r ) const;
470 class ScDocument;
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 SdrModel;
482 class EditTextObject;
483 class SfxObjectShell;
484 class SvNumberFormatter;
485 class ScUnitConverter;
486 class CharClass;
487 class LocaleDataWrapper;
488 class SvtSysLocale;
489 class CalendarWrapper;
490 class CollatorWrapper;
491 class IntlWrapper;
492 class OutputDevice;
493 class ScFieldEditEngine;
495 namespace com { namespace sun { namespace star {
496 namespace lang {
497 struct Locale;
499 namespace i18n {
500 class XOrdinalSuffix;
503 namespace utl {
504 class TransliterationWrapper;
507 class ScGlobal
509 static SvxSearchItem* pSearchItem;
510 static ScAutoFormat* pAutoFormat;
511 static LegacyFuncCollection* pLegacyFuncCollection;
512 static ScUnoAddInCollection* pAddInCollection;
513 static ScUserList* pUserList;
514 static OUString** ppRscString;
515 static OUString* pStrScDoc;
516 static OUString* pEmptyOUString;
517 static OUString* pStrClipDocName;
518 static SvxBrushItem* pEmptyBrushItem;
519 static SvxBrushItem* pButtonBrushItem;
520 static SvxBrushItem* pEmbeddedBrushItem;
522 static ImageList* pOutlineBitmaps;
524 static ScFunctionList* pStarCalcFunctionList;
525 static ScFunctionMgr* pStarCalcFunctionMgr;
527 static ScUnitConverter* pUnitConverter;
529 static SvNumberFormatter* pEnglishFormatter; // for UNO / XML export
531 static css::uno::Reference< css::i18n::XOrdinalSuffix> xOrdinalSuffix;
532 static CalendarWrapper* pCalendar;
533 static CollatorWrapper* pCaseCollator;
534 static CollatorWrapper* pCollator;
535 static ::utl::TransliterationWrapper* pTransliteration;
536 static ::utl::TransliterationWrapper* pCaseTransliteration;
537 static IntlWrapper* pScIntlWrapper;
538 static css::lang::Locale* pLocale;
540 static ScFieldEditEngine* pFieldEditEngine;
542 static void InitPPT();
544 public:
545 static SvtSysLocale* pSysLocale;
546 // for faster access a pointer to the single instance provided by SvtSysLocale
547 SC_DLLPUBLIC static const CharClass* pCharClass;
548 // for faster access a pointer to the single instance provided by SvtSysLocale
549 SC_DLLPUBLIC static const LocaleDataWrapper* pLocaleData;
550 SC_DLLPUBLIC static const LocaleDataWrapper* GetpLocaleData();
552 static CalendarWrapper* GetCalendar();
553 SC_DLLPUBLIC static CollatorWrapper* GetCollator();
554 static CollatorWrapper* GetCaseCollator();
555 static IntlWrapper* GetScIntlWrapper();
556 static css::lang::Locale* GetLocale();
558 SC_DLLPUBLIC static ::utl::TransliterationWrapper* GetpTransliteration();
559 static ::utl::TransliterationWrapper* GetCaseTransliteration();
561 SC_DLLPUBLIC static LanguageType eLnge;
562 static sal_Unicode cListDelimiter;
564 static const OUString& GetClipDocName();
565 static void SetClipDocName( const OUString& rNew );
566 SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem();
567 SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew );
568 SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat();
569 SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat();
570 static void ClearAutoFormat(); //BugId 54209
571 static LegacyFuncCollection* GetLegacyFuncCollection();
572 SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
573 SC_DLLPUBLIC static ScUserList* GetUserList();
574 static void SetUserList( const ScUserList* pNewList );
575 SC_DLLPUBLIC static const OUString& GetRscString( sal_uInt16 nIndex );
576 /// Open the specified URL.
577 static void OpenURL(const OUString& rURL, const OUString& rTarget);
578 SC_DLLPUBLIC static OUString GetAbsDocName( const OUString& rFileName,
579 SfxObjectShell* pShell );
580 SC_DLLPUBLIC static OUString GetDocTabName( const OUString& rFileName,
581 const OUString& rTabName );
582 SC_DLLPUBLIC static sal_uInt32 GetStandardFormat( SvNumberFormatter&, sal_uInt32 nFormat, short nType );
584 SC_DLLPUBLIC static sal_uInt16 GetStandardRowHeight();
585 SC_DLLPUBLIC static double nScreenPPTX;
586 SC_DLLPUBLIC static double nScreenPPTY;
588 static tools::SvRef<ScDocShell> xDrawClipDocShellRef;
590 static sal_uInt16 nDefFontHeight;
591 SC_DLLPUBLIC static sal_uInt16 nStdRowHeight;
593 SC_DLLPUBLIC static long nLastRowHeightExtra;
594 static long nLastColWidthExtra;
596 static void Init(); // during start up
597 static void InitAddIns();
598 static void Clear(); // at the end of the program
600 static void InitTextHeight(SfxItemPool* pPool);
601 static SvxBrushItem* GetEmptyBrushItem() { return pEmptyBrushItem; }
602 static SvxBrushItem* GetButtonBrushItem();
603 SC_DLLPUBLIC static const OUString& GetEmptyOUString();
605 /** Returns the specified image list with outline symbols. */
606 static ImageList* GetOutlineSymbols();
608 static bool HasStarCalcFunctionList();
609 static ScFunctionList* GetStarCalcFunctionList();
610 static ScFunctionMgr* GetStarCalcFunctionMgr();
611 static void ResetFunctionList();
613 static OUString GetErrorString(FormulaError nErrNumber);
614 static OUString GetLongErrorString(FormulaError nErrNumber);
615 static bool EETextObjEqual( const EditTextObject* pObj1,
616 const EditTextObject* pObj2 );
617 static bool CheckWidthInvalidate( bool& bNumFormatChanged,
618 const SfxItemSet& rNewAttrs,
619 const SfxItemSet& rOldAttrs );
620 static bool HasAttrChanged( const SfxItemSet& rNewAttrs,
621 const SfxItemSet& rOldAttrs,
622 const sal_uInt16 nWhich );
624 static ScUnitConverter* GetUnitConverter();
626 /// strchr() functionality on unicode, as long as we need it for FormulaToken etc.
627 static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
629 static inline sal_Unicode ToUpperAlpha( sal_Unicode c )
630 { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
632 /** Adds the string rToken to rTokenList, using a list separator character.
633 @param rTokenList The string list where the token will be appended to.
634 @param rToken The token string to append to the token list.
635 @param cSep The character to separate the tokens.
636 @param nSepCount Specifies how often cSep is inserted between two tokens.
637 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
638 SC_DLLPUBLIC static OUString addToken(
639 const OUString& rTokenList, const OUString& rToken,
640 sal_Unicode cSep, sal_Int32 nSepCount = 1,
641 bool bForceSep = false );
643 /** Returns true, if the first and last character of the string is cQuote. */
644 SC_DLLPUBLIC static bool IsQuoted( const OUString& rString, sal_Unicode cQuote );
646 /** Inserts the character cQuote at beginning and end of rString.
647 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
648 escaped by doubling them.
650 SC_DLLPUBLIC static void AddQuotes( OUString& rString, sal_Unicode cQuote, bool bEscapeEmbedded = true );
652 /** Erases the character cQuote from rString, if it exists at beginning AND end.
653 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
654 are unescaped by replacing them with a
655 single instance.
657 SC_DLLPUBLIC static void EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescapeEmbedded = true );
659 /** Finds an unquoted instance of cChar in rString, starting at
660 offset nStart. Unquoted instances may occur when concatenating two
661 quoted strings with a separator, for example, 's1':'s2'. Embedded
662 quotes have to be escaped by being doubled. Caller must ensure that
663 nStart points into an unquoted range or the opening quote. Specialty:
664 if cChar==cQuote the first cQuote character from nStart on is found.
665 @returns offset if found, else -1
667 SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar);
669 /** Finds an unquoted instance of cChar in null-terminated pString. Same
670 semantics as FindUnquoted( const String&, ...)
671 @returns: pointer to cChar if found, else NULL
673 SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar );
675 static rtl_TextEncoding GetCharsetValue( const OUString& rCharSet );
676 static OUString GetCharsetString( rtl_TextEncoding eVal );
678 /// a "ReadOnly" formatter for UNO/XML export
679 static SvNumberFormatter* GetEnglishFormatter();
681 static bool IsSystemRTL(); // depending on system language
682 static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
683 SC_DLLPUBLIC static SvtScriptType GetDefaultScriptType(); // for all WEAK characters
684 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
685 If more than one SvtScriptType::... values are or'ed together, prefers
686 first COMPLEX, then ASIAN */
687 SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( SvtScriptType nScriptType, sal_uInt16 nWhich );
689 /** Adds a language item to the item set, if the number format item contains
690 a language that differs from its parent's language. */
691 SC_DLLPUBLIC static void AddLanguage( SfxItemSet& rSet, SvNumberFormatter& rFormatter );
693 /** Obtain the ordinal suffix for a number according to the system locale */
694 static OUString GetOrdinalSuffix( sal_Int32 nNumber);
696 /** A static instance of ScFieldEditEngine not capable of resolving
697 document specific fields, to be used only by ScEditUtil::GetString(). */
698 static ScFieldEditEngine& GetStaticFieldEditEngine();
700 /** Replaces the first occurrence of rPlaceholder in rString with
701 rReplacement, or if rPlaceholder is not found appends one space if
702 rString does not end in a space and appends rReplacement.
704 Meant to be used with resource strings ala "Column %1" where a
705 translation may have omitted the %1 placeholder and a simple
706 replacement would end up with nothing replaced so no column indicator
707 in the result string.
709 SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString,
710 const OUString& rPlaceholder,
711 const OUString& rReplacement );
714 /** Convert string content to numeric value.
716 In any case, if rError is set 0.0 is returned.
718 If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally
719 assigned to rError and 0.0 is returned. The caller is expected to
720 handle this situation. Used by the interpreter.
722 Usually FormulaError::NoValue is passed as nStringNoValueError.
724 Otherwise, depending on the string conversion configuration different
725 approaches are taken:
728 For ScCalcConfig::StringConversion::ILLEGAL
729 The error value passed in nStringNoValueError is assigned to rError
730 (and 0.0 returned).
733 For ScCalcConfig::StringConversion::ZERO
734 A zero value is returned and no error assigned.
737 For ScCalcConfig::StringConversion::LOCALE
739 If the string is empty or consists only of spaces, if "treat empty
740 string as zero" is set 0.0 is returned, else nStringNoValueError
741 assigned to rError (and 0.0 returned).
743 Else a non-empty string is passed to the number formatter's scanner to
744 be parsed locale dependent. If that does not detect a numeric value
745 nStringNoValueError is assigned to rError (and 0.0 returned).
747 If no number formatter was passed, the conversion falls back to
748 UNAMBIGUOUS.
751 For ScCalcConfig::StringConversion::UNAMBIGUOUS
753 If the string is empty or consists only of spaces, if "treat empty
754 string as zero" is set 0.0 is returned, else nStringNoValueError
755 assigned to rError (and 0.0 returned).
757 If the string is not empty the following conversion rules are applied:
759 Converted are only integer numbers including exponent, and ISO 8601 dates
760 and times in their extended formats with separators. Anything else,
761 especially fractional numeric values with decimal separators or dates other
762 than ISO 8601 would be locale dependent and is a no-no. Leading and
763 trailing blanks are ignored.
765 The following ISO 8601 formats are converted:
767 CCYY-MM-DD
768 CCYY-MM-DDThh:mm
769 CCYY-MM-DDThh:mm:ss
770 CCYY-MM-DDThh:mm:ss,s
771 CCYY-MM-DDThh:mm:ss.s
772 hh:mm
773 hh:mm:ss
774 hh:mm:ss,s
775 hh:mm:ss.s
777 The century CC may not be omitted and the two-digit year setting is not
778 taken into account. Instead of the T date and time separator exactly one
779 blank may be used.
781 If a date is given, it must be a valid Gregorian calendar date. In this
782 case the optional time must be in the range 00:00 to 23:59:59.99999...
783 If only time is given, it may have any value for hours, taking elapsed time
784 into account; minutes and seconds are limited to the value 59 as well.
786 If the string can not be converted to a numeric value, the error value
787 passed in nStringNoValueError is assigned to rError.
790 @param rStr
791 The string to be converted.
793 @param rConfig
794 The calculation configuration.
796 @param rError
797 Contains the error on return, if any. If an error was set before
798 and the conversion did not result in an error, still 0.0 is
799 returned.
801 @param nStringNoValueError
802 The error value to be assigned to rError if string could not be
803 converted to number.
805 @param pFormatter
806 The number formatter to use in case of
807 ScCalcConfig::StringConversion::LOCALE. Can but should not be
808 nullptr in which case conversion falls back to
809 ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is
810 detected the null date is assumed to be the standard 1899-12-30
811 instead of the configured null date.
813 @param rCurFmtType
814 Can be assigned a format type in case a date or time or date+time
815 string was converted, e.g. css::util::NumberFormat::DATE or
816 css::util::NumberFormat::TIME or a combination thereof.
819 static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig,
820 FormulaError & rError, FormulaError nStringNoValueError,
821 SvNumberFormatter* pFormatter, short & rCurFmtType );
825 // maybe move to dbdata.hxx (?):
827 enum ScQueryOp
829 SC_EQUAL,
830 SC_LESS,
831 SC_GREATER,
832 SC_LESS_EQUAL,
833 SC_GREATER_EQUAL,
834 SC_NOT_EQUAL,
835 SC_TOPVAL,
836 SC_BOTVAL,
837 SC_TOPPERC,
838 SC_BOTPERC,
839 SC_CONTAINS,
840 SC_DOES_NOT_CONTAIN,
841 SC_BEGINS_WITH,
842 SC_DOES_NOT_BEGIN_WITH,
843 SC_ENDS_WITH,
844 SC_DOES_NOT_END_WITH
847 enum ScQueryConnect
849 SC_AND,
850 SC_OR
853 enum ScSubTotalFunc
855 SUBTOTAL_FUNC_NONE = 0,
856 SUBTOTAL_FUNC_AVE = 1,
857 SUBTOTAL_FUNC_CNT = 2,
858 SUBTOTAL_FUNC_CNT2 = 3,
859 SUBTOTAL_FUNC_MAX = 4,
860 SUBTOTAL_FUNC_MIN = 5,
861 SUBTOTAL_FUNC_PROD = 6,
862 SUBTOTAL_FUNC_STD = 7,
863 SUBTOTAL_FUNC_STDP = 8,
864 SUBTOTAL_FUNC_SUM = 9,
865 SUBTOTAL_FUNC_VAR = 10,
866 SUBTOTAL_FUNC_VARP = 11,
867 SUBTOTAL_FUNC_MED = 12,
868 SUBTOTAL_FUNC_SELECTION_COUNT = 13
871 enum ScAggregateFunc
873 AGGREGATE_FUNC_MEDIAN = 12,
874 AGGREGATE_FUNC_MODSNGL = 13,
875 AGGREGATE_FUNC_LARGE = 14,
876 AGGREGATE_FUNC_SMALL = 15,
877 AGGREGATE_FUNC_PERCINC = 16,
878 AGGREGATE_FUNC_QRTINC = 17,
879 AGGREGATE_FUNC_PERCEXC = 18,
880 AGGREGATE_FUNC_QRTEXC = 19
883 class ScArea;
885 struct ScConsolidateParam
887 SCCOL nCol; // cursor position /
888 SCROW nRow; // or start of destination area respectively
889 SCTAB nTab;
890 ScSubTotalFunc eFunction;
891 sal_uInt16 nDataAreaCount; // number of data areas
892 ScArea** ppDataAreas; // array of pointers into data areas
893 bool bByCol;
894 bool bByRow;
895 bool bReferenceData; // reference source data
897 ScConsolidateParam();
898 ScConsolidateParam( const ScConsolidateParam& r );
899 ~ScConsolidateParam();
901 ScConsolidateParam& operator= ( const ScConsolidateParam& r );
902 bool operator== ( const ScConsolidateParam& r ) const;
903 void Clear (); // = ClearDataAreas()+Members
904 void ClearDataAreas ();
905 void SetAreas ( ScArea* const* ppAreas, sal_uInt16 nCount );
908 #endif
910 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */