Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / inc / global.hxx
blob9c1bb5e377d9ee9db9beda7d0873466e5f6a3bee
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 <osl/endian.h>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include "scdllapi.h"
29 #include <rtl/ustring.hxx>
31 #include <vector>
33 class ImageList;
34 class Bitmap;
35 class SfxItemSet;
36 class Color;
37 struct ScCalcConfig;
38 enum class SvtScriptType;
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 // '\r' does not work on a Mac...
58 #define CHAR_CR char(13)
60 const sal_Unicode CHAR_NBSP = 0x00A0;
61 const sal_Unicode CHAR_SHY = 0x00AD;
62 const sal_Unicode CHAR_ZWSP = 0x200B;
63 const sal_Unicode CHAR_LRM = 0x200E;
64 const sal_Unicode CHAR_RLM = 0x200F;
65 const sal_Unicode CHAR_NBHY = 0x2011;
66 const sal_Unicode CHAR_ZWNBSP = 0x2060;
68 #define MINDOUBLE 1.7e-307
69 #define MAXDOUBLE 1.7e307
71 #define MINZOOM 20
72 #define MAXZOOM 400
74 const SCSIZE MAXSUBTOTAL = 3;
76 #define PIXEL_PER_INCH 96.0
77 #define CM_PER_INCH 2.54
78 #define POINTS_PER_INCH 72.0 /**< PostScript points per inch */
79 #define PIXEL_PER_POINT (PIXEL_PER_INCH / POINTS_PER_INCH)
80 #define TWIPS_PER_POINT 20.0
81 #define TWIPS_PER_INCH (TWIPS_PER_POINT * POINTS_PER_INCH)
82 #define TWIPS_PER_CM (TWIPS_PER_INCH / CM_PER_INCH)
83 #define CM_PER_TWIPS (CM_PER_INCH / TWIPS_PER_INCH)
84 #define TWIPS_PER_PIXEL (TWIPS_PER_INCH / PIXEL_PER_INCH)
85 #define TWIPS_PER_CHAR (TWIPS_PER_INCH / 13.6)
86 #define PIXEL_PER_TWIPS (PIXEL_PER_INCH / TWIPS_PER_INCH)
87 #define HMM_PER_TWIPS (CM_PER_TWIPS * 1000.0)
89 #define STD_COL_WIDTH 1280 /* 2.2577cm, 64.00pt PS */
90 #define STD_EXTRA_WIDTH 113 /* 2mm extra for optimal width,
91 * 0.1986cm with TeX points,
92 * 0.1993cm with PS points. */
94 #define MAX_EXTRA_WIDTH 23811 /* 42cm in TWIPS, 41.8430cm TeX, 41.9999cm PS */
95 #define MAX_EXTRA_HEIGHT 23811
96 #define MAX_COL_WIDTH 56693 /* 1m in TWIPS, 99.6266cm TeX, 100.0001cm PS */
97 #define MAX_ROW_HEIGHT 56693
99 /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
100 #define STD_ROWHEIGHT_DIFF 23
102 namespace sc
104 inline long TwipsToHMM( long nTwips ) { return (nTwips * 127 + 36) / 72; }
105 inline long HMMToTwips( long nHMM ) { return (nHMM * 72 + 63) / 127; }
106 inline long TwipsToEvenHMM( long nTwips ) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
109 // standard size as OLE server (cells)
110 #define OLE_STD_CELLS_X 4
111 #define OLE_STD_CELLS_Y 5
114 // repaint flags (for messages)
115 #define PAINT_GRID 1
116 #define PAINT_TOP 2
117 #define PAINT_LEFT 4
118 #define PAINT_EXTRAS 8
119 #define PAINT_MARKS 16
120 #define PAINT_OBJECTS 32
121 #define PAINT_SIZE 64
122 #define PAINT_ALL ( PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS | PAINT_OBJECTS | PAINT_SIZE )
124 // flags for columns / rows
125 // FILTERED always together with HIDDEN
126 // FILTERED and MANUALSIZE only valid for rows
127 const sal_uInt8 CR_HIDDEN = 1;
128 const sal_uInt8 CR_MANUALBREAK = 8;
129 const sal_uInt8 CR_FILTERED = 16;
130 const sal_uInt8 CR_MANUALSIZE = 32;
131 const sal_uInt8 CR_ALL = (CR_HIDDEN | CR_MANUALBREAK | CR_FILTERED | CR_MANUALSIZE);
133 typedef sal_uInt8 ScBreakType;
134 const ScBreakType BREAK_NONE = 0;
135 const ScBreakType BREAK_PAGE = 1;
136 const ScBreakType BREAK_MANUAL = 2;
138 enum class InsertDeleteFlags : sal_uInt16
140 NONE = 0x0000,
141 VALUE = 0x0001, /// Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
142 DATETIME = 0x0002, /// Dates, times, datetime values.
143 STRING = 0x0004, /// Strings (and string results if InsertDeleteFlags::FORMULA is not set).
144 NOTE = 0x0008, /// Cell notes.
145 FORMULA = 0x0010, /// Formula cells.
146 HARDATTR = 0x0020, /// Hard cell attributes.
147 STYLES = 0x0040, /// Cell styles.
148 OBJECTS = 0x0080, /// Drawing objects.
149 EDITATTR = 0x0100, /// Rich-text attributes.
150 OUTLINE = 0x0800, /// Sheet / outlining (grouping) information
151 NOCAPTIONS = 0x0200, /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
152 ADDNOTES = 0x0400, /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
153 SPECIAL_BOOLEAN = 0x1000,
154 FORGETCAPTIONS = 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes.
155 ATTRIB = HARDATTR | STYLES,
156 CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE,
157 ALL = CONTENTS | ATTRIB | OBJECTS,
158 ALL_USED_BITS = ALL | EDITATTR | NOCAPTIONS | ADDNOTES | SPECIAL_BOOLEAN | FORGETCAPTIONS,
159 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
160 AUTOFILL = ALL & ~(NOTE | OBJECTS)
162 namespace o3tl
164 template<> struct typed_flags<InsertDeleteFlags> : is_typed_flags<InsertDeleteFlags, 0x3fff> {};
166 // This doesn't work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work.
167 //static_assert((InsertDeleteFlags::ATTRIB & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE, "these must match");
170 enum class ScPasteFunc {
171 NONE, ADD, SUB, MUL, DIV
173 // bits for HasAttr
174 #define HASATTR_LINES 1
175 #define HASATTR_MERGED 2
176 #define HASATTR_OVERLAPPED 4
177 #define HASATTR_PROTECTED 8
178 #define HASATTR_SHADOW 16
179 #define HASATTR_NEEDHEIGHT 32
180 #define HASATTR_SHADOW_RIGHT 64
181 #define HASATTR_SHADOW_DOWN 128
182 #define HASATTR_AUTOFILTER 256
183 #define HASATTR_CONDITIONAL 512
184 #define HASATTR_ROTATE 1024
185 #define HASATTR_NOTOVERLAPPED 2048
186 #define HASATTR_RTL 4096
187 #define HASATTR_RIGHTORCENTER 8192 // right or centered logical alignment
189 #define HASATTR_PAINTEXT ( HASATTR_LINES | HASATTR_SHADOW | HASATTR_CONDITIONAL )
191 #define EMPTY_OUSTRING ScGlobal::GetEmptyOUString()
193 // layer id's for drawing
194 #define SC_LAYER_FRONT 0
195 #define SC_LAYER_BACK 1
196 #define SC_LAYER_INTERN 2
197 #define SC_LAYER_CONTROLS 3
198 #define SC_LAYER_HIDDEN 4
200 // link tables
201 enum class ScLinkMode {
202 NONE, NORMAL, VALUE
204 // input
205 enum class ScEnterMode {
206 NORMAL, BLOCK, MATRIX
209 // step = 10pt, max. indention = 100 steps
210 #define SC_INDENT_STEP 200
212 // scenario flags
213 #define SC_SCENARIO_COPYALL 1
214 #define SC_SCENARIO_SHOWFRAME 2
215 #define SC_SCENARIO_PRINTFRAME 4
216 #define SC_SCENARIO_TWOWAY 8
217 #define SC_SCENARIO_ATTRIB 16
218 #define SC_SCENARIO_VALUE 32
219 #define SC_SCENARIO_PROTECT 64
221 #define SUBTOTAL_IGN_NESTED_ST_AG 0x08
222 #define SUBTOTAL_IGN_ERR_VAL 0x04
223 #define SUBTOTAL_IGN_HIDDEN 0x02
224 #define SUBTOTAL_IGN_FILTERED 0x01
226 /** Default cell clone flags: do not start listening, do not adjust 3D refs to
227 old position, clone note captions of cell notes. */
228 const int SC_CLONECELL_DEFAULT = 0x0000;
230 /** If set, cloned formula cells will start to listen to the document. */
231 const int SC_CLONECELL_STARTLISTENING = 0x0001;
233 /** If set, relative 3D references of cloned formula cells will be adjusted to
234 old position (used while swapping cells for sorting a cell range). */
235 const int SC_CLONECELL_ADJUST3DREL = 0x0002;
237 /** If set, the caption object of a cell note will not be cloned (used while
238 copying cells to undo document, where captions are handled in drawing undo). */
239 const int SC_CLONECELL_NOCAPTION = 0x0004;
241 /** If set, absolute refs will not transformed to external references */
242 const int SC_CLONECELL_NOMAKEABS_EXTERNAL = 0x0008;
244 /** If set, global named expressions will be converted to sheet-local named
245 expressions. */
246 const int SC_CLONECELL_NAMES_TO_LOCAL = 0x0010;
248 #ifndef DELETEZ
249 #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
250 #endif
252 // is bit set in set?
253 #define IS_SET(bit,set)(((set)&(bit))==(bit))
255 enum CellType
257 CELLTYPE_NONE,
258 CELLTYPE_VALUE,
259 CELLTYPE_STRING,
260 CELLTYPE_FORMULA,
261 CELLTYPE_EDIT,
264 enum DelCellCmd
266 DEL_CELLSUP,
267 DEL_CELLSLEFT,
268 DEL_DELROWS,
269 DEL_DELCOLS,
270 DEL_NONE
273 enum InsCellCmd
275 INS_CELLSDOWN,
276 INS_CELLSRIGHT,
277 INS_INSROWS_BEFORE,
278 INS_INSCOLS_BEFORE,
279 INS_NONE,
280 INS_INSROWS_AFTER,
281 INS_INSCOLS_AFTER
284 enum UpdateRefMode
286 URM_INSDEL,
287 URM_COPY,
288 URM_MOVE,
289 URM_REORDER
292 enum FillDir
294 FILL_TO_BOTTOM,
295 FILL_TO_RIGHT,
296 FILL_TO_TOP,
297 FILL_TO_LEFT
300 enum FillCmd
302 FILL_SIMPLE,
303 FILL_LINEAR,
304 FILL_GROWTH,
305 FILL_DATE,
306 FILL_AUTO
309 enum ScMoveDirection
311 SC_MOVE_RIGHT,
312 SC_MOVE_LEFT,
313 SC_MOVE_UP,
314 SC_MOVE_DOWN
317 enum FillDateCmd
319 FILL_DAY,
320 FILL_WEEKDAY,
321 FILL_MONTH,
322 FILL_YEAR
325 enum ScDirection
327 DIR_BOTTOM,
328 DIR_RIGHT,
329 DIR_TOP,
330 DIR_LEFT
333 enum ScSizeMode
335 SC_SIZE_DIRECT, // set size or hide if value is 0
336 SC_SIZE_OPTIMAL, // set optimal size for everything
337 SC_SIZE_SHOW, // show with original size
338 SC_SIZE_VISOPT, // set optimal size only if visible
339 SC_SIZE_ORIGINAL // only set size, don't change visible flag
342 enum ScInputMode
344 SC_INPUT_NONE,
345 SC_INPUT_TYPE, // input, while not in inplace mode
346 SC_INPUT_TABLE, // text cursor in the table
347 SC_INPUT_TOP // text cursor in the input line
350 enum ScVObjMode // output modes of objects on a page
352 VOBJ_MODE_SHOW,
353 VOBJ_MODE_HIDE
356 enum ScAnchorType // anchor of a character object
358 SCA_CELL,
359 SCA_PAGE,
360 SCA_DONTKNOW // for multi selection
363 enum ScGetDBMode
365 SC_DB_MAKE, ///< create "untitled" (if necessary)
366 SC_DB_AUTOFILTER, ///< force use of sheet-local instead of document global anonymous range
367 SC_DB_IMPORT, ///< create "Importx" (if necessary)
368 SC_DB_OLD ///< don't create
371 /// For ScDBFunc::GetDBData()
372 enum ScGetDBSelection
374 /** Keep selection as is, expand to used data area if no selection. */
375 SC_DBSEL_KEEP,
377 /** Shrink selection to sheet's data area. */
378 SC_DBSEL_SHRINK_TO_SHEET_DATA,
380 /** Shrink selection to actually used data area within the selection. */
381 SC_DBSEL_SHRINK_TO_USED_DATA,
383 /** If only one row or portion thereof is selected, shrink row to used data
384 columns and select further rows down until end of data. If an area is
385 selected, shrink rows to actually used columns. Else, no selection,
386 expand to used data area. */
387 SC_DBSEL_ROW_DOWN,
389 /** Behave as if the range corresponding to a ScDBData area was selected,
390 for API use. */
391 SC_DBSEL_FORCE_MARK
394 enum ScLkUpdMode // modes for updating links
396 LM_ALWAYS,
397 LM_NEVER,
398 LM_ON_DEMAND,
399 LM_UNKNOWN
402 // enum with values equal to old DBObject enum from sdb
403 enum ScDBObject
405 ScDbTable,
406 ScDbQuery
409 struct ScImportParam
411 SCCOL nCol1;
412 SCROW nRow1;
413 SCCOL nCol2;
414 SCROW nRow2;
415 bool bImport;
416 OUString aDBName; // alias of data base
417 OUString aStatement;
418 bool bNative;
419 bool bSql; // statement or name?
420 sal_uInt8 nType; // enum DBObject
422 ScImportParam();
423 ScImportParam( const ScImportParam& r );
424 ~ScImportParam();
426 ScImportParam& operator= ( const ScImportParam& r );
427 bool operator== ( const ScImportParam& r ) const;
430 class ScDocument;
431 class ScDocShell;
432 class SvxSearchItem;
433 class ScAutoFormat;
434 class LegacyFuncCollection;
435 class ScUnoAddInCollection;
436 class ScUserList;
437 class SvxBrushItem;
438 class ScFunctionList;
439 class ScFunctionMgr;
440 class SfxItemPool;
441 class SdrModel;
442 class EditTextObject;
443 class SfxObjectShell;
444 class SvNumberFormatter;
445 class ScUnitConverter;
446 class CharClass;
447 class LocaleDataWrapper;
448 class SvtSysLocale;
449 class CalendarWrapper;
450 class CollatorWrapper;
451 class IntlWrapper;
452 class OutputDevice;
453 class ScFieldEditEngine;
455 namespace com { namespace sun { namespace star {
456 namespace lang {
457 struct Locale;
459 namespace i18n {
460 class XOrdinalSuffix;
463 namespace utl {
464 class TransliterationWrapper;
467 class ScGlobal
469 static SvxSearchItem* pSearchItem;
470 static ScAutoFormat* pAutoFormat;
471 static LegacyFuncCollection* pLegacyFuncCollection;
472 static ScUnoAddInCollection* pAddInCollection;
473 static ScUserList* pUserList;
474 static OUString** ppRscString;
475 static OUString* pStrScDoc;
476 static OUString* pEmptyOUString;
477 static OUString* pStrClipDocName;
478 static SvxBrushItem* pEmptyBrushItem;
479 static SvxBrushItem* pButtonBrushItem;
480 static SvxBrushItem* pEmbeddedBrushItem;
481 static SvxBrushItem* pProtectedBrushItem;
483 static ImageList* pOutlineBitmaps;
485 static ScFunctionList* pStarCalcFunctionList;
486 static ScFunctionMgr* pStarCalcFunctionMgr;
488 static ScUnitConverter* pUnitConverter;
490 static SvNumberFormatter* pEnglishFormatter; // for UNO / XML export
492 static css::uno::Reference< css::i18n::XOrdinalSuffix> xOrdinalSuffix;
493 static CalendarWrapper* pCalendar;
494 static CollatorWrapper* pCaseCollator;
495 static CollatorWrapper* pCollator;
496 static ::utl::TransliterationWrapper* pTransliteration;
497 static ::utl::TransliterationWrapper* pCaseTransliteration;
498 static IntlWrapper* pScIntlWrapper;
499 static css::lang::Locale* pLocale;
501 static ScFieldEditEngine* pFieldEditEngine;
503 public:
504 static SvtSysLocale* pSysLocale;
505 // for faster access a pointer to the single instance provided by SvtSysLocale
506 SC_DLLPUBLIC static const CharClass* pCharClass;
507 // for faster access a pointer to the single instance provided by SvtSysLocale
508 SC_DLLPUBLIC static const LocaleDataWrapper* pLocaleData;
509 SC_DLLPUBLIC static const LocaleDataWrapper* GetpLocaleData();
511 static CalendarWrapper* GetCalendar();
512 SC_DLLPUBLIC static CollatorWrapper* GetCollator();
513 static CollatorWrapper* GetCaseCollator();
514 static IntlWrapper* GetScIntlWrapper();
515 static css::lang::Locale* GetLocale();
517 SC_DLLPUBLIC static ::utl::TransliterationWrapper* GetpTransliteration();
518 static ::utl::TransliterationWrapper* GetCaseTransliteration();
520 SC_DLLPUBLIC static LanguageType eLnge;
521 static sal_Unicode cListDelimiter;
523 static const OUString& GetClipDocName();
524 static void SetClipDocName( const OUString& rNew );
525 SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem();
526 SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew );
527 SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat();
528 SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat();
529 static void ClearAutoFormat(); //BugId 54209
530 static LegacyFuncCollection* GetLegacyFuncCollection();
531 SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
532 SC_DLLPUBLIC static ScUserList* GetUserList();
533 static void SetUserList( const ScUserList* pNewList );
534 SC_DLLPUBLIC static const OUString& GetRscString( sal_uInt16 nIndex );
535 /// Open the specified URL.
536 /// If pDrawLayer is specified, check if tiled-rendering, and leave clients to handle the openURL action if that's the case.
537 static void OpenURL(const OUString& rURL, const OUString& rTarget, const SdrModel* pDrawLayer = nullptr);
538 SC_DLLPUBLIC static OUString GetAbsDocName( const OUString& rFileName,
539 SfxObjectShell* pShell );
540 SC_DLLPUBLIC static OUString GetDocTabName( const OUString& rFileName,
541 const OUString& rTabName );
542 SC_DLLPUBLIC static sal_uInt32 GetStandardFormat( SvNumberFormatter&, sal_uInt32 nFormat, short nType );
544 SC_DLLPUBLIC static sal_uInt16 GetStandardRowHeight();
545 SC_DLLPUBLIC static double nScreenPPTX;
546 SC_DLLPUBLIC static double nScreenPPTY;
548 static tools::SvRef<ScDocShell> xDrawClipDocShellRef;
550 static sal_uInt16 nDefFontHeight;
551 SC_DLLPUBLIC static sal_uInt16 nStdRowHeight;
553 SC_DLLPUBLIC static long nLastRowHeightExtra;
554 static long nLastColWidthExtra;
556 static void Init(); // during start up
557 static void InitAddIns();
558 static void Clear(); // at the end of the program
560 static void UpdatePPT(OutputDevice* pDev);
562 static void InitTextHeight(SfxItemPool* pPool);
563 static SvxBrushItem* GetEmptyBrushItem() { return pEmptyBrushItem; }
564 static SvxBrushItem* GetButtonBrushItem();
565 static SvxBrushItem* GetProtectedBrushItem() { return pProtectedBrushItem; }
566 SC_DLLPUBLIC static const OUString& GetEmptyOUString();
568 /** Returns the specified image list with outline symbols. */
569 static ImageList* GetOutlineSymbols();
571 static bool HasStarCalcFunctionList();
572 static ScFunctionList* GetStarCalcFunctionList();
573 static ScFunctionMgr* GetStarCalcFunctionMgr();
574 static void ResetFunctionList();
576 static OUString GetErrorString(sal_uInt16 nErrNumber);
577 static OUString GetLongErrorString(sal_uInt16 nErrNumber);
578 static bool EETextObjEqual( const EditTextObject* pObj1,
579 const EditTextObject* pObj2 );
580 static bool CheckWidthInvalidate( bool& bNumFormatChanged,
581 const SfxItemSet& rNewAttrs,
582 const SfxItemSet& rOldAttrs );
583 static bool HasAttrChanged( const SfxItemSet& rNewAttrs,
584 const SfxItemSet& rOldAttrs,
585 const sal_uInt16 nWhich );
587 static ScUnitConverter* GetUnitConverter();
589 /// strchr() functionality on unicode, as long as we need it for FormulaToken etc.
590 static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
592 static inline sal_Unicode ToUpperAlpha( sal_Unicode c )
593 { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
595 /** Adds the string rToken to rTokenList, using a list separator character.
596 @param rTokenList The string list where the token will be appended to.
597 @param rToken The token string to append to the token list.
598 @param cSep The character to separate the tokens.
599 @param nSepCount Specifies how often cSep is inserted between two tokens.
600 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
601 SC_DLLPUBLIC static OUString addToken(
602 const OUString& rTokenList, const OUString& rToken,
603 sal_Unicode cSep, sal_Int32 nSepCount = 1,
604 bool bForceSep = false );
606 /** Returns true, if the first and last character of the string is cQuote. */
607 SC_DLLPUBLIC static bool IsQuoted( const OUString& rString, sal_Unicode cQuote = '\'' );
609 /** Inserts the character cQuote at beginning and end of rString.
610 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
611 escaped by doubling them.
613 SC_DLLPUBLIC static void AddQuotes( OUString& rString, sal_Unicode cQuote = '\'', bool bEscapeEmbedded = true );
615 /** Erases the character cQuote from rString, if it exists at beginning AND end.
616 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
617 are unescaped by replacing them with a
618 single instance.
620 SC_DLLPUBLIC static void EraseQuotes( OUString& rString, sal_Unicode cQuote = '\'', bool bUnescapeEmbedded = true );
622 /** Finds an unquoted instance of cChar in rString, starting at
623 offset nStart. Unquoted instances may occur when concatenating two
624 quoted strings with a separator, for example, 's1':'s2'. Embedded
625 quotes have to be escaped by being doubled. Caller must ensure that
626 nStart points into an unquoted range or the opening quote. Specialty:
627 if cChar==cQuote the first cQuote character from nStart on is found.
628 @returns offset if found, else -1
630 SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar);
632 /** Finds an unquoted instance of cChar in null-terminated pString. Same
633 semantics as FindUnquoted( const String&, ...)
634 @returns: pointer to cChar if found, else NULL
636 SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar );
638 static rtl_TextEncoding GetCharsetValue( const OUString& rCharSet );
639 static OUString GetCharsetString( rtl_TextEncoding eVal );
641 /// a "ReadOnly" formatter for UNO/XML export
642 static SvNumberFormatter* GetEnglishFormatter();
644 static bool IsSystemRTL(); // depending on system language
645 static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
646 SC_DLLPUBLIC static SvtScriptType GetDefaultScriptType(); // for all WEAK characters
647 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
648 If more than one SvtScriptType::... values are or'ed together, prefers
649 first COMPLEX, then ASIAN */
650 SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( SvtScriptType nScriptType, sal_uInt16 nWhich );
652 /** Adds a language item to the item set, if the number format item contains
653 a language that differs from its parent's language. */
654 SC_DLLPUBLIC static void AddLanguage( SfxItemSet& rSet, SvNumberFormatter& rFormatter );
656 /** Obtain the ordinal suffix for a number according to the system locale */
657 static OUString GetOrdinalSuffix( sal_Int32 nNumber);
659 /** A static instance of ScFieldEditEngine not capable of resolving
660 document specific fields, to be used only by ScEditUtil::GetString(). */
661 static ScFieldEditEngine& GetStaticFieldEditEngine();
663 /** Replaces the first occurrence of rPlaceholder in rString with
664 rReplacement, or if rPlaceholder is not found appends one space if
665 rString does not end in a space and appends rReplacement.
667 Meant to be used with resource strings ala "Column %1" where a
668 translation may have omitted the %1 placeholder and a simple
669 replacement would end up with nothing replaced so no column indicator
670 in the result string.
672 SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString,
673 const OUString& rPlaceholder,
674 const OUString& rReplacement );
677 /** Convert string content to numeric value.
679 In any case, if rError is set 0.0 is returned.
681 If nStringNoValueError is errCellNoValue, that is unconditionally
682 assigned to rError and 0.0 is returned. The caller is expected to
683 handle this situation. Used by the interpreter.
685 Usually errNoValue is passed as nStringNoValueError.
687 Otherwise, depending on the string conversion configuration different
688 approaches are taken:
691 For ScCalcConfig::StringConversion::ILLEGAL
692 The error value passed in nStringNoValueError is assigned to rError
693 (and 0.0 returned).
696 For ScCalcConfig::StringConversion::ZERO
697 A zero value is returned and no error assigned.
700 For ScCalcConfig::StringConversion::LOCALE
702 If the string is empty or consists only of spaces, if "treat empty
703 string as zero" is set 0.0 is returned, else nStringNoValueError
704 assigned to rError (and 0.0 returned).
706 Else a non-empty string is passed to the number formatter's scanner to
707 be parsed locale dependent. If that does not detect a numeric value
708 nStringNoValueError is assigned to rError (and 0.0 returned).
710 If no number formatter was passed, the conversion falls back to
711 UNAMBIGUOUS.
714 For ScCalcConfig::StringConversion::UNAMBIGUOUS
716 If the string is empty or consists only of spaces, if "treat empty
717 string as zero" is set 0.0 is returned, else nStringNoValueError
718 assigned to rError (and 0.0 returned).
720 If the string is not empty the following conversion rules are applied:
722 Converted are only integer numbers including exponent, and ISO 8601 dates
723 and times in their extended formats with separators. Anything else,
724 especially fractional numeric values with decimal separators or dates other
725 than ISO 8601 would be locale dependent and is a no-no. Leading and
726 trailing blanks are ignored.
728 The following ISO 8601 formats are converted:
730 CCYY-MM-DD
731 CCYY-MM-DDThh:mm
732 CCYY-MM-DDThh:mm:ss
733 CCYY-MM-DDThh:mm:ss,s
734 CCYY-MM-DDThh:mm:ss.s
735 hh:mm
736 hh:mm:ss
737 hh:mm:ss,s
738 hh:mm:ss.s
740 The century CC may not be omitted and the two-digit year setting is not
741 taken into account. Instead of the T date and time separator exactly one
742 blank may be used.
744 If a date is given, it must be a valid Gregorian calendar date. In this
745 case the optional time must be in the range 00:00 to 23:59:59.99999...
746 If only time is given, it may have any value for hours, taking elapsed time
747 into account; minutes and seconds are limited to the value 59 as well.
749 If the string can not be converted to a numeric value, the error value
750 passed in nStringNoValueError is assigned to rError.
753 @param rStr
754 The string to be converted.
756 @param rConfig
757 The calculation configuration.
759 @param rError
760 Contains the error on return, if any. If an error was set before
761 and the conversion did not result in an error, still 0.0 is
762 returned.
764 @param nStringNoValueError
765 The error value to be assigned to rError if string could not be
766 converted to number.
768 @param pFormatter
769 The number formatter to use in case of
770 ScCalcConfig::StringConversion::LOCALE. Can but should not be
771 nullptr in which case conversion falls back to
772 ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is
773 detected the null date is assumed to be the standard 1899-12-30
774 instead of the configured null date.
776 @param rCurFmtType
777 Can be assigned a format type in case a date or time or date+time
778 string was converted, e.g. css::util::NumberFormat::DATE or
779 css::util::NumberFormat::TIME or a combination thereof.
782 static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig,
783 sal_uInt16 & rError, sal_uInt16 nStringNoValueError,
784 SvNumberFormatter* pFormatter, short & rCurFmtType );
788 // maybe move to dbdata.hxx (?):
790 enum ScQueryOp
792 SC_EQUAL,
793 SC_LESS,
794 SC_GREATER,
795 SC_LESS_EQUAL,
796 SC_GREATER_EQUAL,
797 SC_NOT_EQUAL,
798 SC_TOPVAL,
799 SC_BOTVAL,
800 SC_TOPPERC,
801 SC_BOTPERC,
802 SC_CONTAINS,
803 SC_DOES_NOT_CONTAIN,
804 SC_BEGINS_WITH,
805 SC_DOES_NOT_BEGIN_WITH,
806 SC_ENDS_WITH,
807 SC_DOES_NOT_END_WITH
810 enum ScQueryConnect
812 SC_AND,
813 SC_OR
816 enum ScSubTotalFunc
818 SUBTOTAL_FUNC_NONE = 0,
819 SUBTOTAL_FUNC_AVE = 1,
820 SUBTOTAL_FUNC_CNT = 2,
821 SUBTOTAL_FUNC_CNT2 = 3,
822 SUBTOTAL_FUNC_MAX = 4,
823 SUBTOTAL_FUNC_MIN = 5,
824 SUBTOTAL_FUNC_PROD = 6,
825 SUBTOTAL_FUNC_STD = 7,
826 SUBTOTAL_FUNC_STDP = 8,
827 SUBTOTAL_FUNC_SUM = 9,
828 SUBTOTAL_FUNC_VAR = 10,
829 SUBTOTAL_FUNC_VARP = 11,
830 SUBTOTAL_FUNC_SELECTION_COUNT = 12
833 enum ScAggregateFunc
835 AGGREGATE_FUNC_MEDIAN = 12,
836 AGGREGATE_FUNC_MODSNGL = 13,
837 AGGREGATE_FUNC_LARGE = 14,
838 AGGREGATE_FUNC_SMALL = 15,
839 AGGREGATE_FUNC_PERCINC = 16,
840 AGGREGATE_FUNC_QRTINC = 17,
841 AGGREGATE_FUNC_PERCEXC = 18,
842 AGGREGATE_FUNC_QRTEXC = 19
845 class ScArea;
847 struct ScConsolidateParam
849 SCCOL nCol; // cursor position /
850 SCROW nRow; // or start of destination area respectively
851 SCTAB nTab;
852 ScSubTotalFunc eFunction;
853 sal_uInt16 nDataAreaCount; // number of data areas
854 ScArea** ppDataAreas; // array of pointers into data areas
855 bool bByCol;
856 bool bByRow;
857 bool bReferenceData; // reference source data
859 ScConsolidateParam();
860 ScConsolidateParam( const ScConsolidateParam& r );
861 ~ScConsolidateParam();
863 ScConsolidateParam& operator= ( const ScConsolidateParam& r );
864 bool operator== ( const ScConsolidateParam& r ) const;
865 void Clear (); // = ClearDataAreas()+Members
866 void ClearDataAreas ();
867 void SetAreas ( ScArea* const* ppAreas, sal_uInt16 nCount );
870 #endif
872 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */