1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_formula.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //---------------------------------------------------------------------------- 32*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 33*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 34*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 35*cdf0e10cSrcweir #include <vcl/svapp.hxx> 36*cdf0e10cSrcweir #include <vcl/mnemonic.hxx> 37*cdf0e10cSrcweir #include <vcl/tabpage.hxx> 38*cdf0e10cSrcweir #include <vcl/tabctrl.hxx> 39*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 40*cdf0e10cSrcweir #include <vcl/group.hxx> 41*cdf0e10cSrcweir #include <vcl/wall.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <svtools/stdctrl.hxx> 44*cdf0e10cSrcweir #include <svtools/svmedit.hxx> 45*cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 46*cdf0e10cSrcweir #include <svl/stritem.hxx> 47*cdf0e10cSrcweir #include <svl/zforlist.hxx> 48*cdf0e10cSrcweir #include <svl/eitem.hxx> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <unotools/charclass.hxx> 51*cdf0e10cSrcweir #include <tools/urlobj.hxx> 52*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #include "formdlgs.hrc" 55*cdf0e10cSrcweir #include "funcpage.hxx" 56*cdf0e10cSrcweir #include "formula/formula.hxx" 57*cdf0e10cSrcweir #include "formula/IFunctionDescription.hxx" 58*cdf0e10cSrcweir #include "formula/FormulaCompiler.hxx" 59*cdf0e10cSrcweir #include "formula/token.hxx" 60*cdf0e10cSrcweir #include "formula/tokenarray.hxx" 61*cdf0e10cSrcweir #include "formula/formdata.hxx" 62*cdf0e10cSrcweir #include "formula/formulahelper.hxx" 63*cdf0e10cSrcweir #include "structpg.hxx" 64*cdf0e10cSrcweir #include "parawin.hxx" 65*cdf0e10cSrcweir #include "ModuleHelper.hxx" 66*cdf0e10cSrcweir #include "ForResId.hrc" 67*cdf0e10cSrcweir #include <com/sun/star/sheet/FormulaToken.hpp> 68*cdf0e10cSrcweir #include <com/sun/star/sheet/FormulaLanguage.hpp> 69*cdf0e10cSrcweir #include <com/sun/star/sheet/FormulaMapGroup.hpp> 70*cdf0e10cSrcweir #include <com/sun/star/sheet/FormulaMapGroupSpecialOffset.hpp> 71*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 72*cdf0e10cSrcweir #include <boost/bind.hpp> 73*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 74*cdf0e10cSrcweir #include <map> 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir #define TOKEN_OPEN 0 77*cdf0e10cSrcweir #define TOKEN_CLOSE 1 78*cdf0e10cSrcweir #define TOKEN_SEP 2 79*cdf0e10cSrcweir namespace formula 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir using namespace ::com::sun::star; 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir class OFormulaToken : public IFormulaToken 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir sal_Int32 m_nParaCount; 86*cdf0e10cSrcweir bool m_bIsFunction; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir public: 89*cdf0e10cSrcweir OFormulaToken(bool _bFunction,sal_Int32 _nParaCount) : m_nParaCount(_nParaCount),m_bIsFunction(_bFunction){} 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir virtual bool isFunction() const { return m_bIsFunction; } 92*cdf0e10cSrcweir virtual sal_uInt32 getArgumentCount() const { return m_nParaCount; } 93*cdf0e10cSrcweir }; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir class FormulaDlg_Impl 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir public: 99*cdf0e10cSrcweir ::std::pair<RefButton*,RefEdit*> 100*cdf0e10cSrcweir RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ); 101*cdf0e10cSrcweir void RefInputStartAfter( RefEdit* pEdit, RefButton* pButton ); 102*cdf0e10cSrcweir void RefInputDoneAfter( sal_Bool bForced ); 103*cdf0e10cSrcweir sal_Bool CalcValue( const String& rStrExp, String& rStrResult ); 104*cdf0e10cSrcweir sal_Bool CalcStruct( const String& rStrExp); 105*cdf0e10cSrcweir void UpdateValues(); 106*cdf0e10cSrcweir void DeleteArgs(); 107*cdf0e10cSrcweir xub_StrLen GetFunctionPos(xub_StrLen nPos); 108*cdf0e10cSrcweir void ClearAllParas(); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir void MakeTree(IStructHelper* _pTree,SvLBoxEntry* pParent,FormulaToken* _pToken,long Count); 111*cdf0e10cSrcweir void fillTree(IStructHelper* _pTree); 112*cdf0e10cSrcweir void UpdateTokenArray( const String& rStrExp); 113*cdf0e10cSrcweir String RepairFormula(const String& aFormula); 114*cdf0e10cSrcweir void FillDialog(sal_Bool nFlag=sal_True); 115*cdf0e10cSrcweir void EditNextFunc( sal_Bool bForward, xub_StrLen nFStart=NOT_FOUND ); 116*cdf0e10cSrcweir void EditThisFunc(xub_StrLen nFStart); 117*cdf0e10cSrcweir void EditFuncParas(xub_StrLen nEditPos); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir void UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 nInput ); 121*cdf0e10cSrcweir void Update(); 122*cdf0e10cSrcweir void Update(const String& _sExp); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir void SaveArg( sal_uInt16 nEd ); 126*cdf0e10cSrcweir void UpdateSelection(); 127*cdf0e10cSrcweir void DoEnter( sal_Bool bOk ); 128*cdf0e10cSrcweir void UpdateFunctionDesc(); 129*cdf0e10cSrcweir void ResizeArgArr( const IFunctionDescription* pNewFunc ); 130*cdf0e10cSrcweir void FillListboxes(); 131*cdf0e10cSrcweir void FillControls(sal_Bool &rbNext, sal_Bool &rbPrev); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir FormulaDlgMode SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,sal_Bool bMatrix,sal_Bool _bSelect,sal_Bool _bUpdate); 134*cdf0e10cSrcweir void SetMeText(const String& _sText); 135*cdf0e10cSrcweir sal_Bool CheckMatrix(String& aFormula /*IN/OUT*/); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir void SetEdSelection(); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir sal_Bool UpdateParaWin(Selection& _rSelection); 140*cdf0e10cSrcweir void UpdateParaWin(const Selection& _rSelection,const String& _sRefStr); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir void SetData(xub_StrLen nFStart,xub_StrLen nNextFStart,xub_StrLen nNextFEnd,xub_StrLen& PrivStart,xub_StrLen& PrivEnd); 143*cdf0e10cSrcweir void PreNotify( NotifyEvent& rNEvt ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir RefEdit* GetCurrRefEdit(); 146*cdf0e10cSrcweir rtl::OString FindFocusWin(Window *pWin); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir const FormulaHelper& GetFormulaHelper() const; 149*cdf0e10cSrcweir uno::Reference< sheet::XFormulaOpCodeMapper > GetFormulaOpCodeMapper() const; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir DECL_LINK( ModifyHdl, ParaWin* ); 152*cdf0e10cSrcweir DECL_LINK( FxHdl, ParaWin* ); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir DECL_LINK( MatrixHdl, CheckBox *); 155*cdf0e10cSrcweir DECL_LINK( FormulaHdl, MultiLineEdit* ); 156*cdf0e10cSrcweir DECL_LINK( FormulaCursorHdl, EditBox*); 157*cdf0e10cSrcweir DECL_LINK( BtnHdl, PushButton* ); 158*cdf0e10cSrcweir DECL_LINK( GetEdFocusHdl, ArgInput* ); 159*cdf0e10cSrcweir DECL_LINK( GetFxFocusHdl, ArgInput* ); 160*cdf0e10cSrcweir DECL_LINK( DblClkHdl, FuncPage* ); 161*cdf0e10cSrcweir DECL_LINK( FuncSelHdl, FuncPage*); 162*cdf0e10cSrcweir DECL_LINK( StructSelHdl, StructPage * ); 163*cdf0e10cSrcweir public: 164*cdf0e10cSrcweir OModuleClient m_aModuleClient; 165*cdf0e10cSrcweir mutable uno::Reference< sheet::XFormulaOpCodeMapper> m_xOpCodeMapper; 166*cdf0e10cSrcweir uno::Sequence< sheet::FormulaToken > m_aTokenList; 167*cdf0e10cSrcweir ::std::auto_ptr<FormulaTokenArray> m_pTokenArray; 168*cdf0e10cSrcweir mutable uno::Sequence< sheet::FormulaOpCodeMapEntry > m_aSpecialOpCodes; 169*cdf0e10cSrcweir mutable const sheet::FormulaOpCodeMapEntry* m_pSpecialOpCodesEnd; 170*cdf0e10cSrcweir mutable uno::Sequence< sheet::FormulaToken > m_aSeparatorsOpCodes; 171*cdf0e10cSrcweir mutable uno::Sequence< sheet::FormulaOpCodeMapEntry > m_aFunctionOpCodes; 172*cdf0e10cSrcweir mutable const sheet::FormulaOpCodeMapEntry* m_pFunctionOpCodesEnd; 173*cdf0e10cSrcweir mutable uno::Sequence< sheet::FormulaOpCodeMapEntry > m_aUnaryOpCodes; 174*cdf0e10cSrcweir mutable const sheet::FormulaOpCodeMapEntry* m_pUnaryOpCodesEnd; 175*cdf0e10cSrcweir mutable uno::Sequence< sheet::FormulaOpCodeMapEntry > m_aBinaryOpCodes; 176*cdf0e10cSrcweir mutable const sheet::FormulaOpCodeMapEntry* m_pBinaryOpCodesEnd; 177*cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OFormulaToken> > m_aTokens; 178*cdf0e10cSrcweir ::std::map<FormulaToken*,sheet::FormulaToken> m_aTokenMap; 179*cdf0e10cSrcweir IFormulaEditorHelper* m_pHelper; 180*cdf0e10cSrcweir Dialog* m_pParent; 181*cdf0e10cSrcweir IControlReferenceHandler* m_pDlg; 182*cdf0e10cSrcweir TabControl aTabCtrl; 183*cdf0e10cSrcweir GroupBox aGEdit; //! MUST be placed before pParaWin for initializing 184*cdf0e10cSrcweir ParaWin* pParaWin; 185*cdf0e10cSrcweir FixedText aFtHeadLine; 186*cdf0e10cSrcweir FixedInfo aFtFuncName; 187*cdf0e10cSrcweir FixedInfo aFtFuncDesc; 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir FixedText aFtEditName; 190*cdf0e10cSrcweir //FixedInfo aFtEditDesc; 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir FixedText aFtResult; 193*cdf0e10cSrcweir ValWnd aWndResult; 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir FixedText aFtFormula; 196*cdf0e10cSrcweir EditBox aMEFormula; 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir CheckBox aBtnMatrix; 199*cdf0e10cSrcweir HelpButton aBtnHelp; 200*cdf0e10cSrcweir CancelButton aBtnCancel; 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir PushButton aBtnBackward; 203*cdf0e10cSrcweir PushButton aBtnForward; 204*cdf0e10cSrcweir OKButton aBtnEnd; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir RefEdit aEdRef; 207*cdf0e10cSrcweir RefButton aRefBtn; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir FixedText aFtFormResult; 210*cdf0e10cSrcweir ValWnd aWndFormResult; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir RefEdit* pTheRefEdit; 213*cdf0e10cSrcweir RefButton* pTheRefButton; 214*cdf0e10cSrcweir FuncPage* pFuncPage; 215*cdf0e10cSrcweir StructPage* pStructPage; 216*cdf0e10cSrcweir String aOldFormula; 217*cdf0e10cSrcweir sal_Bool bStructUpdate; 218*cdf0e10cSrcweir MultiLineEdit* pMEdit; 219*cdf0e10cSrcweir sal_Bool bUserMatrixFlag; 220*cdf0e10cSrcweir Timer aTimer; 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir const String aTitle1; 223*cdf0e10cSrcweir const String aTitle2; 224*cdf0e10cSrcweir const String aTxtEnd; 225*cdf0e10cSrcweir const String aTxtOk; // hinter aBtnEnd 226*cdf0e10cSrcweir FormulaHelper 227*cdf0e10cSrcweir m_aFormulaHelper; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir rtl::OString m_aEditHelpId; 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir rtl::OString aOldHelp; 232*cdf0e10cSrcweir rtl::OString aOldUnique; 233*cdf0e10cSrcweir rtl::OString aActivWinId; 234*cdf0e10cSrcweir sal_Bool bIsShutDown; 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir Font aFntBold; 239*cdf0e10cSrcweir Font aFntLight; 240*cdf0e10cSrcweir sal_uInt16 nEdFocus; 241*cdf0e10cSrcweir // Selection theCurSel; 242*cdf0e10cSrcweir sal_Bool bEditFlag; 243*cdf0e10cSrcweir const IFunctionDescription* pFuncDesc; 244*cdf0e10cSrcweir xub_StrLen nArgs; 245*cdf0e10cSrcweir ::std::vector< ::rtl::OUString > m_aArguments; 246*cdf0e10cSrcweir Selection aFuncSel; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir FormulaDlg_Impl(Dialog* pParent 249*cdf0e10cSrcweir , bool _bSupportFunctionResult 250*cdf0e10cSrcweir , bool _bSupportResult 251*cdf0e10cSrcweir , bool _bSupportMatrix 252*cdf0e10cSrcweir ,IFormulaEditorHelper* _pHelper 253*cdf0e10cSrcweir ,const IFunctionManager* _pFunctionMgr 254*cdf0e10cSrcweir ,IControlReferenceHandler* _pDlg); 255*cdf0e10cSrcweir ~FormulaDlg_Impl(); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir }; 258*cdf0e10cSrcweir FormulaDlg_Impl::FormulaDlg_Impl(Dialog* pParent 259*cdf0e10cSrcweir , bool _bSupportFunctionResult 260*cdf0e10cSrcweir , bool _bSupportResult 261*cdf0e10cSrcweir , bool _bSupportMatrix 262*cdf0e10cSrcweir ,IFormulaEditorHelper* _pHelper 263*cdf0e10cSrcweir ,const IFunctionManager* _pFunctionMgr 264*cdf0e10cSrcweir ,IControlReferenceHandler* _pDlg) 265*cdf0e10cSrcweir : 266*cdf0e10cSrcweir m_pHelper (_pHelper), 267*cdf0e10cSrcweir m_pParent (pParent), 268*cdf0e10cSrcweir m_pDlg (_pDlg), 269*cdf0e10cSrcweir aTabCtrl ( pParent, ModuleRes( TC_FUNCTION ) ), 270*cdf0e10cSrcweir aGEdit ( pParent, ModuleRes( GB_EDIT ) ), 271*cdf0e10cSrcweir aFtHeadLine ( pParent, ModuleRes( FT_HEADLINE ) ), 272*cdf0e10cSrcweir aFtFuncName ( pParent, ModuleRes( FT_FUNCNAME ) ), 273*cdf0e10cSrcweir aFtFuncDesc ( pParent, ModuleRes( FT_FUNCDESC ) ), 274*cdf0e10cSrcweir // 275*cdf0e10cSrcweir aFtEditName ( pParent, ModuleRes( FT_EDITNAME ) ), 276*cdf0e10cSrcweir aFtResult ( pParent, ModuleRes( FT_RESULT ) ), 277*cdf0e10cSrcweir aWndResult ( pParent, ModuleRes( WND_RESULT ) ), 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir aFtFormula ( pParent, ModuleRes( FT_FORMULA ) ), 280*cdf0e10cSrcweir aMEFormula ( pParent, ModuleRes( ED_FORMULA ) ), 281*cdf0e10cSrcweir // 282*cdf0e10cSrcweir aBtnMatrix ( pParent, ModuleRes( BTN_MATRIX ) ), 283*cdf0e10cSrcweir aBtnHelp ( pParent, ModuleRes( BTN_HELP ) ), 284*cdf0e10cSrcweir aBtnCancel ( pParent, ModuleRes( BTN_CANCEL ) ), 285*cdf0e10cSrcweir aBtnBackward ( pParent, ModuleRes( BTN_BACKWARD ) ), 286*cdf0e10cSrcweir aBtnForward ( pParent, ModuleRes( BTN_FORWARD ) ), 287*cdf0e10cSrcweir aBtnEnd ( pParent, ModuleRes( BTN_END ) ), 288*cdf0e10cSrcweir aEdRef ( pParent, _pDlg, ModuleRes( ED_REF) ), 289*cdf0e10cSrcweir aRefBtn ( pParent, ModuleRes( RB_REF),&aEdRef,_pDlg ), 290*cdf0e10cSrcweir aFtFormResult ( pParent, ModuleRes( FT_FORMULA_RESULT)), 291*cdf0e10cSrcweir aWndFormResult ( pParent, ModuleRes( WND_FORMULA_RESULT)), 292*cdf0e10cSrcweir // 293*cdf0e10cSrcweir pTheRefEdit (NULL), 294*cdf0e10cSrcweir pMEdit (NULL), 295*cdf0e10cSrcweir bUserMatrixFlag (sal_False), 296*cdf0e10cSrcweir // 297*cdf0e10cSrcweir aTitle1 ( ModuleRes( STR_TITLE1 ) ), // lokale Resource 298*cdf0e10cSrcweir aTitle2 ( ModuleRes( STR_TITLE2 ) ), // lokale Resource 299*cdf0e10cSrcweir aTxtEnd ( ModuleRes( STR_END ) ), // lokale Resource 300*cdf0e10cSrcweir aTxtOk ( aBtnEnd.GetText() ), 301*cdf0e10cSrcweir m_aFormulaHelper(_pFunctionMgr), 302*cdf0e10cSrcweir // 303*cdf0e10cSrcweir bIsShutDown (sal_False), 304*cdf0e10cSrcweir nEdFocus (0), 305*cdf0e10cSrcweir pFuncDesc (NULL), 306*cdf0e10cSrcweir nArgs (0) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir pParaWin = new ParaWin( pParent,_pDlg, aGEdit.GetPosPixel()); 309*cdf0e10cSrcweir aGEdit.Hide(); 310*cdf0e10cSrcweir pParaWin->Hide(); 311*cdf0e10cSrcweir aFtEditName.Hide(); 312*cdf0e10cSrcweir aEdRef.Hide(); 313*cdf0e10cSrcweir aRefBtn.Hide(); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir pMEdit = aMEFormula.GetEdit(); 316*cdf0e10cSrcweir //IAccessibility2 Implementation 2009----- 317*cdf0e10cSrcweir aMEFormula.SetAccessibleName(aFtFormula.GetText()); 318*cdf0e10cSrcweir if (pMEdit) 319*cdf0e10cSrcweir pMEdit->SetAccessibleName(aFtFormula.GetText()); 320*cdf0e10cSrcweir //-----IAccessibility2 Implementation 2009 321*cdf0e10cSrcweir m_aEditHelpId = pMEdit->GetHelpId(); 322*cdf0e10cSrcweir pMEdit->SetUniqueId( m_aEditHelpId ); 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir bEditFlag=sal_False; 325*cdf0e10cSrcweir bStructUpdate=sal_True; 326*cdf0e10cSrcweir Point aPos=aGEdit.GetPosPixel(); 327*cdf0e10cSrcweir pParaWin->SetPosPixel(aPos); 328*cdf0e10cSrcweir pParaWin->SetArgModifiedHdl(LINK( this, FormulaDlg_Impl, ModifyHdl ) ); 329*cdf0e10cSrcweir pParaWin->SetFxHdl(LINK( this, FormulaDlg_Impl, FxHdl ) ); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir pFuncPage= new FuncPage( &aTabCtrl,_pFunctionMgr); 332*cdf0e10cSrcweir pStructPage= new StructPage( &aTabCtrl); 333*cdf0e10cSrcweir pFuncPage->Hide(); 334*cdf0e10cSrcweir pStructPage->Hide(); 335*cdf0e10cSrcweir aTabCtrl.SetTabPage( TP_FUNCTION, pFuncPage); 336*cdf0e10cSrcweir aTabCtrl.SetTabPage( TP_STRUCT, pStructPage); 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir aOldHelp = pParent->GetHelpId(); // HelpId aus Resource immer fuer "Seite 1" 339*cdf0e10cSrcweir aOldUnique = pParent->GetUniqueId(); 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir aFtResult.Show( _bSupportResult ); 342*cdf0e10cSrcweir aWndResult.Show( _bSupportResult ); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir aFtFormResult.Show( _bSupportFunctionResult ); 345*cdf0e10cSrcweir aWndFormResult.Show( _bSupportFunctionResult ); 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir if ( _bSupportMatrix ) 348*cdf0e10cSrcweir aBtnMatrix.SetClickHdl(LINK( this, FormulaDlg_Impl, MatrixHdl ) ); 349*cdf0e10cSrcweir else 350*cdf0e10cSrcweir aBtnMatrix.Hide(); 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir aBtnCancel .SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) ); 353*cdf0e10cSrcweir aBtnEnd .SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) ); 354*cdf0e10cSrcweir aBtnForward .SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) ); 355*cdf0e10cSrcweir aBtnBackward.SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) ); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir pFuncPage->SetDoubleClickHdl( LINK( this, FormulaDlg_Impl, DblClkHdl ) ); 358*cdf0e10cSrcweir pFuncPage->SetSelectHdl( LINK( this, FormulaDlg_Impl, FuncSelHdl) ); 359*cdf0e10cSrcweir pStructPage->SetSelectionHdl( LINK( this, FormulaDlg_Impl, StructSelHdl ) ); 360*cdf0e10cSrcweir pMEdit->SetModifyHdl( LINK( this, FormulaDlg_Impl, FormulaHdl ) ); 361*cdf0e10cSrcweir aMEFormula.SetSelChangedHdl( LINK( this, FormulaDlg_Impl, FormulaCursorHdl ) ); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir aFntLight = aFtFormula.GetFont(); 364*cdf0e10cSrcweir aFntLight.SetTransparent( sal_True ); 365*cdf0e10cSrcweir aFntBold = aFntLight; 366*cdf0e10cSrcweir aFntBold.SetWeight( WEIGHT_BOLD ); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir pParaWin->SetArgumentFonts(aFntBold,aFntLight); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir // function description for choosing a function is no longer in a different color 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir aFtHeadLine.SetFont(aFntBold); 373*cdf0e10cSrcweir aFtFuncName.SetFont(aFntLight); 374*cdf0e10cSrcweir aFtFuncDesc.SetFont(aFntLight); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir FormulaDlg_Impl::~FormulaDlg_Impl() 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir if(aTimer.IsActive()) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir aTimer.SetTimeoutHdl(Link()); 381*cdf0e10cSrcweir aTimer.Stop(); 382*cdf0e10cSrcweir } // if(aTimer.IsActive()) 383*cdf0e10cSrcweir bIsShutDown=sal_True;// Setzen, damit PreNotify keinen GetFocus speichert. 384*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 385*cdf0e10cSrcweir if (pData) // wird nicht ueber Close zerstoert; 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir pData->SetFStart((xub_StrLen)pMEdit->GetSelection().Min()); 388*cdf0e10cSrcweir pData->SetSelection(pMEdit->GetSelection()); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir if(aTabCtrl.GetCurPageId()==TP_FUNCTION) 391*cdf0e10cSrcweir pData->SetMode( (sal_uInt16) FORMULA_FORMDLG_FORMULA ); 392*cdf0e10cSrcweir else 393*cdf0e10cSrcweir pData->SetMode( (sal_uInt16) FORMULA_FORMDLG_EDIT ); 394*cdf0e10cSrcweir pData->SetUndoStr(pMEdit->GetText()); 395*cdf0e10cSrcweir pData->SetMatrixFlag(aBtnMatrix.IsChecked()); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir aTabCtrl.RemovePage(TP_FUNCTION); 399*cdf0e10cSrcweir aTabCtrl.RemovePage(TP_STRUCT); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir delete pStructPage; 402*cdf0e10cSrcweir delete pFuncPage; 403*cdf0e10cSrcweir delete pParaWin; 404*cdf0e10cSrcweir DeleteArgs(); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 407*cdf0e10cSrcweir void FormulaDlg_Impl::PreNotify( NotifyEvent& rNEvt ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir sal_uInt16 nSwitch=rNEvt.GetType(); 410*cdf0e10cSrcweir if(nSwitch==EVENT_GETFOCUS && !bIsShutDown) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir Window* pWin=rNEvt.GetWindow(); 413*cdf0e10cSrcweir if(pWin!=NULL) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir aActivWinId = pWin->GetUniqueId(); 416*cdf0e10cSrcweir if(aActivWinId.getLength()==0) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir Window* pParent=pWin->GetParent(); 419*cdf0e10cSrcweir while(pParent!=NULL) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir aActivWinId=pParent->GetUniqueId(); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir if(aActivWinId.getLength()!=0) break; 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir pParent=pParent->GetParent(); 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir if(aActivWinId.getLength()) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir if (pData && !aTimer.IsActive()) // wird nicht ueber Close zerstoert; 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir pData->SetUniqueId(aActivWinId); 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir uno::Reference< sheet::XFormulaOpCodeMapper > FormulaDlg_Impl::GetFormulaOpCodeMapper() const 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir if ( !m_xOpCodeMapper.is() ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir m_xOpCodeMapper = m_pHelper->getFormulaOpCodeMapper(); 446*cdf0e10cSrcweir m_aFunctionOpCodes = m_xOpCodeMapper->getAvailableMappings(sheet::FormulaLanguage::ODFF,sheet::FormulaMapGroup::FUNCTIONS); 447*cdf0e10cSrcweir m_pFunctionOpCodesEnd = m_aFunctionOpCodes.getConstArray() + m_aFunctionOpCodes.getLength(); 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir m_aUnaryOpCodes = m_xOpCodeMapper->getAvailableMappings(sheet::FormulaLanguage::ODFF,sheet::FormulaMapGroup::UNARY_OPERATORS); 450*cdf0e10cSrcweir m_pUnaryOpCodesEnd = m_aUnaryOpCodes.getConstArray() + m_aUnaryOpCodes.getLength(); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir m_aBinaryOpCodes = m_xOpCodeMapper->getAvailableMappings(sheet::FormulaLanguage::ODFF,sheet::FormulaMapGroup::BINARY_OPERATORS); 453*cdf0e10cSrcweir m_pBinaryOpCodesEnd = m_aBinaryOpCodes.getConstArray() + m_aBinaryOpCodes.getLength(); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aArgs(3); 456*cdf0e10cSrcweir aArgs[TOKEN_OPEN] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("(")); 457*cdf0e10cSrcweir aArgs[TOKEN_CLOSE] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")); 458*cdf0e10cSrcweir aArgs[TOKEN_SEP] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";")); 459*cdf0e10cSrcweir m_aSeparatorsOpCodes = m_xOpCodeMapper->getMappings(aArgs,sheet::FormulaLanguage::ODFF); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir m_aSpecialOpCodes = m_xOpCodeMapper->getAvailableMappings(sheet::FormulaLanguage::ODFF,sheet::FormulaMapGroup::SPECIAL); 462*cdf0e10cSrcweir m_pSpecialOpCodesEnd = m_aSpecialOpCodes.getConstArray() + m_aSpecialOpCodes.getLength(); 463*cdf0e10cSrcweir } // if ( !m_xOpCodeMapper.is() ) 464*cdf0e10cSrcweir return m_xOpCodeMapper; 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir void FormulaDlg_Impl::DeleteArgs() 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir ::std::vector< ::rtl::OUString>().swap(m_aArguments); 470*cdf0e10cSrcweir nArgs = 0; 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir namespace 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir // comparing two property instances 475*cdf0e10cSrcweir struct OpCodeCompare : public ::std::binary_function< sheet::FormulaOpCodeMapEntry, sal_Int32 , bool > 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir bool operator() (const sheet::FormulaOpCodeMapEntry& x, sal_Int32 y) const 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir return x.Token.OpCode == y; 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir }; 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 484*cdf0e10cSrcweir xub_StrLen FormulaDlg_Impl::GetFunctionPos(xub_StrLen nPos) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir const sal_Unicode sep = m_pHelper->getFunctionManager()->getSingleToken(IFunctionManager::eSep); 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir xub_StrLen nTokPos=1; 489*cdf0e10cSrcweir xub_StrLen nOldTokPos=1; 490*cdf0e10cSrcweir xub_StrLen nFuncPos=STRING_NOTFOUND; //@ Testweise 491*cdf0e10cSrcweir xub_StrLen nPrevFuncPos=1; 492*cdf0e10cSrcweir short nBracketCount=0; 493*cdf0e10cSrcweir sal_Bool bFlag=sal_False; 494*cdf0e10cSrcweir String aFormString = pMEdit->GetText(); 495*cdf0e10cSrcweir m_aFormulaHelper.GetCharClass()->toUpper( aFormString ); 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir if ( m_aTokenList.getLength() ) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir const uno::Reference< sheet::XFormulaParser > xParser(m_pHelper->getFormulaParser()); 500*cdf0e10cSrcweir const table::CellAddress aRefPos(m_pHelper->getReferencePosition()); 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir const sheet::FormulaToken* pIter = m_aTokenList.getConstArray(); 503*cdf0e10cSrcweir const sheet::FormulaToken* pEnd = pIter + m_aTokenList.getLength(); 504*cdf0e10cSrcweir //if ( pIter != pEnd && aFormString.GetChar(0) == '=' ) 505*cdf0e10cSrcweir // ++pIter; 506*cdf0e10cSrcweir try 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir while ( pIter != pEnd ) 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir const sal_Int32 eOp = pIter->OpCode; 511*cdf0e10cSrcweir uno::Sequence<sheet::FormulaToken> aArgs(1); 512*cdf0e10cSrcweir aArgs[0] = *pIter; 513*cdf0e10cSrcweir const String aString = xParser->printFormula(aArgs, aRefPos); 514*cdf0e10cSrcweir const sheet::FormulaToken* pNextToken = pIter + 1; 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir if(!bUserMatrixFlag && FormulaCompiler::IsMatrixFunction((OpCode)eOp) ) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir aBtnMatrix.Check(); 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir if ( eOp == m_aSpecialOpCodes[sheet::FormulaMapGroupSpecialOffset::PUSH].Token.OpCode || eOp == m_aSpecialOpCodes[sheet::FormulaMapGroupSpecialOffset::SPACES].Token.OpCode ) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir const xub_StrLen n1=aFormString.Search(sep, nTokPos); 524*cdf0e10cSrcweir const xub_StrLen n2=aFormString.Search(')',nTokPos); 525*cdf0e10cSrcweir xub_StrLen nXXX=nTokPos; 526*cdf0e10cSrcweir if(n1<n2) 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir nTokPos=n1; 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir else 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir nTokPos=n2; 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir if ( pNextToken != pEnd ) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir aArgs[0] = *pNextToken; 537*cdf0e10cSrcweir const String a2String = xParser->printFormula(aArgs, aRefPos); 538*cdf0e10cSrcweir const xub_StrLen n3 = aFormString.Search(a2String,nXXX); 539*cdf0e10cSrcweir if ( n3 < nTokPos ) 540*cdf0e10cSrcweir nTokPos = n3; 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir else 544*cdf0e10cSrcweir { 545*cdf0e10cSrcweir nTokPos = sal::static_int_cast<xub_StrLen>( nTokPos + aString.Len() ); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir if ( eOp == m_aSeparatorsOpCodes[TOKEN_OPEN].OpCode ) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir nBracketCount++; 551*cdf0e10cSrcweir bFlag=sal_True; 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir else if ( eOp == m_aSeparatorsOpCodes[TOKEN_CLOSE].OpCode ) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir nBracketCount--; 556*cdf0e10cSrcweir bFlag=sal_False; 557*cdf0e10cSrcweir nFuncPos=nPrevFuncPos; 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir bool bIsFunction = ::std::find_if(m_aFunctionOpCodes.getConstArray(),m_pFunctionOpCodesEnd,::std::bind2nd(OpCodeCompare(),boost::cref(eOp))) != m_pFunctionOpCodesEnd; 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir if ( bIsFunction && m_aSpecialOpCodes[sheet::FormulaMapGroupSpecialOffset::SPACES].Token.OpCode != eOp ) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir nPrevFuncPos = nFuncPos; 564*cdf0e10cSrcweir nFuncPos = nOldTokPos; 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir if ( nOldTokPos <= nPos && nPos < nTokPos ) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir if ( !bIsFunction ) 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir if ( nBracketCount < 1 ) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir nFuncPos= pMEdit->GetText().Len(); 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir else if ( !bFlag ) 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir nFuncPos=nPrevFuncPos; 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir break; 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir pIter = pNextToken; 584*cdf0e10cSrcweir nOldTokPos = nTokPos; 585*cdf0e10cSrcweir } // while ( pIter != pEnd ) 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir catch(const uno::Exception& ) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir DBG_ERROR("Exception caught!"); 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir return nFuncPos; 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 596*cdf0e10cSrcweir sal_Bool FormulaDlg_Impl::CalcValue( const String& rStrExp, String& rStrResult ) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir sal_Bool bResult = sal_True; 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir if ( rStrExp.Len() > 0 ) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir // nur, wenn keine Tastatureingabe mehr anliegt, den Wert berechnen: 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir if ( !Application::AnyInput( INPUT_KEYBOARD ) ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir bResult = m_pHelper->calculateValue(rStrExp,rStrResult); 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir else 609*cdf0e10cSrcweir bResult = sal_False; 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir return bResult; 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir void FormulaDlg_Impl::UpdateValues() 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir String aStrResult; 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir if ( CalcValue( pFuncDesc->getFormula( m_aArguments ), aStrResult ) ) 620*cdf0e10cSrcweir aWndResult.SetValue( aStrResult ); 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir aStrResult.Erase(); 623*cdf0e10cSrcweir if ( CalcValue(m_pHelper->getCurrentFormula(), aStrResult ) ) 624*cdf0e10cSrcweir aWndFormResult.SetValue( aStrResult ); 625*cdf0e10cSrcweir else 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir aStrResult.Erase(); 628*cdf0e10cSrcweir aWndFormResult.SetValue( aStrResult ); 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir CalcStruct(pMEdit->GetText()); 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir sal_Bool FormulaDlg_Impl::CalcStruct( const String& rStrExp) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir sal_Bool bResult = sal_True; 636*cdf0e10cSrcweir xub_StrLen nLength=rStrExp.Len(); 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir if ( rStrExp.Len() > 0 && aOldFormula!=rStrExp && bStructUpdate) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir // nur, wenn keine Tastatureingabe mehr anliegt, den Wert berechnen: 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir if ( !Application::AnyInput( INPUT_KEYBOARD ) ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir pStructPage->ClearStruct(); 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir String aString=rStrExp; 647*cdf0e10cSrcweir if(rStrExp.GetChar(nLength-1)=='(') 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir aString.Erase((xub_StrLen)(nLength-1)); 650*cdf0e10cSrcweir } 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir aString.EraseAllChars('\n'); 653*cdf0e10cSrcweir String aStrResult; 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir if ( CalcValue(aString, aStrResult ) ) 656*cdf0e10cSrcweir aWndFormResult.SetValue( aStrResult ); 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir UpdateTokenArray(aString); 659*cdf0e10cSrcweir fillTree(pStructPage); 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir aOldFormula=rStrExp; 662*cdf0e10cSrcweir if(rStrExp.GetChar(nLength-1)=='(') 663*cdf0e10cSrcweir UpdateTokenArray(rStrExp); 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir else 666*cdf0e10cSrcweir bResult = sal_False; 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir return bResult; 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 672*cdf0e10cSrcweir void FormulaDlg_Impl::MakeTree(IStructHelper* _pTree,SvLBoxEntry* pParent,FormulaToken* _pToken,long Count) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir if( _pToken != NULL && Count > 0 ) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir long nParas = _pToken->GetParamCount(); 677*cdf0e10cSrcweir OpCode eOp = _pToken->GetOpCode(); 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir // #i101512# for output, the original token is needed 680*cdf0e10cSrcweir FormulaToken* pOrigToken = (_pToken->GetType() == svFAP) ? _pToken->GetFAPOrigToken() : _pToken; 681*cdf0e10cSrcweir uno::Sequence<sheet::FormulaToken> aArgs(1); 682*cdf0e10cSrcweir aArgs[0] = m_aTokenMap.find(pOrigToken)->second; 683*cdf0e10cSrcweir try 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir const table::CellAddress aRefPos(m_pHelper->getReferencePosition()); 686*cdf0e10cSrcweir const String aResult = m_pHelper->getFormulaParser()->printFormula(aArgs, aRefPos); 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir if ( nParas > 0 ) 689*cdf0e10cSrcweir { 690*cdf0e10cSrcweir SvLBoxEntry* pEntry; 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir String aTest=_pTree->GetEntryText(pParent); 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir if(aTest==aResult && 695*cdf0e10cSrcweir (eOp==ocAdd || eOp==ocMul || 696*cdf0e10cSrcweir eOp==ocAmpersand)) 697*cdf0e10cSrcweir { 698*cdf0e10cSrcweir pEntry=pParent; 699*cdf0e10cSrcweir } 700*cdf0e10cSrcweir else 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir if(eOp==ocBad) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir pEntry=_pTree->InsertEntry(aResult,pParent,STRUCT_ERROR,0,_pToken); 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir else 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir pEntry=_pTree->InsertEntry(aResult,pParent,STRUCT_FOLDER,0,_pToken); 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir } 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir MakeTree(_pTree,pEntry,m_pTokenArray->PrevRPN(),nParas); 713*cdf0e10cSrcweir --Count; 714*cdf0e10cSrcweir m_pTokenArray->NextRPN(); 715*cdf0e10cSrcweir MakeTree(_pTree,pParent,m_pTokenArray->PrevRPN(),Count); 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir else 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir if(eOp==ocBad) 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir _pTree->InsertEntry(aResult,pParent,STRUCT_ERROR,0,_pToken); 722*cdf0e10cSrcweir } 723*cdf0e10cSrcweir else 724*cdf0e10cSrcweir { 725*cdf0e10cSrcweir _pTree->InsertEntry(aResult,pParent,STRUCT_END,0,_pToken); 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir --Count; 728*cdf0e10cSrcweir MakeTree(_pTree,pParent,m_pTokenArray->PrevRPN(),Count); 729*cdf0e10cSrcweir } 730*cdf0e10cSrcweir } 731*cdf0e10cSrcweir catch(uno::Exception&) 732*cdf0e10cSrcweir { 733*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir void FormulaDlg_Impl::fillTree(IStructHelper* _pTree) 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir GetFormulaOpCodeMapper(); 741*cdf0e10cSrcweir FormulaToken* pToken = m_pTokenArray->LastRPN(); 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir if( pToken != NULL) 744*cdf0e10cSrcweir { 745*cdf0e10cSrcweir MakeTree(_pTree,NULL,pToken,1); 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir void FormulaDlg_Impl::UpdateTokenArray( const String& rStrExp) 749*cdf0e10cSrcweir { 750*cdf0e10cSrcweir m_aTokenMap.clear(); 751*cdf0e10cSrcweir m_aTokenList.realloc(0); 752*cdf0e10cSrcweir try 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir const table::CellAddress aRefPos(m_pHelper->getReferencePosition()); 755*cdf0e10cSrcweir m_aTokenList = m_pHelper->getFormulaParser()->parseFormula(rStrExp, aRefPos); 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir catch(const uno::Exception&) 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 760*cdf0e10cSrcweir } 761*cdf0e10cSrcweir GetFormulaOpCodeMapper(); // just to get it initialized 762*cdf0e10cSrcweir m_pTokenArray = m_pHelper->convertToTokenArray(m_aTokenList); 763*cdf0e10cSrcweir const sal_Int32 nLen = static_cast<sal_Int32>(m_pTokenArray->GetLen()); 764*cdf0e10cSrcweir FormulaToken** pTokens = m_pTokenArray->GetArray(); 765*cdf0e10cSrcweir if ( pTokens && nLen == m_aTokenList.getLength() ) 766*cdf0e10cSrcweir { 767*cdf0e10cSrcweir for (sal_Int32 nPos=0; nPos<nLen; nPos++) 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir m_aTokenMap.insert(::std::map<FormulaToken*,sheet::FormulaToken>::value_type(pTokens[nPos],m_aTokenList[nPos])); 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir } // if ( pTokens && nLen == m_aTokenList.getLength() ) 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir FormulaCompiler aCompiler(*m_pTokenArray.get()); 774*cdf0e10cSrcweir aCompiler.SetCompileForFAP(sal_True); // #i101512# special handling is needed 775*cdf0e10cSrcweir aCompiler.CompileTokenArray(); 776*cdf0e10cSrcweir } 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir void FormulaDlg_Impl::FillDialog(sal_Bool nFlag) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir sal_Bool bNext=sal_True, bPrev=sal_True; 781*cdf0e10cSrcweir if(nFlag) 782*cdf0e10cSrcweir FillControls(bNext, bPrev); 783*cdf0e10cSrcweir FillListboxes(); 784*cdf0e10cSrcweir if(nFlag) 785*cdf0e10cSrcweir { 786*cdf0e10cSrcweir aBtnBackward.Enable(bPrev); 787*cdf0e10cSrcweir aBtnForward.Enable(bNext); 788*cdf0e10cSrcweir } 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir String aStrResult; 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir if ( CalcValue(m_pHelper->getCurrentFormula(), aStrResult ) ) 793*cdf0e10cSrcweir aWndFormResult.SetValue( aStrResult ); 794*cdf0e10cSrcweir else 795*cdf0e10cSrcweir { 796*cdf0e10cSrcweir aStrResult.Erase(); 797*cdf0e10cSrcweir aWndFormResult.SetValue( aStrResult ); 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 802*cdf0e10cSrcweir void FormulaDlg_Impl::FillListboxes() 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir // Umschalten zwischen den "Seiten" 805*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 806*cdf0e10cSrcweir String aNewTitle; 807*cdf0e10cSrcweir // 1. Seite: Funktion auswaehlen 808*cdf0e10cSrcweir if ( pFuncDesc && pFuncDesc->getCategory() ) 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir if( pFuncPage->GetCategory() != pFuncDesc->getCategory()->getNumber() + 1 ) 811*cdf0e10cSrcweir pFuncPage->SetCategory(static_cast<sal_uInt16>(pFuncDesc->getCategory()->getNumber() + 1)); 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir sal_uInt16 nPos=pFuncPage->GetFuncPos(pFuncDesc); 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir pFuncPage->SetFunction(nPos); 816*cdf0e10cSrcweir } 817*cdf0e10cSrcweir else if ( pData ) 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir pFuncPage->SetCategory( pData->GetCatSel() ); 820*cdf0e10cSrcweir pFuncPage->SetFunction( pData->GetFuncSel() ); 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir FuncSelHdl(NULL); 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir // ResizeArgArr jetzt schon in UpdateFunctionDesc 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir m_pHelper->setDispatcherLock( sal_True);// Modal-Modus einschalten 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir aNewTitle = aTitle1; 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir // HelpId fuer 1. Seite ist die aus der Resource 832*cdf0e10cSrcweir m_pParent->SetHelpId( aOldHelp ); 833*cdf0e10cSrcweir m_pParent->SetUniqueId( aOldUnique ); 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 836*cdf0e10cSrcweir void FormulaDlg_Impl::FillControls(sal_Bool &rbNext, sal_Bool &rbPrev) 837*cdf0e10cSrcweir { 838*cdf0e10cSrcweir // Umschalten zwischen den "Seiten" 839*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 840*cdf0e10cSrcweir if (!pData ) 841*cdf0e10cSrcweir return; 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir String aNewTitle; 844*cdf0e10cSrcweir // 2. Seite oder Editieren: ausgewaehlte Funktion anzeigen 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir xub_StrLen nFStart = pData->GetFStart(); 847*cdf0e10cSrcweir String aFormula = m_pHelper->getCurrentFormula(); 848*cdf0e10cSrcweir xub_StrLen nNextFStart = nFStart; 849*cdf0e10cSrcweir xub_StrLen nNextFEnd = 0; 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " )" )); 852*cdf0e10cSrcweir DeleteArgs(); 853*cdf0e10cSrcweir const IFunctionDescription* pOldFuncDesc = pFuncDesc; 854*cdf0e10cSrcweir sal_Bool bTestFlag = sal_False; 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir if ( m_aFormulaHelper.GetNextFunc( aFormula, sal_False, 857*cdf0e10cSrcweir nNextFStart, &nNextFEnd, &pFuncDesc, &m_aArguments ) ) 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir bTestFlag = (pOldFuncDesc != pFuncDesc); 860*cdf0e10cSrcweir if(bTestFlag) 861*cdf0e10cSrcweir { 862*cdf0e10cSrcweir aFtHeadLine.Hide(); 863*cdf0e10cSrcweir aFtFuncName.Hide(); 864*cdf0e10cSrcweir aFtFuncDesc.Hide(); 865*cdf0e10cSrcweir pParaWin->SetFunctionDesc(pFuncDesc); 866*cdf0e10cSrcweir aFtEditName.SetText( pFuncDesc->getFunctionName() ); 867*cdf0e10cSrcweir aFtEditName.Show(); 868*cdf0e10cSrcweir pParaWin->Show(); 869*cdf0e10cSrcweir const rtl::OString aHelpId = pFuncDesc->getHelpId(); 870*cdf0e10cSrcweir if ( aHelpId.getLength() ) 871*cdf0e10cSrcweir pMEdit->SetHelpId(aHelpId); 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir xub_StrLen nOldStart, nOldEnd; 875*cdf0e10cSrcweir m_pHelper->getSelection( nOldStart, nOldEnd ); 876*cdf0e10cSrcweir if ( nOldStart != nNextFStart || nOldEnd != nNextFEnd ) 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir m_pHelper->setSelection( nNextFStart, nNextFEnd ); 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir aFuncSel.Min() = nNextFStart; 881*cdf0e10cSrcweir aFuncSel.Max() = nNextFEnd; 882*cdf0e10cSrcweir 883*cdf0e10cSrcweir if(!bEditFlag) 884*cdf0e10cSrcweir pMEdit->SetText(m_pHelper->getCurrentFormula()); 885*cdf0e10cSrcweir xub_StrLen PrivStart, PrivEnd; 886*cdf0e10cSrcweir m_pHelper->getSelection( PrivStart, PrivEnd); 887*cdf0e10cSrcweir if(!bEditFlag) 888*cdf0e10cSrcweir pMEdit->SetSelection( Selection(PrivStart, PrivEnd)); 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir nArgs = pFuncDesc->getSuppressedArgumentCount(); 891*cdf0e10cSrcweir sal_uInt16 nOffset = pData->GetOffset(); 892*cdf0e10cSrcweir nEdFocus = pData->GetEdFocus(); 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir // Verkettung der Edit's fuer Focus-Kontrolle 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir if(bTestFlag) 897*cdf0e10cSrcweir pParaWin->SetArgumentOffset(nOffset); 898*cdf0e10cSrcweir sal_uInt16 nActiv=0; 899*cdf0e10cSrcweir xub_StrLen nArgPos= m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 ); 900*cdf0e10cSrcweir xub_StrLen nEditPos=(xub_StrLen) pMEdit->GetSelection().Min(); 901*cdf0e10cSrcweir sal_Bool bFlag=sal_False; 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir for(sal_uInt16 i=0;i<nArgs;i++) 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir sal_Int32 nLength = m_aArguments[i].getLength()+1; 906*cdf0e10cSrcweir pParaWin->SetArgument(i,m_aArguments[i]); 907*cdf0e10cSrcweir if(nArgPos<=nEditPos && nEditPos<nArgPos+nLength) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir nActiv=i; 910*cdf0e10cSrcweir bFlag=sal_True; 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir nArgPos = sal::static_int_cast<xub_StrLen>( nArgPos + nLength ); 913*cdf0e10cSrcweir } 914*cdf0e10cSrcweir pParaWin->UpdateParas(); 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir if(bFlag) 917*cdf0e10cSrcweir { 918*cdf0e10cSrcweir pParaWin->SetActiveLine(nActiv); 919*cdf0e10cSrcweir } 920*cdf0e10cSrcweir 921*cdf0e10cSrcweir //pParaWin->SetEdFocus( nEdFocus ); 922*cdf0e10cSrcweir UpdateValues(); 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir else 925*cdf0e10cSrcweir { 926*cdf0e10cSrcweir aFtEditName.SetText(String()); 927*cdf0e10cSrcweir pMEdit->SetHelpId( m_aEditHelpId ); 928*cdf0e10cSrcweir } 929*cdf0e10cSrcweir // Test, ob vorne/hinten noch mehr Funktionen sind 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir xub_StrLen nTempStart = m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 ); 932*cdf0e10cSrcweir rbNext = m_aFormulaHelper.GetNextFunc( aFormula, sal_False, nTempStart ); 933*cdf0e10cSrcweir nTempStart=(xub_StrLen)pMEdit->GetSelection().Min(); 934*cdf0e10cSrcweir pData->SetFStart(nTempStart); 935*cdf0e10cSrcweir rbPrev = m_aFormulaHelper.GetNextFunc( aFormula, sal_True, nTempStart ); 936*cdf0e10cSrcweir } 937*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir void FormulaDlg_Impl::ClearAllParas() 940*cdf0e10cSrcweir { 941*cdf0e10cSrcweir DeleteArgs(); 942*cdf0e10cSrcweir pFuncDesc = NULL; 943*cdf0e10cSrcweir pParaWin->ClearAll(); 944*cdf0e10cSrcweir aWndResult.SetValue(String()); 945*cdf0e10cSrcweir aFtFuncName.SetText(String()); 946*cdf0e10cSrcweir FuncSelHdl(NULL); 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir if(pFuncPage->IsVisible()) 949*cdf0e10cSrcweir { 950*cdf0e10cSrcweir aFtEditName.Hide(); 951*cdf0e10cSrcweir pParaWin->Hide(); 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir aBtnForward.Enable(sal_True); //@new 954*cdf0e10cSrcweir aFtHeadLine.Show(); 955*cdf0e10cSrcweir aFtFuncName.Show(); 956*cdf0e10cSrcweir aFtFuncDesc.Show(); 957*cdf0e10cSrcweir } 958*cdf0e10cSrcweir } 959*cdf0e10cSrcweir String FormulaDlg_Impl::RepairFormula(const String& aFormula) 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir String aResult('='); 962*cdf0e10cSrcweir try 963*cdf0e10cSrcweir { 964*cdf0e10cSrcweir UpdateTokenArray(aFormula); 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir if ( m_aTokenList.getLength() ) 967*cdf0e10cSrcweir { 968*cdf0e10cSrcweir const table::CellAddress aRefPos(m_pHelper->getReferencePosition()); 969*cdf0e10cSrcweir const String sFormula(m_pHelper->getFormulaParser()->printFormula(m_aTokenList, aRefPos)); 970*cdf0e10cSrcweir if ( !sFormula.Len() || sFormula.GetChar(0) != '=' ) 971*cdf0e10cSrcweir aResult += sFormula; 972*cdf0e10cSrcweir else 973*cdf0e10cSrcweir aResult = sFormula; 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir } 976*cdf0e10cSrcweir } 977*cdf0e10cSrcweir catch(const uno::Exception& ) 978*cdf0e10cSrcweir { 979*cdf0e10cSrcweir DBG_ERROR("Exception caught!"); 980*cdf0e10cSrcweir } 981*cdf0e10cSrcweir return aResult; 982*cdf0e10cSrcweir } 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir void FormulaDlg_Impl::DoEnter(sal_Bool bOk) 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir // Eingabe ins Dokument uebernehmen oder abbrechen 987*cdf0e10cSrcweir if ( bOk) 988*cdf0e10cSrcweir { 989*cdf0e10cSrcweir // ggf. Dummy-Argumente entfernen 990*cdf0e10cSrcweir String aInputFormula = m_pHelper->getCurrentFormula(); 991*cdf0e10cSrcweir String aString = RepairFormula(pMEdit->GetText()); 992*cdf0e10cSrcweir m_pHelper->setSelection(0, aInputFormula.Len()); 993*cdf0e10cSrcweir m_pHelper->setCurrentFormula(aString); 994*cdf0e10cSrcweir } 995*cdf0e10cSrcweir 996*cdf0e10cSrcweir m_pHelper->switchBack(); 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir m_pHelper->dispatch(bOk,aBtnMatrix.IsChecked()); 999*cdf0e10cSrcweir // Daten loeschen 1000*cdf0e10cSrcweir m_pHelper->deleteFormData(); 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir // Dialog schliessen 1003*cdf0e10cSrcweir m_pHelper->doClose(bOk); 1004*cdf0e10cSrcweir } 1005*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1006*cdf0e10cSrcweir 1007*cdf0e10cSrcweir IMPL_LINK( FormulaDlg_Impl, BtnHdl, PushButton*, pBtn ) 1008*cdf0e10cSrcweir { 1009*cdf0e10cSrcweir if ( pBtn == &aBtnCancel ) 1010*cdf0e10cSrcweir { 1011*cdf0e10cSrcweir DoEnter(sal_False); // schliesst den Dialog 1012*cdf0e10cSrcweir } 1013*cdf0e10cSrcweir else if ( pBtn == &aBtnEnd ) 1014*cdf0e10cSrcweir { 1015*cdf0e10cSrcweir DoEnter(sal_True); // schliesst den Dialog 1016*cdf0e10cSrcweir } 1017*cdf0e10cSrcweir else if ( pBtn == &aBtnForward ) 1018*cdf0e10cSrcweir { 1019*cdf0e10cSrcweir //@pMEdit->GrabFocus(); // Damit die Selektion auch angezeigt wird. 1020*cdf0e10cSrcweir const IFunctionDescription* pDesc =pFuncPage->GetFuncDesc( pFuncPage->GetFunction() ); 1021*cdf0e10cSrcweir 1022*cdf0e10cSrcweir if(pDesc==pFuncDesc || !pFuncPage->IsVisible()) 1023*cdf0e10cSrcweir EditNextFunc( sal_True ); 1024*cdf0e10cSrcweir else 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir DblClkHdl(pFuncPage); //new 1027*cdf0e10cSrcweir aBtnForward.Enable(sal_False); //new 1028*cdf0e10cSrcweir } 1029*cdf0e10cSrcweir //@EditNextFunc( sal_True ); 1030*cdf0e10cSrcweir } 1031*cdf0e10cSrcweir else if ( pBtn == &aBtnBackward ) 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir bEditFlag=sal_False; 1034*cdf0e10cSrcweir aBtnForward.Enable(sal_True); 1035*cdf0e10cSrcweir EditNextFunc( sal_False ); 1036*cdf0e10cSrcweir aMEFormula.Invalidate(); 1037*cdf0e10cSrcweir aMEFormula.Update(); 1038*cdf0e10cSrcweir } 1039*cdf0e10cSrcweir //... 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir return 0; 1042*cdf0e10cSrcweir } 1043*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1044*cdf0e10cSrcweir 1045*cdf0e10cSrcweir 1046*cdf0e10cSrcweir // -------------------------------------------------------------------------- 1047*cdf0e10cSrcweir // Funktionen fuer 1. Seite 1048*cdf0e10cSrcweir // -------------------------------------------------------------------------- 1049*cdf0e10cSrcweir 1050*cdf0e10cSrcweir void FormulaDlg_Impl::ResizeArgArr( const IFunctionDescription* pNewFunc ) 1051*cdf0e10cSrcweir { 1052*cdf0e10cSrcweir if ( pFuncDesc != pNewFunc ) 1053*cdf0e10cSrcweir { 1054*cdf0e10cSrcweir DeleteArgs(); 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir if ( pNewFunc ) 1057*cdf0e10cSrcweir nArgs = pNewFunc->getSuppressedArgumentCount(); 1058*cdf0e10cSrcweir 1059*cdf0e10cSrcweir pFuncDesc = pNewFunc; 1060*cdf0e10cSrcweir } 1061*cdf0e10cSrcweir } 1062*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1063*cdf0e10cSrcweir 1064*cdf0e10cSrcweir void FormulaDlg_Impl::UpdateFunctionDesc() 1065*cdf0e10cSrcweir { 1066*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1067*cdf0e10cSrcweir if (!pData) 1068*cdf0e10cSrcweir return; 1069*cdf0e10cSrcweir sal_uInt16 nCat = pFuncPage->GetCategory(); 1070*cdf0e10cSrcweir if ( nCat == LISTBOX_ENTRY_NOTFOUND ) 1071*cdf0e10cSrcweir nCat = 0; 1072*cdf0e10cSrcweir pData->SetCatSel( nCat ); 1073*cdf0e10cSrcweir sal_uInt16 nFunc = pFuncPage->GetFunction(); 1074*cdf0e10cSrcweir if ( nFunc == LISTBOX_ENTRY_NOTFOUND ) 1075*cdf0e10cSrcweir nFunc = 0; 1076*cdf0e10cSrcweir pData->SetFuncSel( nFunc ); 1077*cdf0e10cSrcweir 1078*cdf0e10cSrcweir if ( (pFuncPage->GetFunctionEntryCount() > 0) 1079*cdf0e10cSrcweir && (pFuncPage->GetFunction() != LISTBOX_ENTRY_NOTFOUND) ) 1080*cdf0e10cSrcweir { 1081*cdf0e10cSrcweir const IFunctionDescription* pDesc = pFuncPage->GetFuncDesc(pFuncPage->GetFunction() ); 1082*cdf0e10cSrcweir if (pDesc) 1083*cdf0e10cSrcweir { 1084*cdf0e10cSrcweir pDesc->initArgumentInfo(); // full argument info is needed 1085*cdf0e10cSrcweir 1086*cdf0e10cSrcweir String aSig = pDesc->getSignature(); 1087*cdf0e10cSrcweir 1088*cdf0e10cSrcweir aFtFuncName.SetText( aSig ); 1089*cdf0e10cSrcweir aFtFuncDesc.SetText( pDesc->getDescription() ); 1090*cdf0e10cSrcweir ResizeArgArr( pDesc ); 1091*cdf0e10cSrcweir 1092*cdf0e10cSrcweir if ( !m_aArguments.empty() ) // noch Argumente da? 1093*cdf0e10cSrcweir aSig = pDesc->getFormula( m_aArguments ); // fuer Eingabezeile 1094*cdf0e10cSrcweir //@ m_pHelper->setCurrentFormula( aSig ); 1095*cdf0e10cSrcweir } 1096*cdf0e10cSrcweir } 1097*cdf0e10cSrcweir else 1098*cdf0e10cSrcweir { 1099*cdf0e10cSrcweir aFtFuncName.SetText( String() ); 1100*cdf0e10cSrcweir aFtFuncDesc.SetText( String() ); 1101*cdf0e10cSrcweir 1102*cdf0e10cSrcweir //ResizeArgArr( NULL ); 1103*cdf0e10cSrcweir m_pHelper->setCurrentFormula( String() ); 1104*cdf0e10cSrcweir } 1105*cdf0e10cSrcweir } 1106*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir // Handler fuer Listboxen 1109*cdf0e10cSrcweir 1110*cdf0e10cSrcweir IMPL_LINK( FormulaDlg_Impl, DblClkHdl, FuncPage*, EMPTYARG ) 1111*cdf0e10cSrcweir { 1112*cdf0e10cSrcweir sal_uInt16 nFunc = pFuncPage->GetFunction(); 1113*cdf0e10cSrcweir 1114*cdf0e10cSrcweir // ex-UpdateLRUList 1115*cdf0e10cSrcweir const IFunctionDescription* pDesc = pFuncPage->GetFuncDesc(nFunc); 1116*cdf0e10cSrcweir m_pHelper->insertEntryToLRUList(pDesc); 1117*cdf0e10cSrcweir 1118*cdf0e10cSrcweir String aFuncName = pFuncPage->GetSelFunctionName(); 1119*cdf0e10cSrcweir aFuncName.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" )); 1120*cdf0e10cSrcweir m_pHelper->setCurrentFormula(aFuncName); 1121*cdf0e10cSrcweir pMEdit->ReplaceSelected(aFuncName); 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweir Selection aSel=pMEdit->GetSelection(); 1124*cdf0e10cSrcweir aSel.Max()=aSel.Max()-1; 1125*cdf0e10cSrcweir pMEdit->SetSelection(aSel); 1126*cdf0e10cSrcweir 1127*cdf0e10cSrcweir FormulaHdl(pMEdit); 1128*cdf0e10cSrcweir 1129*cdf0e10cSrcweir aSel.Min()=aSel.Max(); 1130*cdf0e10cSrcweir pMEdit->SetSelection(aSel); 1131*cdf0e10cSrcweir 1132*cdf0e10cSrcweir if(nArgs==0) 1133*cdf0e10cSrcweir { 1134*cdf0e10cSrcweir BtnHdl(&aBtnBackward); 1135*cdf0e10cSrcweir } 1136*cdf0e10cSrcweir 1137*cdf0e10cSrcweir pParaWin->SetEdFocus(0); 1138*cdf0e10cSrcweir aBtnForward.Enable(sal_False); //@New 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir return 0; 1141*cdf0e10cSrcweir } 1142*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1143*cdf0e10cSrcweir 1144*cdf0e10cSrcweir // -------------------------------------------------------------------------- 1145*cdf0e10cSrcweir // Funktionen fuer rechte Seite 1146*cdf0e10cSrcweir // -------------------------------------------------------------------------- 1147*cdf0e10cSrcweir void FormulaDlg_Impl::SetData(xub_StrLen nFStart,xub_StrLen nNextFStart,xub_StrLen nNextFEnd,xub_StrLen& PrivStart,xub_StrLen& PrivEnd) 1148*cdf0e10cSrcweir { 1149*cdf0e10cSrcweir xub_StrLen nFEnd; 1150*cdf0e10cSrcweir 1151*cdf0e10cSrcweir // Selektion merken und neue setzen 1152*cdf0e10cSrcweir m_pHelper->getSelection( nFStart, nFEnd ); 1153*cdf0e10cSrcweir m_pHelper->setSelection( nNextFStart, nNextFEnd ); 1154*cdf0e10cSrcweir if(!bEditFlag) 1155*cdf0e10cSrcweir pMEdit->SetText(m_pHelper->getCurrentFormula()); 1156*cdf0e10cSrcweir 1157*cdf0e10cSrcweir 1158*cdf0e10cSrcweir m_pHelper->getSelection( PrivStart, PrivEnd); 1159*cdf0e10cSrcweir if(!bEditFlag) 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir pMEdit->SetSelection( Selection(PrivStart, PrivEnd)); 1162*cdf0e10cSrcweir aMEFormula.UpdateOldSel(); 1163*cdf0e10cSrcweir } 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1166*cdf0e10cSrcweir pData->SetFStart( nNextFStart ); 1167*cdf0e10cSrcweir pData->SetOffset( 0 ); 1168*cdf0e10cSrcweir pData->SetEdFocus( 0 ); 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir FillDialog(); 1171*cdf0e10cSrcweir } 1172*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1173*cdf0e10cSrcweir void FormulaDlg_Impl::EditThisFunc(xub_StrLen nFStart) 1174*cdf0e10cSrcweir { 1175*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1176*cdf0e10cSrcweir if (!pData) return; 1177*cdf0e10cSrcweir 1178*cdf0e10cSrcweir String aFormula = m_pHelper->getCurrentFormula(); 1179*cdf0e10cSrcweir 1180*cdf0e10cSrcweir if(nFStart==NOT_FOUND) 1181*cdf0e10cSrcweir { 1182*cdf0e10cSrcweir nFStart = pData->GetFStart(); 1183*cdf0e10cSrcweir } 1184*cdf0e10cSrcweir else 1185*cdf0e10cSrcweir { 1186*cdf0e10cSrcweir pData->SetFStart(nFStart); 1187*cdf0e10cSrcweir } 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir xub_StrLen nNextFStart = nFStart; 1190*cdf0e10cSrcweir xub_StrLen nNextFEnd = 0; 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir sal_Bool bFound; 1193*cdf0e10cSrcweir 1194*cdf0e10cSrcweir //@bFound = m_pHelper->getNextFunction( aFormula, sal_False, nNextFStart, &nNextFEnd, &pFuncDesc ); 1195*cdf0e10cSrcweir 1196*cdf0e10cSrcweir bFound = m_aFormulaHelper.GetNextFunc( aFormula, sal_False, nNextFStart, &nNextFEnd); 1197*cdf0e10cSrcweir if ( bFound ) 1198*cdf0e10cSrcweir { 1199*cdf0e10cSrcweir xub_StrLen PrivStart, PrivEnd; 1200*cdf0e10cSrcweir SetData(nFStart,nNextFStart,nNextFEnd,PrivStart, PrivEnd); 1201*cdf0e10cSrcweir m_pHelper->showReference(aFormula.Copy(PrivStart, PrivEnd-PrivStart)); 1202*cdf0e10cSrcweir } 1203*cdf0e10cSrcweir else 1204*cdf0e10cSrcweir { 1205*cdf0e10cSrcweir ClearAllParas(); 1206*cdf0e10cSrcweir } 1207*cdf0e10cSrcweir } 1208*cdf0e10cSrcweir 1209*cdf0e10cSrcweir void FormulaDlg_Impl::EditNextFunc( sal_Bool bForward, xub_StrLen nFStart ) 1210*cdf0e10cSrcweir { 1211*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1212*cdf0e10cSrcweir if (!pData) 1213*cdf0e10cSrcweir return; 1214*cdf0e10cSrcweir 1215*cdf0e10cSrcweir String aFormula = m_pHelper->getCurrentFormula(); 1216*cdf0e10cSrcweir 1217*cdf0e10cSrcweir if(nFStart==NOT_FOUND) 1218*cdf0e10cSrcweir { 1219*cdf0e10cSrcweir nFStart = pData->GetFStart(); 1220*cdf0e10cSrcweir } 1221*cdf0e10cSrcweir else 1222*cdf0e10cSrcweir { 1223*cdf0e10cSrcweir pData->SetFStart(nFStart); 1224*cdf0e10cSrcweir } 1225*cdf0e10cSrcweir 1226*cdf0e10cSrcweir xub_StrLen nNextFStart = 0; 1227*cdf0e10cSrcweir xub_StrLen nNextFEnd = 0; 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir sal_Bool bFound; 1230*cdf0e10cSrcweir if ( bForward ) 1231*cdf0e10cSrcweir { 1232*cdf0e10cSrcweir nNextFStart = m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 ); 1233*cdf0e10cSrcweir //@bFound = m_pHelper->getNextFunction( aFormula, sal_False, nNextFStart, &nNextFEnd, &pFuncDesc ); 1234*cdf0e10cSrcweir bFound = m_aFormulaHelper.GetNextFunc( aFormula, sal_False, nNextFStart, &nNextFEnd); 1235*cdf0e10cSrcweir } 1236*cdf0e10cSrcweir else 1237*cdf0e10cSrcweir { 1238*cdf0e10cSrcweir nNextFStart = nFStart; 1239*cdf0e10cSrcweir //@bFound = m_pHelper->getNextFunction( aFormula, sal_True, nNextFStart, &nNextFEnd, &pFuncDesc ); 1240*cdf0e10cSrcweir bFound = m_aFormulaHelper.GetNextFunc( aFormula, sal_True, nNextFStart, &nNextFEnd); 1241*cdf0e10cSrcweir } 1242*cdf0e10cSrcweir 1243*cdf0e10cSrcweir if ( bFound ) 1244*cdf0e10cSrcweir { 1245*cdf0e10cSrcweir xub_StrLen PrivStart, PrivEnd; 1246*cdf0e10cSrcweir SetData(nFStart,nNextFStart,nNextFEnd,PrivStart, PrivEnd); 1247*cdf0e10cSrcweir } 1248*cdf0e10cSrcweir } 1249*cdf0e10cSrcweir 1250*cdf0e10cSrcweir void FormulaDlg_Impl::EditFuncParas(xub_StrLen nEditPos) 1251*cdf0e10cSrcweir { 1252*cdf0e10cSrcweir if(pFuncDesc!=NULL) 1253*cdf0e10cSrcweir { 1254*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1255*cdf0e10cSrcweir if (!pData) return; 1256*cdf0e10cSrcweir 1257*cdf0e10cSrcweir String aFormula = m_pHelper->getCurrentFormula(); 1258*cdf0e10cSrcweir aFormula +=')'; 1259*cdf0e10cSrcweir xub_StrLen nFStart = pData->GetFStart(); 1260*cdf0e10cSrcweir 1261*cdf0e10cSrcweir DeleteArgs(); 1262*cdf0e10cSrcweir 1263*cdf0e10cSrcweir nArgs = pFuncDesc->getSuppressedArgumentCount(); 1264*cdf0e10cSrcweir 1265*cdf0e10cSrcweir sal_Int32 nArgPos=m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 ); 1266*cdf0e10cSrcweir m_aFormulaHelper.GetArgStrings(m_aArguments,aFormula, nFStart, nArgs ); 1267*cdf0e10cSrcweir // m_aArguments = ScFormulaUtil::GetArgStrings( aFormula, nFStart, nArgs ); 1268*cdf0e10cSrcweir 1269*cdf0e10cSrcweir sal_uInt16 nActiv=pParaWin->GetSliderPos(); 1270*cdf0e10cSrcweir sal_Bool bFlag=sal_False; 1271*cdf0e10cSrcweir ::std::vector< ::rtl::OUString >::iterator aIter = m_aArguments.begin(); 1272*cdf0e10cSrcweir ::std::vector< ::rtl::OUString >::iterator aEnd = m_aArguments.end(); 1273*cdf0e10cSrcweir for(sal_uInt16 i=0;aIter != aEnd;i++,++aIter) 1274*cdf0e10cSrcweir { 1275*cdf0e10cSrcweir sal_Int32 nLength=(*aIter).getLength(); 1276*cdf0e10cSrcweir pParaWin->SetArgument(i,(*aIter)); 1277*cdf0e10cSrcweir if(nArgPos<=nEditPos && nEditPos<nArgPos+nLength) 1278*cdf0e10cSrcweir { 1279*cdf0e10cSrcweir nActiv=i; 1280*cdf0e10cSrcweir bFlag=sal_True; 1281*cdf0e10cSrcweir } 1282*cdf0e10cSrcweir nArgPos+=nLength+1; 1283*cdf0e10cSrcweir } 1284*cdf0e10cSrcweir 1285*cdf0e10cSrcweir if(bFlag) 1286*cdf0e10cSrcweir { 1287*cdf0e10cSrcweir pParaWin->SetSliderPos(nActiv); 1288*cdf0e10cSrcweir } 1289*cdf0e10cSrcweir 1290*cdf0e10cSrcweir pParaWin->UpdateParas(); 1291*cdf0e10cSrcweir UpdateValues(); 1292*cdf0e10cSrcweir } 1293*cdf0e10cSrcweir 1294*cdf0e10cSrcweir } 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir void FormulaDlg_Impl::SaveArg( sal_uInt16 nEd ) 1297*cdf0e10cSrcweir { 1298*cdf0e10cSrcweir if (nEd<nArgs) 1299*cdf0e10cSrcweir { 1300*cdf0e10cSrcweir sal_uInt16 i; 1301*cdf0e10cSrcweir for(i=0;i<=nEd;i++) 1302*cdf0e10cSrcweir { 1303*cdf0e10cSrcweir if ( m_aArguments[i].getLength() == 0 ) 1304*cdf0e10cSrcweir m_aArguments[i] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")); 1305*cdf0e10cSrcweir } 1306*cdf0e10cSrcweir if(pParaWin->GetArgument(nEd).Len()!=0) 1307*cdf0e10cSrcweir m_aArguments[nEd] = pParaWin->GetArgument(nEd); 1308*cdf0e10cSrcweir 1309*cdf0e10cSrcweir sal_uInt16 nClearPos=nEd+1; 1310*cdf0e10cSrcweir for(i=nEd+1;i<nArgs;i++) 1311*cdf0e10cSrcweir { 1312*cdf0e10cSrcweir if(pParaWin->GetArgument(i).Len()!=0) 1313*cdf0e10cSrcweir { 1314*cdf0e10cSrcweir nClearPos=i+1; 1315*cdf0e10cSrcweir } 1316*cdf0e10cSrcweir } 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir for(i=nClearPos;i<nArgs;i++) 1319*cdf0e10cSrcweir { 1320*cdf0e10cSrcweir m_aArguments[i] = ::rtl::OUString(); 1321*cdf0e10cSrcweir } 1322*cdf0e10cSrcweir } 1323*cdf0e10cSrcweir } 1324*cdf0e10cSrcweir 1325*cdf0e10cSrcweir IMPL_LINK( FormulaDlg_Impl, FxHdl, ParaWin*, pPtr ) 1326*cdf0e10cSrcweir { 1327*cdf0e10cSrcweir if(pPtr==pParaWin) 1328*cdf0e10cSrcweir { 1329*cdf0e10cSrcweir aBtnForward.Enable(sal_True); //@ Damit eine neue Fkt eingegeben werden kann. 1330*cdf0e10cSrcweir aTabCtrl.SetCurPageId(TP_FUNCTION); 1331*cdf0e10cSrcweir 1332*cdf0e10cSrcweir String aUndoStr = m_pHelper->getCurrentFormula(); // bevor unten ein ";" eingefuegt wird 1333*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1334*cdf0e10cSrcweir if (!pData) return 0; 1335*cdf0e10cSrcweir 1336*cdf0e10cSrcweir sal_uInt16 nArgNo = pParaWin->GetActiveLine(); 1337*cdf0e10cSrcweir nEdFocus=nArgNo; 1338*cdf0e10cSrcweir 1339*cdf0e10cSrcweir SaveArg(nArgNo); 1340*cdf0e10cSrcweir UpdateSelection(); 1341*cdf0e10cSrcweir 1342*cdf0e10cSrcweir xub_StrLen nFormulaStrPos = pData->GetFStart(); 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir String aFormula = m_pHelper->getCurrentFormula(); 1345*cdf0e10cSrcweir xub_StrLen n1 = m_aFormulaHelper.GetArgStart( aFormula, nFormulaStrPos, nEdFocus+pData->GetOffset() ); 1346*cdf0e10cSrcweir 1347*cdf0e10cSrcweir pData->SetEdFocus( nEdFocus ); 1348*cdf0e10cSrcweir pData->SaveValues(); 1349*cdf0e10cSrcweir pData->SetMode( (sal_uInt16) FORMULA_FORMDLG_FORMULA ); 1350*cdf0e10cSrcweir pData->SetFStart( n1 ); 1351*cdf0e10cSrcweir pData->SetUndoStr( aUndoStr ); 1352*cdf0e10cSrcweir ClearAllParas(); 1353*cdf0e10cSrcweir 1354*cdf0e10cSrcweir FillDialog(sal_False); 1355*cdf0e10cSrcweir pFuncPage->SetFocus(); //Da Parawin nicht mehr sichtbar 1356*cdf0e10cSrcweir } 1357*cdf0e10cSrcweir return 0; 1358*cdf0e10cSrcweir } 1359*cdf0e10cSrcweir 1360*cdf0e10cSrcweir IMPL_LINK( FormulaDlg_Impl, ModifyHdl, ParaWin*, pPtr ) 1361*cdf0e10cSrcweir { 1362*cdf0e10cSrcweir if(pPtr==pParaWin) 1363*cdf0e10cSrcweir { 1364*cdf0e10cSrcweir SaveArg(pParaWin->GetActiveLine()); 1365*cdf0e10cSrcweir UpdateValues(); 1366*cdf0e10cSrcweir 1367*cdf0e10cSrcweir UpdateSelection(); 1368*cdf0e10cSrcweir CalcStruct(pMEdit->GetText()); 1369*cdf0e10cSrcweir } 1370*cdf0e10cSrcweir return 0; 1371*cdf0e10cSrcweir } 1372*cdf0e10cSrcweir 1373*cdf0e10cSrcweir IMPL_LINK( FormulaDlg_Impl, FormulaHdl, MultiLineEdit*, EMPTYARG ) 1374*cdf0e10cSrcweir { 1375*cdf0e10cSrcweir 1376*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1377*cdf0e10cSrcweir if (!pData) return 0; 1378*cdf0e10cSrcweir 1379*cdf0e10cSrcweir bEditFlag=sal_True; 1380*cdf0e10cSrcweir String aInputFormula=m_pHelper->getCurrentFormula(); 1381*cdf0e10cSrcweir String aString=pMEdit->GetText(); 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir Selection aSel =pMEdit->GetSelection(); 1384*cdf0e10cSrcweir xub_StrLen nTest=0; 1385*cdf0e10cSrcweir 1386*cdf0e10cSrcweir if(aString.Len()==0) //falls alles geloescht wurde 1387*cdf0e10cSrcweir { 1388*cdf0e10cSrcweir aString +='='; 1389*cdf0e10cSrcweir pMEdit->SetText(aString); 1390*cdf0e10cSrcweir aSel .Min()=1; 1391*cdf0e10cSrcweir aSel .Max()=1; 1392*cdf0e10cSrcweir pMEdit->SetSelection(aSel); 1393*cdf0e10cSrcweir } 1394*cdf0e10cSrcweir else if(aString.GetChar(nTest)!='=') //falls ersetzt wurde; 1395*cdf0e10cSrcweir { 1396*cdf0e10cSrcweir aString.Insert( (sal_Unicode)'=', 0 ); 1397*cdf0e10cSrcweir pMEdit->SetText(aString); 1398*cdf0e10cSrcweir aSel .Min()+=1; 1399*cdf0e10cSrcweir aSel .Max()+=1; 1400*cdf0e10cSrcweir pMEdit->SetSelection(aSel); 1401*cdf0e10cSrcweir } 1402*cdf0e10cSrcweir 1403*cdf0e10cSrcweir 1404*cdf0e10cSrcweir m_pHelper->setSelection(0, aInputFormula.Len()); 1405*cdf0e10cSrcweir m_pHelper->setCurrentFormula(aString); 1406*cdf0e10cSrcweir m_pHelper->setSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max()); 1407*cdf0e10cSrcweir 1408*cdf0e10cSrcweir xub_StrLen nPos=(xub_StrLen)aSel.Min()-1; 1409*cdf0e10cSrcweir 1410*cdf0e10cSrcweir String aStrResult; 1411*cdf0e10cSrcweir 1412*cdf0e10cSrcweir if ( CalcValue(m_pHelper->getCurrentFormula(), aStrResult ) ) 1413*cdf0e10cSrcweir aWndFormResult.SetValue( aStrResult ); 1414*cdf0e10cSrcweir else 1415*cdf0e10cSrcweir { 1416*cdf0e10cSrcweir aStrResult.Erase(); 1417*cdf0e10cSrcweir aWndFormResult.SetValue( aStrResult ); 1418*cdf0e10cSrcweir } 1419*cdf0e10cSrcweir CalcStruct(aString); 1420*cdf0e10cSrcweir 1421*cdf0e10cSrcweir nPos=GetFunctionPos(nPos); 1422*cdf0e10cSrcweir 1423*cdf0e10cSrcweir if(nPos<aSel.Min()-1) 1424*cdf0e10cSrcweir { 1425*cdf0e10cSrcweir xub_StrLen nPos1=aString.Search('(',nPos); 1426*cdf0e10cSrcweir EditNextFunc( sal_False, nPos1); 1427*cdf0e10cSrcweir } 1428*cdf0e10cSrcweir else 1429*cdf0e10cSrcweir { 1430*cdf0e10cSrcweir ClearAllParas(); 1431*cdf0e10cSrcweir } 1432*cdf0e10cSrcweir 1433*cdf0e10cSrcweir m_pHelper->setSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max()); 1434*cdf0e10cSrcweir bEditFlag=sal_False; 1435*cdf0e10cSrcweir return 0; 1436*cdf0e10cSrcweir } 1437*cdf0e10cSrcweir 1438*cdf0e10cSrcweir IMPL_LINK( FormulaDlg_Impl, FormulaCursorHdl, EditBox*, EMPTYARG ) 1439*cdf0e10cSrcweir { 1440*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1441*cdf0e10cSrcweir if (!pData) return 0; 1442*cdf0e10cSrcweir xub_StrLen nFStart = pData->GetFStart(); 1443*cdf0e10cSrcweir 1444*cdf0e10cSrcweir bEditFlag=sal_True; 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir String aInputFormula=m_pHelper->getCurrentFormula(); 1447*cdf0e10cSrcweir String aString=pMEdit->GetText(); 1448*cdf0e10cSrcweir 1449*cdf0e10cSrcweir Selection aSel =pMEdit->GetSelection(); 1450*cdf0e10cSrcweir m_pHelper->setSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max()); 1451*cdf0e10cSrcweir 1452*cdf0e10cSrcweir if(aSel.Min()==0) 1453*cdf0e10cSrcweir { 1454*cdf0e10cSrcweir aSel.Min()=1; 1455*cdf0e10cSrcweir pMEdit->SetSelection(aSel); 1456*cdf0e10cSrcweir } 1457*cdf0e10cSrcweir 1458*cdf0e10cSrcweir if(aSel.Min()!=aString.Len()) 1459*cdf0e10cSrcweir { 1460*cdf0e10cSrcweir xub_StrLen nPos=(xub_StrLen)aSel.Min(); 1461*cdf0e10cSrcweir 1462*cdf0e10cSrcweir nFStart=GetFunctionPos(nPos - 1); 1463*cdf0e10cSrcweir 1464*cdf0e10cSrcweir if(nFStart<nPos) 1465*cdf0e10cSrcweir { 1466*cdf0e10cSrcweir xub_StrLen nPos1=m_aFormulaHelper.GetFunctionEnd(aString,nFStart); 1467*cdf0e10cSrcweir 1468*cdf0e10cSrcweir if(nPos1>nPos || nPos1==STRING_NOTFOUND) 1469*cdf0e10cSrcweir { 1470*cdf0e10cSrcweir EditThisFunc(nFStart); 1471*cdf0e10cSrcweir } 1472*cdf0e10cSrcweir else 1473*cdf0e10cSrcweir { 1474*cdf0e10cSrcweir xub_StrLen n=nPos; 1475*cdf0e10cSrcweir short nCount=1; 1476*cdf0e10cSrcweir while(n>0) 1477*cdf0e10cSrcweir { 1478*cdf0e10cSrcweir if(aString.GetChar(n)==')') 1479*cdf0e10cSrcweir nCount++; 1480*cdf0e10cSrcweir else if(aString.GetChar(n)=='(') 1481*cdf0e10cSrcweir nCount--; 1482*cdf0e10cSrcweir if(nCount==0) break; 1483*cdf0e10cSrcweir n--; 1484*cdf0e10cSrcweir } 1485*cdf0e10cSrcweir if(nCount==0) 1486*cdf0e10cSrcweir { 1487*cdf0e10cSrcweir nFStart=m_aFormulaHelper.GetFunctionStart(aString,n,sal_True); 1488*cdf0e10cSrcweir EditThisFunc(nFStart); 1489*cdf0e10cSrcweir } 1490*cdf0e10cSrcweir else 1491*cdf0e10cSrcweir { 1492*cdf0e10cSrcweir ClearAllParas(); 1493*cdf0e10cSrcweir } 1494*cdf0e10cSrcweir } 1495*cdf0e10cSrcweir } 1496*cdf0e10cSrcweir else 1497*cdf0e10cSrcweir { 1498*cdf0e10cSrcweir ClearAllParas(); 1499*cdf0e10cSrcweir } 1500*cdf0e10cSrcweir } 1501*cdf0e10cSrcweir m_pHelper->setSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max()); 1502*cdf0e10cSrcweir 1503*cdf0e10cSrcweir bEditFlag=sal_False; 1504*cdf0e10cSrcweir return 0; 1505*cdf0e10cSrcweir } 1506*cdf0e10cSrcweir 1507*cdf0e10cSrcweir void FormulaDlg_Impl::UpdateSelection() 1508*cdf0e10cSrcweir { 1509*cdf0e10cSrcweir m_pHelper->setSelection((xub_StrLen)aFuncSel.Min(),(xub_StrLen)aFuncSel.Max()); 1510*cdf0e10cSrcweir m_pHelper->setCurrentFormula( pFuncDesc->getFormula( m_aArguments ) ); 1511*cdf0e10cSrcweir pMEdit->SetText(m_pHelper->getCurrentFormula()); 1512*cdf0e10cSrcweir xub_StrLen PrivStart, PrivEnd; 1513*cdf0e10cSrcweir m_pHelper->getSelection( PrivStart, PrivEnd); 1514*cdf0e10cSrcweir aFuncSel.Min()=PrivStart; 1515*cdf0e10cSrcweir aFuncSel.Max()=PrivEnd; 1516*cdf0e10cSrcweir 1517*cdf0e10cSrcweir nArgs = pFuncDesc->getSuppressedArgumentCount(); 1518*cdf0e10cSrcweir 1519*cdf0e10cSrcweir String aFormula=pMEdit->GetText(); 1520*cdf0e10cSrcweir sal_Int32 nArgPos=m_aFormulaHelper.GetArgStart( aFormula,PrivStart,0); 1521*cdf0e10cSrcweir 1522*cdf0e10cSrcweir sal_uInt16 nPos=pParaWin->GetActiveLine(); 1523*cdf0e10cSrcweir 1524*cdf0e10cSrcweir for(sal_uInt16 i=0;i<nPos;i++) 1525*cdf0e10cSrcweir { 1526*cdf0e10cSrcweir nArgPos += (m_aArguments[i].getLength() + 1); 1527*cdf0e10cSrcweir } 1528*cdf0e10cSrcweir sal_Int32 nLength= m_aArguments[nPos].getLength(); 1529*cdf0e10cSrcweir 1530*cdf0e10cSrcweir Selection aSel(nArgPos,nArgPos+nLength); 1531*cdf0e10cSrcweir m_pHelper->setSelection((sal_uInt16)nArgPos,(sal_uInt16)(nArgPos+nLength)); 1532*cdf0e10cSrcweir pMEdit->SetSelection(aSel); 1533*cdf0e10cSrcweir aMEFormula.UpdateOldSel(); 1534*cdf0e10cSrcweir } 1535*cdf0e10cSrcweir ::std::pair<RefButton*,RefEdit*> FormulaDlg_Impl::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ) 1536*cdf0e10cSrcweir { 1537*cdf0e10cSrcweir aEdRef.Show(); 1538*cdf0e10cSrcweir pTheRefEdit = pEdit; 1539*cdf0e10cSrcweir pTheRefButton = pButton; 1540*cdf0e10cSrcweir 1541*cdf0e10cSrcweir if( pTheRefEdit ) 1542*cdf0e10cSrcweir { 1543*cdf0e10cSrcweir aEdRef.SetRefString( pTheRefEdit->GetText() ); 1544*cdf0e10cSrcweir aEdRef.SetSelection( pTheRefEdit->GetSelection() ); 1545*cdf0e10cSrcweir aEdRef.SetHelpId( pTheRefEdit->GetHelpId() ); 1546*cdf0e10cSrcweir aEdRef.SetUniqueId( pTheRefEdit->GetUniqueId() ); 1547*cdf0e10cSrcweir } 1548*cdf0e10cSrcweir 1549*cdf0e10cSrcweir aRefBtn.Show( pButton != NULL ); 1550*cdf0e10cSrcweir 1551*cdf0e10cSrcweir //m_pHelper->RefInputStart( &aEdRef, pButton ? &aRefBtn : NULL ); 1552*cdf0e10cSrcweir ::std::pair<RefButton*,RefEdit*> aPair; 1553*cdf0e10cSrcweir aPair.first = pButton ? &aRefBtn : NULL; 1554*cdf0e10cSrcweir aPair.second = &aEdRef; 1555*cdf0e10cSrcweir return aPair; 1556*cdf0e10cSrcweir } 1557*cdf0e10cSrcweir void FormulaDlg_Impl::RefInputStartAfter( RefEdit* /*pEdit*/, RefButton* /*pButton*/ ) 1558*cdf0e10cSrcweir { 1559*cdf0e10cSrcweir aRefBtn.SetEndImage(); 1560*cdf0e10cSrcweir 1561*cdf0e10cSrcweir if( pTheRefEdit ) 1562*cdf0e10cSrcweir { 1563*cdf0e10cSrcweir String aStr = aTitle2; 1564*cdf0e10cSrcweir aStr += ' '; 1565*cdf0e10cSrcweir aStr += aFtEditName.GetText(); 1566*cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "( " ) ); 1567*cdf0e10cSrcweir if( pParaWin->GetActiveLine() > 0 ) 1568*cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "...; " ) ); 1569*cdf0e10cSrcweir aStr += pParaWin->GetActiveArgName(); 1570*cdf0e10cSrcweir if( pParaWin->GetActiveLine() + 1 < nArgs ) 1571*cdf0e10cSrcweir aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "; ..." )); 1572*cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " )" ) ); 1573*cdf0e10cSrcweir 1574*cdf0e10cSrcweir m_pParent->SetText( MnemonicGenerator::EraseAllMnemonicChars( aStr ) ); 1575*cdf0e10cSrcweir } 1576*cdf0e10cSrcweir } 1577*cdf0e10cSrcweir void FormulaDlg_Impl::RefInputDoneAfter( sal_Bool bForced ) 1578*cdf0e10cSrcweir { 1579*cdf0e10cSrcweir aRefBtn.SetStartImage(); 1580*cdf0e10cSrcweir if( bForced || !aRefBtn.IsVisible() ) 1581*cdf0e10cSrcweir { 1582*cdf0e10cSrcweir aEdRef.Hide(); 1583*cdf0e10cSrcweir aRefBtn.Hide(); 1584*cdf0e10cSrcweir if( pTheRefEdit ) 1585*cdf0e10cSrcweir { 1586*cdf0e10cSrcweir pTheRefEdit->SetRefString( aEdRef.GetText() ); 1587*cdf0e10cSrcweir pTheRefEdit->GrabFocus(); 1588*cdf0e10cSrcweir 1589*cdf0e10cSrcweir if( pTheRefButton ) 1590*cdf0e10cSrcweir pTheRefButton->SetStartImage(); 1591*cdf0e10cSrcweir 1592*cdf0e10cSrcweir sal_uInt16 nPrivActiv = pParaWin->GetActiveLine(); 1593*cdf0e10cSrcweir pParaWin->SetArgument( nPrivActiv, aEdRef.GetText() ); 1594*cdf0e10cSrcweir ModifyHdl( pParaWin ); 1595*cdf0e10cSrcweir pTheRefEdit = NULL; 1596*cdf0e10cSrcweir } 1597*cdf0e10cSrcweir m_pParent->SetText( aTitle1 ); 1598*cdf0e10cSrcweir } 1599*cdf0e10cSrcweir } 1600*cdf0e10cSrcweir RefEdit* FormulaDlg_Impl::GetCurrRefEdit() 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir return aEdRef.IsVisible() ? &aEdRef : pParaWin->GetActiveEdit(); 1603*cdf0e10cSrcweir } 1604*cdf0e10cSrcweir void FormulaDlg_Impl::Update() 1605*cdf0e10cSrcweir { 1606*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1607*cdf0e10cSrcweir const String sExpression = pMEdit->GetText(); 1608*cdf0e10cSrcweir aOldFormula = String(); 1609*cdf0e10cSrcweir UpdateTokenArray(sExpression); 1610*cdf0e10cSrcweir FormulaCursorHdl(&aMEFormula); 1611*cdf0e10cSrcweir CalcStruct(sExpression); 1612*cdf0e10cSrcweir if(pData->GetMode() == FORMULA_FORMDLG_FORMULA) 1613*cdf0e10cSrcweir aTabCtrl.SetCurPageId(TP_FUNCTION); 1614*cdf0e10cSrcweir else 1615*cdf0e10cSrcweir aTabCtrl.SetCurPageId(TP_STRUCT); 1616*cdf0e10cSrcweir aBtnMatrix.Check(pData->GetMatrixFlag()); 1617*cdf0e10cSrcweir /*aTimer.SetTimeout(200); 1618*cdf0e10cSrcweir aTimer.SetTimeoutHdl(LINK( this, FormulaDlg_Impl, UpdateFocusHdl)); 1619*cdf0e10cSrcweir aTimer.Start();*/ 1620*cdf0e10cSrcweir } 1621*cdf0e10cSrcweir void FormulaDlg_Impl::Update(const String& _sExp) 1622*cdf0e10cSrcweir { 1623*cdf0e10cSrcweir CalcStruct(_sExp); 1624*cdf0e10cSrcweir FillDialog(); 1625*cdf0e10cSrcweir //aBtnForward.Enable(sal_True); //@New 1626*cdf0e10cSrcweir FuncSelHdl(NULL); 1627*cdf0e10cSrcweir } 1628*cdf0e10cSrcweir void FormulaDlg_Impl::SetMeText(const String& _sText) 1629*cdf0e10cSrcweir { 1630*cdf0e10cSrcweir FormEditData* pData = m_pHelper->getFormEditData(); 1631*cdf0e10cSrcweir pMEdit->SetText(_sText); 1632*cdf0e10cSrcweir pMEdit->SetSelection( pData->GetSelection()); 1633*cdf0e10cSrcweir aMEFormula.UpdateOldSel(); 1634*cdf0e10cSrcweir } 1635*cdf0e10cSrcweir FormulaDlgMode FormulaDlg_Impl::SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,sal_Bool bMatrix,sal_Bool _bSelect,sal_Bool _bUpdate) 1636*cdf0e10cSrcweir { 1637*cdf0e10cSrcweir FormulaDlgMode eMode = FORMULA_FORMDLG_FORMULA; 1638*cdf0e10cSrcweir if(!bEditFlag) 1639*cdf0e10cSrcweir pMEdit->SetText(_sText); 1640*cdf0e10cSrcweir 1641*cdf0e10cSrcweir if ( _bSelect || !bEditFlag ) 1642*cdf0e10cSrcweir pMEdit->SetSelection( Selection(PrivStart, PrivEnd)); 1643*cdf0e10cSrcweir if ( _bUpdate ) 1644*cdf0e10cSrcweir { 1645*cdf0e10cSrcweir aMEFormula.UpdateOldSel(); 1646*cdf0e10cSrcweir pMEdit->Invalidate(); 1647*cdf0e10cSrcweir m_pHelper->showReference(pMEdit->GetSelected()); 1648*cdf0e10cSrcweir eMode = FORMULA_FORMDLG_EDIT; 1649*cdf0e10cSrcweir 1650*cdf0e10cSrcweir aBtnMatrix.Check( bMatrix ); 1651*cdf0e10cSrcweir } // if ( _bUpdate ) 1652*cdf0e10cSrcweir return eMode; 1653*cdf0e10cSrcweir } 1654*cdf0e10cSrcweir sal_Bool FormulaDlg_Impl::CheckMatrix(String& aFormula) 1655*cdf0e10cSrcweir { 1656*cdf0e10cSrcweir pMEdit->GrabFocus(); 1657*cdf0e10cSrcweir xub_StrLen nLen = aFormula.Len(); 1658*cdf0e10cSrcweir sal_Bool bMatrix = nLen > 3 // Matrix-Formel ? 1659*cdf0e10cSrcweir && aFormula.GetChar(0) == '{' 1660*cdf0e10cSrcweir && aFormula.GetChar(1) == '=' 1661*cdf0e10cSrcweir && aFormula.GetChar(nLen-1) == '}'; 1662*cdf0e10cSrcweir if ( bMatrix ) 1663*cdf0e10cSrcweir { 1664*cdf0e10cSrcweir aFormula.Erase( 0, 1 ); 1665*cdf0e10cSrcweir aFormula.Erase( aFormula.Len()-1, 1); 1666*cdf0e10cSrcweir aBtnMatrix.Check( bMatrix ); 1667*cdf0e10cSrcweir aBtnMatrix.Disable(); 1668*cdf0e10cSrcweir } // if ( bMatrix ) 1669*cdf0e10cSrcweir 1670*cdf0e10cSrcweir aTabCtrl.SetCurPageId(TP_STRUCT); 1671*cdf0e10cSrcweir return bMatrix; 1672*cdf0e10cSrcweir } 1673*cdf0e10cSrcweir IMPL_LINK( FormulaDlg_Impl, StructSelHdl, StructPage*, pStruP ) 1674*cdf0e10cSrcweir { 1675*cdf0e10cSrcweir bStructUpdate=sal_False; 1676*cdf0e10cSrcweir if(pStructPage->IsVisible()) aBtnForward.Enable(sal_False); //@New 1677*cdf0e10cSrcweir 1678*cdf0e10cSrcweir if(pStructPage==pStruP) 1679*cdf0e10cSrcweir { 1680*cdf0e10cSrcweir /// TODO 1681*cdf0e10cSrcweir //ScToken* pSelToken = pStructPage->GetSelectedToken(); 1682*cdf0e10cSrcweir // ScToken* pOrigToken = ((pSelToken && pSelToken->GetType() == svFAP) ? 1683*cdf0e10cSrcweir // pSelToken->GetFAPOrigToken() : pSelToken); 1684*cdf0e10cSrcweir //xub_StrLen nTokPos=1; 1685*cdf0e10cSrcweir 1686*cdf0e10cSrcweir //if(pScTokA!=NULL) 1687*cdf0e10cSrcweir //{ 1688*cdf0e10cSrcweir // ScToken* pToken = pScTokA->First(); 1689*cdf0e10cSrcweir 1690*cdf0e10cSrcweir // while(pToken!=NULL) 1691*cdf0e10cSrcweir // { 1692*cdf0e10cSrcweir // String aString; 1693*cdf0e10cSrcweir // if ( pToken == pOrigToken ) 1694*cdf0e10cSrcweir // break; 1695*cdf0e10cSrcweir // pComp->CreateStringFromToken( aString,pToken); 1696*cdf0e10cSrcweir // nTokPos = sal::static_int_cast<xub_StrLen>( nTokPos + aString.Len() ); 1697*cdf0e10cSrcweir // pToken=pScTokA->Next(); 1698*cdf0e10cSrcweir // } 1699*cdf0e10cSrcweir // EditThisFunc(nTokPos); 1700*cdf0e10cSrcweir //} 1701*cdf0e10cSrcweir 1702*cdf0e10cSrcweir //if( pOrigToken ) 1703*cdf0e10cSrcweir //{ 1704*cdf0e10cSrcweir // String aStr; 1705*cdf0e10cSrcweir // pComp->CreateStringFromToken( aStr, pOrigToken ); 1706*cdf0e10cSrcweir // String aEntryTxt=pStructPage->GetSelectedEntryText(); 1707*cdf0e10cSrcweir 1708*cdf0e10cSrcweir // if(aEntryTxt!=aStr) 1709*cdf0e10cSrcweir // ShowReference(aEntryTxt); 1710*cdf0e10cSrcweir //} 1711*cdf0e10cSrcweir 1712*cdf0e10cSrcweir } 1713*cdf0e10cSrcweir bStructUpdate=sal_True; 1714*cdf0e10cSrcweir return 0; 1715*cdf0e10cSrcweir } 1716*cdf0e10cSrcweir IMPL_LINK( FormulaDlg_Impl, MatrixHdl, CheckBox *, EMPTYARG ) 1717*cdf0e10cSrcweir { 1718*cdf0e10cSrcweir bUserMatrixFlag=sal_True; 1719*cdf0e10cSrcweir return 0; 1720*cdf0e10cSrcweir } 1721*cdf0e10cSrcweir 1722*cdf0e10cSrcweir IMPL_LINK( FormulaDlg_Impl, FuncSelHdl, FuncPage*, EMPTYARG ) 1723*cdf0e10cSrcweir { 1724*cdf0e10cSrcweir sal_uInt16 nCat = pFuncPage->GetCategory(); 1725*cdf0e10cSrcweir if ( nCat == LISTBOX_ENTRY_NOTFOUND ) nCat = 0; 1726*cdf0e10cSrcweir sal_uInt16 nFunc = pFuncPage->GetFunction(); 1727*cdf0e10cSrcweir if ( nFunc == LISTBOX_ENTRY_NOTFOUND ) nFunc = 0; 1728*cdf0e10cSrcweir 1729*cdf0e10cSrcweir if ( (pFuncPage->GetFunctionEntryCount() > 0) 1730*cdf0e10cSrcweir && (pFuncPage->GetFunction() != LISTBOX_ENTRY_NOTFOUND) ) 1731*cdf0e10cSrcweir { 1732*cdf0e10cSrcweir const IFunctionDescription* pDesc =pFuncPage->GetFuncDesc( pFuncPage->GetFunction() ); 1733*cdf0e10cSrcweir 1734*cdf0e10cSrcweir if(pDesc!=pFuncDesc) aBtnForward.Enable(sal_True); //new 1735*cdf0e10cSrcweir 1736*cdf0e10cSrcweir if (pDesc) 1737*cdf0e10cSrcweir { 1738*cdf0e10cSrcweir pDesc->initArgumentInfo(); // full argument info is needed 1739*cdf0e10cSrcweir 1740*cdf0e10cSrcweir String aSig = pDesc->getSignature(); 1741*cdf0e10cSrcweir aFtHeadLine.SetText( pDesc->getFunctionName() ); 1742*cdf0e10cSrcweir aFtFuncName.SetText( aSig ); 1743*cdf0e10cSrcweir aFtFuncDesc.SetText( pDesc->getDescription() ); 1744*cdf0e10cSrcweir } 1745*cdf0e10cSrcweir } 1746*cdf0e10cSrcweir else 1747*cdf0e10cSrcweir { 1748*cdf0e10cSrcweir aFtHeadLine.SetText( String() ); 1749*cdf0e10cSrcweir aFtFuncName.SetText( String() ); 1750*cdf0e10cSrcweir aFtFuncDesc.SetText( String() ); 1751*cdf0e10cSrcweir } 1752*cdf0e10cSrcweir return 0; 1753*cdf0e10cSrcweir } 1754*cdf0e10cSrcweir 1755*cdf0e10cSrcweir void FormulaDlg_Impl::UpdateParaWin(const Selection& _rSelection,const String& _sRefStr) 1756*cdf0e10cSrcweir { 1757*cdf0e10cSrcweir Selection theSel = _rSelection; 1758*cdf0e10cSrcweir aEdRef.ReplaceSelected( _sRefStr ); 1759*cdf0e10cSrcweir theSel.Max() = theSel.Min() + _sRefStr.Len(); 1760*cdf0e10cSrcweir aEdRef.SetSelection( theSel ); 1761*cdf0e10cSrcweir 1762*cdf0e10cSrcweir //------------------------------------- 1763*cdf0e10cSrcweir // Manuelles Update der Ergebnisfelder: 1764*cdf0e10cSrcweir //------------------------------------- 1765*cdf0e10cSrcweir sal_uInt16 nPrivActiv = pParaWin->GetActiveLine(); 1766*cdf0e10cSrcweir pParaWin->SetArgument(nPrivActiv,aEdRef.GetText()); 1767*cdf0e10cSrcweir pParaWin->UpdateParas(); 1768*cdf0e10cSrcweir 1769*cdf0e10cSrcweir Edit* pEd = GetCurrRefEdit(); 1770*cdf0e10cSrcweir if( pEd != NULL ) 1771*cdf0e10cSrcweir pEd->SetSelection( theSel ); 1772*cdf0e10cSrcweir 1773*cdf0e10cSrcweir pParaWin->SetRefMode(sal_False); 1774*cdf0e10cSrcweir } 1775*cdf0e10cSrcweir sal_Bool FormulaDlg_Impl::UpdateParaWin(Selection& _rSelection) 1776*cdf0e10cSrcweir { 1777*cdf0e10cSrcweir pParaWin->SetRefMode(sal_True); 1778*cdf0e10cSrcweir 1779*cdf0e10cSrcweir String aStrEd; 1780*cdf0e10cSrcweir Edit* pEd = GetCurrRefEdit(); 1781*cdf0e10cSrcweir if(pEd!=NULL && pTheRefEdit==NULL) 1782*cdf0e10cSrcweir { 1783*cdf0e10cSrcweir _rSelection=pEd->GetSelection(); 1784*cdf0e10cSrcweir _rSelection.Justify(); 1785*cdf0e10cSrcweir aStrEd=pEd->GetText(); 1786*cdf0e10cSrcweir aEdRef.SetRefString(aStrEd); 1787*cdf0e10cSrcweir aEdRef.SetSelection( _rSelection ); 1788*cdf0e10cSrcweir } 1789*cdf0e10cSrcweir else 1790*cdf0e10cSrcweir { 1791*cdf0e10cSrcweir _rSelection=aEdRef.GetSelection(); 1792*cdf0e10cSrcweir _rSelection.Justify(); 1793*cdf0e10cSrcweir aStrEd= aEdRef.GetText(); 1794*cdf0e10cSrcweir } 1795*cdf0e10cSrcweir return pTheRefEdit == NULL; 1796*cdf0e10cSrcweir } 1797*cdf0e10cSrcweir rtl::OString FormulaDlg_Impl::FindFocusWin(Window *pWin) 1798*cdf0e10cSrcweir { 1799*cdf0e10cSrcweir rtl::OString aUniqueId; 1800*cdf0e10cSrcweir if(pWin->HasFocus()) 1801*cdf0e10cSrcweir { 1802*cdf0e10cSrcweir aUniqueId=pWin->GetUniqueId(); 1803*cdf0e10cSrcweir if(aUniqueId.getLength()==0) 1804*cdf0e10cSrcweir { 1805*cdf0e10cSrcweir Window* pParent=pWin->GetParent(); 1806*cdf0e10cSrcweir while(pParent!=NULL) 1807*cdf0e10cSrcweir { 1808*cdf0e10cSrcweir aUniqueId=pParent->GetUniqueId(); 1809*cdf0e10cSrcweir 1810*cdf0e10cSrcweir if(aUniqueId.getLength()!=0) break; 1811*cdf0e10cSrcweir 1812*cdf0e10cSrcweir pParent=pParent->GetParent(); 1813*cdf0e10cSrcweir } 1814*cdf0e10cSrcweir } 1815*cdf0e10cSrcweir } 1816*cdf0e10cSrcweir else 1817*cdf0e10cSrcweir { 1818*cdf0e10cSrcweir sal_uInt16 nCount=pWin->GetChildCount(); 1819*cdf0e10cSrcweir 1820*cdf0e10cSrcweir for(sal_uInt16 i=0;i<nCount;i++) 1821*cdf0e10cSrcweir { 1822*cdf0e10cSrcweir Window* pChild=pWin->GetChild(i); 1823*cdf0e10cSrcweir aUniqueId=FindFocusWin(pChild); 1824*cdf0e10cSrcweir if(aUniqueId.getLength()>0) break; 1825*cdf0e10cSrcweir } 1826*cdf0e10cSrcweir } 1827*cdf0e10cSrcweir return aUniqueId; 1828*cdf0e10cSrcweir } 1829*cdf0e10cSrcweir 1830*cdf0e10cSrcweir void FormulaDlg_Impl::SetEdSelection() 1831*cdf0e10cSrcweir { 1832*cdf0e10cSrcweir Edit* pEd = GetCurrRefEdit()/*aScParaWin.GetActiveEdit()*/; 1833*cdf0e10cSrcweir if( pEd ) 1834*cdf0e10cSrcweir { 1835*cdf0e10cSrcweir Selection theSel = aEdRef.GetSelection(); 1836*cdf0e10cSrcweir // Edit may have the focus -> call ModifyHdl in addition 1837*cdf0e10cSrcweir // to what's happening in GetFocus 1838*cdf0e10cSrcweir pEd->GetModifyHdl().Call(pEd); 1839*cdf0e10cSrcweir pEd->GrabFocus(); 1840*cdf0e10cSrcweir pEd->SetSelection(theSel); 1841*cdf0e10cSrcweir } // if( pEd ) 1842*cdf0e10cSrcweir } 1843*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1844*cdf0e10cSrcweir const FormulaHelper& FormulaDlg_Impl::GetFormulaHelper() const 1845*cdf0e10cSrcweir { 1846*cdf0e10cSrcweir return m_aFormulaHelper; 1847*cdf0e10cSrcweir } 1848*cdf0e10cSrcweir //============================================================================ 1849*cdf0e10cSrcweir FormulaModalDialog::FormulaModalDialog( Window* pParent 1850*cdf0e10cSrcweir , bool _bSupportFunctionResult 1851*cdf0e10cSrcweir , bool _bSupportResult 1852*cdf0e10cSrcweir , bool _bSupportMatrix 1853*cdf0e10cSrcweir , IFormulaEditorHelper* _pHelper 1854*cdf0e10cSrcweir , IFunctionManager* _pFunctionMgr 1855*cdf0e10cSrcweir , IControlReferenceHandler* _pDlg ) : 1856*cdf0e10cSrcweir ModalDialog( pParent, ModuleRes(RID_FORMULADLG_FORMULA_MODAL) ), 1857*cdf0e10cSrcweir m_pImpl( new FormulaDlg_Impl(this,_bSupportFunctionResult 1858*cdf0e10cSrcweir , _bSupportResult 1859*cdf0e10cSrcweir , _bSupportMatrix 1860*cdf0e10cSrcweir ,_pHelper,_pFunctionMgr,_pDlg)) 1861*cdf0e10cSrcweir { 1862*cdf0e10cSrcweir FreeResource(); 1863*cdf0e10cSrcweir SetText(m_pImpl->aTitle1); 1864*cdf0e10cSrcweir } 1865*cdf0e10cSrcweir FormulaModalDialog::~FormulaModalDialog() 1866*cdf0e10cSrcweir { 1867*cdf0e10cSrcweir } 1868*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1869*cdf0e10cSrcweir void FormulaModalDialog::Update(const String& _sExp) 1870*cdf0e10cSrcweir { 1871*cdf0e10cSrcweir m_pImpl->Update(_sExp); 1872*cdf0e10cSrcweir } 1873*cdf0e10cSrcweir 1874*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1875*cdf0e10cSrcweir void FormulaModalDialog::SetMeText(const String& _sText) 1876*cdf0e10cSrcweir { 1877*cdf0e10cSrcweir m_pImpl->SetMeText(_sText); 1878*cdf0e10cSrcweir } 1879*cdf0e10cSrcweir 1880*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1881*cdf0e10cSrcweir FormulaDlgMode FormulaModalDialog::SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,sal_Bool bMatrix,sal_Bool _bSelect,sal_Bool _bUpdate) 1882*cdf0e10cSrcweir { 1883*cdf0e10cSrcweir return m_pImpl->SetMeText(_sText,PrivStart, PrivEnd,bMatrix,_bSelect,_bUpdate); 1884*cdf0e10cSrcweir } 1885*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1886*cdf0e10cSrcweir void FormulaModalDialog::CheckMatrix() 1887*cdf0e10cSrcweir { 1888*cdf0e10cSrcweir m_pImpl->aBtnMatrix.Check(); 1889*cdf0e10cSrcweir } 1890*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1891*cdf0e10cSrcweir sal_Bool FormulaModalDialog::CheckMatrix(String& aFormula) 1892*cdf0e10cSrcweir { 1893*cdf0e10cSrcweir return m_pImpl->CheckMatrix(aFormula); 1894*cdf0e10cSrcweir } 1895*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1896*cdf0e10cSrcweir String FormulaModalDialog::GetMeText() const 1897*cdf0e10cSrcweir { 1898*cdf0e10cSrcweir return m_pImpl->pMEdit->GetText(); 1899*cdf0e10cSrcweir } 1900*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1901*cdf0e10cSrcweir void FormulaModalDialog::Update() 1902*cdf0e10cSrcweir { 1903*cdf0e10cSrcweir m_pImpl->Update(); 1904*cdf0e10cSrcweir } 1905*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1906*cdf0e10cSrcweir const FormulaHelper& FormulaModalDialog::GetFormulaHelper() const 1907*cdf0e10cSrcweir { 1908*cdf0e10cSrcweir return m_pImpl->GetFormulaHelper(); 1909*cdf0e10cSrcweir } 1910*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1911*cdf0e10cSrcweir sal_Bool FormulaModalDialog::isUserMatrix() const 1912*cdf0e10cSrcweir { 1913*cdf0e10cSrcweir return m_pImpl->bUserMatrixFlag; 1914*cdf0e10cSrcweir } 1915*cdf0e10cSrcweir void FormulaModalDialog::DoEnter(sal_Bool _bOk) 1916*cdf0e10cSrcweir { 1917*cdf0e10cSrcweir m_pImpl->DoEnter(_bOk); 1918*cdf0e10cSrcweir } 1919*cdf0e10cSrcweir ::std::pair<RefButton*,RefEdit*> FormulaModalDialog::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ) 1920*cdf0e10cSrcweir { 1921*cdf0e10cSrcweir return m_pImpl->RefInputStartBefore( pEdit, pButton ); 1922*cdf0e10cSrcweir } 1923*cdf0e10cSrcweir void FormulaModalDialog::RefInputStartAfter( RefEdit* pEdit, RefButton* pButton ) 1924*cdf0e10cSrcweir { 1925*cdf0e10cSrcweir m_pImpl->RefInputStartAfter( pEdit, pButton ); 1926*cdf0e10cSrcweir } 1927*cdf0e10cSrcweir void FormulaModalDialog::RefInputDoneAfter( sal_Bool bForced ) 1928*cdf0e10cSrcweir { 1929*cdf0e10cSrcweir m_pImpl->RefInputDoneAfter( bForced ); 1930*cdf0e10cSrcweir } 1931*cdf0e10cSrcweir 1932*cdf0e10cSrcweir rtl::OString FormulaModalDialog::FindFocusWin(Window *pWin) 1933*cdf0e10cSrcweir { 1934*cdf0e10cSrcweir return m_pImpl->FindFocusWin( pWin ); 1935*cdf0e10cSrcweir } 1936*cdf0e10cSrcweir 1937*cdf0e10cSrcweir void FormulaModalDialog::SetFocusWin(Window *pWin,const rtl::OString& nUniqueId) 1938*cdf0e10cSrcweir { 1939*cdf0e10cSrcweir if(pWin->GetUniqueId()==nUniqueId) 1940*cdf0e10cSrcweir { 1941*cdf0e10cSrcweir pWin->GrabFocus(); 1942*cdf0e10cSrcweir } 1943*cdf0e10cSrcweir else 1944*cdf0e10cSrcweir { 1945*cdf0e10cSrcweir sal_uInt16 nCount=pWin->GetChildCount(); 1946*cdf0e10cSrcweir 1947*cdf0e10cSrcweir for(sal_uInt16 i=0;i<nCount;i++) 1948*cdf0e10cSrcweir { 1949*cdf0e10cSrcweir Window* pChild=pWin->GetChild(i); 1950*cdf0e10cSrcweir SetFocusWin(pChild,nUniqueId); 1951*cdf0e10cSrcweir } 1952*cdf0e10cSrcweir } 1953*cdf0e10cSrcweir } 1954*cdf0e10cSrcweir 1955*cdf0e10cSrcweir 1956*cdf0e10cSrcweir long FormulaModalDialog::PreNotify( NotifyEvent& rNEvt ) 1957*cdf0e10cSrcweir { 1958*cdf0e10cSrcweir m_pImpl->PreNotify( rNEvt ); 1959*cdf0e10cSrcweir 1960*cdf0e10cSrcweir return ModalDialog::PreNotify(rNEvt); 1961*cdf0e10cSrcweir } 1962*cdf0e10cSrcweir 1963*cdf0e10cSrcweir void FormulaModalDialog::HighlightFunctionParas(const String& aFormula) 1964*cdf0e10cSrcweir { 1965*cdf0e10cSrcweir m_pImpl->m_pHelper->showReference(aFormula); 1966*cdf0e10cSrcweir } 1967*cdf0e10cSrcweir 1968*cdf0e10cSrcweir void FormulaModalDialog::disableOk() 1969*cdf0e10cSrcweir { 1970*cdf0e10cSrcweir m_pImpl->aBtnEnd.Disable(); 1971*cdf0e10cSrcweir } 1972*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1973*cdf0e10cSrcweir const IFunctionDescription* FormulaModalDialog::getCurrentFunctionDescription() const 1974*cdf0e10cSrcweir { 1975*cdf0e10cSrcweir OSL_VERIFY(!m_pImpl->pFuncDesc || m_pImpl->pFuncDesc->getSuppressedArgumentCount() == m_pImpl->nArgs); 1976*cdf0e10cSrcweir return m_pImpl->pFuncDesc; 1977*cdf0e10cSrcweir } 1978*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1979*cdf0e10cSrcweir void FormulaModalDialog::UpdateParaWin(const Selection& _rSelection,const String& _sRefStr) 1980*cdf0e10cSrcweir { 1981*cdf0e10cSrcweir m_pImpl->UpdateParaWin(_rSelection,_sRefStr); 1982*cdf0e10cSrcweir } 1983*cdf0e10cSrcweir sal_Bool FormulaModalDialog::UpdateParaWin(Selection& _rSelection) 1984*cdf0e10cSrcweir { 1985*cdf0e10cSrcweir return m_pImpl->UpdateParaWin(_rSelection); 1986*cdf0e10cSrcweir } 1987*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1988*cdf0e10cSrcweir RefEdit* FormulaModalDialog::GetActiveEdit() 1989*cdf0e10cSrcweir { 1990*cdf0e10cSrcweir return m_pImpl->pParaWin->GetActiveEdit(); 1991*cdf0e10cSrcweir } 1992*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1993*cdf0e10cSrcweir void FormulaModalDialog::SetEdSelection() 1994*cdf0e10cSrcweir { 1995*cdf0e10cSrcweir m_pImpl->SetEdSelection(); 1996*cdf0e10cSrcweir } 1997*cdf0e10cSrcweir 1998*cdf0e10cSrcweir // -------------------------------------------------------------------------- 1999*cdf0e10cSrcweir // Initialisierung / gemeinsaME Funktionen fuer Dialog 2000*cdf0e10cSrcweir // -------------------------------------------------------------------------- 2001*cdf0e10cSrcweir FormulaDlg::FormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, 2002*cdf0e10cSrcweir Window* pParent 2003*cdf0e10cSrcweir , bool _bSupportFunctionResult 2004*cdf0e10cSrcweir , bool _bSupportResult 2005*cdf0e10cSrcweir , bool _bSupportMatrix 2006*cdf0e10cSrcweir , IFormulaEditorHelper* _pHelper,IFunctionManager* _pFunctionMgr,IControlReferenceHandler* _pDlg ) : 2007*cdf0e10cSrcweir SfxModelessDialog( pB, pCW, pParent, ModuleRes(RID_FORMULADLG_FORMULA) ), 2008*cdf0e10cSrcweir m_pImpl( new FormulaDlg_Impl(this, _bSupportFunctionResult 2009*cdf0e10cSrcweir , _bSupportResult 2010*cdf0e10cSrcweir , _bSupportMatrix 2011*cdf0e10cSrcweir ,_pHelper,_pFunctionMgr,_pDlg)) 2012*cdf0e10cSrcweir { 2013*cdf0e10cSrcweir FreeResource(); 2014*cdf0e10cSrcweir if(!GetHelpId().getLength()) //Hack, da im SfxModelessDialog die HelpId 2015*cdf0e10cSrcweir SetHelpId(GetUniqueId()); //fuer einen ModelessDialog entfernt und 2016*cdf0e10cSrcweir //in eine UniqueId gewandelt wird, machen 2017*cdf0e10cSrcweir //wir das an dieser Stelle rueckgaengig. 2018*cdf0e10cSrcweir SetText(m_pImpl->aTitle1); 2019*cdf0e10cSrcweir } 2020*cdf0e10cSrcweir 2021*cdf0e10cSrcweir FormulaDlg::~FormulaDlg() 2022*cdf0e10cSrcweir { 2023*cdf0e10cSrcweir } 2024*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2025*cdf0e10cSrcweir void FormulaDlg::Update(const String& _sExp) 2026*cdf0e10cSrcweir { 2027*cdf0e10cSrcweir m_pImpl->Update(_sExp); 2028*cdf0e10cSrcweir } 2029*cdf0e10cSrcweir 2030*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2031*cdf0e10cSrcweir void FormulaDlg::SetMeText(const String& _sText) 2032*cdf0e10cSrcweir { 2033*cdf0e10cSrcweir m_pImpl->SetMeText(_sText); 2034*cdf0e10cSrcweir } 2035*cdf0e10cSrcweir 2036*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2037*cdf0e10cSrcweir FormulaDlgMode FormulaDlg::SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,sal_Bool bMatrix,sal_Bool _bSelect,sal_Bool _bUpdate) 2038*cdf0e10cSrcweir { 2039*cdf0e10cSrcweir return m_pImpl->SetMeText(_sText,PrivStart, PrivEnd,bMatrix,_bSelect,_bUpdate); 2040*cdf0e10cSrcweir } 2041*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2042*cdf0e10cSrcweir void FormulaDlg::CheckMatrix() 2043*cdf0e10cSrcweir { 2044*cdf0e10cSrcweir m_pImpl->aBtnMatrix.Check(); 2045*cdf0e10cSrcweir } 2046*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2047*cdf0e10cSrcweir sal_Bool FormulaDlg::CheckMatrix(String& aFormula) 2048*cdf0e10cSrcweir { 2049*cdf0e10cSrcweir return m_pImpl->CheckMatrix(aFormula); 2050*cdf0e10cSrcweir } 2051*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2052*cdf0e10cSrcweir String FormulaDlg::GetMeText() const 2053*cdf0e10cSrcweir { 2054*cdf0e10cSrcweir return m_pImpl->pMEdit->GetText(); 2055*cdf0e10cSrcweir } 2056*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2057*cdf0e10cSrcweir void FormulaDlg::Update() 2058*cdf0e10cSrcweir { 2059*cdf0e10cSrcweir m_pImpl->Update(); 2060*cdf0e10cSrcweir m_pImpl->aTimer.SetTimeout(200); 2061*cdf0e10cSrcweir m_pImpl->aTimer.SetTimeoutHdl(LINK( this, FormulaDlg, UpdateFocusHdl)); 2062*cdf0e10cSrcweir m_pImpl->aTimer.Start(); 2063*cdf0e10cSrcweir } 2064*cdf0e10cSrcweir 2065*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2066*cdf0e10cSrcweir sal_Bool FormulaDlg::isUserMatrix() const 2067*cdf0e10cSrcweir { 2068*cdf0e10cSrcweir return m_pImpl->bUserMatrixFlag; 2069*cdf0e10cSrcweir } 2070*cdf0e10cSrcweir void FormulaDlg::DoEnter(sal_Bool _bOk) 2071*cdf0e10cSrcweir { 2072*cdf0e10cSrcweir m_pImpl->DoEnter(_bOk); 2073*cdf0e10cSrcweir } 2074*cdf0e10cSrcweir ::std::pair<RefButton*,RefEdit*> FormulaDlg::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton ) 2075*cdf0e10cSrcweir { 2076*cdf0e10cSrcweir return m_pImpl->RefInputStartBefore( pEdit, pButton ); 2077*cdf0e10cSrcweir } 2078*cdf0e10cSrcweir void FormulaDlg::RefInputStartAfter( RefEdit* pEdit, RefButton* pButton ) 2079*cdf0e10cSrcweir { 2080*cdf0e10cSrcweir m_pImpl->RefInputStartAfter( pEdit, pButton ); 2081*cdf0e10cSrcweir } 2082*cdf0e10cSrcweir void FormulaDlg::RefInputDoneAfter( sal_Bool bForced ) 2083*cdf0e10cSrcweir { 2084*cdf0e10cSrcweir m_pImpl->RefInputDoneAfter( bForced ); 2085*cdf0e10cSrcweir } 2086*cdf0e10cSrcweir 2087*cdf0e10cSrcweir rtl::OString FormulaDlg::FindFocusWin(Window *pWin) 2088*cdf0e10cSrcweir { 2089*cdf0e10cSrcweir return m_pImpl->FindFocusWin( pWin ); 2090*cdf0e10cSrcweir } 2091*cdf0e10cSrcweir 2092*cdf0e10cSrcweir void FormulaDlg::SetFocusWin(Window *pWin,const rtl::OString& nUniqueId) 2093*cdf0e10cSrcweir { 2094*cdf0e10cSrcweir if(pWin->GetUniqueId()==nUniqueId) 2095*cdf0e10cSrcweir { 2096*cdf0e10cSrcweir pWin->GrabFocus(); 2097*cdf0e10cSrcweir } 2098*cdf0e10cSrcweir else 2099*cdf0e10cSrcweir { 2100*cdf0e10cSrcweir sal_uInt16 nCount=pWin->GetChildCount(); 2101*cdf0e10cSrcweir 2102*cdf0e10cSrcweir for(sal_uInt16 i=0;i<nCount;i++) 2103*cdf0e10cSrcweir { 2104*cdf0e10cSrcweir Window* pChild=pWin->GetChild(i); 2105*cdf0e10cSrcweir SetFocusWin(pChild,nUniqueId); 2106*cdf0e10cSrcweir } 2107*cdf0e10cSrcweir } 2108*cdf0e10cSrcweir } 2109*cdf0e10cSrcweir 2110*cdf0e10cSrcweir 2111*cdf0e10cSrcweir long FormulaDlg::PreNotify( NotifyEvent& rNEvt ) 2112*cdf0e10cSrcweir { 2113*cdf0e10cSrcweir m_pImpl->PreNotify( rNEvt ); 2114*cdf0e10cSrcweir return SfxModelessDialog::PreNotify(rNEvt); 2115*cdf0e10cSrcweir } 2116*cdf0e10cSrcweir 2117*cdf0e10cSrcweir void FormulaDlg::HighlightFunctionParas(const String& aFormula) 2118*cdf0e10cSrcweir { 2119*cdf0e10cSrcweir m_pImpl->m_pHelper->showReference(aFormula); 2120*cdf0e10cSrcweir } 2121*cdf0e10cSrcweir 2122*cdf0e10cSrcweir void FormulaDlg::disableOk() 2123*cdf0e10cSrcweir { 2124*cdf0e10cSrcweir m_pImpl->aBtnEnd.Disable(); 2125*cdf0e10cSrcweir } 2126*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2127*cdf0e10cSrcweir const IFunctionDescription* FormulaDlg::getCurrentFunctionDescription() const 2128*cdf0e10cSrcweir { 2129*cdf0e10cSrcweir OSL_VERIFY(!m_pImpl->pFuncDesc || m_pImpl->pFuncDesc->getSuppressedArgumentCount() == m_pImpl->nArgs); 2130*cdf0e10cSrcweir return m_pImpl->pFuncDesc; 2131*cdf0e10cSrcweir } 2132*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2133*cdf0e10cSrcweir void FormulaDlg::UpdateParaWin(const Selection& _rSelection,const String& _sRefStr) 2134*cdf0e10cSrcweir { 2135*cdf0e10cSrcweir m_pImpl->UpdateParaWin(_rSelection,_sRefStr); 2136*cdf0e10cSrcweir } 2137*cdf0e10cSrcweir sal_Bool FormulaDlg::UpdateParaWin(Selection& _rSelection) 2138*cdf0e10cSrcweir { 2139*cdf0e10cSrcweir return m_pImpl->UpdateParaWin(_rSelection); 2140*cdf0e10cSrcweir } 2141*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2142*cdf0e10cSrcweir RefEdit* FormulaDlg::GetActiveEdit() 2143*cdf0e10cSrcweir { 2144*cdf0e10cSrcweir return m_pImpl->pParaWin->GetActiveEdit(); 2145*cdf0e10cSrcweir } 2146*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2147*cdf0e10cSrcweir const FormulaHelper& FormulaDlg::GetFormulaHelper() const 2148*cdf0e10cSrcweir { 2149*cdf0e10cSrcweir return m_pImpl->GetFormulaHelper(); 2150*cdf0e10cSrcweir } 2151*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2152*cdf0e10cSrcweir void FormulaDlg::SetEdSelection() 2153*cdf0e10cSrcweir { 2154*cdf0e10cSrcweir m_pImpl->SetEdSelection(); 2155*cdf0e10cSrcweir } 2156*cdf0e10cSrcweir IMPL_LINK( FormulaDlg, UpdateFocusHdl, Timer*, EMPTYARG ) 2157*cdf0e10cSrcweir { 2158*cdf0e10cSrcweir FormEditData* pData = m_pImpl->m_pHelper->getFormEditData(); 2159*cdf0e10cSrcweir 2160*cdf0e10cSrcweir if (pData) // wird nicht ueber Close zerstoert; 2161*cdf0e10cSrcweir { 2162*cdf0e10cSrcweir m_pImpl->m_pHelper->setReferenceInput(pData); 2163*cdf0e10cSrcweir rtl::OString nUniqueId(pData->GetUniqueId()); 2164*cdf0e10cSrcweir SetFocusWin(this,nUniqueId); 2165*cdf0e10cSrcweir } 2166*cdf0e10cSrcweir return 0; 2167*cdf0e10cSrcweir } 2168*cdf0e10cSrcweir 2169*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2170*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2171*cdf0e10cSrcweir void FormEditData::SaveValues() 2172*cdf0e10cSrcweir { 2173*cdf0e10cSrcweir FormEditData* pTemp = new FormEditData(*this); 2174*cdf0e10cSrcweir 2175*cdf0e10cSrcweir Reset(); 2176*cdf0e10cSrcweir pParent = pTemp; 2177*cdf0e10cSrcweir } 2178*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2179*cdf0e10cSrcweir void FormEditData::Reset() 2180*cdf0e10cSrcweir { 2181*cdf0e10cSrcweir pParent = NULL; 2182*cdf0e10cSrcweir nMode = 0; 2183*cdf0e10cSrcweir nFStart = 0; 2184*cdf0e10cSrcweir nCatSel = 1; //! oder 0 (zuletzt benutzte) 2185*cdf0e10cSrcweir nFuncSel = 0; 2186*cdf0e10cSrcweir nOffset = 0; 2187*cdf0e10cSrcweir nEdFocus = 0; 2188*cdf0e10cSrcweir bMatrix =sal_False; 2189*cdf0e10cSrcweir aUniqueId=rtl::OString(); 2190*cdf0e10cSrcweir aSelection.Min()=0; 2191*cdf0e10cSrcweir aSelection.Max()=0; 2192*cdf0e10cSrcweir aUndoStr.Erase(); 2193*cdf0e10cSrcweir } 2194*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2195*cdf0e10cSrcweir void FormEditData::RestoreValues() 2196*cdf0e10cSrcweir { 2197*cdf0e10cSrcweir FormEditData* pTemp = pParent; 2198*cdf0e10cSrcweir DBG_ASSERT(pTemp,"RestoreValues ohne Parent"); 2199*cdf0e10cSrcweir if (pTemp) 2200*cdf0e10cSrcweir { 2201*cdf0e10cSrcweir *this = *pTemp; 2202*cdf0e10cSrcweir pTemp->pParent = NULL; // sonst wird der auch geloescht! 2203*cdf0e10cSrcweir delete pTemp; 2204*cdf0e10cSrcweir } 2205*cdf0e10cSrcweir } 2206*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2207*cdf0e10cSrcweir const FormEditData& FormEditData::operator=( const FormEditData& r ) 2208*cdf0e10cSrcweir { 2209*cdf0e10cSrcweir pParent = r.pParent; 2210*cdf0e10cSrcweir nMode = r.nMode; 2211*cdf0e10cSrcweir nFStart = r.nFStart; 2212*cdf0e10cSrcweir nCatSel = r.nCatSel; 2213*cdf0e10cSrcweir nFuncSel = r.nFuncSel; 2214*cdf0e10cSrcweir nOffset = r.nOffset; 2215*cdf0e10cSrcweir nEdFocus = r.nEdFocus; 2216*cdf0e10cSrcweir aUndoStr = r.aUndoStr; 2217*cdf0e10cSrcweir bMatrix = r.bMatrix ; 2218*cdf0e10cSrcweir aUniqueId = r.aUniqueId; 2219*cdf0e10cSrcweir aSelection = r.aSelection; 2220*cdf0e10cSrcweir return *this; 2221*cdf0e10cSrcweir } 2222*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2223*cdf0e10cSrcweir FormEditData::FormEditData() 2224*cdf0e10cSrcweir { 2225*cdf0e10cSrcweir Reset(); 2226*cdf0e10cSrcweir } 2227*cdf0e10cSrcweir 2228*cdf0e10cSrcweir FormEditData::~FormEditData() 2229*cdf0e10cSrcweir { 2230*cdf0e10cSrcweir delete pParent; 2231*cdf0e10cSrcweir } 2232*cdf0e10cSrcweir 2233*cdf0e10cSrcweir FormEditData::FormEditData( const FormEditData& r ) 2234*cdf0e10cSrcweir { 2235*cdf0e10cSrcweir *this = r; 2236*cdf0e10cSrcweir } 2237*cdf0e10cSrcweir 2238*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2239*cdf0e10cSrcweir } // formula 2240*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2241