LCOV - code coverage report
Current view: top level - sc/source/ui/docshell - docsh6.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 135 227 59.5 %
Date: 2014-11-03 Functions: 14 17 82.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10