LibreOffice Module sc (master)  1
formula.cxx
Go to the documentation of this file.
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 <memory>
21 #include <scitems.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/docfile.hxx>
24 #include <sfx2/objsh.hxx>
25 #include <svl/zforlist.hxx>
26 #include <svl/stritem.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <tools/urlobj.hxx>
31 #include <formula/errorcodes.hxx>
32 
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>
49 
50 #include <com/sun/star/table/CellAddress.hpp>
51 #include <com/sun/star/sheet/XFormulaOpCodeMapper.hpp>
52 #include <com/sun/star/sheet/XFormulaParser.hpp>
53 
54 using namespace formula;
55 using namespace com::sun::star;
56 
57 // init/ shared functions for dialog
58 
60  weld::Window* pParent, const ScViewData* pViewData, const formula::IFunctionManager* _pFunctionMgr)
61  : formula::FormulaDlg(pB, pCW, pParent, _pFunctionMgr, this)
62  , m_aHelper(this,pB)
63  , m_pViewShell( nullptr )
64 {
66  ScModule* pScMod = SC_MOD();
67  pScMod->InputEnterHandler();
68  m_pViewShell = nullptr;
69 
70  // title has to be from the view that opened the dialog,
71  // even if it's not the current view
72 
73  if ( pB )
74  {
75  SfxDispatcher* pMyDisp = pB->GetDispatcher();
76  if (pMyDisp)
77  {
78  SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame();
79  if (pMyViewFrm)
80  {
81  m_pViewShell = dynamic_cast<ScTabViewShell*>( pMyViewFrm->GetViewShell() );
82  if( m_pViewShell )
84  }
85  }
86  }
87 
88  m_pDoc = pViewData->GetDocument();
90  static_cast<ScDocShell*>(m_pDoc->GetDocumentShell())),uno::UNO_QUERY);
91  uno::Reference< beans::XPropertySet> xSet(m_xParser,uno::UNO_QUERY);
92  xSet->setPropertyValue(SC_UNO_COMPILEFAP, uno::makeAny(true));
93 
95  static_cast<ScDocShell*>(m_pDoc->GetDocumentShell())),uno::UNO_QUERY);
96 
97  ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(m_pViewShell);
98 
99  assert(pInputHdl && "Missing input handler :-/");
100 
101  pInputHdl->NotifyChange( nullptr );
102 
105  m_aHelper.Init();
107 
108  notifyChange();
109  fill();
110 
112  if (!pData)
113  {
114  pScMod->SetRefInputHdl(pInputHdl);
115 
116  m_pDoc = pViewData->GetDocument();
117  SCCOL nCol = pViewData->GetCurX();
118  SCROW nRow = pViewData->GetCurY();
119  SCTAB nTab = pViewData->GetTabNo();
120  m_CursorPos = ScAddress( nCol, nRow, nTab );
121 
122  m_pViewShell->InitFormEditData(); // create new
123  pData = m_pViewShell->GetFormEditData();
124  pData->SetInputHandler(pInputHdl);
125  pData->SetDocShell(pViewData->GetDocShell());
126 
127  OSL_ENSURE(pData,"FormEditData not available");
128 
129  formula::FormulaDlgMode eMode = FormulaDlgMode::Formula; // default...
130 
131  // edit if formula exists
132 
133  OUString aFormula;
134  m_pDoc->GetFormula( nCol, nRow, nTab, aFormula );
135  bool bEdit = ( aFormula.getLength() > 1 );
136  bool bMatrix = false;
137  if ( bEdit )
138  {
139  bMatrix = CheckMatrix(aFormula);
140 
141  sal_Int32 nFStart = 0;
142  sal_Int32 nFEnd = 0;
143  if ( GetFormulaHelper().GetNextFunc( aFormula, false, nFStart, &nFEnd) )
144  {
145  pInputHdl->InputReplaceSelection( aFormula );
146  pInputHdl->InputSetSelection( nFStart, nFEnd );
147  sal_Int32 PrivStart, PrivEnd;
148  pInputHdl->InputGetSelection( PrivStart, PrivEnd);
149 
150  eMode = SetMeText(pInputHdl->GetFormString(),PrivStart, PrivEnd, bMatrix, true, true);
151  pData->SetFStart( nFStart );
152  }
153  else
154  bEdit = false;
155  }
156 
157  if ( !bEdit )
158  {
159  OUString aNewFormula('=');
160  if ( aFormula.startsWith("=") )
161  aNewFormula = aFormula;
162 
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);
168 
169  pData->SetFStart( 1 ); // after "="
170  }
171 
172  pData->SetMode( eMode );
173  OUString rStrExp = GetMeText();
174 
175  Update(rStrExp);
176  }
177 
178 }
179 
181 {
183  if ( pInputHdl )
184  pInputHdl->NotifyChange( nullptr );
185 }
186 
188 {
189  ScModule* pScMod = SC_MOD();
191  notifyChange();
192  OUString rStrExp;
193  if (pData)
194  {
195  // data exists -> restore state (after switch)
196  // don't reinitialise m_pDoc and m_CursorPos
197  //pDoc = pViewData->GetDocument();
198  if(IsInputHdl(pData->GetInputHandler()))
199  {
200  pScMod->SetRefInputHdl(pData->GetInputHandler());
201  }
202  else
203  {
204  ScTabViewShell* pTabViewShell;
205  ScInputHandler* pInputHdl = GetNextInputHandler(pData->GetDocShell(),&pTabViewShell);
206 
207  if ( pInputHdl == nullptr ) //no more InputHandler for DocShell
208  {
209  disableOk();
210  pInputHdl = pScMod->GetInputHdl();
211  }
212  else
213  {
214  pInputHdl->SetRefViewShell(pTabViewShell);
215  }
216  pScMod->SetRefInputHdl(pInputHdl);
217  pData->SetInputHandler(pInputHdl);
218  }
219 
220  OUString aOldFormulaTmp(pData->GetInputHandler()->GetFormString());
221  pData->GetInputHandler()->InputSetSelection( 0, aOldFormulaTmp.getLength());
222 
223  rStrExp=pData->GetUndoStr();
224  pData->GetInputHandler()->InputReplaceSelection(rStrExp);
225 
226  SetMeText(rStrExp);
227 
228  Update();
229  // switch back, maybe new Doc has been opened
230  pScMod->SetRefInputHdl(nullptr);
231  }
232 }
233 
234 ScFormulaDlg::~ScFormulaDlg() COVERITY_NOEXCEPT_FALSE
235 {
237 
238  m_aHelper.dispose();
239 
240  if (pData) // close doesn't destroy;
241  {
242  //set back reference input handler
243  SC_MOD()->SetRefInputHdl(nullptr);
244  StoreFormEditData(pData);
245  }
246 
248 }
249 
251 {
252  bool bAlive = false;
253 
254  // belongs InputHandler to a ViewShell?
255 
256  SfxViewShell* pSh = SfxViewShell::GetFirst( true, checkSfxViewShell<ScTabViewShell> );
257  while ( pSh && !bAlive )
258  {
259  if (static_cast<ScTabViewShell*>(pSh)->GetInputHandler() == pHdl)
260  bAlive = true;
261  pSh = SfxViewShell::GetNext( *pSh, true, checkSfxViewShell<ScTabViewShell> );
262  }
263 
264  return bAlive;
265 
266 }
267 
269 {
270  ScInputHandler* pHdl=nullptr;
271 
272  SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
273  while( pFrame && pHdl==nullptr)
274  {
275  SfxViewShell* p = pFrame->GetViewShell();
276  ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( p );
277  if(pViewSh!=nullptr)
278  {
279  pHdl=pViewSh->GetInputHandler();
280  if(ppViewSh!=nullptr) *ppViewSh=pViewSh;
281  }
282  pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
283  }
284 
285  return pHdl;
286 }
287 
289 {
290  if (IsClosing())
291  return;
292 
293  DoEnter();
294 }
295 
296 // functions for right side
297 
298 bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult, bool bMatrixFormula )
299 {
300  std::unique_ptr<ScSimpleFormulaCalculator> pFCell( new ScSimpleFormulaCalculator(
301  m_pDoc, m_CursorPos, rStrExp, bMatrixFormula));
302  pFCell->SetLimitString(true);
303 
304  // HACK! to avoid neither #REF! from ColRowNames
305  // if a name is added as actually range in the overall formula,
306  // but is interpreted at the individual representation as single-cell reference
307  bool bColRowName = pFCell->HasColRowName();
308  if ( bColRowName )
309  {
310  // ColRowName from RPN-Code?
311  if ( pFCell->GetCode()->GetCodeLen() <= 1 )
312  { // ==1: area
313  // ==0: would be an area if...
314  OUString aBraced = "(" + rStrExp + ")";
315  pFCell.reset( new ScSimpleFormulaCalculator(
316  m_pDoc, m_CursorPos, aBraced, bMatrixFormula));
317  pFCell->SetLimitString(true);
318  }
319  else
320  bColRowName = false;
321  }
322 
323  FormulaError nErrCode = pFCell->GetErrCode();
324  if ( nErrCode == FormulaError::NONE || pFCell->IsMatrix() )
325  {
326  SvNumberFormatter& aFormatter = *(m_pDoc->GetFormatTable());
327  Color* pColor;
328  if (pFCell->IsMatrix())
329  {
330  rStrResult = pFCell->GetString().getString();
331  }
332  else if (pFCell->IsValue())
333  {
334  double n = pFCell->GetValue();
335  sal_uLong nFormat = aFormatter.GetStandardFormat( n, 0,
336  pFCell->GetFormatType(), ScGlobal::eLnge );
337  aFormatter.GetOutputString( n, nFormat, rStrResult, &pColor );
338  }
339  else
340  {
341  sal_uLong nFormat = aFormatter.GetStandardFormat(
342  pFCell->GetFormatType(), ScGlobal::eLnge);
343  aFormatter.GetOutputString( pFCell->GetString().getString(), nFormat,
344  rStrResult, &pColor );
345  // Indicate it's a string, so a number string doesn't look numeric.
346  // Escape embedded quotation marks first by doubling them, as
347  // usual. Actually the result can be copy-pasted from the result
348  // box as literal into a formula expression.
349  rStrResult = "\"" + rStrResult.replaceAll( "\"", "\"\"") + "\"";
350  }
351 
352  ScRange aTestRange;
353  if ( bColRowName || (aTestRange.Parse(rStrExp, m_pDoc) & ScRefFlags::VALID) )
354  rStrResult += " ...";
355  // area
356  }
357  else
358  rStrResult += ScGlobal::GetErrorString(nErrCode);
359 
360  return true;
361 }
362 
363 std::shared_ptr<formula::FormulaCompiler> ScFormulaDlg::getCompiler() const
364 {
365  if (!m_xCompiler)
366  m_xCompiler = std::make_shared<ScCompiler>( m_pDoc, m_CursorPos, m_pDoc->GetGrammar());
367  return m_xCompiler;
368 }
369 
370 std::unique_ptr<formula::FormulaCompiler> ScFormulaDlg::createCompiler( formula::FormulaTokenArray& rArray ) const
371 {
372  ScCompiler* pCompiler = nullptr;
373  ScTokenArray* pArr = dynamic_cast<ScTokenArray*>(&rArray);
374  assert(pArr); // violation of contract and not created using convertToTokenArray()?
375  if (pArr)
376  pCompiler = new ScCompiler( m_pDoc, m_CursorPos, *pArr, m_pDoc->GetGrammar());
377  return std::unique_ptr<formula::FormulaCompiler>(pCompiler);
378 }
379 
380 // virtual methods of ScAnyRefDlg:
382 {
383  pEdit->SelectAll();
384  ::std::pair<formula::RefButton*,formula::RefEdit*> aPair = RefInputStartBefore( pEdit, pButton );
385  m_aHelper.RefInputStart( aPair.second, aPair.first);
387 }
388 
389 void ScFormulaDlg::RefInputDone( bool bForced )
390 {
391  m_aHelper.RefInputDone( bForced );
392  RefInputDoneAfter( bForced );
393 }
394 
395 void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument& rRefDoc )
396 {
398  if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
399  {
400  Selection theSel;
401  bool bRefNull = UpdateParaWin(theSel);
402 
403  if ( rRef.aStart != rRef.aEnd && bRefNull )
404  {
406  }
407 
408  OUString aRefStr;
409  bool bOtherDoc = (&rRefDoc != m_pDoc && rRefDoc.GetDocumentShell()->HasName());
410  if ( bOtherDoc )
411  {
412  // reference to other document - like inputhdl.cxx
413 
414  OSL_ENSURE(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
415 
416  // Always 3D and absolute.
417  OUString aTmp( rRef.Format(rRefDoc, ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D));
418 
419  SfxObjectShell* pObjSh = rRefDoc.GetDocumentShell();
420 
421  // #i75893# convert escaped URL of the document to something user friendly
422 // OUString aFileName = pObjSh->GetMedium()->GetName();
424 
425  aRefStr = "'" + aFileName + "'#" + aTmp;
426  }
427  else
428  {
429  // We can't use ScRange::Format here because in R1C1 mode we need
430  // to display the reference position relative to the cursor
431  // position.
432  ScTokenArray aArray(&rRefDoc);
433  ScComplexRefData aRefData;
434  aRefData.InitRangeRel(&rRefDoc, rRef, m_CursorPos);
435  bool bSingle = aRefData.Ref1 == aRefData.Ref2;
436  if (m_CursorPos.Tab() != rRef.aStart.Tab())
437  {
438  // pointer-selected => absolute sheet reference
439  aRefData.Ref1.SetAbsTab( rRef.aStart.Tab() );
440  aRefData.Ref1.SetFlag3D(true);
441  }
442  if (bSingle)
443  aArray.AddSingleReference(aRefData.Ref1);
444  else
445  aArray.AddDoubleReference(aRefData);
446  ScCompiler aComp(m_pDoc, m_CursorPos, aArray, m_pDoc->GetGrammar());
447  OUStringBuffer aBuf;
448  aComp.CreateStringFromTokenArray(aBuf);
449  aRefStr = aBuf.makeStringAndClear();
450  }
451 
452  UpdateParaWin(theSel,aRefStr);
453  }
454 }
455 
457 {
459  bool bRef = (pDesc && (pDesc->getSuppressedArgumentCount() > 0)) && (m_pDoc != nullptr);
460  return bRef;
461 }
462 
464 {
465  // not allowed: different from this doc, and no name
466  // pDocSh is always a ScDocShell
467  return !(pDocSh && &static_cast<ScDocShell*>(pDocSh)->GetDocument() != m_pDoc && !pDocSh->HasName()); // everything else is allowed
468 }
469 
471 {
473  if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
474  {
475  RefInputDone();
476  SetEdSelection();
477  }
478 }
479 
480 void ScFormulaDlg::SaveLRUEntry(const ScFuncDesc* pFuncDescP)
481 {
482  if (pFuncDescP && pFuncDescP->nFIndex!=0)
483  {
484  ScModule* pScMod = SC_MOD();
485  pScMod->InsertEntryToLRUList(pFuncDescP->nFIndex);
486  }
487 }
488 
489 void ScFormulaDlg::doClose(bool /*_bOk*/)
490 {
491  m_aHelper.DoClose( ScFormulaDlgWrapper::GetChildWindowId() );
492 }
494 {
495  const ScFuncDesc* pDesc = dynamic_cast<const ScFuncDesc*>(_pDesc);
496  SaveLRUEntry(pDesc);
497 }
498 void ScFormulaDlg::showReference(const OUString& _sFormula)
499 {
500  ShowReference(_sFormula);
501 }
502 void ScFormulaDlg::ShowReference(const OUString& _sFormula)
503 {
504  m_aHelper.ShowReference(_sFormula);
505 }
506 void ScFormulaDlg::HideReference( bool bDoneRefMode )
507 {
508  m_aHelper.HideReference(bDoneRefMode);
509 }
511 {
513 }
515 {
516 
517 }
519 {
520  // default: reference input can also be used to switch the table
521  return false;
522 }
523 
525 {
526  m_aHelper.ToggleCollapsed(pEdit,pButton);
527 }
528 
530 {
531  m_aHelper.ReleaseFocus(pEdit);
532 }
533 
534 void ScFormulaDlg::dispatch(bool _bOK, bool _bMatrixChecked)
535 {
536  SfxBoolItem aRetItem( SID_DLG_RETOK, _bOK );
537  SfxBoolItem aMatItem( SID_DLG_MATRIX, _bMatrixChecked );
539 
540  // if edit line is empty (caused by document switching) -> string is empty
541  // -> don't delete old formula
542  if ( aStrItem.GetValue().isEmpty() )
543  aRetItem.SetValue( false ); // sal_False = Cancel
544 
545  m_aHelper.SetDispatcherLock( false ); // turn off modal-mode
546 
547  clear();
548 
549  GetBindings().GetDispatcher()->ExecuteList( SID_INS_FUNCTION,
550  SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
551  { &aRetItem, &aStrItem, &aMatItem });
552 }
554 {
555  m_aHelper.SetDispatcherLock( bLock );
556 }
558 {
559  if (m_pViewShell)
560  m_pViewShell->ClearFormEditData(); // pData is invalid!
561 }
563 {
564  m_pDoc = nullptr;
565 
566  //restore reference inputhandler
567  ScModule* pScMod = SC_MOD();
568  pScMod->SetRefInputHdl(nullptr);
569 
570  // force Enable() of edit line
571  ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
572  if ( pScViewShell )
573  pScViewShell->UpdateInputHandler();
574 }
576 {
577  // back to the document
578  // (foreign doc could be above - #34222#)
580  if ( pHdl )
581  {
582  pHdl->ViewShellGone(nullptr); // -> get active view
583  pHdl->ShowRefFrame();
584  }
585 
586  // restore current chart (cause mouse-RefInput)
587  ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
588  if ( pScViewShell )
589  {
590  ScViewData& rVD=pScViewShell->GetViewData();
591  SCTAB nExecTab = m_CursorPos.Tab();
592  if ( nExecTab != rVD.GetTabNo() )
593  pScViewShell->SetTabNo( nExecTab );
594 
595  SCROW nRow = m_CursorPos.Row();
596  SCCOL nCol = m_CursorPos.Col();
597 
598  if(rVD.GetCurX()!=nCol || rVD.GetCurY()!=nRow)
599  pScViewShell->SetCursor(nCol,nRow);
600  }
601 }
603 {
604  ScTabViewShell* pViewShell = m_pViewShell;
605  if (pViewShell)
606  return pViewShell->GetFormEditData();
607  return nullptr;
608 }
609 void ScFormulaDlg::setCurrentFormula(const OUString& _sReplacement)
610 {
611  ScModule* pScMod = SC_MOD();
612  {
613  //fdo#69971 We need the EditEngine Modification handler of the inputbar that we
614  //are feeding to be disabled while this dialog is open. Otherwise we end up in
615  //a situation where...
616  //a) this ScFormulaDlg changes the editengine
617  //b) the modify callback gets called
618  //c) which also modifies the editengine
619  //d) on return from that modify handler the editengine attempts to use
620  // old node pointers which were replaced and removed by c
621  //
622  //We turn it off in the ctor and back on in the dtor, but if calc has
623  //to repaint, e.g. when switching to another window and back, then in
624  //ScMultiTextWnd::Paint a new editengine will have been created via
625  //GetEditView with its default Modification handler enabled. So ensure
626  //its off when we will access it via InputReplaceSelection
627  pScMod->InputTurnOffWinEngine();
628  }
629  pScMod->InputReplaceSelection(_sReplacement);
630 }
631 void ScFormulaDlg::setSelection(sal_Int32 _nStart, sal_Int32 _nEnd)
632 {
633  ScModule* pScMod = SC_MOD();
634  pScMod->InputSetSelection( _nStart, _nEnd );
635 }
636 void ScFormulaDlg::getSelection(sal_Int32& _nStart, sal_Int32& _nEnd) const
637 {
638  ScModule* pScMod = SC_MOD();
639  pScMod->InputGetSelection( _nStart, _nEnd );
640 }
642 {
644  if (pData && pData->GetInputHandler())
645  return pData->GetInputHandler()->GetFormString();
646  return "";
647 }
649 {
651 }
652 uno::Reference< sheet::XFormulaParser> ScFormulaDlg::getFormulaParser() const
653 {
654  return m_xParser;
655 }
656 uno::Reference< sheet::XFormulaOpCodeMapper> ScFormulaDlg::getFormulaOpCodeMapper() const
657 {
658  return m_xOpCodeMapper;
659 }
660 
661 table::CellAddress ScFormulaDlg::getReferencePosition() const
662 {
663  return table::CellAddress(m_CursorPos.Tab(), m_CursorPos.Col(), m_CursorPos.Row());
664 }
665 
666 ::std::unique_ptr<formula::FormulaTokenArray> ScFormulaDlg::convertToTokenArray(const uno::Sequence< sheet::FormulaToken >& _aTokenList)
667 {
668  ::std::unique_ptr<formula::FormulaTokenArray> pArray(new ScTokenArray(m_pDoc));
669  pArray->Fill(_aTokenList, m_pDoc->GetSharedStringPool(), m_pDoc->GetExternalRefManager());
670  return pArray;
671 }
672 
673 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void DoClose(sal_uInt16 nId)
Definition: anyrefdg.cxx:421
formula::FormulaToken * AddDoubleReference(const ScComplexRefData &rRef)
Definition: token.cxx:2212
void StoreFormEditData(FormEditData *pData)
static bool IsInputHdl(const ScInputHandler *pHdl)
Definition: formula.cxx:250
RefEdit * GetActiveEdit()
ScAddress aStart
Definition: address.hxx:500
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:563
virtual void switchBack() override
Definition: formula.cxx:575
void SetMeText(const OUString &_sText)
SCROW Row() const
Definition: address.hxx:262
virtual bool IsTableLocked() const override
Definition: formula.cxx:518
std::unique_ptr< ContentProperties > pData
const OUString & GetUndoStr() const
sal_uInt16 char char * pDesc
Definition: callform.cxx:58
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, Color **ppColor, bool bUseStarFormat=false)
sal_uIntPtr sal_uLong
void InputGetSelection(sal_Int32 &rStart, sal_Int32 &rEnd)
Definition: scmod.cxx:1402
void RefInputDoneAfter(bool bForced)
SCROW GetCurY() const
Definition: viewdata.hxx:402
sal_Int64 n
virtual void clear() override
Definition: formula.cxx:562
void SetDialog(weld::Dialog *pDialog)
Definition: anyrefdg.hxx:71
aBuf
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: formula.cxx:381
formula::FormulaToken * AddSingleReference(const ScSingleRefData &rRef)
ScSingleRefToken with ocPush.
Definition: token.cxx:2202
virtual bool calculateValue(const OUString &_sExpression, OUString &_rResult, bool bMatrixFormula) override
Definition: formula.cxx:298
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
#define SC_UNO_COMPILEFAP
Definition: unonames.hxx:673
ScInputHandler * GetInputHandler()
Definition: formdata.hxx:33
ScAddress aEnd
Definition: address.hxx:501
virtual css::uno::Reference< css::sheet::XFormulaParser > getFormulaParser() const override
Definition: formula.cxx:652
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:988
virtual ::std::unique_ptr< formula::FormulaTokenArray > convertToTokenArray(const css::uno::Sequence< css::sheet::FormulaToken > &_aTokenList) override
Definition: formula.cxx:666
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:358
void SetRefViewShell(ScTabViewShell *pRefVsh)
Definition: inputhdl.hxx:213
void ViewShellGone(const ScTabViewShell *pViewSh)
Definition: inputhdl.cxx:2116
void ShowRefFrame()
Definition: inputhdl.cxx:2709
virtual void SetReference(const ScRange &rRef, ScDocument &rD) override
Definition: formula.cxx:395
virtual void getSelection(sal_Int32 &_nStart, sal_Int32 &_nEnd) const override
Definition: formula.cxx:636
virtual void setCurrentFormula(const OUString &_sReplacement) override
Definition: formula.cxx:609
SC_DLLPUBLIC void GetFormula(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString &rFormula) const
Definition: document.cxx:3717
virtual void setSelection(sal_Int32 _nStart, sal_Int32 _nEnd) override
Definition: formula.cxx:631
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL)
Definition: scmod.cxx:1359
bool UpdateParaWin(Selection &_rSelection)
void ReleaseFocus(formula::RefEdit *pEdit)
Definition: anyrefdg.cxx:283
void InputReplaceSelection(const OUString &rStr)
Definition: inputhdl.cxx:4326
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
OUString GetMeText() const
virtual void AddRefEntry() override
Definition: formula.cxx:514
static ScInputHandler * GetNextInputHandler(const ScDocShell *pDocShell, ScTabViewShell **ppViewSh)
Definition: formula.cxx:268
void InsertEntryToLRUList(sal_uInt16 nFIndex)
Definition: scmod.cxx:687
virtual void SetActive() override
Definition: formula.cxx:470
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
void SetRefInputHdl(ScInputHandler *pNew)
Definition: scmod.cxx:1397
static SfxViewShell * Current()
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
Definition: documen3.cxx:604
Mode eMode
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:632
SCTAB Tab() const
Definition: address.hxx:271
virtual void setDispatcherLock(bool bLock) override
Definition: formula.cxx:553
ScDocument * GetDocument() const
Definition: viewdata.cxx:859
void InputSetSelection(sal_Int32 nStart, sal_Int32 nEnd)
Definition: inputhdl.cxx:4306
void ClearFormEditData()
Definition: tabvwshc.cxx:729
ScViewData & GetViewData()
Definition: tabview.hxx:332
virtual void notifyChange() override
Definition: formula.cxx:180
const IFunctionDescription * getCurrentFunctionDescription() const
void ToggleCollapsed(formula::RefEdit *pEdit, formula::RefButton *pButton)
Definition: anyrefdg.cxx:401
static css::uno::Reference< css::uno::XInterface > MakeInstance(Type nType, ScDocShell *pDocShell)
Definition: servuno.cxx:396
virtual css::table::CellAddress getReferencePosition() const override
Definition: formula.cxx:661
ScDocShell * GetDocShell()
Definition: formdata.hxx:34
virtual void ReleaseFocus(formula::RefEdit *pEdit) override
Definition: formula.cxx:529
ScAddress m_CursorPos
Definition: formula.hxx:43
virtual formula::FormEditData * getFormEditData() const override
Definition: formula.cxx:602
virtual bool IsRefInputMode() const override
Definition: formula.cxx:456
virtual void insertEntryToLRUList(const formula::IFunctionDescription *pDesc) override
Definition: formula.cxx:493
virtual void deleteFormData() override
Definition: formula.cxx:557
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:438
static void EnableSpreadsheets(bool bFlag=true)
Definition: anyrefdg.cxx:482
#define SCITEM_STRING
Definition: scitems.hxx:88
ScFormEditData * GetFormEditData()
Definition: tabvwsh.hxx:402
void SetFlag3D(bool bVal)
Definition: refdata.hxx:90
virtual void ToggleCollapsed(formula::RefEdit *pEdit, formula::RefButton *pButton) override
Definition: formula.cxx:524
sal_Int16 SCCOL
Definition: types.hxx:22
ScFormulaDlg(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, const ScViewData *pViewData, const formula::IFunctionManager *_pFunctionMgr)
Definition: formula.cxx:59
ScFormulaReferenceHelper m_aHelper
Definition: formula.hxx:38
ScTabViewShell * m_pViewShell
Definition: formula.hxx:44
#define SC_MOD()
Definition: scmod.hxx:253
virtual std::unique_ptr< formula::FormulaCompiler > createCompiler(formula::FormulaTokenArray &rArray) const override
Definition: formula.cxx:370
ScSingleRefData Ref1
Definition: refdata.hxx:125
SC_DLLPUBLIC OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
Definition: address.cxx:2207
const OUString & GetValue() const
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1786
static SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static ScFunctionMgr * GetStarCalcFunctionMgr()
Definition: global.cxx:628
ScSingleRefData Ref2
Definition: refdata.hxx:126
::std::pair< RefButton *, RefEdit * > RefInputStartBefore(RefEdit *pEdit, RefButton *pButton)
const OUString & GetFormString() const
Definition: inputhdl.hxx:191
void HideReference(bool bDoneRefMode=true)
Definition: anyrefdg.cxx:231
bool HasName() const
static void SaveLRUEntry(const ScFuncDesc *pFuncDesc)
Definition: formula.cxx:480
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:551
void SetAbsTab(SCTAB nVal)
Definition: refdata.cxx:93
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
virtual void Close() override
Definition: formula.cxx:288
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument *=nullptr, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, ScAddress::ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, const OUString *pErrRef=nullptr)
Definition: address.cxx:1737
SfxViewShell * GetViewShell() const
static void enableInput(bool _bInput)
Definition: anyrefdg.cxx:76
void SetValue(bool const bTheValue)
FormulaError
void SetInputHandler(ScInputHandler *pHdl)
Definition: formdata.hxx:36
SCCOL Col() const
Definition: address.hxx:267
void SetDocShell(ScDocShell *pSds)
Definition: formdata.hxx:37
virtual void ViewShellChanged() override
Definition: formula.cxx:510
css::uno::Reference< css::sheet::XFormulaParser > m_xParser
Definition: formula.hxx:39
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
virtual formula::IFunctionManager * getFunctionManager() override
Definition: formula.cxx:648
sal_Int32 SCROW
Definition: types.hxx:18
std::shared_ptr< ScCompiler > m_xCompiler
Definition: formula.hxx:45
virtual ~ScFormulaDlg() COVERITY_NOEXCEPT_FALSE override
Definition: formula.cxx:234
void SetDispatcherLock(bool bLock)
Definition: anyrefdg.cxx:458
virtual css::uno::Reference< css::sheet::XFormulaOpCodeMapper > getFormulaOpCodeMapper() const override
Definition: formula.cxx:656
void InputGetSelection(sal_Int32 &rStart, sal_Int32 &rEnd)
Methods for FunctionAutoPilot: InputGetSelection, InputSetSelection, InputReplaceSelection, InputGetFormulaStr.
Definition: inputhdl.cxx:4274
virtual void doClose(bool _bOk) override
Definition: formula.cxx:489
void InitFormEditData()
Definition: tabvwshc.cxx:724
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
virtual sal_Int32 getSuppressedArgumentCount() const =0
SfxViewFrame * GetFrame() const
void InputReplaceSelection(const OUString &rStr)
Definition: scmod.cxx:1416
void NotifyChange(const ScInputHdlState *pState, bool bForce=false, ScTabViewShell *pSourceSh=nullptr, bool bStopEditing=true)
Definition: inputhdl.cxx:3937
Reference< XExecutableDialog > m_xDialog
const INetURLObject & GetURLObject() const
virtual void ShowReference(const OUString &_sRef) override
Definition: formula.cxx:502
void * p
sal_uInt16 nFIndex
Unique function index.
Definition: funcdesc.hxx:222
virtual OUString getCurrentFormula() const override
Definition: formula.cxx:641
const FormulaHelper & GetFormulaHelper() const
void InputSetSelection(sal_Int32 nStart, sal_Int32 nEnd)
Definition: scmod.cxx:1409
void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton)
Definition: anyrefdg.cxx:370
void RefInputDone(bool bForced)
Definition: anyrefdg.cxx:343
ScDocument * m_pDoc
Definition: formula.hxx:42
virtual void HideReference(bool bDoneRefMode=true) override
Definition: formula.cxx:506
static void ViewShellChanged()
Definition: anyrefdg.cxx:476
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
SfxDispatcher * GetDispatcher() const
virtual void dispatch(bool _bOK, bool _bMatrixChecked) override
Definition: formula.cxx:534
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1061
void InitRangeRel(const ScDocument *pDoc, const ScRange &rRange, const ScAddress &rPos)
Definition: refdata.hxx:135
void InputTurnOffWinEngine()
Definition: scmod.cxx:1423
bool CheckMatrix(OUString &aFormula)
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
Definition: scmod.cxx:1303
virtual void showReference(const OUString &_sFormula) override
Definition: formula.cxx:498
virtual bool IsDocAllowed(SfxObjectShell *pDocSh) const override
Definition: formula.cxx:463
void ShowReference(const OUString &rStr)
Definition: anyrefdg.cxx:259
void SetFStart(sal_Int32 nNew)
virtual std::shared_ptr< formula::FormulaCompiler > getCompiler() const override
Definition: formula.cxx:363
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
Definition: funcdesc.hxx:41
const ScInputHandler * GetInputHandler() const
Definition: tabvwsh.hxx:233
static OUString GetErrorString(FormulaError nErrNumber)
Definition: global.cxx:305
virtual void RefInputDone(bool bForced=false) override
Definition: formula.cxx:389
virtual void fill() override
Definition: formula.cxx:187
sal_Int16 SCTAB
Definition: types.hxx:23
void SetMode(FormulaDlgMode nNew)
SCCOL GetCurX() const
Definition: viewdata.hxx:401
css::uno::Reference< css::sheet::XFormulaOpCodeMapper > m_xOpCodeMapper
Definition: formula.hxx:40
SfxMedium * GetMedium() const