summaryrefslogtreecommitdiff
path: root/bf_sc/source/core/data/sc_global.cxx
blob: 8e340c80c08b211e51ec9ec266d24e6f595bdffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifdef _MSC_VER
#pragma hdrstop
#endif


#include "scitems.hxx"
#include <bf_svx/editobj.hxx>
#include <bf_svx/scripttypeitem.hxx>
#include <bf_svx/langitem.hxx>
#include <bf_sfx2/app.hxx>
#include <bf_svtools/zformat.hxx>
#include <vcl/image.hxx>
#include <tools/rcid.h>
#include <vcl/virdev.hxx>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>


#include <i18npool/mslangid.hxx>
#include <unotools/intlwrapper.hxx>

#include "autoform.hxx"
#include "patattr.hxx"
#include "addincol.hxx"
#include "adiasync.hxx"
#include "userlist.hxx"
#include "interpre.hxx"
#include "strload.hxx"
#include "docpool.hxx"
#include "unitconv.hxx"
#include "globstr.hrc"
#include "bf_sc.hrc"
#include <legacysmgr/legacy_binfilters_smgr.hxx>

namespace binfilter {
// -----------------------------------------------------------------------

#define CLIPST_AVAILABLE    0
#define CLIPST_CAPTURED     1
#define CLIPST_DELETE       2
#define CLIPST_DRAW         3

ScDocShellRef*  ScGlobal::pDrawClipDocShellRef = NULL;
ScAutoFormat*   ScGlobal::pAutoFormat = NULL;
FuncCollection* ScGlobal::pFuncCollection = NULL;
ScUnoAddInCollection* ScGlobal::pAddInCollection = NULL;
ScUserList*     ScGlobal::pUserList = NULL;
String**        ScGlobal::ppRscString = NULL;
LanguageType    ScGlobal::eLnge = LANGUAGE_SYSTEM;
::com::sun::star::lang::Locale*     ScGlobal::pLocale = NULL;
SvtSysLocale*   ScGlobal::pSysLocale = NULL;
const CharClass*  ScGlobal::pCharClass = NULL;
const LocaleDataWrapper*  ScGlobal::pLocaleData = NULL;
CalendarWrapper* ScGlobal::pCalendar = NULL;
CollatorWrapper* ScGlobal::pCollator = NULL;
CollatorWrapper* ScGlobal::pCaseCollator = NULL;
::utl::TransliterationWrapper* ScGlobal::pTransliteration = NULL;
::utl::TransliterationWrapper* ScGlobal::pCaseTransliteration = NULL;
IntlWrapper*    ScGlobal::pScIntlWrapper = NULL;
sal_Unicode     ScGlobal::cListDelimiter = ',';
String*         ScGlobal::pEmptyString = NULL;
String*         ScGlobal::pStrClipDocName = NULL;

SvxBrushItem*   ScGlobal::pEmptyBrushItem = NULL;
SvxBrushItem*   ScGlobal::pButtonBrushItem = NULL;
SvxBrushItem*   ScGlobal::pEmbeddedBrushItem = NULL;
SvxBrushItem*   ScGlobal::pProtectedBrushItem = NULL;

ImageList*      ScGlobal::pOutlineBitmaps = NULL;
ImageList*      ScGlobal::pOutlineBitmapsHC = NULL;

ScFunctionList* ScGlobal::pStarCalcFunctionList = NULL;
ScFunctionMgr*  ScGlobal::pStarCalcFunctionMgr  = NULL;

ScUnitConverter* ScGlobal::pUnitConverter = NULL;
SvNumberFormatter* ScGlobal::pEnglishFormatter = NULL;

double          ScGlobal::nScreenPPTX           = 96.0;
double          ScGlobal::nScreenPPTY           = 96.0;

USHORT          ScGlobal::nDefFontHeight        = 240;
USHORT          ScGlobal::nStdRowHeight         = 257;

long            ScGlobal::nLastRowHeightExtra   = 0;
long            ScGlobal::nLastColWidthExtra    = STD_EXTRA_WIDTH;

static USHORT nPPTZoom = 0;     // ScreenZoom used to determine nScreenPPTX/Y


// ... oder so?

BOOL bOderSo;

class SfxViewShell;
SfxViewShell* pScActiveViewShell = NULL;            //! als Member !!!!!
USHORT nScClickMouseModifier = 0;                   //! dito
USHORT nScFillModeMouseModifier = 0;                //! dito

// Hack: ScGlobal::GetUserList() muss InitAppOptions in der UI aufrufen,
//       damit UserList aus Cfg geladen wird

void global_InitAppOptions();

// -----------------------------------------------------------------------

/*N*/ String ScTripel::GetColRowString( BOOL bAbsolute ) const
/*N*/ {
/*N*/   String aString;
/*N*/   if (bAbsolute)
/*N*/       aString.Append( '$' );
/*N*/
/*N*/   if ( nCol < 26 )
/*N*/       aString.Append( (sal_Unicode) ( 'A' + nCol ) );
/*N*/   else
/*N*/   {
/*N*/       aString.Append( (sal_Unicode) ( 'A' + ( nCol / 26 ) - 1 ) );
/*N*/       aString.Append( (sal_Unicode) ( 'A' + ( nCol % 26 ) ) );
/*N*/   }
/*N*/
/*N*/   if ( bAbsolute )
/*N*/       aString.Append( '$' );
/*N*/
/*N*/   aString += String::CreateFromInt32(nRow+1);
/*N*/
/*N*/   return aString;
/*N*/ }

/*N*/ String ScRefTripel::GetRefString(ScDocument* pDoc, USHORT nActTab) const
/*N*/ {
/*N*/   if ( !pDoc )
/*N*/       return EMPTY_STRING;
/*N*/   if ( nTab+1 > pDoc->GetTableCount() )
/*N*/       return ScGlobal::GetRscString( STR_NOREF_STR );
/*N*/
/*N*/     String aString;
/*N*/     USHORT nFlags = SCA_VALID;
/*N*/     if ( nActTab != nTab )
/*N*/     {
/*N*/         nFlags |= SCA_TAB_3D;
/*N*/         if ( !bRelTab )
/*N*/             nFlags |= SCA_TAB_ABSOLUTE;
/*N*/     }
/*N*/     if ( !bRelCol )
/*N*/         nFlags |= SCA_COL_ABSOLUTE;
/*N*/     if ( !bRelRow )
/*N*/         nFlags |= SCA_ROW_ABSOLUTE;
/*N*/
/*N*/     ScAddress( nCol, nRow, nTab ).Format( aString, nFlags, pDoc );
/*N*/
/*N*/     return aString;
/*N*/ }


//========================================================================
//
//      statische Funktionen
//
//========================================================================

/*N*/ BOOL ScGlobal::HasAttrChanged( const SfxItemSet&  rNewAttrs,
/*N*/                              const SfxItemSet&  rOldAttrs,
/*N*/                              const USHORT       nWhich )
/*N*/ {
/*N*/   BOOL                bInvalidate = FALSE;
/*N*/   const SfxItemState  eNewState   = rNewAttrs.GetItemState( nWhich );
/*N*/   const SfxItemState  eOldState   = rOldAttrs.GetItemState( nWhich );
/*N*/
/*N*/   //----------------------------------------------------------
/*N*/
/*N*/   if ( eNewState == eOldState )
/*N*/   {
/*N*/       // beide Items gesetzt
/*N*/       // PoolItems, d.h. Pointer-Vergleich zulaessig
/*N*/       if ( SFX_ITEM_SET == eOldState )
/*N*/           bInvalidate = (&rNewAttrs.Get( nWhich ) != &rOldAttrs.Get( nWhich ));
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/       // ein Default-Item dabei
/*N*/       // PoolItems, d.h. Item-Vergleich noetig
/*N*/
/*N*/       const SfxPoolItem& rOldItem = ( SFX_ITEM_SET == eOldState )
/*N*/                   ? rOldAttrs.Get( nWhich )
/*N*/                   : rOldAttrs.GetPool()->GetDefaultItem( nWhich );
/*N*/
/*N*/       const SfxPoolItem& rNewItem = ( SFX_ITEM_SET == eNewState )
/*N*/                   ? rNewAttrs.Get( nWhich )
/*N*/                   : rNewAttrs.GetPool()->GetDefaultItem( nWhich );
/*N*/
/*N*/       bInvalidate = (rNewItem != rOldItem);
/*N*/   }
/*N*/
/*N*/   return bInvalidate;
/*N*/ }

/*N*/ ULONG ScGlobal::GetStandardFormat( SvNumberFormatter& rFormatter,
/*N*/       ULONG nFormat, short nType )
/*N*/ {
/*N*/   const SvNumberformat* pFormat = rFormatter.GetEntry( nFormat );
/*N*/   if ( pFormat )
/*N*/       return rFormatter.GetStandardFormat( nFormat, nType, pFormat->GetLanguage() );
/*N*/   return rFormatter.GetStandardFormat( nType, eLnge );
/*N*/ }

/*N*/ ULONG ScGlobal::GetStandardFormat( double fNumber, SvNumberFormatter& rFormatter,
/*N*/       ULONG nFormat, short nType )
/*N*/ {
/*N*/   const SvNumberformat* pFormat = rFormatter.GetEntry( nFormat );
/*N*/   if ( pFormat )
/*N*/       return rFormatter.GetStandardFormat( fNumber, nFormat, nType,
/*N*/           pFormat->GetLanguage() );
/*?*/   return rFormatter.GetStandardFormat( nType, eLnge );
/*N*/ }


// static
/*N*/ SvNumberFormatter* ScGlobal::GetEnglishFormatter()
/*N*/ {
/*N*/     if ( !pEnglishFormatter )
/*N*/     {
/*N*/         pEnglishFormatter = new SvNumberFormatter(
/*N*/             ::legacy_binfilters::getLegacyProcessServiceFactory(), LANGUAGE_ENGLISH_US );
/*N*/         pEnglishFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT );
/*N*/     }
/*N*/     return pEnglishFormatter;
/*N*/ }


//------------------------------------------------------------------------

/*N*/ BOOL ScGlobal::CheckWidthInvalidate( BOOL& bNumFormatChanged,
/*N*/                                    const SfxItemSet& rNewAttrs,
/*N*/                                    const SfxItemSet& rOldAttrs )
/*N*/ {
/*N*/   // Ueberpruefen, ob Attributaenderungen in rNewAttrs gegnueber
/*N*/   // rOldAttrs die Textbreite an einer Zelle ungueltig machen
/*N*/
/*N*/   bNumFormatChanged =
/*N*/           HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_VALUE_FORMAT );
/*N*/   return ( bNumFormatChanged
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_LANGUAGE_FORMAT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_HEIGHT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT_HEIGHT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT_HEIGHT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_WEIGHT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT_WEIGHT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT_WEIGHT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_POSTURE )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT_POSTURE )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT_POSTURE )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_UNDERLINE )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_CROSSEDOUT )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_CONTOUR )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_SHADOWED )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_ORIENTATION )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_ROTATE_VALUE )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_ROTATE_MODE )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_LINEBREAK )
/*N*/       || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_MARGIN )
/*N*/       );
/*N*/ }




/*N*/ ScAutoFormat* ScGlobal::GetAutoFormat()
/*N*/ {
/*N*/   if ( !pAutoFormat )
/*N*/   {
/*N*/       pAutoFormat = new ScAutoFormat;
/*N*/       pAutoFormat->Load();
/*N*/   }
/*N*/
/*N*/   return pAutoFormat;
/*N*/ }

/*N*/ FuncCollection* ScGlobal::GetFuncCollection()
/*N*/ {
/*N*/   if (!pFuncCollection)
/*N*/       pFuncCollection = new FuncCollection();
/*N*/   return pFuncCollection;
/*N*/ }

/*N*/ ScUnoAddInCollection* ScGlobal::GetAddInCollection()
/*N*/ {
/*N*/   if (!pAddInCollection)
/*N*/       pAddInCollection = new ScUnoAddInCollection();
/*N*/   return pAddInCollection;
/*N*/ }

/*N*/ ScUserList* ScGlobal::GetUserList()
/*N*/ {
/*N*/   // Hack: Cfg-Item an der App ggF. laden
/*N*/
/*N*/   global_InitAppOptions();
/*N*/
/*N*/   if (!pUserList)
/*N*/       pUserList = new ScUserList();
/*N*/   return pUserList;
/*N*/ }

/*N*/ void ScGlobal::SetUserList( const ScUserList* pNewList )
/*N*/ {
/*N*/   if ( pNewList )
/*N*/   {
/*N*/       if ( !pUserList )
/*N*/           pUserList = new ScUserList( *pNewList );
/*N*/       else
/*?*/           *pUserList = *pNewList;
/*N*/   }
/*N*/   else
/*N*/   {
/*?*/       delete pUserList;
/*?*/       pUserList = NULL;
/*N*/   }
/*N*/ }

