summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-07-16 15:18:09 +0200
committerEike Rathke <erack@redhat.com>2017-07-16 15:18:42 +0200
commitbf1ffc64128f5b96d7c2fcc7adc81cbc25e232fd (patch)
treea6908df747fad0c6ef3c721130cf0aba115712cf /formula
parentb4cf899ce03fc29a0c8056126386ef41564d8ec6 (diff)
FormulaDlg_Impl::UpdateValues: evaluate in force-array context if present
Change-Id: I32488373bd22e644ee06920045008f3d9e20e985
Diffstat (limited to 'formula')
-rw-r--r--formula/source/ui/dlg/formula.cxx26
1 files changed, 22 insertions, 4 deletions
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 8742cc2184c7..d3a50fd6f0a5 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -561,11 +561,29 @@ bool FormulaDlg_Impl::CalcValue( const OUString& rStrExp, OUString& rStrResult,
void FormulaDlg_Impl::UpdateValues( bool bForceRecalcStruct )
{
- /* TODO: this must take array context of the outer
- * FormulaToken::IsInForceArray() into account. As is, this is just the
- * currently selected formula text part. */
+ // Take a force-array context into account. RPN creation propagated those
+ // to tokens that are ref-counted so also available in the token array.
+ bool bForceArray = false;
+ // Only necessary if it's not a matrix formula anyway.
+ if (!m_pBtnMatrix->IsChecked())
+ {
+ const sal_Int32 nPos = m_aFuncSel.Min();
+ assert( 0 <= nPos && nPos < m_pHelper->getCurrentFormula().getLength());
+ OUStringBuffer aBuf;
+ std::unique_ptr<FormulaCompiler> pCompiler( m_pHelper->createCompiler( *m_pTokenArray.get()));
+ const FormulaToken* pToken = nullptr;
+ for (pToken = m_pTokenArrayIterator->First(); pToken; pToken = m_pTokenArrayIterator->Next())
+ {
+ pCompiler->CreateStringFromToken( aBuf, pToken);
+ if (nPos < aBuf.getLength())
+ break;
+ }
+ if (pToken && nPos < aBuf.getLength())
+ bForceArray = pToken->IsInForceArray();
+ }
+
OUString aStrResult;
- if ( m_pFuncDesc && CalcValue( m_pFuncDesc->getFormula( m_aArguments ), aStrResult ) )
+ if (m_pFuncDesc && CalcValue( m_pFuncDesc->getFormula( m_aArguments), aStrResult, bForceArray))
m_pWndResult->SetText( aStrResult );
if (m_bMakingTree)