LCOV - code coverage report
Current view: top level - formula/source/ui/dlg - formula.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 948 0.0 %
Date: 2012-08-25 Functions: 0 107 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1634 0.0 %

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

Generated by: LCOV version 1.10