/*N*/ const String& ScGlobal::GetRscString( USHORT nIndex )
/*N*/ {
/*N*/   DBG_ASSERT( nIndex <= STR_COUNT,
/*N*/       "-ScGlobal::GetRscString(): Index zu gross!");
/*N*/   if( !ppRscString[ nIndex ] )
/*N*/   {
/*N*/       ppRscString[ nIndex ] =
/*N*/           new String( ScRscStrLoader( RID_GLOBSTR, nIndex ).GetString() );
/*N*/   }
/*N*/   return *ppRscString[ nIndex ];
/*N*/ }

/*N*/ String ScGlobal::GetErrorString(USHORT nErrNumber)
/*N*/ {
/*N*/   String sResStr;
/*N*/   switch (nErrNumber)
/*N*/   {
/*N*/       case NOVALUE     : nErrNumber = STR_NV_STR; break;
/*N*/       case errNoRef    : nErrNumber = STR_NO_REF_TABLE; break;
/*N*/       case errNoName   : nErrNumber = STR_NO_NAME_REF; break;
/*N*/         case errNoAddin  : nErrNumber = STR_NO_ADDIN; break;
/*N*/         case errNoMacro  : nErrNumber = STR_NO_MACRO; break;
/*N*/       case errDoubleRef:
/*N*/       case errNoValue  : nErrNumber = STR_NO_VALUE; break;
/*N*/
/*N*/       default          : sResStr = GetRscString(STR_ERROR_STR);
/*N*/                          sResStr += String::CreateFromInt32( nErrNumber );
/*N*/                          nErrNumber = 0;
/*N*/                          break;
/*N*/   }
/*N*/   if( nErrNumber )
/*N*/       sResStr = GetRscString( nErrNumber );
/*N*/   return sResStr;
/*N*/ }

/*N*/ const String& ScGlobal::GetEmptyString()
/*N*/ {
/*N*/   return *pEmptyString;
/*N*/ }


/*N*/ void ScGlobal::Init()
/*N*/ {
/*N*/   pEmptyString = new String;
/*N*/
/*N*/   //  Die Default-Sprache fuer Zahlenformate (ScGlobal::eLnge)
/*N*/   //  muss immer LANGUAGE_SYSTEM sein
/*N*/   //! Dann kann auch die Variable raus
/*N*/   eLnge = LANGUAGE_SYSTEM;
/*N*/
/*N*/   //! Wenn Sortierung etc. von der Sprache der installierten Offfice-Version
/*N*/     //! abhaengen sollen, hier "Application::GetSettings().GetUILanguage()"
/*N*/   String aLanguage, aCountry;
/*N*/     LanguageType eOfficeLanguage = Application::GetSettings().GetLanguage();
/*N*/   pLocale = new ::com::sun::star::lang::Locale( MsLangId::convertLanguageToLocale( eOfficeLanguage ));
/*N*/     pSysLocale = new SvtSysLocale;
/*N*/     pCharClass = pSysLocale->GetCharClassPtr();
/*N*/     pLocaleData = pSysLocale->GetLocaleDataPtr();
/*N*/   pCalendar = new CalendarWrapper( comphelper::getComponentContext( ::legacy_binfilters::getLegacyProcessServiceFactory() ) );
/*N*/   pCalendar->loadDefaultCalendar( *pLocale );
/*N*/   pCollator = new CollatorWrapper( ::legacy_binfilters::getLegacyProcessServiceFactory() );
/*N*/   pCollator->loadDefaultCollator( *pLocale, SC_COLLATOR_IGNORES );
/*N*/   pCaseCollator = new CollatorWrapper( ::legacy_binfilters::getLegacyProcessServiceFactory() );
/*N*/   pCaseCollator->loadDefaultCollator( *pLocale, 0 );
/*N*/     pTransliteration = new ::utl::TransliterationWrapper(
/*N*/         comphelper::getComponentContext( ::legacy_binfilters::getLegacyProcessServiceFactory() ), SC_TRANSLITERATION_IGNORECASE );
/*N*/     pTransliteration->loadModuleIfNeeded( eOfficeLanguage );
/*N*/     pCaseTransliteration = new ::utl::TransliterationWrapper(
/*N*/         comphelper::getComponentContext( ::legacy_binfilters::getLegacyProcessServiceFactory() ), SC_TRANSLITERATION_CASESENSE );
/*N*/     pCaseTransliteration->loadModuleIfNeeded( eOfficeLanguage );
/*N*/     pScIntlWrapper = new IntlWrapper( ::legacy_binfilters::getLegacyProcessServiceFactory(), *pLocale );
/*N*/
/*N*/   ppRscString = new String *[ STR_COUNT+1 ];
/*N*/   for( USHORT nC = 0 ; nC <= STR_COUNT ; nC++ ) ppRscString[ nC ] = NULL;
/*N*/
/*N*/   pEmptyBrushItem = new SvxBrushItem( Color( COL_TRANSPARENT ) );
/*N*/     pButtonBrushItem = new SvxBrushItem( Color() );
/*N*/   pEmbeddedBrushItem = new SvxBrushItem( Color( COL_LIGHTCYAN ) );
/*N*/   pProtectedBrushItem = new SvxBrushItem( Color( COL_LIGHTGRAY ) );
/*N*/
/*N*/   UpdatePPT(NULL);
/*N*/   ScCompiler::Init();
/*N*/   srand( (unsigned) time( NULL ) );       // Random Seed Init fuer Interpreter
/*N*/
/*N*/   InitAddIns();
/*N*/
/*N*/   pStrClipDocName = new String( ScResId( SCSTR_NONAME ).toString() );
/*N*/   *pStrClipDocName += '1';
/*N*/
/*N*/   //  ScDocumentPool::InitVersionMaps() ist schon vorher gerufen worden
/*N*/ }

/*N*/ void ScGlobal::UpdatePPT( OutputDevice* pDev )
/*N*/ {
/*N*/   USHORT nCurrentZoom = Application::GetSettings().GetStyleSettings().GetScreenZoom();
/*N*/   if ( nCurrentZoom != nPPTZoom )
/*N*/   {
/*N*/       //  Screen PPT values must be updated when ScreenZoom has changed.
/*N*/       //  If called from Window::DataChanged, the window is passed as pDev,
/*N*/       //  to make sure LogicToPixel uses a device which already uses the new zoom.
/*N*/       //  For the initial settings, NULL is passed and GetDefaultDevice used.
/*N*/
/*N*/       if ( !pDev )
/*N*/           pDev = Application::GetDefaultDevice();
/*N*/       Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
/*N*/       nScreenPPTX = aPix1000.X() / 1000.0;
/*N*/       nScreenPPTY = aPix1000.Y() / 1000.0;
/*N*/       nPPTZoom = nCurrentZoom;
/*N*/   }
/*N*/ }




/*N*/ void ScGlobal::InitTextHeight(SfxItemPool* pPool)
/*N*/ {
/*N*/   if (!pPool)
/*N*/   {
/*?*/       OSL_FAIL("kein Pool bei ScGlobal::InitTextHeight");
/*?*/       return;
/*N*/   }
/*N*/
/*N*/   const ScPatternAttr* pPattern = (const ScPatternAttr*)&pPool->GetDefaultItem(ATTR_PATTERN);
/*N*/   if (!pPattern)
/*N*/   {
/*?*/       OSL_FAIL("kein Default-Pattern bei ScGlobal::InitTextHeight");
/*?*/       return;
/*N*/   }
/*N*/
/*N*/ //    String aTestString('X');
/*N*/   OutputDevice* pDefaultDev = Application::GetDefaultDevice();
/*N*/   VirtualDevice aVirtWindow( *pDefaultDev );
/*N*/   aVirtWindow.SetMapMode(MAP_PIXEL);
/*N*/   Font aDefFont;
/*N*/   pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow);        // font color doesn't matter here
/*N*/   aVirtWindow.SetFont(aDefFont);
/*N*/   nDefFontHeight = (USHORT) aVirtWindow.PixelToLogic(Size(0, aVirtWindow.GetTextHeight()),
/*N*/                               MAP_TWIP).Height();
/*N*/
/*N*/   const SvxMarginItem* pMargin = (const SvxMarginItem*)&pPattern->GetItem(ATTR_MARGIN);
/*N*/
/*N*/   nStdRowHeight = (USHORT) ( nDefFontHeight +
/*N*/                               pMargin->GetTopMargin() + pMargin->GetBottomMargin()
/*N*/                               - STD_ROWHEIGHT_DIFF );
/*N*/ }

/*N*/ void ScGlobal::Clear()
/*N*/ {
/*N*/   // asyncs _vor_ ExitExternalFunc zerstoeren!
/*N*/   theAddInAsyncTbl.DeleteAndDestroy( 0, theAddInAsyncTbl.Count() );
/*N*/   ExitExternalFunc();
/*N*/   DELETEZ(pAutoFormat);
/*N*/   DELETEZ(pFuncCollection);
/*N*/   DELETEZ(pAddInCollection);
/*N*/   DELETEZ(pUserList);
/*N*/
/*N*/   for( USHORT nC = 0 ; nC < STR_COUNT ; nC++ )
/*N*/       if( ppRscString ) delete ppRscString[ nC ];
/*N*/   delete[] ppRscString;
/*N*/   ppRscString = NULL;
/*N*/
/*N*/   DELETEZ(pStarCalcFunctionList);     // vor ResMgr zerstoeren!
/*N*/   DELETEZ(pStarCalcFunctionMgr);
/*N*/   ScCompiler::DeInit();
/*N*/   ScInterpreter::GlobalExit();            // statischen Stack loeschen
/*N*/
/*N*/   DELETEZ(pEmptyBrushItem);
/*N*/   DELETEZ(pButtonBrushItem);
/*N*/   DELETEZ(pEmbeddedBrushItem);
/*N*/   DELETEZ(pProtectedBrushItem);
/*N*/     DELETEZ(pOutlineBitmaps);
/*N*/     DELETEZ(pOutlineBitmapsHC);
/*N*/     DELETEZ(pEnglishFormatter);
/*N*/     DELETEZ(pCaseTransliteration);
/*N*/     DELETEZ(pTransliteration);
/*N*/   DELETEZ(pCaseCollator);
/*N*/   DELETEZ(pCollator);
/*N*/   DELETEZ(pCalendar);
/*N*/     //! do NOT delete pCharClass since it is a pointer to the single SvtSysLocale instance
/*N*/     pCharClass = NULL;
/*N*/     //! do NOT delete pLocaleData since it is a pointer to the single SvtSysLocale instance
/*N*/     pLocaleData = NULL;
/*N*/     DELETEZ(pSysLocale);
/*N*/   DELETEZ(pLocale);
/*N*/     DELETEZ(pScIntlWrapper);
/*N*/   DELETEZ(pStrClipDocName);
/*N*/
/*N*/   DELETEZ(pUnitConverter);
/*N*/
/*N*/   ScDocumentPool::DeleteVersionMaps();
/*N*/
/*N*/   DELETEZ(pEmptyString);
/*N*/ }

//------------------------------------------------------------------------

