LCOV - code coverage report
Current view: top level - sc/source/ui/docshell - docsh6.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 73 224 32.6 %
Date: 2012-08-25 Functions: 8 15 53.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 66 380 17.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "scitems.hxx"
      30                 :            : 
      31                 :            : #include <svx/pageitem.hxx>
      32                 :            : #include <sfx2/linkmgr.hxx>
      33                 :            : 
      34                 :            : #include "docsh.hxx"
      35                 :            : 
      36                 :            : #include "stlsheet.hxx"
      37                 :            : #include "stlpool.hxx"
      38                 :            : #include "global.hxx"
      39                 :            : #include "viewdata.hxx"
      40                 :            : #include "tabvwsh.hxx"
      41                 :            : #include "tablink.hxx"
      42                 :            : #include "globstr.hrc"
      43                 :            : #include "scmod.hxx"
      44                 :            : #include "compiler.hxx"
      45                 :            : #include "interpre.hxx"
      46                 :            : #include "calcconfig.hxx"
      47                 :            : 
      48                 :            : #include <vcl/msgbox.hxx>
      49                 :            : 
      50                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      51                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      52                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      53                 :            : #include <com/sun/star/util/XChangesBatch.hpp>
      54                 :            : 
      55                 :            : using ::com::sun::star::beans::XPropertySet;
      56                 :            : using ::com::sun::star::lang::XMultiServiceFactory;
      57                 :            : using ::com::sun::star::container::XNameAccess;
      58                 :            : using ::com::sun::star::util::XChangesBatch;
      59                 :            : using ::com::sun::star::uno::Any;
      60                 :            : using ::com::sun::star::uno::Exception;
      61                 :            : using ::com::sun::star::uno::Reference;
      62                 :            : using ::com::sun::star::uno::Sequence;
      63                 :            : using ::com::sun::star::uno::UNO_QUERY_THROW;
      64                 :            : using ::rtl::OUString;
      65                 :            : 
      66                 :            : namespace {
      67                 :            : 
      68                 :            : struct ScStylePair
      69                 :            : {
      70                 :            :     SfxStyleSheetBase *pSource;
      71                 :            :     SfxStyleSheetBase *pDest;
      72                 :            : };
      73                 :            : 
      74                 :            : }
      75                 :            : 
      76                 :            : // STATIC DATA -----------------------------------------------------------
      77                 :            : 
      78                 :            : //----------------------------------------------------------------------
      79                 :            : 
      80                 :            : //
      81                 :            : //  Ole
      82                 :            : //
      83                 :            : 
      84                 :        181 : void ScDocShell::SetVisArea( const Rectangle & rVisArea )
      85                 :            : {
      86                 :            :     //  with the SnapVisArea call in SetVisAreaOrSize, it's safe to always
      87                 :            :     //  use both the size and position of the VisArea
      88                 :        181 :     SetVisAreaOrSize( rVisArea, sal_True );
      89                 :        181 : }
      90                 :            : 
      91                 :          0 : void lcl_SetTopRight( Rectangle& rRect, const Point& rPos )
      92                 :            : {
      93         [ #  # ]:          0 :     Size aSize = rRect.GetSize();
      94                 :          0 :     rRect.Right() = rPos.X();
      95                 :          0 :     rRect.Left() = rPos.X() - aSize.Width() + 1;
      96                 :          0 :     rRect.Top() = rPos.Y();
      97                 :          0 :     rRect.Bottom() = rPos.Y() + aSize.Height() - 1;
      98                 :          0 : }
      99                 :            : 
     100                 :        500 : void ScDocShell::SetVisAreaOrSize( const Rectangle& rVisArea, sal_Bool bModifyStart )
     101                 :            : {
     102         [ +  - ]:        500 :     sal_Bool bNegativePage = aDocument.IsNegativePage( aDocument.GetVisibleTab() );
     103                 :            : 
     104                 :        500 :     Rectangle aArea = rVisArea;
     105         [ +  - ]:        500 :     if (bModifyStart)
     106                 :            :     {
     107                 :            :         // when loading, don't check for negative values, because the sheet orientation
     108                 :            :         // might be set later
     109         [ +  + ]:        500 :         if ( !aDocument.IsImportingXML() )
     110                 :            :         {
     111 [ -  + ][ #  # ]:        407 :             if ( ( bNegativePage ? (aArea.Right() > 0) : (aArea.Left() < 0) ) || aArea.Top() < 0 )
         [ +  - ][ -  + ]
                 [ -  + ]
     112                 :            :             {
     113                 :            :                 //  VisArea start position can't be negative.
     114                 :            :                 //  Move the VisArea, otherwise only the upper left position would
     115                 :            :                 //  be changed in SnapVisArea, and the size would be wrong.
     116                 :            : 
     117                 :          0 :                 Point aNewPos( 0, Max( aArea.Top(), (long) 0 ) );
     118         [ #  # ]:          0 :                 if ( bNegativePage )
     119                 :            :                 {
     120                 :          0 :                     aNewPos.X() = Min( aArea.Right(), (long) 0 );
     121         [ #  # ]:          0 :                     lcl_SetTopRight( aArea, aNewPos );
     122                 :            :                 }
     123                 :            :                 else
     124                 :            :                 {
     125                 :          0 :                     aNewPos.X() = Max( aArea.Left(), (long) 0 );
     126                 :          0 :                     aArea.SetPos( aNewPos );
     127                 :            :                 }
     128                 :            :             }
     129                 :            :         }
     130                 :            :     }
     131                 :            :     else
     132                 :            :     {
     133         [ #  # ]:          0 :         Rectangle aOldVisArea = SfxObjectShell::GetVisArea();
     134         [ #  # ]:          0 :         if ( bNegativePage )
     135 [ #  # ][ #  # ]:          0 :             lcl_SetTopRight( aArea, aOldVisArea.TopRight() );
     136                 :            :         else
     137                 :          0 :             aArea.SetPos( aOldVisArea.TopLeft() );
     138                 :            :     }
     139                 :            : 
     140                 :            :     //      hier Position anpassen!
     141                 :            : 
     142                 :            :     //  when loading an ole object, the VisArea is set from the document's
     143                 :            :     //  view settings and must be used as-is (document content may not be complete yet).
     144         [ +  + ]:        500 :     if ( !aDocument.IsImportingXML() )
     145         [ +  - ]:        407 :         aDocument.SnapVisArea( aArea );
     146                 :            : 
     147                 :            :     //TODO/LATER: it's unclear which IPEnv is used here
     148                 :            :     /*
     149                 :            :     SvInPlaceEnvironment* pEnv = GetIPEnv();
     150                 :            :     if (pEnv)
     151                 :            :     {
     152                 :            :         Window* pWin = pEnv->GetEditWin();
     153                 :            :         pEnv->MakeScale( aArea.GetSize(), MAP_100TH_MM,
     154                 :            :                             pWin->LogicToPixel( aArea.GetSize() ) );
     155                 :            :     } */
     156                 :            : 
     157                 :            :     //TODO/LATER: formerly in SvInplaceObject
     158         [ +  - ]:        500 :     SfxObjectShell::SetVisArea( aArea );
     159                 :            : 
     160         [ +  + ]:        500 :     if (bIsInplace)                     // Zoom in der InPlace View einstellen
     161                 :            :     {
     162         [ +  - ]:        248 :         ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
     163         [ +  + ]:        248 :         if (pViewSh)
     164                 :            :         {
     165         [ -  + ]:          5 :             if (pViewSh->GetViewData()->GetDocShell() == this)
     166         [ #  # ]:          0 :                 pViewSh->UpdateOleZoom();
     167                 :            :         }
     168                 :            :     }
     169                 :            : 
     170 [ +  - ][ -  + ]:        500 :     if (aDocument.IsEmbedded())
     171                 :            :     {
     172                 :          0 :         ScRange aOld;
     173         [ #  # ]:          0 :         aDocument.GetEmbedded( aOld);
     174         [ #  # ]:          0 :         aDocument.SetEmbedded( aArea );
     175                 :          0 :         ScRange aNew;
     176         [ #  # ]:          0 :         aDocument.GetEmbedded( aNew);
     177         [ #  # ]:          0 :         if (aOld != aNew)
     178         [ #  # ]:          0 :             PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB,PAINT_GRID);
     179                 :            : 
     180                 :            :         //TODO/LATER: currently not implemented
     181                 :            :         //ViewChanged( ASPECT_CONTENT );          // auch im Container anzeigen
     182                 :            :     }
     183                 :        500 : }
     184                 :            : 
     185                 :        255 : sal_Bool ScDocShell::IsOle()
     186                 :            : {
     187                 :        255 :     return (GetCreateMode() == SFX_CREATE_MODE_EMBEDDED);
     188                 :            : }
     189                 :            : 
     190                 :         32 : void ScDocShell::UpdateOle( const ScViewData* pViewData, sal_Bool bSnapSize )
     191                 :            : {
     192                 :            :     //  wenn's gar nicht Ole ist, kann man sich die Berechnungen sparen
     193                 :            :     //  (VisArea wird dann beim Save wieder zurueckgesetzt)
     194                 :            : 
     195         [ -  + ]:         32 :     if (GetCreateMode() == SFX_CREATE_MODE_STANDARD)
     196                 :         32 :         return;
     197                 :            : 
     198                 :            :     OSL_ENSURE(pViewData,"pViewData==0 bei ScDocShell::UpdateOle");
     199                 :            : 
     200         [ #  # ]:          0 :     Rectangle aOldArea = SfxObjectShell::GetVisArea();
     201                 :          0 :     Rectangle aNewArea = aOldArea;
     202                 :            : 
     203         [ #  # ]:          0 :     sal_Bool bEmbedded = aDocument.IsEmbedded();
     204         [ #  # ]:          0 :     if (bEmbedded)
     205         [ #  # ]:          0 :         aNewArea = aDocument.GetEmbeddedRect();
     206                 :            :     else
     207                 :            :     {
     208                 :          0 :         SCTAB nTab = pViewData->GetTabNo();
     209         [ #  # ]:          0 :         if ( nTab != aDocument.GetVisibleTab() )
     210         [ #  # ]:          0 :             aDocument.SetVisibleTab( nTab );
     211                 :            : 
     212         [ #  # ]:          0 :         sal_Bool bNegativePage = aDocument.IsNegativePage( nTab );
     213                 :          0 :         SCCOL nX = pViewData->GetPosX(SC_SPLIT_LEFT);
     214                 :          0 :         SCROW nY = pViewData->GetPosY(SC_SPLIT_BOTTOM);
     215         [ #  # ]:          0 :         Rectangle aMMRect = aDocument.GetMMRect( nX,nY, nX,nY, nTab );
     216         [ #  # ]:          0 :         if (bNegativePage)
     217 [ #  # ][ #  # ]:          0 :             lcl_SetTopRight( aNewArea, aMMRect.TopRight() );
     218                 :            :         else
     219                 :          0 :             aNewArea.SetPos( aMMRect.TopLeft() );
     220         [ #  # ]:          0 :         if (bSnapSize)
     221         [ #  # ]:          0 :             aDocument.SnapVisArea(aNewArea);            // uses the new VisibleTab
     222                 :            :     }
     223                 :            : 
     224 [ #  # ][ #  # ]:          0 :     if (aNewArea != aOldArea)
     225         [ #  # ]:         32 :         SetVisAreaOrSize( aNewArea, true ); // hier muss auch der Start angepasst werden
     226                 :            : }
     227                 :            : 
     228                 :            : //
     229                 :            : //  Style-Krempel fuer Organizer etc.
     230                 :            : //
     231                 :            : 
     232                 :          0 : SfxStyleSheetBasePool* ScDocShell::GetStyleSheetPool()
     233                 :            : {
     234                 :          0 :     return (SfxStyleSheetBasePool*)aDocument.GetStyleSheetPool();
     235                 :            : }
     236                 :            : 
     237                 :            : 
     238                 :            : //  nach dem Laden von Vorlagen aus einem anderen Dokment (LoadStyles, Insert)
     239                 :            : //  muessen die SetItems (ATTR_PAGE_HEADERSET, ATTR_PAGE_FOOTERSET) auf den richtigen
     240                 :            : //  Pool umgesetzt werden, bevor der Quell-Pool geloescht wird.
     241                 :            : 
     242                 :          0 : void lcl_AdjustPool( SfxStyleSheetBasePool* pStylePool )
     243                 :            : {
     244                 :          0 :     pStylePool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, 0xffff);
     245                 :          0 :     SfxStyleSheetBase *pStyle = pStylePool->First();
     246         [ #  # ]:          0 :     while ( pStyle )
     247                 :            :     {
     248         [ #  # ]:          0 :         SfxItemSet& rStyleSet = pStyle->GetItemSet();
     249                 :            : 
     250                 :            :         const SfxPoolItem* pItem;
     251 [ #  # ][ #  # ]:          0 :         if (rStyleSet.GetItemState(ATTR_PAGE_HEADERSET,false,&pItem) == SFX_ITEM_SET)
     252                 :            :         {
     253                 :          0 :             SfxItemSet& rSrcSet = ((SvxSetItem*)pItem)->GetItemSet();
     254 [ #  # ][ #  # ]:          0 :             SfxItemSet* pDestSet = new SfxItemSet(*rStyleSet.GetPool(),rSrcSet.GetRanges());
     255         [ #  # ]:          0 :             pDestSet->Put(rSrcSet);
     256 [ #  # ][ #  # ]:          0 :             rStyleSet.Put(SvxSetItem(ATTR_PAGE_HEADERSET,pDestSet));
                 [ #  # ]
     257                 :            :         }
     258 [ #  # ][ #  # ]:          0 :         if (rStyleSet.GetItemState(ATTR_PAGE_FOOTERSET,false,&pItem) == SFX_ITEM_SET)
     259                 :            :         {
     260                 :          0 :             SfxItemSet& rSrcSet = ((SvxSetItem*)pItem)->GetItemSet();
     261 [ #  # ][ #  # ]:          0 :             SfxItemSet* pDestSet = new SfxItemSet(*rStyleSet.GetPool(),rSrcSet.GetRanges());
     262         [ #  # ]:          0 :             pDestSet->Put(rSrcSet);
     263 [ #  # ][ #  # ]:          0 :             rStyleSet.Put(SvxSetItem(ATTR_PAGE_FOOTERSET,pDestSet));
                 [ #  # ]
     264                 :            :         }
     265                 :            : 
     266         [ #  # ]:          0 :         pStyle = pStylePool->Next();
     267                 :            :     }
     268                 :          0 : }
     269                 :            : 
     270                 :          0 : void ScDocShell::LoadStyles( SfxObjectShell &rSource )
     271                 :            : {
     272                 :          0 :     aDocument.StylesToNames();
     273                 :            : 
     274                 :          0 :     SfxObjectShell::LoadStyles(rSource);
     275                 :          0 :     lcl_AdjustPool( GetStyleSheetPool() );      // SetItems anpassen
     276                 :            : 
     277                 :          0 :     aDocument.UpdStlShtPtrsFrmNms();
     278                 :            : 
     279                 :          0 :     UpdateAllRowHeights();
     280                 :            : 
     281                 :            :         //  Paint
     282                 :            : 
     283                 :          0 :     PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID | PAINT_LEFT );
     284                 :          0 : }
     285                 :            : 
     286                 :          0 : void ScDocShell::LoadStylesArgs( ScDocShell& rSource, bool bReplace, bool bCellStyles, bool bPageStyles )
     287                 :            : {
     288                 :            :     //  similar to LoadStyles, but with selectable behavior for XStyleLoader::loadStylesFromURL call
     289                 :            : 
     290 [ #  # ][ #  # ]:          0 :     if ( !bCellStyles && !bPageStyles )     // nothing to do
     291                 :            :         return;
     292                 :            : 
     293         [ #  # ]:          0 :     ScStyleSheetPool* pSourcePool = rSource.GetDocument()->GetStyleSheetPool();
     294         [ #  # ]:          0 :     ScStyleSheetPool* pDestPool = aDocument.GetStyleSheetPool();
     295                 :            : 
     296                 :            :     SfxStyleFamily eFamily = bCellStyles ?
     297                 :            :             ( bPageStyles ? SFX_STYLE_FAMILY_ALL : SFX_STYLE_FAMILY_PARA ) :
     298 [ #  # ][ #  # ]:          0 :             SFX_STYLE_FAMILY_PAGE;
     299         [ #  # ]:          0 :     SfxStyleSheetIterator aIter( pSourcePool, eFamily );
     300         [ #  # ]:          0 :     sal_uInt16 nSourceCount = aIter.Count();
     301         [ #  # ]:          0 :     if ( nSourceCount == 0 )
     302                 :            :         return;                             // no source styles
     303                 :            : 
     304         [ #  # ]:          0 :     ScStylePair* pStyles = new ScStylePair[ nSourceCount ];
     305                 :          0 :     sal_uInt16 nFound = 0;
     306                 :            : 
     307                 :            :     //  first create all new styles
     308                 :            : 
     309         [ #  # ]:          0 :     SfxStyleSheetBase* pSourceStyle = aIter.First();
     310         [ #  # ]:          0 :     while (pSourceStyle)
     311                 :            :     {
     312 [ #  # ][ #  # ]:          0 :         String aName = pSourceStyle->GetName();
     313 [ #  # ][ #  # ]:          0 :         SfxStyleSheetBase* pDestStyle = pDestPool->Find( pSourceStyle->GetName(), pSourceStyle->GetFamily() );
     314         [ #  # ]:          0 :         if ( pDestStyle )
     315                 :            :         {
     316                 :            :             // touch existing styles only if replace flag is set
     317         [ #  # ]:          0 :             if ( bReplace )
     318                 :            :             {
     319                 :          0 :                 pStyles[nFound].pSource = pSourceStyle;
     320                 :          0 :                 pStyles[nFound].pDest = pDestStyle;
     321                 :          0 :                 ++nFound;
     322                 :            :             }
     323                 :            :         }
     324                 :            :         else
     325                 :            :         {
     326                 :          0 :             pStyles[nFound].pSource = pSourceStyle;
     327         [ #  # ]:          0 :             pStyles[nFound].pDest = &pDestPool->Make( aName, pSourceStyle->GetFamily(), pSourceStyle->GetMask() );
     328                 :          0 :             ++nFound;
     329                 :            :         }
     330                 :            : 
     331         [ #  # ]:          0 :         pSourceStyle = aIter.Next();
     332         [ #  # ]:          0 :     }
     333                 :            : 
     334                 :            :     //  then copy contents (after inserting all styles, for parent etc.)
     335                 :            : 
     336         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < nFound; ++i )
     337                 :            :     {
     338         [ #  # ]:          0 :         pStyles[i].pDest->GetItemSet().PutExtended(
     339 [ #  # ][ #  # ]:          0 :             pStyles[i].pSource->GetItemSet(), SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT);
     340 [ #  # ][ #  # ]:          0 :         if(pStyles[i].pSource->HasParentSupport())
     341 [ #  # ][ #  # ]:          0 :             pStyles[i].pDest->SetParent(pStyles[i].pSource->GetParent());
     342                 :            :         // follow is never used
     343                 :            :     }
     344                 :            : 
     345 [ #  # ][ #  # ]:          0 :     lcl_AdjustPool( GetStyleSheetPool() );      // adjust SetItems
     346         [ #  # ]:          0 :     UpdateAllRowHeights();
     347         [ #  # ]:          0 :     PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID | PAINT_LEFT );      // Paint
     348                 :            : 
     349 [ #  # ][ #  # ]:          0 :     delete[] pStyles;
                 [ #  # ]
     350                 :            : }
     351                 :            : 
     352                 :            : 
     353                 :          0 : sal_Bool ScDocShell::Insert( SfxObjectShell &rSource,
     354                 :            :                                 sal_uInt16 nSourceIdx1, sal_uInt16 nSourceIdx2, sal_uInt16 nSourceIdx3,
     355                 :            :                                 sal_uInt16 &nIdx1, sal_uInt16 &nIdx2, sal_uInt16 &nIdx3, sal_uInt16 &rIdxDeleted )
     356                 :            : {
     357                 :            :     sal_Bool bRet = SfxObjectShell::Insert( rSource, nSourceIdx1, nSourceIdx2, nSourceIdx3,
     358                 :          0 :                                             nIdx1, nIdx2, nIdx3, rIdxDeleted );
     359         [ #  # ]:          0 :     if (bRet)
     360                 :          0 :         lcl_AdjustPool( GetStyleSheetPool() );      // SetItems anpassen
     361                 :            : 
     362                 :          0 :     return bRet;
     363                 :            : }
     364                 :            : 
     365                 :        310 : void ScDocShell::ReconnectDdeLink(SfxObjectShell& rServer)
     366                 :            : {
     367                 :        310 :     ::sfx2::LinkManager* pLinkManager = aDocument.GetLinkManager();
     368         [ -  + ]:        310 :     if (!pLinkManager)
     369                 :        310 :         return;
     370                 :            : 
     371                 :        310 :     pLinkManager->ReconnectDdeLink(rServer);
     372                 :            : }
     373                 :            : 
     374                 :        120 : void ScDocShell::UpdateLinks()
     375                 :            : {
     376                 :            :     typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> StrSetType;
     377                 :            : 
     378         [ +  - ]:        120 :     sfx2::LinkManager* pLinkManager = aDocument.GetLinkManager();
     379         [ +  - ]:        120 :     StrSetType aNames;
     380                 :            : 
     381                 :            :     // nicht mehr benutzte Links raus
     382                 :            : 
     383                 :        120 :     sal_uInt16 nCount = pLinkManager->GetLinks().size();
     384         [ -  + ]:        120 :     for (sal_uInt16 k=nCount; k>0; )
     385                 :            :     {
     386                 :          0 :         --k;
     387                 :          0 :         ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[k];
     388 [ #  # ][ #  # ]:          0 :         if (pBase->ISA(ScTableLink))
                 [ #  # ]
     389                 :            :         {
     390                 :          0 :             ScTableLink* pTabLink = (ScTableLink*)pBase;
     391 [ #  # ][ #  # ]:          0 :             if (pTabLink->IsUsed())
     392         [ #  # ]:          0 :                 aNames.insert(pTabLink->GetFileName());
     393                 :            :             else        // nicht mehr benutzt -> loeschen
     394                 :            :             {
     395                 :          0 :                 pTabLink->SetAddUndo(sal_True);
     396         [ #  # ]:          0 :                 pLinkManager->Remove(k);
     397                 :            :             }
     398                 :            :         }
     399                 :            :     }
     400                 :            : 
     401                 :            :     // neue Links eintragen
     402                 :            : 
     403         [ +  - ]:        120 :     SCTAB nTabCount = aDocument.GetTableCount();
     404         [ +  + ]:        407 :     for (SCTAB i = 0; i < nTabCount; ++i)
     405                 :            :     {
     406 [ +  - ][ +  + ]:        287 :         if (!aDocument.IsLinked(i))
     407                 :        285 :             continue;
     408                 :            : 
     409         [ +  - ]:          2 :         rtl::OUString aDocName = aDocument.GetLinkDoc(i);
     410         [ +  - ]:          2 :         rtl::OUString aFltName = aDocument.GetLinkFlt(i);
     411         [ +  - ]:          2 :         rtl::OUString aOptions = aDocument.GetLinkOpt(i);
     412         [ +  - ]:          2 :         sal_uLong nRefresh  = aDocument.GetLinkRefreshDelay(i);
     413                 :          2 :         bool bThere = false;
     414 [ -  + ][ #  # ]:          2 :         for (SCTAB j = 0; j < i && !bThere; ++j)                // im Dokument mehrfach?
                 [ -  + ]
     415                 :            :         {
     416 [ #  # ][ #  #  :          0 :             if (aDocument.IsLinked(j)
          #  #  #  #  #  
              # ][ #  # ]
     417 [ #  # ][ #  # ]:          0 :                     && aDocument.GetLinkDoc(j) == aDocName
                 [ #  # ]
     418 [ #  # ][ #  # ]:          0 :                     && aDocument.GetLinkFlt(j) == aFltName
                 [ #  # ]
     419 [ #  # ][ #  # ]:          0 :                     && aDocument.GetLinkOpt(j) == aOptions)
                 [ #  # ]
     420                 :            :                     // Ignore refresh delay in compare, it should be the
     421                 :            :                     // same for identical links and we don't want dupes
     422                 :            :                     // if it ain't.
     423                 :          0 :                 bThere = true;
     424                 :            :         }
     425                 :            : 
     426         [ +  - ]:          2 :         if (!bThere)                                        // schon als Filter eingetragen?
     427                 :            :         {
     428 [ +  - ][ -  + ]:          2 :             if (!aNames.insert(aDocName).second)
     429                 :          0 :                 bThere = true;
     430                 :            :         }
     431                 :            : 
     432         [ +  - ]:          2 :         if (!bThere)
     433                 :            :         {
     434 [ +  - ][ +  - ]:          2 :             ScTableLink* pLink = new ScTableLink( this, aDocName, aFltName, aOptions, nRefresh );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     435                 :          2 :             pLink->SetInCreate(true);
     436         [ +  - ]:          2 :             pLinkManager->InsertFileLink(*pLink, OBJECT_CLIENT_FILE, aDocName, &aFltName);
     437         [ +  - ]:          2 :             pLink->Update();
     438                 :          2 :             pLink->SetInCreate(false);
     439                 :            :         }
     440         [ +  - ]:        122 :     }
     441                 :        120 : }
     442                 :            : 
     443                 :          0 : sal_Bool ScDocShell::ReloadTabLinks()
     444                 :            : {
     445                 :          0 :     sfx2::LinkManager* pLinkManager = aDocument.GetLinkManager();
     446                 :            : 
     447                 :          0 :     sal_Bool bAny = false;
     448                 :          0 :     sal_uInt16 nCount = pLinkManager->GetLinks().size();
     449         [ #  # ]:          0 :     for (sal_uInt16 i=0; i<nCount; i++ )
     450                 :            :     {
     451                 :          0 :         ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
     452         [ #  # ]:          0 :         if (pBase->ISA(ScTableLink))
     453                 :            :         {
     454                 :          0 :             ScTableLink* pTabLink = (ScTableLink*)pBase;
     455                 :          0 :             pTabLink->SetPaint(false);          //  Paint nur einmal am Ende
     456                 :          0 :             pTabLink->Update();
     457                 :          0 :             pTabLink->SetPaint(true);
     458                 :          0 :             bAny = true;
     459                 :            :         }
     460                 :            :     }
     461                 :            : 
     462         [ #  # ]:          0 :     if ( bAny )
     463                 :            :     {
     464                 :            :         //  Paint nur einmal
     465                 :            :         PostPaint( ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB),
     466 [ #  # ][ #  # ]:          0 :                                     PAINT_GRID | PAINT_TOP | PAINT_LEFT );
                 [ #  # ]
     467                 :            : 
     468                 :          0 :         SetDocumentModified();
     469                 :            :     }
     470                 :            : 
     471                 :          0 :     return sal_True;        //! Fehler erkennen
     472                 :            : }
     473                 :            : 
     474                 :        412 : void ScDocShell::SetFormulaOptions(const ScFormulaOptions& rOpt )
     475                 :            : {
     476                 :        412 :     aDocument.SetGrammar( rOpt.GetFormulaSyntax() );
     477                 :            : 
     478                 :            :     // This needs to be called first since it may re-initialize the entire
     479                 :            :     // opcode map.
     480         [ -  + ]:        412 :     if (rOpt.GetUseEnglishFuncName())
     481                 :            :     {
     482                 :            :         // switch native symbols to English.
     483         [ #  # ]:          0 :         ScCompiler aComp(NULL, ScAddress());
     484         [ #  # ]:          0 :         ScCompiler::OpCodeMapPtr xMap = aComp.GetOpCodeMap(::com::sun::star::sheet::FormulaLanguage::ENGLISH);
     485 [ #  # ][ #  # ]:          0 :         ScCompiler::SetNativeSymbols(xMap);
                 [ #  # ]
     486                 :            :     }
     487                 :            :     else
     488                 :            :         // re-initialize native symbols with localized function names.
     489                 :        412 :         ScCompiler::ResetNativeSymbols();
     490                 :            : 
     491                 :            :     // Force re-population of function names for the function wizard, function tip etc.
     492                 :        412 :     ScGlobal::ResetFunctionList();
     493                 :            : 
     494                 :            :     // Update the separators.
     495                 :            :     ScCompiler::UpdateSeparatorsNative(
     496         [ +  - ]:        412 :         rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
     497                 :            : 
     498                 :            :     // Global interpreter settings.
     499                 :        412 :     ScInterpreter::SetGlobalConfig(rOpt.GetCalcConfig());
     500                 :        412 : }
     501                 :            : 
     502                 :        223 : void ScDocShell::CheckConfigOptions()
     503                 :            : {
     504 [ +  - ][ +  + ]:        223 :     if (IsConfigOptionsChecked())
     505                 :            :         // no need to check repeatedly.
     506                 :        223 :         return;
     507                 :            : 
     508 [ +  - ][ +  - ]:        221 :     OUString aDecSep = ScGlobal::GetpLocaleData()->getNumDecimalSep();
     509                 :            : 
     510         [ +  - ]:        221 :     ScModule* pScMod = SC_MOD();
     511         [ +  - ]:        221 :     const ScFormulaOptions& rOpt=pScMod->GetFormulaOptions();
     512                 :        221 :     OUString aSepArg = rOpt.GetFormulaSepArg();
     513                 :        221 :     OUString aSepArrRow = rOpt.GetFormulaSepArrayRow();
     514                 :        221 :     OUString aSepArrCol = rOpt.GetFormulaSepArrayCol();
     515                 :            : 
     516 [ +  - ][ -  + ]:        221 :     if (aDecSep == aSepArg || aDecSep == aSepArrRow || aDecSep == aSepArrCol)
         [ -  + ][ +  - ]
     517                 :            :     {
     518                 :            :         // One of arg separators conflicts with the current decimal
     519                 :            :         // separator.  Reset them to default.
     520         [ #  # ]:          0 :         ScFormulaOptions aNew = rOpt;
     521         [ #  # ]:          0 :         aNew.ResetFormulaSeparators();
     522         [ #  # ]:          0 :         SetFormulaOptions(aNew);
     523         [ #  # ]:          0 :         pScMod->SetFormulaOptions(aNew);
     524                 :            : 
     525                 :            :         // Launch a nice warning dialog to let the users know of this change.
     526         [ #  # ]:          0 :         ScTabViewShell* pViewShell = GetBestViewShell();
     527         [ #  # ]:          0 :         if (pViewShell)
     528                 :            :         {
     529                 :          0 :             Window* pParent = pViewShell->GetFrameWin();
     530 [ #  # ][ #  # ]:          0 :             InfoBox aBox(pParent, ScGlobal::GetRscString(STR_OPTIONS_WARN_SEPARATORS));
     531 [ #  # ][ #  # ]:          0 :             aBox.Execute();
     532         [ #  # ]:          0 :         }
     533                 :            : 
     534                 :            :         // For now, this is the only option setting that could launch info
     535                 :            :         // dialog.  But in the future we may want to implement a nicer
     536                 :            :         // dialog to display a list of warnings in case we have several
     537                 :            :         // pieces of information to display.
     538                 :            :     }
     539                 :            : 
     540         [ +  - ]:        223 :     SetConfigOptionsChecked(true);
     541                 :            : }
     542                 :            : 
     543                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10