1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
29 #include <rtl/ustring.hxx>
38 enum class SvtScriptType
;
40 #define SC_COLLATOR_IGNORES ( \
41 ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE )
43 #define SC_TRANSLITERATION_IGNORECASE ( \
44 ::com::sun::star::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"
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
74 const SCSIZE MAXSUBTOTAL
= 3;
76 #define SC_USE_PS_POINTS 1 /**< use PostScript points (72ppi) instead of old TeX points (72.27ppi) */
78 #define PIXEL_PER_INCH 96.0
80 #define CM_PER_INCH 2.54
81 #define PS_POINTS_PER_INCH 72.0 /**< PostScript points per inch */
82 #define TEX_POINTS_PER_INCH 72.27 /**< old printer points, or TeX points per inch */
84 #define POINTS_PER_INCH PS_POINTS_PER_INCH /**< the actual definition of points used */
86 #define POINTS_PER_INCH TEX_POINTS_PER_INCH
88 #define PIXEL_PER_POINT (PIXEL_PER_INCH / POINTS_PER_INCH)
89 #define TWIPS_PER_POINT 20.0
90 #define TWIPS_PER_INCH (TWIPS_PER_POINT * POINTS_PER_INCH)
91 #define TWIPS_PER_CM (TWIPS_PER_INCH / CM_PER_INCH)
92 #define CM_PER_TWIPS (CM_PER_INCH / TWIPS_PER_INCH)
93 #define TWIPS_PER_PIXEL (TWIPS_PER_INCH / PIXEL_PER_INCH)
94 #define TWIPS_PER_CHAR (TWIPS_PER_INCH / 13.6)
95 #define PIXEL_PER_TWIPS (PIXEL_PER_INCH / TWIPS_PER_INCH)
96 #define HMM_PER_TWIPS (CM_PER_TWIPS * 1000.0)
99 #define STD_COL_WIDTH 1280 /* 2.2577cm, 64.00pt PS */
101 #define STD_COL_WIDTH 1285 /* 2.2581cm, 64.25pt TeX */
103 #define STD_EXTRA_WIDTH 113 /* 2mm extra for optimal width,
104 * 0.1986cm with TeX points,
105 * 0.1993cm with PS points. */
107 #define MAX_EXTRA_WIDTH 23811 /* 42cm in TWIPS, 41.8430cm TeX, 41.9999cm PS */
108 #define MAX_EXTRA_HEIGHT 23811
109 #define MAX_COL_WIDTH 56693 /* 1m in TWIPS, 99.6266cm TeX, 100.0001cm PS */
110 #define MAX_ROW_HEIGHT 56693
112 /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
113 #define STD_ROWHEIGHT_DIFF 23
117 inline long TwipsToHMM( long nTwips
) { return (nTwips
* 127 + 36) / 72; }
118 inline long HMMToTwips( long nHMM
) { return (nHMM
* 72 + 63) / 127; }
119 inline long TwipsToEvenHMM( long nTwips
) { return ( (nTwips
* 127 + 72) / 144 ) * 2; }
122 // standard size as OLE server (cells)
123 #define OLE_STD_CELLS_X 4
124 #define OLE_STD_CELLS_Y 5
127 // repaint flags (for messages)
131 #define PAINT_EXTRAS 8
132 #define PAINT_MARKS 16
133 #define PAINT_OBJECTS 32
134 #define PAINT_SIZE 64
135 #define PAINT_ALL ( PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS | PAINT_OBJECTS | PAINT_SIZE )
137 // flags for columns / rows
138 // FILTERED always together with HIDDEN
139 // FILTERED and MANUALSIZE only valid for rows
140 const sal_uInt8 CR_HIDDEN
= 1;
141 const sal_uInt8 CR_MANUALBREAK
= 8;
142 const sal_uInt8 CR_FILTERED
= 16;
143 const sal_uInt8 CR_MANUALSIZE
= 32;
144 const sal_uInt8 CR_ALL
= (CR_HIDDEN
| CR_MANUALBREAK
| CR_FILTERED
| CR_MANUALSIZE
);
146 typedef sal_uInt8 ScBreakType
;
147 const ScBreakType BREAK_NONE
= 0;
148 const ScBreakType BREAK_PAGE
= 1;
149 const ScBreakType BREAK_MANUAL
= 2;
151 // insert/delete flags - typesafe bitfield
152 struct InsertDeleteFlags SAL_FINAL
{
155 // hidden so that it doesn't accidentally get called in constructor initialiser lists
156 explicit InsertDeleteFlags(sal_uInt16 _v
) : v(_v
) {}
158 static InsertDeleteFlags
fromInt(sal_uInt16 v
) { return InsertDeleteFlags(v
); }
159 operator bool() const { return v
!= 0; }
160 sal_uInt16
val() const { return v
; }
161 bool operator ==(const InsertDeleteFlags
& other
) const { return v
== other
.v
; }
162 bool operator !=(const InsertDeleteFlags
& other
) const { return v
!= other
.v
; }
164 // disallow implicit conversion to int
165 operator int() const { return v
; }
167 // make combining these type-safe
168 inline InsertDeleteFlags
operator| (const InsertDeleteFlags
& lhs
, const InsertDeleteFlags
& rhs
)
170 return InsertDeleteFlags::fromInt(lhs
.val() | rhs
.val());
172 inline InsertDeleteFlags
operator& (const InsertDeleteFlags
& lhs
, const InsertDeleteFlags
& rhs
)
174 return InsertDeleteFlags::fromInt(lhs
.val() & rhs
.val());
176 inline InsertDeleteFlags
& operator|= (InsertDeleteFlags
& lhs
, const InsertDeleteFlags
& rhs
)
178 lhs
= InsertDeleteFlags::fromInt(lhs
.val() | rhs
.val());
181 inline InsertDeleteFlags
& operator&= (InsertDeleteFlags
& lhs
, const InsertDeleteFlags
& rhs
)
183 lhs
= InsertDeleteFlags::fromInt(lhs
.val() & rhs
.val());
187 const InsertDeleteFlags IDF_NONE
= InsertDeleteFlags::fromInt(0x0000);
188 const InsertDeleteFlags IDF_VALUE
= InsertDeleteFlags::fromInt(0x0001); /// Numeric values (and numeric results if IDF_FORMULA is not set).
189 const InsertDeleteFlags IDF_DATETIME
= InsertDeleteFlags::fromInt(0x0002); /// Dates, times, datetime values.
190 const InsertDeleteFlags IDF_STRING
= InsertDeleteFlags::fromInt(0x0004); /// Strings (and string results if IDF_FORMULA is not set).
191 const InsertDeleteFlags IDF_NOTE
= InsertDeleteFlags::fromInt(0x0008); /// Cell notes.
192 const InsertDeleteFlags IDF_FORMULA
= InsertDeleteFlags::fromInt(0x0010); /// Formula cells.
193 const InsertDeleteFlags IDF_HARDATTR
= InsertDeleteFlags::fromInt(0x0020); /// Hard cell attributes.
194 const InsertDeleteFlags IDF_STYLES
= InsertDeleteFlags::fromInt(0x0040); /// Cell styles.
195 const InsertDeleteFlags IDF_OBJECTS
= InsertDeleteFlags::fromInt(0x0080); /// Drawing objects.
196 const InsertDeleteFlags IDF_EDITATTR
= InsertDeleteFlags::fromInt(0x0100); /// Rich-text attributes.
197 const InsertDeleteFlags IDF_OUTLINE
= InsertDeleteFlags::fromInt(0x0800); /// Sheet / outlining (grouping) information
198 const InsertDeleteFlags IDF_NOCAPTIONS
= InsertDeleteFlags::fromInt(0x0200); /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
199 const InsertDeleteFlags IDF_ADDNOTES
= InsertDeleteFlags::fromInt(0x0400); /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
200 const InsertDeleteFlags IDF_SPECIAL_BOOLEAN
= InsertDeleteFlags::fromInt(0x1000);
201 const InsertDeleteFlags IDF_FORGETCAPTIONS
= InsertDeleteFlags::fromInt(0x2000); /// Internal use only (d&d undo): do not delete caption objects of cell notes.
202 const InsertDeleteFlags IDF_ATTRIB
= IDF_HARDATTR
| IDF_STYLES
;
203 const InsertDeleteFlags IDF_CONTENTS
= IDF_VALUE
| IDF_DATETIME
| IDF_STRING
| IDF_NOTE
| IDF_FORMULA
| IDF_OUTLINE
;
204 const InsertDeleteFlags IDF_ALL
= IDF_CONTENTS
| IDF_ATTRIB
| IDF_OBJECTS
;
205 const InsertDeleteFlags IDF_ALL_USED_BITS
= IDF_ALL
| IDF_EDITATTR
| IDF_NOCAPTIONS
| IDF_ADDNOTES
| IDF_SPECIAL_BOOLEAN
| IDF_FORGETCAPTIONS
;
207 inline InsertDeleteFlags
operator~ (const InsertDeleteFlags
& rhs
)
209 return IDF_ALL_USED_BITS
& InsertDeleteFlags::fromInt(~rhs
.val());
212 // This doesnt work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work.
213 //static_assert((IDF_ATTRIB & IDF_CONTENTS) == IDF_NONE, "these must match");
215 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
216 const InsertDeleteFlags IDF_AUTOFILL
= IDF_ALL
& ~(IDF_NOTE
| IDF_OBJECTS
);
218 #define PASTE_NOFUNC 0
225 #define HASATTR_LINES 1
226 #define HASATTR_MERGED 2
227 #define HASATTR_OVERLAPPED 4
228 #define HASATTR_PROTECTED 8
229 #define HASATTR_SHADOW 16
230 #define HASATTR_NEEDHEIGHT 32
231 #define HASATTR_SHADOW_RIGHT 64
232 #define HASATTR_SHADOW_DOWN 128
233 #define HASATTR_AUTOFILTER 256
234 #define HASATTR_CONDITIONAL 512
235 #define HASATTR_ROTATE 1024
236 #define HASATTR_NOTOVERLAPPED 2048
237 #define HASATTR_RTL 4096
238 #define HASATTR_RIGHTORCENTER 8192 // right or centered logical alignment
240 #define HASATTR_PAINTEXT ( HASATTR_LINES | HASATTR_SHADOW | HASATTR_CONDITIONAL )
242 #define EMPTY_OUSTRING ScGlobal::GetEmptyOUString()
244 // layer id's for drawing
245 #define SC_LAYER_FRONT 0
246 #define SC_LAYER_BACK 1
247 #define SC_LAYER_INTERN 2
248 #define SC_LAYER_CONTROLS 3
249 #define SC_LAYER_HIDDEN 4
252 #define SC_LINK_NONE 0
253 #define SC_LINK_NORMAL 1
254 #define SC_LINK_VALUE 2
257 #define SC_ENTER_NORMAL 0
258 #define SC_ENTER_BLOCK 1
259 #define SC_ENTER_MATRIX 2
261 // step = 10pt, max. indention = 100 steps
262 #define SC_INDENT_STEP 200
265 #define SC_SCENARIO_COPYALL 1
266 #define SC_SCENARIO_SHOWFRAME 2
267 #define SC_SCENARIO_PRINTFRAME 4
268 #define SC_SCENARIO_TWOWAY 8
269 #define SC_SCENARIO_ATTRIB 16
270 #define SC_SCENARIO_VALUE 32
271 #define SC_SCENARIO_PROTECT 64
273 #define SUBTOTAL_IGN_NESTED_ST_AG 0x08
274 #define SUBTOTAL_IGN_ERR_VAL 0x04
275 #define SUBTOTAL_IGN_HIDDEN 0x02
276 #define SUBTOTAL_IGN_FILTERED 0x01
278 /** Default cell clone flags: do not start listening, do not adjust 3D refs to
279 old position, clone note captions of cell notes. */
280 const int SC_CLONECELL_DEFAULT
= 0x0000;
282 /** If set, cloned formula cells will start to listen to the document. */
283 const int SC_CLONECELL_STARTLISTENING
= 0x0001;
285 /** If set, relative 3D references of cloned formula cells will be adjusted to
286 old position (used while swapping cells for sorting a cell range). */
287 const int SC_CLONECELL_ADJUST3DREL
= 0x0002;
289 /** If set, the caption object of a cell note will not be cloned (used while
290 copying cells to undo document, where captions are handled in drawing undo). */
291 const int SC_CLONECELL_NOCAPTION
= 0x0004;
293 /** If set, absolute refs will not transformed to external references */
294 const int SC_CLONECELL_NOMAKEABS_EXTERNAL
= 0x0008;
297 #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
300 // is bit set in set?
301 #define IS_SET(bit,set)(((set)&(bit))==(bit))
381 SC_SIZE_DIRECT
, // set size or hide if value is 0
382 SC_SIZE_OPTIMAL
, // set optimal size for everything
383 SC_SIZE_SHOW
, // show with original size
384 SC_SIZE_VISOPT
, // set optimal size only if visible
385 SC_SIZE_ORIGINAL
// only set size, don't change visible flag
391 SC_INPUT_TYPE
, // input, while not in inplace mode
392 SC_INPUT_TABLE
, // text cursor in the table
393 SC_INPUT_TOP
// text cursor in the input line
396 enum ScVObjMode
// output modes of objects on a page
402 enum ScAnchorType
// anchor of a character object
406 SCA_DONTKNOW
// for multi selection
411 SC_DB_MAKE
, // create "untitled" (if necessary)
412 SC_DB_IMPORT
, // create "Importx" (if necessary)
413 SC_DB_OLD
// don't create
416 /// For ScDBFunc::GetDBData()
417 enum ScGetDBSelection
419 /** Keep selection as is, expand to used data area if no selection. */
422 /** Shrink selection to sheet's data area. */
423 SC_DBSEL_SHRINK_TO_SHEET_DATA
,
425 /** Shrink selection to actually used data area within the selection. */
426 SC_DBSEL_SHRINK_TO_USED_DATA
,
428 /** If only one row or portion thereof is selected, shrink row to used data
429 columns and select further rows down until end of data. If an area is
430 selected, shrink rows to actually used columns. Else, no selection,
431 expand to used data area. */
434 /** Behave as if the range corresponding to a ScDBData area was selected,
439 enum ScLkUpdMode
// modes for updating links
447 // enum with values equal to old DBObject enum from sdb
461 OUString aDBName
; // alias of data base
464 bool bSql
; // statement or name?
465 sal_uInt8 nType
; // enum DBObject
468 ScImportParam( const ScImportParam
& r
);
471 ScImportParam
& operator= ( const ScImportParam
& r
);
472 bool operator== ( const ScImportParam
& r
) const;
479 class FuncCollection
;
480 class ScUnoAddInCollection
;
483 class ScFunctionList
;
487 class EditTextObject
;
488 class SfxObjectShell
;
489 class SvNumberFormatter
;
490 class ScUnitConverter
;
492 class LocaleDataWrapper
;
494 class CalendarWrapper
;
495 class CollatorWrapper
;
498 class ScFieldEditEngine
;
500 namespace com
{ namespace sun
{ namespace star
{
505 class XOrdinalSuffix
;
509 class TransliterationWrapper
;
515 static SvxSearchItem
* pSearchItem
;
516 static ScAutoFormat
* pAutoFormat
;
517 static FuncCollection
* pFuncCollection
;
518 static ScUnoAddInCollection
* pAddInCollection
;
519 static ScUserList
* pUserList
;
520 static OUString
** ppRscString
;
521 static OUString
* pStrScDoc
;
522 static OUString
* pEmptyOUString
;
523 static OUString
* pStrClipDocName
;
524 static SvxBrushItem
* pEmptyBrushItem
;
525 static SvxBrushItem
* pButtonBrushItem
;
526 static SvxBrushItem
* pEmbeddedBrushItem
;
527 static SvxBrushItem
* pProtectedBrushItem
;
529 static ImageList
* pOutlineBitmaps
;
531 static ScFunctionList
* pStarCalcFunctionList
;
532 static ScFunctionMgr
* pStarCalcFunctionMgr
;
534 static ScUnitConverter
* pUnitConverter
;
536 static SvNumberFormatter
* pEnglishFormatter
; // for UNO / XML export
538 static ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XOrdinalSuffix
> xOrdinalSuffix
;
539 static CalendarWrapper
* pCalendar
;
540 static CollatorWrapper
* pCaseCollator
;
541 static CollatorWrapper
* pCollator
;
542 static ::utl::TransliterationWrapper
* pTransliteration
;
543 static ::utl::TransliterationWrapper
* pCaseTransliteration
;
544 static IntlWrapper
* pScIntlWrapper
;
545 static ::com::sun::star::lang::Locale
* pLocale
;
547 static ScFieldEditEngine
* pFieldEditEngine
;
550 static SvtSysLocale
* pSysLocale
;
551 // for faster access a pointer to the single instance provided by SvtSysLocale
552 SC_DLLPUBLIC
static const CharClass
* pCharClass
;
553 // for faster access a pointer to the single instance provided by SvtSysLocale
554 SC_DLLPUBLIC
static const LocaleDataWrapper
* pLocaleData
;
555 SC_DLLPUBLIC
static const LocaleDataWrapper
* GetpLocaleData();
557 static CalendarWrapper
* GetCalendar();
558 SC_DLLPUBLIC
static CollatorWrapper
* GetCollator();
559 static CollatorWrapper
* GetCaseCollator();
560 static IntlWrapper
* GetScIntlWrapper();
561 static ::com::sun::star::lang::Locale
* GetLocale();
563 SC_DLLPUBLIC
static ::utl::TransliterationWrapper
* GetpTransliteration();
564 static ::utl::TransliterationWrapper
* GetCaseTransliteration();
566 SC_DLLPUBLIC
static LanguageType eLnge
;
567 static sal_Unicode cListDelimiter
;
569 static const OUString
& GetClipDocName();
570 static void SetClipDocName( const OUString
& rNew
);
571 SC_DLLPUBLIC
static const SvxSearchItem
& GetSearchItem();
572 SC_DLLPUBLIC
static void SetSearchItem( const SvxSearchItem
& rNew
);
573 SC_DLLPUBLIC
static ScAutoFormat
* GetAutoFormat();
574 SC_DLLPUBLIC
static ScAutoFormat
* GetOrCreateAutoFormat();
575 static void ClearAutoFormat(); //BugId 54209
576 static FuncCollection
* GetFuncCollection();
577 SC_DLLPUBLIC
static ScUnoAddInCollection
* GetAddInCollection();
578 SC_DLLPUBLIC
static ScUserList
* GetUserList();
579 static void SetUserList( const ScUserList
* pNewList
);
580 SC_DLLPUBLIC
static const OUString
& GetRscString( sal_uInt16 nIndex
);
581 /// Open the specified URL.
582 /// If pDrawLayer is specified, check if tiled-rendering, and leave clients to handle the openURL action if that's the case.
583 static void OpenURL(const OUString
& rURL
, const OUString
& rTarget
, const SdrModel
* pDrawLayer
= NULL
);
584 SC_DLLPUBLIC
static OUString
GetAbsDocName( const OUString
& rFileName
,
585 SfxObjectShell
* pShell
);
586 SC_DLLPUBLIC
static OUString
GetDocTabName( const OUString
& rFileName
,
587 const OUString
& rTabName
);
588 SC_DLLPUBLIC
static sal_uLong
GetStandardFormat( SvNumberFormatter
&,
589 sal_uLong nFormat
, short nType
);
591 SC_DLLPUBLIC
static sal_uInt16
GetStandardRowHeight();
592 SC_DLLPUBLIC
static double nScreenPPTX
;
593 SC_DLLPUBLIC
static double nScreenPPTY
;
595 static tools::SvRef
<ScDocShell
>* pDrawClipDocShellRef
;
597 static sal_uInt16 nDefFontHeight
;
598 SC_DLLPUBLIC
static sal_uInt16 nStdRowHeight
;
600 SC_DLLPUBLIC
static long nLastRowHeightExtra
;
601 static long nLastColWidthExtra
;
603 static void Init(); // during start up
604 static void InitAddIns();
605 static void Clear(); // at the end of the program
607 static void UpdatePPT(OutputDevice
* pDev
);
609 static void InitTextHeight(SfxItemPool
* pPool
);
610 static SvxBrushItem
* GetEmptyBrushItem() { return pEmptyBrushItem
; }
611 static SvxBrushItem
* GetButtonBrushItem();
612 static SvxBrushItem
* GetEmbeddedBrushItem() { return pEmbeddedBrushItem
; }
613 static SvxBrushItem
* GetProtectedBrushItem() { return pProtectedBrushItem
; }
614 SC_DLLPUBLIC
static const OUString
& GetEmptyOUString();
615 static const OUString
& GetScDocString();
617 /** Returns the specified image list with outline symbols. */
618 static ImageList
* GetOutlineSymbols();
620 static bool HasStarCalcFunctionList();
621 static ScFunctionList
* GetStarCalcFunctionList();
622 static ScFunctionMgr
* GetStarCalcFunctionMgr();
623 static void ResetFunctionList();
625 static OUString
GetErrorString(sal_uInt16 nErrNumber
);
626 static OUString
GetLongErrorString(sal_uInt16 nErrNumber
);
627 static bool EETextObjEqual( const EditTextObject
* pObj1
,
628 const EditTextObject
* pObj2
);
629 static bool CheckWidthInvalidate( bool& bNumFormatChanged
,
630 const SfxItemSet
& rNewAttrs
,
631 const SfxItemSet
& rOldAttrs
);
632 static bool HasAttrChanged( const SfxItemSet
& rNewAttrs
,
633 const SfxItemSet
& rOldAttrs
,
634 const sal_uInt16 nWhich
);
636 static ScUnitConverter
* GetUnitConverter();
638 /// strchr() functionality on unicode, as long as we need it for FormulaToken etc.
639 static const sal_Unicode
* UnicodeStrChr( const sal_Unicode
* pStr
, sal_Unicode c
);
641 static inline sal_Unicode
ToUpperAlpha( sal_Unicode c
)
642 { return ( c
>= 'a' && c
<= 'z' ) ? ( c
-'a'+'A' ) : c
; }
644 /** Adds the string rToken to rTokenList, using a list separator character.
645 @param rTokenList The string list where the token will be appended to.
646 @param rToken The token string to append to the token list.
647 @param cSep The character to separate the tokens.
648 @param nSepCount Specifies how often cSep is inserted between two tokens.
649 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
650 SC_DLLPUBLIC
static OUString
addToken(
651 const OUString
& rTokenList
, const OUString
& rToken
,
652 sal_Unicode cSep
, sal_Int32 nSepCount
= 1,
653 bool bForceSep
= false );
655 /** Returns true, if the first and last character of the string is cQuote. */
656 SC_DLLPUBLIC
static bool IsQuoted( const OUString
& rString
, sal_Unicode cQuote
= '\'' );
658 /** Inserts the character cQuote at beginning and end of rString.
659 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
660 escaped by doubling them.
662 SC_DLLPUBLIC
static void AddQuotes( OUString
& rString
, sal_Unicode cQuote
= '\'', bool bEscapeEmbedded
= true );
664 /** Erases the character cQuote from rString, if it exists at beginning AND end.
665 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
666 are unescaped by replacing them with a
669 SC_DLLPUBLIC
static void EraseQuotes( OUString
& rString
, sal_Unicode cQuote
= '\'', bool bUnescapeEmbedded
= true );
671 /** Finds an unquoted instance of cChar in rString, starting at
672 offset nStart. Unquoted instances may occur when concatenating two
673 quoted strings with a separator, for example, 's1':'s2'. Embedded
674 quotes have to be escaped by being doubled. Caller must ensure that
675 nStart points into an unquoted range or the opening quote. Specialty:
676 if cChar==cQuote the first cQuote character from nStart on is found.
677 @returns offset if found, else -1
679 SC_DLLPUBLIC
static sal_Int32
FindUnquoted( const OUString
& rString
, sal_Unicode cChar
);
681 /** Finds an unquoted instance of cChar in null-terminated pString. Same
682 semantics as FindUnquoted( const String&, ...)
683 @returns: pointer to cChar if found, else NULL
685 SC_DLLPUBLIC
static const sal_Unicode
* FindUnquoted( const sal_Unicode
* pString
, sal_Unicode cChar
, sal_Unicode cQuote
= '\'' );
687 static rtl_TextEncoding
GetCharsetValue( const OUString
& rCharSet
);
688 static OUString
GetCharsetString( rtl_TextEncoding eVal
);
690 /// a "ReadOnly" formatter for UNO/XML export
691 static SvNumberFormatter
* GetEnglishFormatter();
693 static bool IsSystemRTL(); // depending on system language
694 static LanguageType
GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
695 SC_DLLPUBLIC
static SvtScriptType
GetDefaultScriptType(); // for all WEAK characters
696 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
697 If more than one SvtScriptType::... values are or'ed together, prefers
698 first COMPLEX, then ASIAN */
699 SC_DLLPUBLIC
static sal_uInt16
GetScriptedWhichID( SvtScriptType nScriptType
, sal_uInt16 nWhich
);
701 /** Adds a language item to the item set, if the number format item contains
702 a language that differs from its parent's language. */
703 SC_DLLPUBLIC
static void AddLanguage( SfxItemSet
& rSet
, SvNumberFormatter
& rFormatter
);
705 /** Obtain the ordinal suffix for a number according to the system locale */
706 static OUString
GetOrdinalSuffix( sal_Int32 nNumber
);
708 /** A static instance of ScFieldEditEngine not capable of resolving
709 document specific fields, to be used only by ScEditUtil::GetString(). */
710 static ScFieldEditEngine
& GetStaticFieldEditEngine();
712 /** Replaces the first occurrence of rPlaceholder in rString with
713 rReplacement, or if rPlaceholder is not found appends one space if
714 rString does not end in a space and appends rReplacement.
716 Meant to be used with resource strings ala "Column %1" where a
717 translation may have omitted the %1 placeholder and a simple
718 replacement would end up with nothing replaced so no column indicator
719 in the result string.
721 SC_DLLPUBLIC
static OUString
ReplaceOrAppend( const OUString
& rString
,
722 const OUString
& rPlaceholder
,
723 const OUString
& rReplacement
);
726 /** Convert string content to numeric value.
728 In any case, if rError is set 0.0 is returned.
730 If nStringNoValueError is errCellNoValue, that is unconditionally
731 assigned to rError and 0.0 is returned. The caller is expected to
732 handle this situation. Used by the interpreter.
734 Usually errNoValue is passed as nStringNoValueError.
736 Otherwise, depending on the string conversion configuration different
737 approaches are taken:
740 For ScCalcConfig::StringConversion::ILLEGAL
741 The error value passed in nStringNoValueError is assigned to rError
745 For ScCalcConfig::StringConversion::ZERO
746 A zero value is returned and no error assigned.
749 For ScCalcConfig::StringConversion::LOCALE
751 If the string is empty or consists only of spaces, if "treat empty
752 string as zero" is set 0.0 is returned, else nStringNoValueError
753 assigned to rError (and 0.0 returned).
755 Else a non-empty string is passed to the number formatter's scanner to
756 be parsed locale dependent. If that does not detect a numeric value
757 nStringNoValueError is assigned to rError (and 0.0 returned).
759 If no number formatter was passed, the conversion falls back to
763 For ScCalcConfig::StringConversion::UNAMBIGUOUS
765 If the string is empty or consists only of spaces, if "treat empty
766 string as zero" is set 0.0 is returned, else nStringNoValueError
767 assigned to rError (and 0.0 returned).
769 If the string is not empty the following conversion rules are applied:
771 Converted are only integer numbers including exponent, and ISO 8601 dates
772 and times in their extended formats with separators. Anything else,
773 especially fractional numeric values with decimal separators or dates other
774 than ISO 8601 would be locale dependent and is a no-no. Leading and
775 trailing blanks are ignored.
777 The following ISO 8601 formats are converted:
782 CCYY-MM-DDThh:mm:ss,s
783 CCYY-MM-DDThh:mm:ss.s
789 The century CC may not be omitted and the two-digit year setting is not
790 taken into account. Instead of the T date and time separator exactly one
793 If a date is given, it must be a valid Gregorian calendar date. In this
794 case the optional time must be in the range 00:00 to 23:59:59.99999...
795 If only time is given, it may have any value for hours, taking elapsed time
796 into account; minutes and seconds are limited to the value 59 as well.
798 If the string can not be converted to a numeric value, the error value
799 passed in nStringNoValueError is assigned to rError.
803 The string to be converted.
806 The calculation configuration.
809 Contains the error on return, if any. If an error was set before
810 and the conversion did not result in an error, still 0.0 is
813 @param nStringNoValueError
814 The error value to be assigned to rError if string could not be
818 The number formatter to use in case of
819 ScCalcConfig::StringConversion::LOCALE. Can but should not be
820 nullptr in which case conversion falls back to
821 ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is
822 detected the null date is assumed to be the standard 1899-12-30
823 instead of the configured null date.
826 Can be assigned a format type in case a date or time or date+time
827 string was converted, e.g. css::util::NumberFormat::DATE or
828 css::util::NumberFormat::TIME or a combination thereof.
831 static double ConvertStringToValue( const OUString
& rStr
, const ScCalcConfig
& rConfig
,
832 sal_uInt16
& rError
, sal_uInt16 nStringNoValueError
,
833 SvNumberFormatter
* pFormatter
, short & rCurFmtType
);
838 // maybe move to dbdata.hxx (?):
855 SC_DOES_NOT_BEGIN_WITH
,
868 SUBTOTAL_FUNC_NONE
= 0,
869 SUBTOTAL_FUNC_AVE
= 1,
870 SUBTOTAL_FUNC_CNT
= 2,
871 SUBTOTAL_FUNC_CNT2
= 3,
872 SUBTOTAL_FUNC_MAX
= 4,
873 SUBTOTAL_FUNC_MIN
= 5,
874 SUBTOTAL_FUNC_PROD
= 6,
875 SUBTOTAL_FUNC_STD
= 7,
876 SUBTOTAL_FUNC_STDP
= 8,
877 SUBTOTAL_FUNC_SUM
= 9,
878 SUBTOTAL_FUNC_VAR
= 10,
879 SUBTOTAL_FUNC_VARP
= 11,
880 SUBTOTAL_FUNC_SELECTION_COUNT
= 12
885 AGGREGATE_FUNC_MEDIAN
= 12,
886 AGGREGATE_FUNC_MODSNGL
= 13,
887 AGGREGATE_FUNC_LARGE
= 14,
888 AGGREGATE_FUNC_SMALL
= 15,
889 AGGREGATE_FUNC_PERCINC
= 16,
890 AGGREGATE_FUNC_QRTINC
= 17,
891 AGGREGATE_FUNC_PERCEXC
= 18,
892 AGGREGATE_FUNC_QRTEXC
= 19
897 struct ScConsolidateParam
899 SCCOL nCol
; // cursor position /
900 SCROW nRow
; // or start of destination area respectively
902 ScSubTotalFunc eFunction
;
903 sal_uInt16 nDataAreaCount
; // number of data areas
904 ScArea
** ppDataAreas
; // array of pointers into data areas
907 bool bReferenceData
; // reference source data
909 ScConsolidateParam();
910 ScConsolidateParam( const ScConsolidateParam
& r
);
911 ~ScConsolidateParam();
913 ScConsolidateParam
& operator= ( const ScConsolidateParam
& r
);
914 bool operator== ( const ScConsolidateParam
& r
) const;
915 void Clear (); // = ClearDataAreas()+Members
916 void ClearDataAreas ();
917 void SetAreas ( ScArea
* const* ppAreas
, sal_uInt16 nCount
);
922 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */