LCOV - code coverage report
Current view: top level - sc/source/core/data - global.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 352 552 63.8 %
Date: 2014-11-03 Functions: 46 59 78.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <vcl/svapp.hxx>
      21             : #include "scitems.hxx"
      22             : #include <svx/algitem.hxx>
      23             : #include <editeng/brushitem.hxx>
      24             : #include <editeng/editobj.hxx>
      25             : #include <editeng/scripttypeitem.hxx>
      26             : #include <svl/srchitem.hxx>
      27             : #include <editeng/langitem.hxx>
      28             : #include <sfx2/docfile.hxx>
      29             : #include <sfx2/dispatch.hxx>
      30             : #include <sfx2/objsh.hxx>
      31             : #include <sfx2/viewfrm.hxx>
      32             : #include <sfx2/viewsh.hxx>
      33             : #include <svl/stritem.hxx>
      34             : #include <svl/zforlist.hxx>
      35             : #include <svl/zformat.hxx>
      36             : #include <vcl/image.hxx>
      37             : #include <vcl/virdev.hxx>
      38             : #include <vcl/settings.hxx>
      39             : #include <sal/macros.h>
      40             : #include <tools/rcid.h>
      41             : #include <unotools/charclass.hxx>
      42             : #include <unotools/securityoptions.hxx>
      43             : #include <stdlib.h>
      44             : #include <time.h>
      45             : #include <ctype.h>
      46             : #include <numeric>
      47             : 
      48             : #include <i18nlangtag/mslangid.hxx>
      49             : #include <com/sun/star/lang/Locale.hpp>
      50             : #include <comphelper/processfactory.hxx>
      51             : #include <comphelper/random.hxx>
      52             : #include <comphelper/string.hxx>
      53             : #include <unotools/calendarwrapper.hxx>
      54             : #include <unotools/collatorwrapper.hxx>
      55             : #include <com/sun/star/i18n/CollatorOptions.hpp>
      56             : #include <unotools/intlwrapper.hxx>
      57             : #include <unotools/syslocale.hxx>
      58             : #include <unotools/transliterationwrapper.hxx>
      59             : 
      60             : #include "global.hxx"
      61             : #include "scresid.hxx"
      62             : #include "autoform.hxx"
      63             : #include "document.hxx"
      64             : #include "patattr.hxx"
      65             : #include "addincol.hxx"
      66             : #include "adiasync.hxx"
      67             : #include "userlist.hxx"
      68             : #include "interpre.hxx"
      69             : #include "strload.hxx"
      70             : #include "docpool.hxx"
      71             : #include "unitconv.hxx"
      72             : #include "compiler.hxx"
      73             : #include "parclass.hxx"
      74             : #include "funcdesc.hxx"
      75             : #include "globstr.hrc"
      76             : #include "scfuncs.hrc"
      77             : #include "sc.hrc"
      78             : #include "scmod.hxx"
      79             : #include "appoptio.hxx"
      80             : #include "editutil.hxx"
      81             : 
      82             : tools::SvRef<ScDocShell>*  ScGlobal::pDrawClipDocShellRef = NULL;
      83             : SvxSearchItem*  ScGlobal::pSearchItem = NULL;
      84             : ScAutoFormat*   ScGlobal::pAutoFormat = NULL;
      85             : FuncCollection* ScGlobal::pFuncCollection = NULL;
      86             : ScUnoAddInCollection* ScGlobal::pAddInCollection = NULL;
      87             : ScUserList*     ScGlobal::pUserList = NULL;
      88             : OUString**      ScGlobal::ppRscString = NULL;
      89             : LanguageType    ScGlobal::eLnge = LANGUAGE_SYSTEM;
      90             : ::com::sun::star::lang::Locale*     ScGlobal::pLocale = NULL;
      91             : SvtSysLocale*   ScGlobal::pSysLocale = NULL;
      92             : const CharClass*  ScGlobal::pCharClass = NULL;
      93             : const LocaleDataWrapper*  ScGlobal::pLocaleData = NULL;
      94             : CalendarWrapper* ScGlobal::pCalendar = NULL;
      95             : CollatorWrapper* ScGlobal::pCollator = NULL;
      96             : CollatorWrapper* ScGlobal::pCaseCollator = NULL;
      97             : ::utl::TransliterationWrapper* ScGlobal::pTransliteration = NULL;
      98             : ::utl::TransliterationWrapper* ScGlobal::pCaseTransliteration = NULL;
      99          76 : ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XOrdinalSuffix> ScGlobal::xOrdinalSuffix = NULL;
     100             : IntlWrapper*    ScGlobal::pScIntlWrapper = NULL;
     101             : sal_Unicode     ScGlobal::cListDelimiter = ',';
     102             : OUString*       ScGlobal::pEmptyOUString = NULL;
     103             : OUString*       ScGlobal::pStrClipDocName = NULL;
     104             : 
     105             : SvxBrushItem*   ScGlobal::pEmptyBrushItem = NULL;
     106             : SvxBrushItem*   ScGlobal::pButtonBrushItem = NULL;
     107             : SvxBrushItem*   ScGlobal::pEmbeddedBrushItem = NULL;
     108             : SvxBrushItem*   ScGlobal::pProtectedBrushItem = NULL;
     109             : 
     110             : ImageList*      ScGlobal::pOutlineBitmaps = NULL;
     111             : 
     112             : ScFunctionList* ScGlobal::pStarCalcFunctionList = NULL;
     113             : ScFunctionMgr*  ScGlobal::pStarCalcFunctionMgr  = NULL;
     114             : 
     115             : ScUnitConverter* ScGlobal::pUnitConverter = NULL;
     116             : SvNumberFormatter* ScGlobal::pEnglishFormatter = NULL;
     117             : ScFieldEditEngine* ScGlobal::pFieldEditEngine = NULL;
     118             : 
     119             : double          ScGlobal::nScreenPPTX           = 96.0;
     120             : double          ScGlobal::nScreenPPTY           = 96.0;
     121             : 
     122             : sal_uInt16          ScGlobal::nDefFontHeight        = 225;
     123             : sal_uInt16          ScGlobal::nStdRowHeight         = 256;
     124             : 
     125             : long            ScGlobal::nLastRowHeightExtra   = 0;
     126             : long            ScGlobal::nLastColWidthExtra    = STD_EXTRA_WIDTH;
     127             : 
     128             : static sal_uInt16 nPPTZoom = 0; // ScreenZoom used to determine nScreenPPTX/Y
     129             : 
     130             : class SfxViewShell;
     131             : SfxViewShell* pScActiveViewShell = NULL; //FIXME: Make this a member
     132             : sal_uInt16 nScClickMouseModifier = 0;    //FIXME: This too
     133             : sal_uInt16 nScFillModeMouseModifier = 0; //FIXME: And this
     134             : 
     135             : // Static functions
     136             : 
     137    10751426 : bool ScGlobal::HasAttrChanged( const SfxItemSet&  rNewAttrs,
     138             :                                const SfxItemSet&  rOldAttrs,
     139             :                                const sal_uInt16       nWhich )
     140             : {
     141    10751426 :     bool                bInvalidate = false;
     142    10751426 :     const SfxItemState  eNewState   = rNewAttrs.GetItemState( nWhich );
     143    10751426 :     const SfxItemState  eOldState   = rOldAttrs.GetItemState( nWhich );
     144             : 
     145    10751426 :     if ( eNewState == eOldState )
     146             :     {
     147             :         // Both Items set
     148             :         // PoolItems, meaning comparing pointers is valid
     149    10701352 :         if ( SfxItemState::SET == eOldState )
     150     1029832 :             bInvalidate = (&rNewAttrs.Get( nWhich ) != &rOldAttrs.Get( nWhich ));
     151             :     }
     152             :     else
     153             :     {
     154             :         // Contains a Default Item
     155             :         // PoolItems, meaning Item comparison necessary
     156             :         const SfxPoolItem& rOldItem = ( SfxItemState::SET == eOldState )
     157        3026 :                     ? rOldAttrs.Get( nWhich )
     158       53100 :                     : rOldAttrs.GetPool()->GetDefaultItem( nWhich );
     159             : 
     160             :         const SfxPoolItem& rNewItem = ( SfxItemState::SET == eNewState )
     161       47048 :                     ? rNewAttrs.Get( nWhich )
     162       97122 :                     : rNewAttrs.GetPool()->GetDefaultItem( nWhich );
     163             : 
     164       50074 :         bInvalidate = rNewItem != rOldItem;
     165             :     }
     166             : 
     167    10751426 :     return bInvalidate;
     168             : }
     169             : 
     170        2361 : sal_uLong ScGlobal::GetStandardFormat( SvNumberFormatter& rFormatter,
     171             :         sal_uLong nFormat, short nType )
     172             : {
     173        2361 :     const SvNumberformat* pFormat = rFormatter.GetEntry( nFormat );
     174        2361 :     if ( pFormat )
     175        2361 :         return rFormatter.GetStandardFormat( nFormat, nType, pFormat->GetLanguage() );
     176           0 :     return rFormatter.GetStandardFormat( nType, eLnge );
     177             : }
     178             : 
     179           4 : sal_uInt16 ScGlobal::GetStandardRowHeight()
     180             : {
     181           4 :     return nStdRowHeight;
     182             : }
     183             : 
     184          88 : SvNumberFormatter* ScGlobal::GetEnglishFormatter()
     185             : {
     186          88 :     if ( !pEnglishFormatter )
     187             :     {
     188             :         pEnglishFormatter = new SvNumberFormatter(
     189           4 :             ::comphelper::getProcessComponentContext(), LANGUAGE_ENGLISH_US );
     190           4 :         pEnglishFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT );
     191             :     }
     192          88 :     return pEnglishFormatter;
     193             : }
     194             : 
     195      464448 : bool ScGlobal::CheckWidthInvalidate( bool& bNumFormatChanged,
     196             :                                      const SfxItemSet& rNewAttrs,
     197             :                                      const SfxItemSet& rOldAttrs )
     198             : {
     199             :     // Check whether attribute changes in rNewAttrs compared to rOldAttrs render
     200             :     // the text width at a cell invalid
     201             :     bNumFormatChanged =
     202      464448 :             HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_VALUE_FORMAT );
     203             :     return ( bNumFormatChanged
     204      460718 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_LANGUAGE_FORMAT )
     205      460718 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT )
     206      459304 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT )
     207      454318 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT )
     208      453960 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_HEIGHT )
     209      449408 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT_HEIGHT )
     210      449298 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT_HEIGHT )
     211      449212 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_WEIGHT )
     212      444774 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT_WEIGHT )
     213      444724 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT_WEIGHT )
     214      444674 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_POSTURE )
     215      444526 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CJK_FONT_POSTURE )
     216      444476 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_CTL_FONT_POSTURE )
     217      444426 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_UNDERLINE )
     218      444278 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_OVERLINE )
     219      444218 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_CROSSEDOUT )
     220      444112 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_CONTOUR )
     221      444064 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_FONT_SHADOWED )
     222      444016 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_STACKED )
     223      440524 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_ROTATE_VALUE )
     224      440486 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_ROTATE_MODE )
     225      440486 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_LINEBREAK )
     226      904706 :         || HasAttrChanged( rNewAttrs, rOldAttrs, ATTR_MARGIN )
     227      464448 :         );
     228             : }
     229             : 
     230          36 : const SvxSearchItem& ScGlobal::GetSearchItem()
     231             : {
     232          36 :     if (!pSearchItem)
     233             :     {
     234           2 :         pSearchItem = new SvxSearchItem( SID_SEARCH_ITEM );
     235           2 :         pSearchItem->SetAppFlag( SVX_SEARCHAPP_CALC );
     236             :     }
     237          36 :     return *pSearchItem;
     238             : }
     239             : 
     240          36 : void ScGlobal::SetSearchItem( const SvxSearchItem& rNew )
     241             : {
     242             :     // FIXME: An assignement operator would be nice here
     243          36 :     delete pSearchItem;
     244          36 :     pSearchItem = static_cast<SvxSearchItem*>(rNew.Clone());
     245             : 
     246          36 :     pSearchItem->SetWhich( SID_SEARCH_ITEM );
     247          36 :     pSearchItem->SetAppFlag( SVX_SEARCHAPP_CALC );
     248          36 : }
     249             : 
     250           0 : void ScGlobal::ClearAutoFormat()
     251             : {
     252           0 :     if (pAutoFormat!=NULL)
     253             :     {
     254           0 :         delete pAutoFormat;
     255           0 :         pAutoFormat=NULL;
     256             :     }
     257           0 : }
     258             : 
     259          50 : ScAutoFormat* ScGlobal::GetAutoFormat()
     260             : {
     261          50 :     return pAutoFormat;
     262             : }
     263             : 
     264         864 : ScAutoFormat* ScGlobal::GetOrCreateAutoFormat()
     265             : {
     266         864 :     if ( !pAutoFormat )
     267             :     {
     268           2 :         pAutoFormat = new ScAutoFormat;
     269           2 :         pAutoFormat->Load();
     270             :     }
     271             : 
     272         864 :     return pAutoFormat;
     273             : }
     274             : 
     275        5592 : FuncCollection* ScGlobal::GetFuncCollection()
     276             : {
     277        5592 :     if (!pFuncCollection)
     278          20 :         pFuncCollection = new FuncCollection();
     279        5592 :     return pFuncCollection;
     280             : }
     281             : 
     282        5962 : ScUnoAddInCollection* ScGlobal::GetAddInCollection()
     283             : {
     284        5962 :     if (!pAddInCollection)
     285          54 :         pAddInCollection = new ScUnoAddInCollection();
     286        5962 :     return pAddInCollection;
     287             : }
     288             : 
     289          24 : ScUserList* ScGlobal::GetUserList()
     290             : {
     291             :     // Hack: Load Cfg item at the App
     292          24 :     global_InitAppOptions();
     293             : 
     294          24 :     if (!pUserList)
     295           0 :         pUserList = new ScUserList();
     296          24 :     return pUserList;
     297             : }
     298             : 
     299          76 : void ScGlobal::SetUserList( const ScUserList* pNewList )
     300             : {
     301          76 :     if ( pNewList )
     302             :     {
     303          76 :         if ( !pUserList )
     304          76 :             pUserList = new ScUserList( *pNewList );
     305             :         else
     306           0 :             *pUserList = *pNewList;
     307             :     }
     308             :     else
     309             :     {
     310           0 :         delete pUserList;
     311           0 :         pUserList = NULL;
     312             :     }
     313          76 : }
     314             : 
     315       73770 : const OUString& ScGlobal::GetRscString( sal_uInt16 nIndex )
     316             : {
     317             :     assert( nIndex < SC_GLOBSTR_STR_COUNT);
     318       73770 :     if( !ppRscString[ nIndex ] )
     319             :     {
     320        1508 :         OpCode eOp = ocNone;
     321             :         // Map former globstr.src strings moved to compiler.src
     322        1508 :         switch (nIndex)
     323             :         {
     324             :             case STR_NULL_ERROR:
     325           0 :                 eOp = ocErrNull;
     326           0 :                 break;
     327             :             case STR_DIV_ZERO:
     328           4 :                 eOp = ocErrDivZero;
     329           4 :                 break;
     330             :             case STR_NO_VALUE:
     331           2 :                 eOp = ocErrValue;
     332           2 :                 break;
     333             :             case STR_NOREF_STR:
     334           0 :                 eOp = ocErrRef;
     335           0 :                 break;
     336             :             case STR_NO_NAME_REF:
     337           0 :                 eOp = ocErrName;
     338           0 :                 break;
     339             :             case STR_NUM_ERROR:
     340           2 :                 eOp = ocErrNum;
     341           2 :                 break;
     342             :             case STR_NV_STR:
     343           4 :                 eOp = ocErrNA;
     344           4 :                 break;
     345             :             default:
     346             :                 ;   // nothing
     347             :         }
     348        1508 :         if (eOp != ocNone)
     349          12 :             ppRscString[ nIndex ] = new OUString( ScCompiler::GetNativeSymbol( eOp));
     350             :         else
     351        1496 :             ppRscString[ nIndex ] = new OUString( SC_STRLOAD( RID_GLOBSTR, nIndex ));
     352             :     }
     353       73770 :     return *ppRscString[ nIndex ];
     354             : }
     355             : 
     356         318 : OUString ScGlobal::GetErrorString(sal_uInt16 nErrNumber)
     357             : {
     358         318 :     OUString sResStr;
     359         318 :     switch (nErrNumber)
     360             :     {
     361          52 :         case NOTAVAILABLE          : nErrNumber = STR_NV_STR; break;
     362          70 :         case errNoRef              : nErrNumber = STR_NO_REF_TABLE; break;
     363           0 :         case errNoName             : nErrNumber = STR_NO_NAME_REF; break;
     364           0 :         case errNoAddin            : nErrNumber = STR_NO_ADDIN; break;
     365           0 :         case errNoMacro            : nErrNumber = STR_NO_MACRO; break;
     366             :         case errDoubleRef          :
     367          32 :         case errNoValue            : nErrNumber = STR_NO_VALUE; break;
     368           0 :         case errNoCode             : nErrNumber = STR_NULL_ERROR; break;
     369          10 :         case errDivisionByZero     : nErrNumber = STR_DIV_ZERO; break;
     370         102 :         case errIllegalFPOperation : nErrNumber = STR_NUM_ERROR; break;
     371             : 
     372          52 :         default          : sResStr = GetRscString(STR_ERROR_STR) + OUString::number( nErrNumber );
     373          52 :                            nErrNumber = 0;
     374          52 :                            break;
     375             :     }
     376         318 :     if( nErrNumber )
     377         266 :         sResStr = GetRscString( nErrNumber );
     378         318 :     return sResStr;
     379             : }
     380             : 
     381           0 : OUString ScGlobal::GetLongErrorString(sal_uInt16 nErrNumber)
     382             : {
     383           0 :     switch (nErrNumber)
     384             :     {
     385             :         case 0:
     386           0 :             break;
     387             :         case 1:
     388             :         case errIllegalArgument:
     389           0 :             nErrNumber = STR_LONG_ERR_ILL_ARG;
     390           0 :         break;
     391             :         case 2:
     392             :         case 3:
     393             :         case 4:
     394             :         case 5:
     395             :         case errIllegalFPOperation:
     396           0 :             nErrNumber = STR_LONG_ERR_ILL_FPO;
     397           0 :         break;
     398             :         case errIllegalChar:
     399           0 :             nErrNumber = STR_LONG_ERR_ILL_CHAR;
     400           0 :         break;
     401             :         case errIllegalParameter:
     402           0 :             nErrNumber = STR_LONG_ERR_ILL_PAR;
     403           0 :         break;
     404             :         case errSeparator:
     405           0 :             nErrNumber = STR_LONG_ERR_ILL_SEP;
     406           0 :         break;
     407             :         case errPair:
     408             :         case errPairExpected:
     409           0 :             nErrNumber = STR_LONG_ERR_PAIR;
     410           0 :         break;
     411             :         case errOperatorExpected:
     412           0 :             nErrNumber = STR_LONG_ERR_OP_EXP;
     413           0 :         break;
     414             :         case errVariableExpected:
     415             :         case errParameterExpected:
     416           0 :             nErrNumber = STR_LONG_ERR_VAR_EXP;
     417           0 :         break;
     418             :         case errCodeOverflow:
     419           0 :             nErrNumber = STR_LONG_ERR_CODE_OVF;
     420           0 :         break;
     421             :         case errStringOverflow:
     422           0 :             nErrNumber = STR_LONG_ERR_STR_OVF;
     423           0 :         break;
     424             :         case errStackOverflow:
     425             :         case errInterpOverflow:
     426           0 :             nErrNumber = STR_LONG_ERR_STACK_OVF;
     427           0 :         break;
     428             :         case errIllegalJump:
     429             :         case errUnknownState:
     430             :         case errUnknownVariable:
     431             :         case errUnknownOpCode:
     432             :         case errUnknownStackVariable:
     433             :         case errUnknownToken:
     434             :         case errNoCode:
     435             :         case errDoubleRef:
     436           0 :             nErrNumber = STR_LONG_ERR_SYNTAX;
     437           0 :         break;
     438             :         case errCircularReference:
     439           0 :             nErrNumber = STR_LONG_ERR_CIRC_REF;
     440           0 :         break;
     441             :         case errNoConvergence:
     442           0 :             nErrNumber = STR_LONG_ERR_NO_CONV;
     443           0 :         break;
     444             :         case errNoRef:
     445           0 :             nErrNumber = STR_LONG_ERR_NO_REF;
     446           0 :         break;
     447             :         case errNoName:
     448           0 :             nErrNumber = STR_LONG_ERR_NO_NAME;
     449           0 :         break;
     450             :         case errNoAddin:
     451           0 :             nErrNumber = STR_LONG_ERR_NO_ADDIN;
     452           0 :         break;
     453             :         case errNoMacro:
     454           0 :             nErrNumber = STR_LONG_ERR_NO_MACRO;
     455           0 :         break;
     456             :         case errDivisionByZero:
     457           0 :             nErrNumber = STR_LONG_ERR_DIV_ZERO;
     458           0 :         break;
     459             :         case errNestedArray:
     460           0 :             nErrNumber = STR_ERR_LONG_NESTED_ARRAY;
     461           0 :         break;
     462             :         case errNoValue:
     463           0 :             nErrNumber = STR_LONG_ERR_NO_VALUE;
     464           0 :         break;
     465             :         case NOTAVAILABLE:
     466           0 :             nErrNumber = STR_LONG_ERR_NV;
     467           0 :         break;
     468             :         default:
     469           0 :             nErrNumber = STR_ERROR_STR;
     470           0 :         break;
     471             :     }
     472           0 :     OUString aRes( GetRscString( nErrNumber ) );
     473           0 :     return aRes;
     474             : }
     475             : 
     476           0 : SvxBrushItem* ScGlobal::GetButtonBrushItem()
     477             : {
     478           0 :     pButtonBrushItem->SetColor( Application::GetSettings().GetStyleSettings().GetFaceColor() );
     479           0 :     return pButtonBrushItem;
     480             : }
     481             : 
     482      147650 : const OUString& ScGlobal::GetEmptyOUString()
     483             : {
     484      147650 :     return *pEmptyOUString;
     485             : }
     486             : 
     487          14 : ImageList* ScGlobal::GetOutlineSymbols()
     488             : {
     489          14 :     ImageList*& rpImageList = pOutlineBitmaps;
     490          14 :     if( !rpImageList )
     491           6 :         rpImageList = new ImageList( ScResId( RID_OUTLINEBITMAPS ) );
     492          14 :     return rpImageList;
     493             : }
     494             : 
     495          76 : void ScGlobal::Init()
     496             : {
     497          76 :     pEmptyOUString = new OUString;
     498             : 
     499             :     // The default language for number formats (ScGlobal::eLnge) must
     500             :     // always be LANGUAGE_SYSTEM
     501             :     // FIXME: So remove this variable?
     502          76 :     eLnge = LANGUAGE_SYSTEM;
     503             : 
     504             :     // FIXME: If the sort-order etc. should depend the installed Office version
     505             :     //        use Application::GetSettings().GetUILanguage() here
     506          76 :     pSysLocale = new SvtSysLocale;
     507          76 :     pCharClass = pSysLocale->GetCharClassPtr();
     508          76 :     pLocaleData = pSysLocale->GetLocaleDataPtr();
     509             : 
     510          76 :     ppRscString = new OUString *[ SC_GLOBSTR_STR_COUNT ];
     511          76 :     for( sal_uInt16 nC = 0 ; nC < SC_GLOBSTR_STR_COUNT ; nC++ ) ppRscString[ nC ] = NULL;
     512             : 
     513          76 :     pEmptyBrushItem = new SvxBrushItem( Color( COL_TRANSPARENT ), ATTR_BACKGROUND );
     514          76 :     pButtonBrushItem = new SvxBrushItem( Color(), ATTR_BACKGROUND );
     515          76 :     pEmbeddedBrushItem = new SvxBrushItem( Color( COL_LIGHTCYAN ), ATTR_BACKGROUND );
     516          76 :     pProtectedBrushItem = new SvxBrushItem( Color( COL_LIGHTGRAY ), ATTR_BACKGROUND );
     517             : 
     518          76 :     UpdatePPT(NULL);
     519             :     //ScCompiler::InitSymbolsNative();
     520             :     // ScParameterClassification _after_ Compiler, needs function resources if
     521             :     // arguments are to be merged in, which in turn need strings of function
     522             :     // names from the compiler.
     523          76 :     ScParameterClassification::Init();
     524             : 
     525          76 :     InitAddIns();
     526             : 
     527          76 :     pStrClipDocName = new OUString( ScResId( SCSTR_NONAME ) );
     528          76 :     *pStrClipDocName += "1";
     529             : 
     530             :     //  ScDocumentPool::InitVersionMaps() has been called earlier already
     531          76 : }
     532             : 
     533         116 : void ScGlobal::UpdatePPT( OutputDevice* pDev )
     534             : {
     535         116 :     sal_uInt16 nCurrentZoom = Application::GetSettings().GetStyleSettings().GetScreenZoom();
     536         116 :     if ( nCurrentZoom != nPPTZoom )
     537             :     {
     538             :         // Screen PPT values must be updated when ScreenZoom has changed.
     539             :         // If called from Window::DataChanged, the window is passed as pDev,
     540             :         // to make sure LogicToPixel uses a device which already uses the new zoom.
     541             :         // For the initial settings, NULL is passed and GetDefaultDevice used.
     542             : 
     543          76 :         if ( !pDev )
     544          76 :             pDev = Application::GetDefaultDevice();
     545          76 :         Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
     546          76 :         nScreenPPTX = aPix1000.X() / 1000.0;
     547          76 :         nScreenPPTY = aPix1000.Y() / 1000.0;
     548          76 :         nPPTZoom = nCurrentZoom;
     549             :     }
     550         116 : }
     551             : 
     552           0 : const OUString& ScGlobal::GetClipDocName()
     553             : {
     554           0 :     return *pStrClipDocName;
     555             : }
     556             : 
     557          22 : void ScGlobal::SetClipDocName( const OUString& rNew )
     558             : {
     559          22 :     *pStrClipDocName = rNew;
     560          22 : }
     561             : 
     562          76 : void ScGlobal::InitTextHeight(SfxItemPool* pPool)
     563             : {
     564          76 :     if (!pPool)
     565             :     {
     566             :         OSL_FAIL("ScGlobal::InitTextHeight: No Pool");
     567           0 :         return;
     568             :     }
     569             : 
     570          76 :     const ScPatternAttr* pPattern = static_cast<const ScPatternAttr*>(&pPool->GetDefaultItem(ATTR_PATTERN));
     571          76 :     if (!pPattern)
     572             :     {
     573             :         OSL_FAIL("ScGlobal::InitTextHeight: No default pattern");
     574           0 :         return;
     575             :     }
     576             : 
     577          76 :     OutputDevice* pDefaultDev = Application::GetDefaultDevice();
     578          76 :     VirtualDevice aVirtWindow( *pDefaultDev );
     579          76 :     aVirtWindow.SetMapMode(MAP_PIXEL);
     580         152 :     vcl::Font aDefFont;
     581          76 :     pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow); // Font color doesn't matter here
     582          76 :     aVirtWindow.SetFont(aDefFont);
     583             :     sal_uInt16 nTest = static_cast<sal_uInt16>(
     584          76 :         aVirtWindow.PixelToLogic(Size(0, aVirtWindow.GetTextHeight()), MAP_TWIP).Height());
     585             : 
     586          76 :     if (nTest > nDefFontHeight)
     587           0 :         nDefFontHeight = nTest;
     588             : 
     589          76 :     const SvxMarginItem* pMargin = static_cast<const SvxMarginItem*>(&pPattern->GetItem(ATTR_MARGIN));
     590             : 
     591             :     nTest = static_cast<sal_uInt16>(
     592          76 :         nDefFontHeight + pMargin->GetTopMargin() + pMargin->GetBottomMargin() - STD_ROWHEIGHT_DIFF);
     593             : 
     594          76 :     if (nTest > nStdRowHeight)
     595          76 :         nStdRowHeight = nTest;
     596             : }
     597             : 
     598          20 : void ScGlobal::Clear()
     599             : {
     600             :     // Destroy asyncs _before_ ExitExternalFunc!
     601          20 :     for( ScAddInAsyncs::iterator it = theAddInAsyncTbl.begin(); it != theAddInAsyncTbl.end(); ++it )
     602             :     {
     603           0 :         delete *it;
     604             :     }
     605          20 :     theAddInAsyncTbl.clear();
     606          20 :     ExitExternalFunc();
     607          20 :     DELETEZ(pAutoFormat);
     608          20 :     DELETEZ(pSearchItem);
     609          20 :     DELETEZ(pFuncCollection);
     610          20 :     DELETEZ(pAddInCollection);
     611          20 :     DELETEZ(pUserList);
     612             : 
     613       10680 :     for( sal_uInt16 nC = 0 ; nC < SC_GLOBSTR_STR_COUNT ; nC++ )
     614       10660 :         if( ppRscString ) delete ppRscString[ nC ];
     615          20 :     delete[] ppRscString;
     616          20 :     ppRscString = NULL;
     617             : 
     618          20 :     DELETEZ(pStarCalcFunctionList); // Destroy before ResMgr!
     619          20 :     DELETEZ(pStarCalcFunctionMgr);
     620          20 :     ScParameterClassification::Exit();
     621          20 :     ScCompiler::DeInit();
     622          20 :     ScInterpreter::GlobalExit(); // Delete static Stack
     623             : 
     624          20 :     DELETEZ(pEmptyBrushItem);
     625          20 :     DELETEZ(pButtonBrushItem);
     626          20 :     DELETEZ(pEmbeddedBrushItem);
     627          20 :     DELETEZ(pProtectedBrushItem);
     628          20 :     DELETEZ(pOutlineBitmaps);
     629          20 :     DELETEZ(pEnglishFormatter);
     630          20 :     DELETEZ(pCaseTransliteration);
     631          20 :     DELETEZ(pTransliteration);
     632          20 :     DELETEZ(pCaseCollator);
     633          20 :     DELETEZ(pCollator);
     634          20 :     DELETEZ(pCalendar);
     635             :     //! do NOT delete pCharClass since it is a pointer to the single SvtSysLocale instance
     636          20 :     pCharClass = NULL;
     637             :     //! do NOT delete pLocaleData since it is a pointer to the single SvtSysLocale instance
     638          20 :     pLocaleData = NULL;
     639          20 :     DELETEZ(pSysLocale);
     640          20 :     DELETEZ(pLocale);
     641          20 :     DELETEZ(pScIntlWrapper);
     642          20 :     DELETEZ(pStrClipDocName);
     643             : 
     644          20 :     DELETEZ(pUnitConverter);
     645          20 :     DELETEZ(pFieldEditEngine);
     646             : 
     647          20 :     ScDocumentPool::DeleteVersionMaps();
     648             : 
     649          20 :     DELETEZ(pEmptyOUString);
     650          20 : }
     651             : 
     652          12 : rtl_TextEncoding ScGlobal::GetCharsetValue( const OUString& rCharSet )
     653             : {
     654             :     // new TextEncoding values
     655          12 :     if ( CharClass::isAsciiNumeric( rCharSet ) )
     656             :     {
     657           0 :         sal_Int32 nVal = rCharSet.toInt32();
     658           0 :         if ( !nVal || nVal == RTL_TEXTENCODING_DONTKNOW )
     659           0 :             return osl_getThreadTextEncoding();
     660           0 :         return (rtl_TextEncoding) nVal;
     661             :     }
     662             :     // old CharSet values for compatibility
     663          12 :     else if (rCharSet.equalsIgnoreAsciiCase("ANSI")     ) return RTL_TEXTENCODING_MS_1252;
     664          10 :     else if (rCharSet.equalsIgnoreAsciiCase("MAC")      ) return RTL_TEXTENCODING_APPLE_ROMAN;
     665          10 :     else if (rCharSet.equalsIgnoreAsciiCase("IBMPC")    ) return RTL_TEXTENCODING_IBM_850;
     666          10 :     else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_437")) return RTL_TEXTENCODING_IBM_437;
     667           2 :     else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_850")) return RTL_TEXTENCODING_IBM_850;
     668           0 :     else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_860")) return RTL_TEXTENCODING_IBM_860;
     669           0 :     else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_861")) return RTL_TEXTENCODING_IBM_861;
     670           0 :     else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_863")) return RTL_TEXTENCODING_IBM_863;
     671           0 :     else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_865")) return RTL_TEXTENCODING_IBM_865;
     672           0 :     else return osl_getThreadTextEncoding();
     673             : }
     674             : 
     675          12 : OUString ScGlobal::GetCharsetString( rtl_TextEncoding eVal )
     676             : {
     677             :     const sal_Char* pChar;
     678          12 :     switch ( eVal )
     679             :     {
     680             :         // old CharSet strings for compatibility
     681           2 :         case RTL_TEXTENCODING_MS_1252:      pChar = "ANSI";         break;
     682           0 :         case RTL_TEXTENCODING_APPLE_ROMAN:  pChar = "MAC";          break;
     683             :         // IBMPC == IBMPC_850
     684           8 :         case RTL_TEXTENCODING_IBM_437:      pChar = "IBMPC_437";    break;
     685           2 :         case RTL_TEXTENCODING_IBM_850:      pChar = "IBMPC_850";    break;
     686           0 :         case RTL_TEXTENCODING_IBM_860:      pChar = "IBMPC_860";    break;
     687           0 :         case RTL_TEXTENCODING_IBM_861:      pChar = "IBMPC_861";    break;
     688           0 :         case RTL_TEXTENCODING_IBM_863:      pChar = "IBMPC_863";    break;
     689           0 :         case RTL_TEXTENCODING_IBM_865:      pChar = "IBMPC_865";    break;
     690           0 :         case RTL_TEXTENCODING_DONTKNOW:     pChar = "SYSTEM";       break;
     691             :         // new string of TextEncoding value
     692             :         default:
     693           0 :             return OUString::number( eVal );
     694             :     }
     695          12 :     return OUString::createFromAscii(pChar);
     696             : }
     697             : 
     698           0 : bool ScGlobal::HasStarCalcFunctionList()
     699             : {
     700           0 :     return ( pStarCalcFunctionList != NULL );
     701             : }
     702             : 
     703        1940 : ScFunctionList* ScGlobal::GetStarCalcFunctionList()
     704             : {
     705        1940 :     if ( !pStarCalcFunctionList )
     706           4 :         pStarCalcFunctionList = new ScFunctionList;
     707             : 
     708        1940 :     return pStarCalcFunctionList;
     709             : }
     710             : 
     711           2 : ScFunctionMgr* ScGlobal::GetStarCalcFunctionMgr()
     712             : {
     713           2 :     if ( !pStarCalcFunctionMgr )
     714           2 :         pStarCalcFunctionMgr = new ScFunctionMgr;
     715             : 
     716           2 :     return pStarCalcFunctionMgr;
     717             : }
     718             : 
     719          70 : void ScGlobal::ResetFunctionList()
     720             : {
     721             :     // FunctionMgr has pointers into FunctionList, must also be updated
     722          70 :     DELETEZ( pStarCalcFunctionMgr );
     723          70 :     DELETEZ( pStarCalcFunctionList );
     724          70 : }
     725             : 
     726           0 : ScUnitConverter* ScGlobal::GetUnitConverter()
     727             : {
     728           0 :     if ( !pUnitConverter )
     729           0 :         pUnitConverter = new ScUnitConverter;
     730             : 
     731           0 :     return pUnitConverter;
     732             : }
     733             : 
     734        5302 : const sal_Unicode* ScGlobal::UnicodeStrChr( const sal_Unicode* pStr,
     735             :             sal_Unicode c )
     736             : {
     737        5302 :     if ( !pStr )
     738           0 :         return NULL;
     739       17480 :     while ( *pStr )
     740             :     {
     741        8240 :         if ( *pStr == c )
     742        1364 :             return pStr;
     743        6876 :         pStr++;
     744             :     }
     745        3938 :     return NULL;
     746             : }
     747             : 
     748         184 : OUString ScGlobal::addToken(const OUString& rTokenList, const OUString& rToken,
     749             :     sal_Unicode cSep, sal_Int32 nSepCount, bool bForceSep)
     750             : {
     751         184 :     OUStringBuffer aBuf(rTokenList);
     752         184 :     if( bForceSep || (!rToken.isEmpty() && !rTokenList.isEmpty()) )
     753           0 :         comphelper::string::padToLength(aBuf, aBuf.getLength() + nSepCount, cSep);
     754         184 :     aBuf.append(rToken);
     755         184 :     return aBuf.makeStringAndClear();
     756             : }
     757             : 
     758           0 : bool ScGlobal::IsQuoted( const OUString& rString, sal_Unicode cQuote )
     759             : {
     760           0 :     return (rString.getLength() >= 2) && (rString[0] == cQuote) && (rString[ rString.getLength() - 1 ] == cQuote);
     761             : }
     762             : 
     763           0 : void ScGlobal::AddQuotes( OUString& rString, sal_Unicode cQuote, bool bEscapeEmbedded )
     764             : {
     765           0 :     if (bEscapeEmbedded)
     766             :     {
     767             :         sal_Unicode pQ[3];
     768           0 :         pQ[0] = pQ[1] = cQuote;
     769           0 :         pQ[2] = 0;
     770           0 :         OUString aQuotes( pQ );
     771           0 :         rString = rString.replaceAll( OUString(cQuote), aQuotes);
     772             :     }
     773           0 :     rString = OUString( cQuote ) + rString + OUString( cQuote );
     774           0 : }
     775             : 
     776           0 : void ScGlobal::EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescapeEmbedded )
     777             : {
     778           0 :     if ( IsQuoted( rString, cQuote ) )
     779             :     {
     780           0 :         rString = rString.copy( 1, rString.getLength() - 2 );
     781           0 :         if (bUnescapeEmbedded)
     782             :         {
     783             :             sal_Unicode pQ[3];
     784           0 :             pQ[0] = pQ[1] = cQuote;
     785           0 :             pQ[2] = 0;
     786           0 :             OUString aQuotes( pQ );
     787           0 :             rString = rString.replaceAll( aQuotes, OUString(cQuote));
     788             :         }
     789             :     }
     790           0 : }
     791             : 
     792       13508 : sal_Int32 ScGlobal::FindUnquoted( const OUString& rString, sal_Unicode cChar)
     793             : {
     794       13508 :     const sal_Unicode cQuote = '\'';
     795       13508 :     const sal_Unicode* const pStart = rString.getStr();
     796       13508 :     const sal_Unicode* const pStop = pStart + rString.getLength();
     797       13508 :     const sal_Unicode* p = pStart;
     798       13508 :     bool bQuoted = false;
     799       87722 :     while (p < pStop)
     800             :     {
     801       65470 :         if (*p == cChar && !bQuoted)
     802        4764 :             return sal::static_int_cast< sal_Int32 >( p - pStart );
     803       60706 :         else if (*p == cQuote)
     804             :         {
     805         388 :             if (!bQuoted)
     806         194 :                 bQuoted = true;
     807         194 :             else if (p < pStop-1 && *(p+1) == cQuote)
     808           0 :                 ++p;
     809             :             else
     810         194 :                 bQuoted = false;
     811             :         }
     812       60706 :         ++p;
     813             :     }
     814        8744 :     return -1;
     815             : }
     816             : 
     817       17660 : const sal_Unicode* ScGlobal::FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar, sal_Unicode cQuote )
     818             : {
     819       17660 :     const sal_Unicode* p = pString;
     820       17660 :     bool bQuoted = false;
     821      140588 :     while (*p)
     822             :     {
     823      115998 :         if (*p == cChar && !bQuoted)
     824       10730 :             return p;
     825      105268 :         else if (*p == cQuote)
     826             :         {
     827        1452 :             if (!bQuoted)
     828         718 :                 bQuoted = true;
     829         734 :             else if (*(p+1) == cQuote)
     830          16 :                 ++p;
     831             :             else
     832         718 :                 bQuoted = false;
     833             :         }
     834      105268 :         ++p;
     835             :     }
     836        6930 :     return NULL;
     837             : }
     838             : 
     839       24039 : bool ScGlobal::EETextObjEqual( const EditTextObject* pObj1,
     840             :                                const EditTextObject* pObj2 )
     841             : {
     842       24039 :     if ( pObj1 == pObj2 ) // Both empty or the same object
     843        2799 :         return true;
     844             : 
     845       21240 :     if ( pObj1 && pObj2 )
     846             :     {
     847             :         // First test for equal text content
     848        9466 :         sal_Int32 nParCount = pObj1->GetParagraphCount();
     849        9466 :         if ( nParCount != pObj2->GetParagraphCount() )
     850        9292 :             return false;
     851       14810 :         for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
     852        9434 :             if ( pObj1->GetText(nPar) != pObj2->GetText(nPar) )
     853        4046 :                 return false;
     854             : 
     855        5376 :         SvMemoryStream  aStream1;
     856        5594 :         SvMemoryStream  aStream2;
     857        5376 :         pObj1->Store( aStream1 );
     858        5376 :         pObj2->Store( aStream2 );
     859        5376 :         sal_uLong nSize = aStream1.Tell();
     860        5376 :         if ( aStream2.Tell() == nSize )
     861        5158 :             if ( !memcmp( aStream1.GetData(), aStream2.GetData(), (sal_uInt16) nSize ) )
     862        5376 :                 return true;
     863             :     }
     864             : 
     865       11992 :     return false;
     866             : }
     867             : 
     868           0 : void ScGlobal::OpenURL( const OUString& rURL, const OUString& rTarget )
     869             : {
     870             :     // OpenURL is always called in the GridWindow by mouse clicks in some way or another.
     871             :     // That's why pScActiveViewShell and nScClickMouseModifier are correct.
     872             :     // SvtSecurityOptions to access Libreoffice global security parameters
     873           0 :     SvtSecurityOptions aSecOpt;
     874           0 :     bool bCtrlClickHappened = (nScClickMouseModifier & KEY_MOD1);
     875           0 :     bool bCtrlClickSecOption = aSecOpt.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
     876           0 :     if( bCtrlClickHappened && !( bCtrlClickSecOption ) )
     877             :     {
     878             :         // return since ctrl+click happened when the
     879             :         // ctrl+click security option was disabled, link should not open
     880           0 :         return;
     881             :     }
     882           0 :     else if( !( bCtrlClickHappened ) && bCtrlClickSecOption )
     883             :     {
     884             :         // ctrl+click did not happen; only click happened maybe with some
     885             :         // other key combo. and security option is set, so return
     886           0 :         return;
     887             :     }
     888           0 :     SfxStringItem aUrl( SID_FILE_NAME, rURL );
     889           0 :     SfxStringItem aTarget( SID_TARGETNAME, rTarget );
     890           0 :     aTarget.SetValue(OUString("_blank"));
     891           0 :     SfxViewFrame* pFrame = NULL;
     892           0 :     OUString aReferName;
     893           0 :     if ( pScActiveViewShell )
     894             :     {
     895           0 :         pFrame = pScActiveViewShell->GetViewFrame();
     896           0 :         SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium();
     897           0 :         if (pMed)
     898           0 :             aReferName = pMed->GetName();
     899             :     }
     900             : 
     901           0 :     SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
     902           0 :     SfxStringItem aReferer( SID_REFERER, aReferName );
     903             : 
     904           0 :     SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, false );
     905           0 :     SfxBoolItem aBrowsing( SID_BROWSE, true );
     906             : 
     907             :     // No SID_SILENT anymore
     908           0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     909           0 :     if (pViewFrm)
     910             :         pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
     911             :                                     SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
     912             :                                     &aUrl, &aTarget,
     913             :                                     &aFrm, &aReferer,
     914             :                                     &aNewView, &aBrowsing,
     915           0 :                                     0L );
     916             : }
     917             : 
     918        3932 : bool ScGlobal::IsSystemRTL()
     919             : {
     920        3932 :     return MsLangId::isRightToLeft( Application::GetSettings().GetLanguageTag().getLanguageType() );
     921             : }
     922             : 
     923     2588717 : sal_uInt8 ScGlobal::GetDefaultScriptType()
     924             : {
     925             :     // Used when text contains only WEAK characters.
     926             :     // Script type of office language is used then (same as GetEditDefaultLanguage,
     927             :     // to get consistent behavior of text in simple cells and EditEngine,
     928             :     // also same as GetAppLanguage() in Writer)
     929     2588717 :     return (sal_uInt8) SvtLanguageOptions::GetScriptTypeOfLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
     930             : }
     931             : 
     932       16993 : LanguageType ScGlobal::GetEditDefaultLanguage()
     933             : {
     934             :     // Used for EditEngine::SetDefaultLanguage
     935       16993 :     return Application::GetSettings().GetLanguageTag().getLanguageType();
     936             : }
     937             : 
     938         612 : sal_uInt16 ScGlobal::GetScriptedWhichID( sal_uInt8 nScriptType, sal_uInt16 nWhich )
     939             : {
     940         612 :     switch ( nScriptType )
     941             :     {
     942             :         case SCRIPTTYPE_LATIN:
     943             :         case SCRIPTTYPE_ASIAN:
     944             :         case SCRIPTTYPE_COMPLEX:
     945         612 :         break;      // take exact matches
     946             :         default:    // prefer one, first COMPLEX, then ASIAN
     947           0 :             if ( nScriptType & SCRIPTTYPE_COMPLEX )
     948           0 :                 nScriptType = SCRIPTTYPE_COMPLEX;
     949           0 :             else if ( nScriptType & SCRIPTTYPE_ASIAN )
     950           0 :                 nScriptType = SCRIPTTYPE_ASIAN;
     951             :     }
     952         612 :     switch ( nScriptType )
     953             :     {
     954             :         case SCRIPTTYPE_COMPLEX:
     955             :         {
     956           0 :             switch ( nWhich )
     957             :             {
     958             :                 case ATTR_FONT:
     959             :                 case ATTR_CJK_FONT:
     960           0 :                     nWhich = ATTR_CTL_FONT;
     961           0 :                 break;
     962             :                 case ATTR_FONT_HEIGHT:
     963             :                 case ATTR_CJK_FONT_HEIGHT:
     964           0 :                     nWhich = ATTR_CTL_FONT_HEIGHT;
     965           0 :                 break;
     966             :                 case ATTR_FONT_WEIGHT:
     967             :                 case ATTR_CJK_FONT_WEIGHT:
     968           0 :                     nWhich = ATTR_CTL_FONT_WEIGHT;
     969           0 :                 break;
     970             :                 case ATTR_FONT_POSTURE:
     971             :                 case ATTR_CJK_FONT_POSTURE:
     972           0 :                     nWhich = ATTR_CTL_FONT_POSTURE;
     973           0 :                 break;
     974             :             }
     975             :         }
     976           0 :         break;
     977             :         case SCRIPTTYPE_ASIAN:
     978             :         {
     979           0 :             switch ( nWhich )
     980             :             {
     981             :                 case ATTR_FONT:
     982             :                 case ATTR_CTL_FONT:
     983           0 :                     nWhich = ATTR_CJK_FONT;
     984           0 :                 break;
     985             :                 case ATTR_FONT_HEIGHT:
     986             :                 case ATTR_CTL_FONT_HEIGHT:
     987           0 :                     nWhich = ATTR_CJK_FONT_HEIGHT;
     988           0 :                 break;
     989             :                 case ATTR_FONT_WEIGHT:
     990             :                 case ATTR_CTL_FONT_WEIGHT:
     991           0 :                     nWhich = ATTR_CJK_FONT_WEIGHT;
     992           0 :                 break;
     993             :                 case ATTR_FONT_POSTURE:
     994             :                 case ATTR_CTL_FONT_POSTURE:
     995           0 :                     nWhich = ATTR_CJK_FONT_POSTURE;
     996           0 :                 break;
     997             :             }
     998             :         }
     999           0 :         break;
    1000             :         default:
    1001             :         {
    1002         612 :             switch ( nWhich )
    1003             :             {
    1004             :                 case ATTR_CTL_FONT:
    1005             :                 case ATTR_CJK_FONT:
    1006           0 :                     nWhich = ATTR_FONT;
    1007           0 :                 break;
    1008             :                 case ATTR_CTL_FONT_HEIGHT:
    1009             :                 case ATTR_CJK_FONT_HEIGHT:
    1010           0 :                     nWhich = ATTR_FONT_HEIGHT;
    1011           0 :                 break;
    1012             :                 case ATTR_CTL_FONT_WEIGHT:
    1013             :                 case ATTR_CJK_FONT_WEIGHT:
    1014           0 :                     nWhich = ATTR_FONT_WEIGHT;
    1015           0 :                 break;
    1016             :                 case ATTR_CTL_FONT_POSTURE:
    1017             :                 case ATTR_CJK_FONT_POSTURE:
    1018           0 :                     nWhich = ATTR_FONT_POSTURE;
    1019           0 :                 break;
    1020             :             }
    1021             :         }
    1022             :     }
    1023         612 :     return nWhich;
    1024             : }
    1025             : 
    1026        1348 : void ScGlobal::AddLanguage( SfxItemSet& rSet, SvNumberFormatter& rFormatter )
    1027             : {
    1028             :     OSL_ENSURE( rSet.GetItemState( ATTR_LANGUAGE_FORMAT, false ) == SfxItemState::DEFAULT,
    1029             :         "ScGlobal::AddLanguage - language already added");
    1030             : 
    1031             :     const SfxPoolItem* pHardItem;
    1032        1348 :     if ( rSet.GetItemState( ATTR_VALUE_FORMAT, false, &pHardItem ) == SfxItemState::SET )
    1033             :     {
    1034             :         const SvNumberformat* pHardFormat = rFormatter.GetEntry(
    1035        1348 :             static_cast<const SfxUInt32Item*>(pHardItem)->GetValue() );
    1036             : 
    1037        1348 :         sal_uLong nParentFmt = 0; // Pool default
    1038        1348 :         const SfxItemSet* pParent = rSet.GetParent();
    1039        1348 :         if ( pParent )
    1040          56 :             nParentFmt = static_cast<const SfxUInt32Item&>(pParent->Get( ATTR_VALUE_FORMAT )).GetValue();
    1041        1348 :         const SvNumberformat* pParFormat = rFormatter.GetEntry( nParentFmt );
    1042             : 
    1043        2696 :         if ( pHardFormat && pParFormat &&
    1044        1348 :                 (pHardFormat->GetLanguage() != pParFormat->GetLanguage()) )
    1045          64 :             rSet.Put( SvxLanguageItem( pHardFormat->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
    1046             :     }
    1047        1348 : }
    1048             : 
    1049        6892 : utl::TransliterationWrapper* ScGlobal::GetpTransliteration()
    1050             : {
    1051        6892 :     if ( !pTransliteration )
    1052             :     {
    1053          44 :         const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
    1054             :         pTransliteration = new ::utl::TransliterationWrapper(
    1055          44 :             ::comphelper::getProcessComponentContext(), SC_TRANSLITERATION_IGNORECASE );
    1056          44 :         pTransliteration->loadModuleIfNeeded( eOfficeLanguage );
    1057             :     }
    1058             :     OSL_ENSURE(
    1059             :         pTransliteration,
    1060             :         "ScGlobal::GetpTransliteration() called before ScGlobal::Init()");
    1061        6892 :     return pTransliteration;
    1062             : }
    1063             : 
    1064        1255 : const LocaleDataWrapper* ScGlobal::GetpLocaleData()
    1065             : {
    1066             :     OSL_ENSURE(
    1067             :         pLocaleData,
    1068             :         "ScGlobal::GetpLocaleData() called before ScGlobal::Init()");
    1069        1255 :     return pLocaleData;
    1070             : }
    1071          64 : CalendarWrapper*     ScGlobal::GetCalendar()
    1072             : {
    1073          64 :     if ( !pCalendar )
    1074             :     {
    1075           4 :         pCalendar = new CalendarWrapper( ::comphelper::getProcessComponentContext() );
    1076           4 :         pCalendar->loadDefaultCalendar( *GetLocale() );
    1077             :     }
    1078          64 :     return pCalendar;
    1079             : }
    1080        6558 : CollatorWrapper*        ScGlobal::GetCollator()
    1081             : {
    1082        6558 :     if ( !pCollator )
    1083             :     {
    1084          22 :         pCollator = new CollatorWrapper( ::comphelper::getProcessComponentContext() );
    1085          22 :         pCollator->loadDefaultCollator( *GetLocale(), SC_COLLATOR_IGNORES );
    1086             :     }
    1087        6558 :     return pCollator;
    1088             : }
    1089        7906 : CollatorWrapper*        ScGlobal::GetCaseCollator()
    1090             : {
    1091        7906 :     if ( !pCaseCollator )
    1092             :     {
    1093           4 :         pCaseCollator = new CollatorWrapper( ::comphelper::getProcessComponentContext() );
    1094           4 :         pCaseCollator->loadDefaultCollator( *GetLocale(), 0 );
    1095             :     }
    1096        7906 :     return pCaseCollator;
    1097             : }
    1098           0 : ::utl::TransliterationWrapper* ScGlobal::GetCaseTransliteration()
    1099             : {
    1100           0 :     if ( !pCaseTransliteration )
    1101             :     {
    1102           0 :         const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
    1103           0 :         pCaseTransliteration = new ::utl::TransliterationWrapper(::comphelper::getProcessComponentContext(), SC_TRANSLITERATION_CASESENSE );
    1104           0 :         pCaseTransliteration->loadModuleIfNeeded( eOfficeLanguage );
    1105             :     }
    1106           0 :     return pCaseTransliteration;
    1107             : }
    1108           0 : IntlWrapper*         ScGlobal::GetScIntlWrapper()
    1109             : {
    1110           0 :     if ( !pScIntlWrapper )
    1111             :     {
    1112           0 :         pScIntlWrapper = new IntlWrapper( LanguageTag( *GetLocale()) );
    1113             :     }
    1114           0 :     return pScIntlWrapper;
    1115             : }
    1116         310 : ::com::sun::star::lang::Locale*     ScGlobal::GetLocale()
    1117             : {
    1118         310 :     if ( !pLocale )
    1119             :     {
    1120          70 :         pLocale = new ::com::sun::star::lang::Locale( Application::GetSettings().GetLanguageTag().getLocale());
    1121             :     }
    1122         310 :     return pLocale;
    1123             : }
    1124             : 
    1125           8 : ScFieldEditEngine& ScGlobal::GetStaticFieldEditEngine()
    1126             : {
    1127           8 :     if (!pFieldEditEngine)
    1128             :     {
    1129             :         // Creating a ScFieldEditEngine with pDocument=NULL leads to document
    1130             :         // specific fields not being resolvable! See
    1131             :         // ScFieldEditEngine::CalcFieldValue(). pEnginePool=NULL lets
    1132             :         // EditEngine internally create and delete a default pool.
    1133           2 :         pFieldEditEngine = new ScFieldEditEngine( NULL, NULL);
    1134             :     }
    1135           8 :     return *pFieldEditEngine;
    1136             : }
    1137             : 
    1138           0 : OUString ScGlobal::ReplaceOrAppend( const OUString& rString,
    1139             :         const OUString& rPlaceholder, const OUString& rReplacement )
    1140             : {
    1141           0 :     if (rString.isEmpty())
    1142           0 :         return rReplacement;
    1143           0 :     sal_Int32 nFound = rString.indexOf( rPlaceholder);
    1144           0 :     if (nFound < 0)
    1145             :     {
    1146           0 :         if (rString[rString.getLength()-1] == ' ')
    1147           0 :             return rString + rReplacement;
    1148           0 :         return rString + " " + rReplacement;
    1149             :     }
    1150           0 :     return rString.replaceFirst( rPlaceholder, rReplacement, &nFound);
    1151         228 : }
    1152             : 
    1153             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10