Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / sc / source / ui / formdlg / formula.cxx
blob9af2adbe7472662169f49910aa87c5f5206a4d92
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <memory>
21 #include <scitems.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/docfile.hxx>
24 #include <sfx2/objsh.hxx>
25 #include <svl/numformat.hxx>
26 #include <svl/stritem.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <tools/urlobj.hxx>
29 #include <formula/formulahelper.hxx>
30 #include <formula/IFunctionDescription.hxx>
31 #include <formula/errorcodes.hxx>
33 #include <compiler.hxx>
34 #include <formula.hxx>
35 #include <formdata.hxx>
36 #include <reffact.hxx>
37 #include <document.hxx>
38 #include <simpleformulacalc.hxx>
39 #include <scmod.hxx>
40 #include <inputhdl.hxx>
41 #include <tabvwsh.hxx>
42 #include <docsh.hxx>
43 #include <funcdesc.hxx>
44 #include <tokenarray.hxx>
45 #include <sc.hrc>
46 #include <servuno.hxx>
47 #include <unonames.hxx>
48 #include <externalrefmgr.hxx>
50 #include <com/sun/star/table/CellAddress.hpp>
51 #include <com/sun/star/sheet/XFormulaOpCodeMapper.hpp>
52 #include <com/sun/star/sheet/XFormulaParser.hpp>
54 using namespace formula;
55 using namespace com::sun::star;
57 // init/ shared functions for dialog
59 ScFormulaDlg::ScFormulaDlg(SfxBindings* pB, SfxChildWindow* pCW,
60 weld::Window* pParent, const ScViewData& rViewData, const formula::IFunctionManager* _pFunctionMgr)
61 : formula::FormulaDlg(pB, pCW, pParent, _pFunctionMgr, this)
62 , m_aHelper(this,pB)
63 , m_pViewShell( nullptr )
65 m_aHelper.SetDialog(m_xDialog.get());
66 ScModule* pScMod = ScModule::get();
67 pScMod->InputEnterHandler();
68 m_pViewShell = nullptr;
70 // title has to be from the view that opened the dialog,
71 // even if it's not the current view
73 if ( pB )
75 SfxDispatcher* pMyDisp = pB->GetDispatcher();
76 if (pMyDisp)
78 SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame();
79 if (pMyViewFrm)
81 m_pViewShell = dynamic_cast<ScTabViewShell*>( pMyViewFrm->GetViewShell() );
82 if( m_pViewShell )
83 m_pViewShell->UpdateInputHandler(true);
88 m_pDoc = &rViewData.GetDocument();
89 m_xParser.set(ScServiceProvider::MakeInstance(ScServiceProvider::Type::FORMULAPARS,
90 m_pDoc->GetDocumentShell()), uno::UNO_QUERY);
91 uno::Reference< beans::XPropertySet> xSet(m_xParser,uno::UNO_QUERY);
92 xSet->setPropertyValue(SC_UNO_COMPILEFAP, uno::Any(true));
94 m_xOpCodeMapper.set(ScServiceProvider::MakeInstance(ScServiceProvider::Type::OPCODEMAPPER,
95 m_pDoc->GetDocumentShell()), uno::UNO_QUERY);
97 ScInputHandler* pInputHdl = pScMod->GetInputHdl(m_pViewShell);
99 assert(pInputHdl && "Missing input handler :-/");
101 pInputHdl->NotifyChange( nullptr );
103 ScFormulaReferenceHelper::enableInput( true );
104 ScFormulaReferenceHelper::EnableSpreadsheets();
105 m_aHelper.Init();
106 m_aHelper.SetDispatcherLock( true );
108 notifyChange();
109 fill();
111 ScFormEditData* pData = m_pViewShell->GetFormEditData();
112 if (pData)
113 return;
115 pScMod->SetRefInputHdl(pInputHdl);
117 m_pDoc = &rViewData.GetDocument();
118 SCCOL nCol = rViewData.GetCurX();
119 SCROW nRow = rViewData.GetCurY();
120 SCTAB nTab = rViewData.GetTabNo();
121 m_CursorPos = ScAddress( nCol, nRow, nTab );
123 m_pViewShell->InitFormEditData(); // create new
124 pData = m_pViewShell->GetFormEditData();
125 pData->SetInputHandler(pInputHdl);
126 pData->SetDocShell(rViewData.GetDocShell());
128 OSL_ENSURE(pData,"FormEditData not available");
130 formula::FormulaDlgMode eMode = FormulaDlgMode::Formula; // default...
132 // edit if formula exists
134 OUString aFormula = m_pDoc->GetFormula( nCol, nRow, nTab );
135 bool bEdit = ( aFormula.getLength() > 1 );
136 bool bMatrix = false;
137 if ( bEdit )
139 bMatrix = CheckMatrix(aFormula);
141 sal_Int32 nFStart = 0;
142 sal_Int32 nFEnd = 0;
143 if ( GetFormulaHelper().GetNextFunc( aFormula, false, nFStart, &nFEnd) )
145 pInputHdl->InputReplaceSelection( aFormula );
146 pInputHdl->InputSetSelection( nFStart, nFEnd );
147 sal_Int32 PrivStart, PrivEnd;
148 pInputHdl->InputGetSelection( PrivStart, PrivEnd);
150 eMode = SetMeText(pInputHdl->GetFormString(),PrivStart, PrivEnd, bMatrix, true, true);
151 pData->SetFStart( nFStart );
153 else
154 bEdit = false;
157 if ( !bEdit )
159 OUString aNewFormula('=');
160 if ( aFormula.startsWith("=") )
161 aNewFormula = aFormula;
163 pInputHdl->InputReplaceSelection( aNewFormula );
164 pInputHdl->InputSetSelection( 1, aNewFormula.getLength()+1 );
165 sal_Int32 PrivStart, PrivEnd;
166 pInputHdl->InputGetSelection( PrivStart, PrivEnd);
167 SetMeText(pInputHdl->GetFormString(),PrivStart, PrivEnd,bMatrix,false,false);
169 pData->SetFStart( 1 ); // after "="
172 pData->SetMode( eMode );
173 OUString rStrExp = GetMeText();
175 Update(rStrExp);
179 void ScFormulaDlg::notifyChange()
181 ScInputHandler* pInputHdl = m_pViewShell->GetInputHandler();
182 if ( pInputHdl )
183 pInputHdl->NotifyChange( nullptr );
186 void ScFormulaDlg::fill()
188 ScModule* pScMod = ScModule::get();
189 ScFormEditData* pData = static_cast<ScFormEditData*>(getFormEditData());
190 notifyChange();
191 OUString rStrExp;
192 if (!pData)
193 return;
195 // data exists -> restore state (after switch)
196 // don't reinitialise m_pDoc and m_CursorPos
197 //pDoc = rViewData.GetDocument();
198 if(IsInputHdl(pData->GetInputHandler()))
200 pScMod->SetRefInputHdl(pData->GetInputHandler());
202 else
204 ScTabViewShell* pTabViewShell;
205 ScInputHandler* pInputHdl = GetNextInputHandler(pData->GetDocShell(),&pTabViewShell);
207 if ( pInputHdl == nullptr ) //no more InputHandler for DocShell
209 disableOk();
210 pInputHdl = pScMod->GetInputHdl();
212 else
214 pInputHdl->SetRefViewShell(pTabViewShell);
216 pScMod->SetRefInputHdl(pInputHdl);
217 pData->SetInputHandler(pInputHdl);
220 OUString aOldFormulaTmp(pData->GetInputHandler()->GetFormString());
221 pData->GetInputHandler()->InputSetSelection( 0, aOldFormulaTmp.getLength());
223 rStrExp=pData->GetUndoStr();
224 pData->GetInputHandler()->InputReplaceSelection(rStrExp);
226 SetMeText(rStrExp);
228 Update();
229 // switch back, maybe new Doc has been opened
230 pScMod->SetRefInputHdl(nullptr);
233 ScFormulaDlg::~ScFormulaDlg() COVERITY_NOEXCEPT_FALSE
235 ScFormEditData* pData = m_pViewShell->GetFormEditData();
237 m_aHelper.dispose();
239 if (pData) // close doesn't destroy;
241 //set back reference input handler
242 ScModule::get()->SetRefInputHdl(nullptr);
243 StoreFormEditData(pData);
246 m_pViewShell->ClearFormEditData();
249 bool ScFormulaDlg::IsInputHdl(const ScInputHandler* pHdl)
251 bool bAlive = false;
253 // belongs InputHandler to a ViewShell?
255 SfxViewShell* pSh = SfxViewShell::GetFirst( true, checkSfxViewShell<ScTabViewShell> );
256 while ( pSh && !bAlive )
258 if (static_cast<ScTabViewShell*>(pSh)->GetInputHandler() == pHdl)
259 bAlive = true;
260 pSh = SfxViewShell::GetNext( *pSh, true, checkSfxViewShell<ScTabViewShell> );
263 return bAlive;
267 ScInputHandler* ScFormulaDlg::GetNextInputHandler(const ScDocShell* pDocShell, ScTabViewShell** ppViewSh)
269 ScInputHandler* pHdl=nullptr;
271 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
272 while( pFrame && pHdl==nullptr)
274 SfxViewShell* p = pFrame->GetViewShell();
275 ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( p );
276 if(pViewSh!=nullptr)
278 pHdl=pViewSh->GetInputHandler();
279 if(ppViewSh!=nullptr) *ppViewSh=pViewSh;
281 pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
284 return pHdl;
287 void ScFormulaDlg::Close()
289 if (IsClosing())
290 return;
292 DoEnter();
295 // functions for right side
297 bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult, bool bMatrixFormula )
299 std::optional<ScSimpleFormulaCalculator> pFCell(std::in_place,
300 *m_pDoc, m_CursorPos, rStrExp, bMatrixFormula);
301 pFCell->SetLimitString(true);
303 // HACK! to avoid neither #REF! from ColRowNames
304 // if a name is added as actually range in the overall formula,
305 // but is interpreted at the individual representation as single-cell reference
306 bool bColRowName = pFCell->HasColRowName();
307 if ( bColRowName )
309 // ColRowName from RPN-Code?
310 if ( pFCell->GetCode()->GetCodeLen() <= 1 )
311 { // ==1: area
312 // ==0: would be an area if...
313 OUString aBraced = "(" + rStrExp + ")";
314 pFCell.emplace(*m_pDoc, m_CursorPos, aBraced, bMatrixFormula);
315 pFCell->SetLimitString(true);
317 else
318 bColRowName = false;
321 FormulaError nErrCode = pFCell->GetErrCode();
322 if ( nErrCode == FormulaError::NONE || pFCell->IsMatrix() )
324 SvNumberFormatter& aFormatter = *(m_pDoc->GetFormatTable());
325 const Color* pColor;
326 if (pFCell->IsMatrix())
328 rStrResult = pFCell->GetString().getString();
330 else if (pFCell->IsValue())
332 double n = pFCell->GetValue();
333 sal_uLong nFormat = aFormatter.GetStandardFormat( n, 0,
334 pFCell->GetFormatType(), ScGlobal::eLnge );
335 aFormatter.GetOutputString( n, nFormat, rStrResult, &pColor );
337 else
339 sal_uLong nFormat = aFormatter.GetStandardFormat(
340 pFCell->GetFormatType(), ScGlobal::eLnge);
341 aFormatter.GetOutputString( pFCell->GetString().getString(), nFormat,
342 rStrResult, &pColor );
343 // Indicate it's a string, so a number string doesn't look numeric.
344 // Escape embedded quotation marks first by doubling them, as
345 // usual. Actually the result can be copy-pasted from the result
346 // box as literal into a formula expression.
347 rStrResult = "\"" + rStrResult.replaceAll( "\"", "\"\"") + "\"";
350 ScRange aTestRange;
351 if ( bColRowName || (aTestRange.Parse(rStrExp, *m_pDoc) & ScRefFlags::VALID) )
352 rStrResult += " ...";
353 // area
355 else
356 rStrResult += ScGlobal::GetErrorString(nErrCode);
358 return true;
361 std::shared_ptr<formula::FormulaCompiler> ScFormulaDlg::getCompiler() const
363 if (!m_xCompiler)
364 m_xCompiler = std::make_shared<ScCompiler>(*m_pDoc, m_CursorPos, m_pDoc->GetGrammar());
365 return m_xCompiler;
368 std::unique_ptr<formula::FormulaCompiler> ScFormulaDlg::createCompiler( formula::FormulaTokenArray& rArray ) const
370 ScCompiler* pCompiler = nullptr;
371 ScTokenArray* pArr = dynamic_cast<ScTokenArray*>(&rArray);
372 assert(pArr); // violation of contract and not created using convertToTokenArray()?
373 if (pArr)
374 pCompiler = new ScCompiler(*m_pDoc, m_CursorPos, *pArr, m_pDoc->GetGrammar());
375 return std::unique_ptr<formula::FormulaCompiler>(pCompiler);
378 // virtual methods of ScAnyRefDlg:
379 void ScFormulaDlg::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
381 pEdit->SelectAll();
382 ::std::pair<formula::RefButton*,formula::RefEdit*> aPair = RefInputStartBefore( pEdit, pButton );
383 m_aHelper.RefInputStart( aPair.second, aPair.first);
384 RefInputStartAfter();
387 void ScFormulaDlg::RefInputDone( bool bForced )
389 m_aHelper.RefInputDone( bForced );
390 RefInputDoneAfter( bForced );
393 void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument& rRefDoc )
395 const IFunctionDescription* pFunc = getCurrentFunctionDescription();
396 if ( !(pFunc && pFunc->getSuppressedArgumentCount() > 0) )
397 return;
399 Selection theSel;
400 bool bRefNull = UpdateParaWin(theSel);
402 if ( rRef.aStart != rRef.aEnd && bRefNull )
404 RefInputStart(GetActiveEdit());
407 // Pointer-selected => absolute range references for the non-single
408 // dimensions, so in the other dimension (if any) it's still
409 // copy-adjustable.
410 constexpr ScRefFlags eColFlags = ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS;
411 constexpr ScRefFlags eRowFlags = ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS;
412 ScRefFlags eRangeFlags = ScRefFlags::ZERO;
413 if (rRef.aStart.Col() != rRef.aEnd.Col())
414 eRangeFlags |= eColFlags;
415 if (rRef.aStart.Row() != rRef.aEnd.Row())
416 eRangeFlags |= eRowFlags;
417 OUString aRefStr;
418 bool bOtherDoc = (&rRefDoc != m_pDoc && rRefDoc.GetDocumentShell()->HasName());
419 if ( bOtherDoc )
421 // reference to other document - like inputhdl.cxx
423 OSL_ENSURE(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
425 // Sheet always 3D and absolute.
426 OUString aTmp( rRef.Format(rRefDoc, ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D | eRangeFlags));
428 ScDocShell* pObjSh = rRefDoc.GetDocumentShell();
430 // #i75893# convert escaped URL of the document to something user friendly
431 // OUString aFileName = pObjSh->GetMedium()->GetName();
432 OUString aFileName = pObjSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::Unambiguous );
434 aRefStr = "'" + aFileName + "'#" + aTmp;
436 else
438 // We can't use ScRange::Format here because in R1C1 mode we need
439 // to display the reference position relative to the cursor
440 // position.
441 ScTokenArray aArray(rRefDoc);
442 ScComplexRefData aRefData;
443 aRefData.InitRangeRel(rRefDoc, rRef, m_CursorPos);
444 if ((eRangeFlags & eColFlags) == eColFlags)
446 aRefData.Ref1.SetAbsCol( rRef.aStart.Col() );
447 aRefData.Ref2.SetAbsCol( rRef.aEnd.Col() );
449 if ((eRangeFlags & eRowFlags) == eRowFlags)
451 aRefData.Ref1.SetAbsRow( rRef.aStart.Row() );
452 aRefData.Ref2.SetAbsRow( rRef.aEnd.Row() );
454 bool bSingle = aRefData.Ref1 == aRefData.Ref2;
455 if (m_CursorPos.Tab() != rRef.aStart.Tab())
457 // pointer-selected => absolute sheet reference
458 aRefData.Ref1.SetAbsTab( rRef.aStart.Tab() );
459 aRefData.Ref1.SetFlag3D(true);
461 if (bSingle)
462 aArray.AddSingleReference(aRefData.Ref1);
463 else
464 aArray.AddDoubleReference(aRefData);
465 ScCompiler aComp(*m_pDoc, m_CursorPos, aArray, m_pDoc->GetGrammar());
466 OUStringBuffer aBuf;
467 aComp.CreateStringFromTokenArray(aBuf);
468 aRefStr = aBuf.makeStringAndClear();
471 UpdateParaWin(theSel,aRefStr);
474 bool ScFormulaDlg::IsRefInputMode() const
476 const IFunctionDescription* pDesc = getCurrentFunctionDescription();
477 bool bRef = (pDesc && (pDesc->getSuppressedArgumentCount() > 0)) && (m_pDoc != nullptr);
478 return bRef;
481 bool ScFormulaDlg::IsDocAllowed(SfxObjectShell* pDocSh) const
483 // not allowed: different from this doc, and no name
484 // pDocSh is always a ScDocShell
485 return !pDocSh || &static_cast<ScDocShell*>(pDocSh)->GetDocument() == m_pDoc || pDocSh->HasName(); // everything else is allowed
488 void ScFormulaDlg::SetActive()
490 const IFunctionDescription* pFunc = getCurrentFunctionDescription();
491 if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
493 RefInputDone();
494 SetEdSelection();
498 void ScFormulaDlg::SaveLRUEntry(const ScFuncDesc* pFuncDescP)
500 if (pFuncDescP && pFuncDescP->nFIndex!=0)
502 ScModule::get()->InsertEntryToLRUList(pFuncDescP->nFIndex);
506 void ScFormulaDlg::doClose(bool /*_bOk*/)
508 m_aHelper.DoClose( ScFormulaDlgWrapper::GetChildWindowId() );
510 void ScFormulaDlg::insertEntryToLRUList(const formula::IFunctionDescription* _pDesc)
512 const ScFuncDesc* pDesc = dynamic_cast<const ScFuncDesc*>(_pDesc);
513 SaveLRUEntry(pDesc);
515 void ScFormulaDlg::showReference(const OUString& _sFormula)
517 ShowReference(_sFormula);
519 void ScFormulaDlg::ShowReference(const OUString& _sFormula)
521 m_aHelper.ShowReference(_sFormula);
523 void ScFormulaDlg::HideReference( bool bDoneRefMode )
525 m_aHelper.HideReference(bDoneRefMode);
527 void ScFormulaDlg::ViewShellChanged()
529 ScFormulaReferenceHelper::ViewShellChanged();
531 void ScFormulaDlg::AddRefEntry( )
535 bool ScFormulaDlg::IsTableLocked( ) const
537 // default: reference input can also be used to switch the table
538 return false;
541 void ScFormulaDlg::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton)
543 m_aHelper.ToggleCollapsed(pEdit,pButton);
546 void ScFormulaDlg::ReleaseFocus( formula::RefEdit* pEdit)
548 m_aHelper.ReleaseFocus(pEdit);
551 void ScFormulaDlg::dispatch(bool _bOK, bool _bMatrixChecked)
553 SfxBoolItem aRetItem( SID_DLG_RETOK, _bOK );
554 SfxBoolItem aMatItem( SID_DLG_MATRIX, _bMatrixChecked );
555 SfxStringItem aStrItem( SCITEM_STRING, getCurrentFormula() );
557 // if edit line is empty (caused by document switching) -> string is empty
558 // -> don't delete old formula
559 if ( aStrItem.GetValue().isEmpty() )
560 aRetItem.SetValue( false ); // sal_False = Cancel
562 m_aHelper.SetDispatcherLock( false ); // turn off modal-mode
564 clear();
566 GetBindings().GetDispatcher()->ExecuteList( SID_INS_FUNCTION,
567 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
568 { &aRetItem, &aStrItem, &aMatItem });
570 void ScFormulaDlg::setDispatcherLock( bool bLock )
572 m_aHelper.SetDispatcherLock( bLock );
574 void ScFormulaDlg::deleteFormData()
576 if (m_pViewShell)
577 m_pViewShell->ClearFormEditData(); // pData is invalid!
579 void ScFormulaDlg::clear()
581 m_pDoc = nullptr;
583 //restore reference inputhandler
584 ScModule* pScMod = ScModule::get();
585 pScMod->SetRefInputHdl(nullptr);
587 // force Enable() of edit line
588 ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
589 if ( pScViewShell )
590 pScViewShell->UpdateInputHandler();
592 void ScFormulaDlg::switchBack()
594 // back to the document
595 // (foreign doc could be above - #34222#)
596 ScInputHandler* pHdl = m_pViewShell->GetInputHandler();
597 if ( pHdl )
599 pHdl->ViewShellGone(nullptr); // -> get active view
600 pHdl->ShowRefFrame();
603 // restore current chart (cause mouse-RefInput)
604 ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
605 if ( !pScViewShell )
606 return;
608 ScViewData& rVD=pScViewShell->GetViewData();
609 SCTAB nExecTab = m_CursorPos.Tab();
610 if ( nExecTab != rVD.GetTabNo() )
611 pScViewShell->SetTabNo( nExecTab );
613 SCROW nRow = m_CursorPos.Row();
614 SCCOL nCol = m_CursorPos.Col();
616 if(rVD.GetCurX()!=nCol || rVD.GetCurY()!=nRow)
617 pScViewShell->SetCursor(nCol,nRow);
619 formula::FormEditData* ScFormulaDlg::getFormEditData() const
621 ScTabViewShell* pViewShell = m_pViewShell;
622 if (pViewShell)
623 return pViewShell->GetFormEditData();
624 return nullptr;
626 void ScFormulaDlg::setCurrentFormula(const OUString& _sReplacement)
628 ScModule* pScMod = ScModule::get();
630 //fdo#69971 We need the EditEngine Modification handler of the inputbar that we
631 //are feeding to be disabled while this dialog is open. Otherwise we end up in
632 //a situation where...
633 //a) this ScFormulaDlg changes the editengine
634 //b) the modify callback gets called
635 //c) which also modifies the editengine
636 //d) on return from that modify handler the editengine attempts to use
637 // old node pointers which were replaced and removed by c
639 //We turn it off in the ctor and back on in the dtor, but if calc has
640 //to repaint, e.g. when switching to another window and back, then in
641 //ScMultiTextWnd::Paint a new editengine will have been created via
642 //GetEditView with its default Modification handler enabled. So ensure
643 //its off when we will access it via InputReplaceSelection
644 pScMod->InputTurnOffWinEngine();
646 pScMod->InputReplaceSelection(_sReplacement);
648 void ScFormulaDlg::setSelection(sal_Int32 _nStart, sal_Int32 _nEnd)
650 ScModule::get()->InputSetSelection(_nStart, _nEnd);
652 void ScFormulaDlg::getSelection(sal_Int32& _nStart, sal_Int32& _nEnd) const
654 ScModule::get()->InputGetSelection(_nStart, _nEnd);
656 OUString ScFormulaDlg::getCurrentFormula() const
658 ScFormEditData* pData = m_pViewShell->GetFormEditData();
659 if (pData && pData->GetInputHandler())
660 return pData->GetInputHandler()->GetFormString();
661 return u""_ustr;
663 formula::IFunctionManager* ScFormulaDlg::getFunctionManager()
665 return ScGlobal::GetStarCalcFunctionMgr();
667 uno::Reference< sheet::XFormulaParser> ScFormulaDlg::getFormulaParser() const
669 return m_xParser;
671 uno::Reference< sheet::XFormulaOpCodeMapper> ScFormulaDlg::getFormulaOpCodeMapper() const
673 return m_xOpCodeMapper;
676 table::CellAddress ScFormulaDlg::getReferencePosition() const
678 return table::CellAddress(m_CursorPos.Tab(), m_CursorPos.Col(), m_CursorPos.Row());
681 ::std::unique_ptr<formula::FormulaTokenArray> ScFormulaDlg::convertToTokenArray(const uno::Sequence< sheet::FormulaToken >& _aTokenList)
683 ::std::unique_ptr<formula::FormulaTokenArray> pArray(new ScTokenArray(*m_pDoc));
684 pArray->Fill(_aTokenList, m_pDoc->GetSharedStringPool(), m_pDoc->GetExternalRefManager());
685 return pArray;
688 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */