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/numformat.hxx>
26#include <svl/stritem.hxx>
27#include <sfx2/viewfrm.hxx>
28#include <tools/urlobj.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
54using namespace formula;
55using 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::Any(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
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 = m_pDoc->GetFormula( nCol, nRow, nTab );
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
180{
182 if ( pInputHdl )
183 pInputHdl->NotifyChange( nullptr );
184}
185
187{
188 ScModule* pScMod = SC_MOD();
190 notifyChange();
191 OUString rStrExp;
192 if (!pData)
193 return;
194
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()))
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
233ScFormulaDlg::~ScFormulaDlg() COVERITY_NOEXCEPT_FALSE
234{
236
238
239 if (pData) // close doesn't destroy;
240 {
241 //set back reference input handler
242 SC_MOD()->SetRefInputHdl(nullptr);
244 }
245
247}
248
250{
251 bool bAlive = false;
252
253 // belongs InputHandler to a ViewShell?
254
255 SfxViewShell* pSh = SfxViewShell::GetFirst( true, checkSfxViewShell<ScTabViewShell> );
256 while ( pSh && !bAlive )
257 {
258 if (static_cast<ScTabViewShell*>(pSh)->GetInputHandler() == pHdl)
259 bAlive = true;
260 pSh = SfxViewShell::GetNext( *pSh, true, checkSfxViewShell<ScTabViewShell> );
261 }
262
263 return bAlive;
264
265}
266
268{
269 ScInputHandler* pHdl=nullptr;
270
271 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
272 while( pFrame && pHdl==nullptr)
273 {
274 SfxViewShell* p = pFrame->GetViewShell();
275 ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( p );
276 if(pViewSh!=nullptr)
277 {
278 pHdl=pViewSh->GetInputHandler();
279 if(ppViewSh!=nullptr) *ppViewSh=pViewSh;
280 }
281 pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
282 }
283
284 return pHdl;
285}
286
288{
289 if (IsClosing())
290 return;
291
292 DoEnter();
293}
294
295// functions for right side
296
297bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult, bool bMatrixFormula )
298{
299 std::optional<ScSimpleFormulaCalculator> pFCell(std::in_place,
300 *m_pDoc, m_CursorPos, rStrExp, bMatrixFormula);
301 pFCell->SetLimitString(true);
302
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 )
308 {
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);
316 }
317 else
318 bColRowName = false;
319 }
320
321 FormulaError nErrCode = pFCell->GetErrCode();
322 if ( nErrCode == FormulaError::NONE || pFCell->IsMatrix() )
323 {
324 SvNumberFormatter& aFormatter = *(m_pDoc->GetFormatTable());
325 const Color* pColor;
326 if (pFCell->IsMatrix())
327 {
328 rStrResult = pFCell->GetString().getString();
329 }
330 else if (pFCell->IsValue())
331 {
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 );
336 }
337 else
338 {
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( "\"", "\"\"") + "\"";
348 }
349
350 ScRange aTestRange;
351 if ( bColRowName || (aTestRange.Parse(rStrExp, *m_pDoc) & ScRefFlags::VALID) )
352 rStrResult += " ...";
353 // area
354 }
355 else
356 rStrResult += ScGlobal::GetErrorString(nErrCode);
357
358 return true;
359}
360
361std::shared_ptr<formula::FormulaCompiler> ScFormulaDlg::getCompiler() const
362{
363 if (!m_xCompiler)
364 m_xCompiler = std::make_shared<ScCompiler>(*m_pDoc, m_CursorPos, m_pDoc->GetGrammar());
365 return m_xCompiler;
366}
367
368std::unique_ptr<formula::FormulaCompiler> ScFormulaDlg::createCompiler( formula::FormulaTokenArray& rArray ) const
369{
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);
376}
377
378// virtual methods of ScAnyRefDlg:
380{
381 pEdit->SelectAll();
382 ::std::pair<formula::RefButton*,formula::RefEdit*> aPair = RefInputStartBefore( pEdit, pButton );
383 m_aHelper.RefInputStart( aPair.second, aPair.first);
385}
386
387void ScFormulaDlg::RefInputDone( bool bForced )
388{
389 m_aHelper.RefInputDone( bForced );
390 RefInputDoneAfter( bForced );
391}
392
393void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument& rRefDoc )
394{
396 if ( !(pFunc && pFunc->getSuppressedArgumentCount() > 0) )
397 return;
398
399 Selection theSel;
400 bool bRefNull = UpdateParaWin(theSel);
401
402 if ( rRef.aStart != rRef.aEnd && bRefNull )
403 {
405 }
406
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.
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 )
420 {
421 // reference to other document - like inputhdl.cxx
422
423 OSL_ENSURE(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
424
425 // Sheet always 3D and absolute.
426 OUString aTmp( rRef.Format(rRefDoc, ScRefFlags::VALID | ScRefFlags::TAB_ABS_3D | eRangeFlags));
427
428 SfxObjectShell* pObjSh = rRefDoc.GetDocumentShell();
429
430 // #i75893# convert escaped URL of the document to something user friendly
431// OUString aFileName = pObjSh->GetMedium()->GetName();
433
434 aRefStr = "'" + aFileName + "'#" + aTmp;
435 }
436 else
437 {
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)
445 {
446 aRefData.Ref1.SetAbsCol( rRef.aStart.Col() );
447 aRefData.Ref2.SetAbsCol( rRef.aEnd.Col() );
448 }
449 if ((eRangeFlags & eRowFlags) == eRowFlags)
450 {
451 aRefData.Ref1.SetAbsRow( rRef.aStart.Row() );
452 aRefData.Ref2.SetAbsRow( rRef.aEnd.Row() );
453 }
454 bool bSingle = aRefData.Ref1 == aRefData.Ref2;
455 if (m_CursorPos.Tab() != rRef.aStart.Tab())
456 {
457 // pointer-selected => absolute sheet reference
458 aRefData.Ref1.SetAbsTab( rRef.aStart.Tab() );
459 aRefData.Ref1.SetFlag3D(true);
460 }
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;
468 aRefStr = aBuf.makeStringAndClear();
469 }
470
471 UpdateParaWin(theSel,aRefStr);
472}
473
475{
477 bool bRef = (pDesc && (pDesc->getSuppressedArgumentCount() > 0)) && (m_pDoc != nullptr);
478 return bRef;
479}
480
482{
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
486}
487
489{
491 if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
492 {
493 RefInputDone();
495 }
496}
497
499{
500 if (pFuncDescP && pFuncDescP->nFIndex!=0)
501 {
502 ScModule* pScMod = SC_MOD();
503 pScMod->InsertEntryToLRUList(pFuncDescP->nFIndex);
504 }
505}
506
507void ScFormulaDlg::doClose(bool /*_bOk*/)
508{
509 m_aHelper.DoClose( ScFormulaDlgWrapper::GetChildWindowId() );
510}
512{
513 const ScFuncDesc* pDesc = dynamic_cast<const ScFuncDesc*>(_pDesc);
514 SaveLRUEntry(pDesc);
515}
516void ScFormulaDlg::showReference(const OUString& _sFormula)
517{
518 ShowReference(_sFormula);
519}
520void ScFormulaDlg::ShowReference(const OUString& _sFormula)
521{
522 m_aHelper.ShowReference(_sFormula);
523}
524void ScFormulaDlg::HideReference( bool bDoneRefMode )
525{
526 m_aHelper.HideReference(bDoneRefMode);
527}
529{
531}
533{
534
535}
537{
538 // default: reference input can also be used to switch the table
539 return false;
540}
541
543{
544 m_aHelper.ToggleCollapsed(pEdit,pButton);
545}
546
548{
549 m_aHelper.ReleaseFocus(pEdit);
550}
551
552void ScFormulaDlg::dispatch(bool _bOK, bool _bMatrixChecked)
553{
554 SfxBoolItem aRetItem( SID_DLG_RETOK, _bOK );
555 SfxBoolItem aMatItem( SID_DLG_MATRIX, _bMatrixChecked );
557
558 // if edit line is empty (caused by document switching) -> string is empty
559 // -> don't delete old formula
560 if ( aStrItem.GetValue().isEmpty() )
561 aRetItem.SetValue( false ); // sal_False = Cancel
562
563 m_aHelper.SetDispatcherLock( false ); // turn off modal-mode
564
565 clear();
566
567 GetBindings().GetDispatcher()->ExecuteList( SID_INS_FUNCTION,
568 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
569 { &aRetItem, &aStrItem, &aMatItem });
570}
572{
574}
576{
577 if (m_pViewShell)
578 m_pViewShell->ClearFormEditData(); // pData is invalid!
579}
581{
582 m_pDoc = nullptr;
583
584 //restore reference inputhandler
585 ScModule* pScMod = SC_MOD();
586 pScMod->SetRefInputHdl(nullptr);
587
588 // force Enable() of edit line
589 ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
590 if ( pScViewShell )
591 pScViewShell->UpdateInputHandler();
592}
594{
595 // back to the document
596 // (foreign doc could be above - #34222#)
598 if ( pHdl )
599 {
600 pHdl->ViewShellGone(nullptr); // -> get active view
601 pHdl->ShowRefFrame();
602 }
603
604 // restore current chart (cause mouse-RefInput)
605 ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
606 if ( !pScViewShell )
607 return;
608
609 ScViewData& rVD=pScViewShell->GetViewData();
610 SCTAB nExecTab = m_CursorPos.Tab();
611 if ( nExecTab != rVD.GetTabNo() )
612 pScViewShell->SetTabNo( nExecTab );
613
614 SCROW nRow = m_CursorPos.Row();
615 SCCOL nCol = m_CursorPos.Col();
616
617 if(rVD.GetCurX()!=nCol || rVD.GetCurY()!=nRow)
618 pScViewShell->SetCursor(nCol,nRow);
619}
621{
622 ScTabViewShell* pViewShell = m_pViewShell;
623 if (pViewShell)
624 return pViewShell->GetFormEditData();
625 return nullptr;
626}
627void ScFormulaDlg::setCurrentFormula(const OUString& _sReplacement)
628{
629 ScModule* pScMod = SC_MOD();
630 {
631 //fdo#69971 We need the EditEngine Modification handler of the inputbar that we
632 //are feeding to be disabled while this dialog is open. Otherwise we end up in
633 //a situation where...
634 //a) this ScFormulaDlg changes the editengine
635 //b) the modify callback gets called
636 //c) which also modifies the editengine
637 //d) on return from that modify handler the editengine attempts to use
638 // old node pointers which were replaced and removed by c
639 //
640 //We turn it off in the ctor and back on in the dtor, but if calc has
641 //to repaint, e.g. when switching to another window and back, then in
642 //ScMultiTextWnd::Paint a new editengine will have been created via
643 //GetEditView with its default Modification handler enabled. So ensure
644 //its off when we will access it via InputReplaceSelection
645 pScMod->InputTurnOffWinEngine();
646 }
647 pScMod->InputReplaceSelection(_sReplacement);
648}
649void ScFormulaDlg::setSelection(sal_Int32 _nStart, sal_Int32 _nEnd)
650{
651 ScModule* pScMod = SC_MOD();
652 pScMod->InputSetSelection( _nStart, _nEnd );
653}
654void ScFormulaDlg::getSelection(sal_Int32& _nStart, sal_Int32& _nEnd) const
655{
656 ScModule* pScMod = SC_MOD();
657 pScMod->InputGetSelection( _nStart, _nEnd );
658}
660{
662 if (pData && pData->GetInputHandler())
663 return pData->GetInputHandler()->GetFormString();
664 return "";
665}
667{
669}
670uno::Reference< sheet::XFormulaParser> ScFormulaDlg::getFormulaParser() const
671{
672 return m_xParser;
673}
674uno::Reference< sheet::XFormulaOpCodeMapper> ScFormulaDlg::getFormulaOpCodeMapper() const
675{
676 return m_xOpCodeMapper;
677}
678
679table::CellAddress ScFormulaDlg::getReferencePosition() const
680{
681 return table::CellAddress(m_CursorPos.Tab(), m_CursorPos.Col(), m_CursorPos.Row());
682}
683
684::std::unique_ptr<formula::FormulaTokenArray> ScFormulaDlg::convertToTokenArray(const uno::Sequence< sheet::FormulaToken >& _aTokenList)
685{
686 ::std::unique_ptr<formula::FormulaTokenArray> pArray(new ScTokenArray(*m_pDoc));
687 pArray->Fill(_aTokenList, m_pDoc->GetSharedStringPool(), m_pDoc->GetExternalRefManager());
688 return pArray;
689}
690
691/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScRefFlags
Definition: address.hxx:158
Reference< XExecutableDialog > m_xDialog
const OUString & GetValue() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
Definition: documen3.cxx:633
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:1008
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1081
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:586
SC_DLLPUBLIC OUString GetFormula(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3757
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:461
virtual void deleteFormData() override
Definition: formula.cxx:575
ScTabViewShell * m_pViewShell
Definition: formula.hxx:44
virtual void notifyChange() override
Definition: formula.cxx:179
virtual void setDispatcherLock(bool bLock) override
Definition: formula.cxx:571
ScFormulaDlg(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, const ScViewData &rViewData, const formula::IFunctionManager *_pFunctionMgr)
Definition: formula.cxx:59
virtual css::uno::Reference< css::sheet::XFormulaOpCodeMapper > getFormulaOpCodeMapper() const override
Definition: formula.cxx:674
virtual css::uno::Reference< css::sheet::XFormulaParser > getFormulaParser() const override
Definition: formula.cxx:670
virtual ~ScFormulaDlg() COVERITY_NOEXCEPT_FALSE override
Definition: formula.cxx:233
virtual formula::FormEditData * getFormEditData() const override
Definition: formula.cxx:620
virtual void HideReference(bool bDoneRefMode=true) override
Definition: formula.cxx:524
virtual void fill() override
Definition: formula.cxx:186
virtual std::shared_ptr< formula::FormulaCompiler > getCompiler() const override
Definition: formula.cxx:361
virtual void insertEntryToLRUList(const formula::IFunctionDescription *pDesc) override
Definition: formula.cxx:511
virtual bool calculateValue(const OUString &_sExpression, OUString &_rResult, bool bMatrixFormula) override
Definition: formula.cxx:297
virtual void switchBack() override
Definition: formula.cxx:593
virtual void ReleaseFocus(formula::RefEdit *pEdit) override
Definition: formula.cxx:547
virtual formula::IFunctionManager * getFunctionManager() override
Definition: formula.cxx:666
virtual void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton=nullptr) override
Definition: formula.cxx:379
css::uno::Reference< css::sheet::XFormulaOpCodeMapper > m_xOpCodeMapper
Definition: formula.hxx:40
static void SaveLRUEntry(const ScFuncDesc *pFuncDesc)
Definition: formula.cxx:498
virtual void ToggleCollapsed(formula::RefEdit *pEdit, formula::RefButton *pButton) override
Definition: formula.cxx:542
virtual void getSelection(sal_Int32 &_nStart, sal_Int32 &_nEnd) const override
Definition: formula.cxx:654
virtual void ShowReference(const OUString &_sRef) override
Definition: formula.cxx:520
virtual void SetReference(const ScRange &rRef, ScDocument &rD) override
Definition: formula.cxx:393
virtual OUString getCurrentFormula() const override
Definition: formula.cxx:659
virtual void Close() override
Definition: formula.cxx:287
virtual void ViewShellChanged() override
Definition: formula.cxx:528
virtual void setCurrentFormula(const OUString &_sReplacement) override
Definition: formula.cxx:627
virtual bool IsDocAllowed(SfxObjectShell *pDocSh) const override
Definition: formula.cxx:481
virtual void dispatch(bool _bOK, bool _bMatrixChecked) override
Definition: formula.cxx:552
ScAddress m_CursorPos
Definition: formula.hxx:43
virtual void showReference(const OUString &_sFormula) override
Definition: formula.cxx:516
virtual bool IsRefInputMode() const override
Definition: formula.cxx:474
virtual css::table::CellAddress getReferencePosition() const override
Definition: formula.cxx:679
ScDocument * m_pDoc
Definition: formula.hxx:42
css::uno::Reference< css::sheet::XFormulaParser > m_xParser
Definition: formula.hxx:39
virtual void setSelection(sal_Int32 _nStart, sal_Int32 _nEnd) override
Definition: formula.cxx:649
static ScInputHandler * GetNextInputHandler(const ScDocShell *pDocShell, ScTabViewShell **ppViewSh)
Definition: formula.cxx:267
ScFormulaReferenceHelper m_aHelper
Definition: formula.hxx:38
virtual ::std::unique_ptr< formula::FormulaTokenArray > convertToTokenArray(const css::uno::Sequence< css::sheet::FormulaToken > &_aTokenList) override
Definition: formula.cxx:684
static bool IsInputHdl(const ScInputHandler *pHdl)
Definition: formula.cxx:249
virtual std::unique_ptr< formula::FormulaCompiler > createCompiler(formula::FormulaTokenArray &rArray) const override
Definition: formula.cxx:368
virtual void RefInputDone(bool bForced=false) override
Definition: formula.cxx:387
virtual void doClose(bool _bOk) override
Definition: formula.cxx:507
virtual void clear() override
Definition: formula.cxx:580
virtual void SetActive() override
Definition: formula.cxx:488
virtual void AddRefEntry() override
Definition: formula.cxx:532
virtual bool IsTableLocked() const override
Definition: formula.cxx:536
std::shared_ptr< ScCompiler > m_xCompiler
Definition: formula.hxx:45
void HideReference(bool bDoneRefMode=true)
Definition: anyrefdg.cxx:233
static void ViewShellChanged()
Definition: anyrefdg.cxx:500
static void enableInput(bool _bInput)
Definition: anyrefdg.cxx:78
void ToggleCollapsed(formula::RefEdit *pEdit, formula::RefButton *pButton)
Definition: anyrefdg.cxx:403
static void EnableSpreadsheets(bool bFlag=true)
Definition: anyrefdg.cxx:506
void SetDispatcherLock(bool bLock)
Definition: anyrefdg.cxx:460
void DoClose(sal_uInt16 nId)
Definition: anyrefdg.cxx:423
void SetDialog(weld::Dialog *pDialog)
Definition: anyrefdg.hxx:68
void RefInputStart(formula::RefEdit *pEdit, formula::RefButton *pButton)
Definition: anyrefdg.cxx:372
void ReleaseFocus(formula::RefEdit *pEdit)
Definition: anyrefdg.cxx:285
void ShowReference(const OUString &rStr)
Definition: anyrefdg.cxx:261
void RefInputDone(bool bForced)
Definition: anyrefdg.cxx:345
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
Definition: funcdesc.hxx:41
sal_uInt16 nFIndex
Unique function index.
Definition: funcdesc.hxx:221
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:559
static OUString GetErrorString(FormulaError nErrNumber)
Definition: global.cxx:315
static ScFunctionMgr * GetStarCalcFunctionMgr()
Definition: global.cxx:633
void ViewShellGone(const ScTabViewShell *pViewSh)
Definition: inputhdl.cxx:2224
void NotifyChange(const ScInputHdlState *pState, bool bForce=false, ScTabViewShell *pSourceSh=nullptr, bool bStopEditing=true)
Definition: inputhdl.cxx:4135
void SetRefViewShell(ScTabViewShell *pRefVsh)
Definition: inputhdl.hxx:218
const OUString & GetFormString() const
Definition: inputhdl.hxx:192
void InputGetSelection(sal_Int32 &rStart, sal_Int32 &rEnd)
Methods for FunctionAutoPilot: InputGetSelection, InputSetSelection, InputReplaceSelection,...
Definition: inputhdl.cxx:4501
void ShowRefFrame()
Definition: inputhdl.cxx:2840
void InputReplaceSelection(const OUString &rStr)
Definition: inputhdl.cxx:4553
void InputSetSelection(sal_Int32 nStart, sal_Int32 nEnd)
Definition: inputhdl.cxx:4533
void InputSetSelection(sal_Int32 nStart, sal_Int32 nEnd)
Definition: scmod.cxx:1458
void SetRefInputHdl(ScInputHandler *pNew)
Definition: scmod.cxx:1446
void InputReplaceSelection(const OUString &rStr)
Definition: scmod.cxx:1465
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
Definition: scmod.cxx:1352
void InputTurnOffWinEngine()
Definition: scmod.cxx:1472
void InputGetSelection(sal_Int32 &rStart, sal_Int32 &rEnd)
Definition: scmod.cxx:1451
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL, bool bBeforeSavingInLOK=false)
Definition: scmod.cxx:1408
void InsertEntryToLRUList(sal_uInt16 nFIndex)
Definition: scmod.cxx:729
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:2170
ScAddress aEnd
Definition: address.hxx:498
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:1700
ScAddress aStart
Definition: address.hxx:497
static css::uno::Reference< css::uno::XInterface > MakeInstance(Type nType, ScDocShell *pDocShell)
Definition: servuno.cxx:397
ScFormEditData * GetFormEditData()
Definition: tabvwsh.hxx:408
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:666
void ClearFormEditData()
Definition: tabvwshc.cxx:740
const ScInputHandler * GetInputHandler() const
Definition: tabvwsh.hxx:238
void InitFormEditData()
Definition: tabvwshc.cxx:735
ScViewData & GetViewData()
Definition: tabview.hxx:335
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:363
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1822
formula::FormulaToken * AddDoubleReference(const ScComplexRefData &rRef)
Definition: token.cxx:2282
formula::FormulaToken * AddSingleReference(const ScSingleRefData &rRef)
ScSingleRefToken with ocPush.
Definition: token.cxx:2272
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
SCROW GetCurY() const
Definition: viewdata.hxx:402
SCCOL GetCurX() const
Definition: viewdata.hxx:401
SfxDispatcher * GetDispatcher() const
void SetValue(bool const bTheValue)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
SfxViewFrame * GetFrame() const
const INetURLObject & GetURLObject() const
bool HasName() const
SfxMedium * GetMedium() const
SfxViewShell * GetViewShell() const
static SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SfxViewShell * Current()
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, const Color **ppColor, bool bUseStarFormat=false)
void CreateStringFromTokenArray(OUString &rFormula)
const FormulaHelper & GetFormulaHelper() const
void SetMeText(const OUString &_sText)
RefEdit * GetActiveEdit()
::std::pair< RefButton *, RefEdit * > RefInputStartBefore(RefEdit *pEdit, RefButton *pButton)
bool UpdateParaWin(Selection &_rSelection)
OUString GetMeText() const
bool CheckMatrix(OUString &aFormula)
const IFunctionDescription * getCurrentFunctionDescription() const
void StoreFormEditData(FormEditData *pData)
void RefInputDoneAfter(bool bForced)
virtual sal_Int32 getSuppressedArgumentCount() const=0
virtual SfxBindings & GetBindings() override
FormulaError
Mode eMode
void * p
sal_Int64 n
aBuf
std::unique_ptr< sal_Int32[]> pData
#define SCITEM_STRING
Definition: scitems.hxx:88
#define SC_MOD()
Definition: scmod.hxx:249
sal_uIntPtr sal_uLong
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
void InitRangeRel(const ScDocument &rDoc, const ScRange &rRange, const ScAddress &rPos)
Definition: refdata.hxx:135
ScSingleRefData Ref2
Definition: refdata.hxx:125
ScSingleRefData Ref1
Definition: refdata.hxx:124
void SetAbsCol(SCCOL nVal)
Definition: refdata.cxx:59
void SetAbsTab(SCTAB nVal)
Definition: refdata.cxx:93
void SetAbsRow(SCROW nVal)
Definition: refdata.cxx:76
void SetFlag3D(bool bVal)
Definition: refdata.hxx:89
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
#define SC_UNO_COMPILEFAP
Definition: unonames.hxx:681