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