update dev300-m57
[ooovba.git] / sc / inc / global.hxx
blob6bced1f4b1ed050e426822324e20748d940be60e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: global.hxx,v $
10 * $Revision: 1.53.128.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_SCGLOB_HXX
32 #define SC_SCGLOB_HXX
34 #include "address.hxx"
35 #include <i18npool/lang.h>
36 #include <tools/stream.hxx>
37 #include <osl/endian.h>
38 #include <com/sun/star/uno/Reference.hxx>
39 #include "scdllapi.h"
41 #include <hash_map>
43 class ImageList;
44 class Bitmap;
45 class SfxItemSet;
46 class Color;
48 // Macro fuer den Call-Profiler unter WinNT
49 // mit S_CAP kann eine Messung gestarted, mit E_CAP wieder gestoppt werden
50 #if defined( WNT ) && defined( PROFILE )
52 extern "C" {
53 void StartCAP();
54 void StopCAP();
55 void DumpCAP();
58 #define S_CAP StartCAP();
59 #define E_CAP StopCAP(); DumpCAP();
61 #endif
63 #if 0
64 // I18N doesn't get this right, can't specify more than one to ignore
65 #define SC_COLLATOR_IGNORES ( \
66 ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE | \
67 ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_KANA | \
68 ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_WIDTH )
69 #else
70 #define SC_COLLATOR_IGNORES ( \
71 ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE )
72 #endif
73 #if 0
74 // #107998# Don't ignore Width and Kana. The issue was mainly with AutoInput,
75 // but affects also comparison of names in general.
76 #define SC_TRANSLITERATION_IGNORECASE ( \
77 ::com::sun::star::i18n::TransliterationModules_IGNORE_CASE | \
78 ::com::sun::star::i18n::TransliterationModules_IGNORE_KANA | \
79 ::com::sun::star::i18n::TransliterationModules_IGNORE_WIDTH )
80 #define SC_TRANSLITERATION_CASESENSE ( \
81 ::com::sun::star::i18n::TransliterationModules_IGNORE_KANA | \
82 ::com::sun::star::i18n::TransliterationModules_IGNORE_WIDTH )
83 #else
84 #define SC_TRANSLITERATION_IGNORECASE ( \
85 ::com::sun::star::i18n::TransliterationModules_IGNORE_CASE )
86 #define SC_TRANSLITERATION_CASESENSE 0
87 #endif
89 //------------------------------------------------------------------------
91 // die 1000 Namen des Calc...
92 // Clipboard-Namen sind jetzt in so3/soapp.hxx
93 // STRING_SCAPP war "scalc3", "scalc4", jetzt nur noch "scalc"
95 #define STRING_SCAPP "scalc"
96 #define STRING_SCSTREAM "StarCalcDocument"
98 #define STRING_STANDARD "Standard"
100 // characters -----------------------------------------------------------------
102 // '\r' geht auf'm Mac nicht...
103 #define CHAR_CR char(13)
105 const sal_Unicode CHAR_NBSP = 0x00A0;
106 const sal_Unicode CHAR_SHY = 0x00AD;
107 const sal_Unicode CHAR_ZWSP = 0x200B;
108 const sal_Unicode CHAR_LRM = 0x200E;
109 const sal_Unicode CHAR_RLM = 0x200F;
110 const sal_Unicode CHAR_NBHY = 0x2011;
111 const sal_Unicode CHAR_ZWNBSP = 0x2060;
113 // ----------------------------------------------------------------------------
115 #define MINDOUBLE 1.7e-307
116 #define MAXDOUBLE 1.7e307
118 #define MINZOOM 20
119 #define MAXZOOM 400
121 #ifdef SC_ROWLIMIT_TYPECONVERSION_NOCONVPASS
122 const size_t MAXSUBTOTAL = 3;
123 const size_t MAXQUERY = 8;
124 const size_t PIVOT_MAXFIELD = 8;
125 const size_t PIVOT_MAXPAGEFIELD = 10;
126 #else
127 const SCSIZE MAXSUBTOTAL = 3;
128 const SCSIZE MAXQUERY = 8;
129 const SCSIZE PIVOT_MAXFIELD = 8;
130 const SCSIZE PIVOT_MAXPAGEFIELD = 10;
131 #endif
133 #define SC_START_INDEX_DB_COLL 50000
134 // Oberhalb dieser Grenze liegen
135 // die Indizes fuer DBBereiche
138 #ifdef OS2
139 #define PIXEL_PER_INCH 72.0
140 #else
141 #define PIXEL_PER_INCH 96.0
142 #endif
145 #define PIXEL_PER_INCH 96.0
147 #define CM_PER_INCH 2.54
148 #define POINTS_PER_INCH 72.27
149 #define PIXEL_PER_POINT (PIXEL_PER_INCH / POINTS_PER_INCH)
150 #define INCHT_PER_CM (1.0 / CM_PER_INCH)
151 #define POINTS_PER_CM (POINTS_PER_INCH / CM_PER_INCH)
152 #define TWIPS_PER_POINT 20.0
153 #define TWIPS_PER_INCH (TWIPS_PER_POINT * POINTS_PER_INCH)
154 #define TWIPS_PER_CM (TWIPS_PER_INCH / CM_PER_INCH)
155 #define CM_PER_TWIPS (CM_PER_INCH / TWIPS_PER_INCH)
156 #define TWIPS_PER_PIXEL (TWIPS_PER_INCH / PIXEL_PER_INCH)
157 #define TWIPS_PER_CHAR (TWIPS_PER_INCH / 13.6)
158 #define PIXEL_PER_TWIPS (PIXEL_PER_INCH / TWIPS_PER_INCH)
159 #define HMM_PER_TWIPS (CM_PER_TWIPS * 1000.0)
161 #define STD_COL_WIDTH 1285
162 #define STD_EXTRA_WIDTH 113 // 2mm Extra fuer optimale Breite
163 // Standard Zeilenhoehe: Text + Rand - STD_ROWHEIGHT_DIFF
166 #define MAX_EXTRA_WIDTH 23811 // 42cm in TWIPS
167 #define MAX_EXTRA_HEIGHT 23811
168 #define MAX_COL_WIDTH 56693 // 1m in TWIPS
169 #define MAX_COL_HEIGHT 56693
171 #define STD_ROWHEIGHT_DIFF 23
172 #define STD_FONT_HEIGHT 200 // entspricht 10 Punkt
174 //! statt STD_ROW_HEIGHT ScGlobal::nStdRowHeight benutzen !
176 #define STD_ROW_HEIGHT (12.8 * TWIPS_PER_POINT) // 256 Twips, 0.45 cm
178 // Standardgroesse als Ole-Server (Zellen)
179 #define OLE_STD_CELLS_X 4
180 #define OLE_STD_CELLS_Y 5
182 #define SC_SIZE_OPTIMUM 0xFFFF
184 // Update-Flags
185 #define UF_SCROLL_LEFT 1
186 #define UF_SCROLL_RIGHT 2
187 #define UF_SCROLL_UP 4
188 #define UF_SCROLL_DOWN 8
189 #define UF_ROW 16
190 #define UF_VIEW 32
192 // Repaint-Flags (fuer Messages)
193 #define PAINT_GRID 1
194 #define PAINT_TOP 2
195 #define PAINT_LEFT 4
196 #define PAINT_EXTRAS 8
197 #define PAINT_INVERT 16
198 #define PAINT_MARKS 32
199 #define PAINT_OBJECTS 64
200 #define PAINT_SIZE 128
201 #define PAINT_ALL ( PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS | PAINT_OBJECTS | PAINT_SIZE )
204 // Flags fuer Spalten / Zeilen
205 // FILTERED immer zusammen mit HIDDEN
206 // FILTERED und MANUALSIZE nur fuer Zeilen moeglich
207 const BYTE CR_HIDDEN = 1;
208 //const BYTE CR_MARKED = 2;
209 const BYTE CR_PAGEBREAK = 4;
210 const BYTE CR_MANUALBREAK = 8;
211 const BYTE CR_FILTERED = 16;
212 const BYTE CR_MANUALSIZE = 32;
214 // was davon kommt in die Datei:
215 #define CR_SAVEMASK ( ~CR_PAGEBREAK )
217 // Insert-/Delete-Flags
218 const USHORT IDF_NONE = 0x0000;
219 const USHORT IDF_VALUE = 0x0001; /// Numeric values (and numeric results if IDF_FORMULA is not set).
220 const USHORT IDF_DATETIME = 0x0002; /// Dates, times, datetime values.
221 const USHORT IDF_STRING = 0x0004; /// Strings (and string results if IDF_FORMULA is not set).
222 const USHORT IDF_NOTE = 0x0008; /// Cell notes.
223 const USHORT IDF_FORMULA = 0x0010; /// Formula cells.
224 const USHORT IDF_HARDATTR = 0x0020; /// Hard cell attributes.
225 const USHORT IDF_STYLES = 0x0040; /// Cell styles.
226 const USHORT IDF_OBJECTS = 0x0080; /// Drawing objects.
227 const USHORT IDF_EDITATTR = 0x0100; /// Rich-text attributes.
228 const USHORT IDF_SPECIAL_BOOLEAN = 0x1000;
229 const USHORT IDF_ATTRIB = IDF_HARDATTR | IDF_STYLES;
230 const USHORT IDF_CONTENTS = IDF_VALUE | IDF_DATETIME | IDF_STRING | IDF_NOTE | IDF_FORMULA;
231 const USHORT IDF_ALL = IDF_CONTENTS | IDF_ATTRIB | IDF_OBJECTS;
232 const USHORT IDF_NOCAPTIONS = 0x0200; /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
233 const USHORT IDF_ADDNOTES = 0x0400; /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
235 /// Copy flags for auto/series fill functions: do not touch notes and drawing objects.
236 const USHORT IDF_AUTOFILL = IDF_ALL & ~(IDF_NOTE | IDF_OBJECTS);
238 #define PASTE_NOFUNC 0
239 #define PASTE_ADD 1
240 #define PASTE_SUB 2
241 #define PASTE_MUL 3
242 #define PASTE_DIV 4
244 #define PASTE_NONEMPTY 5
246 // Bits fuer HasAttr
247 #define HASATTR_LINES 1
248 #define HASATTR_MERGED 2
249 #define HASATTR_OVERLAPPED 4
250 #define HASATTR_PROTECTED 8
251 #define HASATTR_SHADOW 16
252 #define HASATTR_NEEDHEIGHT 32
253 #define HASATTR_SHADOW_RIGHT 64
254 #define HASATTR_SHADOW_DOWN 128
255 #define HASATTR_AUTOFILTER 256
256 #define HASATTR_CONDITIONAL 512
257 #define HASATTR_ROTATE 1024
258 #define HASATTR_NOTOVERLAPPED 2048
259 #define HASATTR_RTL 4096
260 #define HASATTR_RIGHTORCENTER 8192 // right or centered logical alignment
262 #define HASATTR_PAINTEXT ( HASATTR_LINES | HASATTR_SHADOW | HASATTR_CONDITIONAL )
265 #define EMPTY_STRING ScGlobal::GetEmptyString()
267 // Layer-ID's fuer Drawing
268 #define SC_LAYER_FRONT 0
269 #define SC_LAYER_BACK 1
270 #define SC_LAYER_INTERN 2
271 #define SC_LAYER_CONTROLS 3
272 #define SC_LAYER_HIDDEN 4
274 // Tabellen linken
275 #define SC_LINK_NONE 0
276 #define SC_LINK_NORMAL 1
277 #define SC_LINK_VALUE 2
279 // Eingabe
280 #define SC_ENTER_NORMAL 0
281 #define SC_ENTER_BLOCK 1
282 #define SC_ENTER_MATRIX 2
284 // Step = 10pt, max. Einzug = 100 Schritte
285 #define SC_INDENT_STEP 200
286 #define SC_MAX_INDENT 20000
288 // Szenario-Flags
289 #define SC_SCENARIO_COPYALL 1
290 #define SC_SCENARIO_SHOWFRAME 2
291 #define SC_SCENARIO_PRINTFRAME 4
292 #define SC_SCENARIO_TWOWAY 8
293 #define SC_SCENARIO_ATTRIB 16
294 #define SC_SCENARIO_VALUE 32
295 #define SC_SCENARIO_PROTECT 64
298 #ifndef DELETEZ
299 #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
300 #endif
302 // Ist Bit in Set gesetzt?
303 #define IS_SET(bit,set)(((set)&(bit))==(bit))
305 #define SEL_ALL -1 // Eingabezeile: alles Selektieren
306 #define RES_CANCEL 0 // Resultate der Funk.AutoPilot-Seiten
307 #define RES_BACKWARD 1
308 #define RES_END 2
310 enum CellType
312 CELLTYPE_NONE,
313 CELLTYPE_VALUE,
314 CELLTYPE_STRING,
315 CELLTYPE_FORMULA,
316 CELLTYPE_NOTE,
317 CELLTYPE_EDIT,
318 CELLTYPE_SYMBOLS // fuer Laden/Speichern
319 #if DBG_UTIL
320 ,CELLTYPE_DESTROYED
321 #endif
324 enum DelCellCmd
326 DEL_CELLSUP,
327 DEL_CELLSLEFT,
328 DEL_DELROWS,
329 DEL_DELCOLS,
330 DEL_NONE
333 enum InsCellCmd
335 INS_CELLSDOWN,
336 INS_CELLSRIGHT,
337 INS_INSROWS,
338 INS_INSCOLS,
339 INS_NONE
342 enum UpdateRefMode
344 URM_INSDEL,
345 URM_COPY,
346 URM_MOVE,
347 URM_REORDER
350 enum FillDir
352 FILL_TO_BOTTOM,
353 FILL_TO_RIGHT,
354 FILL_TO_TOP,
355 FILL_TO_LEFT
358 enum FillCmd
360 FILL_SIMPLE,
361 FILL_LINEAR,
362 FILL_GROWTH,
363 FILL_DATE,
364 FILL_AUTO
367 enum FillDateCmd
369 FILL_DAY,
370 FILL_WEEKDAY,
371 FILL_MONTH,
372 FILL_YEAR
375 enum ScDirection
377 DIR_BOTTOM,
378 DIR_RIGHT,
379 DIR_TOP,
380 DIR_LEFT
383 enum ScSizeMode
385 SC_SIZE_DIRECT, // set size or hide if value is 0
386 SC_SIZE_OPTIMAL, // set optimal size for everything
387 SC_SIZE_SHOW, // show with original size
388 SC_SIZE_VISOPT, // set optimal size only if visible
389 SC_SIZE_ORIGINAL // only set size, don't change visible flag
392 enum ScInputMode
394 SC_INPUT_NONE,
395 SC_INPUT_TYPE, // Eingabe, ohne im Inplace-Modus zu sein
396 SC_INPUT_TABLE, // Textcursor in der Tabelle
397 SC_INPUT_TOP // Textcursor in der Eingabezeile
400 enum ScVObjMode // Ausgabemodi von Objekten auf einer Seite
402 VOBJ_MODE_SHOW,
403 VOBJ_MODE_HIDE
404 // #i80528# VOBJ_MODE_DUMMY removed, no longer supported
407 enum ScAnchorType // Verankerung eines Zeichenobjekts
409 SCA_CELL,
410 SCA_PAGE,
411 SCA_DONTKNOW // bei Mehrfachselektion
414 enum ScGetDBMode
416 SC_DB_MAKE, // wenn noetig, "unbenannt" anlegen
417 SC_DB_IMPORT, // wenn noetig, "Importx" anlegen
418 SC_DB_OLD // nicht neu anlegen
421 enum ScLkUpdMode
422 { //Verknuepfungen
423 LM_ALWAYS, //immer aktualisieren
424 LM_NEVER, //niemals
425 LM_ON_DEMAND, //auf nachfrage
426 LM_UNKNOWN //Shit happens
430 // -----------------------------------------------------------------------
432 //==================================================================
434 // -----------------------------------------------------------------------
436 // enum with values equal to old DBObject enum from sdb
437 enum ScDBObject
439 ScDbTable,
440 ScDbQuery
443 struct ScImportParam
445 SCCOL nCol1;
446 SCROW nRow1;
447 SCCOL nCol2;
448 SCROW nRow2;
449 BOOL bImport;
450 String aDBName; // Alias der Datenbank
451 String aStatement;
452 BOOL bNative;
453 BOOL bSql; // Statement oder Name?
454 BYTE nType; // enum DBObject
456 ScImportParam();
457 ScImportParam( const ScImportParam& r );
458 ~ScImportParam();
460 ScImportParam& operator= ( const ScImportParam& r );
461 BOOL operator== ( const ScImportParam& r ) const;
462 //UNUSED2009-05 void Clear ();
465 struct ScStringHashCode
467 size_t operator()( const String& rStr ) const
469 return rtl_ustr_hashCode_WithLength( rStr.GetBuffer(), rStr.Len() );
473 // -----------------------------------------------------------------------
475 class ScDocument;
476 class ScDocShell;
477 class ScDocShellRef;
478 class SvxSearchItem;
479 class ScAutoFormat;
480 class FuncCollection;
481 class ScUnoAddInCollection;
482 class ScUserList;
483 class SvxBrushItem;
484 class ScFunctionList;
485 class ScFunctionMgr;
486 class SfxItemPool;
487 class SdrModel;
488 class EditTextObject;
489 class SfxObjectShell;
490 class SvNumberFormatter;
491 class ScUnitConverter;
492 class CharClass;
493 class LocaleDataWrapper;
494 class SvtSysLocale;
495 class CalendarWrapper;
496 class CollatorWrapper;
497 class IntlWrapper;
498 class OutputDevice;
500 namespace com { namespace sun { namespace star {
501 namespace lang {
502 struct Locale;
504 namespace i18n {
505 class XOrdinalSuffix;
508 namespace utl {
509 class TransliterationWrapper;
512 #ifndef _SCALC_EXE
513 class ScGlobal
515 static SvxSearchItem* pSearchItem;
516 static ScAutoFormat* pAutoFormat;
517 static FuncCollection* pFuncCollection;
518 static ScUnoAddInCollection* pAddInCollection;
519 static ScUserList* pUserList;
520 static String** ppRscString;
521 static String* pStrScDoc;
522 static String* pEmptyString;
523 static String* pStrClipDocName;
524 static SvxBrushItem* pEmptyBrushItem;
525 static SvxBrushItem* pButtonBrushItem;
526 static SvxBrushItem* pEmbeddedBrushItem;
527 static SvxBrushItem* pProtectedBrushItem;
529 static ImageList* pOutlineBitmaps;
530 static ImageList* pOutlineBitmapsHC;
532 // static Bitmap* pAnchorBitmap;
533 // static Bitmap* pGrayAnchorBitmap;
535 static ScFunctionList* pStarCalcFunctionList;
536 static ScFunctionMgr* pStarCalcFunctionMgr;
538 static ScUnitConverter* pUnitConverter;
540 static SvNumberFormatter* pEnglishFormatter; // for UNO / XML export
542 static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XOrdinalSuffix> xOrdinalSuffix;
544 public:
545 static ::com::sun::star::lang::Locale* pLocale;
546 static SvtSysLocale* pSysLocale;
547 // for faster access a pointer to the single instance provided by SvtSysLocale
548 SC_DLLPUBLIC static const CharClass* pCharClass;
549 // for faster access a pointer to the single instance provided by SvtSysLocale
550 SC_DLLPUBLIC static const LocaleDataWrapper* pLocaleData;
551 SC_DLLPUBLIC static const LocaleDataWrapper* GetpLocaleData();
553 static CalendarWrapper* pCalendar;
554 SC_DLLPUBLIC static CollatorWrapper* pCollator;
555 static CollatorWrapper* pCaseCollator;
557 static ::utl::TransliterationWrapper* pTransliteration;
558 SC_DLLPUBLIC static ::utl::TransliterationWrapper* GetpTransliteration(); //CHINA001
560 static ::utl::TransliterationWrapper* pCaseTransliteration;
561 static IntlWrapper* pScIntlWrapper;
562 SC_DLLPUBLIC static LanguageType eLnge;
563 static sal_Unicode cListDelimiter;
565 static const String& GetClipDocName();
566 static void SetClipDocName( const String& rNew );
567 SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem();
568 SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew );
569 SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat();
570 static void ClearAutoFormat(); //BugId 54209
571 static FuncCollection* GetFuncCollection();
572 SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
573 SC_DLLPUBLIC static ScUserList* GetUserList();
574 static void SetUserList( const ScUserList* pNewList );
575 SC_DLLPUBLIC static const String& GetRscString( USHORT nIndex );
576 static void OpenURL( const String& rURL, const String& rTarget );
577 SC_DLLPUBLIC static String GetAbsDocName( const String& rFileName,
578 SfxObjectShell* pShell );
579 SC_DLLPUBLIC static String GetDocTabName( const String& rFileName,
580 const String& rTabName );
581 SC_DLLPUBLIC static ULONG GetStandardFormat( SvNumberFormatter&,
582 ULONG nFormat, short nType );
583 SC_DLLPUBLIC static ULONG GetStandardFormat( double, SvNumberFormatter&,
584 ULONG nFormat, short nType );
586 SC_DLLPUBLIC static double nScreenPPTX;
587 SC_DLLPUBLIC static double nScreenPPTY;
589 static ScDocShellRef* pDrawClipDocShellRef;
591 static USHORT nDefFontHeight;
592 static USHORT nStdRowHeight;
594 SC_DLLPUBLIC static long nLastRowHeightExtra;
595 static long nLastColWidthExtra;
597 static void Init(); // am Anfang
598 static void InitAddIns();
599 static void Clear(); // bei Programmende
601 static void UpdatePPT(OutputDevice* pDev);
603 static void InitTextHeight(SfxItemPool* pPool);
604 static SvxBrushItem* GetEmptyBrushItem() { return pEmptyBrushItem; }
605 static SvxBrushItem* GetButtonBrushItem();
606 static SvxBrushItem* GetEmbeddedBrushItem() { return pEmbeddedBrushItem; }
607 static SvxBrushItem* GetProtectedBrushItem() { return pProtectedBrushItem; }
608 SC_DLLPUBLIC static const String& GetEmptyString();
609 static const String& GetScDocString();
611 /** Returns the specified image list with outline symbols.
612 @param bHC false = standard symbols; true = high contrast symbols. */
613 static ImageList* GetOutlineSymbols( bool bHC );
615 // static const Bitmap& GetAnchorBitmap();
616 // static const Bitmap& GetGrayAnchorBitmap();
618 static bool HasStarCalcFunctionList();
619 static ScFunctionList* GetStarCalcFunctionList();
620 static ScFunctionMgr* GetStarCalcFunctionMgr();
621 static void ResetFunctionList();
623 static String GetErrorString(USHORT nErrNumber);
624 static String GetLongErrorString(USHORT nErrNumber);
625 static BOOL EETextObjEqual( const EditTextObject* pObj1,
626 const EditTextObject* pObj2 );
627 static BOOL CheckWidthInvalidate( BOOL& bNumFormatChanged,
628 const SfxItemSet& rNewAttrs,
629 const SfxItemSet& rOldAttrs );
630 static BOOL HasAttrChanged( const SfxItemSet& rNewAttrs,
631 const SfxItemSet& rOldAttrs,
632 const USHORT nWhich );
634 static ScUnitConverter* GetUnitConverter();
636 /// strchr() functionality on unicode, as long as we need it for ScToken etc.
637 static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c );
639 static inline sal_Unicode ToUpperAlpha( sal_Unicode c )
640 { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; }
642 /** Adds the string rToken to rTokenList, using a list separator character.
643 @param rTokenList The string list where the token will be appended to.
644 @param rToken The token string to append to the token list.
645 @param cSep The character to separate the tokens.
646 @param nSepCount Specifies how often cSep is inserted between two tokens.
647 @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */
648 SC_DLLPUBLIC static void AddToken(
649 String& rTokenList, const String& rToken,
650 sal_Unicode cSep, xub_StrLen nSepCount = 1,
651 bool bForceSep = false );
653 /** Returns true, if the first and last character of the string is cQuote. */
654 SC_DLLPUBLIC static bool IsQuoted( const String& rString, sal_Unicode cQuote = '\'' );
656 /** Inserts the character cQuote at beginning and end of rString.
657 @param bEscapeEmbedded If <TRUE/>, embedded quote characters are
658 escaped by doubling them.
660 SC_DLLPUBLIC static void AddQuotes( String& rString, sal_Unicode cQuote = '\'', bool bEscapeEmbedded = true );
662 /** Erases the character cQuote from rString, if it exists at beginning AND end.
663 @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters
664 are unescaped by replacing them with a
665 single instance.
667 SC_DLLPUBLIC static void EraseQuotes( String& rString, sal_Unicode cQuote = '\'', bool bUnescapeEmbedded = true );
669 /** Finds an unquoted instance of cChar in rString, starting at
670 offset nStart. Unquoted instances may occur when concatenating two
671 quoted strings with a separator, for example, 's1':'s2'. Embedded
672 quotes have to be escaped by being doubled. Caller must ensure that
673 nStart points into an unquoted range or the opening quote. Specialty:
674 if cChar==cQuote the first cQuote character from nStart on is found.
675 @returns offset if found, else STRING_NOTFOUND
677 SC_DLLPUBLIC static xub_StrLen FindUnquoted( const String& rString, sal_Unicode cChar, xub_StrLen nStart = 0, sal_Unicode cQuote = '\'' );
679 /** Finds an unquoted instance of cChar in null-terminated pString. Same
680 semantics as FindUnquoted( const String&, ...)
681 @returns: pointer to cChar if found, else NULL
683 SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar, sal_Unicode cQuote = '\'' );
686 static CharSet GetCharsetValue( const String& rCharSet );
687 static String GetCharsetString( CharSet eVal );
689 /// a "ReadOnly" formatter for UNO/XML export
690 static SvNumberFormatter* GetEnglishFormatter();
692 static BOOL IsSystemRTL(); // depending on system language
693 static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage
694 SC_DLLPUBLIC static BYTE GetDefaultScriptType(); // for all WEAK characters
695 /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs.
696 If more than one SCRIPTTYPE_... values are or'ed together, prefers
697 first COMPLEX, then ASIAN */
698 SC_DLLPUBLIC static USHORT GetScriptedWhichID( BYTE nScriptType, USHORT nWhich );
700 /** Adds a language item to the item set, if the number format item contains
701 a language that differs from its parent's language. */
702 SC_DLLPUBLIC static void AddLanguage( SfxItemSet& rSet, SvNumberFormatter& rFormatter );
704 /** Obtain the ordinal suffix for a number according to the system locale */
705 static String GetOrdinalSuffix( sal_Int32 nNumber);
707 #endif
709 //==================================================================
710 // evtl. in dbdata.hxx auslagern (?):
712 enum ScQueryOp
714 SC_EQUAL,
715 SC_LESS,
716 SC_GREATER,
717 SC_LESS_EQUAL,
718 SC_GREATER_EQUAL,
719 SC_NOT_EQUAL,
720 SC_TOPVAL,
721 SC_BOTVAL,
722 SC_TOPPERC,
723 SC_BOTPERC,
724 SC_CONTAINS,
725 SC_DOES_NOT_CONTAIN,
726 SC_BEGINS_WITH,
727 SC_DOES_NOT_BEGIN_WITH,
728 SC_ENDS_WITH,
729 SC_DOES_NOT_END_WITH
732 // -----------------------------------------------------------------------
734 enum ScQueryConnect
736 SC_AND,
737 SC_OR
740 // -----------------------------------------------------------------------
742 enum ScSubTotalFunc
744 SUBTOTAL_FUNC_NONE = 0,
745 SUBTOTAL_FUNC_AVE = 1,
746 SUBTOTAL_FUNC_CNT = 2,
747 SUBTOTAL_FUNC_CNT2 = 3,
748 SUBTOTAL_FUNC_MAX = 4,
749 SUBTOTAL_FUNC_MIN = 5,
750 SUBTOTAL_FUNC_PROD = 6,
751 SUBTOTAL_FUNC_STD = 7,
752 SUBTOTAL_FUNC_STDP = 8,
753 SUBTOTAL_FUNC_SUM = 9,
754 SUBTOTAL_FUNC_VAR = 10,
755 SUBTOTAL_FUNC_VARP = 11
759 #define PIVOT_MAXFUNC 11
760 #define PIVOT_FUNC_NONE 0x0000
761 #define PIVOT_FUNC_SUM 0x0001
762 #define PIVOT_FUNC_COUNT 0x0002
763 #define PIVOT_FUNC_AVERAGE 0x0004
764 #define PIVOT_FUNC_MAX 0x0008
765 #define PIVOT_FUNC_MIN 0x0010
766 #define PIVOT_FUNC_PRODUCT 0x0020
767 #define PIVOT_FUNC_COUNT_NUM 0x0040
768 #define PIVOT_FUNC_STD_DEV 0x0080
769 #define PIVOT_FUNC_STD_DEVP 0x0100
770 #define PIVOT_FUNC_STD_VAR 0x0200
771 #define PIVOT_FUNC_STD_VARP 0x0400
772 #define PIVOT_FUNC_AUTO 0x1000
774 // -----------------------------------------------------------------------
777 * Dialog liefert die ausgezeichneten Feldwerte "leer"/"nicht leer"
778 * als Konstanten SC_EMPTYFIELDS bzw. SC_NONEMPTYFIELDS in nVal in
779 * Verbindung mit dem Schalter bQueryByString auf FALSE.
782 #define SC_EMPTYFIELDS ((double)0x0042)
783 #define SC_NONEMPTYFIELDS ((double)0x0043)
785 namespace utl
787 class SearchParam;
788 class TextSearch;
791 struct ScQueryEntry
793 BOOL bDoQuery;
794 BOOL bQueryByString;
795 SCCOLROW nField;
796 ScQueryOp eOp;
797 ScQueryConnect eConnect;
798 String* pStr;
799 double nVal;
800 utl::SearchParam* pSearchParam; // falls RegExp, nicht gespeichert
801 utl::TextSearch* pSearchText; // falls RegExp, nicht gespeichert
803 ScQueryEntry();
804 ScQueryEntry(const ScQueryEntry& r);
805 ~ScQueryEntry();
807 // legt ggbf. pSearchParam und pSearchText an, immer RegExp!
808 utl::TextSearch* GetSearchTextPtr( BOOL bCaseSens );
810 void Clear();
811 ScQueryEntry& operator=( const ScQueryEntry& r );
812 BOOL operator==( const ScQueryEntry& r ) const;
815 struct SC_DLLPUBLIC ScQueryParam
817 SCCOL nCol1;
818 SCROW nRow1;
819 SCCOL nCol2;
820 SCROW nRow2;
821 SCTAB nTab;
822 BOOL bHasHeader;
823 BOOL bByRow;
824 BOOL bInplace;
825 BOOL bCaseSens;
826 BOOL bNaturalSort;
827 BOOL bRegExp;
828 BOOL bMixedComparison; // whether numbers are smaller than strings
829 BOOL bDuplicate;
830 BOOL bDestPers; // nicht gespeichert
831 SCTAB nDestTab;
832 SCCOL nDestCol;
833 SCROW nDestRow;
834 SCROW nDynamicEndRow;
835 bool bUseDynamicRange;
837 private:
838 SCSIZE nEntryCount;
839 ScQueryEntry* pEntries;
841 public:
842 ScQueryParam();
843 ScQueryParam( const ScQueryParam& r );
844 ~ScQueryParam();
846 SCSIZE GetEntryCount() const { return nEntryCount; }
847 ScQueryEntry& GetEntry(SCSIZE n) const { return pEntries[n]; }
848 void Resize(SCSIZE nNew);
850 ScQueryParam& operator= ( const ScQueryParam& r );
851 BOOL operator== ( const ScQueryParam& rOther ) const;
852 void Clear ();
853 void DeleteQuery( SCSIZE nPos );
855 void MoveToDest();
856 void FillInExcelSyntax(String& aCellStr, SCSIZE nIndex);
859 // -----------------------------------------------------------------------
861 struct SC_DLLPUBLIC ScSubTotalParam
863 SCCOL nCol1; // Selektierter Bereich
864 SCROW nRow1;
865 SCCOL nCol2;
866 SCROW nRow2;
867 BOOL bRemoveOnly;
868 BOOL bReplace; // vorhandene Ergebnisse ersetzen
869 BOOL bPagebreak; // Seitenumbruch bei Gruppenwechsel
870 BOOL bCaseSens; // Gross-/Kleinschreibung
871 BOOL bDoSort; // vorher sortieren
872 BOOL bAscending; // aufsteigend sortieren
873 BOOL bUserDef; // Benutzer-def. Sort.Reihenfolge
874 USHORT nUserIndex; // Index auf Liste
875 BOOL bIncludePattern; // Formate mit sortieren
876 BOOL bGroupActive[MAXSUBTOTAL]; // aktive Gruppen
877 SCCOL nField[MAXSUBTOTAL]; // zugehoeriges Feld
878 SCCOL nSubTotals[MAXSUBTOTAL]; // Anzahl der SubTotals
879 SCCOL* pSubTotals[MAXSUBTOTAL]; // Array der zu berechnenden Spalten
880 ScSubTotalFunc* pFunctions[MAXSUBTOTAL]; // Array der zugehoerige Funktionen
882 ScSubTotalParam();
883 ScSubTotalParam( const ScSubTotalParam& r );
885 ScSubTotalParam& operator= ( const ScSubTotalParam& r );
886 BOOL operator== ( const ScSubTotalParam& r ) const;
887 void Clear ();
888 void SetSubTotals ( USHORT nGroup,
889 const SCCOL* ptrSubTotals,
890 const ScSubTotalFunc* ptrFuncions,
891 USHORT nCount );
894 // -----------------------------------------------------------------------
895 class ScArea;
897 struct ScConsolidateParam
899 SCCOL nCol; // Cursor Position /
900 SCROW nRow; // bzw. Anfang des Zielbereiches
901 SCTAB nTab;
902 ScSubTotalFunc eFunction; // Berechnungsvorschrift
903 USHORT nDataAreaCount; // Anzahl der Datenbereiche
904 ScArea** ppDataAreas; // Zeiger-Array auf Datenbereiche
905 BOOL bByCol; // nach Spalten
906 BOOL bByRow; // nach Zeilen
907 BOOL bReferenceData; // Quelldaten referenzieren
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, USHORT nCount );
920 // -----------------------------------------------------------------------
922 class ScSimpleSharedString
924 public:
925 static const sal_Int32 EMPTY = 0;
927 ScSimpleSharedString();
928 ScSimpleSharedString(const ScSimpleSharedString& r);
929 ~ScSimpleSharedString();
931 const String* getString(sal_Int32 nId);
932 sal_Int32 getStringId(const String& aStr);
933 sal_Int32 insertString(const String& aStr);
935 private:
937 /** internal shared string table implementation */
938 class StringTable
940 public:
941 sal_Int32 insertString(const String& aStr);
942 sal_Int32 getStringId(const String& aStr);
943 const String* getString(sal_Int32 nId) const;
945 StringTable();
946 StringTable(const StringTable& r);
947 ~StringTable();
949 private:
950 typedef ::std::hash_map< String, sal_Int32, ScStringHashCode, ::std::equal_to< String > > SharedStrMap;
952 ::std::vector<String> maSharedStrings;
953 SharedStrMap maSharedStringIds;
954 sal_Int32 mnStrCount;
957 StringTable maStringTable;
960 // -----------------------------------------------------------------------
961 extern ::utl::TransliterationWrapper* GetScGlobalpTransliteration();//CHINA001
962 extern const LocaleDataWrapper* GetScGlobalpLocaleData();
964 #endif