LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - linkuno.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 517 957 54.0 %
Date: 2012-08-25 Functions: 84 166 50.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 617 1987 31.1 %

           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 <svl/smplhint.hxx>
      30                 :            : #include <sfx2/linkmgr.hxx>
      31                 :            : #include <vcl/svapp.hxx>
      32                 :            : 
      33                 :            : #include "linkuno.hxx"
      34                 :            : #include "miscuno.hxx"
      35                 :            : #include "convuno.hxx"
      36                 :            : #include "docsh.hxx"
      37                 :            : #include "docfunc.hxx"
      38                 :            : #include "tablink.hxx"
      39                 :            : #include "arealink.hxx"
      40                 :            : #include "hints.hxx"
      41                 :            : #include "unonames.hxx"
      42                 :            : #include "rangeseq.hxx"
      43                 :            : #include "token.hxx"
      44                 :            : 
      45                 :            : #include <vector>
      46                 :            : #include <climits>
      47                 :            : 
      48                 :            : using namespace com::sun::star;
      49                 :            : using namespace formula;
      50                 :            : using ::com::sun::star::uno::Any;
      51                 :            : using ::com::sun::star::uno::Reference;
      52                 :            : using ::com::sun::star::uno::Sequence;
      53                 :            : using ::com::sun::star::uno::UNO_QUERY;
      54                 :            : using ::com::sun::star::uno::UNO_QUERY_THROW;
      55                 :            : using ::com::sun::star::lang::IllegalArgumentException;
      56                 :            : using ::com::sun::star::uno::RuntimeException;
      57                 :            : using ::rtl::OUString;
      58                 :            : using ::std::vector;
      59                 :            : 
      60                 :            : //------------------------------------------------------------------------
      61                 :            : 
      62                 :            : //  fuer Sheet- und Area-Links benutzt:
      63                 :         10 : const SfxItemPropertyMapEntry* lcl_GetSheetLinkMap()
      64                 :            : {
      65                 :            :     static SfxItemPropertyMapEntry aSheetLinkMap_Impl[] =
      66                 :            :     {
      67         [ +  - ]:          1 :         {MAP_CHAR_LEN(SC_UNONAME_FILTER),   0,  &getCppuType((rtl::OUString*)0),    0, 0 },
      68         [ +  - ]:          1 :         {MAP_CHAR_LEN(SC_UNONAME_FILTOPT),  0,  &getCppuType((rtl::OUString*)0),    0, 0 },
      69         [ +  - ]:          1 :         {MAP_CHAR_LEN(SC_UNONAME_LINKURL),  0,  &getCppuType((rtl::OUString*)0),    0, 0 },
      70         [ +  - ]:          1 :         {MAP_CHAR_LEN(SC_UNONAME_REFDELAY), 0,  &getCppuType((sal_Int32*)0),        0, 0 },
      71         [ +  - ]:          1 :         {MAP_CHAR_LEN(SC_UNONAME_REFPERIOD),    0,  &getCppuType((sal_Int32*)0),        0, 0 },
      72                 :            :         {0,0,0,0,0,0}
      73 [ +  + ][ +  - ]:         11 :     };
                 [ #  # ]
      74                 :         10 :     return aSheetLinkMap_Impl;
      75                 :            : }
      76                 :            : 
      77                 :            : //------------------------------------------------------------------------
      78                 :            : 
      79         [ #  # ]:          1 : SC_SIMPLE_SERVICE_INFO( ScAreaLinkObj, "ScAreaLinkObj", "com.sun.star.sheet.CellAreaLink" )
      80         [ #  # ]:          0 : SC_SIMPLE_SERVICE_INFO( ScAreaLinksObj, "ScAreaLinksObj", "com.sun.star.sheet.CellAreaLinks" )
      81         [ #  # ]:          0 : SC_SIMPLE_SERVICE_INFO( ScDDELinkObj, "ScDDELinkObj", "com.sun.star.sheet.DDELink" )
      82         [ #  # ]:          0 : SC_SIMPLE_SERVICE_INFO( ScDDELinksObj, "ScDDELinksObj", "com.sun.star.sheet.DDELinks" )
      83         [ #  # ]:          0 : SC_SIMPLE_SERVICE_INFO( ScSheetLinkObj, "ScSheetLinkObj", "com.sun.star.sheet.SheetLink" )
      84         [ #  # ]:          0 : SC_SIMPLE_SERVICE_INFO( ScSheetLinksObj, "ScSheetLinksObj", "com.sun.star.sheet.SheetLinks" )
      85                 :            : 
      86                 :            : //------------------------------------------------------------------------
      87                 :            : 
      88                 :          5 : ScSheetLinkObj::ScSheetLinkObj(ScDocShell* pDocSh, const String& rName) :
      89                 :            :     aPropSet( lcl_GetSheetLinkMap() ),
      90                 :            :     pDocShell( pDocSh ),
      91 [ +  - ][ +  - ]:          5 :     aFileName( rName )
         [ +  - ][ +  - ]
                 [ +  - ]
      92                 :            : {
      93         [ +  - ]:          5 :     pDocShell->GetDocument()->AddUnoObject(*this);
      94                 :          5 : }
      95                 :            : 
      96 [ +  - ][ +  - ]:          5 : ScSheetLinkObj::~ScSheetLinkObj()
         [ +  - ][ +  - ]
      97                 :            : {
      98         [ -  + ]:          5 :     if (pDocShell)
      99         [ #  # ]:          0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
     100         [ -  + ]:         10 : }
     101                 :            : 
     102                 :          5 : void ScSheetLinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
     103                 :            : {
     104                 :            :     //! notify if links in document are changed
     105                 :            :     //  UpdateRef is not needed here
     106                 :            : 
     107         [ +  - ]:          5 :     if ( rHint.ISA( SfxSimpleHint ) )
     108                 :            :     {
     109         [ +  - ]:          5 :         if ( ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
     110                 :          5 :             pDocShell = NULL;       // pointer is invalid
     111                 :            :     }
     112         [ #  # ]:          0 :     else if ( rHint.ISA( ScLinkRefreshedHint ) )
     113                 :            :     {
     114                 :          0 :         const ScLinkRefreshedHint& rLH = (const ScLinkRefreshedHint&) rHint;
     115 [ #  # ][ #  # ]:          0 :         if ( rLH.GetLinkType() == SC_LINKREFTYPE_SHEET && rLH.GetUrl() == aFileName )
                 [ #  # ]
     116                 :          0 :             Refreshed_Impl();
     117                 :            :     }
     118                 :          5 : }
     119                 :            : 
     120                 :          0 : ScTableLink* ScSheetLinkObj::GetLink_Impl() const
     121                 :            : {
     122         [ #  # ]:          0 :     if (pDocShell)
     123                 :            :     {
     124                 :          0 :         sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
     125                 :          0 :         sal_uInt16 nCount = pLinkManager->GetLinks().size();
     126         [ #  # ]:          0 :         for (sal_uInt16 i=0; i<nCount; i++)
     127                 :            :         {
     128                 :          0 :             ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
     129         [ #  # ]:          0 :             if (pBase->ISA(ScTableLink))
     130                 :            :             {
     131                 :          0 :                 ScTableLink* pTabLink = (ScTableLink*)pBase;
     132         [ #  # ]:          0 :                 if ( pTabLink->GetFileName().equals(aFileName) )
     133                 :          0 :                     return pTabLink;
     134                 :            :             }
     135                 :            :         }
     136                 :            :     }
     137                 :          0 :     return NULL;    // nicht gefunden
     138                 :            : }
     139                 :            : 
     140                 :            : // XNamed
     141                 :            : 
     142                 :          0 : rtl::OUString SAL_CALL ScSheetLinkObj::getName() throw(uno::RuntimeException)
     143                 :            : {
     144         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     145 [ #  # ][ #  # ]:          0 :     return getFileName();   // Name ist der Dateiname (URL)
     146                 :            : }
     147                 :            : 
     148                 :          0 : void SAL_CALL ScSheetLinkObj::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
     149                 :            : {
     150         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     151 [ #  # ][ #  # ]:          0 :     setFileName(aName);     // Name ist der Dateiname (URL)
     152                 :          0 : }
     153                 :            : 
     154                 :            : // XRefreshable
     155                 :            : 
     156                 :          0 : void SAL_CALL ScSheetLinkObj::refresh() throw(uno::RuntimeException)
     157                 :            : {
     158         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     159         [ #  # ]:          0 :     ScTableLink* pLink = GetLink_Impl();
     160         [ #  # ]:          0 :     if (pLink)
     161 [ #  # ][ #  # ]:          0 :         pLink->Refresh( pLink->GetFileName(), pLink->GetFilterName(), NULL, pLink->GetRefreshDelay() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     162                 :          0 : }
     163                 :            : 
     164                 :          0 : void SAL_CALL ScSheetLinkObj::addRefreshListener(
     165                 :            :                                 const uno::Reference<util::XRefreshListener >& xListener )
     166                 :            :                                                 throw(uno::RuntimeException)
     167                 :            : {
     168         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     169                 :            :     uno::Reference<util::XRefreshListener>* pObj =
     170                 :          0 :             new uno::Reference<util::XRefreshListener>( xListener );
     171         [ #  # ]:          0 :     aRefreshListeners.push_back( pObj );
     172                 :            : 
     173                 :            :     //  hold one additional ref to keep this object alive as long as there are listeners
     174         [ #  # ]:          0 :     if ( aRefreshListeners.size() == 1 )
     175         [ #  # ]:          0 :         acquire();
     176                 :          0 : }
     177                 :            : 
     178                 :          0 : void SAL_CALL ScSheetLinkObj::removeRefreshListener(
     179                 :            :                                 const uno::Reference<util::XRefreshListener >& xListener )
     180                 :            :                                                 throw(uno::RuntimeException)
     181                 :            : {
     182         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     183                 :          0 :     sal_uInt16 nCount = aRefreshListeners.size();
     184         [ #  # ]:          0 :     for ( sal_uInt16 n=nCount; n--; )
     185                 :            :     {
     186         [ #  # ]:          0 :         uno::Reference<util::XRefreshListener>& rObj = aRefreshListeners[n];
     187 [ #  # ][ #  # ]:          0 :         if ( rObj == xListener )
     188                 :            :         {
     189 [ #  # ][ #  # ]:          0 :             aRefreshListeners.erase( aRefreshListeners.begin() + n );
                 [ #  # ]
     190         [ #  # ]:          0 :             if ( aRefreshListeners.empty() )
     191                 :          0 :                 release();                          // release ref for listeners
     192                 :          0 :             break;
     193                 :            :         }
     194         [ #  # ]:          0 :     }
     195                 :          0 : }
     196                 :            : 
     197                 :          0 : void ScSheetLinkObj::Refreshed_Impl()
     198                 :            : {
     199         [ #  # ]:          0 :     lang::EventObject aEvent;
     200         [ #  # ]:          0 :     aEvent.Source.set((cppu::OWeakObject*)this);
     201         [ #  # ]:          0 :     for ( sal_uInt16 n=0; n<aRefreshListeners.size(); n++ )
     202 [ #  # ][ #  # ]:          0 :         aRefreshListeners[n]->refreshed( aEvent );
         [ #  # ][ #  # ]
     203                 :          0 : }
     204                 :            : 
     205                 :          0 : void ScSheetLinkObj::ModifyRefreshDelay_Impl( sal_Int32 nRefresh )
     206                 :            : {
     207                 :          0 :     ScTableLink* pLink = GetLink_Impl();
     208         [ #  # ]:          0 :     if( pLink )
     209                 :          0 :         pLink->SetRefreshDelay( (sal_uLong) nRefresh );
     210                 :          0 : }
     211                 :            : 
     212                 :            : // XPropertySet
     213                 :            : 
     214                 :          0 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSheetLinkObj::getPropertySetInfo()
     215                 :            :                                                         throw(uno::RuntimeException)
     216                 :            : {
     217         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     218                 :            :     static uno::Reference<beans::XPropertySetInfo> aRef(
     219 [ #  # ][ #  # ]:          0 :         new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     220         [ #  # ]:          0 :     return aRef;
     221                 :            : }
     222                 :            : 
     223                 :          0 : void SAL_CALL ScSheetLinkObj::setPropertyValue(
     224                 :            :                         const rtl::OUString& aPropertyName, const uno::Any& aValue )
     225                 :            :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     226                 :            :                         lang::IllegalArgumentException, lang::WrappedTargetException,
     227                 :            :                         uno::RuntimeException)
     228                 :            : {
     229         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     230         [ #  # ]:          0 :     String aNameString(aPropertyName);
     231                 :          0 :     rtl::OUString aValStr;
     232 [ #  # ][ #  # ]:          0 :     if ( aNameString.EqualsAscii( SC_UNONAME_LINKURL ) )
     233                 :            :     {
     234         [ #  # ]:          0 :         if ( aValue >>= aValStr )
     235         [ #  # ]:          0 :             setFileName( aValStr );
     236                 :            :     }
     237 [ #  # ][ #  # ]:          0 :     else if ( aNameString.EqualsAscii( SC_UNONAME_FILTER ) )
     238                 :            :     {
     239         [ #  # ]:          0 :         if ( aValue >>= aValStr )
     240         [ #  # ]:          0 :             setFilter( aValStr );
     241                 :            :     }
     242 [ #  # ][ #  # ]:          0 :     else if ( aNameString.EqualsAscii( SC_UNONAME_FILTOPT ) )
     243                 :            :     {
     244         [ #  # ]:          0 :         if ( aValue >>= aValStr )
     245         [ #  # ]:          0 :             setFilterOptions( aValStr );
     246                 :            :     }
     247 [ #  # ][ #  # ]:          0 :     else if ( aNameString.EqualsAscii( SC_UNONAME_REFPERIOD ) )
     248                 :            :     {
     249                 :          0 :         sal_Int32 nRefresh = 0;
     250         [ #  # ]:          0 :         if ( aValue >>= nRefresh )
     251         [ #  # ]:          0 :             setRefreshDelay( nRefresh );
     252                 :            :     }
     253 [ #  # ][ #  # ]:          0 :     else if ( aNameString.EqualsAscii( SC_UNONAME_REFDELAY ) )
     254                 :            :     {
     255                 :          0 :         sal_Int32 nRefresh = 0;
     256         [ #  # ]:          0 :         if ( aValue >>= nRefresh )
     257         [ #  # ]:          0 :             setRefreshDelay( nRefresh );
     258 [ #  # ][ #  # ]:          0 :     }
     259                 :          0 : }
     260                 :            : 
     261                 :          0 : uno::Any SAL_CALL ScSheetLinkObj::getPropertyValue( const rtl::OUString& aPropertyName )
     262                 :            :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     263                 :            :                         uno::RuntimeException)
     264                 :            : {
     265         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     266         [ #  # ]:          0 :     String aNameString(aPropertyName);
     267                 :          0 :     uno::Any aRet;
     268 [ #  # ][ #  # ]:          0 :     if ( aNameString.EqualsAscii( SC_UNONAME_LINKURL ) )
     269 [ #  # ][ #  # ]:          0 :         aRet <<= getFileName();
     270 [ #  # ][ #  # ]:          0 :     else if ( aNameString.EqualsAscii( SC_UNONAME_FILTER ) )
     271 [ #  # ][ #  # ]:          0 :         aRet <<= getFilter();
     272 [ #  # ][ #  # ]:          0 :     else if ( aNameString.EqualsAscii( SC_UNONAME_FILTOPT ) )
     273 [ #  # ][ #  # ]:          0 :         aRet <<= getFilterOptions();
     274 [ #  # ][ #  # ]:          0 :     else if ( aNameString.EqualsAscii( SC_UNONAME_REFPERIOD ) )
     275 [ #  # ][ #  # ]:          0 :         aRet <<= getRefreshDelay();
     276 [ #  # ][ #  # ]:          0 :     else if ( aNameString.EqualsAscii( SC_UNONAME_REFDELAY ) )
     277 [ #  # ][ #  # ]:          0 :         aRet <<= getRefreshDelay();
     278 [ #  # ][ #  # ]:          0 :     return aRet;
     279                 :            : }
     280                 :            : 
     281                 :          0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSheetLinkObj )
     282                 :            : 
     283                 :            : // internal:
     284                 :            : 
     285                 :          0 : rtl::OUString ScSheetLinkObj::getFileName(void) const
     286                 :            : {
     287         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     288 [ #  # ][ #  # ]:          0 :     return aFileName;
     289                 :            : }
     290                 :            : 
     291                 :          0 : void ScSheetLinkObj::setFileName(const rtl::OUString& rNewName)
     292                 :            : {
     293         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     294         [ #  # ]:          0 :     ScTableLink* pLink = GetLink_Impl();
     295         [ #  # ]:          0 :     if (pLink)
     296                 :            :     {
     297                 :            :         //  pLink->Refresh mit neuem Dateinamen bringt sfx2::LinkManager durcheinander
     298                 :            :         //  darum per Hand die Tabellen umsetzen und Link per UpdateLinks neu erzeugen
     299                 :            : 
     300 [ #  # ][ #  # ]:          0 :         String aNewStr(ScGlobal::GetAbsDocName( String(rNewName), pDocShell ));
                 [ #  # ]
     301                 :            : 
     302                 :            :         //  zuerst Tabellen umsetzen
     303                 :            : 
     304                 :          0 :         ScDocument* pDoc = pDocShell->GetDocument();
     305         [ #  # ]:          0 :         SCTAB nTabCount = pDoc->GetTableCount();
     306         [ #  # ]:          0 :         for (SCTAB nTab=0; nTab<nTabCount; nTab++)
     307 [ #  # ][ #  # ]:          0 :             if ( pDoc->IsLinked(nTab) && pDoc->GetLinkDoc(nTab) == rtl::OUString(aFileName) )  // alte Datei
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
     308         [ #  # ]:          0 :                 pDoc->SetLink( nTab, pDoc->GetLinkMode(nTab), aNewStr,
     309                 :            :                                 pDoc->GetLinkFlt(nTab), pDoc->GetLinkOpt(nTab),
     310                 :            :                                 pDoc->GetLinkTab(nTab),
     311 [ #  # ][ #  # ]:          0 :                                 pDoc->GetLinkRefreshDelay(nTab) );  // nur Datei aendern
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     312                 :            : 
     313                 :            :         //  Links updaten
     314                 :            :         //! Undo !!!
     315                 :            : 
     316                 :          0 :         pLink = NULL;               // wird bei UpdateLinks ungueltig
     317         [ #  # ]:          0 :         pDocShell->UpdateLinks();   // alter Link raus, evtl. neuen Link anlegen
     318                 :            : 
     319                 :            :         //  Daten kopieren
     320                 :            : 
     321         [ #  # ]:          0 :         aFileName = aNewStr;
     322         [ #  # ]:          0 :         pLink = GetLink_Impl();     // neuer Link mit neuem Namen
     323         [ #  # ]:          0 :         if (pLink)
     324 [ #  # ][ #  # ]:          0 :             pLink->Update();        // inkl. Paint & Undo fuer Daten
     325         [ #  # ]:          0 :     }
     326                 :          0 : }
     327                 :            : 
     328                 :          0 : rtl::OUString ScSheetLinkObj::getFilter(void) const
     329                 :            : {
     330         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     331                 :          0 :     rtl::OUString aRet;
     332         [ #  # ]:          0 :     ScTableLink* pLink = GetLink_Impl();
     333         [ #  # ]:          0 :     if (pLink)
     334                 :          0 :         aRet = pLink->GetFilterName();
     335         [ #  # ]:          0 :     return aRet;
     336                 :            : }
     337                 :            : 
     338                 :          0 : void ScSheetLinkObj::setFilter(const rtl::OUString& Filter)
     339                 :            : {
     340         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     341         [ #  # ]:          0 :     ScTableLink* pLink = GetLink_Impl();
     342         [ #  # ]:          0 :     if (pLink)
     343                 :            :     {
     344         [ #  # ]:          0 :         String aFilterStr(Filter);
     345 [ #  # ][ #  # ]:          0 :         pLink->Refresh( aFileName, aFilterStr, NULL, pLink->GetRefreshDelay() );
     346         [ #  # ]:          0 :     }
     347                 :          0 : }
     348                 :            : 
     349                 :          0 : rtl::OUString ScSheetLinkObj::getFilterOptions(void) const
     350                 :            : {
     351         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     352                 :          0 :     rtl::OUString aRet;
     353         [ #  # ]:          0 :     ScTableLink* pLink = GetLink_Impl();
     354         [ #  # ]:          0 :     if (pLink)
     355                 :          0 :         aRet = pLink->GetOptions();
     356         [ #  # ]:          0 :     return aRet;
     357                 :            : }
     358                 :            : 
     359                 :          0 : void ScSheetLinkObj::setFilterOptions(const rtl::OUString& FilterOptions)
     360                 :            : {
     361         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     362         [ #  # ]:          0 :     ScTableLink* pLink = GetLink_Impl();
     363         [ #  # ]:          0 :     if (pLink)
     364                 :            :     {
     365         [ #  # ]:          0 :         String aOptStr(FilterOptions);
     366 [ #  # ][ #  # ]:          0 :         pLink->Refresh( aFileName, pLink->GetFilterName(), &aOptStr, pLink->GetRefreshDelay() );
         [ #  # ][ #  # ]
     367         [ #  # ]:          0 :     }
     368                 :          0 : }
     369                 :            : 
     370                 :          0 : sal_Int32 ScSheetLinkObj::getRefreshDelay(void) const
     371                 :            : {
     372         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     373                 :          0 :     sal_Int32 nRet = 0;
     374         [ #  # ]:          0 :     ScTableLink* pLink = GetLink_Impl();
     375         [ #  # ]:          0 :     if (pLink)
     376                 :          0 :         nRet = (sal_Int32) pLink->GetRefreshDelay();
     377         [ #  # ]:          0 :     return nRet;
     378                 :            : }
     379                 :            : 
     380                 :          0 : void ScSheetLinkObj::setRefreshDelay(sal_Int32 nRefreshDelay)
     381                 :            : {
     382         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     383 [ #  # ][ #  # ]:          0 :     ModifyRefreshDelay_Impl( nRefreshDelay );
     384                 :          0 : }
     385                 :            : 
     386                 :            : //------------------------------------------------------------------------
     387                 :            : 
     388                 :          6 : ScSheetLinksObj::ScSheetLinksObj(ScDocShell* pDocSh) :
     389         [ +  - ]:          6 :     pDocShell( pDocSh )
     390                 :            : {
     391         [ +  - ]:          6 :     pDocShell->GetDocument()->AddUnoObject(*this);
     392                 :          6 : }
     393                 :            : 
     394         [ +  - ]:          6 : ScSheetLinksObj::~ScSheetLinksObj()
     395                 :            : {
     396         [ -  + ]:          6 :     if (pDocShell)
     397         [ #  # ]:          0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
     398         [ -  + ]:         12 : }
     399                 :            : 
     400                 :        146 : void ScSheetLinksObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
     401                 :            : {
     402                 :            :     //  Referenz-Update interessiert hier nicht
     403                 :            : 
     404   [ +  -  +  + ]:        292 :     if ( rHint.ISA( SfxSimpleHint ) &&
                 [ +  + ]
     405                 :        146 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
     406                 :            :     {
     407                 :          6 :         pDocShell = NULL;       // ungueltig geworden
     408                 :            :     }
     409                 :        146 : }
     410                 :            : 
     411                 :            : // XSheetLinks
     412                 :            : 
     413                 :          6 : ScSheetLinkObj* ScSheetLinksObj::GetObjectByIndex_Impl(sal_Int32 nIndex)
     414                 :            : {
     415         [ -  + ]:          6 :     if (!pDocShell)
     416                 :          0 :         return NULL;
     417                 :            : 
     418                 :            :     typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> StrSetType;
     419         [ +  - ]:          6 :     StrSetType aNames;
     420                 :          6 :     ScDocument* pDoc = pDocShell->GetDocument();
     421         [ +  - ]:          6 :     SCTAB nTabCount = pDoc->GetTableCount();
     422                 :          6 :     sal_Int32 nCount = 0;
     423         [ +  + ]:          8 :     for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
     424                 :            :     {
     425 [ +  - ][ -  + ]:          6 :         if (!pDoc->IsLinked(nTab))
     426                 :          0 :             continue;
     427                 :            : 
     428         [ +  - ]:          6 :         rtl::OUString aLinkDoc = pDoc->GetLinkDoc(nTab);
     429 [ +  - ][ +  - ]:          6 :         if (aNames.insert(aLinkDoc).second)
     430                 :            :         {
     431                 :            :             // unique document name.
     432         [ +  + ]:          6 :             if (nCount == nIndex)
     433 [ +  - ][ +  - ]:          4 :                 return new ScSheetLinkObj( pDocShell, aLinkDoc );
                 [ +  - ]
     434                 :          2 :             ++nCount;
     435                 :            :         }
     436         [ +  + ]:          6 :     }
     437                 :            : 
     438         [ +  - ]:          6 :     return NULL;    // kein Dokument oder Index zu gross
     439                 :            : }
     440                 :            : 
     441                 :          2 : ScSheetLinkObj* ScSheetLinksObj::GetObjectByName_Impl(const rtl::OUString& aName)
     442                 :            : {
     443                 :            :     //  Name ist der Dateiname
     444                 :            : 
     445         [ +  - ]:          2 :     if (pDocShell)
     446                 :            :     {
     447         [ +  - ]:          2 :         String aNameStr(aName);
     448                 :            : 
     449                 :          2 :         ScDocument* pDoc = pDocShell->GetDocument();
     450         [ +  - ]:          2 :         SCTAB nTabCount = pDoc->GetTableCount();
     451         [ +  + ]:          3 :         for (SCTAB nTab=0; nTab<nTabCount; nTab++)
     452 [ +  - ][ +  - ]:          2 :             if (pDoc->IsLinked(nTab))
     453                 :            :             {
     454                 :            :                 //! case-insensitiv ???
     455 [ +  - ][ +  - ]:          2 :                 String aLinkDoc = pDoc->GetLinkDoc( nTab );
     456 [ +  + ][ +  - ]:          2 :                 if ( aLinkDoc == aNameStr )
     457 [ +  - ][ +  - ]:          2 :                     return new ScSheetLinkObj( pDocShell, aNameStr );
                 [ +  + ]
     458 [ +  - ][ +  + ]:          2 :             }
     459                 :            :     }
     460                 :            : 
     461                 :          2 :     return NULL;
     462                 :            : }
     463                 :            : 
     464                 :            : // XEnumerationAccess
     465                 :            : 
     466                 :          2 : uno::Reference<container::XEnumeration> SAL_CALL ScSheetLinksObj::createEnumeration()
     467                 :            :                                                     throw(uno::RuntimeException)
     468                 :            : {
     469         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     470 [ +  - ][ +  - ]:          2 :     return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SheetLinksEnumeration")));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     471                 :            : }
     472                 :            : 
     473                 :            : // XIndexAccess
     474                 :            : 
     475                 :          5 : sal_Int32 SAL_CALL ScSheetLinksObj::getCount() throw(uno::RuntimeException)
     476                 :            : {
     477                 :            :     typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> StrSetType;
     478                 :            : 
     479         [ +  - ]:          5 :     SolarMutexGuard aGuard;
     480         [ -  + ]:          5 :     if (!pDocShell)
     481                 :          0 :         return 0;
     482                 :            : 
     483                 :          5 :     sal_Int32 nCount = 0;
     484                 :            : 
     485         [ +  - ]:          5 :     StrSetType aNames;
     486                 :          5 :     ScDocument* pDoc = pDocShell->GetDocument();
     487         [ +  - ]:          5 :     SCTAB nTabCount = pDoc->GetTableCount();
     488         [ +  + ]:         10 :     for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
     489                 :            :     {
     490 [ +  - ][ -  + ]:          5 :         if (!pDoc->IsLinked(nTab))
     491                 :          0 :             continue;
     492                 :            : 
     493         [ +  - ]:          5 :         rtl::OUString aLinkDoc = pDoc->GetLinkDoc(nTab);
     494 [ +  - ][ +  - ]:          5 :         if (aNames.insert(aLinkDoc).second)
     495                 :          5 :             ++nCount;
     496                 :          5 :     }
     497 [ +  - ][ +  - ]:          5 :     return nCount;
     498                 :            : }
     499                 :            : 
     500                 :          6 : uno::Any SAL_CALL ScSheetLinksObj::getByIndex( sal_Int32 nIndex )
     501                 :            :                             throw(lang::IndexOutOfBoundsException,
     502                 :            :                                     lang::WrappedTargetException, uno::RuntimeException)
     503                 :            : {
     504         [ +  - ]:          6 :     SolarMutexGuard aGuard;
     505 [ +  - ][ +  + ]:          6 :     uno::Reference<beans::XPropertySet> xLink(GetObjectByIndex_Impl(nIndex));
                 [ +  - ]
     506         [ +  + ]:          6 :     if (xLink.is())
     507         [ +  - ]:          8 :         return uno::makeAny(xLink);
     508                 :            :     else
     509 [ +  - ][ +  - ]:          6 :         throw lang::IndexOutOfBoundsException();
     510                 :            : }
     511                 :            : 
     512                 :          1 : uno::Type SAL_CALL ScSheetLinksObj::getElementType() throw(uno::RuntimeException)
     513                 :            : {
     514         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     515 [ +  - ][ +  - ]:          1 :     return getCppuType((uno::Reference<beans::XPropertySet>*)0);
     516                 :            : }
     517                 :            : 
     518                 :          1 : sal_Bool SAL_CALL ScSheetLinksObj::hasElements() throw(uno::RuntimeException)
     519                 :            : {
     520         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     521 [ +  - ][ +  - ]:          1 :     return ( getCount() != 0 );
     522                 :            : }
     523                 :            : 
     524                 :          2 : uno::Any SAL_CALL ScSheetLinksObj::getByName( const rtl::OUString& aName )
     525                 :            :             throw(container::NoSuchElementException,
     526                 :            :                     lang::WrappedTargetException, uno::RuntimeException)
     527                 :            : {
     528         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     529 [ +  - ][ +  + ]:          2 :     uno::Reference<beans::XPropertySet> xLink(GetObjectByName_Impl(aName));
                 [ +  - ]
     530         [ +  + ]:          2 :     if (xLink.is())
     531         [ +  - ]:          2 :         return uno::makeAny(xLink);
     532                 :            :     else
     533 [ +  - ][ +  - ]:          2 :         throw container::NoSuchElementException();
     534                 :            : //    return uno::Any();
     535                 :            : }
     536                 :            : 
     537                 :          2 : sal_Bool SAL_CALL ScSheetLinksObj::hasByName( const rtl::OUString& aName )
     538                 :            :                                         throw(uno::RuntimeException)
     539                 :            : {
     540         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     541                 :            :     //  Name ist der Dateiname
     542                 :            : 
     543         [ +  - ]:          2 :     if (pDocShell)
     544                 :            :     {
     545         [ +  - ]:          2 :         String aNameStr(aName);
     546                 :            : 
     547                 :          2 :         ScDocument* pDoc = pDocShell->GetDocument();
     548         [ +  - ]:          2 :         SCTAB nTabCount = pDoc->GetTableCount();
     549         [ +  + ]:          3 :         for (SCTAB nTab=0; nTab<nTabCount; nTab++)
     550 [ +  - ][ +  - ]:          2 :             if (pDoc->IsLinked(nTab))
     551                 :            :             {
     552                 :            :                 //! case-insensitiv ???
     553 [ +  - ][ +  - ]:          2 :                 String aLinkDoc(pDoc->GetLinkDoc( nTab ));
     554 [ +  + ][ +  - ]:          2 :                 if ( aLinkDoc == aNameStr )
     555 [ +  - ][ +  + ]:          2 :                     return sal_True;
     556 [ +  - ][ +  + ]:          2 :             }
     557                 :            :     }
     558         [ +  - ]:          2 :     return false;
     559                 :            : }
     560                 :            : 
     561                 :          1 : uno::Sequence<rtl::OUString> SAL_CALL ScSheetLinksObj::getElementNames() throw(uno::RuntimeException)
     562                 :            : {
     563                 :            :     typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> StrSetType;
     564                 :            : 
     565         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     566                 :            :     //  Name ist der Dateiname
     567                 :            : 
     568         [ -  + ]:          1 :     if (!pDocShell)
     569         [ #  # ]:          0 :         return uno::Sequence<rtl::OUString>();
     570                 :            : 
     571         [ +  - ]:          1 :     StrSetType aNames;
     572                 :          1 :     ScDocument* pDoc = pDocShell->GetDocument();
     573         [ +  - ]:          1 :     SCTAB nTabCount = pDoc->GetTableCount();
     574                 :            : 
     575         [ +  - ]:          1 :     sal_Int32 nLinkCount = getCount();
     576         [ +  - ]:          1 :     uno::Sequence<rtl::OUString> aSeq(nLinkCount);
     577         [ +  - ]:          1 :     rtl::OUString* pAry = aSeq.getArray();
     578                 :          1 :     sal_uInt16 nPos = 0;
     579         [ +  + ]:          2 :     for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
     580                 :            :     {
     581 [ +  - ][ -  + ]:          1 :         if (!pDoc->IsLinked(nTab))
     582                 :          0 :             continue;
     583                 :            : 
     584         [ +  - ]:          1 :         rtl::OUString aLinkDoc = pDoc->GetLinkDoc(nTab);
     585 [ +  - ][ +  - ]:          1 :         if (aNames.insert(aLinkDoc).second)
     586                 :          1 :             pAry[nPos++] = aLinkDoc;
     587                 :          1 :     }
     588                 :            :     OSL_ENSURE( nPos==nLinkCount, "verzaehlt" );
     589 [ +  - ][ +  - ]:          1 :     return aSeq;
         [ +  - ][ +  - ]
     590                 :            : }
     591                 :            : 
     592                 :            : //------------------------------------------------------------------------
     593                 :            : 
     594                 :         61 : ScAreaLink* lcl_GetAreaLink( ScDocShell* pDocShell, sal_uInt16 nPos )
     595                 :            : {
     596         [ +  - ]:         61 :     if (pDocShell)
     597                 :            :     {
     598                 :         61 :         sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
     599                 :         61 :         sal_uInt16 nTotalCount = pLinkManager->GetLinks().size();
     600                 :         61 :         sal_uInt16 nAreaCount = 0;
     601         [ +  - ]:         61 :         for (sal_uInt16 i=0; i<nTotalCount; i++)
     602                 :            :         {
     603                 :         61 :             ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
     604         [ +  - ]:         61 :             if (pBase->ISA(ScAreaLink))
     605                 :            :             {
     606         [ +  - ]:         61 :                 if ( nAreaCount == nPos )
     607                 :         61 :                     return (ScAreaLink*)pBase;
     608                 :          0 :                 ++nAreaCount;
     609                 :            :             }
     610                 :            :         }
     611                 :            :     }
     612                 :         61 :     return NULL;    // nicht gefunden
     613                 :            : }
     614                 :            : 
     615                 :          5 : ScAreaLinkObj::ScAreaLinkObj(ScDocShell* pDocSh, sal_uInt16 nP) :
     616                 :            :     aPropSet( lcl_GetSheetLinkMap() ),
     617                 :            :     pDocShell( pDocSh ),
     618 [ +  - ][ +  - ]:          5 :     nPos( nP )
         [ +  - ][ +  - ]
     619                 :            : {
     620         [ +  - ]:          5 :     pDocShell->GetDocument()->AddUnoObject(*this);
     621                 :          5 : }
     622                 :            : 
     623 [ +  - ][ +  - ]:          5 : ScAreaLinkObj::~ScAreaLinkObj()
                 [ +  - ]
     624                 :            : {
     625         [ -  + ]:          5 :     if (pDocShell)
     626         [ #  # ]:          0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
     627         [ -  + ]:         10 : }
     628                 :            : 
     629                 :          7 : void ScAreaLinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
     630                 :            : {
     631                 :            :     //! notify if links in document are changed
     632                 :            :     //  UpdateRef is not needed here
     633                 :            : 
     634         [ +  + ]:          7 :     if ( rHint.ISA( SfxSimpleHint ) )
     635                 :            :     {
     636         [ +  + ]:          6 :         if ( ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
     637                 :          5 :             pDocShell = NULL;       // pointer is invalid
     638                 :            :     }
     639         [ +  - ]:          1 :     else if ( rHint.ISA( ScLinkRefreshedHint ) )
     640                 :            :     {
     641                 :          1 :         const ScLinkRefreshedHint& rLH = (const ScLinkRefreshedHint&) rHint;
     642         [ +  - ]:          1 :         if ( rLH.GetLinkType() == SC_LINKREFTYPE_AREA )
     643                 :            :         {
     644                 :            :             //  get this link to compare dest position
     645                 :          1 :             ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
     646 [ +  - ][ +  - ]:          1 :             if ( pLink && pLink->GetDestArea().aStart == rLH.GetDestPos() )
                 [ +  - ]
     647                 :          1 :                 Refreshed_Impl();
     648                 :            :         }
     649                 :            :     }
     650                 :          7 : }
     651                 :            : 
     652                 :            : // XFileLink
     653                 :            : 
     654                 :         13 : void ScAreaLinkObj::Modify_Impl( const rtl::OUString* pNewFile, const rtl::OUString* pNewFilter,
     655                 :            :                                  const rtl::OUString* pNewOptions, const rtl::OUString* pNewSource,
     656                 :            :                                  const table::CellRangeAddress* pNewDest )
     657                 :            : {
     658                 :         13 :     ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
     659         [ +  - ]:         13 :     if (pLink)
     660                 :            :     {
     661         [ +  - ]:         13 :         String aFile    (pLink->GetFile());
     662         [ +  - ]:         13 :         String aFilter  (pLink->GetFilter());
     663         [ +  - ]:         13 :         String aOptions (pLink->GetOptions());
     664         [ +  - ]:         13 :         String aSource  (pLink->GetSource());
     665                 :         13 :         ScRange aDest   (pLink->GetDestArea());
     666                 :         13 :         sal_uLong nRefresh  = pLink->GetRefreshDelay();
     667                 :            : 
     668                 :            :         //! Undo fuer Loeschen
     669                 :            :         //! Undo zusammenfassen
     670                 :            : 
     671         [ +  - ]:         13 :         sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
     672         [ +  - ]:         13 :         pLinkManager->Remove( pLink );
     673                 :         13 :         pLink = NULL;   // bei Remove geloescht
     674                 :            : 
     675                 :         13 :         sal_Bool bFitBlock = sal_True;          // verschieben, wenn durch Update Groesse geaendert
     676         [ +  + ]:         13 :         if (pNewFile)
     677                 :            :         {
     678 [ +  - ][ +  - ]:          3 :             aFile = String( *pNewFile );
                 [ +  - ]
     679 [ +  - ][ +  - ]:          3 :             aFile = ScGlobal::GetAbsDocName( aFile, pDocShell );    //! in InsertAreaLink?
                 [ +  - ]
     680                 :            :         }
     681         [ +  + ]:         13 :         if (pNewFilter)
     682 [ +  - ][ +  - ]:          3 :             aFilter = String( *pNewFilter );
                 [ +  - ]
     683         [ +  + ]:         13 :         if (pNewOptions)
     684 [ +  - ][ +  - ]:          3 :             aOptions = String( *pNewOptions );
                 [ +  - ]
     685         [ +  + ]:         13 :         if (pNewSource)
     686 [ +  - ][ +  - ]:          2 :             aSource = String( *pNewSource );
                 [ +  - ]
     687         [ +  + ]:         13 :         if (pNewDest)
     688                 :            :         {
     689                 :          2 :             ScUnoConversion::FillScRange( aDest, *pNewDest );
     690                 :          2 :             bFitBlock = false;  // neuer Bereich angegeben -> keine Inhalte verschieben
     691                 :            :         }
     692                 :         13 :         pDocShell->GetDocFunc().InsertAreaLink( aFile, aFilter, aOptions, aSource,
     693 [ +  - ][ +  - ]:         13 :                                                 aDest, nRefresh, bFitBlock, sal_True );
         [ +  - ][ +  - ]
                 [ +  - ]
     694                 :            :     }
     695                 :         13 : }
     696                 :            : 
     697                 :          6 : void ScAreaLinkObj::ModifyRefreshDelay_Impl( sal_Int32 nRefresh )
     698                 :            : {
     699                 :          6 :     ScAreaLink* pLink = lcl_GetAreaLink( pDocShell, nPos );
     700         [ +  - ]:          6 :     if( pLink )
     701                 :          6 :         pLink->SetRefreshDelay( (sal_uLong) nRefresh );
     702                 :          6 : }
     703                 :            : 
     704                 :            : // XRefreshable
     705                 :            : 
     706                 :          0 : void SAL_CALL ScAreaLinkObj::refresh() throw(uno::RuntimeException)
     707                 :            : {
     708         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     709         [ #  # ]:          0 :     ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
     710         [ #  # ]:          0 :     if (pLink)
     711 [ #  # ][ #  # ]:          0 :         pLink->Refresh( pLink->GetFile(), pLink->GetFilter(), pLink->GetSource(), pLink->GetRefreshDelay() );
     712                 :          0 : }
     713                 :            : 
     714                 :          0 : void SAL_CALL ScAreaLinkObj::addRefreshListener(
     715                 :            :                                 const uno::Reference<util::XRefreshListener >& xListener )
     716                 :            :                                                 throw(uno::RuntimeException)
     717                 :            : {
     718         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     719                 :            :     uno::Reference<util::XRefreshListener>* pObj =
     720                 :          0 :             new uno::Reference<util::XRefreshListener>( xListener );
     721         [ #  # ]:          0 :     aRefreshListeners.push_back( pObj );
     722                 :            : 
     723                 :            :     //  hold one additional ref to keep this object alive as long as there are listeners
     724         [ #  # ]:          0 :     if ( aRefreshListeners.size() == 1 )
     725         [ #  # ]:          0 :         acquire();
     726                 :          0 : }
     727                 :            : 
     728                 :          0 : void SAL_CALL ScAreaLinkObj::removeRefreshListener(
     729                 :            :                                 const uno::Reference<util::XRefreshListener >& xListener )
     730                 :            :                                                 throw(uno::RuntimeException)
     731                 :            : {
     732         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     733                 :          0 :     sal_uInt16 nCount = aRefreshListeners.size();
     734         [ #  # ]:          0 :     for ( sal_uInt16 n=nCount; n--; )
     735                 :            :     {
     736         [ #  # ]:          0 :         uno::Reference<util::XRefreshListener>& rObj = aRefreshListeners[n];
     737 [ #  # ][ #  # ]:          0 :         if ( rObj == xListener )
     738                 :            :         {
     739 [ #  # ][ #  # ]:          0 :             aRefreshListeners.erase( aRefreshListeners.begin() + n );
                 [ #  # ]
     740         [ #  # ]:          0 :             if ( aRefreshListeners.empty() )
     741                 :          0 :                 release();                          // release ref for listeners
     742                 :          0 :             break;
     743                 :            :         }
     744         [ #  # ]:          0 :     }
     745                 :          0 : }
     746                 :            : 
     747                 :          1 : void ScAreaLinkObj::Refreshed_Impl()
     748                 :            : {
     749         [ +  - ]:          1 :     lang::EventObject aEvent;
     750         [ +  - ]:          1 :     aEvent.Source.set((cppu::OWeakObject*)this);
     751         [ -  + ]:          1 :     for ( sal_uInt16 n=0; n<aRefreshListeners.size(); n++ )
     752 [ #  # ][ #  # ]:          1 :         aRefreshListeners[n]->refreshed( aEvent );
         [ #  # ][ +  - ]
     753                 :          1 : }
     754                 :            : 
     755                 :            : // XPropertySet
     756                 :            : 
     757                 :         11 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAreaLinkObj::getPropertySetInfo()
     758                 :            :                                                         throw(uno::RuntimeException)
     759                 :            : {
     760         [ +  - ]:         11 :     SolarMutexGuard aGuard;
     761                 :            :     static uno::Reference<beans::XPropertySetInfo> aRef(
     762 [ +  + ][ +  - ]:         11 :         new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
     763         [ +  - ]:         11 :     return aRef;
     764                 :            : }
     765                 :            : 
     766                 :         15 : void SAL_CALL ScAreaLinkObj::setPropertyValue(
     767                 :            :                         const rtl::OUString& aPropertyName, const uno::Any& aValue )
     768                 :            :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     769                 :            :                         lang::IllegalArgumentException, lang::WrappedTargetException,
     770                 :            :                         uno::RuntimeException)
     771                 :            : {
     772         [ +  - ]:         15 :     SolarMutexGuard aGuard;
     773         [ +  - ]:         15 :     String aNameString(aPropertyName);
     774                 :         15 :     rtl::OUString aValStr;
     775 [ +  + ][ +  - ]:         15 :     if ( aNameString.EqualsAscii( SC_UNONAME_LINKURL ) )
     776                 :            :     {
     777         [ +  - ]:          3 :         if ( aValue >>= aValStr )
     778         [ +  - ]:          3 :             setFileName( aValStr );
     779                 :            :     }
     780 [ +  - ][ +  + ]:         12 :     else if ( aNameString.EqualsAscii( SC_UNONAME_FILTER ) )
     781                 :            :     {
     782         [ +  - ]:          3 :         if ( aValue >>= aValStr )
     783         [ +  - ]:          3 :             setFilter( aValStr );
     784                 :            :     }
     785 [ +  - ][ +  + ]:          9 :     else if ( aNameString.EqualsAscii( SC_UNONAME_FILTOPT ) )
     786                 :            :     {
     787         [ +  - ]:          3 :         if ( aValue >>= aValStr )
     788         [ +  - ]:          3 :             setFilterOptions( aValStr );
     789                 :            :     }
     790 [ +  - ][ +  + ]:          6 :     else if ( aNameString.EqualsAscii( SC_UNONAME_REFPERIOD ) )
     791                 :            :     {
     792                 :          3 :         sal_Int32 nRefresh = 0;
     793         [ +  - ]:          3 :         if ( aValue >>= nRefresh )
     794         [ +  - ]:          3 :             setRefreshDelay( nRefresh );
     795                 :            :     }
     796 [ +  - ][ +  - ]:          3 :     else if ( aNameString.EqualsAscii( SC_UNONAME_REFDELAY ) )
     797                 :            :     {
     798                 :          3 :         sal_Int32 nRefresh = 0;
     799         [ +  - ]:          3 :         if ( aValue >>= nRefresh )
     800         [ +  - ]:          3 :             setRefreshDelay( nRefresh );
     801 [ +  - ][ +  - ]:         15 :     }
     802                 :         15 : }
     803                 :            : 
     804                 :         35 : uno::Any SAL_CALL ScAreaLinkObj::getPropertyValue( const rtl::OUString& aPropertyName )
     805                 :            :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     806                 :            :                         uno::RuntimeException)
     807                 :            : {
     808         [ +  - ]:         35 :     SolarMutexGuard aGuard;
     809         [ +  - ]:         35 :     String aNameString(aPropertyName);
     810                 :         35 :     uno::Any aRet;
     811 [ +  + ][ +  - ]:         35 :     if ( aNameString.EqualsAscii( SC_UNONAME_LINKURL ) )
     812 [ +  - ][ +  - ]:          7 :         aRet <<= getFileName();
     813 [ +  - ][ +  + ]:         28 :     else if ( aNameString.EqualsAscii( SC_UNONAME_FILTER ) )
     814 [ +  - ][ +  - ]:          7 :         aRet <<= getFilter();
     815 [ +  - ][ +  + ]:         21 :     else if ( aNameString.EqualsAscii( SC_UNONAME_FILTOPT ) )
     816 [ +  - ][ +  - ]:          7 :         aRet <<= getFilterOptions();
     817 [ +  - ][ +  + ]:         14 :     else if ( aNameString.EqualsAscii( SC_UNONAME_REFPERIOD ) )
     818 [ +  - ][ +  - ]:          7 :         aRet <<= getRefreshDelay();
     819 [ +  - ][ +  - ]:          7 :     else if ( aNameString.EqualsAscii( SC_UNONAME_REFDELAY ) )
     820 [ +  - ][ +  - ]:          7 :         aRet <<= getRefreshDelay();
     821 [ +  - ][ +  - ]:         35 :     return aRet;
     822                 :            : }
     823                 :            : 
     824                 :          0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScAreaLinkObj )
     825                 :            : 
     826                 :            : //  internal:
     827                 :            : 
     828                 :          7 : rtl::OUString ScAreaLinkObj::getFileName(void) const
     829                 :            : {
     830         [ +  - ]:          7 :     SolarMutexGuard aGuard;
     831                 :          7 :     rtl::OUString aRet;
     832         [ +  - ]:          7 :     ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
     833         [ +  - ]:          7 :     if (pLink)
     834         [ +  - ]:          7 :         aRet = pLink->GetFile();
     835         [ +  - ]:          7 :     return aRet;
     836                 :            : }
     837                 :            : 
     838                 :          3 : void ScAreaLinkObj::setFileName(const rtl::OUString& rNewName)
     839                 :            : {
     840         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     841 [ +  - ][ +  - ]:          3 :     Modify_Impl( &rNewName, NULL, NULL, NULL, NULL );
     842                 :          3 : }
     843                 :            : 
     844                 :          7 : rtl::OUString ScAreaLinkObj::getFilter(void) const
     845                 :            : {
     846         [ +  - ]:          7 :     SolarMutexGuard aGuard;
     847                 :          7 :     rtl::OUString aRet;
     848         [ +  - ]:          7 :     ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
     849         [ +  - ]:          7 :     if (pLink)
     850         [ +  - ]:          7 :         aRet = pLink->GetFilter();
     851         [ +  - ]:          7 :     return aRet;
     852                 :            : }
     853                 :            : 
     854                 :          3 : void ScAreaLinkObj::setFilter(const rtl::OUString& Filter)
     855                 :            : {
     856         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     857 [ +  - ][ +  - ]:          3 :     Modify_Impl( NULL, &Filter, NULL, NULL, NULL );
     858                 :          3 : }
     859                 :            : 
     860                 :          7 : rtl::OUString ScAreaLinkObj::getFilterOptions(void) const
     861                 :            : {
     862         [ +  - ]:          7 :     SolarMutexGuard aGuard;
     863                 :          7 :     rtl::OUString aRet;
     864         [ +  - ]:          7 :     ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
     865         [ +  - ]:          7 :     if (pLink)
     866         [ +  - ]:          7 :         aRet = pLink->GetOptions();
     867         [ +  - ]:          7 :     return aRet;
     868                 :            : }
     869                 :            : 
     870                 :          3 : void ScAreaLinkObj::setFilterOptions(const rtl::OUString& FilterOptions)
     871                 :            : {
     872         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     873 [ +  - ][ +  - ]:          3 :     Modify_Impl( NULL, NULL, &FilterOptions, NULL, NULL );
     874                 :          3 : }
     875                 :            : 
     876                 :         14 : sal_Int32 ScAreaLinkObj::getRefreshDelay(void) const
     877                 :            : {
     878         [ +  - ]:         14 :     SolarMutexGuard aGuard;
     879                 :         14 :     sal_Int32 nRet = 0;
     880         [ +  - ]:         14 :     ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
     881         [ +  - ]:         14 :     if (pLink)
     882                 :         14 :         nRet = (sal_Int32) pLink->GetRefreshDelay();
     883         [ +  - ]:         14 :     return nRet;
     884                 :            : }
     885                 :            : 
     886                 :          6 : void ScAreaLinkObj::setRefreshDelay(sal_Int32 nRefreshDelay)
     887                 :            : {
     888         [ +  - ]:          6 :     SolarMutexGuard aGuard;
     889 [ +  - ][ +  - ]:          6 :     ModifyRefreshDelay_Impl( nRefreshDelay );
     890                 :          6 : }
     891                 :            : 
     892                 :            : // XAreaLink
     893                 :            : 
     894                 :          3 : rtl::OUString SAL_CALL ScAreaLinkObj::getSourceArea() throw(uno::RuntimeException)
     895                 :            : {
     896         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     897                 :          3 :     rtl::OUString aRet;
     898         [ +  - ]:          3 :     ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
     899         [ +  - ]:          3 :     if (pLink)
     900         [ +  - ]:          3 :         aRet = pLink->GetSource();
     901         [ +  - ]:          3 :     return aRet;
     902                 :            : }
     903                 :            : 
     904                 :          2 : void SAL_CALL ScAreaLinkObj::setSourceArea( const rtl::OUString& aSourceArea )
     905                 :            :                                             throw(uno::RuntimeException)
     906                 :            : {
     907         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     908 [ +  - ][ +  - ]:          2 :     Modify_Impl( NULL, NULL, NULL, &aSourceArea, NULL );
     909                 :          2 : }
     910                 :            : 
     911                 :          3 : table::CellRangeAddress SAL_CALL ScAreaLinkObj::getDestArea() throw(uno::RuntimeException)
     912                 :            : {
     913         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     914                 :          3 :     table::CellRangeAddress aRet;
     915         [ +  - ]:          3 :     ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
     916         [ +  - ]:          3 :     if (pLink)
     917                 :          3 :         ScUnoConversion::FillApiRange( aRet, pLink->GetDestArea() );
     918         [ +  - ]:          3 :     return aRet;
     919                 :            : }
     920                 :            : 
     921                 :          2 : void SAL_CALL ScAreaLinkObj::setDestArea( const table::CellRangeAddress& aDestArea )
     922                 :            :                                             throw(uno::RuntimeException)
     923                 :            : {
     924         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     925 [ +  - ][ +  - ]:          2 :     Modify_Impl( NULL, NULL, NULL, NULL, &aDestArea );
     926                 :          2 : }
     927                 :            : 
     928                 :            : //------------------------------------------------------------------------
     929                 :            : 
     930                 :         11 : ScAreaLinksObj::ScAreaLinksObj(ScDocShell* pDocSh) :
     931         [ +  - ]:         11 :     pDocShell( pDocSh )
     932                 :            : {
     933         [ +  - ]:         11 :     pDocShell->GetDocument()->AddUnoObject(*this);
     934                 :         11 : }
     935                 :            : 
     936         [ +  - ]:         11 : ScAreaLinksObj::~ScAreaLinksObj()
     937                 :            : {
     938         [ +  + ]:         11 :     if (pDocShell)
     939         [ +  - ]:          4 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
     940         [ -  + ]:         22 : }
     941                 :            : 
     942                 :        141 : void ScAreaLinksObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
     943                 :            : {
     944                 :            :     //  Referenz-Update interessiert hier nicht
     945                 :            : 
     946   [ +  +  +  + ]:        278 :     if ( rHint.ISA( SfxSimpleHint ) &&
                 [ +  + ]
     947                 :        137 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
     948                 :            :     {
     949                 :          7 :         pDocShell = NULL;       // ungueltig geworden
     950                 :            :     }
     951                 :        141 : }
     952                 :            : 
     953                 :            : // XAreaLinks
     954                 :            : 
     955                 :          7 : ScAreaLinkObj* ScAreaLinksObj::GetObjectByIndex_Impl(sal_Int32 nIndex)
     956                 :            : {
     957 [ +  - ][ +  - ]:          7 :     if ( pDocShell && nIndex >= 0 && nIndex < getCount() )
         [ +  + ][ +  + ]
     958         [ +  - ]:          5 :         return new ScAreaLinkObj( pDocShell, (sal_uInt16)nIndex );
     959                 :            : 
     960                 :          7 :     return NULL;    // nicht gefunden
     961                 :            : }
     962                 :            : 
     963                 :          3 : void SAL_CALL ScAreaLinksObj::insertAtPosition( const table::CellAddress& aDestPos,
     964                 :            :                                                 const rtl::OUString& aFileName,
     965                 :            :                                                 const rtl::OUString& aSourceArea,
     966                 :            :                                                 const rtl::OUString& aFilter,
     967                 :            :                                                 const rtl::OUString& aFilterOptions )
     968                 :            :                                             throw(uno::RuntimeException)
     969                 :            : {
     970         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     971         [ +  - ]:          3 :     if (pDocShell)
     972                 :            :     {
     973         [ +  - ]:          3 :         String aFileStr   (aFileName);
     974         [ +  - ]:          3 :         String aFilterStr (aFilter);
     975         [ +  - ]:          3 :         String aOptionStr (aFilterOptions);
     976         [ +  - ]:          3 :         String aSourceStr (aSourceArea);
     977                 :          3 :         ScAddress aDestAddr( (SCCOL)aDestPos.Column, (SCROW)aDestPos.Row, aDestPos.Sheet );
     978                 :            : 
     979 [ +  - ][ +  - ]:          3 :         aFileStr = ScGlobal::GetAbsDocName( aFileStr, pDocShell );  //! in InsertAreaLink ???
                 [ +  - ]
     980                 :          3 :         pDocShell->GetDocFunc().InsertAreaLink( aFileStr, aFilterStr, aOptionStr,
     981                 :            :                                                 aSourceStr, ScRange(aDestAddr),
     982 [ +  - ][ +  - ]:          3 :                                                 0, false, sal_True ); // don't move contents
         [ +  - ][ +  - ]
                 [ +  - ]
     983         [ +  - ]:          3 :     }
     984                 :          3 : }
     985                 :            : 
     986                 :          0 : void SAL_CALL ScAreaLinksObj::removeByIndex( sal_Int32 nIndex ) throw(uno::RuntimeException)
     987                 :            : {
     988         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     989         [ #  # ]:          0 :     ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, (sal_uInt16)nIndex);
     990         [ #  # ]:          0 :     if (pLink)
     991                 :            :     {
     992                 :            :         //! SetAddUndo oder so
     993                 :            : 
     994         [ #  # ]:          0 :         sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
     995         [ #  # ]:          0 :         pLinkManager->Remove( pLink );
     996         [ #  # ]:          0 :     }
     997                 :          0 : }
     998                 :            : 
     999                 :            : // XEnumerationAccess
    1000                 :            : 
    1001                 :          2 : uno::Reference<container::XEnumeration> SAL_CALL ScAreaLinksObj::createEnumeration()
    1002                 :            :                                                     throw(uno::RuntimeException)
    1003                 :            : {
    1004         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1005 [ +  - ][ +  - ]:          2 :     return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.CellAreaLinksEnumeration")));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1006                 :            : }
    1007                 :            : 
    1008                 :            : // XIndexAccess
    1009                 :            : 
    1010                 :         15 : sal_Int32 SAL_CALL ScAreaLinksObj::getCount() throw(uno::RuntimeException)
    1011                 :            : {
    1012         [ +  - ]:         15 :     SolarMutexGuard aGuard;
    1013                 :         15 :     sal_Int32 nAreaCount = 0;
    1014         [ +  - ]:         15 :     if (pDocShell)
    1015                 :            :     {
    1016         [ +  - ]:         15 :         sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
    1017                 :         15 :         sal_uInt16 nTotalCount = pLinkManager->GetLinks().size();
    1018         [ +  + ]:         26 :         for (sal_uInt16 i=0; i<nTotalCount; i++)
    1019                 :            :         {
    1020                 :         11 :             ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
    1021 [ +  - ][ +  - ]:         11 :             if (pBase->ISA(ScAreaLink))
                 [ +  - ]
    1022                 :         11 :                 ++nAreaCount;
    1023                 :            :         }
    1024                 :            :     }
    1025         [ +  - ]:         15 :     return nAreaCount;
    1026                 :            : }
    1027                 :            : 
    1028                 :          7 : uno::Any SAL_CALL ScAreaLinksObj::getByIndex( sal_Int32 nIndex )
    1029                 :            :                             throw(lang::IndexOutOfBoundsException,
    1030                 :            :                                     lang::WrappedTargetException, uno::RuntimeException)
    1031                 :            : {
    1032         [ +  - ]:          7 :     SolarMutexGuard aGuard;
    1033 [ +  - ][ +  + ]:          7 :     uno::Reference<sheet::XAreaLink> xLink(GetObjectByIndex_Impl(nIndex));
                 [ +  - ]
    1034         [ +  + ]:          7 :     if (xLink.is())
    1035         [ +  - ]:         10 :         return uno::makeAny(xLink);
    1036                 :            :     else
    1037 [ +  - ][ +  - ]:          7 :         throw lang::IndexOutOfBoundsException();
    1038                 :            : }
    1039                 :            : 
    1040                 :          1 : uno::Type SAL_CALL ScAreaLinksObj::getElementType() throw(uno::RuntimeException)
    1041                 :            : {
    1042         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    1043 [ +  - ][ +  - ]:          1 :     return getCppuType((uno::Reference<sheet::XAreaLink>*)0);
    1044                 :            : }
    1045                 :            : 
    1046                 :          1 : sal_Bool SAL_CALL ScAreaLinksObj::hasElements() throw(uno::RuntimeException)
    1047                 :            : {
    1048         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    1049 [ +  - ][ +  - ]:          1 :     return ( getCount() != 0 );
    1050                 :            : }
    1051                 :            : 
    1052                 :            : //------------------------------------------------------------------------
    1053                 :            : 
    1054                 :          6 : ScDDELinkObj::ScDDELinkObj(ScDocShell* pDocSh, const String& rA,
    1055                 :            :                             const String& rT, const String& rI) :
    1056                 :            :     pDocShell( pDocSh ),
    1057                 :            :     aAppl( rA ),
    1058                 :            :     aTopic( rT ),
    1059 [ +  - ][ +  - ]:          6 :     aItem( rI )
         [ +  - ][ +  - ]
                 [ +  - ]
    1060                 :            : {
    1061         [ +  - ]:          6 :     pDocShell->GetDocument()->AddUnoObject(*this);
    1062                 :          6 : }
    1063                 :            : 
    1064 [ +  - ][ +  - ]:          6 : ScDDELinkObj::~ScDDELinkObj()
         [ +  - ][ +  - ]
                 [ +  - ]
    1065                 :            : {
    1066         [ -  + ]:          6 :     if (pDocShell)
    1067         [ #  # ]:          0 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    1068         [ -  + ]:         12 : }
    1069                 :            : 
    1070                 :          8 : void ScDDELinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    1071                 :            : {
    1072                 :            :     //! notify if links in document are changed
    1073                 :            :     //  UpdateRef is not needed here
    1074                 :            : 
    1075         [ +  + ]:          8 :     if ( rHint.ISA( SfxSimpleHint ) )
    1076                 :            :     {
    1077         [ +  - ]:          6 :         if ( ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
    1078                 :          6 :             pDocShell = NULL;       // pointer is invalid
    1079                 :            :     }
    1080         [ +  - ]:          2 :     else if ( rHint.ISA( ScLinkRefreshedHint ) )
    1081                 :            :     {
    1082                 :          2 :         const ScLinkRefreshedHint& rLH = (const ScLinkRefreshedHint&) rHint;
    1083   [ +  -  +  -  :          8 :         if ( rLH.GetLinkType() == SC_LINKREFTYPE_DDE &&
             +  -  +  - ]
                 [ +  - ]
    1084                 :          2 :              rLH.GetDdeAppl()  == aAppl &&
    1085                 :          2 :              rLH.GetDdeTopic() == aTopic &&
    1086                 :          2 :              rLH.GetDdeItem()  == aItem )       //! mode is ignored
    1087                 :          2 :             Refreshed_Impl();
    1088                 :            :     }
    1089                 :          8 : }
    1090                 :            : 
    1091                 :            : // XNamed
    1092                 :            : 
    1093                 :          9 : String lcl_BuildDDEName( const String& rAppl, const String& rTopic, const String& rItem )
    1094                 :            : {
    1095                 :            :     //  Appl|Topic!Item (wie Excel)
    1096                 :          9 :     String aRet = rAppl;
    1097         [ +  - ]:          9 :     aRet += '|';
    1098         [ +  - ]:          9 :     aRet += rTopic;
    1099         [ +  - ]:          9 :     aRet += '!';
    1100         [ +  - ]:          9 :     aRet += rItem;
    1101                 :          9 :     return aRet;
    1102                 :            : }
    1103                 :            : 
    1104                 :          2 : rtl::OUString SAL_CALL ScDDELinkObj::getName() throw(uno::RuntimeException)
    1105                 :            : {
    1106         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1107 [ +  - ][ +  - ]:          2 :     return lcl_BuildDDEName( aAppl, aTopic, aItem );
         [ +  - ][ +  - ]
    1108                 :            : }
    1109                 :            : 
    1110                 :          0 : void SAL_CALL ScDDELinkObj::setName( const rtl::OUString& /* aName */ ) throw(uno::RuntimeException)
    1111                 :            : {
    1112                 :            :     //  name can't be changed (formulas wouldn't find the link)
    1113         [ #  # ]:          0 :     throw uno::RuntimeException();
    1114                 :            : }
    1115                 :            : 
    1116                 :            : // XDDELink
    1117                 :            : 
    1118                 :          1 : rtl::OUString SAL_CALL ScDDELinkObj::getApplication() throw(uno::RuntimeException)
    1119                 :            : {
    1120         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    1121                 :            :     //! Test, ob Link noch im Dokument enthalten?
    1122                 :            : 
    1123 [ +  - ][ +  - ]:          1 :     return aAppl;
    1124                 :            : }
    1125                 :            : 
    1126                 :          1 : rtl::OUString SAL_CALL ScDDELinkObj::getTopic() throw(uno::RuntimeException)
    1127                 :            : {
    1128         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    1129                 :            :     //! Test, ob Link noch im Dokument enthalten?
    1130                 :            : 
    1131 [ +  - ][ +  - ]:          1 :     return aTopic;
    1132                 :            : }
    1133                 :            : 
    1134                 :          1 : rtl::OUString SAL_CALL ScDDELinkObj::getItem() throw(uno::RuntimeException)
    1135                 :            : {
    1136         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    1137                 :            :     //! Test, ob Link noch im Dokument enthalten?
    1138                 :            : 
    1139 [ +  - ][ +  - ]:          1 :     return aItem;
    1140                 :            : }
    1141                 :            : 
    1142                 :            : // XRefreshable
    1143                 :            : 
    1144                 :          2 : void SAL_CALL ScDDELinkObj::refresh() throw(uno::RuntimeException)
    1145                 :            : {
    1146         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1147         [ +  - ]:          2 :     if (pDocShell)
    1148                 :            :     {
    1149                 :          2 :         ScDocument* pDoc = pDocShell->GetDocument();
    1150 [ +  - ][ +  - ]:          2 :         (void)pDoc->UpdateDdeLink( aAppl, aTopic, aItem );
         [ +  - ][ +  - ]
    1151                 :            :         //! Fehler abfragen
    1152         [ +  - ]:          2 :     }
    1153                 :          2 : }
    1154                 :            : 
    1155                 :          1 : void SAL_CALL ScDDELinkObj::addRefreshListener(
    1156                 :            :                                 const uno::Reference<util::XRefreshListener >& xListener )
    1157                 :            :                                                 throw(uno::RuntimeException)
    1158                 :            : {
    1159         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    1160                 :            :     uno::Reference<util::XRefreshListener>* pObj =
    1161                 :          1 :             new uno::Reference<util::XRefreshListener>( xListener );
    1162         [ +  - ]:          1 :     aRefreshListeners.push_back( pObj );
    1163                 :            : 
    1164                 :            :     //  hold one additional ref to keep this object alive as long as there are listeners
    1165         [ +  - ]:          1 :     if ( aRefreshListeners.size() == 1 )
    1166         [ +  - ]:          1 :         acquire();
    1167                 :          1 : }
    1168                 :            : 
    1169                 :          1 : void SAL_CALL ScDDELinkObj::removeRefreshListener(
    1170                 :            :                                 const uno::Reference<util::XRefreshListener >& xListener )
    1171                 :            :                                                 throw(uno::RuntimeException)
    1172                 :            : {
    1173         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    1174                 :          1 :     sal_uInt16 nCount = aRefreshListeners.size();
    1175         [ +  - ]:          1 :     for ( sal_uInt16 n=nCount; n--; )
    1176                 :            :     {
    1177         [ +  - ]:          1 :         uno::Reference<util::XRefreshListener>& rObj = aRefreshListeners[n];
    1178 [ +  - ][ +  - ]:          1 :         if ( rObj == xListener )
    1179                 :            :         {
    1180 [ +  - ][ +  - ]:          1 :             aRefreshListeners.erase( aRefreshListeners.begin() + n );
                 [ +  - ]
    1181         [ +  - ]:          1 :             if ( aRefreshListeners.empty() )
    1182                 :          1 :                 release();                          // release ref for listeners
    1183                 :          1 :             break;
    1184                 :            :         }
    1185         [ +  - ]:          1 :     }
    1186                 :          1 : }
    1187                 :            : 
    1188                 :            : // XDDELinkResults
    1189                 :            : 
    1190                 :          0 : uno::Sequence< uno::Sequence< uno::Any > > ScDDELinkObj::getResults(  )
    1191                 :            :     throw (uno::RuntimeException)
    1192                 :            : {
    1193         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1194         [ #  # ]:          0 :     uno::Sequence< uno::Sequence< uno::Any > > aReturn;
    1195                 :          0 :     bool bSuccess = false;
    1196                 :            : 
    1197         [ #  # ]:          0 :     if ( pDocShell )
    1198                 :            :     {
    1199                 :          0 :         ScDocument* pDoc = pDocShell->GetDocument();
    1200         [ #  # ]:          0 :         if ( pDoc )
    1201                 :            :         {
    1202                 :          0 :             sal_uInt16 nPos = 0;
    1203 [ #  # ][ #  # ]:          0 :             if ( pDoc->FindDdeLink( aAppl, aTopic, aItem, SC_DDE_IGNOREMODE, nPos ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1204                 :            :             {
    1205         [ #  # ]:          0 :                 const ScMatrix* pMatrix = pDoc->GetDdeLinkResultMatrix( nPos );
    1206         [ #  # ]:          0 :                 if ( pMatrix )
    1207                 :            :                 {
    1208                 :          0 :                     uno::Any aAny;
    1209 [ #  # ][ #  # ]:          0 :                     if ( ScRangeToSequence::FillMixedArray( aAny, pMatrix, true ) )
    1210                 :            :                     {
    1211         [ #  # ]:          0 :                         aAny >>= aReturn;
    1212                 :          0 :                     }
    1213                 :            :                 }
    1214                 :          0 :                 bSuccess = true;
    1215                 :            :             }
    1216                 :            :         }
    1217                 :            :     }
    1218                 :            : 
    1219         [ #  # ]:          0 :     if ( !bSuccess )
    1220                 :            :     {
    1221                 :            :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
    1222                 :            :             "ScDDELinkObj::getResults: failed to get results!" ) ),
    1223 [ #  # ][ #  # ]:          0 :             uno::Reference< uno::XInterface >() );
    1224                 :            :     }
    1225                 :            : 
    1226         [ #  # ]:          0 :     return aReturn;
    1227                 :            : }
    1228                 :            : 
    1229                 :          0 : void ScDDELinkObj::setResults( const uno::Sequence< uno::Sequence< uno::Any > >& aResults )
    1230                 :            :     throw (uno::RuntimeException)
    1231                 :            : {
    1232         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1233                 :          0 :     bool bSuccess = false;
    1234                 :            : 
    1235         [ #  # ]:          0 :     if ( pDocShell )
    1236                 :            :     {
    1237                 :          0 :         ScDocument* pDoc = pDocShell->GetDocument();
    1238         [ #  # ]:          0 :         if ( pDoc )
    1239                 :            :         {
    1240                 :          0 :             sal_uInt16 nPos = 0;
    1241 [ #  # ][ #  # ]:          0 :             if ( pDoc->FindDdeLink( aAppl, aTopic, aItem, SC_DDE_IGNOREMODE, nPos ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1242                 :            :             {
    1243                 :          0 :                 uno::Any aAny;
    1244         [ #  # ]:          0 :                 aAny <<= aResults;
    1245         [ #  # ]:          0 :                 ScMatrixRef xMatrix = ScSequenceToMatrix::CreateMixedMatrix( aAny );
    1246 [ #  # ][ #  # ]:          0 :                 bSuccess = pDoc->SetDdeLinkResultMatrix( nPos, xMatrix );
                 [ #  # ]
    1247                 :            :             }
    1248                 :            :         }
    1249                 :            :     }
    1250                 :            : 
    1251         [ #  # ]:          0 :     if ( !bSuccess )
    1252                 :            :     {
    1253                 :            :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
    1254                 :            :             "ScDDELinkObj::setResults: failed to set results!" ) ),
    1255 [ #  # ][ #  # ]:          0 :             uno::Reference< uno::XInterface >() );
    1256         [ #  # ]:          0 :     }
    1257                 :          0 : }
    1258                 :            : 
    1259                 :          2 : void ScDDELinkObj::Refreshed_Impl()
    1260                 :            : {
    1261         [ +  - ]:          2 :     lang::EventObject aEvent;
    1262         [ +  - ]:          2 :     aEvent.Source.set((cppu::OWeakObject*)this);
    1263         [ +  + ]:          3 :     for ( sal_uInt16 n=0; n<aRefreshListeners.size(); n++ )
    1264 [ +  - ][ +  - ]:          3 :         aRefreshListeners[n]->refreshed( aEvent );
         [ +  - ][ +  - ]
    1265                 :          2 : }
    1266                 :            : 
    1267                 :            : //------------------------------------------------------------------------
    1268                 :            : 
    1269                 :         11 : ScDDELinksObj::ScDDELinksObj(ScDocShell* pDocSh) :
    1270         [ +  - ]:         11 :     pDocShell( pDocSh )
    1271                 :            : {
    1272         [ +  - ]:         11 :     pDocShell->GetDocument()->AddUnoObject(*this);
    1273                 :         11 : }
    1274                 :            : 
    1275         [ +  - ]:         11 : ScDDELinksObj::~ScDDELinksObj()
    1276                 :            : {
    1277         [ +  + ]:         11 :     if (pDocShell)
    1278         [ +  - ]:          4 :         pDocShell->GetDocument()->RemoveUnoObject(*this);
    1279         [ -  + ]:         22 : }
    1280                 :            : 
    1281                 :        141 : void ScDDELinksObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
    1282                 :            : {
    1283                 :            :     //  Referenz-Update interessiert hier nicht
    1284                 :            : 
    1285   [ +  +  +  + ]:        280 :     if ( rHint.ISA( SfxSimpleHint ) &&
                 [ +  + ]
    1286                 :        139 :             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
    1287                 :            :     {
    1288                 :          7 :         pDocShell = NULL;       // ungueltig geworden
    1289                 :            :     }
    1290                 :        141 : }
    1291                 :            : 
    1292                 :            : // XDDELinks
    1293                 :            : 
    1294                 :          6 : ScDDELinkObj* ScDDELinksObj::GetObjectByIndex_Impl(sal_Int32 nIndex)
    1295                 :            : {
    1296         [ +  - ]:          6 :     if (pDocShell)
    1297                 :            :     {
    1298                 :          6 :         rtl::OUString aAppl, aTopic, aItem;
    1299 [ +  + ][ +  + ]:         12 :         if ( nIndex <= USHRT_MAX &&
                 [ +  - ]
    1300         [ +  - ]:          6 :                 pDocShell->GetDocument()->GetDdeLinkData( (sal_uInt16)nIndex, aAppl, aTopic, aItem ) )
    1301 [ +  - ][ +  - ]:          6 :             return new ScDDELinkObj( pDocShell, aAppl, aTopic, aItem );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
         [ +  + ][ +  + ]
    1302                 :            :     }
    1303                 :          6 :     return NULL;
    1304                 :            : }
    1305                 :            : 
    1306                 :          3 : ScDDELinkObj* ScDDELinksObj::GetObjectByName_Impl(const rtl::OUString& aName)
    1307                 :            : {
    1308         [ +  - ]:          3 :     if (pDocShell)
    1309                 :            :     {
    1310         [ +  - ]:          3 :         String aNamStr(aName);
    1311                 :          3 :         rtl::OUString aAppl, aTopic, aItem;
    1312                 :            : 
    1313                 :          3 :         ScDocument* pDoc = pDocShell->GetDocument();
    1314         [ +  - ]:          3 :         sal_uInt16 nCount = pDoc->GetDdeLinkCount();
    1315         [ +  + ]:          4 :         for (sal_uInt16 i=0; i<nCount; i++)
    1316                 :            :         {
    1317         [ +  - ]:          3 :             pDoc->GetDdeLinkData( i, aAppl, aTopic, aItem );
    1318 [ +  - ][ +  - ]:          3 :             if ( lcl_BuildDDEName(aAppl, aTopic, aItem) == aNamStr )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
    1319 [ +  - ][ +  - ]:          2 :                 return new ScDDELinkObj( pDocShell, aAppl, aTopic, aItem );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1320 [ +  + ][ +  + ]:          3 :         }
         [ +  + ][ +  - ]
                 [ +  + ]
    1321                 :            :     }
    1322                 :          3 :     return NULL;
    1323                 :            : }
    1324                 :            : 
    1325                 :            : // XEnumerationAccess
    1326                 :            : 
    1327                 :          2 : uno::Reference<container::XEnumeration> SAL_CALL ScDDELinksObj::createEnumeration()
    1328                 :            :                                                     throw(uno::RuntimeException)
    1329                 :            : {
    1330         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1331 [ +  - ][ +  - ]:          2 :     return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DDELinksEnumeration")));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1332                 :            : }
    1333                 :            : 
    1334                 :            : // XIndexAccess
    1335                 :            : 
    1336                 :          8 : sal_Int32 SAL_CALL ScDDELinksObj::getCount() throw(uno::RuntimeException)
    1337                 :            : {
    1338         [ +  - ]:          8 :     SolarMutexGuard aGuard;
    1339                 :          8 :     sal_Int32 nAreaCount = 0;
    1340         [ +  - ]:          8 :     if (pDocShell)
    1341         [ +  - ]:          8 :         nAreaCount = pDocShell->GetDocument()->GetDdeLinkCount();
    1342         [ +  - ]:          8 :     return nAreaCount;
    1343                 :            : }
    1344                 :            : 
    1345                 :          6 : uno::Any SAL_CALL ScDDELinksObj::getByIndex( sal_Int32 nIndex )
    1346                 :            :                             throw(lang::IndexOutOfBoundsException,
    1347                 :            :                                     lang::WrappedTargetException, uno::RuntimeException)
    1348                 :            : {
    1349         [ +  - ]:          6 :     SolarMutexGuard aGuard;
    1350 [ +  - ][ +  + ]:          6 :     uno::Reference<sheet::XDDELink> xLink(GetObjectByIndex_Impl(nIndex));
                 [ +  - ]
    1351         [ +  + ]:          6 :     if (xLink.is())
    1352         [ +  - ]:          8 :         return uno::makeAny(xLink);
    1353                 :            :     else
    1354 [ +  - ][ +  - ]:          6 :         throw lang::IndexOutOfBoundsException();
    1355                 :            : }
    1356                 :            : 
    1357                 :          1 : uno::Type SAL_CALL ScDDELinksObj::getElementType() throw(uno::RuntimeException)
    1358                 :            : {
    1359         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    1360 [ +  - ][ +  - ]:          1 :     return getCppuType((uno::Reference<sheet::XDDELink>*)0);
    1361                 :            : }
    1362                 :            : 
    1363                 :          1 : sal_Bool SAL_CALL ScDDELinksObj::hasElements() throw(uno::RuntimeException)
    1364                 :            : {
    1365         [ +  - ]:          1 :     SolarMutexGuard aGuard;
    1366 [ +  - ][ +  - ]:          1 :     return ( getCount() != 0 );
    1367                 :            : }
    1368                 :            : 
    1369                 :          3 : uno::Any SAL_CALL ScDDELinksObj::getByName( const rtl::OUString& aName )
    1370                 :            :             throw(container::NoSuchElementException,
    1371                 :            :                     lang::WrappedTargetException, uno::RuntimeException)
    1372                 :            : {
    1373         [ +  - ]:          3 :     SolarMutexGuard aGuard;
    1374 [ +  - ][ +  + ]:          3 :     uno::Reference<sheet::XDDELink> xLink(GetObjectByName_Impl(aName));
                 [ +  - ]
    1375         [ +  + ]:          3 :     if (xLink.is())
    1376         [ +  - ]:          4 :         return uno::makeAny(xLink);
    1377                 :            :     else
    1378 [ +  - ][ +  - ]:          3 :         throw container::NoSuchElementException();
    1379                 :            : }
    1380                 :            : 
    1381                 :          2 : uno::Sequence<rtl::OUString> SAL_CALL ScDDELinksObj::getElementNames() throw(uno::RuntimeException)
    1382                 :            : {
    1383         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1384         [ +  - ]:          2 :     if (pDocShell)
    1385                 :            :     {
    1386                 :          2 :         rtl::OUString aAppl, aTopic, aItem;
    1387                 :            : 
    1388                 :          2 :         ScDocument* pDoc = pDocShell->GetDocument();
    1389         [ +  - ]:          2 :         sal_uInt16 nCount = pDoc->GetDdeLinkCount();
    1390         [ +  - ]:          2 :         uno::Sequence<rtl::OUString> aSeq(nCount);
    1391         [ +  - ]:          2 :         rtl::OUString* pAry = aSeq.getArray();
    1392                 :            : 
    1393         [ +  + ]:          4 :         for (sal_uInt16 i=0; i<nCount; i++)
    1394                 :            :         {
    1395         [ +  - ]:          2 :             pDoc->GetDdeLinkData( i, aAppl, aTopic, aItem );
    1396 [ +  - ][ +  - ]:          2 :             pAry[i] = lcl_BuildDDEName(aAppl, aTopic, aItem);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1397                 :            :         }
    1398 [ +  - ][ +  - ]:          2 :         return aSeq;
    1399                 :            :     }
    1400 [ #  # ][ +  - ]:          2 :     return uno::Sequence<rtl::OUString>();
    1401                 :            : }
    1402                 :            : 
    1403                 :          2 : sal_Bool SAL_CALL ScDDELinksObj::hasByName( const rtl::OUString& aName )
    1404                 :            :                                         throw(uno::RuntimeException)
    1405                 :            : {
    1406         [ +  - ]:          2 :     SolarMutexGuard aGuard;
    1407         [ +  - ]:          2 :     if (pDocShell)
    1408                 :            :     {
    1409         [ +  - ]:          2 :         String aNamStr(aName);
    1410                 :          2 :         rtl::OUString aAppl, aTopic, aItem;
    1411                 :            : 
    1412                 :          2 :         ScDocument* pDoc = pDocShell->GetDocument();
    1413         [ +  - ]:          2 :         sal_uInt16 nCount = pDoc->GetDdeLinkCount();
    1414         [ +  + ]:          3 :         for (sal_uInt16 i=0; i<nCount; i++)
    1415                 :            :         {
    1416         [ +  - ]:          2 :             pDoc->GetDdeLinkData( i, aAppl, aTopic, aItem );
    1417 [ +  - ][ +  - ]:          2 :             if ( lcl_BuildDDEName(aAppl, aTopic, aItem) == aNamStr )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
    1418                 :          1 :                 return sal_True;
    1419 [ +  + ][ +  + ]:          2 :         }
         [ +  + ][ +  - ]
                 [ +  + ]
    1420                 :            :     }
    1421         [ +  - ]:          2 :     return false;
    1422                 :            : }
    1423                 :            : 
    1424                 :            : // XDDELinks
    1425                 :            : 
    1426                 :          0 : uno::Reference< sheet::XDDELink > ScDDELinksObj::addDDELink(
    1427                 :            :     const ::rtl::OUString& aApplication, const ::rtl::OUString& aTopic,
    1428                 :            :     const ::rtl::OUString& aItem, ::com::sun::star::sheet::DDELinkMode nMode )
    1429                 :            :     throw (uno::RuntimeException)
    1430                 :            : {
    1431         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1432                 :          0 :     uno::Reference< sheet::XDDELink > xLink;
    1433                 :            : 
    1434         [ #  # ]:          0 :     if ( pDocShell )
    1435                 :            :     {
    1436                 :          0 :         ScDocument* pDoc = pDocShell->GetDocument();
    1437         [ #  # ]:          0 :         if ( pDoc )
    1438                 :            :         {
    1439                 :          0 :             sal_uInt8 nMod = SC_DDE_DEFAULT;
    1440   [ #  #  #  # ]:          0 :             switch ( nMode )
    1441                 :            :             {
    1442                 :            :                 case sheet::DDELinkMode_DEFAULT:
    1443                 :            :                     {
    1444                 :          0 :                         nMod = SC_DDE_DEFAULT;
    1445                 :            :                     }
    1446                 :          0 :                     break;
    1447                 :            :                 case sheet::DDELinkMode_ENGLISH:
    1448                 :            :                     {
    1449                 :          0 :                         nMod = SC_DDE_ENGLISH;
    1450                 :            :                     }
    1451                 :          0 :                     break;
    1452                 :            :                 case sheet::DDELinkMode_TEXT:
    1453                 :            :                     {
    1454                 :          0 :                         nMod = SC_DDE_TEXT;
    1455                 :            :                     }
    1456                 :          0 :                     break;
    1457                 :            :                 default:
    1458                 :            :                     {
    1459                 :            :                     }
    1460                 :          0 :                     break;
    1461                 :            :             }
    1462                 :            : 
    1463 [ #  # ][ #  # ]:          0 :             if ( pDoc->CreateDdeLink( aApplication, aTopic, aItem, nMod, ScMatrixRef() ) )
                 [ #  # ]
    1464                 :            :             {
    1465 [ #  # ][ #  # ]:          0 :                 const ::rtl::OUString aName( lcl_BuildDDEName( aApplication, aTopic, aItem ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1466 [ #  # ][ #  # ]:          0 :                 xLink.set( GetObjectByName_Impl( aName ) );
                 [ #  # ]
    1467                 :            :             }
    1468                 :            :         }
    1469                 :            :     }
    1470                 :            : 
    1471         [ #  # ]:          0 :     if ( !xLink.is() )
    1472                 :            :     {
    1473                 :            :         throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
    1474                 :            :             "ScDDELinksObj::addDDELink: cannot add DDE link!" ) ),
    1475 [ #  # ][ #  # ]:          0 :             uno::Reference< uno::XInterface >() );
    1476                 :            :     }
    1477                 :            : 
    1478         [ #  # ]:          0 :     return xLink;
    1479                 :            : }
    1480                 :            : 
    1481                 :            : // ============================================================================
    1482                 :            : 
    1483                 :          0 : ScExternalSheetCacheObj::ScExternalSheetCacheObj(ScExternalRefCache::TableTypeRef pTable, size_t nIndex) :
    1484                 :            :     mpTable(pTable),
    1485         [ #  # ]:          0 :     mnIndex(nIndex)
    1486                 :            : {
    1487                 :          0 : }
    1488                 :            : 
    1489         [ #  # ]:          0 : ScExternalSheetCacheObj::~ScExternalSheetCacheObj()
    1490                 :            : {
    1491         [ #  # ]:          0 : }
    1492                 :            : 
    1493                 :          0 : void SAL_CALL ScExternalSheetCacheObj::setCellValue(sal_Int32 nCol, sal_Int32 nRow, const Any& rValue)
    1494                 :            :     throw (IllegalArgumentException, RuntimeException)
    1495                 :            : {
    1496         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1497 [ #  # ][ #  # ]:          0 :     if (nRow < 0 || nCol < 0)
    1498         [ #  # ]:          0 :         throw IllegalArgumentException();
    1499                 :            : 
    1500                 :          0 :     ScExternalRefCache::TokenRef pToken;
    1501                 :          0 :     double fVal = 0.0;
    1502                 :          0 :     OUString aVal;
    1503         [ #  # ]:          0 :     if (rValue >>= fVal)
    1504 [ #  # ][ #  # ]:          0 :         pToken.reset(new FormulaDoubleToken(fVal));
                 [ #  # ]
    1505         [ #  # ]:          0 :     else if (rValue >>= aVal)
    1506 [ #  # ][ #  # ]:          0 :         pToken.reset(new FormulaStringToken(aVal));
         [ #  # ][ #  # ]
                 [ #  # ]
    1507                 :            :     else
    1508                 :            :         // unidentified value type.
    1509                 :          0 :         return;
    1510                 :            : 
    1511 [ #  # ][ #  # ]:          0 :     mpTable->setCell(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), pToken);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1512                 :            : }
    1513                 :            : 
    1514                 :          0 : Any SAL_CALL ScExternalSheetCacheObj::getCellValue(sal_Int32 nCol, sal_Int32 nRow)
    1515                 :            :     throw (IllegalArgumentException, RuntimeException)
    1516                 :            : {
    1517         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1518 [ #  # ][ #  # ]:          0 :     if (nRow < 0 || nCol < 0)
    1519         [ #  # ]:          0 :         throw IllegalArgumentException();
    1520                 :            : 
    1521 [ #  # ][ #  # ]:          0 :     FormulaToken* pToken = mpTable->getCell(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow)).get();
    1522         [ #  # ]:          0 :     if (!pToken)
    1523         [ #  # ]:          0 :         throw IllegalArgumentException();
    1524                 :            : 
    1525                 :          0 :     Any aValue;
    1526      [ #  #  # ]:          0 :     switch (pToken->GetType())
    1527                 :            :     {
    1528                 :            :         case svDouble:
    1529                 :            :         {
    1530         [ #  # ]:          0 :             double fVal = pToken->GetDouble();
    1531         [ #  # ]:          0 :             aValue <<= fVal;
    1532                 :            :         }
    1533                 :          0 :         break;
    1534                 :            :         case svString:
    1535                 :            :         {
    1536 [ #  # ][ #  # ]:          0 :             OUString aVal = pToken->GetString();
    1537         [ #  # ]:          0 :             aValue <<= aVal;
    1538                 :            :         }
    1539                 :          0 :         break;
    1540                 :            :         default:
    1541         [ #  # ]:          0 :             throw IllegalArgumentException();
    1542                 :            :     }
    1543         [ #  # ]:          0 :     return aValue;
    1544                 :            : }
    1545                 :            : 
    1546                 :          0 : Sequence< sal_Int32 > SAL_CALL ScExternalSheetCacheObj::getAllRows()
    1547                 :            :     throw (RuntimeException)
    1548                 :            : {
    1549         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1550         [ #  # ]:          0 :     vector<SCROW> aRows;
    1551         [ #  # ]:          0 :     mpTable->getAllRows(aRows);
    1552                 :          0 :     size_t nSize = aRows.size();
    1553         [ #  # ]:          0 :     Sequence<sal_Int32> aRowsSeq(nSize);
    1554         [ #  # ]:          0 :     for (size_t i = 0; i < nSize; ++i)
    1555 [ #  # ][ #  # ]:          0 :         aRowsSeq[i] = aRows[i];
    1556                 :            : 
    1557         [ #  # ]:          0 :     return aRowsSeq;
    1558                 :            : }
    1559                 :            : 
    1560                 :          0 : Sequence< sal_Int32 > SAL_CALL ScExternalSheetCacheObj::getAllColumns(sal_Int32 nRow)
    1561                 :            :     throw (IllegalArgumentException, RuntimeException)
    1562                 :            : {
    1563         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1564         [ #  # ]:          0 :     if (nRow < 0)
    1565         [ #  # ]:          0 :         throw IllegalArgumentException();
    1566                 :            : 
    1567         [ #  # ]:          0 :     vector<SCCOL> aCols;
    1568         [ #  # ]:          0 :     mpTable->getAllCols(static_cast<SCROW>(nRow), aCols);
    1569                 :          0 :     size_t nSize = aCols.size();
    1570         [ #  # ]:          0 :     Sequence<sal_Int32> aColsSeq(nSize);
    1571         [ #  # ]:          0 :     for (size_t i = 0; i < nSize; ++i)
    1572 [ #  # ][ #  # ]:          0 :         aColsSeq[i] = aCols[i];
    1573                 :            : 
    1574         [ #  # ]:          0 :     return aColsSeq;
    1575                 :            : }
    1576                 :            : 
    1577                 :          0 : sal_Int32 SAL_CALL ScExternalSheetCacheObj::getTokenIndex()
    1578                 :            :         throw (RuntimeException)
    1579                 :            : {
    1580                 :          0 :     return static_cast< sal_Int32 >( mnIndex );
    1581                 :            : }
    1582                 :            : 
    1583                 :            : // ============================================================================
    1584                 :            : 
    1585                 :          0 : ScExternalDocLinkObj::ScExternalDocLinkObj(ScExternalRefManager* pRefMgr, sal_uInt16 nFileId) :
    1586                 :          0 :     mpRefMgr(pRefMgr), mnFileId(nFileId)
    1587                 :            : {
    1588                 :          0 : }
    1589                 :            : 
    1590                 :          0 : ScExternalDocLinkObj::~ScExternalDocLinkObj()
    1591                 :            : {
    1592         [ #  # ]:          0 : }
    1593                 :            : 
    1594                 :          0 : Reference< sheet::XExternalSheetCache > SAL_CALL ScExternalDocLinkObj::addSheetCache(
    1595                 :            :     const OUString& aSheetName, sal_Bool bDynamicCache )
    1596                 :            :         throw (RuntimeException)
    1597                 :            : {
    1598         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1599                 :          0 :     size_t nIndex = 0;
    1600         [ #  # ]:          0 :     ScExternalRefCache::TableTypeRef pTable = mpRefMgr->getCacheTable(mnFileId, aSheetName, true, &nIndex);
    1601         [ #  # ]:          0 :     if (!bDynamicCache)
    1602                 :            :         // Set the whole table cached to prevent access to the source document.
    1603         [ #  # ]:          0 :         pTable->setWholeTableCached();
    1604                 :            : 
    1605 [ #  # ][ #  # ]:          0 :     Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(pTable, nIndex));
         [ #  # ][ #  # ]
                 [ #  # ]
    1606 [ #  # ][ #  # ]:          0 :     return aSheetCache;
    1607                 :            : }
    1608                 :            : 
    1609                 :          0 : Any SAL_CALL ScExternalDocLinkObj::getByName(const::rtl::OUString &aName)
    1610                 :            :         throw (container::NoSuchElementException, lang::WrappedTargetException, RuntimeException)
    1611                 :            : {
    1612         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1613                 :          0 :     size_t nIndex = 0;
    1614         [ #  # ]:          0 :     ScExternalRefCache::TableTypeRef pTable = mpRefMgr->getCacheTable(mnFileId, aName, false, &nIndex);
    1615         [ #  # ]:          0 :     if (!pTable)
    1616         [ #  # ]:          0 :         throw container::NoSuchElementException();
    1617                 :            : 
    1618 [ #  # ][ #  # ]:          0 :     Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(pTable, nIndex));
         [ #  # ][ #  # ]
                 [ #  # ]
    1619                 :            : 
    1620                 :          0 :     Any aAny;
    1621         [ #  # ]:          0 :     aAny <<= aSheetCache;
    1622 [ #  # ][ #  # ]:          0 :     return aAny;
    1623                 :            : }
    1624                 :            : 
    1625                 :          0 : Sequence< OUString > SAL_CALL ScExternalDocLinkObj::getElementNames()
    1626                 :            :         throw (RuntimeException)
    1627                 :            : {
    1628         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1629         [ #  # ]:          0 :     vector<OUString> aTabNames;
    1630         [ #  # ]:          0 :     mpRefMgr->getAllCachedTableNames(mnFileId, aTabNames);
    1631                 :          0 :     size_t n = aTabNames.size();
    1632         [ #  # ]:          0 :     Sequence<OUString> aSeq(n);
    1633         [ #  # ]:          0 :     for (size_t i = 0; i < n; ++i)
    1634         [ #  # ]:          0 :         aSeq[i] = aTabNames[i];
    1635         [ #  # ]:          0 :     return aSeq;
    1636                 :            : }
    1637                 :            : 
    1638                 :          0 : sal_Bool SAL_CALL ScExternalDocLinkObj::hasByName(const OUString &aName)
    1639                 :            :         throw (RuntimeException)
    1640                 :            : {
    1641         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1642 [ #  # ][ #  # ]:          0 :     return static_cast<sal_Bool>(mpRefMgr->hasCacheTable(mnFileId, aName));
    1643                 :            : }
    1644                 :            : 
    1645                 :          0 : sal_Int32 SAL_CALL ScExternalDocLinkObj::getCount()
    1646                 :            :         throw (RuntimeException)
    1647                 :            : {
    1648         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1649 [ #  # ][ #  # ]:          0 :     return static_cast<sal_Int32>(mpRefMgr->getCacheTableCount(mnFileId));
    1650                 :            : }
    1651                 :            : 
    1652                 :          0 : Any SAL_CALL ScExternalDocLinkObj::getByIndex(sal_Int32 nIndex)
    1653                 :            :         throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, RuntimeException)
    1654                 :            : {
    1655         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1656         [ #  # ]:          0 :     size_t nTabCount = mpRefMgr->getCacheTableCount(mnFileId);
    1657 [ #  # ][ #  # ]:          0 :     if (nIndex < 0 || nIndex >= static_cast<sal_Int32>(nTabCount))
    1658         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
    1659                 :            : 
    1660         [ #  # ]:          0 :     ScExternalRefCache::TableTypeRef pTable = mpRefMgr->getCacheTable(mnFileId, static_cast<size_t>(nIndex));
    1661         [ #  # ]:          0 :     if (!pTable)
    1662         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
    1663                 :            : 
    1664 [ #  # ][ #  # ]:          0 :     Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(pTable, nIndex));
         [ #  # ][ #  # ]
                 [ #  # ]
    1665                 :            : 
    1666                 :          0 :     Any aAny;
    1667         [ #  # ]:          0 :     aAny <<= aSheetCache;
    1668 [ #  # ][ #  # ]:          0 :     return aAny;
    1669                 :            : }
    1670                 :            : 
    1671                 :          0 : Reference< container::XEnumeration > SAL_CALL ScExternalDocLinkObj::createEnumeration()
    1672                 :            :         throw (RuntimeException)
    1673                 :            : {
    1674         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1675                 :            :     Reference< container::XEnumeration > aRef(
    1676                 :            :         new ScIndexEnumeration(this, OUString(RTL_CONSTASCII_USTRINGPARAM(
    1677 [ #  # ][ #  # ]:          0 :             "com.sun.star.sheet.ExternalDocLink"))));
         [ #  # ][ #  # ]
                 [ #  # ]
    1678         [ #  # ]:          0 :     return aRef;
    1679                 :            : }
    1680                 :            : 
    1681                 :          0 : uno::Type SAL_CALL ScExternalDocLinkObj::getElementType()
    1682                 :            :         throw (RuntimeException)
    1683                 :            : {
    1684         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1685 [ #  # ][ #  # ]:          0 :     return getCppuType(static_cast<Reference<sheet::XExternalDocLink>*>(0));
    1686                 :            : }
    1687                 :            : 
    1688                 :          0 : sal_Bool SAL_CALL ScExternalDocLinkObj::hasElements()
    1689                 :            :         throw (RuntimeException)
    1690                 :            : {
    1691         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1692 [ #  # ][ #  # ]:          0 :     return static_cast<sal_Bool>(mpRefMgr->getCacheTableCount(mnFileId) > 0);
    1693                 :            : }
    1694                 :            : 
    1695                 :          0 : sal_Int32 SAL_CALL ScExternalDocLinkObj::getTokenIndex()
    1696                 :            :         throw (RuntimeException)
    1697                 :            : {
    1698                 :          0 :     return static_cast<sal_Int32>(mnFileId);
    1699                 :            : }
    1700                 :            : 
    1701                 :            : // ============================================================================
    1702                 :            : 
    1703                 :          2 : ScExternalDocLinksObj::ScExternalDocLinksObj(ScDocShell* pDocShell) :
    1704                 :            :     mpDocShell(pDocShell),
    1705         [ +  - ]:          2 :     mpRefMgr(pDocShell->GetDocument()->GetExternalRefManager())
    1706                 :            : {
    1707                 :          2 : }
    1708                 :            : 
    1709                 :          2 : ScExternalDocLinksObj::~ScExternalDocLinksObj()
    1710                 :            : {
    1711         [ -  + ]:          4 : }
    1712                 :            : 
    1713                 :          0 : Reference< sheet::XExternalDocLink > SAL_CALL ScExternalDocLinksObj::addDocLink(
    1714                 :            :     const OUString& aDocName )
    1715                 :            :         throw (RuntimeException)
    1716                 :            : {
    1717         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1718         [ #  # ]:          0 :     sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aDocName);
    1719 [ #  # ][ #  # ]:          0 :     Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpRefMgr, nFileId));
                 [ #  # ]
    1720         [ #  # ]:          0 :     return aDocLink;
    1721                 :            : }
    1722                 :            : 
    1723                 :          0 : Any SAL_CALL ScExternalDocLinksObj::getByName(const::rtl::OUString &aName)
    1724                 :            :         throw (container::NoSuchElementException, lang::WrappedTargetException, RuntimeException)
    1725                 :            : {
    1726         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1727 [ #  # ][ #  # ]:          0 :     if (!mpRefMgr->hasExternalFile(aName))
    1728         [ #  # ]:          0 :         throw container::NoSuchElementException();
    1729                 :            : 
    1730         [ #  # ]:          0 :     sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aName);
    1731 [ #  # ][ #  # ]:          0 :     Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpRefMgr, nFileId));
                 [ #  # ]
    1732                 :            : 
    1733                 :          0 :     Any aAny;
    1734         [ #  # ]:          0 :     aAny <<= aDocLink;
    1735         [ #  # ]:          0 :     return aAny;
    1736                 :            : }
    1737                 :            : 
    1738                 :          0 : Sequence< OUString > SAL_CALL ScExternalDocLinksObj::getElementNames()
    1739                 :            :         throw (RuntimeException)
    1740                 :            : {
    1741         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1742         [ #  # ]:          0 :     sal_uInt16 n = mpRefMgr->getExternalFileCount();
    1743         [ #  # ]:          0 :     Sequence<OUString> aSeq(n);
    1744         [ #  # ]:          0 :     for (sal_uInt16 i = 0; i < n; ++i)
    1745                 :            :     {
    1746         [ #  # ]:          0 :         const OUString* pName = mpRefMgr->getExternalFileName(i);
    1747 [ #  # ][ #  # ]:          0 :         aSeq[i] = pName ? *pName : OUString();
    1748                 :            :     }
    1749                 :            : 
    1750         [ #  # ]:          0 :     return aSeq;
    1751                 :            : }
    1752                 :            : 
    1753                 :          0 : sal_Bool SAL_CALL ScExternalDocLinksObj::hasByName(const OUString &aName)
    1754                 :            :         throw (RuntimeException)
    1755                 :            : {
    1756         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1757 [ #  # ][ #  # ]:          0 :     return mpRefMgr->hasExternalFile(aName);
    1758                 :            : }
    1759                 :            : 
    1760                 :          0 : sal_Int32 SAL_CALL ScExternalDocLinksObj::getCount()
    1761                 :            :         throw (RuntimeException)
    1762                 :            : {
    1763         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1764 [ #  # ][ #  # ]:          0 :     return mpRefMgr->getExternalFileCount();
    1765                 :            : }
    1766                 :            : 
    1767                 :          0 : Any SAL_CALL ScExternalDocLinksObj::getByIndex(sal_Int32 nIndex)
    1768                 :            :         throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, RuntimeException)
    1769                 :            : {
    1770         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1771 [ #  # ][ #  # ]:          0 :     if (nIndex > ::std::numeric_limits<sal_uInt16>::max() || nIndex < ::std::numeric_limits<sal_uInt16>::min())
                 [ #  # ]
    1772         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
    1773                 :            : 
    1774                 :          0 :     sal_uInt16 nFileId = static_cast<sal_uInt16>(nIndex);
    1775                 :            : 
    1776 [ #  # ][ #  # ]:          0 :     if (!mpRefMgr->hasExternalFile(nFileId))
    1777         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
    1778                 :            : 
    1779 [ #  # ][ #  # ]:          0 :     Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpRefMgr, nFileId));
                 [ #  # ]
    1780                 :          0 :     Any aAny;
    1781         [ #  # ]:          0 :     aAny <<= aDocLink;
    1782         [ #  # ]:          0 :     return aAny;
    1783                 :            : }
    1784                 :            : 
    1785                 :          0 : Reference< container::XEnumeration > SAL_CALL ScExternalDocLinksObj::createEnumeration()
    1786                 :            :         throw (RuntimeException)
    1787                 :            : {
    1788         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1789                 :            :     Reference< container::XEnumeration > aRef(
    1790                 :            :         new ScIndexEnumeration(this, OUString(RTL_CONSTASCII_USTRINGPARAM(
    1791 [ #  # ][ #  # ]:          0 :             "com.sun.star.sheet.ExternalDocLinks"))));
         [ #  # ][ #  # ]
                 [ #  # ]
    1792         [ #  # ]:          0 :     return aRef;
    1793                 :            : }
    1794                 :            : 
    1795                 :          0 : uno::Type SAL_CALL ScExternalDocLinksObj::getElementType()
    1796                 :            :         throw (RuntimeException)
    1797                 :            : {
    1798         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1799 [ #  # ][ #  # ]:          0 :     return getCppuType(static_cast<Reference<sheet::XExternalDocLinks>*>(0));
    1800                 :            : }
    1801                 :            : 
    1802                 :          0 : sal_Bool SAL_CALL ScExternalDocLinksObj::hasElements()
    1803                 :            :         throw (RuntimeException)
    1804                 :            : {
    1805         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1806 [ #  # ][ #  # ]:          0 :     return mpRefMgr->getExternalFileCount() > 0;
    1807                 :            : }
    1808                 :            : 
    1809                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10