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& rViewData, 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 = &rViewData.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  return;
114 
115  pScMod->SetRefInputHdl(pInputHdl);
116 
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 );
122 
123  m_pViewShell->InitFormEditData(); // create new
124  pData = m_pViewShell->GetFormEditData();
125  pData->SetInputHandler(pInputHdl);
126  pData->SetDocShell(rViewData.GetDocShell());
127 
128  OSL_ENSURE(pData,"FormEditData not available");
129 
130  formula::FormulaDlgMode eMode = FormulaDlgMode::Formula; // default...
131 
132  // edit if formula exists
133 
134  OUString aFormula;
135  m_pDoc->GetFormula( nCol, nRow, nTab, aFormula );
136  bool bEdit = ( aFormula.getLength() > 1 );
137  bool bMatrix = false;
138  if ( bEdit )
139  {
140  bMatrix = CheckMatrix(aFormula);
141 
142  sal_Int32 nFStart = 0;
143  sal_Int32 nFEnd = 0;
144  if ( GetFormulaHelper().GetNextFunc( aFormula, false, nFStart, &nFEnd) )
145  {
146  pInputHdl->InputReplaceSelection( aFormula );
147  pInputHdl->InputSetSelection( nFStart, nFEnd );
148  sal_Int32 PrivStart, PrivEnd;
149  pInputHdl->InputGetSelection( PrivStart, PrivEnd);
150 
151  eMode = SetMeText(pInputHdl->GetFormString(),PrivStart, PrivEnd, bMatrix, true, true);
152  pData->SetFStart( nFStart );
153  }
154  else
155  bEdit = false;
156  }
157 
158  if ( !bEdit )
159  {
160  OUString aNewFormula('=');
161  if ( aFormula.startsWith("=") )
162  aNewFormula = aFormula;
163 
164  pInputHdl->InputReplaceSelection( aNewFormula );
165  pInputHdl->InputSetSelection( 1, aNewFormula.getLength()+1 );
166  sal_Int32 PrivStart, PrivEnd;
167  pInputHdl->InputGetSelection( PrivStart, PrivEnd);
168  SetMeText(pInputHdl->GetFormString(),PrivStart, PrivEnd,bMatrix,false,false);
169 
170  pData->SetFStart( 1 ); // after "="
171  }
172 
173  pData->SetMode( eMode );
174  OUString rStrExp = GetMeText();
175 
176  Update(rStrExp);
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  return;
195 
196  // data exists -> restore state (after switch)
197  // don't reinitialise m_pDoc and m_CursorPos
198  //pDoc = rViewData.GetDocument();
199  if(IsInputHdl(pData->GetInputHandler()))
200  {
201  pScMod->SetRefInputHdl(pData->GetInputHandler());
202  }
203  else
204  {
205  ScTabViewShell* pTabViewShell;
206  ScInputHandler* pInputHdl = GetNextInputHandler(pData->GetDocShell(),&pTabViewShell);
207 
208  if ( pInputHdl == nullptr ) //no more InputHandler for DocShell
209  {
210  disableOk();
211  pInputHdl = pScMod->GetInputHdl();
212  }
213  else
214  {
215  pInputHdl->SetRefViewShell(pTabViewShell);
216  }
217  pScMod->SetRefInputHdl(pInputHdl);
218  pData->SetInputHandler(pInputHdl);
219  }
220 
221  OUString aOldFormulaTmp(pData->GetInputHandler()->GetFormString());
222  pData->GetInputHandler()->InputSetSelection( 0, aOldFormulaTmp.getLength());
223 
224  rStrExp=pData->GetUndoStr();
225  pData->GetInputHandler()->InputReplaceSelection(rStrExp);
226 
227  SetMeText(rStrExp);
228 
229  Update();
230  // switch back, maybe new Doc has been opened
231  pScMod->SetRefInputHdl(nullptr);
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  const 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  return;
400 
401  Selection theSel;
402  bool bRefNull = UpdateParaWin(theSel);
403 
404  if ( rRef.aStart != rRef.aEnd && bRefNull )
405  {
407  }
408 
409  // Pointer-selected => absolute range references for the non-single
410  // dimensions, so in the other dimension (if any) it's still
411  // copy-adjustable.
412  constexpr ScRefFlags eColFlags = ScRefFlags::COL_ABS | ScRefFlags::COL2_ABS;
413  constexpr ScRefFlags eRowFlags = ScRefFlags::ROW_ABS | ScRefFlags::ROW2_ABS;
414  ScRefFlags eRangeFlags = ScRefFlags::ZERO;
415  if (rRef.aStart.Col() != rRef.aEnd.Col())
416  eRangeFlags |= eColFlags;
417  if (rRef.aStart.Row() != rRef.aEnd.Row())
418  eRangeFlags |= eRowFlags;
419  OUString aRefStr;
420  bool bOtherDoc = (&rRefDoc != m_pDoc && rRefDoc.GetDocumentShell()->HasName());
421  if ( bOtherDoc )
422  {
423  // reference to other document - like inputhdl.cxx
424 
425  OSL_ENSURE(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
426 
427  // Sheet always 3D and absolute.
428  OUString aTmp( rRef.Format(rRefDoc, ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D | eRangeFlags));
429 
430  SfxObjectShell* pObjSh = rRefDoc.GetDocumentShell();
431 
432  // #i75893# convert escaped URL of the document to something user friendly
433 // OUString aFileName = pObjSh->GetMedium()->GetName();
435 
436  aRefStr = "'" + aFileName + "'#" + aTmp;
437  }
438  else
439  {
440  // We can't use ScRange::Format here because in R1C1 mode we need
441  // to display the reference position relative to the cursor
442  // position.
443  ScTokenArray aArray(rRefDoc);
444  ScComplexRefData aRefData;
445  aRefData.InitRangeRel(rRefDoc, rRef, m_CursorPos);
446  if ((eRangeFlags & eColFlags) == eColFlags)
447  {
448  aRefData.Ref1.SetAbsCol( rRef.aStart.Col() );
449  aRefData.Ref2.SetAbsCol( rRef.aEnd.Col() );
450  }
451  if ((eRangeFlags & eRowFlags) == eRowFlags)
452  {
453  aRefData.Ref1.SetAbsRow( rRef.aStart.Row() );
454  aRefData.Ref2.SetAbsRow( rRef.aEnd.Row() );
455  }
456  bool bSingle = aRefData.Ref1 == aRefData.Ref2;
457  if (m_CursorPos.Tab() != rRef.aStart.Tab())
458  {
459  // pointer-selected => absolute sheet reference
460  aRefData.Ref1.SetAbsTab( rRef.aStart.Tab() );
461  aRefData.Ref1.SetFlag3D(true);
462  }
463  if (bSingle)
464  aArray.AddSingleReference(aRefData.Ref1);
465  else
466  aArray.AddDoubleReference(aRefData);
467  ScCompiler aComp(*m_pDoc, m_CursorPos, aArray, m_pDoc->GetGrammar());
468  OUStringBuffer aBuf;
469  aComp.CreateStringFromTokenArray(aBuf);
470  aRefStr = aBuf.makeStringAndClear();
471  }
472 
473  UpdateParaWin(theSel,aRefStr);
474 }
475 
477 {
479  bool bRef = (pDesc && (pDesc->getSuppressedArgumentCount() > 0)) && (m_pDoc != nullptr);
480  return bRef;
481 }
482 
484 {
485  // not allowed: different from this doc, and no name
486  // pDocSh is always a ScDocShell
487  return !pDocSh || &static_cast<ScDocShell*>(pDocSh)->GetDocument() == m_pDoc || pDocSh->HasName(); // everything else is allowed
488 }
489 
491 {
493  if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
494  {
495  RefInputDone();
496  SetEdSelection();
497  }
498 }
499 
500 void ScFormulaDlg::SaveLRUEntry(const ScFuncDesc* pFuncDescP)
501 {
502  if (pFuncDescP && pFuncDescP->nFIndex!=0)
503  {
504  ScModule* pScMod = SC_MOD();
505  pScMod->InsertEntryToLRUList(pFuncDescP->nFIndex);
506  }
507 }
508 
509 void ScFormulaDlg::doClose(bool /*_bOk*/)
510 {
511  m_aHelper.DoClose( ScFormulaDlgWrapper::GetChildWindowId() );
512 }
514 {
515  const ScFuncDesc* pDesc = dynamic_cast<const ScFuncDesc*>(_pDesc);
516  SaveLRUEntry(pDesc);
517 }
518 void ScFormulaDlg::showReference(const OUString& _sFormula)
519 {
520  ShowReference(_sFormula);
521 }
522 void ScFormulaDlg::ShowReference(const OUString& _sFormula)
523 {
524  m_aHelper.ShowReference(_sFormula);
525 }
526 void ScFormulaDlg::HideReference( bool bDoneRefMode )
527 {
528  m_aHelper.HideReference(bDoneRefMode);
529 }
531 {
533 }
535 {
536 
537 }
539 {
540  // default: reference input can also be used to switch the table
541  return false;
542 }
543 
545 {
546  m_aHelper.ToggleCollapsed(pEdit,pButton);
547 }
548 
550 {
551  m_aHelper.ReleaseFocus(pEdit);
552 }
553 
554 void ScFormulaDlg::dispatch(bool _bOK, bool _bMatrixChecked)
555 {
556  SfxBoolItem aRetItem( SID_DLG_RETOK, _bOK );
557  SfxBoolItem aMatItem( SID_DLG_MATRIX, _bMatrixChecked );
559 
560  // if edit line is empty (caused by document switching) -> string is empty
561  // -> don't delete old formula
562  if ( aStrItem.GetValue().isEmpty() )
563  aRetItem.SetValue( false ); // sal_False = Cancel
564 
565  m_aHelper.SetDispatcherLock( false ); // turn off modal-mode
566 
567  clear();
568 
569  GetBindings().GetDispatcher()->ExecuteList( SID_INS_FUNCTION,
570  SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
571  { &aRetItem, &aStrItem, &aMatItem });
572 }
574 {
575  m_aHelper.SetDispatcherLock( bLock );
576 }
578 {
579  if (m_pViewShell)
580  m_pViewShell->ClearFormEditData(); // pData is invalid!
581 }
583 {
584  m_pDoc = nullptr;
585 
586  //restore reference inputhandler
587  ScModule* pScMod = SC_MOD();
588  pScMod->SetRefInputHdl(nullptr);
589 
590  // force Enable() of edit line
591  ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
592  if ( pScViewShell )
593  pScViewShell->UpdateInputHandler();
594 }
596 {
597  // back to the document
598  // (foreign doc could be above - #34222#)
600  if ( pHdl )
601  {
602  pHdl->ViewShellGone(nullptr); // -> get active view
603  pHdl->ShowRefFrame();
604  }
605 
606  // restore current chart (cause mouse-RefInput)
607  ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
608  if ( !pScViewShell )
609  return;
610 
611  ScViewData& rVD=pScViewShell->GetViewData();
612  SCTAB nExecTab = m_CursorPos.Tab();
613  if ( nExecTab != rVD.GetTabNo() )
614  pScViewShell->SetTabNo( nExecTab );
615 
616  SCROW nRow = m_CursorPos.Row();
617  SCCOL nCol = m_CursorPos.Col();
618 
619  if(rVD.GetCurX()!=nCol || rVD.GetCurY()!=nRow)
620  pScViewShell->SetCursor(nCol,nRow);
621 }
623 {
624  ScTabViewShell* pViewShell = m_pViewShell;
625  if (pViewShell)
626  return pViewShell->GetFormEditData();
627  return nullptr;
628 }
629 void ScFormulaDlg::setCurrentFormula(const OUString& _sReplacement)
630 {
631  ScModule* pScMod = SC_MOD();
632  {
633  //fdo#69971 We need the EditEngine Modification handler of the inputbar that we
634  //are feeding to be disabled while this dialog is open. Otherwise we end up in
635  //a situation where...
636  //a) this ScFormulaDlg changes the editengine
637  //b) the modify callback gets called
638  //c) which also modifies the editengine
639  //d) on return from that modify handler the editengine attempts to use
640  // old node pointers which were replaced and removed by c
641  //
642  //We turn it off in the ctor and back on in the dtor, but if calc has
643  //to repaint, e.g. when switching to another window and back, then in
644  //ScMultiTextWnd::Paint a new editengine will have been created via
645  //GetEditView with its default Modification handler enabled. So ensure
646  //its off when we will access it via InputReplaceSelection
647  pScMod->InputTurnOffWinEngine();
648  }
649  pScMod->InputReplaceSelection(_sReplacement);
650 }
651 void ScFormulaDlg::setSelection(sal_Int32 _nStart, sal_Int32 _nEnd)
652 {
653  ScModule* pScMod = SC_MOD();
654  pScMod->InputSetSelection( _nStart, _nEnd );
655 }
656 void ScFormulaDlg::getSelection(sal_Int32& _nStart, sal_Int32& _nEnd) const
657 {
658  ScModule* pScMod = SC_MOD();
659  pScMod->InputGetSelection( _nStart, _nEnd );
660 }
662 {
664  if (pData && pData->GetInputHandler())
665  return pData->GetInputHandler()->GetFormString();
666  return "";
667 }
669 {
671 }
672 uno::Reference< sheet::XFormulaParser> ScFormulaDlg::getFormulaParser() const
673 {
674  return m_xParser;
675 }
676 uno::Reference< sheet::XFormulaOpCodeMapper> ScFormulaDlg::getFormulaOpCodeMapper() const
677 {
678  return m_xOpCodeMapper;
679 }
680 
681 table::CellAddress ScFormulaDlg::getReferencePosition() const
682 {
683  return table::CellAddress(m_CursorPos.Tab(), m_CursorPos.Col(), m_CursorPos.Row());
684 }
685 
686 ::std::unique_ptr<formula::FormulaTokenArray> ScFormulaDlg::convertToTokenArray(const uno::Sequence< sheet::FormulaToken >& _aTokenList)
687 {
688  ::std::unique_ptr<formula::FormulaTokenArray> pArray(new ScTokenArray(*m_pDoc));
689  pArray->Fill(_aTokenList, m_pDoc->GetSharedStringPool(), m_pDoc->GetExternalRefManager());
690  return pArray;
691 }
692 
693 /* 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:595
void SetMeText(const OUString &_sText)
SCROW Row() const
Definition: address.hxx:262
virtual bool IsTableLocked() const override
Definition: formula.cxx:538
std::unique_ptr< ContentProperties > pData
const OUString & GetUndoStr() const
sal_uInt16 char char * pDesc
Definition: callform.cxx:58
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:582
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
void InitRangeRel(const ScDocument &rDoc, const ScRange &rRange, const ScAddress &rPos)
Definition: refdata.hxx:135
ScAddress aEnd
Definition: address.hxx:501
void SetAbsRow(SCROW nVal)
Definition: refdata.cxx:76
virtual css::uno::Reference< css::sheet::XFormulaParser > getFormulaParser() const override
Definition: formula.cxx:672
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:985
virtual ::std::unique_ptr< formula::FormulaTokenArray > convertToTokenArray(const css::uno::Sequence< css::sheet::FormulaToken > &_aTokenList) override
Definition: formula.cxx:686
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:2122
void ShowRefFrame()
Definition: inputhdl.cxx:2715
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:656
virtual void setCurrentFormula(const OUString &_sReplacement) override
Definition: formula.cxx:629
SC_DLLPUBLIC void GetFormula(SCCOL nCol, SCROW nRow, SCTAB nTab, OUString &rFormula) const
Definition: document.cxx:3715
virtual void setSelection(sal_Int32 _nStart, sal_Int32 _nEnd) override
Definition: formula.cxx:651
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:4331
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
OUString GetMeText() const
virtual void AddRefEntry() override
Definition: formula.cxx:534
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:490
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:618
Mode eMode
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:638
SCTAB Tab() const
Definition: address.hxx:271
virtual void setDispatcherLock(bool bLock) override
Definition: formula.cxx:573
ScFormulaDlg(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, const ScViewData &rViewData, const formula::IFunctionManager *_pFunctionMgr)
Definition: formula.cxx:59
void InputSetSelection(sal_Int32 nStart, sal_Int32 nEnd)
Definition: inputhdl.cxx:4311
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:681
ScDocShell * GetDocShell()
Definition: formdata.hxx:34
virtual void ReleaseFocus(formula::RefEdit *pEdit) override
Definition: formula.cxx:549
ScAddress m_CursorPos
Definition: formula.hxx:43
virtual formula::FormEditData * getFormEditData() const override
Definition: formula.cxx:622
virtual bool IsRefInputMode() const override
Definition: formula.cxx:476
virtual void insertEntryToLRUList(const formula::IFunctionDescription *pDesc) override
Definition: formula.cxx:513
virtual void deleteFormData() override
Definition: formula.cxx:577
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:544
sal_Int16 SCCOL
Definition: types.hxx:22
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
void SetAbsCol(SCCOL nVal)
Definition: refdata.cxx:59
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:2203
const OUString & GetValue() const
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1793
static SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static ScFunctionMgr * GetStarCalcFunctionMgr()
Definition: global.cxx:620
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:500
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:548
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
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:530
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:668
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:676
void InputGetSelection(sal_Int32 &rStart, sal_Int32 &rEnd)
Methods for FunctionAutoPilot: InputGetSelection, InputSetSelection, InputReplaceSelection, InputGetFormulaStr.
Definition: inputhdl.cxx:4279
virtual void doClose(bool _bOk) override
Definition: formula.cxx:509
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
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument &, 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:1733
void NotifyChange(const ScInputHdlState *pState, bool bForce=false, ScTabViewShell *pSourceSh=nullptr, bool bStopEditing=true)
Definition: inputhdl.cxx:3942
Reference< XExecutableDialog > m_xDialog
const INetURLObject & GetURLObject() const
virtual void ShowReference(const OUString &_sRef) override
Definition: formula.cxx:522
void * p
sal_uInt16 nFIndex
Unique function index.
Definition: funcdesc.hxx:222
virtual OUString getCurrentFormula() const override
Definition: formula.cxx:661
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:526
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:554
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1058
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:518
ScRefFlags
Definition: address.hxx:145
virtual bool IsDocAllowed(SfxObjectShell *pDocSh) const override
Definition: formula.cxx:483
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
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, const Color **ppColor, bool bUseStarFormat=false)
static OUString GetErrorString(FormulaError nErrNumber)
Definition: global.cxx:301
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