Bump version to 4.3-4
[LibreOffice.git] / sc / inc / global.hxx
blob0614bce65c654bd1ed7a9f03c33afec0b43705e9
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 <boost/static_assert.hpp>
32 #include <boost/unordered_map.hpp>
33 #include <vector>
35 class ImageList;
36 class Bitmap;
37 class SfxItemSet;
38 class Color;
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"
52 #define STRING_SCSTREAM "StarCalcDocument"
54 #define STRING_STANDARD "Standard"
56 // characters
58 // '\r' does not work on a Mac...
59 #define CHAR_CR char(13)
61 const sal_Unicode CHAR_NBSP = 0x00A0;
62 const sal_Unicode CHAR_SHY = 0x00AD;
63 const sal_Unicode CHAR_ZWSP = 0x200B;
64 const sal_Unicode CHAR_LRM = 0x200E;
65 const sal_Unicode CHAR_RLM = 0x200F;
66 const sal_Unicode CHAR_NBHY = 0x2011;
67 const sal_Unicode CHAR_ZWNBSP = 0x2060;
69 #define MINDOUBLE 1.7e-307
70 #define MAXDOUBLE 1.7e307
72 #define MINZOOM 20
73 #define MAXZOOM 400
75 const SCSIZE MAXSUBTOTAL = 3;
77 #define SC_START_INDEX_DB_COLL 50000
78 // Above this threshold are indices
79 // for data base areas
81 #define SC_USE_PS_POINTS 1 /**< use PostScript points (72ppi) instead of old TeX points (72.27ppi) */
83 #define PIXEL_PER_INCH 96.0
85 #define CM_PER_INCH 2.54
86 #define PS_POINTS_PER_INCH 72.0 /**< PostScript points per inch */
87 #define TEX_POINTS_PER_INCH 72.27 /**< old printer points, or TeX points per inch */
88 #if SC_USE_PS_POINTS
89 #define POINTS_PER_INCH PS_POINTS_PER_INCH /**< the actual definition of points used */
90 #else
91 #define POINTS_PER_INCH TEX_POINTS_PER_INCH
92 #endif
93 #define PIXEL_PER_POINT (PIXEL_PER_INCH / POINTS_PER_INCH)
94 #define TWIPS_PER_POINT 20.0
95 #define TWIPS_PER_INCH (TWIPS_PER_POINT * POINTS_PER_INCH)
96 #define TWIPS_PER_CM (TWIPS_PER_INCH / CM_PER_INCH)
97 #define CM_PER_TWIPS (CM_PER_INCH / TWIPS_PER_INCH)
98 #define TWIPS_PER_PIXEL (TWIPS_PER_INCH / PIXEL_PER_INCH)
99 #define TWIPS_PER_CHAR (TWIPS_PER_INCH / 13.6)
100 #define PIXEL_PER_TWIPS (PIXEL_PER_INCH / TWIPS_PER_INCH)
101 #define HMM_PER_TWIPS (CM_PER_TWIPS * 1000.0)
103 #if SC_USE_PS_POINTS
104 #define STD_COL_WIDTH 1280 /* 2.2577cm, 64.00pt PS */
105 #else
106 #define STD_COL_WIDTH 1285 /* 2.2581cm, 64.25pt TeX */
107 #endif
108 #define STD_EXTRA_WIDTH 113 /* 2mm extra for optimal width,
109 * 0.1986cm with TeX points,
110 * 0.1993cm with PS points. */
112 #define MAX_EXTRA_WIDTH 23811 /* 42cm in TWIPS, 41.8430cm TeX, 41.9999cm PS */
113 #define MAX_EXTRA_HEIGHT 23811
114 #define MAX_COL_WIDTH 56693 /* 1m in TWIPS, 99.6266cm TeX, 100.0001cm PS */
115 #define MAX_ROW_HEIGHT 56693
117 /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
118 #define STD_ROWHEIGHT_DIFF 23
120 namespace sc
122 inline long TwipsToHMM( long nTwips ) { return (nTwips * 127 + 36) / 72; }
123 inline long HMMToTwips( long nHMM ) { return (nHMM * 72 + 63) / 127; }
124 inline long TwipsToEvenHMM( long nTwips ) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
127 // standard size as OLE server (cells)
128 #define OLE_STD_CELLS_X 4
129 #define OLE_STD_CELLS_Y 5
131 #define SC_SIZE_OPTIMUM 0xFFFF
133 // repaint flags (for messages)
134 #define PAINT_GRID 1
135 #define PAINT_TOP 2
136 #define PAINT_LEFT 4
137 #define PAINT_EXTRAS 8
138 #define PAINT_MARKS 16
139 #define PAINT_OBJECTS 32
140 #define PAINT_SIZE 64
141 #define PAINT_ALL ( PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS | PAINT_OBJECTS | PAINT_SIZE )
143 // flags for columns / rows
144 // FILTERED always together with HIDDEN
145 // FILTERED and MANUALSIZE only valid for rows
146 const sal_uInt8 CR_HIDDEN = 1;
147 const sal_uInt8 CR_MANUALBREAK = 8;
148 const sal_uInt8 CR_FILTERED = 16;
149 const sal_uInt8 CR_MANUALSIZE = 32;
150 const sal_uInt8 CR_ALL = (CR_HIDDEN | CR_MANUALBREAK | CR_FILTERED | CR_MANUALSIZE);
152 typedef sal_uInt8 ScBreakType;
153 const ScBreakType BREAK_NONE = 0;
154 const ScBreakType BREAK_PAGE = 1;
155 const ScBreakType BREAK_MANUAL = 2;
157 // insert/delete flags
158 const sal_uInt16 IDF_NONE = 0x0000;
159 const sal_uInt16 IDF_VALUE = 0x0001; /// Numeric values (and numeric results if IDF_FORMULA is not set).
160 const sal_uInt16 IDF_DATETIME = 0x0002; /// Dates, times, datetime values.
161 const sal_uInt16 IDF_STRING = 0x0004; /// Strings (and string results if IDF_FORMULA is not set).
162 const sal_uInt16 IDF_NOTE = 0x0008; /// Cell notes.
163 const sal_uInt16 IDF_FORMULA = 0x0010; /// Formula cells.
164 const sal_uInt16 IDF_HARDATTR = 0x0020; /// Hard cell attributes.
165 const sal_uInt16 IDF_STYLES = 0x0040; /// Cell styles.
166 const sal_uInt16 IDF_OBJECTS = 0x0080; /// Drawing objects.
167 const sal_uInt16 IDF_EDITATTR = 0x0100; /// Rich-text attributes.
168 const sal_uInt16 IDF_OUTLINE = 0x0800; /// Sheet / outlining (grouping) information
169 const sal_uInt16 IDF_NOCAPTIONS = 0x0200; /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
170 const sal_uInt16 IDF_ADDNOTES = 0x0400; /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
171 const sal_uInt16 IDF_SPECIAL_BOOLEAN = 0x1000;
172 const sal_uInt16 IDF_ATTRIB = IDF_HARDATTR | IDF_STYLES;
173 const sal_uInt16 IDF_CONTENTS = IDF_VALUE | IDF_DATETIME | IDF_STRING | IDF_NOTE | IDF_FORMULA | IDF_OUTLINE;
174 const sal_uInt16 IDF_ALL = IDF_CONTENTS | IDF_ATTRIB | IDF_OBJECTS;
176 BOOST_STATIC_ASSERT((IDF_ATTRIB & IDF_CONTENTS) == 0);
178 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
179 const sal_uInt16 IDF_AUTOFILL = IDF_ALL & ~(IDF_NOTE | IDF_OBJECTS);
181 #define PASTE_NOFUNC 0
182 #define PASTE_ADD 1
183 #define PASTE_SUB 2
184 #define PASTE_MUL 3
185 #define PASTE_DIV 4
187 // bits for HasAttr
188 #define HASATTR_LINES 1
189 #define HASATTR_MERGED 2
190 #define HASATTR_OVERLAPPED 4
191 #define HASATTR_PROTECTED 8
192 #define HASATTR_SHADOW 16
193 #define HASATTR_NEEDHEIGHT 32
194 #define HASATTR_SHADOW_RIGHT 64
195 #define HASATTR_SHADOW_DOWN 128
196 #define HASATTR_AUTOFILTER 256
197 #define HASATTR_CONDITIONAL 512
198 #define HASATTR_ROTATE 1024
199 #define HASATTR_NOTOVERLAPPED 2048
200 #define HASATTR_RTL 4096
201 #define HASATTR_RIGHTORCENTER 8192 // right or centered logical alignment
203 #define HASATTR_PAINTEXT ( HASATTR_LINES | HASATTR_SHADOW | HASATTR_CONDITIONAL )
205 #define EMPTY_OUSTRING ScGlobal::GetEmptyOUString()
207 // layer id's for drawing
208 #define SC_LAYER_FRONT 0
209 #define SC_LAYER_BACK 1
210 #define SC_LAYER_INTERN 2
211 #define SC_LAYER_CONTROLS 3
212 #define SC_LAYER_HIDDEN 4
214 // link tables
215 #define SC_LINK_NONE 0
216 #define SC_LINK_NORMAL 1
217 #define SC_LINK_VALUE 2
219 // input
220 #define SC_ENTER_NORMAL 0
221 #define SC_ENTER_BLOCK 1
222 #define SC_ENTER_MATRIX 2
224 // step = 10pt, max. indention = 100 steps
225 #define SC_INDENT_STEP 200
226 #define SC_MAX_INDENT 20000
228 // scenario flags
229 #define SC_SCENARIO_COPYALL 1
230 #define SC_SCENARIO_SHOWFRAME 2
231 #define SC_SCENARIO_PRINTFRAME 4
232 #define SC_SCENARIO_TWOWAY 8
233 #define SC_SCENARIO_ATTRIB 16
234 #define SC_SCENARIO_VALUE 32
235 #define SC_SCENARIO_PROTECT 64
237 #define AGGR_IGN_NESTED_ST_AG 0x04
238 #define AGGR_IGN_ERR_VAL 0x02
239 #define AGGR_IGN_HID_ROW 0x01
241 /** Default cell clone flags: do not start listening, do not adjust 3D refs to
242 old position, clone note captions of cell notes. */
243 const int SC_CLONECELL_DEFAULT = 0x0000;
245 /** If set, cloned formula cells will start to listen to the document. */
246 const int SC_CLONECELL_STARTLISTENING = 0x0001;
248 /** If set, relative 3D references of cloned formula cells will be adjusted to
249 old position (used while swapping cells for sorting a cell range). */
250 const int SC_CLONECELL_ADJUST3DREL = 0x0002;
252 /** If set, the caption object of a cell note will not be cloned (used while
253 copying cells to undo document, where captions are handled in drawing undo). */
254 const int SC_CLONECELL_NOCAPTION = 0x0004;
256 /** If set, absolute refs will not transformed to external references */
257 const int SC_CLONECELL_NOMAKEABS_EXTERNAL = 0x0008;
259 #ifndef DELETEZ
260 #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
261 #endif
263 // is bit set in set?
264 #define IS_SET(bit,set)(((set)&(bit))==(bit))
266 enum CellType
268 CELLTYPE_NONE,
269 CELLTYPE_VALUE,
270 CELLTYPE_STRING,
271 CELLTYPE_FORMULA,
272 CELLTYPE_EDIT,
275 enum DelCellCmd
277 DEL_CELLSUP,
278 DEL_CELLSLEFT,
279 DEL_DELROWS,
280 DEL_DELCOLS,
281 DEL_NONE
284 enum InsCellCmd
286 INS_CELLSDOWN,
287 INS_CELLSRIGHT,
288 INS_INSROWS,
289 INS_INSCOLS,
290 INS_NONE
293 enum UpdateRefMode
295 URM_INSDEL,
296 URM_COPY,
297 URM_MOVE,
298 URM_REORDER
301 enum FillDir
303 FILL_TO_BOTTOM,
304 FILL_TO_RIGHT,
305 FILL_TO_TOP,
306 FILL_TO_LEFT
309 enum FillCmd
311 FILL_SIMPLE,
312 FILL_LINEAR,
313 FILL_GROWTH,
314 FILL_DATE,
315 FILL_AUTO
318 enum ScMoveDirection
320 SC_MOVE_RIGHT,
321 SC_MOVE_LEFT,
322 SC_MOVE_UP,
323 SC_MOVE_DOWN
326 enum FillDateCmd
328 FILL_DAY,
329 FILL_WEEKDAY,
330 FILL_MONTH,
331 FILL_YEAR
334 enum ScDirection
336 DIR_BOTTOM,
337 DIR_RIGHT,
338 DIR_TOP,
339 DIR_LEFT
342 enum ScSizeMode
344 SC_SIZE_DIRECT, // set size or hide if value is 0
345 SC_SIZE_OPTIMAL, // set optimal size for everything
346 SC_SIZE_SHOW, // show with original size
347 SC_SIZE_VISOPT, // set optimal size only if visible
348 SC_SIZE_ORIGINAL // only set size, don't change visible flag
351 enum ScInputMode
353 SC_INPUT_NONE,
354 SC_INPUT_TYPE, // input, while not in inplace mode
355 SC_INPUT_TABLE, // text cursor in the table
356 SC_INPUT_TOP // text cursor in the input line
359 enum ScVObjMode // output modes of objects on a page
361 VOBJ_MODE_SHOW,
362 VOBJ_MODE_HIDE
365 enum ScAnchorType // anchor of a character object
367 SCA_CELL,
368 SCA_PAGE,
369 SCA_DONTKNOW // for multi selection
372 enum ScGetDBMode
374 SC_DB_MAKE, // create "untitled" (if necessary)
375 SC_DB_IMPORT, // create "Importx" (if necessary)
376 SC_DB_OLD // don't create
379 /// For ScDBFunc::GetDBData()
380 enum ScGetDBSelection
382 /** Keep selection as is, expand to used data area if no selection. */
383 SC_DBSEL_KEEP,
385 /** Shrink selection to sheet's data area. */
386 SC_DBSEL_SHRINK_TO_SHEET_DATA,
388 /** Shrink selection to actually used data area within the selection. */
389 SC_DBSEL_SHRINK_TO_USED_DATA,
391 /** If only one row or portion thereof is selected, shrink row to used data
392 columns and select further rows down until end of data. If an area is
393 selected, shrink rows to actually used columns. Else, no selection,
394 expand to used data area. */
395 SC_DBSEL_ROW_DOWN,
397 /** Behave as if the range corresponding to a ScDBData area was selected,
398 for API use. */
399 SC_DBSEL_FORCE_MARK
402 enum ScLkUpdMode // modes for updating links
404 LM_ALWAYS,
405 LM_NEVER,
406 LM_ON_DEMAND,
407 LM_UNKNOWN
410 // enum with values equal to old DBObject enum from sdb
411 enum ScDBObject
413 ScDbTable,
414 ScDbQuery
417 struct ScImportParam
419 SCCOL nCol1;
420 SCROW nRow1;
421 SCCOL nCol2;
422 SCROW nRow2;
423 bool bImport;
424 OUString aDBName; // alias of data base
425 OUString aStatement;
426 bool bNative;
427 bool bSql; // statement or name?
428 sal_uInt8 nType; // enum DBObject
430 ScImportParam();
431 ScImportParam( const ScImportParam& r );
432 ~ScImportParam();
434 ScImportParam& operator= ( const ScImportParam& r );
435 bool operator== ( const ScImportParam& r ) const;
438 class ScDocument;
439 class ScDocShell;
440 class SvxSearchItem;
441 class ScAutoFormat;
442 class FuncCollection;
443 class ScUnoAddInCollection;
444 class ScUserList;
445 class SvxBrushItem;
446 class ScFunctionList;
447 class ScFunctionMgr;
448 class SfxItemPool;
449 class SdrModel;
450 class EditTextObject;
451 class SfxObjectShell;
452 class SvNumberFormatter;
453 class ScUnitConverter;
454 class CharClass;
455 class LocaleDataWrapper;
456 class SvtSysLocale;
457 class CalendarWrapper;
458 class CollatorWrapper;
459 class IntlWrapper;
460 class OutputDevice;
461 class ScFieldEditEngine;
463 namespace com { namespace sun { namespace star {
464 namespace lang {
465 struct Locale;
467 namespace i18n {
468 class XOrdinalSuffix;
471 namespace utl {
472 class TransliterationWrapper;
475 #ifndef _SCALC_EXE
476 class ScGlobal
478 static SvxSearchItem* pSearchItem;
479 static ScAutoFormat* pAutoFormat;
480 static FuncCollection* pFuncCollection;
481 static ScUnoAddInCollection* pAddInCollection;
482 static ScUserList* pUserList;
483 static OUString** ppRscString;
484 static OUString* pStrScDoc;
485 static OUString* pEmptyOUString;
486 static OUString* pStrClipDocName;
487 static SvxBrushItem* pEmptyBrushItem;
488 static SvxBrushItem* pButtonBrushItem;
489 static SvxBrushItem* pEmbeddedBrushItem;
490 static SvxBrushItem* pProtectedBrushItem;
492 static ImageList* pOutlineBitmaps;
494 static ScFunctionList* pStarCalcFunctionList;
495 static ScFunctionMgr* pStarCalcFunctionMgr;
497 static ScUnitConverter* pUnitConverter;
499 static SvNumberFormatter* pEnglishFormatter; // for UNO / XML export
501 static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XOrdinalSuffix> xOrdinalSuffix;
502 static CalendarWrapper* pCalendar;
503 static CollatorWrapper* pCaseCollator;
504 static CollatorWrapper* pCollator;
505 static ::utl::TransliterationWrapper* pTransliteration;
506 static ::utl::TransliterationWrapper* pCaseTransliteration;
507 static IntlWrapper* pScIntlWrapper;
508 static ::com::sun::star::lang::Locale* pLocale;
510 static ScFieldEditEngine* pFieldEditEngine;
512 public:
513 static SvtSysLocale* pSysLocale;
514 // for faster access a pointer to the single instance provided by SvtSysLocale
515 SC_DLLPUBLIC static const CharClass* pCharClass;
516 // for faster access a pointer to the single instance provided by SvtSysLocale
517 SC_DLLPUBLIC static const LocaleDataWrapper* pLocaleData;
518 SC_DLLPUBLIC static const LocaleDataWrapper* GetpLocaleData();
520 static CalendarWrapper* GetCalendar();
521 SC_DLLPUBLIC static CollatorWrapper* GetCollator();
522 static CollatorWrapper* GetCaseCollator();
523 static IntlWrapper* GetScIntlWrapper();
524 static ::com::sun::star::lang::Locale* GetLocale();
526 SC_DLLPUBLIC static ::utl::TransliterationWrapper* GetpTransliteration();
527 static ::utl::TransliterationWrapper* GetCaseTransliteration();
529 SC_DLLPUBLIC static LanguageType eLnge;
530 static sal_Unicode cListDelimiter;
532 static const OUString& GetClipDocName();
533 static void SetClipDocName( const OUString& rNew );
534 SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem();
535 SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew );
536 SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat();
537 SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat();
538 static void ClearAutoFormat(); //BugId 54209
539 static FuncCollection* GetFuncCollection();
540 SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
541 SC_DLLPUBLIC static ScUserList* GetUserList();
542 static void SetUserList( const ScUserList* pNewList );
543 SC_DLLPUBLIC static const OUString& GetRscString( sal_uInt16 nIndex );
544 static void OpenURL( const OUString& rURL, const OUString& rTarget );
545 SC_DLLPUBLIC static OUString GetAbsDocName( const OUString& rFileName,
546 SfxObjectShell* pShell );
547 SC_DLLPUBLIC static OUString GetDocTabName( const OUString& rFileName,
548 const OUString& rTabName );
549 SC_DLLPUBLIC static sal_uLong GetStandardFormat( SvNumberFormatter&,
550 sal_uLong nFormat, short nType );
552 SC_DLLPUBLIC static sal_uInt16 GetStandardRowHeight();
553 SC_DLLPUBLIC static double nScreenPPTX;
554 SC_DLLPUBLIC static double nScreenPPTY;
556 static tools::SvRef<ScDocShell>* pDrawClipDocShellRef;
558 static sal_uInt16 nDefFontHeight;
559 SC_DLLPUBLIC static sal_uInt16 nStdRowHeight;
561 SC_DLLPUBLIC static long nLastRowHeightExtra;
562 static long nLastColWidthExtra;
564 static void Init(); // during start up
565 static void InitAddIns();
566 static void Clear(); // at the end of the program
568 static void UpdatePPT(OutputDevice* pDev);
570 static void InitTextHeight(SfxItemPool* pPool);
571 static SvxBrushItem* GetEmptyBrushItem() { return pEmptyBrushItem; }
572 static SvxBrushItem* GetButtonBrushItem();
573 static SvxBrushItem* GetEmbeddedBrushItem() { return pEmbeddedBrushItem; }
574 static SvxBrushItem* GetProtectedBrushItem() { return pProtectedBrushItem; }
575 SC_DLLPUBLIC static const OUString& GetEmptyOUString();
576 static const OUString& GetScDocString();
578 /** Returns the specified image list with outline symbols. */
579 static ImageList* GetOutlineSymbols();
581 static bool HasStarCalcFunctionList();
582 static ScFunctionList* GetStarCalcFunctionList();
583 static ScFunctionMgr* GetStarCalcFunctionMgr();
584 static void ResetFunctionList();
586 static OUString GetErrorString(sal_uInt16 nErrNumber);
587 static OUString GetLongErrorString(sal_uInt16 nErrNumber);
588 static bool EETextObjEqual( const EditTextObject* pObj1,
589 const EditTextObject* pObj2 );
590 static bool CheckWidthInvalidate( bool& bNumFormatChanged,
591 const SfxItemSet& rNewAttrs,
592 const SfxItemSet& rOldAttrs );
593 static bool HasAttrChanged( const SfxItemSet& rNewAttrs,
594 const SfxItemSet& rOldAttrs,
595 const sal_uInt16 nWhich );
597 static ScUnitConverter* GetUnitConverter();
599 /// strchr() functionality on unicode, as long as we need it for ScToken etc.
600 static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
602 static inline sal_Unicode ToUpperAlpha( sal_Unicode c )
603 { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
605 /** Adds the string rToken to rTokenList, using a list separator character.
606 @param rTokenList The string list where the token will be appended to.
607 @param rToken The token string to append to the token list.
608 @param cSep The character to separate the tokens.
609 @param nSepCount Specifies how often cSep is inserted between two tokens.
610 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
611 SC_DLLPUBLIC static OUString addToken(
612 const OUString& rTokenList, const OUString& rToken,
613 sal_Unicode cSep, sal_Int32 nSepCount = 1,
614 bool bForceSep = false );
616 /** Returns true, if the first and last character of the string is cQuote. */
617 SC_DLLPUBLIC static bool IsQuoted( const OUString& rString, sal_Unicode cQuote = '\'' );
619 /** Inserts the character cQuote at beginning and end of rString.
620 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
621 escaped by doubling them.
623 SC_DLLPUBLIC static void AddQuotes( OUString& rString, sal_Unicode cQuote = '\'', bool bEscapeEmbedded = true );
625 /** Erases the character cQuote from rString, if it exists at beginning AND end.
626 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
627 are unescaped by replacing them with a
628 single instance.
630 SC_DLLPUBLIC static void EraseQuotes( OUString& rString, sal_Unicode cQuote = '\'', bool bUnescapeEmbedded = true );
632 /** Finds an unquoted instance of cChar in rString, starting at
633 offset nStart. Unquoted instances may occur when concatenating two
634 quoted strings with a separator, for example, 's1':'s2'. Embedded
635 quotes have to be escaped by being doubled. Caller must ensure that
636 nStart points into an unquoted range or the opening quote. Specialty:
637 if cChar==cQuote the first cQuote character from nStart on is found.
638 @returns offset if found, else -1
640 SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar);
642 /** Finds an unquoted instance of cChar in null-terminated pString. Same
643 semantics as FindUnquoted( const String&, ...)
644 @returns: pointer to cChar if found, else NULL
646 SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar, sal_Unicode cQuote = '\'' );
648 static rtl_TextEncoding GetCharsetValue( const OUString& rCharSet );
649 static OUString GetCharsetString( rtl_TextEncoding eVal );
651 /// a "ReadOnly" formatter for UNO/XML export
652 static SvNumberFormatter* GetEnglishFormatter();
654 static bool IsSystemRTL(); // depending on system language
655 static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
656 SC_DLLPUBLIC static sal_uInt8 GetDefaultScriptType(); // for all WEAK characters
657 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
658 If more than one SCRIPTTYPE_... values are or'ed together, prefers
659 first COMPLEX, then ASIAN */
660 SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( sal_uInt8 nScriptType, sal_uInt16 nWhich );
662 /** Adds a language item to the item set, if the number format item contains
663 a language that differs from its parent's language. */
664 SC_DLLPUBLIC static void AddLanguage( SfxItemSet& rSet, SvNumberFormatter& rFormatter );
666 /** Obtain the ordinal suffix for a number according to the system locale */
667 static OUString GetOrdinalSuffix( sal_Int32 nNumber);
669 /** A static instance of ScFieldEditEngine not capable of resolving
670 document specific fields, to be used only by ScEditUtil::GetString(). */
671 static ScFieldEditEngine& GetStaticFieldEditEngine();
673 /** Replaces the first occurrence of rPlaceholder in rString with
674 rReplacement, or if rPlaceholder is not found appends one space if
675 rString does not end in a space and appends rReplacement.
677 Meant to be used with resource strings ala "Column %1" where a
678 translation may have omitted the %1 placeholder and a simple
679 replacement would end up with nothing replaced so no column indicator
680 in the result string.
682 SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString,
683 const OUString& rPlaceholder,
684 const OUString& rReplacement );
686 #endif
688 // maybe move to dbdata.hxx (?):
690 enum ScQueryOp
692 SC_EQUAL,
693 SC_LESS,
694 SC_GREATER,
695 SC_LESS_EQUAL,
696 SC_GREATER_EQUAL,
697 SC_NOT_EQUAL,
698 SC_TOPVAL,
699 SC_BOTVAL,
700 SC_TOPPERC,
701 SC_BOTPERC,
702 SC_CONTAINS,
703 SC_DOES_NOT_CONTAIN,
704 SC_BEGINS_WITH,
705 SC_DOES_NOT_BEGIN_WITH,
706 SC_ENDS_WITH,
707 SC_DOES_NOT_END_WITH
710 enum ScQueryConnect
712 SC_AND,
713 SC_OR
716 enum ScSubTotalFunc
718 SUBTOTAL_FUNC_NONE = 0,
719 SUBTOTAL_FUNC_AVE = 1,
720 SUBTOTAL_FUNC_CNT = 2,
721 SUBTOTAL_FUNC_CNT2 = 3,
722 SUBTOTAL_FUNC_MAX = 4,
723 SUBTOTAL_FUNC_MIN = 5,
724 SUBTOTAL_FUNC_PROD = 6,
725 SUBTOTAL_FUNC_STD = 7,
726 SUBTOTAL_FUNC_STDP = 8,
727 SUBTOTAL_FUNC_SUM = 9,
728 SUBTOTAL_FUNC_VAR = 10,
729 SUBTOTAL_FUNC_VARP = 11,
730 SUBTOTAL_FUNC_SELECTION_COUNT = 12
733 enum ScAggregateFunc
735 AGGREGATE_FUNC_MEDIAN = 12,
736 AGGREGATE_FUNC_MODSNGL = 13,
737 AGGREGATE_FUNC_LARGE = 14,
738 AGGREGATE_FUNC_SMALL = 15,
739 AGGREGATE_FUNC_PERCINC = 16,
740 AGGREGATE_FUNC_QRTINC = 17,
741 AGGREGATE_FUNC_PERCEXC = 18,
742 AGGREGATE_FUNC_QRTEXC = 19
745 class ScArea;
747 struct ScConsolidateParam
749 SCCOL nCol; // cursor position /
750 SCROW nRow; // or start of destination area respectively
751 SCTAB nTab;
752 ScSubTotalFunc eFunction;
753 sal_uInt16 nDataAreaCount; // number of data areas
754 ScArea** ppDataAreas; // array of pointers into data areas
755 bool bByCol;
756 bool bByRow;
757 bool bReferenceData; // reference source data
759 ScConsolidateParam();
760 ScConsolidateParam( const ScConsolidateParam& r );
761 ~ScConsolidateParam();
763 ScConsolidateParam& operator= ( const ScConsolidateParam& r );
764 bool operator== ( const ScConsolidateParam& r ) const;
765 void Clear (); // = ClearDataAreas()+Members
766 void ClearDataAreas ();
767 void SetAreas ( ScArea* const* ppAreas, sal_uInt16 nCount );
770 #endif
772 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */