1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formula.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_formula.hxx"
34 //----------------------------------------------------------------------------
35 #include <sfx2/dispatch.hxx>
36 #include <sfx2/docfile.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <sfx2/topfrm.hxx>
39 #include <vcl/svapp.hxx>
40 #include <vcl/mnemonic.hxx>
41 #include <vcl/tabpage.hxx>
42 #include <vcl/tabctrl.hxx>
43 #include <vcl/lstbox.hxx>
44 #include <vcl/group.hxx>
45 #include <vcl/wall.hxx>
47 #include <svtools/stdctrl.hxx>
48 #include <svtools/svmedit.hxx>
49 #include <svtools/svtreebx.hxx>
50 #include <svtools/stritem.hxx>
51 #include <svtools/zforlist.hxx>
52 #include <svtools/eitem.hxx>
54 #include <unotools/charclass.hxx>
55 #include <tools/urlobj.hxx>
56 #include <tools/diagnose_ex.h>
58 #include "formdlgs.hrc"
59 #include "funcpage.hxx"
60 #include "formula/formula.hxx"
61 #include "formula/IFunctionDescription.hxx"
62 #include "formula/FormulaCompiler.hxx"
63 #include "formula/token.hxx"
64 #include "formula/tokenarray.hxx"
65 #include "formula/formdata.hxx"
66 #include "formula/formulahelper.hxx"
67 #include "structpg.hxx"
68 #include "parawin.hxx"
69 #include "ModuleHelper.hxx"
70 #include "ForResId.hrc"
71 #include <com/sun/star/sheet/FormulaToken.hpp>
72 #include <com/sun/star/sheet/FormulaLanguage.hpp>
73 #include <com/sun/star/sheet/FormulaMapGroup.hpp>
74 #include <com/sun/star/sheet/FormulaMapGroupSpecialOffset.hpp>
75 #include <com/sun/star/beans/XPropertySet.hpp>
76 #include <boost/bind.hpp>
77 #include <comphelper/processfactory.hxx>
85 using namespace ::com::sun::star
;
87 class OFormulaToken
: public IFormulaToken
89 sal_Int32 m_nParaCount
;
93 OFormulaToken(bool _bFunction
,sal_Int32 _nParaCount
) : m_nParaCount(_nParaCount
),m_bIsFunction(_bFunction
){}
95 virtual bool isFunction() const { return m_bIsFunction
; }
96 virtual sal_uInt32
getArgumentCount() const { return m_nParaCount
; }
100 class FormulaDlg_Impl
103 ::std::pair
<RefButton
*,RefEdit
*>
104 RefInputStartBefore( RefEdit
* pEdit
, RefButton
* pButton
);
105 void RefInputStartAfter( RefEdit
* pEdit
, RefButton
* pButton
);
106 void RefInputDoneAfter( BOOL bForced
);
107 BOOL
CalcValue( const String
& rStrExp
, String
& rStrResult
);
108 BOOL
CalcStruct( const String
& rStrExp
);
111 xub_StrLen
GetFunctionPos(xub_StrLen nPos
);
112 void ClearAllParas();
114 void MakeTree(IStructHelper
* _pTree
,SvLBoxEntry
* pParent
,FormulaToken
* _pToken
,long Count
);
115 void fillTree(IStructHelper
* _pTree
);
116 void UpdateTokenArray( const String
& rStrExp
);
117 String
RepairFormula(const String
& aFormula
);
118 void FillDialog(BOOL nFlag
=TRUE
);
119 void EditNextFunc( BOOL bForward
, xub_StrLen nFStart
=NOT_FOUND
);
120 void EditThisFunc(xub_StrLen nFStart
);
121 void EditFuncParas(xub_StrLen nEditPos
);
124 void UpdateArgInput( USHORT nOffset
, USHORT nInput
);
126 void Update(const String
& _sExp
);
129 void SaveArg( USHORT nEd
);
130 void UpdateSelection();
131 void DoEnter( BOOL bOk
);
132 void UpdateFunctionDesc();
133 void ResizeArgArr( const IFunctionDescription
* pNewFunc
);
134 void FillListboxes();
137 FormulaDlgMode
SetMeText(const String
& _sText
,xub_StrLen PrivStart
, xub_StrLen PrivEnd
,BOOL bMatrix
,BOOL _bSelect
,BOOL _bUpdate
);
138 void SetMeText(const String
& _sText
);
139 BOOL
CheckMatrix(String
& aFormula
/*IN/OUT*/);
141 void SetEdSelection();
143 BOOL
UpdateParaWin(Selection
& _rSelection
);
144 void UpdateParaWin(const Selection
& _rSelection
,const String
& _sRefStr
);
146 void SetData(xub_StrLen nFStart
,xub_StrLen nNextFStart
,xub_StrLen nNextFEnd
,xub_StrLen
& PrivStart
,xub_StrLen
& PrivEnd
);
147 void PreNotify( NotifyEvent
& rNEvt
);
149 RefEdit
* GetCurrRefEdit();
150 ULONG
FindFocusWin(Window
*pWin
);
152 const FormulaHelper
& GetFormulaHelper() const;
153 uno::Reference
< sheet::XFormulaOpCodeMapper
> GetFormulaOpCodeMapper() const;
155 DECL_LINK( ModifyHdl
, ParaWin
* );
156 DECL_LINK( FxHdl
, ParaWin
* );
158 DECL_LINK( MatrixHdl
, CheckBox
*);
159 DECL_LINK( FormulaHdl
, MultiLineEdit
* );
160 DECL_LINK( FormulaCursorHdl
, EditBox
*);
161 DECL_LINK( BtnHdl
, PushButton
* );
162 DECL_LINK( GetEdFocusHdl
, ArgInput
* );
163 DECL_LINK( GetFxFocusHdl
, ArgInput
* );
164 DECL_LINK( DblClkHdl
, FuncPage
* );
165 DECL_LINK( FuncSelHdl
, FuncPage
*);
166 DECL_LINK( StructSelHdl
, StructPage
* );
168 OModuleClient m_aModuleClient
;
169 mutable uno::Reference
< sheet::XFormulaOpCodeMapper
> m_xOpCodeMapper
;
170 uno::Sequence
< sheet::FormulaToken
> m_aTokenList
;
171 ::std::auto_ptr
<FormulaTokenArray
> m_pTokenArray
;
172 mutable uno::Sequence
< sheet::FormulaOpCodeMapEntry
> m_aSpecialOpCodes
;
173 mutable const sheet::FormulaOpCodeMapEntry
* m_pSpecialOpCodesEnd
;
174 mutable uno::Sequence
< sheet::FormulaToken
> m_aSeparatorsOpCodes
;
175 mutable uno::Sequence
< sheet::FormulaOpCodeMapEntry
> m_aFunctionOpCodes
;
176 mutable const sheet::FormulaOpCodeMapEntry
* m_pFunctionOpCodesEnd
;
177 mutable uno::Sequence
< sheet::FormulaOpCodeMapEntry
> m_aUnaryOpCodes
;
178 mutable const sheet::FormulaOpCodeMapEntry
* m_pUnaryOpCodesEnd
;
179 mutable uno::Sequence
< sheet::FormulaOpCodeMapEntry
> m_aBinaryOpCodes
;
180 mutable const sheet::FormulaOpCodeMapEntry
* m_pBinaryOpCodesEnd
;
181 ::std::vector
< ::boost::shared_ptr
<OFormulaToken
> > m_aTokens
;
182 ::std::map
<FormulaToken
*,sheet::FormulaToken
> m_aTokenMap
;
183 IFormulaEditorHelper
* m_pHelper
;
185 IControlReferenceHandler
* m_pDlg
;
187 GroupBox aGEdit
; //! MUST be placed before pParaWin for initializing
189 FixedText aFtHeadLine
;
190 FixedInfo aFtFuncName
;
191 FixedInfo aFtFuncDesc
;
193 FixedText aFtEditName
;
194 //FixedInfo aFtEditDesc;
199 FixedText aFtFormula
;
204 CancelButton aBtnCancel
;
206 PushButton aBtnBackward
;
207 PushButton aBtnForward
;
213 FixedText aFtFormResult
;
214 ValWnd aWndFormResult
;
216 RefEdit
* pTheRefEdit
;
217 RefButton
* pTheRefButton
;
219 StructPage
* pStructPage
;
222 MultiLineEdit
* pMEdit
;
223 BOOL bUserMatrixFlag
;
226 const String aTitle1
;
227 const String aTitle2
;
228 const String aTxtEnd
;
229 const String aTxtOk
; // hinter aBtnEnd
233 SmartId m_aSmartEditHelpId
;
245 // Selection theCurSel;
247 const IFunctionDescription
* pFuncDesc
;
249 ::std::vector
< ::rtl::OUString
> m_aArguments
;
252 FormulaDlg_Impl(Dialog
* pParent
253 , bool _bSupportFunctionResult
254 , bool _bSupportResult
255 , bool _bSupportMatrix
256 ,IFormulaEditorHelper
* _pHelper
257 ,const IFunctionManager
* _pFunctionMgr
258 ,IControlReferenceHandler
* _pDlg
);
262 FormulaDlg_Impl::FormulaDlg_Impl(Dialog
* pParent
263 , bool _bSupportFunctionResult
264 , bool _bSupportResult
265 , bool _bSupportMatrix
266 ,IFormulaEditorHelper
* _pHelper
267 ,const IFunctionManager
* _pFunctionMgr
268 ,IControlReferenceHandler
* _pDlg
)
270 m_pHelper (_pHelper
),
273 aTabCtrl ( pParent
, ModuleRes( TC_FUNCTION
) ),
274 aGEdit ( pParent
, ModuleRes( GB_EDIT
) ),
275 aFtHeadLine ( pParent
, ModuleRes( FT_HEADLINE
) ),
276 aFtFuncName ( pParent
, ModuleRes( FT_FUNCNAME
) ),
277 aFtFuncDesc ( pParent
, ModuleRes( FT_FUNCDESC
) ),
279 aFtEditName ( pParent
, ModuleRes( FT_EDITNAME
) ),
280 aFtResult ( pParent
, ModuleRes( FT_RESULT
) ),
281 aWndResult ( pParent
, ModuleRes( WND_RESULT
) ),
283 aFtFormula ( pParent
, ModuleRes( FT_FORMULA
) ),
284 aMEFormula ( pParent
, ModuleRes( ED_FORMULA
) ),
286 aBtnMatrix ( pParent
, ModuleRes( BTN_MATRIX
) ),
287 aBtnHelp ( pParent
, ModuleRes( BTN_HELP
) ),
288 aBtnCancel ( pParent
, ModuleRes( BTN_CANCEL
) ),
289 aBtnBackward ( pParent
, ModuleRes( BTN_BACKWARD
) ),
290 aBtnForward ( pParent
, ModuleRes( BTN_FORWARD
) ),
291 aBtnEnd ( pParent
, ModuleRes( BTN_END
) ),
292 aEdRef ( pParent
, _pDlg
, ModuleRes( ED_REF
) ),
293 aRefBtn ( pParent
, ModuleRes( RB_REF
),&aEdRef
,_pDlg
),
294 aFtFormResult ( pParent
, ModuleRes( FT_FORMULA_RESULT
)),
295 aWndFormResult ( pParent
, ModuleRes( WND_FORMULA_RESULT
)),
299 bUserMatrixFlag (FALSE
),
301 aTitle1 ( ModuleRes( STR_TITLE1
) ), // lokale Resource
302 aTitle2 ( ModuleRes( STR_TITLE2
) ), // lokale Resource
303 aTxtEnd ( ModuleRes( STR_END
) ), // lokale Resource
304 aTxtOk ( aBtnEnd
.GetText() ),
305 m_aFormulaHelper(_pFunctionMgr
),
313 pParaWin
= new ParaWin( pParent
,_pDlg
, aGEdit
.GetPosPixel());
320 pMEdit
= aMEFormula
.GetEdit();
321 m_aSmartEditHelpId
= pMEdit
->GetSmartHelpId();
322 pMEdit
->SetSmartUniqueId(m_aSmartEditHelpId
);
326 Point aPos
=aGEdit
.GetPosPixel();
327 pParaWin
->SetPosPixel(aPos
);
328 pParaWin
->SetArgModifiedHdl(LINK( this, FormulaDlg_Impl
, ModifyHdl
) );
329 pParaWin
->SetFxHdl(LINK( this, FormulaDlg_Impl
, FxHdl
) );
331 pFuncPage
= new FuncPage( &aTabCtrl
,_pFunctionMgr
);
332 pStructPage
= new StructPage( &aTabCtrl
);
335 aTabCtrl
.SetTabPage( TP_FUNCTION
, pFuncPage
);
336 aTabCtrl
.SetTabPage( TP_STRUCT
, pStructPage
);
338 nOldHelp
= pParent
->GetHelpId(); // HelpId aus Resource immer fuer "Seite 1"
339 nOldUnique
= pParent
->GetUniqueId();
341 aFtResult
.Show( _bSupportResult
);
342 aWndResult
.Show( _bSupportResult
);
344 aFtFormResult
.Show( _bSupportFunctionResult
);
345 aWndFormResult
.Show( _bSupportFunctionResult
);
347 if ( _bSupportMatrix
)
348 aBtnMatrix
.SetClickHdl(LINK( this, FormulaDlg_Impl
, MatrixHdl
) );
352 aBtnCancel
.SetClickHdl( LINK( this, FormulaDlg_Impl
, BtnHdl
) );
353 aBtnEnd
.SetClickHdl( LINK( this, FormulaDlg_Impl
, BtnHdl
) );
354 aBtnForward
.SetClickHdl( LINK( this, FormulaDlg_Impl
, BtnHdl
) );
355 aBtnBackward
.SetClickHdl( LINK( this, FormulaDlg_Impl
, BtnHdl
) );
357 pFuncPage
->SetDoubleClickHdl( LINK( this, FormulaDlg_Impl
, DblClkHdl
) );
358 pFuncPage
->SetSelectHdl( LINK( this, FormulaDlg_Impl
, FuncSelHdl
) );
359 pStructPage
->SetSelectionHdl( LINK( this, FormulaDlg_Impl
, StructSelHdl
) );
360 pMEdit
->SetModifyHdl( LINK( this, FormulaDlg_Impl
, FormulaHdl
) );
361 aMEFormula
.SetSelChangedHdl( LINK( this, FormulaDlg_Impl
, FormulaCursorHdl
) );
363 aFntLight
= aFtFormula
.GetFont();
364 aFntLight
.SetTransparent( TRUE
);
365 aFntBold
= aFntLight
;
366 aFntBold
.SetWeight( WEIGHT_BOLD
);
368 pParaWin
->SetArgumentFonts(aFntBold
,aFntLight
);
370 // function description for choosing a function is no longer in a different color
372 aFtHeadLine
.SetFont(aFntBold
);
373 aFtFuncName
.SetFont(aFntLight
);
374 aFtFuncDesc
.SetFont(aFntLight
);
376 FormulaDlg_Impl::~FormulaDlg_Impl()
378 if(aTimer
.IsActive())
380 aTimer
.SetTimeoutHdl(Link());
382 } // if(aTimer.IsActive())
383 bIsShutDown
=TRUE
;// Setzen, damit PreNotify keinen GetFocus speichert.
384 FormEditData
* pData
= m_pHelper
->getFormEditData();
385 if (pData
) // wird nicht ueber Close zerstoert;
387 pData
->SetFStart((xub_StrLen
)pMEdit
->GetSelection().Min());
388 pData
->SetSelection(pMEdit
->GetSelection());
390 if(aTabCtrl
.GetCurPageId()==TP_FUNCTION
)
391 pData
->SetMode( (USHORT
) FORMULA_FORMDLG_FORMULA
);
393 pData
->SetMode( (USHORT
) FORMULA_FORMDLG_EDIT
);
394 pData
->SetUndoStr(pMEdit
->GetText());
395 pData
->SetMatrixFlag(aBtnMatrix
.IsChecked());
398 aTabCtrl
.RemovePage(TP_FUNCTION
);
399 aTabCtrl
.RemovePage(TP_STRUCT
);
406 // -----------------------------------------------------------------------------
407 void FormulaDlg_Impl::PreNotify( NotifyEvent
& rNEvt
)
409 USHORT nSwitch
=rNEvt
.GetType();
410 if(nSwitch
==EVENT_GETFOCUS
&& !bIsShutDown
)
412 Window
* pWin
=rNEvt
.GetWindow();
415 nActivWinId
= pWin
->GetUniqueId();
418 Window
* pParent
=pWin
->GetParent();
421 nActivWinId
=pParent
->GetUniqueId();
423 if(nActivWinId
!=0) break;
425 pParent
=pParent
->GetParent();
431 FormEditData
* pData
= m_pHelper
->getFormEditData();
433 if (pData
&& !aTimer
.IsActive()) // wird nicht ueber Close zerstoert;
435 pData
->SetUniqueId(nActivWinId
);
441 uno::Reference
< sheet::XFormulaOpCodeMapper
> FormulaDlg_Impl::GetFormulaOpCodeMapper() const
443 if ( !m_xOpCodeMapper
.is() )
445 m_xOpCodeMapper
= m_pHelper
->getFormulaOpCodeMapper();
446 m_aFunctionOpCodes
= m_xOpCodeMapper
->getAvailableMappings(sheet::FormulaLanguage::ODFF
,sheet::FormulaMapGroup::FUNCTIONS
);
447 m_pFunctionOpCodesEnd
= m_aFunctionOpCodes
.getConstArray() + m_aFunctionOpCodes
.getLength();
449 m_aUnaryOpCodes
= m_xOpCodeMapper
->getAvailableMappings(sheet::FormulaLanguage::ODFF
,sheet::FormulaMapGroup::UNARY_OPERATORS
);
450 m_pUnaryOpCodesEnd
= m_aUnaryOpCodes
.getConstArray() + m_aUnaryOpCodes
.getLength();
452 m_aBinaryOpCodes
= m_xOpCodeMapper
->getAvailableMappings(sheet::FormulaLanguage::ODFF
,sheet::FormulaMapGroup::BINARY_OPERATORS
);
453 m_pBinaryOpCodesEnd
= m_aBinaryOpCodes
.getConstArray() + m_aBinaryOpCodes
.getLength();
455 uno::Sequence
< ::rtl::OUString
> aArgs(3);
456 aArgs
[TOKEN_OPEN
] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("("));
457 aArgs
[TOKEN_CLOSE
] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
458 aArgs
[TOKEN_SEP
] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
459 m_aSeparatorsOpCodes
= m_xOpCodeMapper
->getMappings(aArgs
,sheet::FormulaLanguage::ODFF
);
461 m_aSpecialOpCodes
= m_xOpCodeMapper
->getAvailableMappings(sheet::FormulaLanguage::ODFF
,sheet::FormulaMapGroup::SPECIAL
);
462 m_pSpecialOpCodesEnd
= m_aSpecialOpCodes
.getConstArray() + m_aSpecialOpCodes
.getLength();
463 } // if ( !m_xOpCodeMapper.is() )
464 return m_xOpCodeMapper
;
467 void FormulaDlg_Impl::DeleteArgs()
469 ::std::vector
< ::rtl::OUString
>().swap(m_aArguments
);
474 // comparing two property instances
475 struct OpCodeCompare
: public ::std::binary_function
< sheet::FormulaOpCodeMapEntry
, sal_Int32
, bool >
477 bool operator() (const sheet::FormulaOpCodeMapEntry
& x
, sal_Int32 y
) const
479 return x
.Token
.OpCode
== y
;
483 // -----------------------------------------------------------------------------
484 xub_StrLen
FormulaDlg_Impl::GetFunctionPos(xub_StrLen nPos
)
486 const sal_Unicode sep
= m_pHelper
->getFunctionManager()->getSingleToken(IFunctionManager::eSep
);
488 xub_StrLen nTokPos
=1;
489 xub_StrLen nOldTokPos
=1;
490 xub_StrLen nFuncPos
=STRING_NOTFOUND
; //@ Testweise
491 xub_StrLen nPrevFuncPos
=1;
492 short nBracketCount
=0;
494 String aFormString
= pMEdit
->GetText();
495 m_aFormulaHelper
.GetCharClass()->toUpper( aFormString
);
497 if ( m_aTokenList
.getLength() )
499 const uno::Reference
< sheet::XFormulaParser
> xParser(m_pHelper
->getFormulaParser());
501 const sheet::FormulaToken
* pIter
= m_aTokenList
.getConstArray();
502 const sheet::FormulaToken
* pEnd
= pIter
+ m_aTokenList
.getLength();
503 //if ( pIter != pEnd && aFormString.GetChar(0) == '=' )
507 while ( pIter
!= pEnd
)
509 const sal_Int32 eOp
= pIter
->OpCode
;
510 uno::Sequence
<sheet::FormulaToken
> aArgs(1);
512 const String aString
= xParser
->printFormula(aArgs
);
513 const sheet::FormulaToken
* pNextToken
= pIter
+ 1;
515 if(!bUserMatrixFlag
&& FormulaCompiler::IsMatrixFunction((OpCode
)eOp
) )
520 if ( eOp
== m_aSpecialOpCodes
[sheet::FormulaMapGroupSpecialOffset::PUSH
].Token
.OpCode
|| eOp
== m_aSpecialOpCodes
[sheet::FormulaMapGroupSpecialOffset::SPACES
].Token
.OpCode
)
522 const xub_StrLen n1
=aFormString
.Search(sep
, nTokPos
);
523 const xub_StrLen n2
=aFormString
.Search(')',nTokPos
);
524 xub_StrLen nXXX
=nTokPos
;
533 if ( pNextToken
!= pEnd
)
535 aArgs
[0] = *pNextToken
;
536 const String a2String
= xParser
->printFormula(aArgs
);
537 const xub_StrLen n3
= aFormString
.Search(a2String
,nXXX
);
544 nTokPos
= sal::static_int_cast
<xub_StrLen
>( nTokPos
+ aString
.Len() );
547 if ( eOp
== m_aSeparatorsOpCodes
[TOKEN_OPEN
].OpCode
)
552 else if ( eOp
== m_aSeparatorsOpCodes
[TOKEN_CLOSE
].OpCode
)
556 nFuncPos
=nPrevFuncPos
;
558 bool bIsFunction
= ::std::find_if(m_aFunctionOpCodes
.getConstArray(),m_pFunctionOpCodesEnd
,::std::bind2nd(OpCodeCompare(),boost::cref(eOp
))) != m_pFunctionOpCodesEnd
;
560 if ( bIsFunction
&& m_aSpecialOpCodes
[sheet::FormulaMapGroupSpecialOffset::SPACES
].Token
.OpCode
!= eOp
)
562 nPrevFuncPos
= nFuncPos
;
563 nFuncPos
= nOldTokPos
;
566 if ( nOldTokPos
<= nPos
&& nPos
< nTokPos
)
570 if ( nBracketCount
< 1 )
572 nFuncPos
= pMEdit
->GetText().Len();
576 nFuncPos
=nPrevFuncPos
;
583 nOldTokPos
= nTokPos
;
584 } // while ( pIter != pEnd )
586 catch(const uno::Exception
& )
588 DBG_ERROR("Exception caught!");
594 // -----------------------------------------------------------------------------
595 BOOL
FormulaDlg_Impl::CalcValue( const String
& rStrExp
, String
& rStrResult
)
599 if ( rStrExp
.Len() > 0 )
601 // nur, wenn keine Tastatureingabe mehr anliegt, den Wert berechnen:
603 if ( !Application::AnyInput( INPUT_KEYBOARD
) )
605 bResult
= m_pHelper
->calculateValue(rStrExp
,rStrResult
);
614 void FormulaDlg_Impl::UpdateValues()
618 if ( CalcValue( pFuncDesc
->getFormula( m_aArguments
), aStrResult
) )
619 aWndResult
.SetValue( aStrResult
);
622 if ( CalcValue(m_pHelper
->getCurrentFormula(), aStrResult
) )
623 aWndFormResult
.SetValue( aStrResult
);
627 aWndFormResult
.SetValue( aStrResult
);
629 CalcStruct(pMEdit
->GetText());
632 BOOL
FormulaDlg_Impl::CalcStruct( const String
& rStrExp
)
635 xub_StrLen nLength
=rStrExp
.Len();
637 if ( rStrExp
.Len() > 0 && aOldFormula
!=rStrExp
&& bStructUpdate
)
639 // nur, wenn keine Tastatureingabe mehr anliegt, den Wert berechnen:
641 if ( !Application::AnyInput( INPUT_KEYBOARD
) )
643 pStructPage
->ClearStruct();
645 String aString
=rStrExp
;
646 if(rStrExp
.GetChar(nLength
-1)=='(')
648 aString
.Erase((xub_StrLen
)(nLength
-1));
651 aString
.EraseAllChars('\n');
654 if ( CalcValue(aString
, aStrResult
) )
655 aWndFormResult
.SetValue( aStrResult
);
657 UpdateTokenArray(aString
);
658 fillTree(pStructPage
);
661 if(rStrExp
.GetChar(nLength
-1)=='(')
662 UpdateTokenArray(rStrExp
);
670 // -----------------------------------------------------------------------------
671 void FormulaDlg_Impl::MakeTree(IStructHelper
* _pTree
,SvLBoxEntry
* pParent
,FormulaToken
* _pToken
,long Count
)
673 if( _pToken
!= NULL
&& Count
> 0 )
675 long nParas
= _pToken
->GetParamCount();
676 OpCode eOp
= _pToken
->GetOpCode();
678 uno::Sequence
<sheet::FormulaToken
> aArgs(1);
679 aArgs
[0] = m_aTokenMap
.find(_pToken
)->second
;
682 const String aResult
= m_pHelper
->getFormulaParser()->printFormula(aArgs
);
688 String aTest
=_pTree
->GetEntryText(pParent
);
691 (eOp
==ocAdd
|| eOp
==ocMul
||
700 pEntry
=_pTree
->InsertEntry(aResult
,pParent
,STRUCT_ERROR
,0,_pToken
);
704 pEntry
=_pTree
->InsertEntry(aResult
,pParent
,STRUCT_FOLDER
,0,_pToken
);
708 MakeTree(_pTree
,pEntry
,m_pTokenArray
->PrevRPN(),nParas
);
710 m_pTokenArray
->NextRPN();
711 MakeTree(_pTree
,pParent
,m_pTokenArray
->PrevRPN(),Count
);
717 _pTree
->InsertEntry(aResult
,pParent
,STRUCT_ERROR
,0,_pToken
);
721 _pTree
->InsertEntry(aResult
,pParent
,STRUCT_END
,0,_pToken
);
724 MakeTree(_pTree
,pParent
,m_pTokenArray
->PrevRPN(),Count
);
727 catch(uno::Exception
&)
729 DBG_UNHANDLED_EXCEPTION();
734 void FormulaDlg_Impl::fillTree(IStructHelper
* _pTree
)
736 GetFormulaOpCodeMapper();
737 FormulaToken
* pToken
= m_pTokenArray
->LastRPN();
741 MakeTree(_pTree
,NULL
,pToken
,1);
744 void FormulaDlg_Impl::UpdateTokenArray( const String
& rStrExp
)
747 m_aTokenList
.realloc(0);
750 m_aTokenList
= m_pHelper
->getFormulaParser()->parseFormula(rStrExp
);
752 catch(const uno::Exception
&)
754 DBG_UNHANDLED_EXCEPTION();
756 GetFormulaOpCodeMapper(); // just to get it initialized
757 m_pTokenArray
= m_pHelper
->convertToTokenArray(m_aTokenList
);
758 const sal_Int32 nLen
= static_cast<sal_Int32
>(m_pTokenArray
->GetLen());
759 FormulaToken
** pTokens
= m_pTokenArray
->GetArray();
760 if ( pTokens
&& nLen
== m_aTokenList
.getLength() )
762 for (sal_Int32 nPos
=0; nPos
<nLen
; nPos
++)
764 m_aTokenMap
.insert(::std::map
<FormulaToken
*,sheet::FormulaToken
>::value_type(pTokens
[nPos
],m_aTokenList
[nPos
]));
766 } // if ( pTokens && nLen == m_aTokenList.getLength() )
768 FormulaCompiler
aCompiler(*m_pTokenArray
.get());
769 aCompiler
.CompileTokenArray();
772 void FormulaDlg_Impl::FillDialog(BOOL nFlag
)
780 if ( CalcValue(m_pHelper
->getCurrentFormula(), aStrResult
) )
781 aWndFormResult
.SetValue( aStrResult
);
785 aWndFormResult
.SetValue( aStrResult
);
789 // -----------------------------------------------------------------------------
790 void FormulaDlg_Impl::FillListboxes()
792 // Umschalten zwischen den "Seiten"
793 FormEditData
* pData
= m_pHelper
->getFormEditData();
795 // 1. Seite: Funktion auswaehlen
796 if ( pFuncDesc
&& pFuncDesc
->getCategory() )
798 if( pFuncPage
->GetCategory() != pFuncDesc
->getCategory()->getNumber() + 1 )
799 pFuncPage
->SetCategory(static_cast<USHORT
>(pFuncDesc
->getCategory()->getNumber() + 1));
801 USHORT nPos
=pFuncPage
->GetFuncPos(pFuncDesc
);
803 pFuncPage
->SetFunction(nPos
);
807 pFuncPage
->SetCategory( pData
->GetCatSel() );
808 pFuncPage
->SetFunction( pData
->GetFuncSel() );
812 // ResizeArgArr jetzt schon in UpdateFunctionDesc
815 m_pHelper
->setDispatcherLock( TRUE
);// Modal-Modus einschalten
819 // HelpId fuer 1. Seite ist die aus der Resource
820 m_pParent
->SetHelpId( nOldHelp
);
821 m_pParent
->SetUniqueId( nOldUnique
);
823 // -----------------------------------------------------------------------------
824 void FormulaDlg_Impl::FillControls()
826 // Umschalten zwischen den "Seiten"
827 FormEditData
* pData
= m_pHelper
->getFormEditData();
832 // 2. Seite oder Editieren: ausgewaehlte Funktion anzeigen
834 xub_StrLen nFStart
= pData
->GetFStart();
835 String aFormula
= m_pHelper
->getCurrentFormula();
836 xub_StrLen nNextFStart
= nFStart
;
837 xub_StrLen nNextFEnd
= 0;
839 aFormula
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " )" ));
841 const IFunctionDescription
* pOldFuncDesc
= pFuncDesc
;
842 BOOL bTestFlag
= FALSE
;
844 if ( m_aFormulaHelper
.GetNextFunc( aFormula
, FALSE
,
845 nNextFStart
, &nNextFEnd
, &pFuncDesc
, &m_aArguments
) )
847 bTestFlag
= (pOldFuncDesc
!= pFuncDesc
);
853 pParaWin
->SetFunctionDesc(pFuncDesc
);
854 aFtEditName
.SetText( pFuncDesc
->getFunctionName() );
857 const long nHelpId
= pFuncDesc
->getHelpId();
859 pMEdit
->SetSmartHelpId(SmartId(nHelpId
));
862 xub_StrLen nOldStart
, nOldEnd
;
863 m_pHelper
->getSelection( nOldStart
, nOldEnd
);
864 if ( nOldStart
!= nNextFStart
|| nOldEnd
!= nNextFEnd
)
866 m_pHelper
->setSelection( nNextFStart
, nNextFEnd
);
868 aFuncSel
.Min() = nNextFStart
;
869 aFuncSel
.Max() = nNextFEnd
;
872 pMEdit
->SetText(m_pHelper
->getCurrentFormula());
873 xub_StrLen PrivStart
, PrivEnd
;
874 m_pHelper
->getSelection( PrivStart
, PrivEnd
);
876 pMEdit
->SetSelection( Selection(PrivStart
, PrivEnd
));
878 nArgs
= pFuncDesc
->getSuppressedArgumentCount();
879 USHORT nOffset
= pData
->GetOffset();
880 nEdFocus
= pData
->GetEdFocus();
882 // Verkettung der Edit's fuer Focus-Kontrolle
885 pParaWin
->SetArgumentOffset(nOffset
);
887 xub_StrLen nArgPos
= m_aFormulaHelper
.GetArgStart( aFormula
, nFStart
, 0 );
888 xub_StrLen nEditPos
=(xub_StrLen
) pMEdit
->GetSelection().Min();
891 for(USHORT i
=0;i
<nArgs
;i
++)
893 sal_Int32 nLength
= m_aArguments
[i
].getLength()+1;
894 pParaWin
->SetArgument(i
,m_aArguments
[i
]);
895 if(nArgPos
<=nEditPos
&& nEditPos
<nArgPos
+nLength
)
900 nArgPos
= sal::static_int_cast
<xub_StrLen
>( nArgPos
+ nLength
);
902 pParaWin
->UpdateParas();
906 pParaWin
->SetActiveLine(nActiv
);
909 //pParaWin->SetEdFocus( nEdFocus );
914 aFtEditName
.SetText(String());
915 pMEdit
->SetSmartHelpId(m_aSmartEditHelpId
);
917 // Test, ob vorne/hinten noch mehr Funktionen sind
919 xub_StrLen nTempStart
= m_aFormulaHelper
.GetArgStart( aFormula
, nFStart
, 0 );
920 BOOL bNext
= m_aFormulaHelper
.GetNextFunc( aFormula
, FALSE
, nTempStart
);
921 nTempStart
=(xub_StrLen
)pMEdit
->GetSelection().Min();
922 pData
->SetFStart(nTempStart
);
923 BOOL bPrev
= m_aFormulaHelper
.GetNextFunc( aFormula
, TRUE
, nTempStart
);
924 aBtnBackward
.Enable(bPrev
);
925 aBtnForward
.Enable(bNext
);
927 // -----------------------------------------------------------------------------
929 void FormulaDlg_Impl::ClearAllParas()
933 pParaWin
->ClearAll();
934 aWndResult
.SetValue(String());
935 aFtFuncName
.SetText(String());
938 if(pFuncPage
->IsVisible())
943 aBtnForward
.Enable(TRUE
); //@new
949 String
FormulaDlg_Impl::RepairFormula(const String
& aFormula
)
954 UpdateTokenArray(aFormula
);
956 if ( m_aTokenList
.getLength() )
958 const String
sFormula(m_pHelper
->getFormulaParser()->printFormula(m_aTokenList
));
959 if ( !sFormula
.Len() || sFormula
.GetChar(0) != '=' )
966 catch(const uno::Exception
& )
968 DBG_ERROR("Exception caught!");
973 void FormulaDlg_Impl::DoEnter(BOOL bOk
)
975 // Eingabe ins Dokument uebernehmen oder abbrechen
978 // ggf. Dummy-Argumente entfernen
979 String aInputFormula
= m_pHelper
->getCurrentFormula();
980 String aString
= RepairFormula(pMEdit
->GetText());
981 m_pHelper
->setSelection(0, aInputFormula
.Len());
982 m_pHelper
->setCurrentFormula(aString
);
985 m_pHelper
->switchBack();
987 m_pHelper
->dispatch(bOk
,aBtnMatrix
.IsChecked());
989 m_pHelper
->deleteFormData();
992 m_pHelper
->doClose(bOk
);
994 // -----------------------------------------------------------------------------
996 IMPL_LINK( FormulaDlg_Impl
, BtnHdl
, PushButton
*, pBtn
)
998 if ( pBtn
== &aBtnCancel
)
1000 DoEnter(FALSE
); // schliesst den Dialog
1002 else if ( pBtn
== &aBtnEnd
)
1004 DoEnter(TRUE
); // schliesst den Dialog
1006 else if ( pBtn
== &aBtnForward
)
1008 //@pMEdit->GrabFocus(); // Damit die Selektion auch angezeigt wird.
1009 const IFunctionDescription
* pDesc
=pFuncPage
->GetFuncDesc( pFuncPage
->GetFunction() );
1011 if(pDesc
==pFuncDesc
|| !pFuncPage
->IsVisible())
1012 EditNextFunc( TRUE
);
1015 DblClkHdl(pFuncPage
); //new
1016 aBtnForward
.Enable(FALSE
); //new
1018 //@EditNextFunc( TRUE );
1020 else if ( pBtn
== &aBtnBackward
)
1023 aBtnForward
.Enable(TRUE
);
1024 EditNextFunc( FALSE
);
1025 aMEFormula
.Invalidate();
1026 aMEFormula
.Update();
1032 // -----------------------------------------------------------------------------
1035 // --------------------------------------------------------------------------
1036 // Funktionen fuer 1. Seite
1037 // --------------------------------------------------------------------------
1039 void FormulaDlg_Impl::ResizeArgArr( const IFunctionDescription
* pNewFunc
)
1041 if ( pFuncDesc
!= pNewFunc
)
1046 nArgs
= pNewFunc
->getSuppressedArgumentCount();
1048 pFuncDesc
= pNewFunc
;
1051 // -----------------------------------------------------------------------------
1053 void FormulaDlg_Impl::UpdateFunctionDesc()
1055 FormEditData
* pData
= m_pHelper
->getFormEditData();
1058 USHORT nCat
= pFuncPage
->GetCategory();
1059 if ( nCat
== LISTBOX_ENTRY_NOTFOUND
)
1061 pData
->SetCatSel( nCat
);
1062 USHORT nFunc
= pFuncPage
->GetFunction();
1063 if ( nFunc
== LISTBOX_ENTRY_NOTFOUND
)
1065 pData
->SetFuncSel( nFunc
);
1067 if ( (pFuncPage
->GetFunctionEntryCount() > 0)
1068 && (pFuncPage
->GetFunction() != LISTBOX_ENTRY_NOTFOUND
) )
1070 const IFunctionDescription
* pDesc
= pFuncPage
->GetFuncDesc(pFuncPage
->GetFunction() );
1073 pDesc
->initArgumentInfo(); // full argument info is needed
1075 String aSig
= pDesc
->getSignature();
1077 aFtFuncName
.SetText( aSig
);
1078 aFtFuncDesc
.SetText( pDesc
->getDescription() );
1079 ResizeArgArr( pDesc
);
1081 if ( !m_aArguments
.empty() ) // noch Argumente da?
1082 aSig
= pDesc
->getFormula( m_aArguments
); // fuer Eingabezeile
1083 //@ m_pHelper->setCurrentFormula( aSig );
1088 aFtFuncName
.SetText( String() );
1089 aFtFuncDesc
.SetText( String() );
1091 //ResizeArgArr( NULL );
1092 m_pHelper
->setCurrentFormula( String() );
1095 // -----------------------------------------------------------------------------
1097 // Handler fuer Listboxen
1099 IMPL_LINK( FormulaDlg_Impl
, DblClkHdl
, FuncPage
*, EMPTYARG
)
1101 USHORT nFunc
= pFuncPage
->GetFunction();
1104 const IFunctionDescription
* pDesc
= pFuncPage
->GetFuncDesc(nFunc
);
1105 m_pHelper
->insertEntryToLRUList(pDesc
);
1107 String aFuncName
= pFuncPage
->GetSelFunctionName();
1108 aFuncName
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
1109 m_pHelper
->setCurrentFormula(aFuncName
);
1110 pMEdit
->ReplaceSelected(aFuncName
);
1112 Selection aSel
=pMEdit
->GetSelection();
1113 aSel
.Max()=aSel
.Max()-1;
1114 pMEdit
->SetSelection(aSel
);
1118 aSel
.Min()=aSel
.Max();
1119 pMEdit
->SetSelection(aSel
);
1123 BtnHdl(&aBtnBackward
);
1126 pParaWin
->SetEdFocus(0);
1127 aBtnForward
.Enable(FALSE
); //@New
1131 // -----------------------------------------------------------------------------
1133 // --------------------------------------------------------------------------
1134 // Funktionen fuer rechte Seite
1135 // --------------------------------------------------------------------------
1136 void FormulaDlg_Impl::SetData(xub_StrLen nFStart
,xub_StrLen nNextFStart
,xub_StrLen nNextFEnd
,xub_StrLen
& PrivStart
,xub_StrLen
& PrivEnd
)
1140 // Selektion merken und neue setzen
1141 m_pHelper
->getSelection( nFStart
, nFEnd
);
1142 m_pHelper
->setSelection( nNextFStart
, nNextFEnd
);
1144 pMEdit
->SetText(m_pHelper
->getCurrentFormula());
1147 m_pHelper
->getSelection( PrivStart
, PrivEnd
);
1150 pMEdit
->SetSelection( Selection(PrivStart
, PrivEnd
));
1151 aMEFormula
.UpdateOldSel();
1154 FormEditData
* pData
= m_pHelper
->getFormEditData();
1155 pData
->SetFStart( nNextFStart
);
1156 pData
->SetOffset( 0 );
1157 pData
->SetEdFocus( 0 );
1161 // -----------------------------------------------------------------------------
1162 void FormulaDlg_Impl::EditThisFunc(xub_StrLen nFStart
)
1164 FormEditData
* pData
= m_pHelper
->getFormEditData();
1167 String aFormula
= m_pHelper
->getCurrentFormula();
1169 if(nFStart
==NOT_FOUND
)
1171 nFStart
= pData
->GetFStart();
1175 pData
->SetFStart(nFStart
);
1178 xub_StrLen nNextFStart
= nFStart
;
1179 xub_StrLen nNextFEnd
= 0;
1183 //@bFound = m_pHelper->getNextFunction( aFormula, FALSE, nNextFStart, &nNextFEnd, &pFuncDesc );
1185 bFound
= m_aFormulaHelper
.GetNextFunc( aFormula
, FALSE
, nNextFStart
, &nNextFEnd
);
1188 xub_StrLen PrivStart
, PrivEnd
;
1189 SetData(nFStart
,nNextFStart
,nNextFEnd
,PrivStart
, PrivEnd
);
1190 m_pHelper
->showReference(aFormula
.Copy(PrivStart
, PrivEnd
-PrivStart
));
1198 void FormulaDlg_Impl::EditNextFunc( BOOL bForward
, xub_StrLen nFStart
)
1200 FormEditData
* pData
= m_pHelper
->getFormEditData();
1204 String aFormula
= m_pHelper
->getCurrentFormula();
1206 if(nFStart
==NOT_FOUND
)
1208 nFStart
= pData
->GetFStart();
1212 pData
->SetFStart(nFStart
);
1215 xub_StrLen nNextFStart
= 0;
1216 xub_StrLen nNextFEnd
= 0;
1221 nNextFStart
= m_aFormulaHelper
.GetArgStart( aFormula
, nFStart
, 0 );
1222 //@bFound = m_pHelper->getNextFunction( aFormula, FALSE, nNextFStart, &nNextFEnd, &pFuncDesc );
1223 bFound
= m_aFormulaHelper
.GetNextFunc( aFormula
, FALSE
, nNextFStart
, &nNextFEnd
);
1227 nNextFStart
= nFStart
;
1228 //@bFound = m_pHelper->getNextFunction( aFormula, TRUE, nNextFStart, &nNextFEnd, &pFuncDesc );
1229 bFound
= m_aFormulaHelper
.GetNextFunc( aFormula
, TRUE
, nNextFStart
, &nNextFEnd
);
1234 xub_StrLen PrivStart
, PrivEnd
;
1235 SetData(nFStart
,nNextFStart
,nNextFEnd
,PrivStart
, PrivEnd
);
1239 void FormulaDlg_Impl::EditFuncParas(xub_StrLen nEditPos
)
1243 FormEditData
* pData
= m_pHelper
->getFormEditData();
1246 String aFormula
= m_pHelper
->getCurrentFormula();
1248 xub_StrLen nFStart
= pData
->GetFStart();
1252 nArgs
= pFuncDesc
->getSuppressedArgumentCount();
1254 sal_Int32 nArgPos
=m_aFormulaHelper
.GetArgStart( aFormula
, nFStart
, 0 );
1255 m_aFormulaHelper
.GetArgStrings(m_aArguments
,aFormula
, nFStart
, nArgs
);
1256 // m_aArguments = ScFormulaUtil::GetArgStrings( aFormula, nFStart, nArgs );
1258 USHORT nActiv
=pParaWin
->GetSliderPos();
1260 ::std::vector
< ::rtl::OUString
>::iterator aIter
= m_aArguments
.begin();
1261 ::std::vector
< ::rtl::OUString
>::iterator aEnd
= m_aArguments
.end();
1262 for(USHORT i
=0;aIter
!= aEnd
;i
++,++aIter
)
1264 sal_Int32 nLength
=(*aIter
).getLength();
1265 pParaWin
->SetArgument(i
,(*aIter
));
1266 if(nArgPos
<=nEditPos
&& nEditPos
<nArgPos
+nLength
)
1276 pParaWin
->SetSliderPos(nActiv
);
1279 pParaWin
->UpdateParas();
1285 void FormulaDlg_Impl::SaveArg( USHORT nEd
)
1292 if ( m_aArguments
[i
].getLength() == 0 )
1293 m_aArguments
[i
] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
1295 if(pParaWin
->GetArgument(nEd
).Len()!=0)
1296 m_aArguments
[nEd
] = pParaWin
->GetArgument(nEd
);
1298 USHORT nClearPos
=nEd
+1;
1299 for(i
=nEd
+1;i
<nArgs
;i
++)
1301 if(pParaWin
->GetArgument(i
).Len()!=0)
1307 for(i
=nClearPos
;i
<nArgs
;i
++)
1309 m_aArguments
[i
] = ::rtl::OUString();
1314 IMPL_LINK( FormulaDlg_Impl
, FxHdl
, ParaWin
*, pPtr
)
1318 aBtnForward
.Enable(TRUE
); //@ Damit eine neue Fkt eingegeben werden kann.
1319 aTabCtrl
.SetCurPageId(TP_FUNCTION
);
1321 String aUndoStr
= m_pHelper
->getCurrentFormula(); // bevor unten ein ";" eingefuegt wird
1322 FormEditData
* pData
= m_pHelper
->getFormEditData();
1323 if (!pData
) return 0;
1325 USHORT nArgNo
= pParaWin
->GetActiveLine();
1331 xub_StrLen nFormulaStrPos
= pData
->GetFStart();
1333 String aFormula
= m_pHelper
->getCurrentFormula();
1334 xub_StrLen n1
= m_aFormulaHelper
.GetArgStart( aFormula
, nFormulaStrPos
, nEdFocus
+pData
->GetOffset() );
1336 pData
->SetEdFocus( nEdFocus
);
1337 pData
->SaveValues();
1338 pData
->SetMode( (USHORT
) FORMULA_FORMDLG_FORMULA
);
1339 pData
->SetFStart( n1
);
1340 pData
->SetUndoStr( aUndoStr
);
1344 pFuncPage
->SetFocus(); //Da Parawin nicht mehr sichtbar
1349 IMPL_LINK( FormulaDlg_Impl
, ModifyHdl
, ParaWin
*, pPtr
)
1353 SaveArg(pParaWin
->GetActiveLine());
1357 CalcStruct(pMEdit
->GetText());
1362 IMPL_LINK( FormulaDlg_Impl
, FormulaHdl
, MultiLineEdit
*, EMPTYARG
)
1365 FormEditData
* pData
= m_pHelper
->getFormEditData();
1366 if (!pData
) return 0;
1369 String aInputFormula
=m_pHelper
->getCurrentFormula();
1370 String aString
=pMEdit
->GetText();
1372 Selection aSel
=pMEdit
->GetSelection();
1375 if(aString
.Len()==0) //falls alles geloescht wurde
1378 pMEdit
->SetText(aString
);
1381 pMEdit
->SetSelection(aSel
);
1383 else if(aString
.GetChar(nTest
)!='=') //falls ersetzt wurde;
1385 aString
.Insert( (sal_Unicode
)'=', 0 );
1386 pMEdit
->SetText(aString
);
1389 pMEdit
->SetSelection(aSel
);
1393 m_pHelper
->setSelection(0, aInputFormula
.Len());
1394 m_pHelper
->setCurrentFormula(aString
);
1395 m_pHelper
->setSelection((xub_StrLen
)aSel
.Min(),(xub_StrLen
)aSel
.Max());
1397 xub_StrLen nPos
=(xub_StrLen
)aSel
.Min()-1;
1401 if ( CalcValue(m_pHelper
->getCurrentFormula(), aStrResult
) )
1402 aWndFormResult
.SetValue( aStrResult
);
1406 aWndFormResult
.SetValue( aStrResult
);
1408 CalcStruct(aString
);
1410 nPos
=GetFunctionPos(nPos
);
1412 if(nPos
<aSel
.Min()-1)
1414 xub_StrLen nPos1
=aString
.Search('(',nPos
);
1415 EditNextFunc( FALSE
, nPos1
);
1422 m_pHelper
->setSelection((xub_StrLen
)aSel
.Min(),(xub_StrLen
)aSel
.Max());
1427 IMPL_LINK( FormulaDlg_Impl
, FormulaCursorHdl
, EditBox
*, EMPTYARG
)
1429 FormEditData
* pData
= m_pHelper
->getFormEditData();
1430 if (!pData
) return 0;
1431 xub_StrLen nFStart
= pData
->GetFStart();
1435 String aInputFormula
=m_pHelper
->getCurrentFormula();
1436 String aString
=pMEdit
->GetText();
1438 Selection aSel
=pMEdit
->GetSelection();
1439 m_pHelper
->setSelection((xub_StrLen
)aSel
.Min(),(xub_StrLen
)aSel
.Max());
1444 pMEdit
->SetSelection(aSel
);
1447 if(aSel
.Min()!=aString
.Len())
1449 xub_StrLen nPos
=(xub_StrLen
)aSel
.Min();
1451 nFStart
=GetFunctionPos(nPos
- 1);
1455 xub_StrLen nPos1
=m_aFormulaHelper
.GetFunctionEnd(aString
,nFStart
);
1457 if(nPos1
>nPos
|| nPos1
==STRING_NOTFOUND
)
1459 EditThisFunc(nFStart
);
1467 if(aString
.GetChar(n
)==')')
1469 else if(aString
.GetChar(n
)=='(')
1471 if(nCount
==0) break;
1476 nFStart
=m_aFormulaHelper
.GetFunctionStart(aString
,n
,TRUE
);
1477 EditThisFunc(nFStart
);
1490 m_pHelper
->setSelection((xub_StrLen
)aSel
.Min(),(xub_StrLen
)aSel
.Max());
1496 void FormulaDlg_Impl::UpdateSelection()
1498 m_pHelper
->setSelection((xub_StrLen
)aFuncSel
.Min(),(xub_StrLen
)aFuncSel
.Max());
1499 m_pHelper
->setCurrentFormula( pFuncDesc
->getFormula( m_aArguments
) );
1500 pMEdit
->SetText(m_pHelper
->getCurrentFormula());
1501 xub_StrLen PrivStart
, PrivEnd
;
1502 m_pHelper
->getSelection( PrivStart
, PrivEnd
);
1503 aFuncSel
.Min()=PrivStart
;
1504 aFuncSel
.Max()=PrivEnd
;
1506 nArgs
= pFuncDesc
->getSuppressedArgumentCount();
1508 String aFormula
=pMEdit
->GetText();
1509 sal_Int32 nArgPos
=m_aFormulaHelper
.GetArgStart( aFormula
,PrivStart
,0);
1511 USHORT nPos
=pParaWin
->GetActiveLine();
1513 for(USHORT i
=0;i
<nPos
;i
++)
1515 nArgPos
+= (m_aArguments
[i
].getLength() + 1);
1517 sal_Int32 nLength
= m_aArguments
[nPos
].getLength();
1519 Selection
aSel(nArgPos
,nArgPos
+nLength
);
1520 m_pHelper
->setSelection((USHORT
)nArgPos
,(USHORT
)(nArgPos
+nLength
));
1521 pMEdit
->SetSelection(aSel
);
1522 aMEFormula
.UpdateOldSel();
1524 ::std::pair
<RefButton
*,RefEdit
*> FormulaDlg_Impl::RefInputStartBefore( RefEdit
* pEdit
, RefButton
* pButton
)
1527 pTheRefEdit
= pEdit
;
1528 pTheRefButton
= pButton
;
1532 aEdRef
.SetRefString( pTheRefEdit
->GetText() );
1533 aEdRef
.SetSelection( pTheRefEdit
->GetSelection() );
1534 aEdRef
.SetHelpId( pTheRefEdit
->GetHelpId() );
1535 aEdRef
.SetUniqueId( pTheRefEdit
->GetUniqueId() );
1538 aRefBtn
.Show( pButton
!= NULL
);
1540 //m_pHelper->RefInputStart( &aEdRef, pButton ? &aRefBtn : NULL );
1541 ::std::pair
<RefButton
*,RefEdit
*> aPair
;
1542 aPair
.first
= pButton
? &aRefBtn
: NULL
;
1543 aPair
.second
= &aEdRef
;
1546 void FormulaDlg_Impl::RefInputStartAfter( RefEdit
* /*pEdit*/, RefButton
* /*pButton*/ )
1548 aRefBtn
.SetEndImage();
1552 String aStr
= aTitle2
;
1554 aStr
+= aFtEditName
.GetText();
1555 aStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "( " ) );
1556 if( pParaWin
->GetActiveLine() > 0 )
1557 aStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "...; " ) );
1558 aStr
+= pParaWin
->GetActiveArgName();
1559 if( pParaWin
->GetActiveLine() + 1 < nArgs
)
1560 aStr
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "; ..." ));
1561 aStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " )" ) );
1563 m_pParent
->SetText( MnemonicGenerator::EraseAllMnemonicChars( aStr
) );
1566 void FormulaDlg_Impl::RefInputDoneAfter( BOOL bForced
)
1568 aRefBtn
.SetStartImage();
1569 if( bForced
|| !aRefBtn
.IsVisible() )
1575 pTheRefEdit
->SetRefString( aEdRef
.GetText() );
1576 pTheRefEdit
->GrabFocus();
1579 pTheRefButton
->SetStartImage();
1581 USHORT nPrivActiv
= pParaWin
->GetActiveLine();
1582 pParaWin
->SetArgument( nPrivActiv
, aEdRef
.GetText() );
1583 ModifyHdl( pParaWin
);
1586 m_pParent
->SetText( aTitle1
);
1589 RefEdit
* FormulaDlg_Impl::GetCurrRefEdit()
1591 return aEdRef
.IsVisible() ? &aEdRef
: pParaWin
->GetActiveEdit();
1593 void FormulaDlg_Impl::Update()
1595 FormEditData
* pData
= m_pHelper
->getFormEditData();
1596 const String sExpression
= pMEdit
->GetText();
1597 UpdateTokenArray(sExpression
);
1598 FormulaCursorHdl(&aMEFormula
);
1599 CalcStruct(sExpression
);
1600 if(pData
->GetMode() == FORMULA_FORMDLG_FORMULA
)
1601 aTabCtrl
.SetCurPageId(TP_FUNCTION
);
1603 aTabCtrl
.SetCurPageId(TP_STRUCT
);
1604 aBtnMatrix
.Check(pData
->GetMatrixFlag());
1605 /*aTimer.SetTimeout(200);
1606 aTimer.SetTimeoutHdl(LINK( this, FormulaDlg_Impl, UpdateFocusHdl));
1609 void FormulaDlg_Impl::Update(const String
& _sExp
)
1613 //aBtnForward.Enable(TRUE); //@New
1616 void FormulaDlg_Impl::SetMeText(const String
& _sText
)
1618 FormEditData
* pData
= m_pHelper
->getFormEditData();
1619 pMEdit
->SetText(_sText
);
1620 pMEdit
->SetSelection( pData
->GetSelection());
1621 aMEFormula
.UpdateOldSel();
1623 FormulaDlgMode
FormulaDlg_Impl::SetMeText(const String
& _sText
,xub_StrLen PrivStart
, xub_StrLen PrivEnd
,BOOL bMatrix
,BOOL _bSelect
,BOOL _bUpdate
)
1625 FormulaDlgMode eMode
= FORMULA_FORMDLG_FORMULA
;
1627 pMEdit
->SetText(_sText
);
1629 if ( _bSelect
|| !bEditFlag
)
1630 pMEdit
->SetSelection( Selection(PrivStart
, PrivEnd
));
1633 aMEFormula
.UpdateOldSel();
1634 pMEdit
->Invalidate();
1635 m_pHelper
->showReference(pMEdit
->GetSelected());
1636 eMode
= FORMULA_FORMDLG_EDIT
;
1638 aBtnMatrix
.Check( bMatrix
);
1639 } // if ( _bUpdate )
1642 BOOL
FormulaDlg_Impl::CheckMatrix(String
& aFormula
)
1644 pMEdit
->GrabFocus();
1645 xub_StrLen nLen
= aFormula
.Len();
1646 BOOL bMatrix
= nLen
> 3 // Matrix-Formel ?
1647 && aFormula
.GetChar(0) == '{'
1648 && aFormula
.GetChar(1) == '='
1649 && aFormula
.GetChar(nLen
-1) == '}';
1652 aFormula
.Erase( 0, 1 );
1653 aFormula
.Erase( aFormula
.Len()-1, 1);
1654 aBtnMatrix
.Check( bMatrix
);
1655 aBtnMatrix
.Disable();
1658 aTabCtrl
.SetCurPageId(TP_STRUCT
);
1661 IMPL_LINK( FormulaDlg_Impl
, StructSelHdl
, StructPage
*, pStruP
)
1663 bStructUpdate
=FALSE
;
1664 if(pStructPage
->IsVisible()) aBtnForward
.Enable(FALSE
); //@New
1666 if(pStructPage
==pStruP
)
1669 //ScToken* pSelToken = pStructPage->GetSelectedToken();
1670 // ScToken* pOrigToken = ((pSelToken && pSelToken->GetType() == svFAP) ?
1671 // pSelToken->GetFAPOrigToken() : pSelToken);
1672 //xub_StrLen nTokPos=1;
1676 // ScToken* pToken = pScTokA->First();
1678 // while(pToken!=NULL)
1681 // if ( pToken == pOrigToken )
1683 // pComp->CreateStringFromToken( aString,pToken);
1684 // nTokPos = sal::static_int_cast<xub_StrLen>( nTokPos + aString.Len() );
1685 // pToken=pScTokA->Next();
1687 // EditThisFunc(nTokPos);
1693 // pComp->CreateStringFromToken( aStr, pOrigToken );
1694 // String aEntryTxt=pStructPage->GetSelectedEntryText();
1696 // if(aEntryTxt!=aStr)
1697 // ShowReference(aEntryTxt);
1704 IMPL_LINK( FormulaDlg_Impl
, MatrixHdl
, CheckBox
*, EMPTYARG
)
1706 bUserMatrixFlag
=TRUE
;
1710 IMPL_LINK( FormulaDlg_Impl
, FuncSelHdl
, FuncPage
*, EMPTYARG
)
1712 USHORT nCat
= pFuncPage
->GetCategory();
1713 if ( nCat
== LISTBOX_ENTRY_NOTFOUND
) nCat
= 0;
1714 USHORT nFunc
= pFuncPage
->GetFunction();
1715 if ( nFunc
== LISTBOX_ENTRY_NOTFOUND
) nFunc
= 0;
1717 if ( (pFuncPage
->GetFunctionEntryCount() > 0)
1718 && (pFuncPage
->GetFunction() != LISTBOX_ENTRY_NOTFOUND
) )
1720 const IFunctionDescription
* pDesc
=pFuncPage
->GetFuncDesc( pFuncPage
->GetFunction() );
1722 if(pDesc
!=pFuncDesc
) aBtnForward
.Enable(TRUE
); //new
1726 pDesc
->initArgumentInfo(); // full argument info is needed
1728 String aSig
= pDesc
->getSignature();
1729 aFtHeadLine
.SetText( pDesc
->getFunctionName() );
1730 aFtFuncName
.SetText( aSig
);
1731 aFtFuncDesc
.SetText( pDesc
->getDescription() );
1736 aFtHeadLine
.SetText( String() );
1737 aFtFuncName
.SetText( String() );
1738 aFtFuncDesc
.SetText( String() );
1743 void FormulaDlg_Impl::UpdateParaWin(const Selection
& _rSelection
,const String
& _sRefStr
)
1745 Selection theSel
= _rSelection
;
1746 aEdRef
.ReplaceSelected( _sRefStr
);
1747 theSel
.Max() = theSel
.Min() + _sRefStr
.Len();
1748 aEdRef
.SetSelection( theSel
);
1750 //-------------------------------------
1751 // Manuelles Update der Ergebnisfelder:
1752 //-------------------------------------
1753 USHORT nPrivActiv
= pParaWin
->GetActiveLine();
1754 pParaWin
->SetArgument(nPrivActiv
,aEdRef
.GetText());
1755 pParaWin
->UpdateParas();
1757 Edit
* pEd
= GetCurrRefEdit();
1759 pEd
->SetSelection( theSel
);
1761 pParaWin
->SetRefMode(FALSE
);
1763 BOOL
FormulaDlg_Impl::UpdateParaWin(Selection
& _rSelection
)
1765 pParaWin
->SetRefMode(TRUE
);
1768 Edit
* pEd
= GetCurrRefEdit();
1769 if(pEd
!=NULL
&& pTheRefEdit
==NULL
)
1771 _rSelection
=pEd
->GetSelection();
1772 _rSelection
.Justify();
1773 aStrEd
=pEd
->GetText();
1774 aEdRef
.SetRefString(aStrEd
);
1775 aEdRef
.SetSelection( _rSelection
);
1779 _rSelection
=aEdRef
.GetSelection();
1780 _rSelection
.Justify();
1781 aStrEd
= aEdRef
.GetText();
1783 return pTheRefEdit
== NULL
;
1785 ULONG
FormulaDlg_Impl::FindFocusWin(Window
*pWin
)
1788 if(pWin
->HasFocus())
1790 nUniqueId
=pWin
->GetUniqueId();
1793 Window
* pParent
=pWin
->GetParent();
1794 while(pParent
!=NULL
)
1796 nUniqueId
=pParent
->GetUniqueId();
1798 if(nUniqueId
!=0) break;
1800 pParent
=pParent
->GetParent();
1806 USHORT nCount
=pWin
->GetChildCount();
1808 for(USHORT i
=0;i
<nCount
;i
++)
1810 Window
* pChild
=pWin
->GetChild(i
);
1811 nUniqueId
=FindFocusWin(pChild
);
1812 if(nUniqueId
>0) break;
1818 void FormulaDlg_Impl::SetEdSelection()
1820 Edit
* pEd
= GetCurrRefEdit()/*aScParaWin.GetActiveEdit()*/;
1823 Selection theSel
= aEdRef
.GetSelection();
1824 // Edit may have the focus -> call ModifyHdl in addition
1825 // to what's happening in GetFocus
1826 pEd
->GetModifyHdl().Call(pEd
);
1828 pEd
->SetSelection(theSel
);
1831 // -----------------------------------------------------------------------------
1832 const FormulaHelper
& FormulaDlg_Impl::GetFormulaHelper() const
1834 return m_aFormulaHelper
;
1836 //============================================================================
1837 FormulaModalDialog::FormulaModalDialog( Window
* pParent
1838 , bool _bSupportFunctionResult
1839 , bool _bSupportResult
1840 , bool _bSupportMatrix
1841 , IFormulaEditorHelper
* _pHelper
1842 , IFunctionManager
* _pFunctionMgr
1843 , IControlReferenceHandler
* _pDlg
) :
1844 ModalDialog( pParent
, ModuleRes(RID_FORMULADLG_FORMULA_MODAL
) ),
1845 m_pImpl( new FormulaDlg_Impl(this,_bSupportFunctionResult
1848 ,_pHelper
,_pFunctionMgr
,_pDlg
))
1851 SetText(m_pImpl
->aTitle1
);
1853 FormulaModalDialog::~FormulaModalDialog()
1856 // -----------------------------------------------------------------------------
1857 void FormulaModalDialog::Update(const String
& _sExp
)
1859 m_pImpl
->Update(_sExp
);
1862 // -----------------------------------------------------------------------------
1863 void FormulaModalDialog::SetMeText(const String
& _sText
)
1865 m_pImpl
->SetMeText(_sText
);
1868 // -----------------------------------------------------------------------------
1869 FormulaDlgMode
FormulaModalDialog::SetMeText(const String
& _sText
,xub_StrLen PrivStart
, xub_StrLen PrivEnd
,BOOL bMatrix
,BOOL _bSelect
,BOOL _bUpdate
)
1871 return m_pImpl
->SetMeText(_sText
,PrivStart
, PrivEnd
,bMatrix
,_bSelect
,_bUpdate
);
1873 // -----------------------------------------------------------------------------
1874 void FormulaModalDialog::CheckMatrix()
1876 m_pImpl
->aBtnMatrix
.Check();
1878 // -----------------------------------------------------------------------------
1879 BOOL
FormulaModalDialog::CheckMatrix(String
& aFormula
)
1881 return m_pImpl
->CheckMatrix(aFormula
);
1883 // -----------------------------------------------------------------------------
1884 String
FormulaModalDialog::GetMeText() const
1886 return m_pImpl
->pMEdit
->GetText();
1888 // -----------------------------------------------------------------------------
1889 void FormulaModalDialog::Update()
1893 // -----------------------------------------------------------------------------
1894 const FormulaHelper
& FormulaModalDialog::GetFormulaHelper() const
1896 return m_pImpl
->GetFormulaHelper();
1898 // -----------------------------------------------------------------------------
1899 BOOL
FormulaModalDialog::isUserMatrix() const
1901 return m_pImpl
->bUserMatrixFlag
;
1903 void FormulaModalDialog::DoEnter(BOOL _bOk
)
1905 m_pImpl
->DoEnter(_bOk
);
1907 ::std::pair
<RefButton
*,RefEdit
*> FormulaModalDialog::RefInputStartBefore( RefEdit
* pEdit
, RefButton
* pButton
)
1909 return m_pImpl
->RefInputStartBefore( pEdit
, pButton
);
1911 void FormulaModalDialog::RefInputStartAfter( RefEdit
* pEdit
, RefButton
* pButton
)
1913 m_pImpl
->RefInputStartAfter( pEdit
, pButton
);
1915 void FormulaModalDialog::RefInputDoneAfter( BOOL bForced
)
1917 m_pImpl
->RefInputDoneAfter( bForced
);
1920 ULONG
FormulaModalDialog::FindFocusWin(Window
*pWin
)
1922 return m_pImpl
->FindFocusWin( pWin
);
1925 void FormulaModalDialog::SetFocusWin(Window
*pWin
,ULONG nUniqueId
)
1927 if(pWin
->GetUniqueId()==nUniqueId
)
1933 USHORT nCount
=pWin
->GetChildCount();
1935 for(USHORT i
=0;i
<nCount
;i
++)
1937 Window
* pChild
=pWin
->GetChild(i
);
1938 SetFocusWin(pChild
,nUniqueId
);
1944 long FormulaModalDialog::PreNotify( NotifyEvent
& rNEvt
)
1946 m_pImpl
->PreNotify( rNEvt
);
1948 return ModalDialog::PreNotify(rNEvt
);
1951 void FormulaModalDialog::HighlightFunctionParas(const String
& aFormula
)
1953 m_pImpl
->m_pHelper
->showReference(aFormula
);
1956 void FormulaModalDialog::disableOk()
1958 m_pImpl
->aBtnEnd
.Disable();
1960 // -----------------------------------------------------------------------------
1961 const IFunctionDescription
* FormulaModalDialog::getCurrentFunctionDescription() const
1963 OSL_VERIFY(!m_pImpl
->pFuncDesc
|| m_pImpl
->pFuncDesc
->getSuppressedArgumentCount() == m_pImpl
->nArgs
);
1964 return m_pImpl
->pFuncDesc
;
1966 // -----------------------------------------------------------------------------
1967 void FormulaModalDialog::UpdateParaWin(const Selection
& _rSelection
,const String
& _sRefStr
)
1969 m_pImpl
->UpdateParaWin(_rSelection
,_sRefStr
);
1971 BOOL
FormulaModalDialog::UpdateParaWin(Selection
& _rSelection
)
1973 return m_pImpl
->UpdateParaWin(_rSelection
);
1975 // -----------------------------------------------------------------------------
1976 RefEdit
* FormulaModalDialog::GetActiveEdit()
1978 return m_pImpl
->pParaWin
->GetActiveEdit();
1980 // -----------------------------------------------------------------------------
1981 void FormulaModalDialog::SetEdSelection()
1983 m_pImpl
->SetEdSelection();
1986 // --------------------------------------------------------------------------
1987 // Initialisierung / gemeinsaME Funktionen fuer Dialog
1988 // --------------------------------------------------------------------------
1989 FormulaDlg::FormulaDlg( SfxBindings
* pB
, SfxChildWindow
* pCW
,
1991 , bool _bSupportFunctionResult
1992 , bool _bSupportResult
1993 , bool _bSupportMatrix
1994 , IFormulaEditorHelper
* _pHelper
,IFunctionManager
* _pFunctionMgr
,IControlReferenceHandler
* _pDlg
) :
1995 SfxModelessDialog( pB
, pCW
, pParent
, ModuleRes(RID_FORMULADLG_FORMULA
) ),
1996 m_pImpl( new FormulaDlg_Impl(this, _bSupportFunctionResult
1999 ,_pHelper
,_pFunctionMgr
,_pDlg
))
2002 if(GetHelpId()==0) //Hack, da im SfxModelessDialog die HelpId
2003 SetHelpId(GetUniqueId()); //fuer einen ModelessDialog entfernt und
2004 //in eine UniqueId gewandelt wird, machen
2005 //wir das an dieser Stelle rueckgaengig.
2006 SetText(m_pImpl
->aTitle1
);
2009 FormulaDlg::~FormulaDlg()
2012 // -----------------------------------------------------------------------------
2013 void FormulaDlg::Update(const String
& _sExp
)
2015 m_pImpl
->Update(_sExp
);
2018 // -----------------------------------------------------------------------------
2019 void FormulaDlg::SetMeText(const String
& _sText
)
2021 m_pImpl
->SetMeText(_sText
);
2024 // -----------------------------------------------------------------------------
2025 FormulaDlgMode
FormulaDlg::SetMeText(const String
& _sText
,xub_StrLen PrivStart
, xub_StrLen PrivEnd
,BOOL bMatrix
,BOOL _bSelect
,BOOL _bUpdate
)
2027 return m_pImpl
->SetMeText(_sText
,PrivStart
, PrivEnd
,bMatrix
,_bSelect
,_bUpdate
);
2029 // -----------------------------------------------------------------------------
2030 void FormulaDlg::CheckMatrix()
2032 m_pImpl
->aBtnMatrix
.Check();
2034 // -----------------------------------------------------------------------------
2035 BOOL
FormulaDlg::CheckMatrix(String
& aFormula
)
2037 return m_pImpl
->CheckMatrix(aFormula
);
2039 // -----------------------------------------------------------------------------
2040 String
FormulaDlg::GetMeText() const
2042 return m_pImpl
->pMEdit
->GetText();
2044 // -----------------------------------------------------------------------------
2045 void FormulaDlg::Update()
2048 m_pImpl
->aTimer
.SetTimeout(200);
2049 m_pImpl
->aTimer
.SetTimeoutHdl(LINK( this, FormulaDlg
, UpdateFocusHdl
));
2050 m_pImpl
->aTimer
.Start();
2053 // -----------------------------------------------------------------------------
2054 BOOL
FormulaDlg::isUserMatrix() const
2056 return m_pImpl
->bUserMatrixFlag
;
2058 void FormulaDlg::DoEnter(BOOL _bOk
)
2060 m_pImpl
->DoEnter(_bOk
);
2062 ::std::pair
<RefButton
*,RefEdit
*> FormulaDlg::RefInputStartBefore( RefEdit
* pEdit
, RefButton
* pButton
)
2064 return m_pImpl
->RefInputStartBefore( pEdit
, pButton
);
2066 void FormulaDlg::RefInputStartAfter( RefEdit
* pEdit
, RefButton
* pButton
)
2068 m_pImpl
->RefInputStartAfter( pEdit
, pButton
);
2070 void FormulaDlg::RefInputDoneAfter( BOOL bForced
)
2072 m_pImpl
->RefInputDoneAfter( bForced
);
2075 ULONG
FormulaDlg::FindFocusWin(Window
*pWin
)
2077 return m_pImpl
->FindFocusWin( pWin
);
2080 void FormulaDlg::SetFocusWin(Window
*pWin
,ULONG nUniqueId
)
2082 if(pWin
->GetUniqueId()==nUniqueId
)
2088 USHORT nCount
=pWin
->GetChildCount();
2090 for(USHORT i
=0;i
<nCount
;i
++)
2092 Window
* pChild
=pWin
->GetChild(i
);
2093 SetFocusWin(pChild
,nUniqueId
);
2099 long FormulaDlg::PreNotify( NotifyEvent
& rNEvt
)
2101 m_pImpl
->PreNotify( rNEvt
);
2102 return SfxModelessDialog::PreNotify(rNEvt
);
2105 void FormulaDlg::HighlightFunctionParas(const String
& aFormula
)
2107 m_pImpl
->m_pHelper
->showReference(aFormula
);
2110 void FormulaDlg::disableOk()
2112 m_pImpl
->aBtnEnd
.Disable();
2114 // -----------------------------------------------------------------------------
2115 const IFunctionDescription
* FormulaDlg::getCurrentFunctionDescription() const
2117 OSL_VERIFY(!m_pImpl
->pFuncDesc
|| m_pImpl
->pFuncDesc
->getSuppressedArgumentCount() == m_pImpl
->nArgs
);
2118 return m_pImpl
->pFuncDesc
;
2120 // -----------------------------------------------------------------------------
2121 void FormulaDlg::UpdateParaWin(const Selection
& _rSelection
,const String
& _sRefStr
)
2123 m_pImpl
->UpdateParaWin(_rSelection
,_sRefStr
);
2125 BOOL
FormulaDlg::UpdateParaWin(Selection
& _rSelection
)
2127 return m_pImpl
->UpdateParaWin(_rSelection
);
2129 // -----------------------------------------------------------------------------
2130 RefEdit
* FormulaDlg::GetActiveEdit()
2132 return m_pImpl
->pParaWin
->GetActiveEdit();
2134 // -----------------------------------------------------------------------------
2135 const FormulaHelper
& FormulaDlg::GetFormulaHelper() const
2137 return m_pImpl
->GetFormulaHelper();
2139 // -----------------------------------------------------------------------------
2140 void FormulaDlg::SetEdSelection()
2142 m_pImpl
->SetEdSelection();
2144 IMPL_LINK( FormulaDlg
, UpdateFocusHdl
, Timer
*, EMPTYARG
)
2146 FormEditData
* pData
= m_pImpl
->m_pHelper
->getFormEditData();
2148 if (pData
) // wird nicht ueber Close zerstoert;
2150 m_pImpl
->m_pHelper
->setReferenceInput(pData
);
2151 ULONG nUniqueId
=pData
->GetUniqueId();
2152 SetFocusWin(this,nUniqueId
);
2157 // -----------------------------------------------------------------------------
2158 // -----------------------------------------------------------------------------
2159 void FormEditData::SaveValues()
2161 FormEditData
* pTemp
= new FormEditData(*this);
2166 // -----------------------------------------------------------------------------
2167 void FormEditData::Reset()
2172 nCatSel
= 1; //! oder 0 (zuletzt benutzte)
2182 // -----------------------------------------------------------------------------
2183 void FormEditData::RestoreValues()
2185 FormEditData
* pTemp
= pParent
;
2186 DBG_ASSERT(pTemp
,"RestoreValues ohne Parent");
2190 pTemp
->pParent
= NULL
; // sonst wird der auch geloescht!
2194 // -----------------------------------------------------------------------------
2195 const FormEditData
& FormEditData::operator=( const FormEditData
& r
)
2197 pParent
= r
.pParent
;
2199 nFStart
= r
.nFStart
;
2200 nCatSel
= r
.nCatSel
;
2201 nFuncSel
= r
.nFuncSel
;
2202 nOffset
= r
.nOffset
;
2203 nEdFocus
= r
.nEdFocus
;
2204 aUndoStr
= r
.aUndoStr
;
2205 bMatrix
= r
.bMatrix
;
2206 nUniqueId
= r
.nUniqueId
;
2207 aSelection
= r
.aSelection
;
2210 // -----------------------------------------------------------------------------
2211 FormEditData::FormEditData()
2216 FormEditData::~FormEditData()
2221 FormEditData::FormEditData( const FormEditData
& r
)
2226 // -----------------------------------------------------------------------------
2228 // -----------------------------------------------------------------------------