// static
/*N*/ String ScGlobal::GetCharsetString( CharSet eVal )
/*N*/ {
/*N*/   const sal_Char* pChar;
/*N*/   switch ( eVal )
/*N*/   {
/*N*/       // old CharSet strings for compatibility
/*N*/       case RTL_TEXTENCODING_MS_1252:      pChar = "ANSI";         break;
/*N*/       case RTL_TEXTENCODING_APPLE_ROMAN:  pChar = "MAC";          break;
/*N*/       // IBMPC == IBMPC_850
/*N*/       case RTL_TEXTENCODING_IBM_437:      pChar = "IBMPC_437";    break;
/*N*/       case RTL_TEXTENCODING_IBM_850:      pChar = "IBMPC_850";    break;
/*N*/       case RTL_TEXTENCODING_IBM_860:      pChar = "IBMPC_860";    break;
/*N*/       case RTL_TEXTENCODING_IBM_861:      pChar = "IBMPC_861";    break;
/*N*/       case RTL_TEXTENCODING_IBM_863:      pChar = "IBMPC_863";    break;
/*N*/       case RTL_TEXTENCODING_IBM_865:      pChar = "IBMPC_865";    break;
/*N*/       case RTL_TEXTENCODING_DONTKNOW:     pChar = "SYSTEM";       break;
/*N*/       // new string of TextEncoding value
/*N*/       default:
/*N*/           return String::CreateFromInt32( eVal );
/*N*/   }
/*N*/   return String::CreateFromAscii(pChar);
/*N*/  }

//------------------------------------------------------------------------

/*N*/ ScFunctionList* ScGlobal::GetStarCalcFunctionList()
/*N*/ {
/*N*/   if ( !pStarCalcFunctionList )
/*N*/       pStarCalcFunctionList = new ScFunctionList;
/*N*/
/*N*/   return pStarCalcFunctionList;
/*N*/ }

// static
/*N*/ ScUnitConverter* ScGlobal::GetUnitConverter()
/*N*/ {
/*N*/   if ( !pUnitConverter )
/*N*/       pUnitConverter = new ScUnitConverter;
/*N*/
/*N*/   return pUnitConverter;
/*N*/ }


//------------------------------------------------------------------------

// static
/*N*/ const sal_Unicode* ScGlobal::UnicodeStrChr( const sal_Unicode* pStr,
/*N*/           sal_Unicode c )
/*N*/ {
/*N*/   if ( !pStr )
/*N*/       return NULL;
/*N*/   while ( *pStr )
/*N*/   {
/*N*/       if ( *pStr == c )
/*N*/           return pStr;
/*N*/       pStr++;
/*N*/   }
/*N*/   return NULL;
/*N*/ }


//------------------------------------------------------------------------

/*N*/ BOOL ScGlobal::EETextObjEqual( const EditTextObject* pObj1,
/*N*/                              const EditTextObject* pObj2 )
/*N*/ {
/*N*/   if ( pObj1 == pObj2 )               // both empty or the same object
/*N*/       return TRUE;
/*N*/
/*N*/   if ( pObj1 && pObj2 )
/*N*/   {
/*N*/       //  first test for equal text content
/*N*/       USHORT nParCount = pObj1->GetParagraphCount();
/*N*/       if ( nParCount != pObj2->GetParagraphCount() )
/*N*/           return FALSE;
/*N*/       for (USHORT nPar=0; nPar<nParCount; nPar++)
/*N*/           if ( pObj1->GetText(nPar) != pObj2->GetText(nPar) )
/*N*/               return FALSE;
/*N*/
/*N*/       SvMemoryStream  aStream1;
/*N*/       SvMemoryStream  aStream2;
/*N*/       pObj1->Store( aStream1 );
/*N*/       pObj2->Store( aStream2 );
/*N*/       ULONG nSize = aStream1.Tell();
/*N*/       if ( aStream2.Tell() == nSize )
/*N*/           if ( !memcmp( aStream1.GetData(), aStream2.GetData(), (USHORT) nSize ) )
/*N*/               return TRUE;
/*N*/   }
/*N*/
/*N*/   return FALSE;
/*N*/ }


//------------------------------------------------------------------------

/*N*/ BYTE ScGlobal::GetDefaultScriptType()
/*N*/ {
/*N*/   //  Used when text contains only WEAK characters.
/*N*/   //  Script type of office language is used then (same as GetEditDefaultLanguage,
/*N*/   //  to get consistent behavior of text in simple cells and EditEngine,
/*N*/   //  also same as GetAppLanguage() in Writer)
/*N*/
/*N*/   return (BYTE) SvtLanguageOptions::GetScriptTypeOfLanguage( Application::GetSettings().GetLanguage() );
/*N*/ }

