summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-12-18 15:40:31 +0100
committerEike Rathke <erack@redhat.com>2015-12-18 15:43:45 +0100
commit9d1ee5a5b4730a6d3da4e8a02a08d1d27e9d27e4 (patch)
treeedf4a06b5c8bd65450f6356c3e502ce89988b5c2 /formula
parentb2e78fc73363d3ee43e3ee7bc90237d6d048aef7 (diff)
Resolves: tdf#96366 replace Edit...() calls with actually working code
... and way less overhead, geez.. Change-Id: Id9277301fbe69bc9a83ca39a907032b0b86b1c81
Diffstat (limited to 'formula')
-rw-r--r--formula/source/ui/dlg/formula.cxx55
1 files changed, 38 insertions, 17 deletions
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
index 3c1523cdfcc0..bb4f46d26f31 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -92,6 +92,8 @@ public:
bool EditNextFunc( bool bForward, sal_Int32 nFStart=NOT_FOUND );
void EditThisFunc(sal_Int32 nFStart);
+ OUString GetPrevFuncExpression( bool bStartFromEnd );
+
void StoreFormEditData(FormEditData* pEditData);
void Update();
@@ -206,6 +208,8 @@ public:
::std::vector< OUString > m_aArguments;
Selection aFuncSel;
+ sal_Int32 mnFuncExpStart; ///< current formula position for treeview results
+
FormulaDlg_Impl(Dialog* pParent
, bool _bSupportFunctionResult
, bool _bSupportResult
@@ -242,7 +246,8 @@ FormulaDlg_Impl::FormulaDlg_Impl(Dialog* pParent
bMakingTree (false),
nEdFocus (0),
pFuncDesc (nullptr),
- nArgs (0)
+ nArgs (0),
+ mnFuncExpStart (0)
{
pParent->get(m_pParaWinBox, "BOX");
pParent->get(m_pTabCtrl, "tabs");
@@ -695,31 +700,25 @@ void FormulaDlg_Impl::MakeTree(StructPage* _pTree,SvTreeListEntry* pParent,Formu
if (bCalcSubformula)
{
-/* FIXME: tdf#96366 this simply does not work, disable until solved. */
-#if 0
- OUString aStr;
- OUString aEquals(" = ");
+ OUString aFormula;
if (!bMakingTree)
- { // gets the last subformula result
+ {
+ // gets the last subformula result
bMakingTree = true;
- EditThisFunc(0);
- while ( EditNextFunc(true) ) {}
+ aFormula = GetPrevFuncExpression( true);
}
else
- { // gets subsequent subformula results (from the back)
- const IFunctionDescription* pDesc =pFuncPage->GetFuncDesc( pFuncPage->GetFunction() );
- if(pDesc==pFuncDesc || !pFuncPage->IsVisible())
- {
- EditNextFunc(false);
- }
+ {
+ // gets subsequent subformula results (from the back)
+ aFormula = GetPrevFuncExpression( false);
}
- if ( CalcValue( pFuncDesc->getFormula( m_aArguments ), aStr ) )
+ OUString aStr;
+ if (CalcValue( aFormula, aStr))
m_pWndResult->SetText( aStr );
aStr = m_pWndResult->GetText();
- pStructPage->GetTlbStruct()->SetEntryText(pEntry,aResult + aEquals + aStr);
-#endif
+ pStructPage->GetTlbStruct()->SetEntryText( pEntry, aResult + " = " + aStr);
}
--Count;
@@ -1200,6 +1199,28 @@ bool FormulaDlg_Impl::EditNextFunc( bool bForward, sal_Int32 nFStart )
return bFound;
}
+OUString FormulaDlg_Impl::GetPrevFuncExpression( bool bStartFromEnd )
+{
+ OUString aExpression;
+
+ OUString aFormula( m_pHelper->getCurrentFormula());
+ if (aFormula.isEmpty())
+ return aExpression;
+
+ if (bStartFromEnd || mnFuncExpStart >= aFormula.getLength())
+ mnFuncExpStart = aFormula.getLength() - 1;
+
+ sal_Int32 nFStart = mnFuncExpStart;
+ sal_Int32 nFEnd = 0;
+ if (m_aFormulaHelper.GetNextFunc( aFormula, true, nFStart, &nFEnd))
+ {
+ aExpression = aFormula.copy( nFStart, nFEnd - nFStart); // nFEnd is exclusive
+ mnFuncExpStart = nFStart;
+ }
+
+ return aExpression;
+}
+
void FormulaDlg_Impl::SaveArg( sal_uInt16 nEd )
{
if (nEd<nArgs)