LCOV - code coverage report
Current view: top level - sc/source/ui/formdlg - formula.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 2 327 0.6 %
Date: 2014-04-11 Functions: 2 44 4.5 %
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             : #include <sfx2/dispatch.hxx>
      22             : #include <sfx2/docfile.hxx>
      23             : #include <sfx2/objsh.hxx>
      24             : #include <svl/zforlist.hxx>
      25             : #include <svl/stritem.hxx>
      26             : #include <svtools/treelistbox.hxx>
      27             : #include <sfx2/viewfrm.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/mnemonic.hxx>
      30             : #include <unotools/charclass.hxx>
      31             : #include <tools/urlobj.hxx>
      32             : #include <formula/formulahelper.hxx>
      33             : #include <formula/IFunctionDescription.hxx>
      34             : 
      35             : #include "tokenuno.hxx"
      36             : #include "formula.hxx"
      37             : #include "formdata.hxx"
      38             : #include "globstr.hrc"
      39             : #include "scresid.hxx"
      40             : #include "reffact.hxx"
      41             : #include "document.hxx"
      42             : #include "simpleformulacalc.hxx"
      43             : #include "scmod.hxx"
      44             : #include "inputhdl.hxx"
      45             : #include "tabvwsh.hxx"
      46             : #include "appoptio.hxx"
      47             : #include "docsh.hxx"
      48             : #include "funcdesc.hxx"
      49             : #include "formula/token.hxx"
      50             : #include "tokenarray.hxx"
      51             : #include "sc.hrc"
      52             : #include "servuno.hxx"
      53             : #include "unonames.hxx"
      54             : #include "externalrefmgr.hxx"
      55             : 
      56             : #include <com/sun/star/table/CellAddress.hpp>
      57             : 
      58             : 
      59             : using namespace formula;
      60             : using namespace com::sun::star;
      61             : 
      62             : ScDocument* ScFormulaDlg::pDoc = NULL;
      63          34 : ScAddress ScFormulaDlg::aCursorPos;
      64             : 
      65             : 
      66             : //      Initialisierung / gemeinsame Funktionen  fuer Dialog
      67             : 
      68             : 
      69           0 : ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
      70             :                                     Window* pParent, ScViewData* pViewData,formula::IFunctionManager* _pFunctionMgr )
      71             :     : formula::FormulaDlg( pB, pCW, pParent, true,true,true, _pFunctionMgr,this)
      72           0 :     , m_aHelper(this,pB)
      73             : {
      74           0 :     m_aHelper.SetWindow(this);
      75           0 :     ScModule* pScMod = SC_MOD();
      76           0 :     pScMod->InputEnterHandler();
      77           0 :     ScTabViewShell* pScViewShell = NULL;
      78             : 
      79             :     // title has to be from the view that opened the dialog,
      80             :     // even if it's not the current view
      81             : 
      82           0 :     if ( pB )
      83             :     {
      84           0 :         SfxDispatcher* pMyDisp = pB->GetDispatcher();
      85           0 :         if (pMyDisp)
      86             :         {
      87           0 :             SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame();
      88           0 :             if (pMyViewFrm)
      89             :             {
      90           0 :                 pScViewShell = PTR_CAST( ScTabViewShell, pMyViewFrm->GetViewShell() );
      91           0 :                 if( pScViewShell )
      92           0 :                     pScViewShell->UpdateInputHandler(true);
      93             :             }
      94             :         }
      95             :     }
      96             : 
      97           0 :     if ( pDoc == NULL )
      98           0 :         pDoc = pViewData->GetDocument();
      99           0 :     m_xParser.set(ScServiceProvider::MakeInstance(SC_SERVICE_FORMULAPARS,(ScDocShell*)pDoc->GetDocumentShell()),uno::UNO_QUERY);
     100           0 :     uno::Reference< beans::XPropertySet> xSet(m_xParser,uno::UNO_QUERY);
     101           0 :     xSet->setPropertyValue(OUString(SC_UNO_COMPILEFAP),uno::makeAny(sal_True));
     102             : 
     103           0 :     m_xOpCodeMapper.set(ScServiceProvider::MakeInstance(SC_SERVICE_OPCODEMAPPER,(ScDocShell*)pDoc->GetDocumentShell()),uno::UNO_QUERY);
     104             : 
     105           0 :     ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(pScViewShell);
     106             : 
     107             :     OSL_ENSURE( pInputHdl, "Missing input handler :-/" );
     108             : 
     109           0 :     if ( pInputHdl )
     110           0 :         pInputHdl->NotifyChange( NULL );
     111             : 
     112           0 :     m_aHelper.enableInput( false );
     113           0 :     m_aHelper.EnableSpreadsheets();
     114           0 :     m_aHelper.Init();
     115           0 :     m_aHelper.SetDispatcherLock( true );
     116             : 
     117           0 :     notifyChange();
     118           0 :     fill();
     119             : 
     120           0 :     ScFormEditData* pData = pScMod->GetFormEditData();
     121           0 :     if (!pData)
     122             :     {
     123             :         //Nun wird es Zeit den Inputhandler festzulegen
     124           0 :         pScMod->SetRefInputHdl(pScMod->GetInputHdl());
     125             : 
     126           0 :         pDoc = pViewData->GetDocument();
     127           0 :         SCCOL nCol = pViewData->GetCurX();
     128           0 :         SCROW nRow = pViewData->GetCurY();
     129           0 :         SCTAB nTab = pViewData->GetTabNo();
     130           0 :         aCursorPos = ScAddress( nCol, nRow, nTab );
     131             : 
     132           0 :         pScMod->InitFormEditData();                             // neu anlegen
     133           0 :         pData = pScMod->GetFormEditData();
     134           0 :         pData->SetInputHandler(pScMod->GetInputHdl());
     135           0 :         pData->SetDocShell(pViewData->GetDocShell());
     136             : 
     137             :         OSL_ENSURE(pData,"FormEditData ist nicht da");
     138             : 
     139           0 :         formula::FormulaDlgMode eMode = FORMULA_FORMDLG_FORMULA;            // Default...
     140             : 
     141             :         //  Formel vorhanden? Dann editieren
     142             : 
     143           0 :         OUString aFormula;
     144           0 :         pDoc->GetFormula( nCol, nRow, nTab, aFormula );
     145           0 :         sal_Bool bEdit   = ( aFormula.getLength() > 1 );
     146           0 :         sal_Bool bMatrix = false;
     147           0 :         if ( bEdit )
     148             :         {
     149           0 :             bMatrix = CheckMatrix(aFormula);
     150             : 
     151           0 :             sal_Int32 nFStart = 0;
     152           0 :             sal_Int32 nFEnd   = 0;
     153           0 :             if ( GetFormulaHelper().GetNextFunc( aFormula, false, nFStart, &nFEnd) )
     154             :             {
     155           0 :                 pScMod->InputReplaceSelection( aFormula );
     156           0 :                 pScMod->InputSetSelection( nFStart, nFEnd );
     157             :                 sal_Int32 PrivStart, PrivEnd;
     158           0 :                 pScMod->InputGetSelection( PrivStart, PrivEnd);
     159             : 
     160           0 :                 eMode = SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd, bMatrix, true, true);
     161           0 :                 pData->SetFStart( nFStart );
     162             :             }
     163             :             else
     164           0 :                 bEdit = false;
     165             :         }
     166             : 
     167           0 :         if ( !bEdit )
     168             :         {
     169           0 :             OUString aNewFormula('=');
     170           0 :             if ( aFormula.startsWith("=") )
     171           0 :                 aNewFormula = aFormula;
     172             : 
     173           0 :             pScMod->InputReplaceSelection( aNewFormula );
     174           0 :             pScMod->InputSetSelection( 1, aNewFormula.getLength()+1 );
     175             :             sal_Int32 PrivStart, PrivEnd;
     176           0 :             pScMod->InputGetSelection( PrivStart, PrivEnd);
     177           0 :             SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd,bMatrix,false,false);
     178             : 
     179           0 :             pData->SetFStart( 1 );      // hinter dem "="
     180             :         }
     181             : 
     182           0 :         pData->SetMode( (sal_uInt16) eMode );
     183           0 :         OUString rStrExp = GetMeText();
     184             : 
     185           0 :         Update(rStrExp);
     186           0 :     }
     187             : 
     188           0 : }
     189             : 
     190           0 : void ScFormulaDlg::notifyChange()
     191             : {
     192           0 :     ScModule* pScMod = SC_MOD();
     193             : 
     194           0 :     ScInputHandler* pInputHdl = pScMod->GetInputHdl();
     195           0 :     if ( pInputHdl )
     196           0 :         pInputHdl->NotifyChange( NULL );
     197           0 : }
     198             : 
     199           0 : void ScFormulaDlg::fill()
     200             : {
     201           0 :     ScModule* pScMod = SC_MOD();
     202           0 :     ScFormEditData* pData = pScMod->GetFormEditData();
     203           0 :     notifyChange();
     204           0 :     OUString rStrExp;
     205           0 :     if (pData)
     206             :     {
     207             :         //  Daten schon vorhanden -> Zustand wiederherstellen (nach Umschalten)
     208             :         //  pDoc und aCursorPos nicht neu initialisieren
     209             :         //pDoc = pViewData->GetDocument();
     210           0 :         if(IsInputHdl(pData->GetInputHandler()))
     211             :         {
     212           0 :             pScMod->SetRefInputHdl(pData->GetInputHandler());
     213             :         }
     214             :         else
     215             :         {
     216             :             PtrTabViewShell pTabViewShell;
     217           0 :             ScInputHandler* pInputHdl = GetNextInputHandler(pData->GetDocShell(),&pTabViewShell);
     218             : 
     219           0 :             if ( pInputHdl == NULL ) //DocShell hat keinen InputHandler mehr,
     220             :             {                   //hat der Anwender halt Pech gehabt.
     221           0 :                 disableOk();
     222           0 :                 pInputHdl = pScMod->GetInputHdl();
     223             :             }
     224             :             else
     225             :             {
     226           0 :                 pInputHdl->SetRefViewShell(pTabViewShell);
     227             :             }
     228           0 :             pScMod->SetRefInputHdl(pInputHdl);
     229           0 :             pData->SetInputHandler(pInputHdl);
     230             :         }
     231             : 
     232           0 :         OUString aOldFormulaTmp(pScMod->InputGetFormulaStr());
     233           0 :         pScMod->InputSetSelection( 0, aOldFormulaTmp.getLength());
     234             : 
     235           0 :         rStrExp=pData->GetUndoStr();
     236           0 :         pScMod->InputReplaceSelection(rStrExp);
     237             : 
     238           0 :         SetMeText(rStrExp);
     239             : 
     240           0 :         Update();
     241             :         // Jetzt nochmals zurueckschalten, da evtl. neues Doc geoeffnet wurde!
     242           0 :         pScMod->SetRefInputHdl(NULL);
     243           0 :     }
     244           0 : }
     245             : 
     246           0 : ScFormulaDlg::~ScFormulaDlg()
     247             : {
     248           0 :     ScModule* pScMod = SC_MOD();
     249           0 :     ScFormEditData* pData = pScMod->GetFormEditData();
     250             : 
     251           0 :     if (pData) // wird nicht ueber Close zerstoert;
     252             :     {
     253             :         //Referenz Inputhandler zuruecksetzen
     254           0 :         pScMod->SetRefInputHdl(NULL);
     255           0 :         StoreFormEditData(pData);
     256             :     } // if (pData) // wird nicht ueber Close zerstoert;
     257           0 : }
     258             : 
     259           0 : bool ScFormulaDlg::IsInputHdl(ScInputHandler* pHdl)
     260             : {
     261           0 :     bool bAlive = false;
     262             : 
     263             :     //  gehoert der InputHandler zu irgendeiner ViewShell ?
     264             : 
     265           0 :     TypeId aScType = TYPE(ScTabViewShell);
     266           0 :     SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
     267           0 :     while ( pSh && !bAlive )
     268             :     {
     269           0 :         if (((ScTabViewShell*)pSh)->GetInputHandler() == pHdl)
     270           0 :             bAlive = true;
     271           0 :         pSh = SfxViewShell::GetNext( *pSh, &aScType );
     272             :     }
     273             : 
     274           0 :     return bAlive;
     275             : 
     276             : }
     277             : 
     278           0 : ScInputHandler* ScFormulaDlg::GetNextInputHandler(ScDocShell* pDocShell,PtrTabViewShell* ppViewSh)
     279             : {
     280           0 :     ScInputHandler* pHdl=NULL;
     281             : 
     282           0 :     SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
     283           0 :     while( pFrame && pHdl==NULL)
     284             :     {
     285           0 :         SfxViewShell* p = pFrame->GetViewShell();
     286           0 :         ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
     287           0 :         if(pViewSh!=NULL)
     288             :         {
     289           0 :             pHdl=pViewSh->GetInputHandler();
     290           0 :             if(ppViewSh!=NULL) *ppViewSh=pViewSh;
     291             :         }
     292           0 :         pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
     293             :     }
     294             : 
     295             : 
     296           0 :     return pHdl;
     297             : }
     298             : 
     299             : 
     300           0 : bool ScFormulaDlg::Close()
     301             : {
     302           0 :     DoEnter(false);
     303           0 :     return true;
     304             : }
     305             : 
     306             : 
     307             : //                          Funktionen fuer rechte Seite
     308             : 
     309           0 : bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult )
     310             : {
     311           0 :     boost::scoped_ptr<ScSimpleFormulaCalculator> pFCell( new ScSimpleFormulaCalculator( pDoc, aCursorPos, rStrExp ) );
     312             : 
     313             :     // HACK! um bei ColRowNames kein #REF! zu bekommen,
     314             :     // wenn ein Name eigentlich als Bereich in die Gesamt-Formel
     315             :     // eingefuegt wird, bei der Einzeldarstellung aber als
     316             :     // single-Zellbezug interpretiert wird
     317           0 :     sal_Bool bColRowName = pFCell->HasColRowName();
     318           0 :     if ( bColRowName )
     319             :     {
     320             :         // ColRowName im RPN-Code?
     321           0 :         if ( pFCell->GetCode()->GetCodeLen() <= 1 )
     322             :         {   // ==1: einzelner ist als Parameter immer Bereich
     323             :             // ==0: es waere vielleicht einer, wenn..
     324           0 :             OUStringBuffer aBraced;
     325           0 :             aBraced.append('(');
     326           0 :             aBraced.append(rStrExp);
     327           0 :             aBraced.append(')');
     328           0 :             pFCell.reset( new ScSimpleFormulaCalculator( pDoc, aCursorPos, aBraced.makeStringAndClear() ) );
     329             :         }
     330             :         else
     331           0 :             bColRowName = false;
     332             :     }
     333             : 
     334           0 :     sal_uInt16 nErrCode = pFCell->GetErrCode();
     335           0 :     if ( nErrCode == 0 )
     336             :     {
     337           0 :         SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
     338             :         Color* pColor;
     339           0 :         if ( pFCell->IsValue() )
     340             :         {
     341           0 :             double n = pFCell->GetValue();
     342             :             sal_uLong nFormat = aFormatter.GetStandardFormat( n, 0,
     343           0 :                             pFCell->GetFormatType(), ScGlobal::eLnge );
     344             :             aFormatter.GetOutputString( n, nFormat,
     345           0 :                                         rStrResult, &pColor );
     346             :         }
     347             :         else
     348             :         {
     349             :             sal_uLong nFormat = aFormatter.GetStandardFormat(
     350           0 :                             pFCell->GetFormatType(), ScGlobal::eLnge);
     351             :             aFormatter.GetOutputString( pFCell->GetString().getString(), nFormat,
     352           0 :                                         rStrResult, &pColor );
     353             :         }
     354             : 
     355           0 :         ScRange aTestRange;
     356           0 :         if ( bColRowName || (aTestRange.Parse(rStrExp) & SCA_VALID) )
     357           0 :             rStrResult += " ...";
     358             :             // Bereich
     359             :     }
     360             :     else
     361           0 :         rStrResult += ScGlobal::GetErrorString(nErrCode);
     362             : 
     363           0 :     return true;
     364             : }
     365             : 
     366             : //  virtuelle Methoden von ScAnyRefDlg:
     367           0 : void ScFormulaDlg::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
     368             : {
     369           0 :     pEdit->SetSelection(Selection(0, SELECTION_MAX));
     370           0 :     ::std::pair<formula::RefButton*,formula::RefEdit*> aPair = RefInputStartBefore( pEdit, pButton );
     371           0 :     m_aHelper.RefInputStart( aPair.second, aPair.first);
     372           0 :     RefInputStartAfter( aPair.second, aPair.first );
     373           0 : }
     374             : 
     375           0 : void ScFormulaDlg::RefInputDone( bool bForced )
     376             : {
     377           0 :     m_aHelper.RefInputDone( bForced );
     378           0 :     RefInputDoneAfter( bForced );
     379           0 : }
     380             : 
     381           0 : void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc )
     382             : {
     383           0 :     const IFunctionDescription* pFunc = getCurrentFunctionDescription();
     384           0 :     if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
     385             :     {
     386           0 :         Selection theSel;
     387           0 :         sal_Bool bRefNull = UpdateParaWin(theSel);
     388             : 
     389           0 :         if ( rRef.aStart != rRef.aEnd && bRefNull )
     390             :         {
     391           0 :             RefInputStart(GetActiveEdit());
     392             :         }
     393             : 
     394           0 :         OUString      aRefStr;
     395           0 :         sal_Bool bOtherDoc = ( pRefDoc != pDoc && pRefDoc->GetDocumentShell()->HasName() );
     396           0 :         if ( bOtherDoc )
     397             :         {
     398             :             //  Referenz auf anderes Dokument - wie inputhdl.cxx
     399             : 
     400             :             OSL_ENSURE(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
     401             : 
     402           0 :             OUString aTmp(rRef.Format(SCA_VALID|SCA_TAB_3D, pRefDoc));     // immer 3d
     403             : 
     404           0 :             SfxObjectShell* pObjSh = pRefDoc->GetDocumentShell();
     405             : 
     406             :             // #i75893# convert escaped URL of the document to something user friendly
     407             : //           OUString aFileName = pObjSh->GetMedium()->GetName();
     408           0 :             OUString aFileName = pObjSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
     409             : 
     410           0 :             aRefStr = "'";
     411           0 :             aRefStr += aFileName;
     412           0 :             aRefStr += "'#";
     413           0 :             aRefStr += aTmp;
     414             :         }
     415             :         else
     416             :         {
     417             :             // We can't use ScRange::Format here because in R1C1 mode we need
     418             :             // to display the reference position relative to the cursor
     419             :             // position.
     420           0 :             ScTokenArray aArray;
     421             :             ScComplexRefData aRefData;
     422           0 :             aRefData.InitRangeRel(rRef, aCursorPos);
     423           0 :             bool bSingle = aRefData.Ref1 == aRefData.Ref2;
     424           0 :             if (aCursorPos.Tab() != rRef.aStart.Tab())
     425           0 :                 aRefData.Ref1.SetFlag3D(true);
     426           0 :             if (bSingle)
     427           0 :                 aArray.AddSingleReference(aRefData.Ref1);
     428             :             else
     429           0 :                 aArray.AddDoubleReference(aRefData);
     430           0 :             ScCompiler aComp(pDoc, aCursorPos, aArray);
     431           0 :             aComp.SetGrammar(pDoc->GetGrammar());
     432           0 :             OUStringBuffer aBuf;
     433           0 :             aComp.CreateStringFromTokenArray(aBuf);
     434           0 :             aRefStr = aBuf.makeStringAndClear();
     435             :         }
     436             : 
     437           0 :         UpdateParaWin(theSel,aRefStr);
     438             :     }
     439           0 : }
     440             : 
     441           0 : bool ScFormulaDlg::IsRefInputMode() const
     442             : {
     443           0 :     const IFunctionDescription* pDesc = getCurrentFunctionDescription();
     444           0 :     bool bRef = (pDesc && (pDesc->getSuppressedArgumentCount() > 0)) && (pDoc!=NULL);
     445           0 :     return bRef;
     446             : }
     447             : 
     448           0 : bool ScFormulaDlg::IsDocAllowed(SfxObjectShell* pDocSh) const
     449             : {
     450             :     //  not allowed: different from this doc, and no name
     451             :     //  pDocSh is always a ScDocShell
     452           0 :     if ( pDocSh && ((ScDocShell*)pDocSh)->GetDocument() != pDoc && !pDocSh->HasName() )
     453           0 :         return false;
     454             : 
     455           0 :     return true;        // everything else is allowed
     456             : }
     457             : 
     458           0 : void ScFormulaDlg::SetActive()
     459             : {
     460           0 :     const IFunctionDescription* pFunc = getCurrentFunctionDescription();
     461           0 :     if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
     462             :     {
     463           0 :         RefInputDone();
     464           0 :         SetEdSelection();
     465             :     }
     466           0 : }
     467             : 
     468           0 : void ScFormulaDlg::SaveLRUEntry(const ScFuncDesc* pFuncDescP)
     469             : {
     470           0 :     if (pFuncDescP && pFuncDescP->nFIndex!=0)
     471             :     {
     472           0 :         ScModule* pScMod = SC_MOD();
     473           0 :         pScMod->InsertEntryToLRUList(pFuncDescP->nFIndex);
     474             :     }
     475           0 : }
     476             : 
     477           0 : void ScFormulaDlg::doClose(bool /*_bOk*/)
     478             : {
     479           0 :     m_aHelper.DoClose( ScFormulaDlgWrapper::GetChildWindowId() );
     480           0 : }
     481           0 : void ScFormulaDlg::insertEntryToLRUList(const formula::IFunctionDescription*    _pDesc)
     482             : {
     483           0 :     const ScFuncDesc* pDesc = dynamic_cast<const ScFuncDesc*>(_pDesc);
     484           0 :     SaveLRUEntry(pDesc);
     485           0 : }
     486           0 : void ScFormulaDlg::showReference(const OUString& _sFormula)
     487             : {
     488           0 :     ShowReference(_sFormula);
     489           0 : }
     490           0 : void ScFormulaDlg::ShowReference(const OUString& _sFormula)
     491             : {
     492           0 :     m_aHelper.ShowReference(_sFormula);
     493           0 : }
     494           0 : void ScFormulaDlg::HideReference( bool bDoneRefMode )
     495             : {
     496           0 :     m_aHelper.HideReference(bDoneRefMode);
     497           0 : }
     498           0 : void ScFormulaDlg::ViewShellChanged()
     499             : {
     500           0 :     m_aHelper.ViewShellChanged();
     501           0 : }
     502           0 : void ScFormulaDlg::AddRefEntry( )
     503             : {
     504             : 
     505           0 : }
     506           0 : bool ScFormulaDlg::IsTableLocked( ) const
     507             : {
     508             :     // per Default kann bei Referenzeingabe auch die Tabelle umgeschaltet werden
     509           0 :     return false;
     510             : }
     511           0 : void ScFormulaDlg::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton)
     512             : {
     513           0 :     m_aHelper.ToggleCollapsed(pEdit,pButton);
     514           0 : }
     515           0 : void ScFormulaDlg::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton)
     516             : {
     517           0 :     m_aHelper.ReleaseFocus(pEdit,pButton);
     518           0 : }
     519           0 : void ScFormulaDlg::dispatch(bool _bOK, bool _bMatrixChecked)
     520             : {
     521           0 :     SfxBoolItem   aRetItem( SID_DLG_RETOK, _bOK );
     522           0 :     SfxBoolItem   aMatItem( SID_DLG_MATRIX, _bMatrixChecked );
     523           0 :     SfxStringItem aStrItem( SCITEM_STRING, getCurrentFormula() );
     524             : 
     525             :     // Wenn durch Dokument-Umschalterei die Eingabezeile weg war/ist,
     526             :     // ist der String leer. Dann nicht die alte Formel loeschen.
     527           0 :     if ( aStrItem.GetValue().isEmpty() )
     528           0 :         aRetItem.SetValue( false );     // sal_False = Cancel
     529             : 
     530           0 :     m_aHelper.SetDispatcherLock( false ); // Modal-Modus ausschalten
     531             : 
     532           0 :     clear();
     533             : 
     534           0 :     GetBindings().GetDispatcher()->Execute( SID_INS_FUNCTION,
     535             :                               SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
     536           0 :                               &aRetItem, &aStrItem, &aMatItem, 0L );
     537           0 : }
     538           0 : void ScFormulaDlg::setDispatcherLock( bool bLock )
     539             : {
     540           0 :     m_aHelper.SetDispatcherLock( bLock );
     541           0 : }
     542           0 : void ScFormulaDlg::setReferenceInput(const formula::FormEditData* _pData)
     543             : {
     544           0 :     ScModule* pScMod = SC_MOD();
     545           0 :     ScFormEditData* pData = const_cast<ScFormEditData*>(dynamic_cast<const ScFormEditData*>(_pData));
     546           0 :     pScMod->SetRefInputHdl(pData->GetInputHandler());
     547           0 : }
     548           0 : void ScFormulaDlg::deleteFormData()
     549             : {
     550           0 :     ScModule* pScMod = SC_MOD();
     551           0 :     pScMod->ClearFormEditData();        // pData wird ungueltig!
     552           0 : }
     553           0 : void ScFormulaDlg::clear()
     554             : {
     555           0 :     pDoc = NULL;
     556             : 
     557             :     //Referenz Inputhandler zuruecksetzen
     558           0 :     ScModule* pScMod = SC_MOD();
     559           0 :     pScMod->SetRefInputHdl(NULL);
     560             : 
     561             :     // Enable() der Eingabezeile erzwingen:
     562           0 :     ScTabViewShell* pScViewShell = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
     563           0 :     if ( pScViewShell )
     564           0 :         pScViewShell->UpdateInputHandler();
     565           0 : }
     566           0 : void ScFormulaDlg::switchBack()
     567             : {
     568           0 :     ScModule* pScMod = SC_MOD();
     569             :     // auf das Dokument zurueckschalten
     570             :     // (noetig, weil ein fremdes oben sein kann - #34222#)
     571           0 :     ScInputHandler* pHdl = pScMod->GetInputHdl();
     572           0 :     if ( pHdl )
     573             :     {
     574           0 :         pHdl->ViewShellGone(NULL);  // -> aktive View neu holen
     575           0 :         pHdl->ShowRefFrame();
     576             :     }
     577             : 
     578             :     // aktuelle Tabelle ggF. restaurieren (wg. Maus-RefInput)
     579           0 :     ScTabViewShell* pScViewShell = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
     580           0 :     if ( pScViewShell )
     581             :     {
     582           0 :         ScViewData* pVD=pScViewShell->GetViewData();
     583           0 :         SCTAB nExecTab = aCursorPos.Tab();
     584           0 :         if ( nExecTab != pVD->GetTabNo() )
     585           0 :             pScViewShell->SetTabNo( nExecTab );
     586             : 
     587           0 :         SCROW nRow=aCursorPos.Row();
     588           0 :         SCCOL nCol=aCursorPos.Col();
     589             : 
     590           0 :         if(pVD->GetCurX()!=nCol || pVD->GetCurY()!=nRow)
     591           0 :             pScViewShell->SetCursor(nCol,nRow);
     592             :     }
     593           0 : }
     594           0 : formula::FormEditData* ScFormulaDlg::getFormEditData() const
     595             : {
     596           0 :     ScModule* pScMod = SC_MOD();
     597           0 :     return pScMod->GetFormEditData();
     598             : }
     599           0 : void ScFormulaDlg::setCurrentFormula(const OUString& _sReplacement)
     600             : {
     601           0 :     ScModule* pScMod = SC_MOD();
     602             :     {
     603             :         //fdo#69971 We need the EditEngine Modification handler of the inputbar that we
     604             :         //are feeding to be disabled while this dialog is open. Otherwise we end up in
     605             :         //a situation where...
     606             :         //a) this ScFormulaDlg changes the editengine
     607             :         //b) the modify callback gets called
     608             :         //c) which also modifies the editengine
     609             :         //d) on return from that modify handler the editengine attempts to use
     610             :         //   old node pointers which were replaced and removed by c
     611             :         //
     612             :         //We turn it off in the ctor and back on in the dtor, but if calc has
     613             :         //to repaint, e.g. when switching to another window and back, then in
     614             :         //ScMultiTextWnd::Paint a new editengine will have been created via
     615             :         //GetEditView with its default Modification handler enabled. So ensure
     616             :         //its off when we will access it via InputReplaceSelection
     617           0 :         pScMod->InputTurnOffWinEngine();
     618             :     }
     619           0 :     pScMod->InputReplaceSelection(_sReplacement);
     620           0 : }
     621           0 : void ScFormulaDlg::setSelection(sal_Int32 _nStart, sal_Int32 _nEnd)
     622             : {
     623           0 :     ScModule* pScMod = SC_MOD();
     624           0 :     pScMod->InputSetSelection( _nStart, _nEnd );
     625           0 : }
     626           0 : void ScFormulaDlg::getSelection(sal_Int32& _nStart, sal_Int32& _nEnd) const
     627             : {
     628           0 :     ScModule* pScMod = SC_MOD();
     629           0 :     pScMod->InputGetSelection( _nStart, _nEnd );
     630           0 : }
     631           0 : OUString ScFormulaDlg::getCurrentFormula() const
     632             : {
     633           0 :     ScModule* pScMod = SC_MOD();
     634           0 :     return pScMod->InputGetFormulaStr();
     635             : }
     636           0 : formula::IFunctionManager* ScFormulaDlg::getFunctionManager()
     637             : {
     638           0 :     return ScGlobal::GetStarCalcFunctionMgr();
     639             : }
     640           0 : uno::Reference< sheet::XFormulaParser> ScFormulaDlg::getFormulaParser() const
     641             : {
     642           0 :     return m_xParser;
     643             : }
     644           0 : uno::Reference< sheet::XFormulaOpCodeMapper> ScFormulaDlg::getFormulaOpCodeMapper() const
     645             : {
     646           0 :     return m_xOpCodeMapper;
     647             : }
     648             : 
     649           0 : table::CellAddress ScFormulaDlg::getReferencePosition() const
     650             : {
     651           0 :     return table::CellAddress(aCursorPos.Tab(),aCursorPos.Col(),aCursorPos.Row());
     652             : }
     653             : 
     654             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     655           0 : ::std::auto_ptr<formula::FormulaTokenArray> ScFormulaDlg::convertToTokenArray(const uno::Sequence< sheet::FormulaToken >& _aTokenList)
     656             : {
     657           0 :     ::std::auto_ptr<formula::FormulaTokenArray> pArray(new ScTokenArray());
     658           0 :     pArray->Fill( _aTokenList, pDoc->GetExternalRefManager());
     659           0 :     return pArray;
     660             : }
     661             : // for mysterious reasons Apple llvm-g++ 4.2.1 needs these explicit
     662             : // template instantiations; otherwise linking fails with unresolved symbols
     663             : template class ::std::auto_ptr<formula::FormulaTokenArray>;
     664             : template std::auto_ptr<formula::FormulaTokenArray>::operator std::auto_ptr_ref<formula::FormulaTokenArray>();
     665         102 : SAL_WNODEPRECATED_DECLARATIONS_POP
     666             : 
     667             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10