/*N*/ LanguageType ScGlobal::GetEditDefaultLanguage()
/*N*/ {
/*N*/   //  used for EditEngine::SetDefaultLanguage
/*N*/
/*N*/   return Application::GetSettings().GetLanguage();
/*N*/ }


//------------------------------------------------------------------------

/*N*/ void ScGlobal::AddLanguage( SfxItemSet& rSet, SvNumberFormatter& rFormatter )
/*N*/ {
/*N*/     DBG_ASSERT( rSet.GetItemState( ATTR_LANGUAGE_FORMAT, FALSE ) == SFX_ITEM_DEFAULT,
/*N*/         "ScGlobal::AddLanguage - language already added");
/*N*/
/*N*/     const SfxPoolItem* pHardItem;
/*N*/     if ( rSet.GetItemState( ATTR_VALUE_FORMAT, FALSE, &pHardItem ) == SFX_ITEM_SET )
/*N*/     {
/*N*/         const SvNumberformat* pHardFormat = rFormatter.GetEntry(
/*N*/             ((const SfxUInt32Item*)pHardItem)->GetValue() );
/*N*/
/*N*/         ULONG nParentFmt = 0;   // pool default
/*N*/         const SfxItemSet* pParent = rSet.GetParent();
/*N*/         if ( pParent )
/*N*/             nParentFmt = ((const SfxUInt32Item&)pParent->Get( ATTR_VALUE_FORMAT )).GetValue();
/*N*/         const SvNumberformat* pParFormat = rFormatter.GetEntry( nParentFmt );
/*N*/
/*N*/         if ( pHardFormat && pParFormat &&
/*N*/                 (pHardFormat->GetLanguage() != pParFormat->GetLanguage()) )
/*N*/             rSet.Put( SvxLanguageItem( pHardFormat->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
/*N*/     }
/*N*/ }


ScFunctionList::ScFunctionList() :
    nMaxFuncNameLen ( 0 )
{
}

//------------------------------------------------------------------------

/*N*/ ScFunctionList::~ScFunctionList()
/*N*/ {
/*N*/   ScFuncDesc* pDesc = (ScFuncDesc*)aFunctionList.First();
/*N*/   while (pDesc)
/*N*/   {
/*N*/       delete pDesc;
/*N*/       pDesc = (ScFuncDesc*)aFunctionList.Next();
/*N*/   }
/*N*/ }


//========================================================================
// class ScFuncDesc:

/*N*/ ScFuncDesc::~ScFuncDesc()
/*N*/ {
/*N*/   USHORT      nArgs;
/*N*/
/*N*/   nArgs = nArgCount;
/*N*/   if (nArgs >= VAR_ARGS) nArgs -= VAR_ARGS-1;
/*N*/   if (nArgs)
/*N*/   {
/*?*/       for (USHORT i=0; i<nArgs; i++ )
/*?*/       {
/*?*/           delete aDefArgNames[i];
/*?*/           delete aDefArgDescs[i];
/*?*/       }
/*?*/       delete [] aDefArgNames;
/*?*/       delete [] aDefArgDescs;
/*?*/       delete [] aDefArgOpt;
/*N*/   }
/*N*/   if(pFuncName)
/*?*/       delete pFuncName;
/*N*/
/*N*/   if(pFuncDesc)
/*?*/       delete pFuncDesc;
/*N*/ }

//========================================================================
// class ScFunctionMgr:

ScFunctionMgr::~ScFunctionMgr()
{
}

/*N*/ String ColToAlpha( const USHORT nCol )
/*N*/ {
/*N*/   String aStr;
/*N*/
/*N*/   if ( nCol < 26 )
/*N*/       aStr = (sal_Unicode) ( 'A' + nCol );
/*N*/   else
/*N*/   {
/*N*/       aStr  = (sal_Unicode) ( 'A' + ( nCol / 26 ) - 1 );
/*N*/       aStr += (sal_Unicode) ( 'A' + ( nCol % 26 ) );
/*N*/   }
/*N*/
/*N*/   return aStr;
/*N*/ }

}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */