LCOV - code coverage report
Current view: top level - sc/source/core/data - documen2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 391 542 72.1 %
Date: 2012-08-25 Functions: 32 42 76.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 389 1028 37.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "scitems.hxx"
      30                 :            : #include <editeng/eeitem.hxx>
      31                 :            : 
      32                 :            : #include <editeng/editeng.hxx>
      33                 :            : #include <editeng/forbiddencharacterstable.hxx>
      34                 :            : #include <svx/xtable.hxx>
      35                 :            : #include <sfx2/linkmgr.hxx>
      36                 :            : #include <svx/svdpool.hxx>
      37                 :            : #include <svx/svdobj.hxx>
      38                 :            : #include <sfx2/bindings.hxx>
      39                 :            : #include <sfx2/objsh.hxx>
      40                 :            : #include <sfx2/docfile.hxx>
      41                 :            : #include <sfx2/printer.hxx>
      42                 :            : #include <svl/zforlist.hxx>
      43                 :            : #include <svl/zformat.hxx>
      44                 :            : #include <vcl/virdev.hxx>
      45                 :            : #include <comphelper/processfactory.hxx>
      46                 :            : #include <svl/PasswordHelper.hxx>
      47                 :            : #include <tools/tenccvt.hxx>
      48                 :            : #include <tools/urlobj.hxx>
      49                 :            : #include <rtl/crc.h>
      50                 :            : #include <basic/basmgr.hxx>
      51                 :            : 
      52                 :            : #include "document.hxx"
      53                 :            : #include "table.hxx"
      54                 :            : #include "attrib.hxx"
      55                 :            : #include "patattr.hxx"
      56                 :            : #include "rangenam.hxx"
      57                 :            : #include "dbdata.hxx"
      58                 :            : #include "pivot.hxx"
      59                 :            : #include "docpool.hxx"
      60                 :            : #include "stlpool.hxx"
      61                 :            : #include "stlsheet.hxx"
      62                 :            : #include "globstr.hrc"
      63                 :            : #include "chartarr.hxx"
      64                 :            : #include "chartlock.hxx"
      65                 :            : #include "rechead.hxx"
      66                 :            : #include "global.hxx"
      67                 :            : #include "brdcst.hxx"
      68                 :            : #include "bcaslot.hxx"
      69                 :            : #include "adiasync.hxx"
      70                 :            : #include "addinlis.hxx"
      71                 :            : #include "chartlis.hxx"
      72                 :            : #include "markdata.hxx"
      73                 :            : #include "conditio.hxx"
      74                 :            : #include "colorscale.hxx"
      75                 :            : #include "validat.hxx"
      76                 :            : #include "progress.hxx"
      77                 :            : #include "detdata.hxx"
      78                 :            : #include "sc.hrc"               // FID_DATACHANGED
      79                 :            : #include "ddelink.hxx"
      80                 :            : #include "chgtrack.hxx"
      81                 :            : #include "chgviset.hxx"
      82                 :            : #include "editutil.hxx"
      83                 :            : #include "hints.hxx"
      84                 :            : #include "dpobject.hxx"
      85                 :            : #include "scrdata.hxx"
      86                 :            : #include "poolhelp.hxx"
      87                 :            : #include "unoreflist.hxx"
      88                 :            : #include "listenercalls.hxx"
      89                 :            : #include "recursionhelper.hxx"
      90                 :            : #include "lookupcache.hxx"
      91                 :            : #include "externalrefmgr.hxx"
      92                 :            : #include "tabprotection.hxx"
      93                 :            : #include "formulaparserpool.hxx"
      94                 :            : #include "clipparam.hxx"
      95                 :            : #include "macromgr.hxx"
      96                 :            : 
      97                 :            : using namespace com::sun::star;
      98                 :            : 
      99                 :            : // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and
     100                 :            : // dtor plus helpers are convenient.
     101         [ +  - ]:          3 : struct ScLookupCacheMapImpl
     102                 :            : {
     103                 :            :     ScLookupCacheMap aCacheMap;
     104                 :          0 :     ~ScLookupCacheMapImpl()
     105                 :          0 :     {
     106         [ #  # ]:          0 :         freeCaches();
     107                 :          0 :     }
     108                 :         24 :     void clear()
     109                 :            :     {
     110         [ +  - ]:         24 :         freeCaches();
     111                 :            :         // Zap map.
     112         [ +  - ]:         24 :         ScLookupCacheMap aTmp;
     113 [ +  - ][ +  - ]:         24 :         aCacheMap.swap( aTmp);
     114                 :         24 :     }
     115                 :            : private:
     116                 :         24 :     void freeCaches()
     117                 :            :     {
     118 [ +  - ][ +  - ]:         24 :         for (ScLookupCacheMap::iterator it( aCacheMap.begin()); it != aCacheMap.end(); ++it)
                 [ -  + ]
     119 [ #  # ][ #  # ]:          0 :             delete (*it).second;
                 [ #  # ]
     120                 :         24 :     }
     121                 :            : };
     122                 :            : 
     123                 :            : // STATIC DATA -----------------------------------------------------------
     124                 :            : 
     125                 :       1781 : ScDocument::ScDocument( ScDocumentMode  eMode,
     126                 :            :                         SfxObjectShell* pDocShell ) :
     127                 :            :         xServiceManager( ::comphelper::getProcessServiceFactory() ),
     128                 :            :         mpUndoManager( NULL ),
     129                 :            :         pEditEngine( NULL ),
     130                 :            :         pNoteEngine( NULL ),
     131                 :            :         pShell( pDocShell ),
     132                 :            :         pPrinter( NULL ),
     133                 :            :         pVirtualDevice_100th_mm( NULL ),
     134                 :            :         pDrawLayer( NULL ),
     135                 :            :         pValidationList( NULL ),
     136                 :            :         pFormatExchangeList( NULL ),
     137                 :            :         pRangeName(NULL),
     138                 :            :         pDPCollection( NULL ),
     139                 :            :         pLinkManager( NULL ),
     140                 :            :         pFormulaTree( NULL ),
     141                 :            :         pEOFormulaTree( NULL ),
     142                 :            :         pFormulaTrack( NULL ),
     143                 :            :         pEOFormulaTrack( NULL ),
     144                 :            :         pClipData( NULL ),
     145                 :            :         pDetOpList(NULL),
     146                 :            :         pChangeTrack( NULL ),
     147                 :            :         pUnoBroadcaster( NULL ),
     148                 :            :         pUnoListenerCalls( NULL ),
     149                 :            :         pUnoRefUndoList( NULL ),
     150                 :            :         pChangeViewSettings( NULL ),
     151                 :            :         pScriptTypeData( NULL ),
     152                 :            :         pCacheFieldEditEngine( NULL ),
     153                 :            :         pDocProtection( NULL ),
     154                 :            :         mpClipParam( NULL),
     155                 :            :         pExternalRefMgr( NULL ),
     156                 :            :         mpMacroMgr( NULL ),
     157                 :            :         pViewOptions( NULL ),
     158                 :            :         pDocOptions( NULL ),
     159                 :            :         pExtDocOptions( NULL ),
     160                 :            :         pConsolidateDlgData( NULL ),
     161                 :            :         pRecursionHelper( NULL ),
     162                 :            :         pAutoNameCache( NULL ),
     163                 :            :         pLookupCacheMapImpl( NULL ),
     164                 :            :         nUnoObjectId( 0 ),
     165                 :            :         nRangeOverflowType( 0 ),
     166                 :            :         aCurTextWidthCalcPos(MAXCOL,0,0),
     167                 :            :         aTableOpList( 0 ),
     168                 :            :         nFormulaCodeInTree(0),
     169                 :            :         nXMLImportedFormulaCount( 0 ),
     170                 :            :         nInterpretLevel(0),
     171                 :            :         nMacroInterpretLevel(0),
     172                 :            :         nInterpreterTableOpLevel(0),
     173                 :            :         nSrcVer( SC_CURRENT_VERSION ),
     174                 :            :         nSrcMaxRow( MAXROW ),
     175                 :            :         nFormulaTrackCount(0),
     176                 :            :         bHardRecalcState(false),
     177                 :            :         nVisibleTab( 0 ),
     178                 :            :         eLinkMode(LM_UNKNOWN),
     179                 :            :         bAutoCalc( eMode == SCDOCMODE_DOCUMENT ),
     180                 :            :         bAutoCalcShellDisabled( false ),
     181                 :            :         bForcedFormulaPending( false ),
     182                 :            :         bCalculatingFormulaTree( false ),
     183                 :            :         bIsClip( eMode == SCDOCMODE_CLIP ),
     184                 :            :         bIsUndo( eMode == SCDOCMODE_UNDO ),
     185                 :            :         bIsVisible( false ),
     186                 :            :         bIsEmbedded( false ),
     187                 :            :         bNoSetDirty( false ),
     188                 :            :         bInsertingFromOtherDoc( false ),
     189                 :            :         bLoadingMedium( false ),
     190                 :            :         bImportingXML( false ),
     191                 :            :         bXMLFromWrapper( false ),
     192                 :            :         bCalcingAfterLoad( false ),
     193                 :            :         bNoListening( false ),
     194                 :            :         bIdleDisabled( false ),
     195                 :            :         bInLinkUpdate( false ),
     196                 :            :         bChartListenerCollectionNeedsUpdate( false ),
     197                 :            :         bHasForcedFormulas( false ),
     198                 :            :         bInDtorClear( false ),
     199                 :            :         bExpandRefs( false ),
     200                 :            :         bDetectiveDirty( false ),
     201                 :            :         nMacroCallMode( SC_MACROCALL_ALLOWED ),
     202                 :            :         bHasMacroFunc( false ),
     203                 :            :         nVisSpellState( 0 ),
     204                 :            :         nAsianCompression(SC_ASIANCOMPRESSION_INVALID),
     205                 :            :         nAsianKerning(SC_ASIANKERNING_INVALID),
     206                 :            :         bSetDrawDefaults( false ),
     207                 :            :         bPastingDrawFromOtherDoc( false ),
     208                 :            :         nInDdeLinkUpdate( 0 ),
     209                 :            :         bInUnoBroadcast( false ),
     210                 :            :         bInUnoListenerCall( false ),
     211                 :            :         eGrammar( formula::FormulaGrammar::GRAM_NATIVE ),
     212                 :            :         bStyleSheetUsageInvalid( true ),
     213                 :            :         mbUndoEnabled( true ),
     214                 :            :         mbAdjustHeightEnabled( true ),
     215                 :            :         mbExecuteLinkEnabled( true ),
     216                 :            :         mbChangeReadOnlyEnabled( false ),
     217                 :            :         mbStreamValidLocked( false ),
     218                 :            :         mnNamedRangesLockCount( 0 ),
     219 [ +  - ][ +  - ]:       1781 :         mbIsInTest( false )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     220                 :            : {
     221                 :       1781 :     SetStorageGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT);
     222                 :            : 
     223         [ +  - ]:       1781 :     eSrcSet = osl_getThreadTextEncoding();
     224                 :            : 
     225         [ +  + ]:       1781 :     if ( eMode == SCDOCMODE_DOCUMENT )
     226                 :            :     {
     227         [ +  - ]:        846 :         if ( pDocShell )
     228 [ +  - ][ +  - ]:        846 :             pLinkManager = new sfx2::LinkManager( pDocShell );
     229                 :            : 
     230 [ +  - ][ +  - ]:        846 :         xPoolHelper = new ScPoolHelper( this );
                 [ +  - ]
     231                 :            : 
     232 [ +  - ][ +  - ]:        846 :         pBASM = new ScBroadcastAreaSlotMachine( this );
     233 [ +  - ][ +  - ]:        846 :         pChartListenerCollection = new ScChartListenerCollection( this );
     234 [ +  - ][ +  - ]:        846 :         pRefreshTimerControl = new ScRefreshTimerControl;
     235                 :            :     }
     236                 :            :     else
     237                 :            :     {
     238                 :        935 :         pBASM       = NULL;
     239                 :        935 :         pChartListenerCollection = NULL;
     240                 :        935 :         pRefreshTimerControl = NULL;
     241                 :            :     }
     242 [ +  - ][ +  - ]:       1781 :     pDBCollection = new ScDBCollection(this);
     243                 :       1781 :     pSelectionAttr = NULL;
     244 [ +  - ][ +  - ]:       1781 :     pChartCollection = new ScChartCollection;
     245 [ +  - ][ +  - ]:       1781 :     apTemporaryChartLock = std::auto_ptr< ScTemporaryChartLock >( new ScTemporaryChartLock(this) );
                 [ +  - ]
     246 [ +  - ][ +  - ]:       1781 :     xColNameRanges = new ScRangePairList;
                 [ +  - ]
     247 [ +  - ][ +  - ]:       1781 :     xRowNameRanges = new ScRangePairList;
                 [ +  - ]
     248         [ +  - ]:       1781 :     ImplCreateOptions();
     249                 :            :     // languages for a visible document are set by docshell later (from options)
     250         [ +  - ]:       1781 :     SetLanguage( ScGlobal::eLnge, ScGlobal::eLnge, ScGlobal::eLnge );
     251                 :            : 
     252         [ +  - ]:       1781 :     aTrackTimer.SetTimeoutHdl( LINK( this, ScDocument, TrackTimeHdl ) );
     253         [ +  - ]:       1781 :     aTrackTimer.SetTimeout( 100 );
     254                 :       1781 : }
     255                 :            : 
     256                 :       5332 : sfx2::LinkManager*  ScDocument::GetLinkManager()  const
     257                 :            : {
     258 [ +  + ][ -  + ]:       5332 :     if ( bAutoCalc && !pLinkManager && pShell)
                 [ #  # ]
     259                 :            :     {
     260         [ #  # ]:          0 :         pLinkManager = new sfx2::LinkManager( pShell );
     261                 :            :     }
     262                 :       5332 :     return pLinkManager;
     263                 :            : }
     264                 :            : 
     265                 :            : 
     266                 :       1899 : void ScDocument::SetStorageGrammar( formula::FormulaGrammar::Grammar eGram )
     267                 :            : {
     268                 :            :     OSL_PRECOND(
     269                 :            :         eGram == formula::FormulaGrammar::GRAM_ODFF ||
     270                 :            :             eGram == formula::FormulaGrammar::GRAM_PODF,
     271                 :            :             "ScDocument::SetStorageGrammar: wrong storage grammar");
     272                 :            : 
     273                 :       1899 :     eStorageGrammar = eGram;
     274                 :            : 
     275                 :            :     // FIXME: the XML import shouldn't strip brackets, the compiler should
     276                 :            :     // digest them instead, which could also speedup reference recognition
     277                 :            :     // during import.
     278                 :            : 
     279                 :            :     eXmlImportGrammar = formula::FormulaGrammar::mergeToGrammar( eGram,
     280                 :       1899 :             formula::FormulaGrammar::CONV_OOO);
     281                 :       1899 : }
     282                 :            : 
     283                 :            : 
     284                 :        227 : void ScDocument::SetDocVisible( bool bSet )
     285                 :            : {
     286                 :            :     //  called from view ctor - only for a visible document,
     287                 :            :     //  each new sheet's RTL flag is initialized from the locale
     288                 :        227 :     bIsVisible = bSet;
     289                 :        227 : }
     290                 :            : 
     291                 :            : 
     292                 :         16 : sal_uInt32 ScDocument::GetDocumentID() const
     293                 :            : {
     294                 :         16 :     const ScDocument* pThis = this;
     295                 :         16 :     sal_uInt32 nCrc = rtl_crc32( 0, &pThis, sizeof(ScDocument*) );
     296                 :            :     // the this pointer only might not be sufficient
     297                 :         16 :     nCrc = rtl_crc32( nCrc, &pShell, sizeof(SfxObjectShell*) );
     298                 :         16 :     return nCrc;
     299                 :            : }
     300                 :            : 
     301                 :            : 
     302                 :          0 : void ScDocument::StartChangeTracking()
     303                 :            : {
     304         [ #  # ]:          0 :     if (!pChangeTrack)
     305         [ #  # ]:          0 :         pChangeTrack = new ScChangeTrack( this );
     306                 :          0 : }
     307                 :            : 
     308                 :          0 : void ScDocument::EndChangeTracking()
     309                 :            : {
     310         [ #  # ]:          0 :     delete pChangeTrack;
     311                 :          0 :     pChangeTrack = NULL;
     312                 :          0 : }
     313                 :            : 
     314                 :          0 : void ScDocument::SetChangeTrack( ScChangeTrack* pTrack )
     315                 :            : {
     316                 :            :     OSL_ENSURE( pTrack->GetDocument() == this, "SetChangeTrack: different documents" );
     317 [ #  # ][ #  # ]:          0 :     if ( !pTrack || pTrack == pChangeTrack || pTrack->GetDocument() != this )
         [ #  # ][ #  # ]
     318                 :          0 :         return ;
     319                 :          0 :     EndChangeTracking();
     320                 :          0 :     pChangeTrack = pTrack;
     321                 :            : }
     322                 :            : 
     323                 :            : 
     324                 :          0 : IMPL_LINK_NOARG(ScDocument, TrackTimeHdl)
     325                 :            : {
     326         [ #  # ]:          0 :     if ( ScDdeLink::IsInUpdate() )      // nicht verschachteln
     327                 :            :     {
     328                 :          0 :         aTrackTimer.Start();            // spaeter nochmal versuchen
     329                 :            :     }
     330         [ #  # ]:          0 :     else if (pShell)                    // ausfuehren
     331                 :            :     {
     332                 :          0 :         TrackFormulas();
     333         [ #  # ]:          0 :         pShell->Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
     334                 :            : 
     335                 :            :             //  modified...
     336                 :            : 
     337         [ #  # ]:          0 :         if (!pShell->IsModified())
     338                 :            :         {
     339                 :          0 :             pShell->SetModified( true );
     340                 :          0 :             SfxBindings* pBindings = GetViewBindings();
     341         [ #  # ]:          0 :             if (pBindings)
     342                 :            :             {
     343                 :          0 :                 pBindings->Invalidate( SID_SAVEDOC );
     344                 :          0 :                 pBindings->Invalidate( SID_DOC_MODIFIED );
     345                 :            :             }
     346                 :            :         }
     347                 :            :     }
     348                 :            : 
     349                 :          0 :     return 0;
     350                 :            : }
     351                 :            : 
     352                 :          2 : void ScDocument::StartTrackTimer()
     353                 :            : {
     354         [ +  + ]:          2 :     if (!aTrackTimer.IsActive())        // nicht ewig aufschieben
     355                 :          1 :         aTrackTimer.Start();
     356                 :          2 : }
     357                 :            : 
     358 [ +  - ][ +  - ]:       1611 : ScDocument::~ScDocument()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     359                 :            : {
     360                 :            :     OSL_PRECOND( !bInLinkUpdate, "bInLinkUpdate in dtor" );
     361                 :            : 
     362                 :       1611 :     bInDtorClear = true;
     363                 :            : 
     364                 :            :     // first of all disable all refresh timers by deleting the control
     365         [ +  + ]:       1611 :     if ( pRefreshTimerControl )
     366                 :            :     {   // To be sure there isn't anything running do it with a protector,
     367                 :            :         // this ensures also that nothing needs the control anymore.
     368         [ +  - ]:        695 :         ScRefreshTimerProtector aProt( GetRefreshTimerControlAddress() );
     369 [ +  - ][ +  - ]:        695 :         delete pRefreshTimerControl, pRefreshTimerControl = NULL;
     370                 :            :     }
     371                 :            : 
     372                 :            :     // Links aufrauemen
     373                 :            : 
     374 [ +  - ][ +  + ]:       1611 :     if ( GetLinkManager() )
     375                 :            :     {
     376                 :            :         // BaseLinks freigeben
     377         [ +  - ]:        695 :         ::sfx2::SvLinkSources aTemp(pLinkManager->GetServers());
     378 [ #  # ][ +  - ]:        695 :         for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin(); it != aTemp.end(); ++it )
                 [ -  + ]
     379 [ #  # ][ #  # ]:          0 :             (*it)->Closed();
     380                 :            : 
     381         [ +  + ]:        695 :         if ( pLinkManager->GetLinks().size() )
     382         [ +  - ]:        695 :             pLinkManager->Remove( 0, pLinkManager->GetLinks().size() );
     383                 :            :     }
     384                 :            : 
     385                 :       1611 :     mxFormulaParserPool.reset();
     386                 :            :     // Destroy the external ref mgr instance here because it has a timer
     387                 :            :     // which needs to be stopped before the app closes.
     388                 :       1611 :     pExternalRefMgr.reset();
     389                 :            : 
     390         [ +  - ]:       1611 :     ScAddInAsync::RemoveDocument( this );
     391         [ +  - ]:       1611 :     ScAddInListener::RemoveDocument( this );
     392 [ +  + ][ +  - ]:       1611 :     DELETEZ( pChartListenerCollection);   // vor pBASM wg. evtl. Listener!
     393 [ -  + ][ #  # ]:       1611 :     DELETEZ( pLookupCacheMapImpl);  // before pBASM because of listeners
     394                 :            :     // BroadcastAreas vor allen Zellen zerstoeren um unnoetige
     395                 :            :     // Einzel-EndListenings der Formelzellen zu vermeiden
     396 [ +  + ][ +  - ]:       1611 :     delete pBASM;       // BroadcastAreaSlotMachine
     397                 :       1611 :     pBASM = NULL;
     398                 :            : 
     399 [ +  + ][ +  - ]:       1611 :     delete pUnoBroadcaster;     // broadcasted nochmal SFX_HINT_DYING
     400                 :       1611 :     pUnoBroadcaster = NULL;
     401                 :            : 
     402 [ -  + ][ #  # ]:       1611 :     delete pUnoRefUndoList;
     403 [ -  + ][ #  # ]:       1611 :     delete pUnoListenerCalls;
     404                 :            : 
     405         [ +  - ]:       1611 :     Clear( true );              // true = from destructor (needed for SdrModel::ClearModel)
     406                 :            : 
     407         [ +  + ]:       1611 :     if (pValidationList)
     408                 :            :     {
     409 [ +  - ][ +  - ]:         21 :         for( ScValidationDataList::iterator it = pValidationList->begin(); it != pValidationList->end(); ++it )
                 [ +  + ]
     410 [ +  - ][ +  - ]:         12 :             delete *it;
                 [ +  - ]
     411                 :          9 :         pValidationList->clear();
     412         [ +  - ]:          9 :         DELETEZ(pValidationList);
     413                 :            :     }
     414 [ +  + ][ +  - ]:       1611 :     delete pRangeName;
     415 [ +  - ][ +  - ]:       1611 :     delete pDBCollection;
     416 [ -  + ][ #  # ]:       1611 :     delete pSelectionAttr;
     417                 :       1611 :     apTemporaryChartLock.reset();
     418 [ +  - ][ +  - ]:       1611 :     delete pChartCollection;
     419         [ +  - ]:       1611 :     DeleteDrawLayer();
     420         [ -  + ]:       1611 :     delete pFormatExchangeList;
     421 [ +  + ][ +  - ]:       1611 :     delete pPrinter;
     422         [ +  - ]:       1611 :     ImplDeleteOptions();
     423 [ +  + ][ +  - ]:       1611 :     delete pConsolidateDlgData;
     424 [ +  + ][ +  - ]:       1611 :     delete pLinkManager;
     425 [ -  + ][ #  # ]:       1611 :     delete pClipData;
     426 [ +  + ][ +  - ]:       1611 :     delete pDetOpList;                  // loescht auch die Eintraege
     427 [ -  + ][ #  # ]:       1611 :     delete pChangeTrack;
     428 [ +  + ][ +  - ]:       1611 :     delete pEditEngine;
     429 [ +  + ][ +  - ]:       1611 :     delete pNoteEngine;
     430 [ -  + ][ #  # ]:       1611 :     delete pChangeViewSettings;         // und weg damit
     431 [ +  + ][ +  - ]:       1611 :     delete pVirtualDevice_100th_mm;
     432                 :            : 
     433 [ +  + ][ +  - ]:       1611 :     delete pDPCollection;
     434                 :            : 
     435                 :            :     // delete the EditEngine before destroying the xPoolHelper
     436 [ +  + ][ +  - ]:       1611 :     delete pCacheFieldEditEngine;
     437                 :            : 
     438 [ +  - ][ +  + ]:       1611 :     if ( xPoolHelper.is() && !bIsClip )
                 [ +  + ]
     439         [ +  - ]:       1585 :         xPoolHelper->SourceDocumentGone();
     440         [ +  - ]:       1611 :     xPoolHelper.clear();
     441                 :            : 
     442 [ +  + ][ +  - ]:       1611 :     delete pScriptTypeData;
     443         [ +  + ]:       1611 :     delete pRecursionHelper;
     444                 :            : 
     445                 :            :     OSL_POSTCOND( !pAutoNameCache, "AutoNameCache still set in dtor" );
     446                 :       1611 : }
     447                 :            : 
     448                 :         29 : void ScDocument::InitClipPtrs( ScDocument* pSourceDoc )
     449                 :            : {
     450                 :            :     OSL_ENSURE(bIsClip, "InitClipPtrs und nicht bIsClip");
     451                 :            : 
     452         [ -  + ]:         29 :     if (pValidationList)
     453                 :            :     {
     454 [ #  # ][ #  # ]:          0 :         for(ScValidationDataList::iterator it = pValidationList->begin(); it != pValidationList->end(); ++it )
                 [ #  # ]
     455 [ #  # ][ #  # ]:          0 :             delete *it;
                 [ #  # ]
     456                 :          0 :         pValidationList->clear();
     457         [ #  # ]:          0 :         DELETEZ(pValidationList);
     458                 :            :     }
     459                 :            : 
     460                 :         29 :     Clear();
     461                 :            : 
     462                 :         29 :     xPoolHelper = pSourceDoc->xPoolHelper;
     463                 :            : 
     464                 :            :     //  bedingte Formate / Gueltigkeiten
     465                 :            :     //! Vorlagen kopieren?
     466                 :         29 :     const ScValidationDataList* pSourceValid = pSourceDoc->pValidationList;
     467         [ -  + ]:         29 :     if ( pSourceValid )
     468         [ #  # ]:          0 :         pValidationList = new ScValidationDataList(this, *pSourceValid);
     469                 :            : 
     470                 :            :                         // Links in Stream speichern
     471         [ -  + ]:         29 :     delete pClipData;
     472         [ -  + ]:         29 :     if (pSourceDoc->HasDdeLinks())
     473                 :            :     {
     474         [ #  # ]:          0 :         pClipData = new SvMemoryStream;
     475                 :          0 :         pSourceDoc->SaveDdeLinks(*pClipData);
     476                 :            :     }
     477                 :            :     else
     478                 :         29 :         pClipData = NULL;
     479                 :            : 
     480                 :            :     // Options pointers exist (ImplCreateOptions) for any document.
     481                 :            :     // Must be copied for correct results in OLE objects (#i42666#).
     482                 :         29 :     SetDocOptions( pSourceDoc->GetDocOptions() );
     483                 :         29 :     SetViewOptions( pSourceDoc->GetViewOptions() );
     484                 :         29 : }
     485                 :            : 
     486                 :     101150 : SvNumberFormatter* ScDocument::GetFormatTable() const
     487                 :            : {
     488                 :     101150 :     return xPoolHelper->GetFormTable();
     489                 :            : }
     490                 :            : 
     491                 :       3868 : SfxItemPool* ScDocument::GetEditPool() const
     492                 :            : {
     493                 :       3868 :     return xPoolHelper->GetEditPool();
     494                 :            : }
     495                 :            : 
     496                 :       2941 : SfxItemPool* ScDocument::GetEnginePool() const
     497                 :            : {
     498                 :       2941 :     return xPoolHelper->GetEnginePool();
     499                 :            : }
     500                 :            : 
     501                 :        408 : ScFieldEditEngine& ScDocument::GetEditEngine()
     502                 :            : {
     503         [ +  + ]:        408 :     if ( !pEditEngine )
     504                 :            :     {
     505         [ +  - ]:         44 :         pEditEngine = new ScFieldEditEngine(this, GetEnginePool(), GetEditPool());
     506                 :         44 :         pEditEngine->SetUpdateMode( false );
     507                 :         44 :         pEditEngine->EnableUndo( false );
     508         [ +  - ]:         44 :         pEditEngine->SetRefMapMode( MAP_100TH_MM );
     509                 :         44 :         ApplyAsianEditSettings( *pEditEngine );
     510                 :            :     }
     511                 :        408 :     return *pEditEngine;
     512                 :            : }
     513                 :            : 
     514                 :         13 : ScNoteEditEngine& ScDocument::GetNoteEngine()
     515                 :            : {
     516         [ +  + ]:         13 :     if ( !pNoteEngine )
     517                 :            :     {
     518         [ +  - ]:          7 :         pNoteEngine = new ScNoteEditEngine( GetEnginePool(), GetEditPool() );
     519                 :          7 :         pNoteEngine->SetUpdateMode( false );
     520                 :          7 :         pNoteEngine->EnableUndo( false );
     521         [ +  - ]:          7 :         pNoteEngine->SetRefMapMode( MAP_100TH_MM );
     522                 :          7 :         ApplyAsianEditSettings( *pNoteEngine );
     523                 :          7 :         const SfxItemSet& rItemSet = GetDefPattern()->GetItemSet();
     524         [ +  - ]:          7 :         SfxItemSet* pEEItemSet = new SfxItemSet( pNoteEngine->GetEmptyItemSet() );
     525                 :          7 :         ScPatternAttr::FillToEditItemSet( *pEEItemSet, rItemSet );
     526                 :          7 :         pNoteEngine->SetDefaults( pEEItemSet );      // edit engine takes ownership
     527                 :            :     }
     528                 :         13 :     return *pNoteEngine;
     529                 :            : }
     530                 :            : 
     531                 :            : 
     532                 :         13 : void ScDocument::ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks )
     533                 :            : {
     534         [ +  - ]:         13 :     if (bIsClip)
     535                 :            :     {
     536                 :         13 :         InitClipPtrs(pSourceDoc);
     537                 :            : 
     538         [ +  + ]:         40 :         for (SCTAB i = 0; i < static_cast<SCTAB>(pSourceDoc->maTabs.size()); i++)
     539         [ +  - ]:         27 :             if (pSourceDoc->maTabs[i])
     540 [ +  - ][ +  + ]:         27 :                 if (!pMarks || pMarks->GetTableSelect(i))
                 [ +  + ]
     541                 :            :                 {
     542                 :         12 :                     rtl::OUString aString;
     543         [ +  - ]:         12 :                     pSourceDoc->maTabs[i]->GetName(aString);
     544         [ -  + ]:         12 :                     if ( i < static_cast<SCTAB>(maTabs.size()) )
     545                 :            :                     {
     546 [ #  # ][ #  # ]:          0 :                         maTabs[i] = new ScTable(this, i, aString);
     547                 :            : 
     548                 :            :                     }
     549                 :            :                     else
     550                 :            :                     {
     551         [ -  + ]:         12 :                         if( i > static_cast<SCTAB>(maTabs.size()) )
     552                 :            :                         {
     553         [ #  # ]:          0 :                             maTabs.resize(i, NULL );
     554                 :            :                         }
     555 [ +  - ][ +  - ]:         12 :                         maTabs.push_back(new ScTable(this, i, aString));
                 [ +  - ]
     556                 :            :                     }
     557         [ +  - ]:         12 :                     maTabs[i]->SetLayoutRTL( pSourceDoc->maTabs[i]->IsLayoutRTL() );
     558                 :            :                 }
     559                 :            :     }
     560                 :            :     else
     561                 :            :     {
     562                 :            :         OSL_FAIL("ResetClip");
     563                 :            :     }
     564                 :         13 : }
     565                 :            : 
     566                 :         16 : void ScDocument::ResetClip( ScDocument* pSourceDoc, SCTAB nTab )
     567                 :            : {
     568         [ +  - ]:         16 :     if (bIsClip)
     569                 :            :     {
     570                 :         16 :         InitClipPtrs(pSourceDoc);
     571         [ +  - ]:         16 :         if (nTab >= static_cast<SCTAB>(maTabs.size()))
     572                 :            :         {
     573         [ +  - ]:         16 :             maTabs.resize(nTab+1, NULL );
     574                 :            :         }
     575                 :         16 :         maTabs[nTab] = new ScTable(this, nTab,
     576 [ +  - ][ +  - ]:         32 :                             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("baeh")));
     577 [ +  - ][ +  - ]:         16 :         if (nTab < static_cast<SCTAB>(pSourceDoc->maTabs.size()) && pSourceDoc->maTabs[nTab])
                 [ +  - ]
     578                 :         16 :             maTabs[nTab]->SetLayoutRTL( pSourceDoc->maTabs[nTab]->IsLayoutRTL() );
     579                 :            :     }
     580                 :            :     else
     581                 :            :     {
     582                 :            :         OSL_FAIL("ResetClip");
     583                 :            :     }
     584                 :         16 : }
     585                 :            : 
     586                 :          0 : void ScDocument::PutCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
     587                 :            :                           ScBaseCell* pCell, sal_uLong nFormatIndex, bool bForceTab )
     588                 :            : {
     589         [ #  # ]:          0 :     if (VALIDTAB(nTab))
     590                 :            :     {
     591 [ #  # ][ #  # ]:          0 :         if ( bForceTab && ( nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab] ) )
         [ #  # ][ #  # ]
     592                 :            :         {
     593                 :          0 :             bool bExtras = !bIsUndo;        // Spaltenbreiten, Zeilenhoehen, Flags
     594         [ #  # ]:          0 :             if ( nTab >= static_cast<SCTAB>(maTabs.size()) )
     595                 :            :             {
     596         [ #  # ]:          0 :                 maTabs.resize( nTab + 1, NULL );
     597                 :            :             }
     598         [ #  # ]:          0 :             maTabs.at(nTab) = new ScTable(this, nTab,
     599                 :            :                                     rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("temp")),
     600 [ #  # ][ #  # ]:          0 :                                     bExtras, bExtras);
     601                 :            :         }
     602                 :            : 
     603 [ #  # ][ #  # ]:          0 :         if ( nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
                 [ #  # ]
     604                 :          0 :             maTabs[nTab]->PutCell( nCol, nRow, nFormatIndex, pCell );
     605                 :            :     }
     606                 :          0 : }
     607                 :            : 
     608                 :            : 
     609                 :        994 : bool ScDocument::GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
     610                 :            :                                 bool bNotes ) const
     611                 :            : {
     612 [ +  - ][ +  - ]:        994 :     if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
         [ +  - ][ +  - ]
     613                 :            :     {
     614                 :        994 :         bool bAny = maTabs[nTab]->GetPrintArea( rEndCol, rEndRow, bNotes );
     615         [ +  + ]:        994 :         if (pDrawLayer)
     616                 :            :         {
     617                 :        770 :             ScRange aDrawRange(0,0,nTab, MAXCOL,MAXROW,nTab);
     618 [ +  + ][ +  - ]:        770 :             if (DrawGetPrintArea( aDrawRange, true, true ))
     619                 :            :             {
     620         [ +  + ]:         49 :                 if (aDrawRange.aEnd.Col()>rEndCol) rEndCol=aDrawRange.aEnd.Col();
     621         [ +  + ]:         49 :                 if (aDrawRange.aEnd.Row()>rEndRow) rEndRow=aDrawRange.aEnd.Row();
     622                 :        770 :                 bAny = true;
     623                 :            :             }
     624                 :            :         }
     625                 :        994 :         return bAny;
     626                 :            :     }
     627                 :            : 
     628                 :          0 :     rEndCol = 0;
     629                 :          0 :     rEndRow = 0;
     630                 :        994 :     return false;
     631                 :            : }
     632                 :            : 
     633                 :          0 : bool ScDocument::GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow,
     634                 :            :                                         SCCOL& rEndCol, bool bNotes ) const
     635                 :            : {
     636 [ #  # ][ #  # ]:          0 :     if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
         [ #  # ][ #  # ]
     637                 :            :     {
     638                 :          0 :         bool bAny = maTabs[nTab]->GetPrintAreaHor( nStartRow, nEndRow, rEndCol, bNotes );
     639         [ #  # ]:          0 :         if (pDrawLayer)
     640                 :            :         {
     641                 :          0 :             ScRange aDrawRange(0,nStartRow,nTab, MAXCOL,nEndRow,nTab);
     642 [ #  # ][ #  # ]:          0 :             if (DrawGetPrintArea( aDrawRange, true, false ))
     643                 :            :             {
     644         [ #  # ]:          0 :                 if (aDrawRange.aEnd.Col()>rEndCol) rEndCol=aDrawRange.aEnd.Col();
     645                 :          0 :                 bAny = true;
     646                 :            :             }
     647                 :            :         }
     648                 :          0 :         return bAny;
     649                 :            :     }
     650                 :            : 
     651                 :          0 :     rEndCol = 0;
     652                 :          0 :     return false;
     653                 :            : }
     654                 :            : 
     655                 :         96 : bool ScDocument::GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol,
     656                 :            :                                         SCROW& rEndRow, bool bNotes ) const
     657                 :            : {
     658 [ +  - ][ +  - ]:         96 :     if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
         [ +  - ][ +  - ]
     659                 :            :     {
     660                 :         96 :         bool bAny = maTabs[nTab]->GetPrintAreaVer( nStartCol, nEndCol, rEndRow, bNotes );
     661         [ +  - ]:         96 :         if (pDrawLayer)
     662                 :            :         {
     663                 :         96 :             ScRange aDrawRange(nStartCol,0,nTab, nEndCol,MAXROW,nTab);
     664 [ -  + ][ +  - ]:         96 :             if (DrawGetPrintArea( aDrawRange, false, true ))
     665                 :            :             {
     666         [ #  # ]:          0 :                 if (aDrawRange.aEnd.Row()>rEndRow) rEndRow=aDrawRange.aEnd.Row();
     667                 :         96 :                 bAny = true;
     668                 :            :             }
     669                 :            :         }
     670                 :         96 :         return bAny;
     671                 :            :     }
     672                 :            : 
     673                 :          0 :     rEndRow = 0;
     674                 :         96 :     return false;
     675                 :            : }
     676                 :            : 
     677                 :        873 : bool ScDocument::GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const
     678                 :            : {
     679 [ +  - ][ +  - ]:        873 :     if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
         [ +  - ][ +  - ]
     680                 :            :     {
     681                 :        873 :         bool bAny = maTabs[nTab]->GetDataStart( rStartCol, rStartRow );
     682         [ +  + ]:        873 :         if (pDrawLayer)
     683                 :            :         {
     684                 :        649 :             ScRange aDrawRange(0,0,nTab, MAXCOL,MAXROW,nTab);
     685 [ +  + ][ +  - ]:        649 :             if (DrawGetPrintArea( aDrawRange, true, true ))
     686                 :            :             {
     687         [ +  + ]:         49 :                 if (aDrawRange.aStart.Col()<rStartCol) rStartCol=aDrawRange.aStart.Col();
     688         [ +  + ]:         49 :                 if (aDrawRange.aStart.Row()<rStartRow) rStartRow=aDrawRange.aStart.Row();
     689                 :        649 :                 bAny = true;
     690                 :            :             }
     691                 :            :         }
     692                 :        873 :         return bAny;
     693                 :            :     }
     694                 :            : 
     695                 :          0 :     rStartCol = 0;
     696                 :          0 :     rStartRow = 0;
     697                 :        873 :     return false;
     698                 :            : }
     699                 :            : 
     700                 :         15 : bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
     701                 :            : {
     702         [ -  + ]:         15 :     if (nOldPos == nNewPos)
     703                 :          0 :         return false;
     704                 :            : 
     705                 :         15 :     SCTAB nTabCount = static_cast<SCTAB>(maTabs.size());
     706         [ -  + ]:         15 :     if(nTabCount < 2)
     707                 :          0 :         return false;
     708                 :            : 
     709                 :         15 :     bool bValid = false;
     710 [ +  - ][ +  - ]:         15 :     if (VALIDTAB(nOldPos) && nOldPos < nTabCount )
                 [ +  - ]
     711                 :            :     {
     712         [ +  - ]:         15 :         if (maTabs[nOldPos])
     713                 :            :         {
     714                 :         15 :             bool bOldAutoCalc = GetAutoCalc();
     715         [ +  - ]:         15 :             SetAutoCalc( false );   // Mehrfachberechnungen vermeiden
     716                 :         15 :             SetNoListening( true );
     717 [ -  + ][ +  - ]:         15 :             if (nNewPos == SC_TAB_APPEND || nNewPos >= nTabCount)
     718                 :          0 :                 nNewPos = nTabCount-1;
     719                 :            : 
     720                 :            :             //  Referenz-Updaterei
     721                 :            :             //! mit UpdateReference zusammenfassen!
     722                 :            : 
     723                 :         15 :             SCsTAB nDz = ((SCsTAB)nNewPos) - (SCsTAB)nOldPos;
     724                 :         15 :             ScRange aSourceRange( 0,0,nOldPos, MAXCOL,MAXROW,nOldPos );
     725         [ +  + ]:         15 :             if (pRangeName)
     726         [ +  - ]:          3 :                 pRangeName->UpdateTabRef(nOldPos, 3, nNewPos);
     727         [ +  - ]:         15 :             pDBCollection->UpdateMoveTab( nOldPos, nNewPos );
     728         [ +  - ]:         15 :             xColNameRanges->UpdateReference( URM_REORDER, this, aSourceRange, 0,0,nDz );
     729         [ +  - ]:         15 :             xRowNameRanges->UpdateReference( URM_REORDER, this, aSourceRange, 0,0,nDz );
     730         [ +  + ]:         15 :             if (pDPCollection)
     731         [ +  - ]:          6 :                 pDPCollection->UpdateReference( URM_REORDER, aSourceRange, 0,0,nDz );
     732         [ -  + ]:         15 :             if (pDetOpList)
     733         [ #  # ]:          0 :                 pDetOpList->UpdateReference( this, URM_REORDER, aSourceRange, 0,0,nDz );
     734                 :            :             UpdateChartRef( URM_REORDER,
     735         [ +  - ]:         15 :                     0,0,nOldPos, MAXCOL,MAXROW,nOldPos, 0,0,nDz );
     736         [ +  - ]:         15 :             UpdateRefAreaLinks( URM_REORDER, aSourceRange, 0,0,nDz );
     737         [ -  + ]:         15 :             if ( pValidationList )
     738         [ #  # ]:          0 :                 pValidationList->UpdateMoveTab( nOldPos, nNewPos );
     739         [ +  - ]:         15 :             if ( pUnoBroadcaster )
     740                 :            :                 pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_REORDER,
     741 [ +  - ][ +  - ]:         15 :                             aSourceRange, 0,0,nDz ) );
                 [ +  - ]
     742                 :            : 
     743                 :         15 :             ScTable* pSaveTab = maTabs[nOldPos];
     744 [ +  - ][ +  - ]:         15 :             maTabs.erase(maTabs.begin()+nOldPos);
     745 [ +  - ][ +  - ]:         15 :             maTabs.insert(maTabs.begin()+nNewPos, pSaveTab);
     746                 :         15 :             TableContainer::iterator it = maTabs.begin();
     747         [ +  + ]:         45 :             for (SCTAB i = 0; i < nTabCount; i++)
     748         [ +  - ]:         30 :                 if (maTabs[i])
     749         [ +  - ]:         30 :                     maTabs[i]->UpdateMoveTab( nOldPos, nNewPos, i, pProgress );
     750                 :         15 :             it = maTabs.begin();
     751 [ +  - ][ +  + ]:         45 :             for (; it != maTabs.end(); ++it)
     752         [ +  - ]:         30 :                 if (*it)
     753         [ +  - ]:         30 :                     (*it)->UpdateCompile();
     754                 :         15 :             SetNoListening( false );
     755                 :         15 :             it = maTabs.begin();
     756 [ +  - ][ +  + ]:         45 :             for (; it != maTabs.end(); ++it)
     757         [ +  - ]:         30 :                 if (*it)
     758         [ +  - ]:         30 :                     (*it)->StartAllListeners();
     759                 :            :             // sheet names of references may not be valid until sheet is moved
     760         [ +  - ]:         15 :             pChartListenerCollection->UpdateScheduledSeriesRanges();
     761         [ +  - ]:         15 :             SetDirty();
     762         [ +  - ]:         15 :             SetAutoCalc( bOldAutoCalc );
     763                 :            : 
     764         [ +  + ]:         15 :             if (pDrawLayer)
     765         [ +  - ]:          3 :                 DrawMovePage( static_cast<sal_uInt16>(nOldPos), static_cast<sal_uInt16>(nNewPos) );
     766                 :            : 
     767                 :         15 :             bValid = true;
     768                 :            :         }
     769                 :            :     }
     770                 :         15 :     return bValid;
     771                 :            : }
     772                 :            : 
     773                 :         10 : bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyMarked )
     774                 :            : {
     775 [ +  - ][ +  - ]:         10 :     if (SC_TAB_APPEND == nNewPos  || nNewPos >= static_cast<SCTAB>(maTabs.size()))
                 [ +  - ]
     776                 :         10 :         nNewPos = static_cast<SCTAB>(maTabs.size());
     777                 :         10 :     rtl::OUString aName;
     778         [ +  - ]:         10 :     GetName(nOldPos, aName);
     779                 :            : 
     780                 :            :     //  vorneweg testen, ob der Prefix als gueltig erkannt wird
     781                 :            :     //  wenn nicht, nur doppelte vermeiden
     782         [ +  - ]:         10 :     bool bPrefix = ValidTabName( aName );
     783                 :            :     OSL_ENSURE(bPrefix, "ungueltiger Tabellenname");
     784                 :            :     SCTAB nDummy;
     785                 :            : 
     786         [ +  - ]:         10 :     CreateValidTabName(aName);
     787                 :            : 
     788                 :            :     bool bValid;
     789         [ +  - ]:         10 :     if (bPrefix)
     790         [ +  - ]:         10 :         bValid = ValidNewTabName(aName);
     791                 :            :     else
     792         [ #  # ]:          0 :         bValid = !GetTable( aName, nDummy );
     793                 :            : 
     794                 :         10 :     bool bOldAutoCalc = GetAutoCalc();
     795         [ +  - ]:         10 :     SetAutoCalc( false );   // Mehrfachberechnungen vermeiden
     796         [ +  - ]:         10 :     if (bValid)
     797                 :            :     {
     798         [ +  - ]:         10 :         if (nNewPos >= static_cast<SCTAB>(maTabs.size()))
     799                 :            :         {
     800                 :         10 :             nNewPos = static_cast<SCTAB>(maTabs.size());
     801 [ +  - ][ +  - ]:         10 :             maTabs.push_back(new ScTable(this, nNewPos, aName));
                 [ +  - ]
     802                 :            :         }
     803                 :            :         else
     804                 :            :         {
     805 [ #  # ][ #  # ]:          0 :             if (VALIDTAB(nNewPos) && (nNewPos < static_cast<SCTAB>(maTabs.size())))
                 [ #  # ]
     806                 :            :             {
     807                 :          0 :                 SetNoListening( true );
     808                 :            : 
     809                 :          0 :                 ScRange aRange( 0,0,nNewPos, MAXCOL,MAXROW,MAXTAB );
     810         [ #  # ]:          0 :                 xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 );
     811         [ #  # ]:          0 :                 xRowNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,1 );
     812         [ #  # ]:          0 :                 if (pRangeName)
     813         [ #  # ]:          0 :                     pRangeName->UpdateTabRef(nNewPos, 1);
     814                 :            :                 pDBCollection->UpdateReference(
     815         [ #  # ]:          0 :                                     URM_INSDEL, 0,0,nNewPos, MAXCOL,MAXROW,MAXTAB, 0,0,1 );
     816         [ #  # ]:          0 :                 if (pDPCollection)
     817         [ #  # ]:          0 :                     pDPCollection->UpdateReference( URM_INSDEL, aRange, 0,0,1 );
     818         [ #  # ]:          0 :                 if (pDetOpList)
     819         [ #  # ]:          0 :                     pDetOpList->UpdateReference( this, URM_INSDEL, aRange, 0,0,1 );
     820         [ #  # ]:          0 :                 UpdateChartRef( URM_INSDEL, 0,0,nNewPos, MAXCOL,MAXROW,MAXTAB, 0,0,1 );
     821         [ #  # ]:          0 :                 UpdateRefAreaLinks( URM_INSDEL, aRange, 0,0,1 );
     822         [ #  # ]:          0 :                 if ( pUnoBroadcaster )
     823 [ #  # ][ #  # ]:          0 :                     pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,1 ) );
                 [ #  # ]
     824                 :            : 
     825                 :            :                 SCTAB i;
     826 [ #  # ][ #  # ]:          0 :                 for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
     827 [ #  # ][ #  # ]:          0 :                     if (*it && it != (maTabs.begin() + nOldPos))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                      # ]
     828         [ #  # ]:          0 :                         (*it)->UpdateInsertTab(nNewPos);
     829         [ #  # ]:          0 :                 maTabs.push_back(NULL);
     830         [ #  # ]:          0 :                 for (i = static_cast<SCTAB>(maTabs.size())-1; i > nNewPos; i--)
     831                 :          0 :                     maTabs[i] = maTabs[i - 1];
     832         [ #  # ]:          0 :                 if (nNewPos <= nOldPos)
     833                 :          0 :                     nOldPos++;
     834 [ #  # ][ #  # ]:          0 :                 maTabs[nNewPos] = new ScTable(this, nNewPos, aName);
     835                 :          0 :                 bValid = true;
     836 [ #  # ][ #  # ]:          0 :                 for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
     837 [ #  # ][ #  # ]:          0 :                     if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin() + nNewPos)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     838         [ #  # ]:          0 :                         (*it)->UpdateCompile();
     839                 :          0 :                 SetNoListening( false );
     840 [ #  # ][ #  # ]:          0 :                 for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
     841 [ #  # ][ #  # ]:          0 :                     if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin()+nNewPos)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     842         [ #  # ]:          0 :                         (*it)->StartAllListeners();
     843                 :            : 
     844         [ #  # ]:          0 :                 if ( pValidationList )
     845         [ #  # ]:          0 :                     pValidationList->UpdateReference( URM_INSDEL, aRange, 0,0,1 );
     846                 :            :                 // sheet names of references may not be valid until sheet is copied
     847         [ #  # ]:          0 :                 pChartListenerCollection->UpdateScheduledSeriesRanges();
     848                 :            :             }
     849                 :            :             else
     850                 :          0 :                 bValid = false;
     851                 :            :         }
     852                 :            :     }
     853         [ +  - ]:         10 :     if (bValid)
     854                 :            :     {
     855                 :         10 :         SetNoListening( true );     // noch nicht bei CopyToTable/Insert
     856                 :         10 :         maTabs[nOldPos]->CopyToTable(0, 0, MAXCOL, MAXROW, IDF_ALL, (pOnlyMarked != NULL),
     857         [ +  - ]:         20 :                                         maTabs[nNewPos], pOnlyMarked );
     858 [ +  - ][ +  - ]:         10 :         maTabs[nNewPos]->SetTabBgColor(maTabs[nOldPos]->GetTabBgColor());
     859                 :            : 
     860                 :         10 :         SCsTAB nDz = (static_cast<SCsTAB>(nNewPos)) - static_cast<SCsTAB>(nOldPos);
     861                 :         10 :         maTabs[nNewPos]->UpdateReference(URM_COPY, 0, 0, nNewPos , MAXCOL, MAXROW,
     862         [ +  - ]:         10 :                                         nNewPos, 0, 0, nDz, NULL);
     863                 :            : 
     864         [ +  - ]:         10 :         maTabs[nNewPos]->UpdateInsertTabAbs(nNewPos); // alle abs. um eins hoch!!
     865         [ +  - ]:         10 :         maTabs[nOldPos]->UpdateInsertTab(nNewPos);
     866                 :            : 
     867         [ +  - ]:         10 :         maTabs[nOldPos]->UpdateCompile();
     868         [ +  - ]:         10 :         maTabs[nNewPos]->UpdateCompile( true ); //  maybe already compiled in Clone, but used names need recompilation
     869                 :         10 :         SetNoListening( false );
     870         [ +  - ]:         10 :         maTabs[nOldPos]->StartAllListeners();
     871         [ +  - ]:         10 :         maTabs[nNewPos]->StartAllListeners();
     872                 :            : 
     873 [ +  - ][ +  - ]:         10 :         ScConditionalFormatList* pNewList = new ScConditionalFormatList(*maTabs[nOldPos]->GetCondFormList());
                 [ +  - ]
     874                 :            :         pNewList->UpdateReference(URM_COPY, ScRange( 0, 0, nNewPos , MAXCOL, MAXROW,
     875         [ +  - ]:         10 :                                         nNewPos), 0, 0, nDz);
     876         [ +  - ]:         10 :         maTabs[nNewPos]->SetCondFormList( pNewList );
     877                 :            : 
     878         [ +  - ]:         10 :         SetDirty();
     879         [ +  - ]:         10 :         SetAutoCalc( bOldAutoCalc );
     880                 :            : 
     881         [ +  + ]:         10 :         if (pDrawLayer)
     882         [ +  - ]:          4 :             DrawCopyPage( static_cast<sal_uInt16>(nOldPos), static_cast<sal_uInt16>(nNewPos) );
     883                 :            : 
     884         [ -  + ]:         10 :         if (pDPCollection)
     885         [ #  # ]:          0 :             pDPCollection->CopyToTab(nOldPos, nNewPos);
     886                 :            : 
     887         [ +  - ]:         10 :         maTabs[nNewPos]->SetPageStyle( maTabs[nOldPos]->GetPageStyle() );
     888         [ +  - ]:         10 :         maTabs[nNewPos]->SetPendingRowHeights( maTabs[nOldPos]->IsPendingRowHeights() );
     889                 :            : 
     890                 :            :         // Copy the custom print range if exists.
     891         [ +  - ]:         10 :         maTabs[nNewPos]->CopyPrintRange(*maTabs[nOldPos]);
     892                 :            : 
     893                 :            :         // Copy the RTL settings
     894         [ +  - ]:         10 :         maTabs[nNewPos]->SetLayoutRTL(maTabs[nOldPos]->IsLayoutRTL());
     895         [ +  - ]:         10 :         maTabs[nNewPos]->SetLoadingRTL(maTabs[nOldPos]->IsLoadingRTL());
     896                 :            :     }
     897                 :            :     else
     898         [ #  # ]:          0 :         SetAutoCalc( bOldAutoCalc );
     899                 :         10 :     return bValid;
     900                 :            : }
     901                 :            : 
     902                 :            : void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, const rtl::OUString& sModuleName, const rtl::OUString& sModuleSource );
     903                 :            : 
     904                 :          4 : sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
     905                 :            :                                 SCTAB nDestPos, bool bInsertNew,
     906                 :            :                                 bool bResultsOnly )
     907                 :            : {
     908                 :          4 :     sal_uLong nRetVal = 1;                      // 0 => Fehler 1 = ok
     909                 :            :                                             // 3 => NameBox
     910                 :            :                                             // 4 => beides
     911                 :            : 
     912         [ +  - ]:          4 :     if (pSrcDoc->pShell->GetMedium())
     913                 :            :     {
     914                 :          4 :         pSrcDoc->maFileURL = pSrcDoc->pShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI);
     915                 :            :         // for unsaved files use the title name and adjust during save of file
     916         [ -  + ]:          4 :         if (pSrcDoc->maFileURL.isEmpty())
     917                 :          0 :             pSrcDoc->maFileURL = pSrcDoc->pShell->GetName();
     918                 :            :     }
     919                 :            :     else
     920                 :            :     {
     921                 :          0 :         pSrcDoc->maFileURL = pSrcDoc->pShell->GetName();
     922                 :            :     }
     923                 :            : 
     924                 :          4 :     bool bValid = true;
     925         [ +  + ]:          4 :     if (bInsertNew)             // neu einfuegen
     926                 :            :     {
     927                 :          2 :         rtl::OUString aName;
     928         [ +  - ]:          2 :         pSrcDoc->GetName(nSrcPos, aName);
     929         [ +  - ]:          2 :         CreateValidTabName(aName);
     930         [ +  - ]:          2 :         bValid = InsertTab(nDestPos, aName);
     931                 :            : 
     932                 :            :         // Copy the RTL settings
     933         [ +  - ]:          2 :         maTabs[nDestPos]->SetLayoutRTL(pSrcDoc->maTabs[nSrcPos]->IsLayoutRTL());
     934         [ +  - ]:          2 :         maTabs[nDestPos]->SetLoadingRTL(pSrcDoc->maTabs[nSrcPos]->IsLoadingRTL());
     935                 :            :     }
     936                 :            :     else                        // bestehende Tabelle ersetzen
     937                 :            :     {
     938 [ +  - ][ +  - ]:          2 :         if (VALIDTAB(nDestPos) && nDestPos < static_cast<SCTAB>(maTabs.size()) && maTabs[nDestPos])
         [ +  - ][ +  - ]
     939                 :            :         {
     940                 :          2 :             maTabs[nDestPos]->DeleteArea( 0,0, MAXCOL,MAXROW, IDF_ALL );
     941                 :            :         }
     942                 :            :         else
     943                 :          0 :             bValid = false;
     944                 :            :     }
     945                 :            : 
     946         [ +  - ]:          4 :     if (bValid)
     947                 :            :     {
     948                 :          4 :         bool bOldAutoCalcSrc = false;
     949                 :          4 :         bool bOldAutoCalc = GetAutoCalc();
     950                 :          4 :         SetAutoCalc( false );   // Mehrfachberechnungen vermeiden
     951                 :          4 :         SetNoListening( true );
     952         [ +  + ]:          4 :         if ( bResultsOnly )
     953                 :            :         {
     954                 :          2 :             bOldAutoCalcSrc = pSrcDoc->GetAutoCalc();
     955                 :          2 :             pSrcDoc->SetAutoCalc( true );   // falls was berechnet werden muss
     956                 :            :         }
     957                 :            : 
     958                 :            :         {
     959         [ +  - ]:          4 :             NumFmtMergeHandler aNumFmtMergeHdl(this, pSrcDoc);
     960                 :            : 
     961         [ +  - ]:          4 :             nDestPos = Min(nDestPos, (SCTAB)(GetTableCount() - 1));
     962                 :            :             {   // scope for bulk broadcast
     963         [ +  - ]:          4 :                 ScBulkBroadcast aBulkBroadcast( pBASM);
     964                 :          4 :                 pSrcDoc->maTabs[nSrcPos]->CopyToTable(0, 0, MAXCOL, MAXROW,
     965                 :            :                         ( bResultsOnly ? IDF_ALL & ~IDF_FORMULA : IDF_ALL),
     966 [ +  + ][ +  - ]:          8 :                         false, maTabs[nDestPos] );
                 [ +  - ]
     967         [ +  - ]:          4 :             }
     968                 :            :         }
     969                 :          4 :         maTabs[nDestPos]->SetTabNo(nDestPos);
     970                 :            : 
     971         [ +  + ]:          4 :         if ( !bResultsOnly )
     972                 :            :         {
     973                 :            : 
     974                 :          2 :             SCsTAB nDz = ((SCsTAB)nDestPos) - (SCsTAB)nSrcPos;
     975                 :          2 :             maTabs[nDestPos]->UpdateReference(URM_COPY, 0, 0, nDestPos,
     976                 :            :                                                      MAXCOL, MAXROW, nDestPos,
     977                 :          2 :                                                      0, 0, nDz, NULL);
     978                 :            :             // Readjust self-contained absolute references to this sheet
     979                 :          2 :             maTabs[nDestPos]->TestTabRefAbs(nSrcPos);
     980                 :          2 :             maTabs[nDestPos]->CompileAll();
     981                 :            :         }
     982                 :            : 
     983                 :          4 :         SetNoListening( false );
     984         [ +  + ]:          4 :         if ( !bResultsOnly )
     985                 :          2 :             maTabs[nDestPos]->StartAllListeners();
     986         [ +  - ]:          4 :         SetDirty( ScRange( 0, 0, nDestPos, MAXCOL, MAXROW, nDestPos));
     987                 :            : 
     988         [ +  + ]:          4 :         if ( bResultsOnly )
     989                 :          2 :             pSrcDoc->SetAutoCalc( bOldAutoCalcSrc );
     990                 :          4 :         SetAutoCalc( bOldAutoCalc );
     991                 :            : 
     992                 :            :         //  Drawing kopieren
     993                 :            : 
     994         [ +  + ]:          4 :         if (bInsertNew)
     995                 :          2 :             TransferDrawPage( pSrcDoc, nSrcPos, nDestPos );
     996                 :            : 
     997                 :          4 :         maTabs[nDestPos]->SetPendingRowHeights( pSrcDoc->maTabs[nSrcPos]->IsPendingRowHeights() );
     998                 :            :     }
     999         [ -  + ]:          4 :     if (!bValid)
    1000                 :          0 :         nRetVal = 0;
    1001                 :          4 :     bool bVbaEnabled = IsInVBAMode();
    1002                 :            : 
    1003         [ -  + ]:          4 :     if ( bVbaEnabled  )
    1004                 :            :     {
    1005         [ #  # ]:          0 :         SfxObjectShell* pSrcShell = pSrcDoc ? pSrcDoc->GetDocumentShell() : NULL;
    1006         [ #  # ]:          0 :         if ( pSrcShell )
    1007                 :            :         {
    1008         [ #  # ]:          0 :             rtl::OUString aLibName(RTL_CONSTASCII_USTRINGPARAM("Standard"));
    1009         [ #  # ]:          0 :             const BasicManager *pBasicManager = pSrcShell->GetBasicManager();
    1010 [ #  # ][ #  # ]:          0 :             if (pBasicManager && pBasicManager->GetName().Len() > 0)
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1011 [ #  # ][ #  # ]:          0 :                 aLibName = pSrcShell->GetBasicManager()->GetName();
         [ #  # ][ #  # ]
    1012                 :            : 
    1013                 :          0 :             rtl::OUString sCodeName;
    1014                 :          0 :             rtl::OUString sSource;
    1015         [ #  # ]:          0 :             uno::Reference< script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer();
    1016                 :          0 :             uno::Reference< container::XNameContainer > xLib;
    1017         [ #  # ]:          0 :             if( xLibContainer.is() )
    1018                 :            :             {
    1019 [ #  # ][ #  # ]:          0 :                 uno::Any aLibAny = xLibContainer->getByName(aLibName);
    1020         [ #  # ]:          0 :                 aLibAny >>= xLib;
    1021                 :            :             }
    1022                 :            : 
    1023         [ #  # ]:          0 :             if( xLib.is() )
    1024                 :            :             {
    1025                 :          0 :                 rtl::OUString sSrcCodeName;
    1026         [ #  # ]:          0 :                 pSrcDoc->GetCodeName( nSrcPos, sSrcCodeName );
    1027                 :          0 :                 rtl::OUString sRTLSource;
    1028 [ #  # ][ #  # ]:          0 :                 xLib->getByName( sSrcCodeName ) >>= sRTLSource;
    1029                 :          0 :                 sSource = sRTLSource;
    1030                 :            :             }
    1031         [ #  # ]:          0 :             VBA_InsertModule( *this, nDestPos, sCodeName, sSource );
    1032                 :            :         }
    1033                 :            :     }
    1034                 :            : 
    1035                 :          4 :     return nRetVal;
    1036                 :            : }
    1037                 :            : 
    1038                 :            : //  ----------------------------------------------------------------------------
    1039                 :            : 
    1040                 :          0 : void ScDocument::SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const sal_uInt16 nError)
    1041                 :            : {
    1042 [ #  # ][ #  # ]:          0 :     if (VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
                 [ #  # ]
    1043         [ #  # ]:          0 :         if (maTabs[nTab])
    1044                 :          0 :             maTabs[nTab]->SetError( nCol, nRow, nError );
    1045                 :          0 : }
    1046                 :            : 
    1047                 :            : //  ----------------------------------------------------------------------------
    1048                 :            : 
    1049                 :          1 : void ScDocument::SetConsolidateDlgData( const ScConsolidateParam* pData )
    1050                 :            : {
    1051         [ -  + ]:          1 :     delete pConsolidateDlgData;
    1052                 :            : 
    1053         [ +  - ]:          1 :     if ( pData )
    1054         [ +  - ]:          1 :         pConsolidateDlgData = new ScConsolidateParam( *pData );
    1055                 :            :     else
    1056                 :          0 :         pConsolidateDlgData = NULL;
    1057                 :          1 : }
    1058                 :            : 
    1059                 :          0 : void ScDocument::SetChangeViewSettings(const ScChangeViewSettings& rNew)
    1060                 :            : {
    1061         [ #  # ]:          0 :     if (pChangeViewSettings==NULL)
    1062         [ #  # ]:          0 :         pChangeViewSettings = new ScChangeViewSettings;
    1063                 :            : 
    1064                 :            :     OSL_ENSURE( pChangeViewSettings, "Oops. No ChangeViewSettings :-( by!" );
    1065                 :            : 
    1066                 :          0 :     *pChangeViewSettings=rNew;
    1067                 :          0 : }
    1068                 :            : 
    1069                 :            : //  ----------------------------------------------------------------------------
    1070                 :            : 
    1071                 :       1180 : ScFieldEditEngine* ScDocument::CreateFieldEditEngine()
    1072                 :            : {
    1073                 :       1180 :     ScFieldEditEngine* pNewEditEngine = NULL;
    1074         [ +  + ]:       1180 :     if (!pCacheFieldEditEngine)
    1075                 :            :     {
    1076                 :            :         pNewEditEngine = new ScFieldEditEngine(
    1077         [ +  - ]:        126 :             this, GetEnginePool(), GetEditPool(), false);
    1078                 :            :     }
    1079                 :            :     else
    1080                 :            :     {
    1081         [ +  + ]:       1054 :         if ( !bImportingXML )
    1082                 :            :         {
    1083                 :            :             // #i66209# previous use might not have restored update mode,
    1084                 :            :             // ensure same state as for a new EditEngine (UpdateMode = true)
    1085         [ -  + ]:       1051 :             if ( !pCacheFieldEditEngine->GetUpdateMode() )
    1086                 :          0 :                 pCacheFieldEditEngine->SetUpdateMode(true);
    1087                 :            :         }
    1088                 :            : 
    1089                 :       1054 :         pNewEditEngine = pCacheFieldEditEngine;
    1090                 :       1054 :         pCacheFieldEditEngine = NULL;
    1091                 :            :     }
    1092                 :       1180 :     return pNewEditEngine;
    1093                 :            : }
    1094                 :            : 
    1095                 :       1152 : void ScDocument::DisposeFieldEditEngine(ScFieldEditEngine*& rpEditEngine)
    1096                 :            : {
    1097 [ +  + ][ +  - ]:       1152 :     if (!pCacheFieldEditEngine && rpEditEngine)
    1098                 :            :     {
    1099                 :       1084 :         pCacheFieldEditEngine = rpEditEngine;
    1100                 :       1084 :         pCacheFieldEditEngine->Clear();
    1101                 :            :     }
    1102                 :            :     else
    1103         [ +  + ]:         68 :         delete rpEditEngine;
    1104                 :       1152 :     rpEditEngine = NULL;
    1105                 :       1152 : }
    1106                 :            : 
    1107                 :            : //  ----------------------------------------------------------------------------
    1108                 :            : 
    1109                 :        142 : ScRecursionHelper* ScDocument::CreateRecursionHelperInstance()
    1110                 :            : {
    1111         [ +  - ]:        142 :     return new ScRecursionHelper;
    1112                 :            : }
    1113                 :            : 
    1114                 :            : //  ----------------------------------------------------------------------------
    1115                 :            : 
    1116                 :        144 : ScLookupCache & ScDocument::GetLookupCache( const ScRange & rRange )
    1117                 :            : {
    1118                 :        144 :     ScLookupCache* pCache = 0;
    1119         [ +  + ]:        144 :     if (!pLookupCacheMapImpl)
    1120 [ +  - ][ +  - ]:          3 :         pLookupCacheMapImpl = new ScLookupCacheMapImpl;
    1121         [ +  - ]:        144 :     ScLookupCacheMap::iterator it( pLookupCacheMapImpl->aCacheMap.find( rRange));
    1122 [ +  - ][ +  + ]:        144 :     if (it == pLookupCacheMapImpl->aCacheMap.end())
    1123                 :            :     {
    1124 [ +  - ][ +  - ]:          9 :         pCache = new ScLookupCache( this, rRange);
    1125         [ +  - ]:          9 :         AddLookupCache( *pCache);
    1126                 :            :     }
    1127                 :            :     else
    1128         [ +  - ]:        135 :         pCache = (*it).second;
    1129                 :        144 :     return *pCache;
    1130                 :            : }
    1131                 :            : 
    1132                 :          9 : void ScDocument::AddLookupCache( ScLookupCache & rCache )
    1133                 :            : {
    1134         [ +  - ]:          9 :     if (!pLookupCacheMapImpl->aCacheMap.insert( ::std::pair< const ScRange,
    1135         [ +  - ]:          9 :                 ScLookupCache*>( rCache.getRange(), &rCache)).second)
    1136                 :            :     {
    1137                 :            :         OSL_FAIL( "ScDocument::AddLookupCache: couldn't add to hash map");
    1138                 :            :     }
    1139                 :            :     else
    1140                 :          9 :         StartListeningArea( rCache.getRange(), &rCache);
    1141                 :          9 : }
    1142                 :            : 
    1143                 :          9 : void ScDocument::RemoveLookupCache( ScLookupCache & rCache )
    1144                 :            : {
    1145                 :            :     ScLookupCacheMap::iterator it( pLookupCacheMapImpl->aCacheMap.find(
    1146         [ +  - ]:          9 :                 rCache.getRange()));
    1147 [ +  - ][ +  - ]:          9 :     if (it == pLookupCacheMapImpl->aCacheMap.end())
    1148                 :            :     {
    1149                 :            :         OSL_FAIL( "ScDocument::RemoveLookupCache: range not found in hash map");
    1150                 :            :     }
    1151                 :            :     else
    1152                 :            :     {
    1153         [ +  - ]:          9 :         ScLookupCache* pCache = (*it).second;
    1154         [ +  - ]:          9 :         pLookupCacheMapImpl->aCacheMap.erase( it);
    1155         [ +  - ]:          9 :         EndListeningArea( pCache->getRange(), &rCache);
    1156                 :            :     }
    1157                 :          9 : }
    1158                 :            : 
    1159                 :        205 : void ScDocument::ClearLookupCaches()
    1160                 :            : {
    1161         [ +  + ]:        205 :     if( pLookupCacheMapImpl )
    1162                 :         24 :         pLookupCacheMapImpl->clear();
    1163                 :        205 : }
    1164                 :            : 
    1165                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10